repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
thephpleague/monga
src/League/Monga/Query/Where.php
Where.notWhere
public function notWhere($clause, $type = '$and') { if ($clause instanceof Closure) { $query = new static(); $clause($query); $clause = $query->getWhere(); if (empty($clause)) { return $this; } } if (! is_array($clause)) { throw new \InvalidArgumentException('$not statements should be Closures or arrays.'); } return $this->formatWhere($type, '$not', [$clause]); }
php
public function notWhere($clause, $type = '$and') { if ($clause instanceof Closure) { $query = new static(); $clause($query); $clause = $query->getWhere(); if (empty($clause)) { return $this; } } if (! is_array($clause)) { throw new \InvalidArgumentException('$not statements should be Closures or arrays.'); } return $this->formatWhere($type, '$not', [$clause]); }
[ "public", "function", "notWhere", "(", "$", "clause", ",", "$", "type", "=", "'$and'", ")", "{", "if", "(", "$", "clause", "instanceof", "Closure", ")", "{", "$", "query", "=", "new", "static", "(", ")", ";", "$", "clause", "(", "$", "query", ")", ";", "$", "clause", "=", "$", "query", "->", "getWhere", "(", ")", ";", "if", "(", "empty", "(", "$", "clause", ")", ")", "{", "return", "$", "this", ";", "}", "}", "if", "(", "!", "is_array", "(", "$", "clause", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$not statements should be Closures or arrays.'", ")", ";", "}", "return", "$", "this", "->", "formatWhere", "(", "$", "type", ",", "'$not'", ",", "[", "$", "clause", "]", ")", ";", "}" ]
Appends a and-not-where-clause @param array|closure $clause nor where clause @param integer $type chain type @return object $this
[ "Appends", "a", "and", "-", "not", "-", "where", "-", "clause" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L1033-L1050
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.getWhere
public function getWhere() { $where = $this->where; if (! $where) { return []; } foreach ($where['$or'] as &$and) { if (isset($and['$and']) && count($and['$and']) === 1) { $and = reset($and['$and']); } if (isset($and['$or']) && count($and['$or']) === 1) { $and = reset($and['$or']); } } if (count($where['$or']) === 1) { $where = reset($where['$or']); } return $where; }
php
public function getWhere() { $where = $this->where; if (! $where) { return []; } foreach ($where['$or'] as &$and) { if (isset($and['$and']) && count($and['$and']) === 1) { $and = reset($and['$and']); } if (isset($and['$or']) && count($and['$or']) === 1) { $and = reset($and['$or']); } } if (count($where['$or']) === 1) { $where = reset($where['$or']); } return $where; }
[ "public", "function", "getWhere", "(", ")", "{", "$", "where", "=", "$", "this", "->", "where", ";", "if", "(", "!", "$", "where", ")", "{", "return", "[", "]", ";", "}", "foreach", "(", "$", "where", "[", "'$or'", "]", "as", "&", "$", "and", ")", "{", "if", "(", "isset", "(", "$", "and", "[", "'$and'", "]", ")", "&&", "count", "(", "$", "and", "[", "'$and'", "]", ")", "===", "1", ")", "{", "$", "and", "=", "reset", "(", "$", "and", "[", "'$and'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "and", "[", "'$or'", "]", ")", "&&", "count", "(", "$", "and", "[", "'$or'", "]", ")", "===", "1", ")", "{", "$", "and", "=", "reset", "(", "$", "and", "[", "'$or'", "]", ")", ";", "}", "}", "if", "(", "count", "(", "$", "where", "[", "'$or'", "]", ")", "===", "1", ")", "{", "$", "where", "=", "reset", "(", "$", "where", "[", "'$or'", "]", ")", ";", "}", "return", "$", "where", ";", "}" ]
Retrieve the formatted where filter @return array filter query
[ "Retrieve", "the", "formatted", "where", "filter" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L1081-L1104
train
thephpleague/monga
src/League/Monga/Query/Where.php
Where.resolveType
public function resolveType($type) { if (is_numeric($type)) { return (int) $type; } $type = strtoupper($type); static $types = [ 'DOUBLE' => 1, 'STRING' => 2, 'OBJECT' => 3, 'ARRAY' => 4, 'BINARY' => 5, 'ID' => 8, 'BOOL' => 8, 'BOOLEAN' => 8, 'DATE' => 9, 'NULL' => 10, 'REGEX' => 11, 'JAVASCRIPT' => 13, 'CODE' => 13, 'SYMBOL' => 14, 'JAVASCRIPT_SCOPE' => 15, 'CODE_SCOPE' => 15, 'INT32' => 16, 'TS' => 17, 'TIMESTAMP' => 17, 'INT64' => 18, 'MIN' => -1, 'MAX' => 127, ]; if (! isset($types[$type])) { throw new \InvalidArgumentException('Type "'.$type.'" could not be resolved'); } return $types[$type]; }
php
public function resolveType($type) { if (is_numeric($type)) { return (int) $type; } $type = strtoupper($type); static $types = [ 'DOUBLE' => 1, 'STRING' => 2, 'OBJECT' => 3, 'ARRAY' => 4, 'BINARY' => 5, 'ID' => 8, 'BOOL' => 8, 'BOOLEAN' => 8, 'DATE' => 9, 'NULL' => 10, 'REGEX' => 11, 'JAVASCRIPT' => 13, 'CODE' => 13, 'SYMBOL' => 14, 'JAVASCRIPT_SCOPE' => 15, 'CODE_SCOPE' => 15, 'INT32' => 16, 'TS' => 17, 'TIMESTAMP' => 17, 'INT64' => 18, 'MIN' => -1, 'MAX' => 127, ]; if (! isset($types[$type])) { throw new \InvalidArgumentException('Type "'.$type.'" could not be resolved'); } return $types[$type]; }
[ "public", "function", "resolveType", "(", "$", "type", ")", "{", "if", "(", "is_numeric", "(", "$", "type", ")", ")", "{", "return", "(", "int", ")", "$", "type", ";", "}", "$", "type", "=", "strtoupper", "(", "$", "type", ")", ";", "static", "$", "types", "=", "[", "'DOUBLE'", "=>", "1", ",", "'STRING'", "=>", "2", ",", "'OBJECT'", "=>", "3", ",", "'ARRAY'", "=>", "4", ",", "'BINARY'", "=>", "5", ",", "'ID'", "=>", "8", ",", "'BOOL'", "=>", "8", ",", "'BOOLEAN'", "=>", "8", ",", "'DATE'", "=>", "9", ",", "'NULL'", "=>", "10", ",", "'REGEX'", "=>", "11", ",", "'JAVASCRIPT'", "=>", "13", ",", "'CODE'", "=>", "13", ",", "'SYMBOL'", "=>", "14", ",", "'JAVASCRIPT_SCOPE'", "=>", "15", ",", "'CODE_SCOPE'", "=>", "15", ",", "'INT32'", "=>", "16", ",", "'TS'", "=>", "17", ",", "'TIMESTAMP'", "=>", "17", ",", "'INT64'", "=>", "18", ",", "'MIN'", "=>", "-", "1", ",", "'MAX'", "=>", "127", ",", "]", ";", "if", "(", "!", "isset", "(", "$", "types", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Type \"'", ".", "$", "type", ".", "'\" could not be resolved'", ")", ";", "}", "return", "$", "types", "[", "$", "type", "]", ";", "}" ]
Resolves a string data type to its integer counterpart @param string|int $type data type @return int The data type's integer
[ "Resolves", "a", "string", "data", "type", "to", "its", "integer", "counterpart" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Where.php#L1113-L1135
train
thephpleague/monga
src/League/Monga/Query/Builder.php
Builder.setOptions
public function setOptions(array $options) { foreach ($options as $option => $value) { if (property_exists($this, $option)) { $this->{$option} = $value; } } return $this; }
php
public function setOptions(array $options) { foreach ($options as $option => $value) { if (property_exists($this, $option)) { $this->{$option} = $value; } } return $this; }
[ "public", "function", "setOptions", "(", "array", "$", "options", ")", "{", "foreach", "(", "$", "options", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "option", ")", ")", "{", "$", "this", "->", "{", "$", "option", "}", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Inject query options @param array $options query options @return object $this
[ "Inject", "query", "options" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Builder.php#L97-L106
train
thephpleague/monga
src/League/Monga/Query/Find.php
Find.orderBy
public function orderBy($field, $direction = 1) { if (is_string($direction)) { $direction = $direction === 'asc' ? 1 : -1; } $this->orderBy[$field] = $direction; return $this; }
php
public function orderBy($field, $direction = 1) { if (is_string($direction)) { $direction = $direction === 'asc' ? 1 : -1; } $this->orderBy[$field] = $direction; return $this; }
[ "public", "function", "orderBy", "(", "$", "field", ",", "$", "direction", "=", "1", ")", "{", "if", "(", "is_string", "(", "$", "direction", ")", ")", "{", "$", "direction", "=", "$", "direction", "===", "'asc'", "?", "1", ":", "-", "1", ";", "}", "$", "this", "->", "orderBy", "[", "$", "field", "]", "=", "$", "direction", ";", "return", "$", "this", ";", "}" ]
Orders a collection @param string $field field to order by @param string $direction asc/desc/1/-1 @return object current instance
[ "Orders", "a", "collection" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Find.php#L78-L87
train
thephpleague/monga
src/League/Monga/Query/Find.php
Find.select
public function select($field) { $fields = (is_array($field) ? $field : func_get_args()); foreach ((array) $fields as $field) { $this->fields[$field] = 1; } }
php
public function select($field) { $fields = (is_array($field) ? $field : func_get_args()); foreach ((array) $fields as $field) { $this->fields[$field] = 1; } }
[ "public", "function", "select", "(", "$", "field", ")", "{", "$", "fields", "=", "(", "is_array", "(", "$", "field", ")", "?", "$", "field", ":", "func_get_args", "(", ")", ")", ";", "foreach", "(", "(", "array", ")", "$", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "fields", "[", "$", "field", "]", "=", "1", ";", "}", "}" ]
Specifies fields to select @param mixed $field field(s) to select @return object current instance
[ "Specifies", "fields", "to", "select" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Find.php#L96-L103
train
thephpleague/monga
src/League/Monga/Query/Find.php
Find.exclude
public function exclude($field) { $fields = (is_array($field) ? $field : func_get_args()); foreach ($fields as $field) { $this->fields[$field] = -1; } }
php
public function exclude($field) { $fields = (is_array($field) ? $field : func_get_args()); foreach ($fields as $field) { $this->fields[$field] = -1; } }
[ "public", "function", "exclude", "(", "$", "field", ")", "{", "$", "fields", "=", "(", "is_array", "(", "$", "field", ")", "?", "$", "field", ":", "func_get_args", "(", ")", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "fields", "[", "$", "field", "]", "=", "-", "1", ";", "}", "}" ]
Specifies fields to exclude @param mixed $field field(s) to exclude @return object current instance
[ "Specifies", "fields", "to", "exclude" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Find.php#L112-L119
train
thephpleague/monga
src/League/Monga/Query/Find.php
Find.getPostFindActions
public function getPostFindActions() { $actions = []; empty($this->orderBy) || $actions[] = ['sort', $this->orderBy]; $this->skip === null || $actions[] = ['skip', $this->skip]; $this->limit === null || $actions[] = ['limit', $this->limit]; return $actions; }
php
public function getPostFindActions() { $actions = []; empty($this->orderBy) || $actions[] = ['sort', $this->orderBy]; $this->skip === null || $actions[] = ['skip', $this->skip]; $this->limit === null || $actions[] = ['limit', $this->limit]; return $actions; }
[ "public", "function", "getPostFindActions", "(", ")", "{", "$", "actions", "=", "[", "]", ";", "empty", "(", "$", "this", "->", "orderBy", ")", "||", "$", "actions", "[", "]", "=", "[", "'sort'", ",", "$", "this", "->", "orderBy", "]", ";", "$", "this", "->", "skip", "===", "null", "||", "$", "actions", "[", "]", "=", "[", "'skip'", ",", "$", "this", "->", "skip", "]", ";", "$", "this", "->", "limit", "===", "null", "||", "$", "actions", "[", "]", "=", "[", "'limit'", ",", "$", "this", "->", "limit", "]", ";", "return", "$", "actions", ";", "}" ]
Get the post-find actions. @return array post-find actions
[ "Get", "the", "post", "-", "find", "actions", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Find.php#L180-L189
train
thephpleague/monga
src/League/Monga/Query/Indexes.php
Indexes.prepareIndex
protected function prepareIndex($index) { foreach ($index as &$value) { // Convert ascending $value = $value === 'asc' ? 1 : $value; // Convert descending $value = $value === 'desc' ? -1 : $value; // Convert geo to 2d $value = $value === 'geo' ? '2d' : $value; } return $index; }
php
protected function prepareIndex($index) { foreach ($index as &$value) { // Convert ascending $value = $value === 'asc' ? 1 : $value; // Convert descending $value = $value === 'desc' ? -1 : $value; // Convert geo to 2d $value = $value === 'geo' ? '2d' : $value; } return $index; }
[ "protected", "function", "prepareIndex", "(", "$", "index", ")", "{", "foreach", "(", "$", "index", "as", "&", "$", "value", ")", "{", "// Convert ascending", "$", "value", "=", "$", "value", "===", "'asc'", "?", "1", ":", "$", "value", ";", "// Convert descending", "$", "value", "=", "$", "value", "===", "'desc'", "?", "-", "1", ":", "$", "value", ";", "// Convert geo to 2d", "$", "value", "=", "$", "value", "===", "'geo'", "?", "'2d'", ":", "$", "value", ";", "}", "return", "$", "index", ";", "}" ]
Prepate an index, allowing more expressive syntax. @param object $index index @return object $index prepared index
[ "Prepate", "an", "index", "allowing", "more", "expressive", "syntax", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Indexes.php#L92-L106
train
thephpleague/monga
src/League/Monga/Query/Indexes.php
Indexes.drop
public function drop($index) { $indexes = func_get_args(); foreach ($indexes as $index) { $index = is_array($index) ? $this->prepareIndex($index) : $index; $this->collection->deleteIndex($index); } return $this; }
php
public function drop($index) { $indexes = func_get_args(); foreach ($indexes as $index) { $index = is_array($index) ? $this->prepareIndex($index) : $index; $this->collection->deleteIndex($index); } return $this; }
[ "public", "function", "drop", "(", "$", "index", ")", "{", "$", "indexes", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "$", "index", "=", "is_array", "(", "$", "index", ")", "?", "$", "this", "->", "prepareIndex", "(", "$", "index", ")", ":", "$", "index", ";", "$", "this", "->", "collection", "->", "deleteIndex", "(", "$", "index", ")", ";", "}", "return", "$", "this", ";", "}" ]
Drop one or more indexes @param mixed $index string index name or index @return object $this
[ "Drop", "one", "or", "more", "indexes" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Indexes.php#L115-L126
train
thephpleague/monga
src/League/Monga/Query/Aggregation.php
Aggregation.project
public function project($projection) { if ($projection instanceof Closure) { $callback = $projection; $projection = new Projection(); $callback($projection); } if ($projection instanceof Projection) { $projection = $projection->getProjection(); } $this->pipeline[] = ['$project' => $projection]; return $this; }
php
public function project($projection) { if ($projection instanceof Closure) { $callback = $projection; $projection = new Projection(); $callback($projection); } if ($projection instanceof Projection) { $projection = $projection->getProjection(); } $this->pipeline[] = ['$project' => $projection]; return $this; }
[ "public", "function", "project", "(", "$", "projection", ")", "{", "if", "(", "$", "projection", "instanceof", "Closure", ")", "{", "$", "callback", "=", "$", "projection", ";", "$", "projection", "=", "new", "Projection", "(", ")", ";", "$", "callback", "(", "$", "projection", ")", ";", "}", "if", "(", "$", "projection", "instanceof", "Projection", ")", "{", "$", "projection", "=", "$", "projection", "->", "getProjection", "(", ")", ";", "}", "$", "this", "->", "pipeline", "[", "]", "=", "[", "'$project'", "=>", "$", "projection", "]", ";", "return", "$", "this", ";", "}" ]
Project the results. @param array $projection projection @return object $this
[ "Project", "the", "results", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Aggregation.php#L31-L46
train
thephpleague/monga
src/League/Monga/Query/Aggregation.php
Aggregation.group
public function group($group) { if ($group instanceof Closure) { $callback = $group; $group = new Group(); is_callable('Closure::bind') && $callback = $callback->bindTo($group, $group); $callback($group); } if ($group instanceof Group) { $group = $group->getGroup(); } $this->pipeline[] = ['$group' => $group]; return $this; }
php
public function group($group) { if ($group instanceof Closure) { $callback = $group; $group = new Group(); is_callable('Closure::bind') && $callback = $callback->bindTo($group, $group); $callback($group); } if ($group instanceof Group) { $group = $group->getGroup(); } $this->pipeline[] = ['$group' => $group]; return $this; }
[ "public", "function", "group", "(", "$", "group", ")", "{", "if", "(", "$", "group", "instanceof", "Closure", ")", "{", "$", "callback", "=", "$", "group", ";", "$", "group", "=", "new", "Group", "(", ")", ";", "is_callable", "(", "'Closure::bind'", ")", "&&", "$", "callback", "=", "$", "callback", "->", "bindTo", "(", "$", "group", ",", "$", "group", ")", ";", "$", "callback", "(", "$", "group", ")", ";", "}", "if", "(", "$", "group", "instanceof", "Group", ")", "{", "$", "group", "=", "$", "group", "->", "getGroup", "(", ")", ";", "}", "$", "this", "->", "pipeline", "[", "]", "=", "[", "'$group'", "=>", "$", "group", "]", ";", "return", "$", "this", ";", "}" ]
Group the results. @param mixed $projection projection array / closure / Query\Group instance @return object $this
[ "Group", "the", "results", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Aggregation.php#L55-L71
train
thephpleague/monga
src/League/Monga/Query/Aggregation.php
Aggregation.match
public function match($filter) { if ($filter instanceof Closure) { // Store the callback $callback = $filter; // Set a new Where filter $filter = new Where(); // Execute the callback $callback($filter); } if ($filter instanceof Where) { $filter = $filter->getWhere(); } $this->pipeline[] = ['$match' => $filter]; return $this; }
php
public function match($filter) { if ($filter instanceof Closure) { // Store the callback $callback = $filter; // Set a new Where filter $filter = new Where(); // Execute the callback $callback($filter); } if ($filter instanceof Where) { $filter = $filter->getWhere(); } $this->pipeline[] = ['$match' => $filter]; return $this; }
[ "public", "function", "match", "(", "$", "filter", ")", "{", "if", "(", "$", "filter", "instanceof", "Closure", ")", "{", "// Store the callback", "$", "callback", "=", "$", "filter", ";", "// Set a new Where filter", "$", "filter", "=", "new", "Where", "(", ")", ";", "// Execute the callback", "$", "callback", "(", "$", "filter", ")", ";", "}", "if", "(", "$", "filter", "instanceof", "Where", ")", "{", "$", "filter", "=", "$", "filter", "->", "getWhere", "(", ")", ";", "}", "$", "this", "->", "pipeline", "[", "]", "=", "[", "'$match'", "=>", "$", "filter", "]", ";", "return", "$", "this", ";", "}" ]
Add a match operation to the pipeline @param mixed $filter filter array / filter callback / Query\Where instance @return object $this
[ "Add", "a", "match", "operation", "to", "the", "pipeline" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Aggregation.php#L136-L156
train
thephpleague/monga
src/League/Monga/Query/Computer.php
Computer.sum
public function sum($result, $field = 1) { $field = $this->prepareField($field); $this->fields[$result] = ['$sum' => $field]; return $this; }
php
public function sum($result, $field = 1) { $field = $this->prepareField($field); $this->fields[$result] = ['$sum' => $field]; return $this; }
[ "public", "function", "sum", "(", "$", "result", ",", "$", "field", "=", "1", ")", "{", "$", "field", "=", "$", "this", "->", "prepareField", "(", "$", "field", ")", ";", "$", "this", "->", "fields", "[", "$", "result", "]", "=", "[", "'$sum'", "=>", "$", "field", "]", ";", "return", "$", "this", ";", "}" ]
Aggregate a sum from a field. @param string $result result key @param mixed $field field to take the sum from, 1 for totals @return object $this
[ "Aggregate", "a", "sum", "from", "a", "field", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Computer.php#L30-L37
train
thephpleague/monga
src/League/Monga/Query/Computer.php
Computer.addToSet
public function addToSet($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$addToSet' => $field]; return $this; }
php
public function addToSet($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$addToSet' => $field]; return $this; }
[ "public", "function", "addToSet", "(", "$", "result", ",", "$", "field", "=", "null", ")", "{", "$", "field", "=", "$", "this", "->", "prepareField", "(", "$", "field", "?", ":", "$", "result", ")", ";", "$", "this", "->", "fields", "[", "$", "result", "]", "=", "[", "'$addToSet'", "=>", "$", "field", "]", ";", "return", "$", "this", ";", "}" ]
Aggregate a unique set of values. @param string $result result key @param string $field field to generate the set from @return object $this
[ "Aggregate", "a", "unique", "set", "of", "values", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Computer.php#L47-L54
train
thephpleague/monga
src/League/Monga/Query/Computer.php
Computer.first
public function first($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$first' => $field]; return $this; }
php
public function first($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$first' => $field]; return $this; }
[ "public", "function", "first", "(", "$", "result", ",", "$", "field", "=", "null", ")", "{", "$", "field", "=", "$", "this", "->", "prepareField", "(", "$", "field", "?", ":", "$", "result", ")", ";", "$", "this", "->", "fields", "[", "$", "result", "]", "=", "[", "'$first'", "=>", "$", "field", "]", ";", "return", "$", "this", ";", "}" ]
Aggregate the first value of a set. @param string $result result key @param string $field field to generate get the first from @return object $this
[ "Aggregate", "the", "first", "value", "of", "a", "set", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Computer.php#L64-L71
train
thephpleague/monga
src/League/Monga/Query/Computer.php
Computer.last
public function last($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$last' => $field]; return $this; }
php
public function last($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$last' => $field]; return $this; }
[ "public", "function", "last", "(", "$", "result", ",", "$", "field", "=", "null", ")", "{", "$", "field", "=", "$", "this", "->", "prepareField", "(", "$", "field", "?", ":", "$", "result", ")", ";", "$", "this", "->", "fields", "[", "$", "result", "]", "=", "[", "'$last'", "=>", "$", "field", "]", ";", "return", "$", "this", ";", "}" ]
Aggregate the last value of a set. @param string $result result key @param string $field field to generate get the last from @return object $this
[ "Aggregate", "the", "last", "value", "of", "a", "set", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Computer.php#L81-L88
train
thephpleague/monga
src/League/Monga/Query/Computer.php
Computer.max
public function max($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$max' => $field]; return $this; }
php
public function max($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$max' => $field]; return $this; }
[ "public", "function", "max", "(", "$", "result", ",", "$", "field", "=", "null", ")", "{", "$", "field", "=", "$", "this", "->", "prepareField", "(", "$", "field", "?", ":", "$", "result", ")", ";", "$", "this", "->", "fields", "[", "$", "result", "]", "=", "[", "'$max'", "=>", "$", "field", "]", ";", "return", "$", "this", ";", "}" ]
Aggregate the max value of a set. @param string $result result key @param string $field field to generate get the max from @return object $this
[ "Aggregate", "the", "max", "value", "of", "a", "set", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Computer.php#L98-L105
train
thephpleague/monga
src/League/Monga/Query/Computer.php
Computer.min
public function min($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$min' => $field]; return $this; }
php
public function min($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$min' => $field]; return $this; }
[ "public", "function", "min", "(", "$", "result", ",", "$", "field", "=", "null", ")", "{", "$", "field", "=", "$", "this", "->", "prepareField", "(", "$", "field", "?", ":", "$", "result", ")", ";", "$", "this", "->", "fields", "[", "$", "result", "]", "=", "[", "'$min'", "=>", "$", "field", "]", ";", "return", "$", "this", ";", "}" ]
Aggregate the min value of a set. @param string $result result key @param string $field field to generate get the min from @return object $this
[ "Aggregate", "the", "min", "value", "of", "a", "set", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Computer.php#L115-L122
train
thephpleague/monga
src/League/Monga/Query/Computer.php
Computer.push
public function push($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$push' => $field]; return $this; }
php
public function push($result, $field = null) { $field = $this->prepareField($field ?: $result); $this->fields[$result] = ['$push' => $field]; return $this; }
[ "public", "function", "push", "(", "$", "result", ",", "$", "field", "=", "null", ")", "{", "$", "field", "=", "$", "this", "->", "prepareField", "(", "$", "field", "?", ":", "$", "result", ")", ";", "$", "this", "->", "fields", "[", "$", "result", "]", "=", "[", "'$push'", "=>", "$", "field", "]", ";", "return", "$", "this", ";", "}" ]
Aggregate the all the values of a given key. @param string $result result key @param string $field field to get all the values from @return object $this
[ "Aggregate", "the", "all", "the", "values", "of", "a", "given", "key", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Query/Computer.php#L132-L139
train
thephpleague/monga
src/League/Monga/Database.php
Database.allCollections
public function allCollections($wrap = false) { $collections = $this->database->listCollections(); if (! $wrap) { return $collections; } return array_map( function ($collection) { return new Collection($collection); }, $collections ); }
php
public function allCollections($wrap = false) { $collections = $this->database->listCollections(); if (! $wrap) { return $collections; } return array_map( function ($collection) { return new Collection($collection); }, $collections ); }
[ "public", "function", "allCollections", "(", "$", "wrap", "=", "false", ")", "{", "$", "collections", "=", "$", "this", "->", "database", "->", "listCollections", "(", ")", ";", "if", "(", "!", "$", "wrap", ")", "{", "return", "$", "collections", ";", "}", "return", "array_map", "(", "function", "(", "$", "collection", ")", "{", "return", "new", "Collection", "(", "$", "collection", ")", ";", "}", ",", "$", "collections", ")", ";", "}" ]
Returns all collection. @param boolean $wrap whether to wrap the collection instances in Collection classes. @return array connections array
[ "Returns", "all", "collection", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Database.php#L73-L87
train
thephpleague/monga
src/League/Monga/Database.php
Database.collection
public function collection($collection, $wrap = true) { $collection = $this->database->selectCollection($collection); $wrap && $collection = new Collection($collection); return $collection; }
php
public function collection($collection, $wrap = true) { $collection = $this->database->selectCollection($collection); $wrap && $collection = new Collection($collection); return $collection; }
[ "public", "function", "collection", "(", "$", "collection", ",", "$", "wrap", "=", "true", ")", "{", "$", "collection", "=", "$", "this", "->", "database", "->", "selectCollection", "(", "$", "collection", ")", ";", "$", "wrap", "&&", "$", "collection", "=", "new", "Collection", "(", "$", "collection", ")", ";", "return", "$", "collection", ";", "}" ]
Retrieve a collection @param string $collection collection name @param boolean $wrap whether to wrap it in a Collection class. @return mixed Collection instance or MongoCollection instance.
[ "Retrieve", "a", "collection" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Database.php#L148-L154
train
thephpleague/monga
src/League/Monga/Database.php
Database.filesystem
public function filesystem($prefix = 'fs', $wrap = true) { $collection = $this->database->getGridFS($prefix); $wrap && $collection = new Filesystem($collection); return $collection; }
php
public function filesystem($prefix = 'fs', $wrap = true) { $collection = $this->database->getGridFS($prefix); $wrap && $collection = new Filesystem($collection); return $collection; }
[ "public", "function", "filesystem", "(", "$", "prefix", "=", "'fs'", ",", "$", "wrap", "=", "true", ")", "{", "$", "collection", "=", "$", "this", "->", "database", "->", "getGridFS", "(", "$", "prefix", ")", ";", "$", "wrap", "&&", "$", "collection", "=", "new", "Filesystem", "(", "$", "collection", ")", ";", "return", "$", "collection", ";", "}" ]
Retrieve a GridFS object @param string $prefix collection name @param boolean $wrap whether to wrap it in a Collection class. @return mixed Collection instance or MongoCollection instance.
[ "Retrieve", "a", "GridFS", "object" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Database.php#L164-L170
train
thephpleague/monga
src/League/Monga/Database.php
Database.getRef
public function getRef($reference) { $array = ! isset($reference['$ref']); $reference = $array ? $reference : [$reference]; $database = $this->database; $result = array_map( function ($ref) use ($database) { return MongoDBRef::get($database, $ref); }, $reference ); return $array ? $result : reset($result); }
php
public function getRef($reference) { $array = ! isset($reference['$ref']); $reference = $array ? $reference : [$reference]; $database = $this->database; $result = array_map( function ($ref) use ($database) { return MongoDBRef::get($database, $ref); }, $reference ); return $array ? $result : reset($result); }
[ "public", "function", "getRef", "(", "$", "reference", ")", "{", "$", "array", "=", "!", "isset", "(", "$", "reference", "[", "'$ref'", "]", ")", ";", "$", "reference", "=", "$", "array", "?", "$", "reference", ":", "[", "$", "reference", "]", ";", "$", "database", "=", "$", "this", "->", "database", ";", "$", "result", "=", "array_map", "(", "function", "(", "$", "ref", ")", "use", "(", "$", "database", ")", "{", "return", "MongoDBRef", "::", "get", "(", "$", "database", ",", "$", "ref", ")", ";", "}", ",", "$", "reference", ")", ";", "return", "$", "array", "?", "$", "result", ":", "reset", "(", "$", "result", ")", ";", "}" ]
Retrieve one or more references from the database. @param object|array $reference one or more references @return array one or more documents
[ "Retrieve", "one", "or", "more", "references", "from", "the", "database", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Database.php#L191-L205
train
thephpleague/monga
src/League/Monga/Database.php
Database.executeCode
public function executeCode($code, array $arguments = []) { if (! ($code instanceof MongoCode)) { $code = new MongoCode($code); } return $this->database->execute($code, $arguments); }
php
public function executeCode($code, array $arguments = []) { if (! ($code instanceof MongoCode)) { $code = new MongoCode($code); } return $this->database->execute($code, $arguments); }
[ "public", "function", "executeCode", "(", "$", "code", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "if", "(", "!", "(", "$", "code", "instanceof", "MongoCode", ")", ")", "{", "$", "code", "=", "new", "MongoCode", "(", "$", "code", ")", ";", "}", "return", "$", "this", "->", "database", "->", "execute", "(", "$", "code", ",", "$", "arguments", ")", ";", "}" ]
Execute javascript on the database @param mixed $code MongoCode or javascript string @param array $arguments function arguments @return mixed result
[ "Execute", "javascript", "on", "the", "database" ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Database.php#L215-L222
train
thephpleague/monga
src/League/Monga/Filesystem.php
Filesystem.storeBytes
public function storeBytes($bytes, $metadata = [], $options = []) { return $this->collection->storeBytes($bytes, $metadata, $options); }
php
public function storeBytes($bytes, $metadata = [], $options = []) { return $this->collection->storeBytes($bytes, $metadata, $options); }
[ "public", "function", "storeBytes", "(", "$", "bytes", ",", "$", "metadata", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "collection", "->", "storeBytes", "(", "$", "bytes", ",", "$", "metadata", ",", "$", "options", ")", ";", "}" ]
Store a set of bytes. @param string $bytes bytes @param array $metadata metadata @param array $options options @return object MongoId object
[ "Store", "a", "set", "of", "bytes", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Filesystem.php#L56-L59
train
thephpleague/monga
src/League/Monga/Filesystem.php
Filesystem.extract
public function extract($name, $destination = null) { $file = $this->findOne($name); if (! $file || ! $file->write($destination)) { return false; } return (bool) $this->collection->remove(['_id' => $file->file['_id']]); }
php
public function extract($name, $destination = null) { $file = $this->findOne($name); if (! $file || ! $file->write($destination)) { return false; } return (bool) $this->collection->remove(['_id' => $file->file['_id']]); }
[ "public", "function", "extract", "(", "$", "name", ",", "$", "destination", "=", "null", ")", "{", "$", "file", "=", "$", "this", "->", "findOne", "(", "$", "name", ")", ";", "if", "(", "!", "$", "file", "||", "!", "$", "file", "->", "write", "(", "$", "destination", ")", ")", "{", "return", "false", ";", "}", "return", "(", "bool", ")", "$", "this", "->", "collection", "->", "remove", "(", "[", "'_id'", "=>", "$", "file", "->", "file", "[", "'_id'", "]", "]", ")", ";", "}" ]
Extracts a file from the database, writes it to disc, and removes it from the database. @param string $name file name @param string $destination new location, optional @return boolean success boolean
[ "Extracts", "a", "file", "from", "the", "database", "writes", "it", "to", "disc", "and", "removes", "it", "from", "the", "database", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Filesystem.php#L98-L107
train
thephpleague/monga
src/League/Monga/Filesystem.php
Filesystem.findOne
public function findOne($query = [], $fields = []) { if (is_string($query)) { return $this->collection->findOne($query, $fields = []); } return parent::findOne($query, $fields); }
php
public function findOne($query = [], $fields = []) { if (is_string($query)) { return $this->collection->findOne($query, $fields = []); } return parent::findOne($query, $fields); }
[ "public", "function", "findOne", "(", "$", "query", "=", "[", "]", ",", "$", "fields", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "query", ")", ")", "{", "return", "$", "this", "->", "collection", "->", "findOne", "(", "$", "query", ",", "$", "fields", "=", "[", "]", ")", ";", "}", "return", "parent", "::", "findOne", "(", "$", "query", ",", "$", "fields", ")", ";", "}" ]
Finds one file. @param mixed $query filename or search query @param array $fields metadata fields select/exclude statement @return object|null MongoGridFSFile instance or null when not found.
[ "Finds", "one", "file", "." ]
4df18d949087f6ab2826bc303463382148c3c440
https://github.com/thephpleague/monga/blob/4df18d949087f6ab2826bc303463382148c3c440/src/League/Monga/Filesystem.php#L117-L124
train
yzalis/UAParser
src/UAParser/UAParser.php
UAParser.parseOperatingsystem
protected function parseOperatingsystem($userAgent) { $result = array( 'family' => 'Other', 'major' => null, 'minor' => null, 'patch' => null, ); if (!isset($this->regexes['operating_system_parsers'])) { return $result; } foreach ($this->regexes['operating_system_parsers'] as $expression) { if (preg_match('/'.str_replace('/','\/',str_replace('\/','/', $expression['regex'])).'/i', $userAgent, $matches)) { if (!isset($matches[1])) { $matches[1] = 'Other'; } if (!isset($matches[2])) { $matches[2] = null; } if (!isset($matches[3])) { $matches[3] = null; } if (!isset($matches[4])) { $matches[4] = null; } $result['family'] = isset($expression['family_replacement']) ? str_replace('$1', $matches[1], $expression['family_replacement']) : $matches[1]; $result['major'] = isset($expression['major_replacement']) ? $expression['major_replacement'] : $matches[2]; $result['minor'] = isset($expression['minor_replacement']) ? $expression['minor_replacement'] : $matches[3]; $result['patch'] = isset($expression['patch_replacement']) ? $expression['patch_replacement'] : $matches[4]; return $result; } } return $result; }
php
protected function parseOperatingsystem($userAgent) { $result = array( 'family' => 'Other', 'major' => null, 'minor' => null, 'patch' => null, ); if (!isset($this->regexes['operating_system_parsers'])) { return $result; } foreach ($this->regexes['operating_system_parsers'] as $expression) { if (preg_match('/'.str_replace('/','\/',str_replace('\/','/', $expression['regex'])).'/i', $userAgent, $matches)) { if (!isset($matches[1])) { $matches[1] = 'Other'; } if (!isset($matches[2])) { $matches[2] = null; } if (!isset($matches[3])) { $matches[3] = null; } if (!isset($matches[4])) { $matches[4] = null; } $result['family'] = isset($expression['family_replacement']) ? str_replace('$1', $matches[1], $expression['family_replacement']) : $matches[1]; $result['major'] = isset($expression['major_replacement']) ? $expression['major_replacement'] : $matches[2]; $result['minor'] = isset($expression['minor_replacement']) ? $expression['minor_replacement'] : $matches[3]; $result['patch'] = isset($expression['patch_replacement']) ? $expression['patch_replacement'] : $matches[4]; return $result; } } return $result; }
[ "protected", "function", "parseOperatingsystem", "(", "$", "userAgent", ")", "{", "$", "result", "=", "array", "(", "'family'", "=>", "'Other'", ",", "'major'", "=>", "null", ",", "'minor'", "=>", "null", ",", "'patch'", "=>", "null", ",", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "regexes", "[", "'operating_system_parsers'", "]", ")", ")", "{", "return", "$", "result", ";", "}", "foreach", "(", "$", "this", "->", "regexes", "[", "'operating_system_parsers'", "]", "as", "$", "expression", ")", "{", "if", "(", "preg_match", "(", "'/'", ".", "str_replace", "(", "'/'", ",", "'\\/'", ",", "str_replace", "(", "'\\/'", ",", "'/'", ",", "$", "expression", "[", "'regex'", "]", ")", ")", ".", "'/i'", ",", "$", "userAgent", ",", "$", "matches", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "matches", "[", "1", "]", "=", "'Other'", ";", "}", "if", "(", "!", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "$", "matches", "[", "2", "]", "=", "null", ";", "}", "if", "(", "!", "isset", "(", "$", "matches", "[", "3", "]", ")", ")", "{", "$", "matches", "[", "3", "]", "=", "null", ";", "}", "if", "(", "!", "isset", "(", "$", "matches", "[", "4", "]", ")", ")", "{", "$", "matches", "[", "4", "]", "=", "null", ";", "}", "$", "result", "[", "'family'", "]", "=", "isset", "(", "$", "expression", "[", "'family_replacement'", "]", ")", "?", "str_replace", "(", "'$1'", ",", "$", "matches", "[", "1", "]", ",", "$", "expression", "[", "'family_replacement'", "]", ")", ":", "$", "matches", "[", "1", "]", ";", "$", "result", "[", "'major'", "]", "=", "isset", "(", "$", "expression", "[", "'major_replacement'", "]", ")", "?", "$", "expression", "[", "'major_replacement'", "]", ":", "$", "matches", "[", "2", "]", ";", "$", "result", "[", "'minor'", "]", "=", "isset", "(", "$", "expression", "[", "'minor_replacement'", "]", ")", "?", "$", "expression", "[", "'minor_replacement'", "]", ":", "$", "matches", "[", "3", "]", ";", "$", "result", "[", "'patch'", "]", "=", "isset", "(", "$", "expression", "[", "'patch_replacement'", "]", ")", "?", "$", "expression", "[", "'patch_replacement'", "]", ":", "$", "matches", "[", "4", "]", ";", "return", "$", "result", ";", "}", "}", "return", "$", "result", ";", "}" ]
Parse the user agent an extract the operating system informations @param string $userAgent the user agent string @return array
[ "Parse", "the", "user", "agent", "an", "extract", "the", "operating", "system", "informations" ]
f7e3e4d3fc4f697cd0717da45fd15b54ba622d68
https://github.com/yzalis/UAParser/blob/f7e3e4d3fc4f697cd0717da45fd15b54ba622d68/src/UAParser/UAParser.php#L129-L159
train
redjanym/FCMBundle
FCMClient.php
FCMClient.createDeviceNotification
public function createDeviceNotification($title = null, $body = null, $token = array()) { $notification = new DeviceNotification(); $notification ->setTitle($title) ->setBody($body); if(is_array($token)){ $notification->setDeviceTokens($token); } else { $notification->addDeviceToken($token); } return $notification; }
php
public function createDeviceNotification($title = null, $body = null, $token = array()) { $notification = new DeviceNotification(); $notification ->setTitle($title) ->setBody($body); if(is_array($token)){ $notification->setDeviceTokens($token); } else { $notification->addDeviceToken($token); } return $notification; }
[ "public", "function", "createDeviceNotification", "(", "$", "title", "=", "null", ",", "$", "body", "=", "null", ",", "$", "token", "=", "array", "(", ")", ")", "{", "$", "notification", "=", "new", "DeviceNotification", "(", ")", ";", "$", "notification", "->", "setTitle", "(", "$", "title", ")", "->", "setBody", "(", "$", "body", ")", ";", "if", "(", "is_array", "(", "$", "token", ")", ")", "{", "$", "notification", "->", "setDeviceTokens", "(", "$", "token", ")", ";", "}", "else", "{", "$", "notification", "->", "addDeviceToken", "(", "$", "token", ")", ";", "}", "return", "$", "notification", ";", "}" ]
Create a notification of type Device Notification @param null $title @param null $body @param null | array $token @return DeviceNotification
[ "Create", "a", "notification", "of", "type", "Device", "Notification" ]
61b8bb71bce5c3079416ddae7d1abee15bc8a1ea
https://github.com/redjanym/FCMBundle/blob/61b8bb71bce5c3079416ddae7d1abee15bc8a1ea/FCMClient.php#L51-L65
train
redjanym/FCMBundle
FCMClient.php
FCMClient.createTopicNotification
public function createTopicNotification($title = null, $body = null, $topic = null) { $notification = new TopicNotification(); $notification ->setTitle($title) ->setBody($body) ->setTopic($topic); return $notification; }
php
public function createTopicNotification($title = null, $body = null, $topic = null) { $notification = new TopicNotification(); $notification ->setTitle($title) ->setBody($body) ->setTopic($topic); return $notification; }
[ "public", "function", "createTopicNotification", "(", "$", "title", "=", "null", ",", "$", "body", "=", "null", ",", "$", "topic", "=", "null", ")", "{", "$", "notification", "=", "new", "TopicNotification", "(", ")", ";", "$", "notification", "->", "setTitle", "(", "$", "title", ")", "->", "setBody", "(", "$", "body", ")", "->", "setTopic", "(", "$", "topic", ")", ";", "return", "$", "notification", ";", "}" ]
Create a notification of type Topic @param null $title @param null $body @param null $topic @return TopicNotification
[ "Create", "a", "notification", "of", "type", "Topic" ]
61b8bb71bce5c3079416ddae7d1abee15bc8a1ea
https://github.com/redjanym/FCMBundle/blob/61b8bb71bce5c3079416ddae7d1abee15bc8a1ea/FCMClient.php#L75-L84
train
redjanym/FCMBundle
FCMClient.php
FCMClient.subscribeDevicesToTopic
public function subscribeDevicesToTopic($topicId = null, $deviceTokens = array()) { if(!$topicId || empty($deviceTokens)){ throw new \InvalidArgumentException("Please check arguments!"); } return $this->client->addTopicSubscription($topicId, $deviceTokens); }
php
public function subscribeDevicesToTopic($topicId = null, $deviceTokens = array()) { if(!$topicId || empty($deviceTokens)){ throw new \InvalidArgumentException("Please check arguments!"); } return $this->client->addTopicSubscription($topicId, $deviceTokens); }
[ "public", "function", "subscribeDevicesToTopic", "(", "$", "topicId", "=", "null", ",", "$", "deviceTokens", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "topicId", "||", "empty", "(", "$", "deviceTokens", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Please check arguments!\"", ")", ";", "}", "return", "$", "this", "->", "client", "->", "addTopicSubscription", "(", "$", "topicId", ",", "$", "deviceTokens", ")", ";", "}" ]
Subscribe devices to a Topic @param null $topicId @param array $deviceTokens @return \Psr\Http\Message\ResponseInterface
[ "Subscribe", "devices", "to", "a", "Topic" ]
61b8bb71bce5c3079416ddae7d1abee15bc8a1ea
https://github.com/redjanym/FCMBundle/blob/61b8bb71bce5c3079416ddae7d1abee15bc8a1ea/FCMClient.php#L93-L100
train
redjanym/FCMBundle
FCMClient.php
FCMClient.removeDevicesFromTopic
public function removeDevicesFromTopic($topicId = null, $deviceTokens = array()) { if(!$topicId || empty($deviceTokens)){ throw new \InvalidArgumentException("Please check arguments!"); } return $this->client->removeTopicSubscription($topicId, $deviceTokens); }
php
public function removeDevicesFromTopic($topicId = null, $deviceTokens = array()) { if(!$topicId || empty($deviceTokens)){ throw new \InvalidArgumentException("Please check arguments!"); } return $this->client->removeTopicSubscription($topicId, $deviceTokens); }
[ "public", "function", "removeDevicesFromTopic", "(", "$", "topicId", "=", "null", ",", "$", "deviceTokens", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "topicId", "||", "empty", "(", "$", "deviceTokens", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Please check arguments!\"", ")", ";", "}", "return", "$", "this", "->", "client", "->", "removeTopicSubscription", "(", "$", "topicId", ",", "$", "deviceTokens", ")", ";", "}" ]
Remove devices from a Topic @param null $topicId @param array $deviceTokens @return \Psr\Http\Message\ResponseInterface
[ "Remove", "devices", "from", "a", "Topic" ]
61b8bb71bce5c3079416ddae7d1abee15bc8a1ea
https://github.com/redjanym/FCMBundle/blob/61b8bb71bce5c3079416ddae7d1abee15bc8a1ea/FCMClient.php#L109-L116
train
gburtini/Probability-Distributions-for-PHP
src/gburtini/Distributions/Binomial.php
Binomial.icdf
public function icdf($p) { if ($p < 0 || $p > 1) { throw new \InvalidArgumentException("Parameter (\$p = " . var_export($p, true) . " must be between 0 and 1. "); } if ($p == 1) { return INF; } $accumulator = 0.0; $k = 0; do { $delta = $this->pdf($k); $accumulator = $accumulator + $delta; if ($accumulator >= $p) { return $k; } $k = $k + 1; } while ($k < $this->n); return $k; }
php
public function icdf($p) { if ($p < 0 || $p > 1) { throw new \InvalidArgumentException("Parameter (\$p = " . var_export($p, true) . " must be between 0 and 1. "); } if ($p == 1) { return INF; } $accumulator = 0.0; $k = 0; do { $delta = $this->pdf($k); $accumulator = $accumulator + $delta; if ($accumulator >= $p) { return $k; } $k = $k + 1; } while ($k < $this->n); return $k; }
[ "public", "function", "icdf", "(", "$", "p", ")", "{", "if", "(", "$", "p", "<", "0", "||", "$", "p", ">", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Parameter (\\$p = \"", ".", "var_export", "(", "$", "p", ",", "true", ")", ".", "\" must be between 0 and 1. \"", ")", ";", "}", "if", "(", "$", "p", "==", "1", ")", "{", "return", "INF", ";", "}", "$", "accumulator", "=", "0.0", ";", "$", "k", "=", "0", ";", "do", "{", "$", "delta", "=", "$", "this", "->", "pdf", "(", "$", "k", ")", ";", "$", "accumulator", "=", "$", "accumulator", "+", "$", "delta", ";", "if", "(", "$", "accumulator", ">=", "$", "p", ")", "{", "return", "$", "k", ";", "}", "$", "k", "=", "$", "k", "+", "1", ";", "}", "while", "(", "$", "k", "<", "$", "this", "->", "n", ")", ";", "return", "$", "k", ";", "}" ]
Again, not a very efficient implementation
[ "Again", "not", "a", "very", "efficient", "implementation" ]
0e2e71bb497b589b537f563a625857fa78484b42
https://github.com/gburtini/Probability-Distributions-for-PHP/blob/0e2e71bb497b589b537f563a625857fa78484b42/src/gburtini/Distributions/Binomial.php#L89-L108
train
AcclimateContainer/acclimate-container
src/CompositeContainer.php
CompositeContainer.get
public function get($id) { /** @var ContainerInterface $container */ foreach ($this->containers as $container) { if ($container->has($id)) { return $container->get($id); } } throw NotFoundException::fromPrevious($id); }
php
public function get($id) { /** @var ContainerInterface $container */ foreach ($this->containers as $container) { if ($container->has($id)) { return $container->get($id); } } throw NotFoundException::fromPrevious($id); }
[ "public", "function", "get", "(", "$", "id", ")", "{", "/** @var ContainerInterface $container */", "foreach", "(", "$", "this", "->", "containers", "as", "$", "container", ")", "{", "if", "(", "$", "container", "->", "has", "(", "$", "id", ")", ")", "{", "return", "$", "container", "->", "get", "(", "$", "id", ")", ";", "}", "}", "throw", "NotFoundException", "::", "fromPrevious", "(", "$", "id", ")", ";", "}" ]
Finds an entry of the container by delegating the get call to a FIFO queue of internal containers {@inheritDoc}
[ "Finds", "an", "entry", "of", "the", "container", "by", "delegating", "the", "get", "call", "to", "a", "FIFO", "queue", "of", "internal", "containers" ]
8c3373637900c48aa4a950bdb7099ac881d8f382
https://github.com/AcclimateContainer/acclimate-container/blob/8c3373637900c48aa4a950bdb7099ac881d8f382/src/CompositeContainer.php#L47-L57
train
AcclimateContainer/acclimate-container
src/Exception/ContainerException.php
ContainerException.fromPrevious
public static function fromPrevious($id, \Exception $prev = null) { $message = strtr(static::$template, array( '{id}' => (is_string($id) || method_exists($id, '__toString')) ? $id : '?', '{error}' => $prev ? get_class($prev) : 'error', )); if ($prev) { $message .= ' Message: ' . $prev->getMessage(); } return new static($message, 0, $prev); }
php
public static function fromPrevious($id, \Exception $prev = null) { $message = strtr(static::$template, array( '{id}' => (is_string($id) || method_exists($id, '__toString')) ? $id : '?', '{error}' => $prev ? get_class($prev) : 'error', )); if ($prev) { $message .= ' Message: ' . $prev->getMessage(); } return new static($message, 0, $prev); }
[ "public", "static", "function", "fromPrevious", "(", "$", "id", ",", "\\", "Exception", "$", "prev", "=", "null", ")", "{", "$", "message", "=", "strtr", "(", "static", "::", "$", "template", ",", "array", "(", "'{id}'", "=>", "(", "is_string", "(", "$", "id", ")", "||", "method_exists", "(", "$", "id", ",", "'__toString'", ")", ")", "?", "$", "id", ":", "'?'", ",", "'{error}'", "=>", "$", "prev", "?", "get_class", "(", "$", "prev", ")", ":", "'error'", ",", ")", ")", ";", "if", "(", "$", "prev", ")", "{", "$", "message", ".=", "' Message: '", ".", "$", "prev", "->", "getMessage", "(", ")", ";", "}", "return", "new", "static", "(", "$", "message", ",", "0", ",", "$", "prev", ")", ";", "}" ]
Creates a ContainerException by using the information from the previous exception @param string|mixed $id @param \Exception $prev @return ContainerException
[ "Creates", "a", "ContainerException", "by", "using", "the", "information", "from", "the", "previous", "exception" ]
8c3373637900c48aa4a950bdb7099ac881d8f382
https://github.com/AcclimateContainer/acclimate-container/blob/8c3373637900c48aa4a950bdb7099ac881d8f382/src/Exception/ContainerException.php#L25-L37
train
AcclimateContainer/acclimate-container
src/ContainerAcclimator.php
ContainerAcclimator.acclimateContainer
public static function acclimateContainer($container, array $customAdapterMap = null) { $acclimator = new self($customAdapterMap); return $acclimator->acclimate($container); }
php
public static function acclimateContainer($container, array $customAdapterMap = null) { $acclimator = new self($customAdapterMap); return $acclimator->acclimate($container); }
[ "public", "static", "function", "acclimateContainer", "(", "$", "container", ",", "array", "$", "customAdapterMap", "=", "null", ")", "{", "$", "acclimator", "=", "new", "self", "(", "$", "customAdapterMap", ")", ";", "return", "$", "acclimator", "->", "acclimate", "(", "$", "container", ")", ";", "}" ]
Create an adaptor statically for a particular container. @param mixed $container A third-party object to be acclimated @param array|null $customAdapterMap An optional adapter map to pass to the acclimator @return ContainerInterface
[ "Create", "an", "adaptor", "statically", "for", "a", "particular", "container", "." ]
8c3373637900c48aa4a950bdb7099ac881d8f382
https://github.com/AcclimateContainer/acclimate-container/blob/8c3373637900c48aa4a950bdb7099ac881d8f382/src/ContainerAcclimator.php#L26-L31
train
AcclimateContainer/acclimate-container
src/ContainerAcclimator.php
ContainerAcclimator.acclimate
public function acclimate($adaptee) { if ($adaptee instanceof ContainerInterface) { // If the adaptee already implements the ContainerInterface, just return it return $adaptee; } else { // Otherwise, check the adapter map to see if there is an appropriate adapter registered foreach ($this->adapterMap as $adapteeFqcn => $adapterFqcn) { if ($adaptee instanceof $adapteeFqcn) { return new $adapterFqcn($adaptee); } } } // If no adapter matches the provided container object, throw an exception throw InvalidAdapterException::fromAdaptee($adaptee); }
php
public function acclimate($adaptee) { if ($adaptee instanceof ContainerInterface) { // If the adaptee already implements the ContainerInterface, just return it return $adaptee; } else { // Otherwise, check the adapter map to see if there is an appropriate adapter registered foreach ($this->adapterMap as $adapteeFqcn => $adapterFqcn) { if ($adaptee instanceof $adapteeFqcn) { return new $adapterFqcn($adaptee); } } } // If no adapter matches the provided container object, throw an exception throw InvalidAdapterException::fromAdaptee($adaptee); }
[ "public", "function", "acclimate", "(", "$", "adaptee", ")", "{", "if", "(", "$", "adaptee", "instanceof", "ContainerInterface", ")", "{", "// If the adaptee already implements the ContainerInterface, just return it", "return", "$", "adaptee", ";", "}", "else", "{", "// Otherwise, check the adapter map to see if there is an appropriate adapter registered", "foreach", "(", "$", "this", "->", "adapterMap", "as", "$", "adapteeFqcn", "=>", "$", "adapterFqcn", ")", "{", "if", "(", "$", "adaptee", "instanceof", "$", "adapteeFqcn", ")", "{", "return", "new", "$", "adapterFqcn", "(", "$", "adaptee", ")", ";", "}", "}", "}", "// If no adapter matches the provided container object, throw an exception", "throw", "InvalidAdapterException", "::", "fromAdaptee", "(", "$", "adaptee", ")", ";", "}" ]
Adapts an object by wrapping it with a registered adapter class that implements an Acclimate interface @param mixed $adaptee A third-party object to be acclimated @return ContainerInterface @throws InvalidAdapterException if there is no adapter found for the provided object
[ "Adapts", "an", "object", "by", "wrapping", "it", "with", "a", "registered", "adapter", "class", "that", "implements", "an", "Acclimate", "interface" ]
8c3373637900c48aa4a950bdb7099ac881d8f382
https://github.com/AcclimateContainer/acclimate-container/blob/8c3373637900c48aa4a950bdb7099ac881d8f382/src/ContainerAcclimator.php#L64-L80
train
airbrake/phpbrake
src/Notifier.php
Notifier.sendNotice
public function sendNotice($notice) { $notice = $this->filterNotice($notice); if (isset($notice['error'])) { return $notice; } if (time() < $this->rateLimitReset) { $notice['error'] = ERR_IP_RATE_LIMITED; return $notice; } $req = $this->newHttpRequest($notice); $resp = $this->sendRequest($req); return $this->processHttpResponse($notice, $resp); }
php
public function sendNotice($notice) { $notice = $this->filterNotice($notice); if (isset($notice['error'])) { return $notice; } if (time() < $this->rateLimitReset) { $notice['error'] = ERR_IP_RATE_LIMITED; return $notice; } $req = $this->newHttpRequest($notice); $resp = $this->sendRequest($req); return $this->processHttpResponse($notice, $resp); }
[ "public", "function", "sendNotice", "(", "$", "notice", ")", "{", "$", "notice", "=", "$", "this", "->", "filterNotice", "(", "$", "notice", ")", ";", "if", "(", "isset", "(", "$", "notice", "[", "'error'", "]", ")", ")", "{", "return", "$", "notice", ";", "}", "if", "(", "time", "(", ")", "<", "$", "this", "->", "rateLimitReset", ")", "{", "$", "notice", "[", "'error'", "]", "=", "ERR_IP_RATE_LIMITED", ";", "return", "$", "notice", ";", "}", "$", "req", "=", "$", "this", "->", "newHttpRequest", "(", "$", "notice", ")", ";", "$", "resp", "=", "$", "this", "->", "sendRequest", "(", "$", "req", ")", ";", "return", "$", "this", "->", "processHttpResponse", "(", "$", "notice", ",", "$", "resp", ")", ";", "}" ]
Sends notice to Airbrake. It returns notice with 2 possible new keys: - ['id' => '12345'] - notice id on success. - ['error' => 'error message'] - error message on failure. @param array $notice Airbrake notice @return array Airbrake notice
[ "Sends", "notice", "to", "Airbrake", "." ]
1354defbf86f534d9a7408a1c5a1018a4d845f3f
https://github.com/airbrake/phpbrake/blob/1354defbf86f534d9a7408a1c5a1018a4d845f3f/src/Notifier.php#L295-L310
train
airbrake/phpbrake
src/Notifier.php
Notifier.buildNoticesURL
protected function buildNoticesURL() { $schemeAndHost = $this->opt['host']; if (!preg_match('~^https?://~i', $schemeAndHost)) { $schemeAndHost = "https://$schemeAndHost"; } return sprintf( '%s/api/v3/projects/%d/notices', $schemeAndHost, $this->opt['projectId'] ); }
php
protected function buildNoticesURL() { $schemeAndHost = $this->opt['host']; if (!preg_match('~^https?://~i', $schemeAndHost)) { $schemeAndHost = "https://$schemeAndHost"; } return sprintf( '%s/api/v3/projects/%d/notices', $schemeAndHost, $this->opt['projectId'] ); }
[ "protected", "function", "buildNoticesURL", "(", ")", "{", "$", "schemeAndHost", "=", "$", "this", "->", "opt", "[", "'host'", "]", ";", "if", "(", "!", "preg_match", "(", "'~^https?://~i'", ",", "$", "schemeAndHost", ")", ")", "{", "$", "schemeAndHost", "=", "\"https://$schemeAndHost\"", ";", "}", "return", "sprintf", "(", "'%s/api/v3/projects/%d/notices'", ",", "$", "schemeAndHost", ",", "$", "this", "->", "opt", "[", "'projectId'", "]", ")", ";", "}" ]
Builds notices URL. @return string
[ "Builds", "notices", "URL", "." ]
1354defbf86f534d9a7408a1c5a1018a4d845f3f
https://github.com/airbrake/phpbrake/blob/1354defbf86f534d9a7408a1c5a1018a4d845f3f/src/Notifier.php#L450-L461
train
airbrake/phpbrake
src/ErrorHandler.php
ErrorHandler.onError
public function onError($code, $message, $file, $line) { $this->lastError = [ 'message' => $message, 'file' => $file, 'line' => $line ]; $trace = debug_backtrace(); if (count($trace) > 0 && !isset($trace[0]['file'])) { array_shift($trace); } switch ($code) { case E_NOTICE: case E_USER_NOTICE: $exc = new Errors\Notice($message, $trace); break; case E_WARNING: case E_USER_WARNING: $exc = new Errors\Warning($message, $trace); break; case E_ERROR: case E_CORE_ERROR: case E_RECOVERABLE_ERROR: case E_USER_ERROR: $exc = new Errors\Fatal($message, $trace); break; default: $exc = new Errors\Error($message, $trace); break; } $this->notifier->notify($exc); return false; }
php
public function onError($code, $message, $file, $line) { $this->lastError = [ 'message' => $message, 'file' => $file, 'line' => $line ]; $trace = debug_backtrace(); if (count($trace) > 0 && !isset($trace[0]['file'])) { array_shift($trace); } switch ($code) { case E_NOTICE: case E_USER_NOTICE: $exc = new Errors\Notice($message, $trace); break; case E_WARNING: case E_USER_WARNING: $exc = new Errors\Warning($message, $trace); break; case E_ERROR: case E_CORE_ERROR: case E_RECOVERABLE_ERROR: case E_USER_ERROR: $exc = new Errors\Fatal($message, $trace); break; default: $exc = new Errors\Error($message, $trace); break; } $this->notifier->notify($exc); return false; }
[ "public", "function", "onError", "(", "$", "code", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "$", "this", "->", "lastError", "=", "[", "'message'", "=>", "$", "message", ",", "'file'", "=>", "$", "file", ",", "'line'", "=>", "$", "line", "]", ";", "$", "trace", "=", "debug_backtrace", "(", ")", ";", "if", "(", "count", "(", "$", "trace", ")", ">", "0", "&&", "!", "isset", "(", "$", "trace", "[", "0", "]", "[", "'file'", "]", ")", ")", "{", "array_shift", "(", "$", "trace", ")", ";", "}", "switch", "(", "$", "code", ")", "{", "case", "E_NOTICE", ":", "case", "E_USER_NOTICE", ":", "$", "exc", "=", "new", "Errors", "\\", "Notice", "(", "$", "message", ",", "$", "trace", ")", ";", "break", ";", "case", "E_WARNING", ":", "case", "E_USER_WARNING", ":", "$", "exc", "=", "new", "Errors", "\\", "Warning", "(", "$", "message", ",", "$", "trace", ")", ";", "break", ";", "case", "E_ERROR", ":", "case", "E_CORE_ERROR", ":", "case", "E_RECOVERABLE_ERROR", ":", "case", "E_USER_ERROR", ":", "$", "exc", "=", "new", "Errors", "\\", "Fatal", "(", "$", "message", ",", "$", "trace", ")", ";", "break", ";", "default", ":", "$", "exc", "=", "new", "Errors", "\\", "Error", "(", "$", "message", ",", "$", "trace", ")", ";", "break", ";", "}", "$", "this", "->", "notifier", "->", "notify", "(", "$", "exc", ")", ";", "return", "false", ";", "}" ]
PHP error handler that notifies Airbrake about errors. Should be used with set_error_handler.
[ "PHP", "error", "handler", "that", "notifies", "Airbrake", "about", "errors", ".", "Should", "be", "used", "with", "set_error_handler", "." ]
1354defbf86f534d9a7408a1c5a1018a4d845f3f
https://github.com/airbrake/phpbrake/blob/1354defbf86f534d9a7408a1c5a1018a4d845f3f/src/ErrorHandler.php#L32-L66
train
airbrake/phpbrake
src/ErrorHandler.php
ErrorHandler.onShutdown
public function onShutdown() { $error = error_get_last(); if ($error === null) { return; } if (($error['type'] & error_reporting()) === 0) { return; } if ($this->lastError !== null && $error['message'] === $this->lastError['message'] && $error['file'] === $this->lastError['file'] && $error['line'] === $this->lastError['line']) { return; } $trace = [[ 'file' => $error['file'], 'line' => $error['line'], ]]; $exc = new Errors\Fatal($error['message'], $trace); $this->notifier->notify($exc); }
php
public function onShutdown() { $error = error_get_last(); if ($error === null) { return; } if (($error['type'] & error_reporting()) === 0) { return; } if ($this->lastError !== null && $error['message'] === $this->lastError['message'] && $error['file'] === $this->lastError['file'] && $error['line'] === $this->lastError['line']) { return; } $trace = [[ 'file' => $error['file'], 'line' => $error['line'], ]]; $exc = new Errors\Fatal($error['message'], $trace); $this->notifier->notify($exc); }
[ "public", "function", "onShutdown", "(", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "error", "===", "null", ")", "{", "return", ";", "}", "if", "(", "(", "$", "error", "[", "'type'", "]", "&", "error_reporting", "(", ")", ")", "===", "0", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "lastError", "!==", "null", "&&", "$", "error", "[", "'message'", "]", "===", "$", "this", "->", "lastError", "[", "'message'", "]", "&&", "$", "error", "[", "'file'", "]", "===", "$", "this", "->", "lastError", "[", "'file'", "]", "&&", "$", "error", "[", "'line'", "]", "===", "$", "this", "->", "lastError", "[", "'line'", "]", ")", "{", "return", ";", "}", "$", "trace", "=", "[", "[", "'file'", "=>", "$", "error", "[", "'file'", "]", ",", "'line'", "=>", "$", "error", "[", "'line'", "]", ",", "]", "]", ";", "$", "exc", "=", "new", "Errors", "\\", "Fatal", "(", "$", "error", "[", "'message'", "]", ",", "$", "trace", ")", ";", "$", "this", "->", "notifier", "->", "notify", "(", "$", "exc", ")", ";", "}" ]
PHP shutdown handler that notifies Airbrake about shutdown. Should be used with register_shutdown_function.
[ "PHP", "shutdown", "handler", "that", "notifies", "Airbrake", "about", "shutdown", ".", "Should", "be", "used", "with", "register_shutdown_function", "." ]
1354defbf86f534d9a7408a1c5a1018a4d845f3f
https://github.com/airbrake/phpbrake/blob/1354defbf86f534d9a7408a1c5a1018a4d845f3f/src/ErrorHandler.php#L81-L102
train
heimrichhannot/contao-haste_plus
library/Haste/Image/Image.php
Image.getSizedImagePath
public static function getSizedImagePath($uuid, $size) { $container = \System::getContainer(); $rootDir = $container->getParameter('kernel.project_dir'); if (!($path = Files::getPathFromUuid($uuid))) { return false; } $size = unserialize($size); if (is_array($size)) { if (count($size) < 3) { return false; } else { $size = $size[2]; } } return $container->get('contao.image.image_factory')->create( $rootDir . '/' . $path, $size )->getUrl($rootDir); }
php
public static function getSizedImagePath($uuid, $size) { $container = \System::getContainer(); $rootDir = $container->getParameter('kernel.project_dir'); if (!($path = Files::getPathFromUuid($uuid))) { return false; } $size = unserialize($size); if (is_array($size)) { if (count($size) < 3) { return false; } else { $size = $size[2]; } } return $container->get('contao.image.image_factory')->create( $rootDir . '/' . $path, $size )->getUrl($rootDir); }
[ "public", "static", "function", "getSizedImagePath", "(", "$", "uuid", ",", "$", "size", ")", "{", "$", "container", "=", "\\", "System", "::", "getContainer", "(", ")", ";", "$", "rootDir", "=", "$", "container", "->", "getParameter", "(", "'kernel.project_dir'", ")", ";", "if", "(", "!", "(", "$", "path", "=", "Files", "::", "getPathFromUuid", "(", "$", "uuid", ")", ")", ")", "{", "return", "false", ";", "}", "$", "size", "=", "unserialize", "(", "$", "size", ")", ";", "if", "(", "is_array", "(", "$", "size", ")", ")", "{", "if", "(", "count", "(", "$", "size", ")", "<", "3", ")", "{", "return", "false", ";", "}", "else", "{", "$", "size", "=", "$", "size", "[", "2", "]", ";", "}", "}", "return", "$", "container", "->", "get", "(", "'contao.image.image_factory'", ")", "->", "create", "(", "$", "rootDir", ".", "'/'", ".", "$", "path", ",", "$", "size", ")", "->", "getUrl", "(", "$", "rootDir", ")", ";", "}" ]
Returns path of sized image. @param $uuid mixed binary uuid @param $size int|array @return bool|string
[ "Returns", "path", "of", "sized", "image", "." ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Image/Image.php#L63-L89
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Url.php
Url.addScheme
public static function addScheme($strUrl, $strScheme = 'http://') { return parse_url($strUrl, PHP_URL_SCHEME) === null ? $strScheme . $strUrl : $strUrl; }
php
public static function addScheme($strUrl, $strScheme = 'http://') { return parse_url($strUrl, PHP_URL_SCHEME) === null ? $strScheme . $strUrl : $strUrl; }
[ "public", "static", "function", "addScheme", "(", "$", "strUrl", ",", "$", "strScheme", "=", "'http://'", ")", "{", "return", "parse_url", "(", "$", "strUrl", ",", "PHP_URL_SCHEME", ")", "===", "null", "?", "$", "strScheme", ".", "$", "strUrl", ":", "$", "strUrl", ";", "}" ]
Check an url for existing scheme and add if it is missing @param $strUrl The url @param string $strScheme Name of the scheme @return string The url with scheme
[ "Check", "an", "url", "for", "existing", "scheme", "and", "add", "if", "it", "is", "missing" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Url.php#L24-L27
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Url.php
Url.addAutoItemToPageUrl
public static function addAutoItemToPageUrl($objPage, $objItem, $strAutoItemType = 'items') { $strAutoItem = ((\Config::get('useAutoItem') && !\Config::get('disableAlias')) ? '/' : '/' . $strAutoItemType . '/') . ((!\Config::get('disableAlias') && $objItem->alias != '') ? $objItem->alias : $objItem->id); return \Controller::generateFrontendUrl($objPage->row(), $strAutoItem); }
php
public static function addAutoItemToPageUrl($objPage, $objItem, $strAutoItemType = 'items') { $strAutoItem = ((\Config::get('useAutoItem') && !\Config::get('disableAlias')) ? '/' : '/' . $strAutoItemType . '/') . ((!\Config::get('disableAlias') && $objItem->alias != '') ? $objItem->alias : $objItem->id); return \Controller::generateFrontendUrl($objPage->row(), $strAutoItem); }
[ "public", "static", "function", "addAutoItemToPageUrl", "(", "$", "objPage", ",", "$", "objItem", ",", "$", "strAutoItemType", "=", "'items'", ")", "{", "$", "strAutoItem", "=", "(", "(", "\\", "Config", "::", "get", "(", "'useAutoItem'", ")", "&&", "!", "\\", "Config", "::", "get", "(", "'disableAlias'", ")", ")", "?", "'/'", ":", "'/'", ".", "$", "strAutoItemType", ".", "'/'", ")", ".", "(", "(", "!", "\\", "Config", "::", "get", "(", "'disableAlias'", ")", "&&", "$", "objItem", "->", "alias", "!=", "''", ")", "?", "$", "objItem", "->", "alias", ":", "$", "objItem", "->", "id", ")", ";", "return", "\\", "Controller", "::", "generateFrontendUrl", "(", "$", "objPage", "->", "row", "(", ")", ",", "$", "strAutoItem", ")", ";", "}" ]
Adds the auto_item to a page's url @param $objPage @param $objEvent @param string $strAutoItemType @return string
[ "Adds", "the", "auto_item", "to", "a", "page", "s", "url" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Url.php#L312-L320
train
heimrichhannot/contao-haste_plus
library/Haste/Util/GeoLocation.php
GeoLocation.getDistance
public static function getDistance($latitudeA, $longitudeA, $latitudeB, $longitudeB) { $earth_radius = 6371; $dLat = deg2rad($latitudeB - $latitudeA); $dLon = deg2rad($longitudeB - $longitudeA); $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latitudeA)) * cos(deg2rad($latitudeB)) * sin($dLon / 2) * sin($dLon / 2); $c = 2 * asin(sqrt($a)); $d = $earth_radius * $c; return $d; }
php
public static function getDistance($latitudeA, $longitudeA, $latitudeB, $longitudeB) { $earth_radius = 6371; $dLat = deg2rad($latitudeB - $latitudeA); $dLon = deg2rad($longitudeB - $longitudeA); $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latitudeA)) * cos(deg2rad($latitudeB)) * sin($dLon / 2) * sin($dLon / 2); $c = 2 * asin(sqrt($a)); $d = $earth_radius * $c; return $d; }
[ "public", "static", "function", "getDistance", "(", "$", "latitudeA", ",", "$", "longitudeA", ",", "$", "latitudeB", ",", "$", "longitudeB", ")", "{", "$", "earth_radius", "=", "6371", ";", "$", "dLat", "=", "deg2rad", "(", "$", "latitudeB", "-", "$", "latitudeA", ")", ";", "$", "dLon", "=", "deg2rad", "(", "$", "longitudeB", "-", "$", "longitudeA", ")", ";", "$", "a", "=", "sin", "(", "$", "dLat", "/", "2", ")", "*", "sin", "(", "$", "dLat", "/", "2", ")", "+", "cos", "(", "deg2rad", "(", "$", "latitudeA", ")", ")", "*", "cos", "(", "deg2rad", "(", "$", "latitudeB", ")", ")", "*", "sin", "(", "$", "dLon", "/", "2", ")", "*", "sin", "(", "$", "dLon", "/", "2", ")", ";", "$", "c", "=", "2", "*", "asin", "(", "sqrt", "(", "$", "a", ")", ")", ";", "$", "d", "=", "$", "earth_radius", "*", "$", "c", ";", "return", "$", "d", ";", "}" ]
Get distance between position A and position B as kilometer @param $latitudeA @param $longitudeA @param $latitudeB @param $longitudeB @return int
[ "Get", "distance", "between", "position", "A", "and", "position", "B", "as", "kilometer" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/GeoLocation.php#L26-L38
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Numbers.php
Numbers.getReadableNumber
public static function getReadableNumber($intNumber, $intPrecision = 1, $blnAddDots = true) { $intNumber = (0 + str_replace(",", "", $intNumber)); if (!is_numeric($intNumber)) { return false; } // now filter it; if ($intNumber > 1000000000) { return round(($intNumber / 1000000000), $intPrecision) . ' Mrd'; } else { if ($intNumber > 1000000) { return round(($intNumber / 1000000), $intPrecision) . ' Mio'; } else { if ($intNumber > 1000) { if ($blnAddDots) { return static::addDotsToNumber($intNumber); } else { return $intNumber; } } } } return number_format($intNumber); }
php
public static function getReadableNumber($intNumber, $intPrecision = 1, $blnAddDots = true) { $intNumber = (0 + str_replace(",", "", $intNumber)); if (!is_numeric($intNumber)) { return false; } // now filter it; if ($intNumber > 1000000000) { return round(($intNumber / 1000000000), $intPrecision) . ' Mrd'; } else { if ($intNumber > 1000000) { return round(($intNumber / 1000000), $intPrecision) . ' Mio'; } else { if ($intNumber > 1000) { if ($blnAddDots) { return static::addDotsToNumber($intNumber); } else { return $intNumber; } } } } return number_format($intNumber); }
[ "public", "static", "function", "getReadableNumber", "(", "$", "intNumber", ",", "$", "intPrecision", "=", "1", ",", "$", "blnAddDots", "=", "true", ")", "{", "$", "intNumber", "=", "(", "0", "+", "str_replace", "(", "\",\"", ",", "\"\"", ",", "$", "intNumber", ")", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "intNumber", ")", ")", "{", "return", "false", ";", "}", "// now filter it;", "if", "(", "$", "intNumber", ">", "1000000000", ")", "{", "return", "round", "(", "(", "$", "intNumber", "/", "1000000000", ")", ",", "$", "intPrecision", ")", ".", "' Mrd'", ";", "}", "else", "{", "if", "(", "$", "intNumber", ">", "1000000", ")", "{", "return", "round", "(", "(", "$", "intNumber", "/", "1000000", ")", ",", "$", "intPrecision", ")", ".", "' Mio'", ";", "}", "else", "{", "if", "(", "$", "intNumber", ">", "1000", ")", "{", "if", "(", "$", "blnAddDots", ")", "{", "return", "static", "::", "addDotsToNumber", "(", "$", "intNumber", ")", ";", "}", "else", "{", "return", "$", "intNumber", ";", "}", "}", "}", "}", "return", "number_format", "(", "$", "intNumber", ")", ";", "}" ]
currently only optimized for German users
[ "currently", "only", "optimized", "for", "German", "users" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Numbers.php#L18-L55
train
heimrichhannot/contao-haste_plus
library/Haste/Util/DateUtil.php
DateUtil.formatPhpDateToJsDate
public static function formatPhpDateToJsDate($php_format) { $SYMBOLS_MATCHING = [ // Day 'd' => 'DD', 'D' => 'D', 'j' => 'd', 'l' => 'DD', 'N' => '', 'S' => '', 'w' => '', 'z' => 'o', // Week 'W' => '', // Month 'F' => 'MM', 'm' => 'MM', 'M' => 'M', 'n' => 'm', 't' => '', // Year 'L' => '', 'o' => '', 'Y' => 'YYYY', 'y' => 'y', // Time 'a' => '', 'A' => '', 'B' => '', 'g' => '', 'G' => '', 'h' => '', 'H' => 'HH', 'i' => 'mm', 's' => '', 'u' => '' ]; $replacement = ""; $escaping = false; for ($i = 0; $i < strlen($php_format); $i++) { $char = $php_format [$i]; if ($char === '\\') // PHP date format escaping character { $i++; if ($escaping) { $replacement .= $php_format [$i]; } else { $replacement .= '\'' . $php_format [$i]; } $escaping = true; } else { if ($escaping) { $replacement .= "'"; $escaping = false; } if (isset ($SYMBOLS_MATCHING [$char])) { $replacement .= $SYMBOLS_MATCHING [$char]; } else { $replacement .= $char; } } } return $replacement; }
php
public static function formatPhpDateToJsDate($php_format) { $SYMBOLS_MATCHING = [ // Day 'd' => 'DD', 'D' => 'D', 'j' => 'd', 'l' => 'DD', 'N' => '', 'S' => '', 'w' => '', 'z' => 'o', // Week 'W' => '', // Month 'F' => 'MM', 'm' => 'MM', 'M' => 'M', 'n' => 'm', 't' => '', // Year 'L' => '', 'o' => '', 'Y' => 'YYYY', 'y' => 'y', // Time 'a' => '', 'A' => '', 'B' => '', 'g' => '', 'G' => '', 'h' => '', 'H' => 'HH', 'i' => 'mm', 's' => '', 'u' => '' ]; $replacement = ""; $escaping = false; for ($i = 0; $i < strlen($php_format); $i++) { $char = $php_format [$i]; if ($char === '\\') // PHP date format escaping character { $i++; if ($escaping) { $replacement .= $php_format [$i]; } else { $replacement .= '\'' . $php_format [$i]; } $escaping = true; } else { if ($escaping) { $replacement .= "'"; $escaping = false; } if (isset ($SYMBOLS_MATCHING [$char])) { $replacement .= $SYMBOLS_MATCHING [$char]; } else { $replacement .= $char; } } } return $replacement; }
[ "public", "static", "function", "formatPhpDateToJsDate", "(", "$", "php_format", ")", "{", "$", "SYMBOLS_MATCHING", "=", "[", "// Day", "'d'", "=>", "'DD'", ",", "'D'", "=>", "'D'", ",", "'j'", "=>", "'d'", ",", "'l'", "=>", "'DD'", ",", "'N'", "=>", "''", ",", "'S'", "=>", "''", ",", "'w'", "=>", "''", ",", "'z'", "=>", "'o'", ",", "// Week", "'W'", "=>", "''", ",", "// Month", "'F'", "=>", "'MM'", ",", "'m'", "=>", "'MM'", ",", "'M'", "=>", "'M'", ",", "'n'", "=>", "'m'", ",", "'t'", "=>", "''", ",", "// Year", "'L'", "=>", "''", ",", "'o'", "=>", "''", ",", "'Y'", "=>", "'YYYY'", ",", "'y'", "=>", "'y'", ",", "// Time", "'a'", "=>", "''", ",", "'A'", "=>", "''", ",", "'B'", "=>", "''", ",", "'g'", "=>", "''", ",", "'G'", "=>", "''", ",", "'h'", "=>", "''", ",", "'H'", "=>", "'HH'", ",", "'i'", "=>", "'mm'", ",", "'s'", "=>", "''", ",", "'u'", "=>", "''", "]", ";", "$", "replacement", "=", "\"\"", ";", "$", "escaping", "=", "false", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "php_format", ")", ";", "$", "i", "++", ")", "{", "$", "char", "=", "$", "php_format", "[", "$", "i", "]", ";", "if", "(", "$", "char", "===", "'\\\\'", ")", "// PHP date format escaping character", "{", "$", "i", "++", ";", "if", "(", "$", "escaping", ")", "{", "$", "replacement", ".=", "$", "php_format", "[", "$", "i", "]", ";", "}", "else", "{", "$", "replacement", ".=", "'\\''", ".", "$", "php_format", "[", "$", "i", "]", ";", "}", "$", "escaping", "=", "true", ";", "}", "else", "{", "if", "(", "$", "escaping", ")", "{", "$", "replacement", ".=", "\"'\"", ";", "$", "escaping", "=", "false", ";", "}", "if", "(", "isset", "(", "$", "SYMBOLS_MATCHING", "[", "$", "char", "]", ")", ")", "{", "$", "replacement", ".=", "$", "SYMBOLS_MATCHING", "[", "$", "char", "]", ";", "}", "else", "{", "$", "replacement", ".=", "$", "char", ";", "}", "}", "}", "return", "$", "replacement", ";", "}" ]
Format a php date format string to javascript compatible date format string @param string $php_format The date format (e.g. "d.m.y H:i") @return string The formatted js date string
[ "Format", "a", "php", "date", "format", "string", "to", "javascript", "compatible", "date", "format", "string" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/DateUtil.php#L230-L295
train
heimrichhannot/contao-haste_plus
library/Haste/Model/MemberModel.php
MemberModel.findActiveById
public static function findActiveById($intId, array $arrOptions = []) { $t = static::$strTable; $time = \Date::floorToMinute(); $arrColumns = ["$t.login='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t.disable=''"]; $arrColumns[] = "$t.id = ?"; return static::findOneBy($arrColumns, $intId, $arrOptions); }
php
public static function findActiveById($intId, array $arrOptions = []) { $t = static::$strTable; $time = \Date::floorToMinute(); $arrColumns = ["$t.login='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t.disable=''"]; $arrColumns[] = "$t.id = ?"; return static::findOneBy($arrColumns, $intId, $arrOptions); }
[ "public", "static", "function", "findActiveById", "(", "$", "intId", ",", "array", "$", "arrOptions", "=", "[", "]", ")", "{", "$", "t", "=", "static", "::", "$", "strTable", ";", "$", "time", "=", "\\", "Date", "::", "floorToMinute", "(", ")", ";", "$", "arrColumns", "=", "[", "\"$t.login='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'\"", ".", "(", "$", "time", "+", "60", ")", ".", "\"') AND $t.disable=''\"", "]", ";", "$", "arrColumns", "[", "]", "=", "\"$t.id = ?\"", ";", "return", "static", "::", "findOneBy", "(", "$", "arrColumns", ",", "$", "intId", ",", "$", "arrOptions", ")", ";", "}" ]
Find active members by id @param int $intId @param array $arrOptions @return \MemberModel|\MemberModel[]|\Model\Collection|null
[ "Find", "active", "members", "by", "id" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Model/MemberModel.php#L19-L29
train
heimrichhannot/contao-haste_plus
library/Haste/Model/MemberModel.php
MemberModel.findAllActiveByIds
public static function findAllActiveByIds(array $arrIds, array $arrOptions = []) { $t = static::$strTable; $time = \Date::floorToMinute(); $arrColumns = ["$t.login='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t.disable=''"]; $arrColumns[] = \Database::getInstance()->findInSet('id', $arrIds); return static::findBy($arrColumns, null, $arrOptions); }
php
public static function findAllActiveByIds(array $arrIds, array $arrOptions = []) { $t = static::$strTable; $time = \Date::floorToMinute(); $arrColumns = ["$t.login='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t.disable=''"]; $arrColumns[] = \Database::getInstance()->findInSet('id', $arrIds); return static::findBy($arrColumns, null, $arrOptions); }
[ "public", "static", "function", "findAllActiveByIds", "(", "array", "$", "arrIds", ",", "array", "$", "arrOptions", "=", "[", "]", ")", "{", "$", "t", "=", "static", "::", "$", "strTable", ";", "$", "time", "=", "\\", "Date", "::", "floorToMinute", "(", ")", ";", "$", "arrColumns", "=", "[", "\"$t.login='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'\"", ".", "(", "$", "time", "+", "60", ")", ".", "\"') AND $t.disable=''\"", "]", ";", "$", "arrColumns", "[", "]", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "findInSet", "(", "'id'", ",", "$", "arrIds", ")", ";", "return", "static", "::", "findBy", "(", "$", "arrColumns", ",", "null", ",", "$", "arrOptions", ")", ";", "}" ]
Find active members by ids @param array $arrIds @param array $arrOptions @return \MemberModel|\MemberModel[]|\Model\Collection|null
[ "Find", "active", "members", "by", "ids" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Model/MemberModel.php#L39-L49
train
heimrichhannot/contao-haste_plus
library/Haste/Model/MemberModel.php
MemberModel.findByEmail
public static function findByEmail($strEmail, array $arrOptions = []) { $time = time(); $t = static::$strTable; $arrColumns = ["LOWER($t.email)=? AND ($t.start='' OR $t.start<$time) AND ($t.stop='' OR $t.stop>$time)"]; return static::findOneBy($arrColumns, [$strEmail], $arrOptions); }
php
public static function findByEmail($strEmail, array $arrOptions = []) { $time = time(); $t = static::$strTable; $arrColumns = ["LOWER($t.email)=? AND ($t.start='' OR $t.start<$time) AND ($t.stop='' OR $t.stop>$time)"]; return static::findOneBy($arrColumns, [$strEmail], $arrOptions); }
[ "public", "static", "function", "findByEmail", "(", "$", "strEmail", ",", "array", "$", "arrOptions", "=", "[", "]", ")", "{", "$", "time", "=", "time", "(", ")", ";", "$", "t", "=", "static", "::", "$", "strTable", ";", "$", "arrColumns", "=", "[", "\"LOWER($t.email)=? AND ($t.start='' OR $t.start<$time) AND ($t.stop='' OR $t.stop>$time)\"", "]", ";", "return", "static", "::", "findOneBy", "(", "$", "arrColumns", ",", "[", "$", "strEmail", "]", ",", "$", "arrOptions", ")", ";", "}" ]
Find a member by e-mail-address @param string $strEmail The e-mail address @param array $arrOptions An optional options array @return \Model|null The model or null if there is no member
[ "Find", "a", "member", "by", "e", "-", "mail", "-", "address" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Model/MemberModel.php#L87-L95
train
heimrichhannot/contao-haste_plus
library/Haste/Model/MemberModel.php
MemberModel.findOrCreate
public static function findOrCreate($strEmail) { $objMember = static::findByEmail($strEmail); if ($objMember === null) { $objMember = new \MemberModel(); $objMember->dateAdded = time(); $objMember->tstamp = time(); $objMember->email = trim(strtolower($strEmail)); $objMember->save(); } return $objMember; }
php
public static function findOrCreate($strEmail) { $objMember = static::findByEmail($strEmail); if ($objMember === null) { $objMember = new \MemberModel(); $objMember->dateAdded = time(); $objMember->tstamp = time(); $objMember->email = trim(strtolower($strEmail)); $objMember->save(); } return $objMember; }
[ "public", "static", "function", "findOrCreate", "(", "$", "strEmail", ")", "{", "$", "objMember", "=", "static", "::", "findByEmail", "(", "$", "strEmail", ")", ";", "if", "(", "$", "objMember", "===", "null", ")", "{", "$", "objMember", "=", "new", "\\", "MemberModel", "(", ")", ";", "$", "objMember", "->", "dateAdded", "=", "time", "(", ")", ";", "$", "objMember", "->", "tstamp", "=", "time", "(", ")", ";", "$", "objMember", "->", "email", "=", "trim", "(", "strtolower", "(", "$", "strEmail", ")", ")", ";", "$", "objMember", "->", "save", "(", ")", ";", "}", "return", "$", "objMember", ";", "}" ]
Tries to find a member with the given email address. If found, this member is returned, if not a new member with this email address is created. @param $strEmail @return \MemberModel
[ "Tries", "to", "find", "a", "member", "with", "the", "given", "email", "address", ".", "If", "found", "this", "member", "is", "returned", "if", "not", "a", "new", "member", "with", "this", "email", "address", "is", "created", "." ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Model/MemberModel.php#L104-L118
train
heimrichhannot/contao-haste_plus
library/Haste/Util/DOMUtil.php
DOMUtil.createAttributes
public static function createAttributes($attributes = []) { $list = []; foreach ($attributes as $key => $value) { $list[] = sprintf('%s="%s"', $key, is_array($value) ? implode(' ', $value) : $value); } return implode(' ', $list); }
php
public static function createAttributes($attributes = []) { $list = []; foreach ($attributes as $key => $value) { $list[] = sprintf('%s="%s"', $key, is_array($value) ? implode(' ', $value) : $value); } return implode(' ', $list); }
[ "public", "static", "function", "createAttributes", "(", "$", "attributes", "=", "[", "]", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "list", "[", "]", "=", "sprintf", "(", "'%s=\"%s\"'", ",", "$", "key", ",", "is_array", "(", "$", "value", ")", "?", "implode", "(", "' '", ",", "$", "value", ")", ":", "$", "value", ")", ";", "}", "return", "implode", "(", "' '", ",", "$", "list", ")", ";", "}" ]
Create tag attributes from an array @param array $arrAttributes The tag attributes @return string The attributes as string key="value" key1="value1"
[ "Create", "tag", "attributes", "from", "an", "array" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/DOMUtil.php#L24-L34
train
heimrichhannot/contao-haste_plus
library/Haste/Pdf/PdfTemplate.php
PdfTemplate.writeHtml
public function writeHtml($strHtml, $strCss = '') { $strHtml = ($strCss ? '<style>' . $strCss . '</style>' : '') . $strHtml; $this->objPdf->WriteHTML(html_entity_decode($this->replaceInsertTags($strHtml))); }
php
public function writeHtml($strHtml, $strCss = '') { $strHtml = ($strCss ? '<style>' . $strCss . '</style>' : '') . $strHtml; $this->objPdf->WriteHTML(html_entity_decode($this->replaceInsertTags($strHtml))); }
[ "public", "function", "writeHtml", "(", "$", "strHtml", ",", "$", "strCss", "=", "''", ")", "{", "$", "strHtml", "=", "(", "$", "strCss", "?", "'<style>'", ".", "$", "strCss", ".", "'</style>'", ":", "''", ")", ".", "$", "strHtml", ";", "$", "this", "->", "objPdf", "->", "WriteHTML", "(", "html_entity_decode", "(", "$", "this", "->", "replaceInsertTags", "(", "$", "strHtml", ")", ")", ")", ";", "}" ]
Writes Html-Code into the pdf at the current position @param $strHtml @throws \MpdfException
[ "Writes", "Html", "-", "Code", "into", "the", "pdf", "at", "the", "current", "position" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Pdf/PdfTemplate.php#L65-L70
train
heimrichhannot/contao-haste_plus
library/Haste/Pdf/PdfTemplate.php
PdfTemplate.sendToBrowser
public function sendToBrowser($strFilename = '', $strDest = 'I') { $strFilename = $strFilename ?: $this->buildFilename(); $this->objPdf->Output($strFilename, $strDest); }
php
public function sendToBrowser($strFilename = '', $strDest = 'I') { $strFilename = $strFilename ?: $this->buildFilename(); $this->objPdf->Output($strFilename, $strDest); }
[ "public", "function", "sendToBrowser", "(", "$", "strFilename", "=", "''", ",", "$", "strDest", "=", "'I'", ")", "{", "$", "strFilename", "=", "$", "strFilename", "?", ":", "$", "this", "->", "buildFilename", "(", ")", ";", "$", "this", "->", "objPdf", "->", "Output", "(", "$", "strFilename", ",", "$", "strDest", ")", ";", "}" ]
Sends the pdf to the browser for download. @param string $strFilename The filename @throws \MpdfException
[ "Sends", "the", "pdf", "to", "the", "browser", "for", "download", "." ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Pdf/PdfTemplate.php#L79-L84
train
heimrichhannot/contao-haste_plus
library/Haste/Pdf/PdfTemplate.php
PdfTemplate.saveToFile
public function saveToFile($strFolder, $strFilename = '', $blnSkipDb = false) { $strFilename = $strFilename ?: $this->buildFilename(); // create if not exists new \Folder($strFolder); $this->objPdf->Output(TL_ROOT . '/' . trim($strFolder, '/') . '/' . $strFilename, 'F'); // save database entity if (!$blnSkipDb) { $objFile = new \File(trim($strFolder, '/') . '/' . $strFilename); $objFile->close(); } }
php
public function saveToFile($strFolder, $strFilename = '', $blnSkipDb = false) { $strFilename = $strFilename ?: $this->buildFilename(); // create if not exists new \Folder($strFolder); $this->objPdf->Output(TL_ROOT . '/' . trim($strFolder, '/') . '/' . $strFilename, 'F'); // save database entity if (!$blnSkipDb) { $objFile = new \File(trim($strFolder, '/') . '/' . $strFilename); $objFile->close(); } }
[ "public", "function", "saveToFile", "(", "$", "strFolder", ",", "$", "strFilename", "=", "''", ",", "$", "blnSkipDb", "=", "false", ")", "{", "$", "strFilename", "=", "$", "strFilename", "?", ":", "$", "this", "->", "buildFilename", "(", ")", ";", "// create if not exists", "new", "\\", "Folder", "(", "$", "strFolder", ")", ";", "$", "this", "->", "objPdf", "->", "Output", "(", "TL_ROOT", ".", "'/'", ".", "trim", "(", "$", "strFolder", ",", "'/'", ")", ".", "'/'", ".", "$", "strFilename", ",", "'F'", ")", ";", "// save database entity", "if", "(", "!", "$", "blnSkipDb", ")", "{", "$", "objFile", "=", "new", "\\", "File", "(", "trim", "(", "$", "strFolder", ",", "'/'", ")", ".", "'/'", ".", "$", "strFilename", ")", ";", "$", "objFile", "->", "close", "(", ")", ";", "}", "}" ]
Saves the pdf to file @param $strFolder string The folder as a path without TL_ROOT @param string $strFilename The filename without the path @throws \MpdfException
[ "Saves", "the", "pdf", "to", "file" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Pdf/PdfTemplate.php#L94-L109
train
heimrichhannot/contao-haste_plus
library/Haste/Database/QueryHelper.php
QueryHelper.processInPieces
public static function processInPieces($strCountQuery, $strQuery, $callback = null, $strKey = null, $intBulkSize = 5000) { $objTotal = \Database::getInstance()->execute($strCountQuery); if ($objTotal->total < 1) { return false; } $intBulkSize = intval($intBulkSize); $intTotal = $objTotal->total; $intCycles = $intTotal / $intBulkSize; for ($i = 0; $i <= $intCycles; $i++) { $objResult = \Database::getInstance()->prepare($strQuery)->limit($intBulkSize, $i * $intBulkSize)->execute(); if ($objResult->numRows < 1) { return false; } if (is_callable($callback)) { $arrReturn = []; while (($arrRow = $objResult->fetchAssoc()) !== false) { if ($strKey) { $arrReturn[$arrRow[$strKey]] = $arrRow; continue; } $arrReturn[] = $arrRow; } call_user_func_array($callback, [$arrReturn]); } } return $intTotal; }
php
public static function processInPieces($strCountQuery, $strQuery, $callback = null, $strKey = null, $intBulkSize = 5000) { $objTotal = \Database::getInstance()->execute($strCountQuery); if ($objTotal->total < 1) { return false; } $intBulkSize = intval($intBulkSize); $intTotal = $objTotal->total; $intCycles = $intTotal / $intBulkSize; for ($i = 0; $i <= $intCycles; $i++) { $objResult = \Database::getInstance()->prepare($strQuery)->limit($intBulkSize, $i * $intBulkSize)->execute(); if ($objResult->numRows < 1) { return false; } if (is_callable($callback)) { $arrReturn = []; while (($arrRow = $objResult->fetchAssoc()) !== false) { if ($strKey) { $arrReturn[$arrRow[$strKey]] = $arrRow; continue; } $arrReturn[] = $arrRow; } call_user_func_array($callback, [$arrReturn]); } } return $intTotal; }
[ "public", "static", "function", "processInPieces", "(", "$", "strCountQuery", ",", "$", "strQuery", ",", "$", "callback", "=", "null", ",", "$", "strKey", "=", "null", ",", "$", "intBulkSize", "=", "5000", ")", "{", "$", "objTotal", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "execute", "(", "$", "strCountQuery", ")", ";", "if", "(", "$", "objTotal", "->", "total", "<", "1", ")", "{", "return", "false", ";", "}", "$", "intBulkSize", "=", "intval", "(", "$", "intBulkSize", ")", ";", "$", "intTotal", "=", "$", "objTotal", "->", "total", ";", "$", "intCycles", "=", "$", "intTotal", "/", "$", "intBulkSize", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "$", "intCycles", ";", "$", "i", "++", ")", "{", "$", "objResult", "=", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "$", "strQuery", ")", "->", "limit", "(", "$", "intBulkSize", ",", "$", "i", "*", "$", "intBulkSize", ")", "->", "execute", "(", ")", ";", "if", "(", "$", "objResult", "->", "numRows", "<", "1", ")", "{", "return", "false", ";", "}", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "arrReturn", "=", "[", "]", ";", "while", "(", "(", "$", "arrRow", "=", "$", "objResult", "->", "fetchAssoc", "(", ")", ")", "!==", "false", ")", "{", "if", "(", "$", "strKey", ")", "{", "$", "arrReturn", "[", "$", "arrRow", "[", "$", "strKey", "]", "]", "=", "$", "arrRow", ";", "continue", ";", "}", "$", "arrReturn", "[", "]", "=", "$", "arrRow", ";", "}", "call_user_func_array", "(", "$", "callback", ",", "[", "$", "arrReturn", "]", ")", ";", "}", "}", "return", "$", "intTotal", ";", "}" ]
Process a query in pieces, run callback within each cycle @param string $strCountQuery The query that count the total rows, must contain "Select COUNT(*) as total" @param string $strQuery The query, with the rows that should be iterated over @param callable $callback A callback that should be triggered after each cycle, contains $arrRows of current cycle @param string $strKey The key of the value that should be set as key identifier for the returned result array entries @param int $intBulkSize The bulk size @return bool|int False if nothing to do, otherwise return the total number of processes entities
[ "Process", "a", "query", "in", "pieces", "run", "callback", "within", "each", "cycle" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Database/QueryHelper.php#L59-L102
train
heimrichhannot/contao-haste_plus
library/Haste/Database/QueryHelper.php
QueryHelper.createWhereForSerializedBlob
public static function createWhereForSerializedBlob($strField, array $arrValues, $strCondition = self::SQL_CONDITION_OR, $blnFallback = true) { $where = null; if (!in_array($strCondition, [self::SQL_CONDITION_OR, self::SQL_CONDITION_AND])) { return ''; } foreach ($arrValues as $val) { if ($where !== null) { $where .= " $strCondition "; } $where .= $strCondition == self::SQL_CONDITION_AND ? "(" : ""; $where .= "$strField REGEXP (':\"" . str_replace('\'', '',$val) . "\"')"; if ($blnFallback) { $where .= " OR $strField=" . static::escapeString($val); // backwards compatibility (if field was no array before) } $where .= $strCondition == self::SQL_CONDITION_AND ? ")" : ""; } return "($where)"; }
php
public static function createWhereForSerializedBlob($strField, array $arrValues, $strCondition = self::SQL_CONDITION_OR, $blnFallback = true) { $where = null; if (!in_array($strCondition, [self::SQL_CONDITION_OR, self::SQL_CONDITION_AND])) { return ''; } foreach ($arrValues as $val) { if ($where !== null) { $where .= " $strCondition "; } $where .= $strCondition == self::SQL_CONDITION_AND ? "(" : ""; $where .= "$strField REGEXP (':\"" . str_replace('\'', '',$val) . "\"')"; if ($blnFallback) { $where .= " OR $strField=" . static::escapeString($val); // backwards compatibility (if field was no array before) } $where .= $strCondition == self::SQL_CONDITION_AND ? ")" : ""; } return "($where)"; }
[ "public", "static", "function", "createWhereForSerializedBlob", "(", "$", "strField", ",", "array", "$", "arrValues", ",", "$", "strCondition", "=", "self", "::", "SQL_CONDITION_OR", ",", "$", "blnFallback", "=", "true", ")", "{", "$", "where", "=", "null", ";", "if", "(", "!", "in_array", "(", "$", "strCondition", ",", "[", "self", "::", "SQL_CONDITION_OR", ",", "self", "::", "SQL_CONDITION_AND", "]", ")", ")", "{", "return", "''", ";", "}", "foreach", "(", "$", "arrValues", "as", "$", "val", ")", "{", "if", "(", "$", "where", "!==", "null", ")", "{", "$", "where", ".=", "\" $strCondition \"", ";", "}", "$", "where", ".=", "$", "strCondition", "==", "self", "::", "SQL_CONDITION_AND", "?", "\"(\"", ":", "\"\"", ";", "$", "where", ".=", "\"$strField REGEXP (':\\\"\"", ".", "str_replace", "(", "'\\''", ",", "''", ",", "$", "val", ")", ".", "\"\\\"')\"", ";", "if", "(", "$", "blnFallback", ")", "{", "$", "where", ".=", "\" OR $strField=\"", ".", "static", "::", "escapeString", "(", "$", "val", ")", ";", "// backwards compatibility (if field was no array before)", "}", "$", "where", ".=", "$", "strCondition", "==", "self", "::", "SQL_CONDITION_AND", "?", "\")\"", ":", "\"\"", ";", "}", "return", "\"($where)\"", ";", "}" ]
Create a where condition for fields that contain serialized @param string $strField The field the condition should be checked against accordances @param array $arrValues The values array to check the field against @param string $strCondition SQL_CONDITION_OR | SQL_CONDITION_AND @param bool $blnFallback Set to false if field you know the field was no array in past. @return string
[ "Create", "a", "where", "condition", "for", "fields", "that", "contain", "serialized" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Database/QueryHelper.php#L291-L320
train
heimrichhannot/contao-haste_plus
library/Haste/Database/QueryHelper.php
QueryHelper.computeCondition
public static function computeCondition($strField, $strOperator, $varValue, $strTable = null) { $strOperator = trim(strtolower($strOperator)); $arrValues = []; $strPattern = '?'; $blnAddQuotes = false; if ($strTable) { \Controller::loadDataContainer($strTable); $arrDca = &$GLOBALS['TL_DCA'][$strTable]['fields'][$strField]; if (isset($arrDca['sql']) && stripos($arrDca['sql'], 'blob') !== false) { $blnAddQuotes = true; } } switch ($strOperator) { case static::OPERATOR_UNLIKE: $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%'; break; case static::OPERATOR_EQUAL: $arrValues[] = $varValue; break; case static::OPERATOR_UNEQUAL: case '<>': $arrValues[] = $varValue; break; case static::OPERATOR_LOWER: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_GREATER: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_LOWER_EQUAL: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_GREATER_EQUAL: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_IN: $strPattern = '(' . implode( ',', array_map( function ($value) { return '\'' . $value . '\''; }, explode(',', $varValue) ) ) . ')'; break; case static::OPERATOR_NOT_IN: $strPattern = '(' . implode( ',', array_map( function ($value) { return '\'' . $value . '\''; }, explode(',', $varValue) ) ) . ')'; break; default: $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%'; break; } $strOperator = static::transformVerboseOperator($strOperator); return ["$strField $strOperator $strPattern", $arrValues]; }
php
public static function computeCondition($strField, $strOperator, $varValue, $strTable = null) { $strOperator = trim(strtolower($strOperator)); $arrValues = []; $strPattern = '?'; $blnAddQuotes = false; if ($strTable) { \Controller::loadDataContainer($strTable); $arrDca = &$GLOBALS['TL_DCA'][$strTable]['fields'][$strField]; if (isset($arrDca['sql']) && stripos($arrDca['sql'], 'blob') !== false) { $blnAddQuotes = true; } } switch ($strOperator) { case static::OPERATOR_UNLIKE: $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%'; break; case static::OPERATOR_EQUAL: $arrValues[] = $varValue; break; case static::OPERATOR_UNEQUAL: case '<>': $arrValues[] = $varValue; break; case static::OPERATOR_LOWER: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_GREATER: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_LOWER_EQUAL: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_GREATER_EQUAL: $strPattern = 'CAST(? AS DECIMAL)'; $arrValues[] = $varValue; break; case static::OPERATOR_IN: $strPattern = '(' . implode( ',', array_map( function ($value) { return '\'' . $value . '\''; }, explode(',', $varValue) ) ) . ')'; break; case static::OPERATOR_NOT_IN: $strPattern = '(' . implode( ',', array_map( function ($value) { return '\'' . $value . '\''; }, explode(',', $varValue) ) ) . ')'; break; default: $arrValues[] = '%' . ($blnAddQuotes ? '"' . $varValue . '"' : $varValue) . '%'; break; } $strOperator = static::transformVerboseOperator($strOperator); return ["$strField $strOperator $strPattern", $arrValues]; }
[ "public", "static", "function", "computeCondition", "(", "$", "strField", ",", "$", "strOperator", ",", "$", "varValue", ",", "$", "strTable", "=", "null", ")", "{", "$", "strOperator", "=", "trim", "(", "strtolower", "(", "$", "strOperator", ")", ")", ";", "$", "arrValues", "=", "[", "]", ";", "$", "strPattern", "=", "'?'", ";", "$", "blnAddQuotes", "=", "false", ";", "if", "(", "$", "strTable", ")", "{", "\\", "Controller", "::", "loadDataContainer", "(", "$", "strTable", ")", ";", "$", "arrDca", "=", "&", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "strTable", "]", "[", "'fields'", "]", "[", "$", "strField", "]", ";", "if", "(", "isset", "(", "$", "arrDca", "[", "'sql'", "]", ")", "&&", "stripos", "(", "$", "arrDca", "[", "'sql'", "]", ",", "'blob'", ")", "!==", "false", ")", "{", "$", "blnAddQuotes", "=", "true", ";", "}", "}", "switch", "(", "$", "strOperator", ")", "{", "case", "static", "::", "OPERATOR_UNLIKE", ":", "$", "arrValues", "[", "]", "=", "'%'", ".", "(", "$", "blnAddQuotes", "?", "'\"'", ".", "$", "varValue", ".", "'\"'", ":", "$", "varValue", ")", ".", "'%'", ";", "break", ";", "case", "static", "::", "OPERATOR_EQUAL", ":", "$", "arrValues", "[", "]", "=", "$", "varValue", ";", "break", ";", "case", "static", "::", "OPERATOR_UNEQUAL", ":", "case", "'<>'", ":", "$", "arrValues", "[", "]", "=", "$", "varValue", ";", "break", ";", "case", "static", "::", "OPERATOR_LOWER", ":", "$", "strPattern", "=", "'CAST(? AS DECIMAL)'", ";", "$", "arrValues", "[", "]", "=", "$", "varValue", ";", "break", ";", "case", "static", "::", "OPERATOR_GREATER", ":", "$", "strPattern", "=", "'CAST(? AS DECIMAL)'", ";", "$", "arrValues", "[", "]", "=", "$", "varValue", ";", "break", ";", "case", "static", "::", "OPERATOR_LOWER_EQUAL", ":", "$", "strPattern", "=", "'CAST(? AS DECIMAL)'", ";", "$", "arrValues", "[", "]", "=", "$", "varValue", ";", "break", ";", "case", "static", "::", "OPERATOR_GREATER_EQUAL", ":", "$", "strPattern", "=", "'CAST(? AS DECIMAL)'", ";", "$", "arrValues", "[", "]", "=", "$", "varValue", ";", "break", ";", "case", "static", "::", "OPERATOR_IN", ":", "$", "strPattern", "=", "'('", ".", "implode", "(", "','", ",", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "'\\''", ".", "$", "value", ".", "'\\''", ";", "}", ",", "explode", "(", "','", ",", "$", "varValue", ")", ")", ")", ".", "')'", ";", "break", ";", "case", "static", "::", "OPERATOR_NOT_IN", ":", "$", "strPattern", "=", "'('", ".", "implode", "(", "','", ",", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "'\\''", ".", "$", "value", ".", "'\\''", ";", "}", ",", "explode", "(", "','", ",", "$", "varValue", ")", ")", ")", ".", "')'", ";", "break", ";", "default", ":", "$", "arrValues", "[", "]", "=", "'%'", ".", "(", "$", "blnAddQuotes", "?", "'\"'", ".", "$", "varValue", ".", "'\"'", ":", "$", "varValue", ")", ".", "'%'", ";", "break", ";", "}", "$", "strOperator", "=", "static", "::", "transformVerboseOperator", "(", "$", "strOperator", ")", ";", "return", "[", "\"$strField $strOperator $strPattern\"", ",", "$", "arrValues", "]", ";", "}" ]
Computes a MySQL condition appropriate for the given operator @param $strField @param $strOperator @param $varValue @return array Returns array($strQuery, $arrValues)
[ "Computes", "a", "MySQL", "condition", "appropriate", "for", "the", "given", "operator" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Database/QueryHelper.php#L413-L492
train
heimrichhannot/contao-haste_plus
library/Haste/Model/UserModel.php
UserModel.findActiveByGroups
public static function findActiveByGroups(array $arrGroups, array $arrOptions = []) { if (empty($arrGroups)) { return null; } $t = static::$strTable; $time = \Date::floorToMinute(); $arrColumns = ["($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t.disable=''"]; if (!empty(array_filter($arrGroups))) { $arrColumns[] = QueryHelper::createWhereForSerializedBlob('groups', array_filter($arrGroups)); } return static::findBy($arrColumns, null, $arrOptions); }
php
public static function findActiveByGroups(array $arrGroups, array $arrOptions = []) { if (empty($arrGroups)) { return null; } $t = static::$strTable; $time = \Date::floorToMinute(); $arrColumns = ["($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t.disable=''"]; if (!empty(array_filter($arrGroups))) { $arrColumns[] = QueryHelper::createWhereForSerializedBlob('groups', array_filter($arrGroups)); } return static::findBy($arrColumns, null, $arrOptions); }
[ "public", "static", "function", "findActiveByGroups", "(", "array", "$", "arrGroups", ",", "array", "$", "arrOptions", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "arrGroups", ")", ")", "{", "return", "null", ";", "}", "$", "t", "=", "static", "::", "$", "strTable", ";", "$", "time", "=", "\\", "Date", "::", "floorToMinute", "(", ")", ";", "$", "arrColumns", "=", "[", "\"($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'\"", ".", "(", "$", "time", "+", "60", ")", ".", "\"') AND $t.disable=''\"", "]", ";", "if", "(", "!", "empty", "(", "array_filter", "(", "$", "arrGroups", ")", ")", ")", "{", "$", "arrColumns", "[", "]", "=", "QueryHelper", "::", "createWhereForSerializedBlob", "(", "'groups'", ",", "array_filter", "(", "$", "arrGroups", ")", ")", ";", "}", "return", "static", "::", "findBy", "(", "$", "arrColumns", ",", "null", ",", "$", "arrOptions", ")", ";", "}" ]
Find active users by given user groups @param array $arrGroups @param array $arrOptions @return \UserModel|\UserModel[]|\Model\Collection|null
[ "Find", "active", "users", "by", "given", "user", "groups" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Model/UserModel.php#L26-L44
train
heimrichhannot/contao-haste_plus
library/Haste/Dca/General.php
General.addDateAddedToDca
public static function addDateAddedToDca($strDca) { \Controller::loadDataContainer($strDca); $arrDca = &$GLOBALS['TL_DCA'][$strDca]; $arrDca['config']['onload_callback']['setDateAdded'] = ['HeimrichHannot\Haste\Dca\General', 'setDateAdded', true]; $arrDca['fields']['dateAdded'] = static::getDateAddedField(); }
php
public static function addDateAddedToDca($strDca) { \Controller::loadDataContainer($strDca); $arrDca = &$GLOBALS['TL_DCA'][$strDca]; $arrDca['config']['onload_callback']['setDateAdded'] = ['HeimrichHannot\Haste\Dca\General', 'setDateAdded', true]; $arrDca['fields']['dateAdded'] = static::getDateAddedField(); }
[ "public", "static", "function", "addDateAddedToDca", "(", "$", "strDca", ")", "{", "\\", "Controller", "::", "loadDataContainer", "(", "$", "strDca", ")", ";", "$", "arrDca", "=", "&", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "strDca", "]", ";", "$", "arrDca", "[", "'config'", "]", "[", "'onload_callback'", "]", "[", "'setDateAdded'", "]", "=", "[", "'HeimrichHannot\\Haste\\Dca\\General'", ",", "'setDateAdded'", ",", "true", "]", ";", "$", "arrDca", "[", "'fields'", "]", "[", "'dateAdded'", "]", "=", "static", "::", "getDateAddedField", "(", ")", ";", "}" ]
Adds a date added field to the dca and sets the appropriate callback @param $strDca
[ "Adds", "a", "date", "added", "field", "to", "the", "dca", "and", "sets", "the", "appropriate", "callback" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Dca/General.php#L190-L199
train
heimrichhannot/contao-haste_plus
library/Haste/Dca/General.php
General.setDateAdded
public static function setDateAdded(\DataContainer $objDc) { if ($objDc === null || !$objDc->id || $objDc->activeRecord->dateAdded > 0) { return false; } \Database::getInstance()->prepare("UPDATE $objDc->table SET dateAdded=? WHERE id=? AND dateAdded = 0")->execute(time(), $objDc->id); }
php
public static function setDateAdded(\DataContainer $objDc) { if ($objDc === null || !$objDc->id || $objDc->activeRecord->dateAdded > 0) { return false; } \Database::getInstance()->prepare("UPDATE $objDc->table SET dateAdded=? WHERE id=? AND dateAdded = 0")->execute(time(), $objDc->id); }
[ "public", "static", "function", "setDateAdded", "(", "\\", "DataContainer", "$", "objDc", ")", "{", "if", "(", "$", "objDc", "===", "null", "||", "!", "$", "objDc", "->", "id", "||", "$", "objDc", "->", "activeRecord", "->", "dateAdded", ">", "0", ")", "{", "return", "false", ";", "}", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"UPDATE $objDc->table SET dateAdded=? WHERE id=? AND dateAdded = 0\"", ")", "->", "execute", "(", "time", "(", ")", ",", "$", "objDc", "->", "id", ")", ";", "}" ]
Sets the current date as the date added -> callback function @param \DataContainer $objDc
[ "Sets", "the", "current", "date", "as", "the", "date", "added", "-", ">", "callback", "function" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Dca/General.php#L206-L213
train
heimrichhannot/contao-haste_plus
library/Haste/Dca/General.php
General.addAliasToDca
public static function addAliasToDca($strDca, array $arrGenerateAliasCallback, $strPaletteField, $arrPalettes = ['default']) { \Controller::loadDataContainer($strDca); $arrDca = &$GLOBALS['TL_DCA'][$strDca]; // add to palettes foreach ($arrPalettes as $strPalette) { $arrDca['palettes'][$strPalette] = str_replace($strPaletteField . ',', $strPaletteField . ',alias,', $arrDca['palettes'][$strPalette]); } // add field $arrDca['fields']['alias'] = static::getAliasField($arrGenerateAliasCallback); }
php
public static function addAliasToDca($strDca, array $arrGenerateAliasCallback, $strPaletteField, $arrPalettes = ['default']) { \Controller::loadDataContainer($strDca); $arrDca = &$GLOBALS['TL_DCA'][$strDca]; // add to palettes foreach ($arrPalettes as $strPalette) { $arrDca['palettes'][$strPalette] = str_replace($strPaletteField . ',', $strPaletteField . ',alias,', $arrDca['palettes'][$strPalette]); } // add field $arrDca['fields']['alias'] = static::getAliasField($arrGenerateAliasCallback); }
[ "public", "static", "function", "addAliasToDca", "(", "$", "strDca", ",", "array", "$", "arrGenerateAliasCallback", ",", "$", "strPaletteField", ",", "$", "arrPalettes", "=", "[", "'default'", "]", ")", "{", "\\", "Controller", "::", "loadDataContainer", "(", "$", "strDca", ")", ";", "$", "arrDca", "=", "&", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "strDca", "]", ";", "// add to palettes", "foreach", "(", "$", "arrPalettes", "as", "$", "strPalette", ")", "{", "$", "arrDca", "[", "'palettes'", "]", "[", "$", "strPalette", "]", "=", "str_replace", "(", "$", "strPaletteField", ".", "','", ",", "$", "strPaletteField", ".", "',alias,'", ",", "$", "arrDca", "[", "'palettes'", "]", "[", "$", "strPalette", "]", ")", ";", "}", "// add field", "$", "arrDca", "[", "'fields'", "]", "[", "'alias'", "]", "=", "static", "::", "getAliasField", "(", "$", "arrGenerateAliasCallback", ")", ";", "}" ]
Adds an alias field to the dca and to the desired palettes @param $strDca @param $arrGenerateAliasCallback array The callback to call for generating the alias @param $strPaletteField String The field after which to insert the alias field in the palettes @param array $arrPalettes The palettes in which to insert the field
[ "Adds", "an", "alias", "field", "to", "the", "dca", "and", "to", "the", "desired", "palettes" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Dca/General.php#L236-L249
train
heimrichhannot/contao-haste_plus
library/Haste/Dca/General.php
General.doAddAliasButton
public function doAddAliasButton($arrButtons, \DataContainer $dc) { // Generate the aliases if (\Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias'])) { if (version_compare(VERSION, '4.0', '<')) { $objSessionData = \Session::getInstance()->getData(); $arrIds = $objSessionData['CURRENT']['IDS']; } else { /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $objSession */ $objSession = \System::getContainer()->get('session'); $session = $objSession->all(); $arrIds = $session['CURRENT']['IDS']; } $strItemClass = \Model::getClassFromTable($dc->table); if (!class_exists($strItemClass)) { return $arrButtons; } foreach ($arrIds as $intId) { $objItem = $strItemClass::findByPk($intId); if ($objItem === null) { continue; } $dc->id = $intId; $dc->activeRecord = $objItem; $strAlias = ''; // Generate new alias through save callbacks foreach ($GLOBALS['TL_DCA'][$dc->table]['fields']['alias']['save_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $strAlias = $this->{$callback[0]}->{$callback[1]}($strAlias, $dc); } elseif (is_callable($callback)) { $strAlias = $callback($strAlias, $dc); } } // The alias has not changed if ($strAlias == $objItem->alias) { continue; } // Initialize the version manager $objVersions = new \Versions($dc->table, $intId); $objVersions->initialize(); // Store the new alias \Database::getInstance()->prepare("UPDATE $dc->table SET alias=? WHERE id=?")->execute($strAlias, $intId); // Create a new version $objVersions->create(); } \Controller::redirect($this->getReferer()); } // Add the button if (version_compare(VERSION, '4.0', '<')) { $arrButtons['alias'] = '<input type="submit" name="alias" id="alias" class="tl_submit" accesskey="a" value="' . specialchars( $GLOBALS['TL_LANG']['MSC']['aliasSelected'] ) . '"> '; } else { $arrButtons['alias'] = '<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">' . $GLOBALS['TL_LANG']['MSC']['aliasSelected'] . '</button> '; } return $arrButtons; }
php
public function doAddAliasButton($arrButtons, \DataContainer $dc) { // Generate the aliases if (\Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias'])) { if (version_compare(VERSION, '4.0', '<')) { $objSessionData = \Session::getInstance()->getData(); $arrIds = $objSessionData['CURRENT']['IDS']; } else { /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $objSession */ $objSession = \System::getContainer()->get('session'); $session = $objSession->all(); $arrIds = $session['CURRENT']['IDS']; } $strItemClass = \Model::getClassFromTable($dc->table); if (!class_exists($strItemClass)) { return $arrButtons; } foreach ($arrIds as $intId) { $objItem = $strItemClass::findByPk($intId); if ($objItem === null) { continue; } $dc->id = $intId; $dc->activeRecord = $objItem; $strAlias = ''; // Generate new alias through save callbacks foreach ($GLOBALS['TL_DCA'][$dc->table]['fields']['alias']['save_callback'] as $callback) { if (is_array($callback)) { $this->import($callback[0]); $strAlias = $this->{$callback[0]}->{$callback[1]}($strAlias, $dc); } elseif (is_callable($callback)) { $strAlias = $callback($strAlias, $dc); } } // The alias has not changed if ($strAlias == $objItem->alias) { continue; } // Initialize the version manager $objVersions = new \Versions($dc->table, $intId); $objVersions->initialize(); // Store the new alias \Database::getInstance()->prepare("UPDATE $dc->table SET alias=? WHERE id=?")->execute($strAlias, $intId); // Create a new version $objVersions->create(); } \Controller::redirect($this->getReferer()); } // Add the button if (version_compare(VERSION, '4.0', '<')) { $arrButtons['alias'] = '<input type="submit" name="alias" id="alias" class="tl_submit" accesskey="a" value="' . specialchars( $GLOBALS['TL_LANG']['MSC']['aliasSelected'] ) . '"> '; } else { $arrButtons['alias'] = '<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">' . $GLOBALS['TL_LANG']['MSC']['aliasSelected'] . '</button> '; } return $arrButtons; }
[ "public", "function", "doAddAliasButton", "(", "$", "arrButtons", ",", "\\", "DataContainer", "$", "dc", ")", "{", "// Generate the aliases", "if", "(", "\\", "Input", "::", "post", "(", "'FORM_SUBMIT'", ")", "==", "'tl_select'", "&&", "isset", "(", "$", "_POST", "[", "'alias'", "]", ")", ")", "{", "if", "(", "version_compare", "(", "VERSION", ",", "'4.0'", ",", "'<'", ")", ")", "{", "$", "objSessionData", "=", "\\", "Session", "::", "getInstance", "(", ")", "->", "getData", "(", ")", ";", "$", "arrIds", "=", "$", "objSessionData", "[", "'CURRENT'", "]", "[", "'IDS'", "]", ";", "}", "else", "{", "/** @var \\Symfony\\Component\\HttpFoundation\\Session\\SessionInterface $objSession */", "$", "objSession", "=", "\\", "System", "::", "getContainer", "(", ")", "->", "get", "(", "'session'", ")", ";", "$", "session", "=", "$", "objSession", "->", "all", "(", ")", ";", "$", "arrIds", "=", "$", "session", "[", "'CURRENT'", "]", "[", "'IDS'", "]", ";", "}", "$", "strItemClass", "=", "\\", "Model", "::", "getClassFromTable", "(", "$", "dc", "->", "table", ")", ";", "if", "(", "!", "class_exists", "(", "$", "strItemClass", ")", ")", "{", "return", "$", "arrButtons", ";", "}", "foreach", "(", "$", "arrIds", "as", "$", "intId", ")", "{", "$", "objItem", "=", "$", "strItemClass", "::", "findByPk", "(", "$", "intId", ")", ";", "if", "(", "$", "objItem", "===", "null", ")", "{", "continue", ";", "}", "$", "dc", "->", "id", "=", "$", "intId", ";", "$", "dc", "->", "activeRecord", "=", "$", "objItem", ";", "$", "strAlias", "=", "''", ";", "// Generate new alias through save callbacks", "foreach", "(", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dc", "->", "table", "]", "[", "'fields'", "]", "[", "'alias'", "]", "[", "'save_callback'", "]", "as", "$", "callback", ")", "{", "if", "(", "is_array", "(", "$", "callback", ")", ")", "{", "$", "this", "->", "import", "(", "$", "callback", "[", "0", "]", ")", ";", "$", "strAlias", "=", "$", "this", "->", "{", "$", "callback", "[", "0", "]", "}", "->", "{", "$", "callback", "[", "1", "]", "}", "(", "$", "strAlias", ",", "$", "dc", ")", ";", "}", "elseif", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "strAlias", "=", "$", "callback", "(", "$", "strAlias", ",", "$", "dc", ")", ";", "}", "}", "// The alias has not changed", "if", "(", "$", "strAlias", "==", "$", "objItem", "->", "alias", ")", "{", "continue", ";", "}", "// Initialize the version manager", "$", "objVersions", "=", "new", "\\", "Versions", "(", "$", "dc", "->", "table", ",", "$", "intId", ")", ";", "$", "objVersions", "->", "initialize", "(", ")", ";", "// Store the new alias", "\\", "Database", "::", "getInstance", "(", ")", "->", "prepare", "(", "\"UPDATE $dc->table SET alias=? WHERE id=?\"", ")", "->", "execute", "(", "$", "strAlias", ",", "$", "intId", ")", ";", "// Create a new version", "$", "objVersions", "->", "create", "(", ")", ";", "}", "\\", "Controller", "::", "redirect", "(", "$", "this", "->", "getReferer", "(", ")", ")", ";", "}", "// Add the button", "if", "(", "version_compare", "(", "VERSION", ",", "'4.0'", ",", "'<'", ")", ")", "{", "$", "arrButtons", "[", "'alias'", "]", "=", "'<input type=\"submit\" name=\"alias\" id=\"alias\" class=\"tl_submit\" accesskey=\"a\" value=\"'", ".", "specialchars", "(", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'MSC'", "]", "[", "'aliasSelected'", "]", ")", ".", "'\"> '", ";", "}", "else", "{", "$", "arrButtons", "[", "'alias'", "]", "=", "'<button type=\"submit\" name=\"alias\" id=\"alias\" class=\"tl_submit\" accesskey=\"a\">'", ".", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'MSC'", "]", "[", "'aliasSelected'", "]", ".", "'</button> '", ";", "}", "return", "$", "arrButtons", ";", "}" ]
Generic method for automatically generating aliases @param array $arrButtons @param \DataContainer $dc @return array
[ "Generic", "method", "for", "automatically", "generating", "aliases" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Dca/General.php#L291-L364
train
TheDMSGroup/mautic-contact-ledger
Command/ClientStatsCommand.php
ClientStatsCommand.setDateContext
private function setDateContext(\DateTime $dateContext = null) { if (!$dateContext) { // we havent set context so we need the default to be: now minus 15 mins, rounded to 5 min increment. $now = new \DateTime(); $now->sub(new \DateInterval('PT15M')); // round down to 5 minute increment $now->setTime($now->format('H'), floor($now->format('i') / 5) * 5, 0); $dateContext = $now; } $this->dateContext = $dateContext; }
php
private function setDateContext(\DateTime $dateContext = null) { if (!$dateContext) { // we havent set context so we need the default to be: now minus 15 mins, rounded to 5 min increment. $now = new \DateTime(); $now->sub(new \DateInterval('PT15M')); // round down to 5 minute increment $now->setTime($now->format('H'), floor($now->format('i') / 5) * 5, 0); $dateContext = $now; } $this->dateContext = $dateContext; }
[ "private", "function", "setDateContext", "(", "\\", "DateTime", "$", "dateContext", "=", "null", ")", "{", "if", "(", "!", "$", "dateContext", ")", "{", "// we havent set context so we need the default to be: now minus 15 mins, rounded to 5 min increment.", "$", "now", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "now", "->", "sub", "(", "new", "\\", "DateInterval", "(", "'PT15M'", ")", ")", ";", "// round down to 5 minute increment", "$", "now", "->", "setTime", "(", "$", "now", "->", "format", "(", "'H'", ")", ",", "floor", "(", "$", "now", "->", "format", "(", "'i'", ")", "/", "5", ")", "*", "5", ",", "0", ")", ";", "$", "dateContext", "=", "$", "now", ";", "}", "$", "this", "->", "dateContext", "=", "$", "dateContext", ";", "}" ]
This becomes the dateAdded value to use in report stats table This will be the default To date, which a From date is calculated by subtracting 4 mins 59s. @param \DateTime|null $dateContext @throws \Exception
[ "This", "becomes", "the", "dateAdded", "value", "to", "use", "in", "report", "stats", "table", "This", "will", "be", "the", "default", "To", "date", "which", "a", "From", "date", "is", "calculated", "by", "subtracting", "4", "mins", "59s", "." ]
03655210c95f9e7efc58dfae4fb8baf08f4c8bd1
https://github.com/TheDMSGroup/mautic-contact-ledger/blob/03655210c95f9e7efc58dfae4fb8baf08f4c8bd1/Command/ClientStatsCommand.php#L224-L234
train
TheDMSGroup/mautic-contact-ledger
Command/ClientStatsCommand.php
ClientStatsCommand.getDateParams
private function getDateParams($params) { /** * @var \DateTime */ $to = $this->dateContext; /** * @var \DateTime */ $from = clone $to; $from->sub(new \DateInterval('PT4M')); $from->sub(new \DateInterval('PT59S')); $params['dateFrom'] = $from->format('Y-m-d H:i:s'); $params['dateTo'] = $to->format('Y-m-d H:i:s'); return $params; }
php
private function getDateParams($params) { /** * @var \DateTime */ $to = $this->dateContext; /** * @var \DateTime */ $from = clone $to; $from->sub(new \DateInterval('PT4M')); $from->sub(new \DateInterval('PT59S')); $params['dateFrom'] = $from->format('Y-m-d H:i:s'); $params['dateTo'] = $to->format('Y-m-d H:i:s'); return $params; }
[ "private", "function", "getDateParams", "(", "$", "params", ")", "{", "/**\n * @var \\DateTime\n */", "$", "to", "=", "$", "this", "->", "dateContext", ";", "/**\n * @var \\DateTime\n */", "$", "from", "=", "clone", "$", "to", ";", "$", "from", "->", "sub", "(", "new", "\\", "DateInterval", "(", "'PT4M'", ")", ")", ";", "$", "from", "->", "sub", "(", "new", "\\", "DateInterval", "(", "'PT59S'", ")", ")", ";", "$", "params", "[", "'dateFrom'", "]", "=", "$", "from", "->", "format", "(", "'Y-m-d H:i:s'", ")", ";", "$", "params", "[", "'dateTo'", "]", "=", "$", "to", "->", "format", "(", "'Y-m-d H:i:s'", ")", ";", "return", "$", "params", ";", "}" ]
Return 5 minute to and from intervals based on dateContext. @param string @return array @throws \Exception
[ "Return", "5", "minute", "to", "and", "from", "intervals", "based", "on", "dateContext", "." ]
03655210c95f9e7efc58dfae4fb8baf08f4c8bd1
https://github.com/TheDMSGroup/mautic-contact-ledger/blob/03655210c95f9e7efc58dfae4fb8baf08f4c8bd1/Command/ClientStatsCommand.php#L245-L263
train
heimrichhannot/contao-haste_plus
library/Haste/Maps/GoogleMap.php
GoogleMap.addAssets
public static function addAssets($strBuffer) { if (!class_exists('\delahaye\googlemaps\Googlemap') || \Config::get('loadGoogleMapsAssetsOnDemand')) { return $strBuffer; } \delahaye\googlemaps\Googlemap::CssInjection(); if (!isset($GLOBALS['TL_JAVASCRIPT']['googlemaps'])) { $strUrl = '//maps.google.com/maps/api/js'; $strUrl = Url::addQueryString('language=' . $GLOBALS['TL_LANGUAGE'], $strUrl); global $objPage; if (($objRootPage = \PageModel::findPublishedById($objPage->rootId)) !== null && $objRootPage->dlh_googlemaps_apikey) { $strUrl = Url::addQueryString('key=' . $objRootPage->dlh_googlemaps_apikey, $strUrl); } $GLOBALS['TL_JAVASCRIPT']['googlemaps'] = $strUrl; } if (!isset($GLOBALS['TL_JAVASCRIPT']['googlemaps_clustering'])) { $GLOBALS['TL_JAVASCRIPT']['googlemaps_clustering'] = 'system/modules/haste_plus/assets/js/vendor/marker-clustering/markerclusterer.min.js|static'; } return $strBuffer; }
php
public static function addAssets($strBuffer) { if (!class_exists('\delahaye\googlemaps\Googlemap') || \Config::get('loadGoogleMapsAssetsOnDemand')) { return $strBuffer; } \delahaye\googlemaps\Googlemap::CssInjection(); if (!isset($GLOBALS['TL_JAVASCRIPT']['googlemaps'])) { $strUrl = '//maps.google.com/maps/api/js'; $strUrl = Url::addQueryString('language=' . $GLOBALS['TL_LANGUAGE'], $strUrl); global $objPage; if (($objRootPage = \PageModel::findPublishedById($objPage->rootId)) !== null && $objRootPage->dlh_googlemaps_apikey) { $strUrl = Url::addQueryString('key=' . $objRootPage->dlh_googlemaps_apikey, $strUrl); } $GLOBALS['TL_JAVASCRIPT']['googlemaps'] = $strUrl; } if (!isset($GLOBALS['TL_JAVASCRIPT']['googlemaps_clustering'])) { $GLOBALS['TL_JAVASCRIPT']['googlemaps_clustering'] = 'system/modules/haste_plus/assets/js/vendor/marker-clustering/markerclusterer.min.js|static'; } return $strBuffer; }
[ "public", "static", "function", "addAssets", "(", "$", "strBuffer", ")", "{", "if", "(", "!", "class_exists", "(", "'\\delahaye\\googlemaps\\Googlemap'", ")", "||", "\\", "Config", "::", "get", "(", "'loadGoogleMapsAssetsOnDemand'", ")", ")", "{", "return", "$", "strBuffer", ";", "}", "\\", "delahaye", "\\", "googlemaps", "\\", "Googlemap", "::", "CssInjection", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "'googlemaps'", "]", ")", ")", "{", "$", "strUrl", "=", "'//maps.google.com/maps/api/js'", ";", "$", "strUrl", "=", "Url", "::", "addQueryString", "(", "'language='", ".", "$", "GLOBALS", "[", "'TL_LANGUAGE'", "]", ",", "$", "strUrl", ")", ";", "global", "$", "objPage", ";", "if", "(", "(", "$", "objRootPage", "=", "\\", "PageModel", "::", "findPublishedById", "(", "$", "objPage", "->", "rootId", ")", ")", "!==", "null", "&&", "$", "objRootPage", "->", "dlh_googlemaps_apikey", ")", "{", "$", "strUrl", "=", "Url", "::", "addQueryString", "(", "'key='", ".", "$", "objRootPage", "->", "dlh_googlemaps_apikey", ",", "$", "strUrl", ")", ";", "}", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "'googlemaps'", "]", "=", "$", "strUrl", ";", "}", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "'googlemaps_clustering'", "]", ")", ")", "{", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "'googlemaps_clustering'", "]", "=", "'system/modules/haste_plus/assets/js/vendor/marker-clustering/markerclusterer.min.js|static'", ";", "}", "return", "$", "strBuffer", ";", "}" ]
Add google maps assets @param string $strBuffer Current frontend template buffer (replaceDynamicScriptTags HOOK) @return string $strBuffer Modified frontend template buffer (replaceDynamicScriptTags HOOK)
[ "Add", "google", "maps", "assets" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Maps/GoogleMap.php#L127-L155
train
heimrichhannot/contao-haste_plus
library/Haste/InsertTags/InsertTags.php
InsertTags.replace
public function replace($strTag, $blnCache, $strCache, $flags, $tags, $arrCache, $index, $count) { $elements = explode('::', $strTag); switch (strtolower($elements[0])) { case 'trimsplit': if (!$elements[1] || !$elements[2] || is_array($elements[2]) || is_object($elements[2])) { return ''; } return serialize(trimsplit($elements[1], $elements[2])); break; case 'encrypt': if (!$elements[1]) { return ''; } return \Encryption::hash($elements[1]); break; } return false; }
php
public function replace($strTag, $blnCache, $strCache, $flags, $tags, $arrCache, $index, $count) { $elements = explode('::', $strTag); switch (strtolower($elements[0])) { case 'trimsplit': if (!$elements[1] || !$elements[2] || is_array($elements[2]) || is_object($elements[2])) { return ''; } return serialize(trimsplit($elements[1], $elements[2])); break; case 'encrypt': if (!$elements[1]) { return ''; } return \Encryption::hash($elements[1]); break; } return false; }
[ "public", "function", "replace", "(", "$", "strTag", ",", "$", "blnCache", ",", "$", "strCache", ",", "$", "flags", ",", "$", "tags", ",", "$", "arrCache", ",", "$", "index", ",", "$", "count", ")", "{", "$", "elements", "=", "explode", "(", "'::'", ",", "$", "strTag", ")", ";", "switch", "(", "strtolower", "(", "$", "elements", "[", "0", "]", ")", ")", "{", "case", "'trimsplit'", ":", "if", "(", "!", "$", "elements", "[", "1", "]", "||", "!", "$", "elements", "[", "2", "]", "||", "is_array", "(", "$", "elements", "[", "2", "]", ")", "||", "is_object", "(", "$", "elements", "[", "2", "]", ")", ")", "{", "return", "''", ";", "}", "return", "serialize", "(", "trimsplit", "(", "$", "elements", "[", "1", "]", ",", "$", "elements", "[", "2", "]", ")", ")", ";", "break", ";", "case", "'encrypt'", ":", "if", "(", "!", "$", "elements", "[", "1", "]", ")", "{", "return", "''", ";", "}", "return", "\\", "Encryption", "::", "hash", "(", "$", "elements", "[", "1", "]", ")", ";", "break", ";", "}", "return", "false", ";", "}" ]
Add additional tags @param $strTag @param $blnCache @param $strCache @param $flags @param $tags @param $arrCache @param $index @param $count @return mixed Return false, if the tag was not replaced, otherwise return the value of the replaced tag
[ "Add", "additional", "tags" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/InsertTags/InsertTags.php#L31-L57
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Widget.php
Widget.getBackendFormField
public static function getBackendFormField($strField, array $arrDca, $varValue = null, $strDbField = '', $strTable = '', $objDca = null) { if (!($strClass = $GLOBALS['BE_FFL'][$arrDca['inputType']])) { return false; } return new $strClass(\Widget::getAttributesFromDca($arrDca, $strField, $varValue, $strDbField, $strTable, $objDca)); }
php
public static function getBackendFormField($strField, array $arrDca, $varValue = null, $strDbField = '', $strTable = '', $objDca = null) { if (!($strClass = $GLOBALS['BE_FFL'][$arrDca['inputType']])) { return false; } return new $strClass(\Widget::getAttributesFromDca($arrDca, $strField, $varValue, $strDbField, $strTable, $objDca)); }
[ "public", "static", "function", "getBackendFormField", "(", "$", "strField", ",", "array", "$", "arrDca", ",", "$", "varValue", "=", "null", ",", "$", "strDbField", "=", "''", ",", "$", "strTable", "=", "''", ",", "$", "objDca", "=", "null", ")", "{", "if", "(", "!", "(", "$", "strClass", "=", "$", "GLOBALS", "[", "'BE_FFL'", "]", "[", "$", "arrDca", "[", "'inputType'", "]", "]", ")", ")", "{", "return", "false", ";", "}", "return", "new", "$", "strClass", "(", "\\", "Widget", "::", "getAttributesFromDca", "(", "$", "arrDca", ",", "$", "strField", ",", "$", "varValue", ",", "$", "strDbField", ",", "$", "strTable", ",", "$", "objDca", ")", ")", ";", "}" ]
Get an instance of \Widget by passing fieldname and dca data @param $strField string The field name @param $arrDca array The DCA @param null $varValue array @param string $strDbField string The database field name @param string $strTable The table @param null $objDca object The data container @return bool
[ "Get", "an", "instance", "of", "\\", "Widget", "by", "passing", "fieldname", "and", "dca", "data" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Widget.php#L130-L138
train
TheDMSGroup/mautic-contact-ledger
EventListener/ContactLedgerContextSubscriber.php
ContactLedgerContextSubscriber.contextCreate
public function contextCreate(Event $event) { if (method_exists($event, 'getCampaign')) { $this->campaign = $event->getCampaign(); } if (method_exists($event, 'getActor')) { $this->actor = $event->getActor(); } if (method_exists($event, 'getActivity')) { $this->activity = $event->getActivity(); } if (method_exists($event, 'getMemo')) { $this->memo = $event->getMemo(); } if (method_exists($event, 'getLead')) { $this->lead = $event->getLead(); } }
php
public function contextCreate(Event $event) { if (method_exists($event, 'getCampaign')) { $this->campaign = $event->getCampaign(); } if (method_exists($event, 'getActor')) { $this->actor = $event->getActor(); } if (method_exists($event, 'getActivity')) { $this->activity = $event->getActivity(); } if (method_exists($event, 'getMemo')) { $this->memo = $event->getMemo(); } if (method_exists($event, 'getLead')) { $this->lead = $event->getLead(); } }
[ "public", "function", "contextCreate", "(", "Event", "$", "event", ")", "{", "if", "(", "method_exists", "(", "$", "event", ",", "'getCampaign'", ")", ")", "{", "$", "this", "->", "campaign", "=", "$", "event", "->", "getCampaign", "(", ")", ";", "}", "if", "(", "method_exists", "(", "$", "event", ",", "'getActor'", ")", ")", "{", "$", "this", "->", "actor", "=", "$", "event", "->", "getActor", "(", ")", ";", "}", "if", "(", "method_exists", "(", "$", "event", ",", "'getActivity'", ")", ")", "{", "$", "this", "->", "activity", "=", "$", "event", "->", "getActivity", "(", ")", ";", "}", "if", "(", "method_exists", "(", "$", "event", ",", "'getMemo'", ")", ")", "{", "$", "this", "->", "memo", "=", "$", "event", "->", "getMemo", "(", ")", ";", "}", "if", "(", "method_exists", "(", "$", "event", ",", "'getLead'", ")", ")", "{", "$", "this", "->", "lead", "=", "$", "event", "->", "getLead", "(", ")", ";", "}", "}" ]
This method expects an event comparable with the definition in \MauticPlugin\MauticContactLedgerBundle\Event\ContactLedgerContextEventInterface However, to minimize inter-plugin dependencies, any \Symfony\Component\EventDispatcher\Event is allowed. @param Event $event
[ "This", "method", "expects", "an", "event", "comparable", "with", "the", "definition", "in", "\\", "MauticPlugin", "\\", "MauticContactLedgerBundle", "\\", "Event", "\\", "ContactLedgerContextEventInterface", "However", "to", "minimize", "inter", "-", "plugin", "dependencies", "any", "\\", "Symfony", "\\", "Component", "\\", "EventDispatcher", "\\", "Event", "is", "allowed", "." ]
03655210c95f9e7efc58dfae4fb8baf08f4c8bd1
https://github.com/TheDMSGroup/mautic-contact-ledger/blob/03655210c95f9e7efc58dfae4fb8baf08f4c8bd1/EventListener/ContactLedgerContextSubscriber.php#L55-L72
train
heimrichhannot/contao-haste_plus
library/Haste/Util/StringUtil.php
StringUtil.slimText
public static function slimText($strText, $intLength = null, $allowedTags = '<p><br><br/>') { $strText = strip_tags($strText, $allowedTags); if ($intLength !== null) { $strText = static::truncateHtml($strText, $intLength); } $strText = str_replace(['[-]', '&shy;', '[nbsp]', '&nbsp;'], ['', '', ' ', ' '], $strText); return $strText; }
php
public static function slimText($strText, $intLength = null, $allowedTags = '<p><br><br/>') { $strText = strip_tags($strText, $allowedTags); if ($intLength !== null) { $strText = static::truncateHtml($strText, $intLength); } $strText = str_replace(['[-]', '&shy;', '[nbsp]', '&nbsp;'], ['', '', ' ', ' '], $strText); return $strText; }
[ "public", "static", "function", "slimText", "(", "$", "strText", ",", "$", "intLength", "=", "null", ",", "$", "allowedTags", "=", "'<p><br><br/>'", ")", "{", "$", "strText", "=", "strip_tags", "(", "$", "strText", ",", "$", "allowedTags", ")", ";", "if", "(", "$", "intLength", "!==", "null", ")", "{", "$", "strText", "=", "static", "::", "truncateHtml", "(", "$", "strText", ",", "$", "intLength", ")", ";", "}", "$", "strText", "=", "str_replace", "(", "[", "'[-]'", ",", "'&shy;'", ",", "'[nbsp]'", ",", "'&nbsp;'", "]", ",", "[", "''", ",", "''", ",", "' '", ",", "' '", "]", ",", "$", "strText", ")", ";", "return", "$", "strText", ";", "}" ]
Strip tags from text and truncate if needed @param $strText The text @param null $intLength Truncate length or null if not needed @param string $allowedTags Allowed tags for strip_tags @return string The slim text
[ "Strip", "tags", "from", "text", "and", "truncate", "if", "needed" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/StringUtil.php#L89-L100
train
heimrichhannot/contao-haste_plus
library/Haste/Security/HttpResponse.php
HttpResponse.setSecurityHeaders
public static function setSecurityHeaders($strBuffer, $strTemplate) { if (version_compare(VERSION, "4.4", ">=")) { return $strBuffer; } if (\Config::get('headerAddXFrame')) { static::addXFrame(); } if (\Config::get('headerAllowOrigins')) { static::allowOrigins(); } return $strBuffer; }
php
public static function setSecurityHeaders($strBuffer, $strTemplate) { if (version_compare(VERSION, "4.4", ">=")) { return $strBuffer; } if (\Config::get('headerAddXFrame')) { static::addXFrame(); } if (\Config::get('headerAllowOrigins')) { static::allowOrigins(); } return $strBuffer; }
[ "public", "static", "function", "setSecurityHeaders", "(", "$", "strBuffer", ",", "$", "strTemplate", ")", "{", "if", "(", "version_compare", "(", "VERSION", ",", "\"4.4\"", ",", "\">=\"", ")", ")", "{", "return", "$", "strBuffer", ";", "}", "if", "(", "\\", "Config", "::", "get", "(", "'headerAddXFrame'", ")", ")", "{", "static", "::", "addXFrame", "(", ")", ";", "}", "if", "(", "\\", "Config", "::", "get", "(", "'headerAllowOrigins'", ")", ")", "{", "static", "::", "allowOrigins", "(", ")", ";", "}", "return", "$", "strBuffer", ";", "}" ]
Set security headers NOTE ABOUT CONTAO 4: This won't work with contao 4 anymore. See readme about further informations! @param $strBuffer @param $strTemplate @return mixed
[ "Set", "security", "headers" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Security/HttpResponse.php#L32-L50
train
heimrichhannot/contao-haste_plus
library/Haste/Security/HttpResponse.php
HttpResponse.addXFrame
public static function addXFrame() { global $objPage; $arrSkipPages = deserialize(\Config::get('headerXFrameSkipPages'), true); if (in_array($objPage->id, $arrSkipPages)) { return; } header("X-Frame-Options: SAMEORIGIN"); }
php
public static function addXFrame() { global $objPage; $arrSkipPages = deserialize(\Config::get('headerXFrameSkipPages'), true); if (in_array($objPage->id, $arrSkipPages)) { return; } header("X-Frame-Options: SAMEORIGIN"); }
[ "public", "static", "function", "addXFrame", "(", ")", "{", "global", "$", "objPage", ";", "$", "arrSkipPages", "=", "deserialize", "(", "\\", "Config", "::", "get", "(", "'headerXFrameSkipPages'", ")", ",", "true", ")", ";", "if", "(", "in_array", "(", "$", "objPage", "->", "id", ",", "$", "arrSkipPages", ")", ")", "{", "return", ";", "}", "header", "(", "\"X-Frame-Options: SAMEORIGIN\"", ")", ";", "}" ]
Protect against IFRAME Clickjacking
[ "Protect", "against", "IFRAME", "Clickjacking" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Security/HttpResponse.php#L55-L67
train
heimrichhannot/contao-haste_plus
library/Haste/Security/HttpResponse.php
HttpResponse.allowOrigins
public static function allowOrigins() { $arrPaths = \HeimrichHannot\Haste\Util\Environment::getAvailableOrigins(); $arrReferer = parse_url(\Environment::get('httpReferer')); $strRefereHost = $arrReferer['scheme'] . '://' . $arrReferer['host']; // check if current request url http://<host> is part of available origins if (!empty($arrPaths) && is_array($arrPaths) && in_array($strRefereHost, $arrPaths)) { header('Access-Control-Allow-Origin: ' . $strRefereHost); header('Access-Control-Allow-Headers: X-Requested-With'); } }
php
public static function allowOrigins() { $arrPaths = \HeimrichHannot\Haste\Util\Environment::getAvailableOrigins(); $arrReferer = parse_url(\Environment::get('httpReferer')); $strRefereHost = $arrReferer['scheme'] . '://' . $arrReferer['host']; // check if current request url http://<host> is part of available origins if (!empty($arrPaths) && is_array($arrPaths) && in_array($strRefereHost, $arrPaths)) { header('Access-Control-Allow-Origin: ' . $strRefereHost); header('Access-Control-Allow-Headers: X-Requested-With'); } }
[ "public", "static", "function", "allowOrigins", "(", ")", "{", "$", "arrPaths", "=", "\\", "HeimrichHannot", "\\", "Haste", "\\", "Util", "\\", "Environment", "::", "getAvailableOrigins", "(", ")", ";", "$", "arrReferer", "=", "parse_url", "(", "\\", "Environment", "::", "get", "(", "'httpReferer'", ")", ")", ";", "$", "strRefereHost", "=", "$", "arrReferer", "[", "'scheme'", "]", ".", "'://'", ".", "$", "arrReferer", "[", "'host'", "]", ";", "// check if current request url http://<host> is part of available origins", "if", "(", "!", "empty", "(", "$", "arrPaths", ")", "&&", "is_array", "(", "$", "arrPaths", ")", "&&", "in_array", "(", "$", "strRefereHost", ",", "$", "arrPaths", ")", ")", "{", "header", "(", "'Access-Control-Allow-Origin: '", ".", "$", "strRefereHost", ")", ";", "header", "(", "'Access-Control-Allow-Headers: X-Requested-With'", ")", ";", "}", "}" ]
Set Access-Control-Allow-Origins if user request is part of current contao environment otherwise the following error: 'Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.' may occur if origins are not given
[ "Set", "Access", "-", "Control", "-", "Allow", "-", "Origins", "if", "user", "request", "is", "part", "of", "current", "contao", "environment" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Security/HttpResponse.php#L77-L90
train
heimrichhannot/contao-haste_plus
library/Haste/Model/Model.php
Model.removeModelFromCollection
public static function removeModelFromCollection(\Model $objModel, \Model\Collection $objCollection = null) { $arrRegistered = []; if ($objCollection !== null) { while ($objCollection->next()) { if ($objCollection->getTable() !== $objModel->getTable) { return $objCollection; } $intId = $objCollection->{$objModel::getPk()}; if ($objModel->{$objModel::getPk()} == $intId) { continue; } $arrRegistered[$intId] = $objCollection->current(); } } return static::createCollection(array_filter(array_values($arrRegistered)), $objModel->getTable()); }
php
public static function removeModelFromCollection(\Model $objModel, \Model\Collection $objCollection = null) { $arrRegistered = []; if ($objCollection !== null) { while ($objCollection->next()) { if ($objCollection->getTable() !== $objModel->getTable) { return $objCollection; } $intId = $objCollection->{$objModel::getPk()}; if ($objModel->{$objModel::getPk()} == $intId) { continue; } $arrRegistered[$intId] = $objCollection->current(); } } return static::createCollection(array_filter(array_values($arrRegistered)), $objModel->getTable()); }
[ "public", "static", "function", "removeModelFromCollection", "(", "\\", "Model", "$", "objModel", ",", "\\", "Model", "\\", "Collection", "$", "objCollection", "=", "null", ")", "{", "$", "arrRegistered", "=", "[", "]", ";", "if", "(", "$", "objCollection", "!==", "null", ")", "{", "while", "(", "$", "objCollection", "->", "next", "(", ")", ")", "{", "if", "(", "$", "objCollection", "->", "getTable", "(", ")", "!==", "$", "objModel", "->", "getTable", ")", "{", "return", "$", "objCollection", ";", "}", "$", "intId", "=", "$", "objCollection", "->", "{", "$", "objModel", "::", "getPk", "(", ")", "}", ";", "if", "(", "$", "objModel", "->", "{", "$", "objModel", "::", "getPk", "(", ")", "}", "==", "$", "intId", ")", "{", "continue", ";", "}", "$", "arrRegistered", "[", "$", "intId", "]", "=", "$", "objCollection", "->", "current", "(", ")", ";", "}", "}", "return", "static", "::", "createCollection", "(", "array_filter", "(", "array_values", "(", "$", "arrRegistered", ")", ")", ",", "$", "objModel", "->", "getTable", "(", ")", ")", ";", "}" ]
Remove a model from a collection @param \Model $objModel @param \Model\Collection|null $objCollection @return \Model\Collection|null
[ "Remove", "a", "model", "from", "a", "collection" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Model/Model.php#L40-L65
train
heimrichhannot/contao-haste_plus
library/Haste/Util/PaymentUtil.php
PaymentUtil.generateSEPAMandateReference
public static function generateSEPAMandateReference($prefix = '', $suffix = '', $length = 35, $useSpecialCharacters = false, $useLetters = true, $useNumbers = true) { if (!is_string($prefix) || !is_string($suffix) || !is_int($length)) { throw new InvalidArgumentException(); } if ($length > 35) { throw new InputRangeException("SEPA mandate reference number must not be greater thant 35!"); } $length -= strlen($prefix); $length -= strlen($suffix); if ($length <= 0) { throw new InputRangeException("Length argument to small to have an random part in SEPA mandate reference."); } if (!$useSpecialCharacters && !$useLetters && !$useNumbers) { throw new InputRangeException("You need at least one allowed character type to generate a random string."); } $allowedCharacters = []; if ($useSpecialCharacters) { $allowedCharacters = array_merge($allowedCharacters, str_split(static::MANDATE_REFERENCE_ALLOWED_SPECIAL_CHARACTERS)); } if ($useLetters) { $allowedCharacters = array_merge($allowedCharacters, range('A','Z')); } if ($useNumbers) { $allowedCharacters = array_merge($allowedCharacters, range('0','9')); } $max = count($allowedCharacters) - 1; $reference = ''; for ($i = 0; $i < $length; $i++) { $rand = mt_rand(0, $max); $reference .= $allowedCharacters[$rand]; } return strtoupper($prefix).$reference.strtoupper($suffix); }
php
public static function generateSEPAMandateReference($prefix = '', $suffix = '', $length = 35, $useSpecialCharacters = false, $useLetters = true, $useNumbers = true) { if (!is_string($prefix) || !is_string($suffix) || !is_int($length)) { throw new InvalidArgumentException(); } if ($length > 35) { throw new InputRangeException("SEPA mandate reference number must not be greater thant 35!"); } $length -= strlen($prefix); $length -= strlen($suffix); if ($length <= 0) { throw new InputRangeException("Length argument to small to have an random part in SEPA mandate reference."); } if (!$useSpecialCharacters && !$useLetters && !$useNumbers) { throw new InputRangeException("You need at least one allowed character type to generate a random string."); } $allowedCharacters = []; if ($useSpecialCharacters) { $allowedCharacters = array_merge($allowedCharacters, str_split(static::MANDATE_REFERENCE_ALLOWED_SPECIAL_CHARACTERS)); } if ($useLetters) { $allowedCharacters = array_merge($allowedCharacters, range('A','Z')); } if ($useNumbers) { $allowedCharacters = array_merge($allowedCharacters, range('0','9')); } $max = count($allowedCharacters) - 1; $reference = ''; for ($i = 0; $i < $length; $i++) { $rand = mt_rand(0, $max); $reference .= $allowedCharacters[$rand]; } return strtoupper($prefix).$reference.strtoupper($suffix); }
[ "public", "static", "function", "generateSEPAMandateReference", "(", "$", "prefix", "=", "''", ",", "$", "suffix", "=", "''", ",", "$", "length", "=", "35", ",", "$", "useSpecialCharacters", "=", "false", ",", "$", "useLetters", "=", "true", ",", "$", "useNumbers", "=", "true", ")", "{", "if", "(", "!", "is_string", "(", "$", "prefix", ")", "||", "!", "is_string", "(", "$", "suffix", ")", "||", "!", "is_int", "(", "$", "length", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", ")", ";", "}", "if", "(", "$", "length", ">", "35", ")", "{", "throw", "new", "InputRangeException", "(", "\"SEPA mandate reference number must not be greater thant 35!\"", ")", ";", "}", "$", "length", "-=", "strlen", "(", "$", "prefix", ")", ";", "$", "length", "-=", "strlen", "(", "$", "suffix", ")", ";", "if", "(", "$", "length", "<=", "0", ")", "{", "throw", "new", "InputRangeException", "(", "\"Length argument to small to have an random part in SEPA mandate reference.\"", ")", ";", "}", "if", "(", "!", "$", "useSpecialCharacters", "&&", "!", "$", "useLetters", "&&", "!", "$", "useNumbers", ")", "{", "throw", "new", "InputRangeException", "(", "\"You need at least one allowed character type to generate a random string.\"", ")", ";", "}", "$", "allowedCharacters", "=", "[", "]", ";", "if", "(", "$", "useSpecialCharacters", ")", "{", "$", "allowedCharacters", "=", "array_merge", "(", "$", "allowedCharacters", ",", "str_split", "(", "static", "::", "MANDATE_REFERENCE_ALLOWED_SPECIAL_CHARACTERS", ")", ")", ";", "}", "if", "(", "$", "useLetters", ")", "{", "$", "allowedCharacters", "=", "array_merge", "(", "$", "allowedCharacters", ",", "range", "(", "'A'", ",", "'Z'", ")", ")", ";", "}", "if", "(", "$", "useNumbers", ")", "{", "$", "allowedCharacters", "=", "array_merge", "(", "$", "allowedCharacters", ",", "range", "(", "'0'", ",", "'9'", ")", ")", ";", "}", "$", "max", "=", "count", "(", "$", "allowedCharacters", ")", "-", "1", ";", "$", "reference", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "++", ")", "{", "$", "rand", "=", "mt_rand", "(", "0", ",", "$", "max", ")", ";", "$", "reference", ".=", "$", "allowedCharacters", "[", "$", "rand", "]", ";", "}", "return", "strtoupper", "(", "$", "prefix", ")", ".", "$", "reference", ".", "strtoupper", "(", "$", "suffix", ")", ";", "}" ]
Generate a SEPA mandate reference @param string $prefix Will be prepended to the mandate reference. Counted into length. @param string $suffix Will be appended to the mandate reference. Counted into length. @param int $length Max length is 35. Higher length will throw InputRangeException. Length shorted or same as count of prefix and suffix will throw InputRangeException. @param bool $useSpecialCharacters Activate usage of special characters for reference generation. Default: false @param bool $useLetters Activate usage of letters (A-Z) for reference generation. Default: true @param bool $useNumbers Activate usage of numbers (0-9) for reference generation. Default: true @return string An uppercase SEPA mandate reference of given length. @throws InputRangeException Thrown if length is to long or to short and if all character types are set to false. @throws InvalidArgumentException Will be throws if called with wrong file types.
[ "Generate", "a", "SEPA", "mandate", "reference" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/PaymentUtil.php#L35-L73
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Arrays.php
Arrays.getListPositonCssClass
public static function getListPositonCssClass($key, array $arrList, $blnReturnAsArray = false) { $arrClasses = []; $idx = array_search($key, array_keys($arrList), true); if ($idx === false) { return $blnReturnAsArray ? $arrClasses : ''; } if ($idx == 0) { $arrClasses[] = 'first'; } $arrClasses[] = ($idx % 2 == 0) ? 'odd' : 'even'; if ($idx + 1 == count($arrList)) { $arrClasses[] = 'last'; } return $blnReturnAsArray ? $arrClasses : implode(' ', $arrClasses); }
php
public static function getListPositonCssClass($key, array $arrList, $blnReturnAsArray = false) { $arrClasses = []; $idx = array_search($key, array_keys($arrList), true); if ($idx === false) { return $blnReturnAsArray ? $arrClasses : ''; } if ($idx == 0) { $arrClasses[] = 'first'; } $arrClasses[] = ($idx % 2 == 0) ? 'odd' : 'even'; if ($idx + 1 == count($arrList)) { $arrClasses[] = 'last'; } return $blnReturnAsArray ? $arrClasses : implode(' ', $arrClasses); }
[ "public", "static", "function", "getListPositonCssClass", "(", "$", "key", ",", "array", "$", "arrList", ",", "$", "blnReturnAsArray", "=", "false", ")", "{", "$", "arrClasses", "=", "[", "]", ";", "$", "idx", "=", "array_search", "(", "$", "key", ",", "array_keys", "(", "$", "arrList", ")", ",", "true", ")", ";", "if", "(", "$", "idx", "===", "false", ")", "{", "return", "$", "blnReturnAsArray", "?", "$", "arrClasses", ":", "''", ";", "}", "if", "(", "$", "idx", "==", "0", ")", "{", "$", "arrClasses", "[", "]", "=", "'first'", ";", "}", "$", "arrClasses", "[", "]", "=", "(", "$", "idx", "%", "2", "==", "0", ")", "?", "'odd'", ":", "'even'", ";", "if", "(", "$", "idx", "+", "1", "==", "count", "(", "$", "arrList", ")", ")", "{", "$", "arrClasses", "[", "]", "=", "'last'", ";", "}", "return", "$", "blnReturnAsArray", "?", "$", "arrClasses", ":", "implode", "(", "' '", ",", "$", "arrClasses", ")", ";", "}" ]
Create the class names for an item within a array list @param $key mixed The current index @param $arrList array The array list @param $blnReturnAsArray boolean Return as array, or String @return string | array String of class names, or an array if $blnReturnAsArray is true.
[ "Create", "the", "class", "names", "for", "an", "item", "within", "a", "array", "list" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Arrays.php#L26-L50
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Arrays.php
Arrays.filterByPrefixes
public static function filterByPrefixes(array $arrData = [], $arrPrefixes = []) { $arrExtract = []; if (!is_array($arrPrefixes) || empty($arrPrefixes)) { return $arrData; } foreach ($arrData as $key => $value) { foreach ($arrPrefixes as $strPrefix) { if (\HeimrichHannot\Haste\Util\StringUtil::startsWith($key, $strPrefix)) { $arrExtract[$key] = $value; } } } return $arrExtract; }
php
public static function filterByPrefixes(array $arrData = [], $arrPrefixes = []) { $arrExtract = []; if (!is_array($arrPrefixes) || empty($arrPrefixes)) { return $arrData; } foreach ($arrData as $key => $value) { foreach ($arrPrefixes as $strPrefix) { if (\HeimrichHannot\Haste\Util\StringUtil::startsWith($key, $strPrefix)) { $arrExtract[$key] = $value; } } } return $arrExtract; }
[ "public", "static", "function", "filterByPrefixes", "(", "array", "$", "arrData", "=", "[", "]", ",", "$", "arrPrefixes", "=", "[", "]", ")", "{", "$", "arrExtract", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "arrPrefixes", ")", "||", "empty", "(", "$", "arrPrefixes", ")", ")", "{", "return", "$", "arrData", ";", "}", "foreach", "(", "$", "arrData", "as", "$", "key", "=>", "$", "value", ")", "{", "foreach", "(", "$", "arrPrefixes", "as", "$", "strPrefix", ")", "{", "if", "(", "\\", "HeimrichHannot", "\\", "Haste", "\\", "Util", "\\", "StringUtil", "::", "startsWith", "(", "$", "key", ",", "$", "strPrefix", ")", ")", "{", "$", "arrExtract", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "arrExtract", ";", "}" ]
Filter an Array by given prefixes @param array $arrData @param array $arrPrefixes @return array the filtered array or $arrData if $strPrefix is empty
[ "Filter", "an", "Array", "by", "given", "prefixes" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Arrays.php#L60-L81
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Arrays.php
Arrays.array_unique_keys
public static function array_unique_keys($array) { $arrResult = []; foreach (array_unique(array_keys($array)) as $varKey) { $arrResult[$varKey] = $array[$varKey]; } return $arrResult; }
php
public static function array_unique_keys($array) { $arrResult = []; foreach (array_unique(array_keys($array)) as $varKey) { $arrResult[$varKey] = $array[$varKey]; } return $arrResult; }
[ "public", "static", "function", "array_unique_keys", "(", "$", "array", ")", "{", "$", "arrResult", "=", "[", "]", ";", "foreach", "(", "array_unique", "(", "array_keys", "(", "$", "array", ")", ")", "as", "$", "varKey", ")", "{", "$", "arrResult", "[", "$", "varKey", "]", "=", "$", "array", "[", "$", "varKey", "]", ";", "}", "return", "$", "arrResult", ";", "}" ]
Uniques an array by key, not by value
[ "Uniques", "an", "array", "by", "key", "not", "by", "value" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Arrays.php#L231-L241
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Arrays.php
Arrays.concatArrays
public static function concatArrays($strDelimiter) { $arrArrays = func_get_args(); array_shift($arrArrays); $arrResult = []; foreach ($arrArrays as $arrArray) { foreach ($arrArray as $varKey => $varValue) { if (isset($arrResult[$varKey])) { $arrResult[$varKey] .= ($arrArray[$varKey] ? $strDelimiter : '') . $varValue; } else { $arrResult[$varKey] = $varValue; } } } return $arrResult; }
php
public static function concatArrays($strDelimiter) { $arrArrays = func_get_args(); array_shift($arrArrays); $arrResult = []; foreach ($arrArrays as $arrArray) { foreach ($arrArray as $varKey => $varValue) { if (isset($arrResult[$varKey])) { $arrResult[$varKey] .= ($arrArray[$varKey] ? $strDelimiter : '') . $varValue; } else { $arrResult[$varKey] = $varValue; } } } return $arrResult; }
[ "public", "static", "function", "concatArrays", "(", "$", "strDelimiter", ")", "{", "$", "arrArrays", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "arrArrays", ")", ";", "$", "arrResult", "=", "[", "]", ";", "foreach", "(", "$", "arrArrays", "as", "$", "arrArray", ")", "{", "foreach", "(", "$", "arrArray", "as", "$", "varKey", "=>", "$", "varValue", ")", "{", "if", "(", "isset", "(", "$", "arrResult", "[", "$", "varKey", "]", ")", ")", "{", "$", "arrResult", "[", "$", "varKey", "]", ".=", "(", "$", "arrArray", "[", "$", "varKey", "]", "?", "$", "strDelimiter", ":", "''", ")", ".", "$", "varValue", ";", "}", "else", "{", "$", "arrResult", "[", "$", "varKey", "]", "=", "$", "varValue", ";", "}", "}", "}", "return", "$", "arrResult", ";", "}" ]
Merges multiple arrays wrapped in another array by concating the values which must be concatable @param array $arrArray @return array|mixed
[ "Merges", "multiple", "arrays", "wrapped", "in", "another", "array", "by", "concating", "the", "values", "which", "must", "be", "concatable" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Arrays.php#L250-L272
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Arrays.php
Arrays.removeValue
public static function removeValue($varValue, array &$arrArray) { if (($intPosition = array_search($varValue, $arrArray)) !== false) { unset($arrArray[$intPosition]); return true; } return false; }
php
public static function removeValue($varValue, array &$arrArray) { if (($intPosition = array_search($varValue, $arrArray)) !== false) { unset($arrArray[$intPosition]); return true; } return false; }
[ "public", "static", "function", "removeValue", "(", "$", "varValue", ",", "array", "&", "$", "arrArray", ")", "{", "if", "(", "(", "$", "intPosition", "=", "array_search", "(", "$", "varValue", ",", "$", "arrArray", ")", ")", "!==", "false", ")", "{", "unset", "(", "$", "arrArray", "[", "$", "intPosition", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Removes a value in an array @param $varValue @param array $arrArray @return bool Returns true if the value has been found and removed, false in other cases
[ "Removes", "a", "value", "in", "an", "array" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Arrays.php#L295-L305
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Environment.php
Environment.getAvailableOrigins
public static function getAvailableOrigins() { $arrOrigins = []; if(!\Config::get('bypassCache')) { // Try to get the cache key from the mapper array if (file_exists(TL_ROOT . '/system/cache/config/origins.php')) { $arrOrigins = include TL_ROOT . '/system/cache/config/origins.php'; return $arrOrigins; } } $objRootPages = \PageModel::findPublishedRootPages(); if($objRootPages !== null) { while($objRootPages->next()) { if($objRootPages->dns == '') { continue; } $strDomain = $objRootPages->useSSL ? 'https://' : 'http://'; $strDomain .= $objRootPages->dns; $arrOrigins[$objRootPages->id] = $strDomain; } } if(!\Config::get('bypassCache')) { // Generate the page mapper file $objCacheFile = new \File('system/cache/config/origins.php', true); $objCacheFile->write(sprintf("<?php\n\nreturn %s;\n", var_export($arrOrigins, true))); $objCacheFile->close(); } return $arrOrigins; }
php
public static function getAvailableOrigins() { $arrOrigins = []; if(!\Config::get('bypassCache')) { // Try to get the cache key from the mapper array if (file_exists(TL_ROOT . '/system/cache/config/origins.php')) { $arrOrigins = include TL_ROOT . '/system/cache/config/origins.php'; return $arrOrigins; } } $objRootPages = \PageModel::findPublishedRootPages(); if($objRootPages !== null) { while($objRootPages->next()) { if($objRootPages->dns == '') { continue; } $strDomain = $objRootPages->useSSL ? 'https://' : 'http://'; $strDomain .= $objRootPages->dns; $arrOrigins[$objRootPages->id] = $strDomain; } } if(!\Config::get('bypassCache')) { // Generate the page mapper file $objCacheFile = new \File('system/cache/config/origins.php', true); $objCacheFile->write(sprintf("<?php\n\nreturn %s;\n", var_export($arrOrigins, true))); $objCacheFile->close(); } return $arrOrigins; }
[ "public", "static", "function", "getAvailableOrigins", "(", ")", "{", "$", "arrOrigins", "=", "[", "]", ";", "if", "(", "!", "\\", "Config", "::", "get", "(", "'bypassCache'", ")", ")", "{", "// Try to get the cache key from the mapper array", "if", "(", "file_exists", "(", "TL_ROOT", ".", "'/system/cache/config/origins.php'", ")", ")", "{", "$", "arrOrigins", "=", "include", "TL_ROOT", ".", "'/system/cache/config/origins.php'", ";", "return", "$", "arrOrigins", ";", "}", "}", "$", "objRootPages", "=", "\\", "PageModel", "::", "findPublishedRootPages", "(", ")", ";", "if", "(", "$", "objRootPages", "!==", "null", ")", "{", "while", "(", "$", "objRootPages", "->", "next", "(", ")", ")", "{", "if", "(", "$", "objRootPages", "->", "dns", "==", "''", ")", "{", "continue", ";", "}", "$", "strDomain", "=", "$", "objRootPages", "->", "useSSL", "?", "'https://'", ":", "'http://'", ";", "$", "strDomain", ".=", "$", "objRootPages", "->", "dns", ";", "$", "arrOrigins", "[", "$", "objRootPages", "->", "id", "]", "=", "$", "strDomain", ";", "}", "}", "if", "(", "!", "\\", "Config", "::", "get", "(", "'bypassCache'", ")", ")", "{", "// Generate the page mapper file", "$", "objCacheFile", "=", "new", "\\", "File", "(", "'system/cache/config/origins.php'", ",", "true", ")", ";", "$", "objCacheFile", "->", "write", "(", "sprintf", "(", "\"<?php\\n\\nreturn %s;\\n\"", ",", "var_export", "(", "$", "arrOrigins", ",", "true", ")", ")", ")", ";", "$", "objCacheFile", "->", "close", "(", ")", ";", "}", "return", "$", "arrOrigins", ";", "}" ]
Get all available origins for this contao environment @return array List of available origins (<protocol> :// <host>)
[ "Get", "all", "available", "origins", "for", "this", "contao", "environment" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Environment.php#L20-L61
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Files.php
Files.getFileList
public static function getFileList($strDir, $baseUrl, $protectedBaseUrl = null) { $arrResult = []; if (is_dir($strDir)) { if ($handler = opendir($strDir)) { while (($strFile = readdir($handler)) !== false) { if (substr($strFile, 0, 1) == '.') { continue; } $arrFile = []; $arrFile['filename'] = htmlentities($strFile); if ($protectedBaseUrl) { $arrFile['absUrl'] = $protectedBaseUrl . (empty($_GET) ? '?' : '&') . 'file=' . urlencode($arrFile['absUrl']); } else { $arrFile['absUrl'] = str_replace('\\', '/', str_replace('//', '', $baseUrl . '/' . $strFile)); } $arrFile['path'] = str_replace($arrFile['filename'], '', $arrFile['absUrl']); $arrFile['filesize'] = self::formatSizeUnits(filesize(str_replace('\\', '/', str_replace('//', '', $strDir . '/' . $strFile))), true); $arrResult[] = $arrFile; } closedir($handler); } } Arrays::aasort($arrResult, 'filename'); return $arrResult; }
php
public static function getFileList($strDir, $baseUrl, $protectedBaseUrl = null) { $arrResult = []; if (is_dir($strDir)) { if ($handler = opendir($strDir)) { while (($strFile = readdir($handler)) !== false) { if (substr($strFile, 0, 1) == '.') { continue; } $arrFile = []; $arrFile['filename'] = htmlentities($strFile); if ($protectedBaseUrl) { $arrFile['absUrl'] = $protectedBaseUrl . (empty($_GET) ? '?' : '&') . 'file=' . urlencode($arrFile['absUrl']); } else { $arrFile['absUrl'] = str_replace('\\', '/', str_replace('//', '', $baseUrl . '/' . $strFile)); } $arrFile['path'] = str_replace($arrFile['filename'], '', $arrFile['absUrl']); $arrFile['filesize'] = self::formatSizeUnits(filesize(str_replace('\\', '/', str_replace('//', '', $strDir . '/' . $strFile))), true); $arrResult[] = $arrFile; } closedir($handler); } } Arrays::aasort($arrResult, 'filename'); return $arrResult; }
[ "public", "static", "function", "getFileList", "(", "$", "strDir", ",", "$", "baseUrl", ",", "$", "protectedBaseUrl", "=", "null", ")", "{", "$", "arrResult", "=", "[", "]", ";", "if", "(", "is_dir", "(", "$", "strDir", ")", ")", "{", "if", "(", "$", "handler", "=", "opendir", "(", "$", "strDir", ")", ")", "{", "while", "(", "(", "$", "strFile", "=", "readdir", "(", "$", "handler", ")", ")", "!==", "false", ")", "{", "if", "(", "substr", "(", "$", "strFile", ",", "0", ",", "1", ")", "==", "'.'", ")", "{", "continue", ";", "}", "$", "arrFile", "=", "[", "]", ";", "$", "arrFile", "[", "'filename'", "]", "=", "htmlentities", "(", "$", "strFile", ")", ";", "if", "(", "$", "protectedBaseUrl", ")", "{", "$", "arrFile", "[", "'absUrl'", "]", "=", "$", "protectedBaseUrl", ".", "(", "empty", "(", "$", "_GET", ")", "?", "'?'", ":", "'&'", ")", ".", "'file='", ".", "urlencode", "(", "$", "arrFile", "[", "'absUrl'", "]", ")", ";", "}", "else", "{", "$", "arrFile", "[", "'absUrl'", "]", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "str_replace", "(", "'//'", ",", "''", ",", "$", "baseUrl", ".", "'/'", ".", "$", "strFile", ")", ")", ";", "}", "$", "arrFile", "[", "'path'", "]", "=", "str_replace", "(", "$", "arrFile", "[", "'filename'", "]", ",", "''", ",", "$", "arrFile", "[", "'absUrl'", "]", ")", ";", "$", "arrFile", "[", "'filesize'", "]", "=", "self", "::", "formatSizeUnits", "(", "filesize", "(", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "str_replace", "(", "'//'", ",", "''", ",", "$", "strDir", ".", "'/'", ".", "$", "strFile", ")", ")", ")", ",", "true", ")", ";", "$", "arrResult", "[", "]", "=", "$", "arrFile", ";", "}", "closedir", "(", "$", "handler", ")", ";", "}", "}", "Arrays", "::", "aasort", "(", "$", "arrResult", ",", "'filename'", ")", ";", "return", "$", "arrResult", ";", "}" ]
Returns the file list for a given directory @param string $strDir - the absolute local path to the directory (e.g. /dir/mydir) @param string $baseUrl - the relative uri (e.g. /tl_files/mydir) @param string $protectedBaseUrl - domain + request uri -> absUrl will be domain + request uri + ?file=$baseUrl/filename.ext @return array file list containing file objects.
[ "Returns", "the", "file", "list", "for", "a", "given", "directory" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Files.php#L85-L120
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Files.php
Files.addUniqIdToFilename
public static function addUniqIdToFilename($strFileName, $strPrefix = null, $blnMoreEntropy = true) { $objFile = new \File($strFileName, true); $strDirectory = ltrim(str_replace(TL_ROOT, '', $objFile->dirname), '/'); return ($strDirectory ? $strDirectory . '/' : '') . $objFile->filename . uniqid($strPrefix, $blnMoreEntropy) . ($objFile->extension ? '.' . $objFile->extension : ''); }
php
public static function addUniqIdToFilename($strFileName, $strPrefix = null, $blnMoreEntropy = true) { $objFile = new \File($strFileName, true); $strDirectory = ltrim(str_replace(TL_ROOT, '', $objFile->dirname), '/'); return ($strDirectory ? $strDirectory . '/' : '') . $objFile->filename . uniqid($strPrefix, $blnMoreEntropy) . ($objFile->extension ? '.' . $objFile->extension : ''); }
[ "public", "static", "function", "addUniqIdToFilename", "(", "$", "strFileName", ",", "$", "strPrefix", "=", "null", ",", "$", "blnMoreEntropy", "=", "true", ")", "{", "$", "objFile", "=", "new", "\\", "File", "(", "$", "strFileName", ",", "true", ")", ";", "$", "strDirectory", "=", "ltrim", "(", "str_replace", "(", "TL_ROOT", ",", "''", ",", "$", "objFile", "->", "dirname", ")", ",", "'/'", ")", ";", "return", "(", "$", "strDirectory", "?", "$", "strDirectory", ".", "'/'", ":", "''", ")", ".", "$", "objFile", "->", "filename", ".", "uniqid", "(", "$", "strPrefix", ",", "$", "blnMoreEntropy", ")", ".", "(", "$", "objFile", "->", "extension", "?", "'.'", ".", "$", "objFile", "->", "extension", ":", "''", ")", ";", "}" ]
Add a unique identifier to a file name @param $strFileName The file name, can be with or without path @param null $strPrefix Add a prefix to the unique identifier, with an empty prefix, the returned string will be 13 characters long. @param bool $blnMoreEntropy If set to TRUE, will add additional entropy (using the combined linear congruential generator) at the end of the return value, which increases the likelihood that the result will be unique. @return string Filename with imestamp based unique identifier
[ "Add", "a", "unique", "identifier", "to", "a", "file", "name" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Files.php#L231-L239
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Files.php
Files.getFolderFromDca
public static function getFolderFromDca($varFolder, \DataContainer $dc = null, $blnDoNotCreate = true) { // upload folder if (is_array($varFolder) && $dc !== null) { $arrCallback = $varFolder; $varFolder = \System::importStatic($arrCallback[0])->{$arrCallback[1]}($dc); } elseif (is_callable($varFolder) && $dc !== null) { $strMethod = $varFolder; $varFolder = $strMethod($dc); } else { if (strpos($varFolder, '../') !== false) { throw new \Exception("Invalid target path $varFolder"); } } if ($varFolder instanceof \File) { $varFolder = $varFolder->value; } else { if ($varFolder instanceof \FilesModel) { $varFolder = $varFolder->path; } } if (\Validator::isUuid($varFolder)) { $objFolder = static::getFolderFromUuid($varFolder, $blnDoNotCreate); $varFolder = $objFolder->value; } return $varFolder; }
php
public static function getFolderFromDca($varFolder, \DataContainer $dc = null, $blnDoNotCreate = true) { // upload folder if (is_array($varFolder) && $dc !== null) { $arrCallback = $varFolder; $varFolder = \System::importStatic($arrCallback[0])->{$arrCallback[1]}($dc); } elseif (is_callable($varFolder) && $dc !== null) { $strMethod = $varFolder; $varFolder = $strMethod($dc); } else { if (strpos($varFolder, '../') !== false) { throw new \Exception("Invalid target path $varFolder"); } } if ($varFolder instanceof \File) { $varFolder = $varFolder->value; } else { if ($varFolder instanceof \FilesModel) { $varFolder = $varFolder->path; } } if (\Validator::isUuid($varFolder)) { $objFolder = static::getFolderFromUuid($varFolder, $blnDoNotCreate); $varFolder = $objFolder->value; } return $varFolder; }
[ "public", "static", "function", "getFolderFromDca", "(", "$", "varFolder", ",", "\\", "DataContainer", "$", "dc", "=", "null", ",", "$", "blnDoNotCreate", "=", "true", ")", "{", "// upload folder", "if", "(", "is_array", "(", "$", "varFolder", ")", "&&", "$", "dc", "!==", "null", ")", "{", "$", "arrCallback", "=", "$", "varFolder", ";", "$", "varFolder", "=", "\\", "System", "::", "importStatic", "(", "$", "arrCallback", "[", "0", "]", ")", "->", "{", "$", "arrCallback", "[", "1", "]", "}", "(", "$", "dc", ")", ";", "}", "elseif", "(", "is_callable", "(", "$", "varFolder", ")", "&&", "$", "dc", "!==", "null", ")", "{", "$", "strMethod", "=", "$", "varFolder", ";", "$", "varFolder", "=", "$", "strMethod", "(", "$", "dc", ")", ";", "}", "else", "{", "if", "(", "strpos", "(", "$", "varFolder", ",", "'../'", ")", "!==", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid target path $varFolder\"", ")", ";", "}", "}", "if", "(", "$", "varFolder", "instanceof", "\\", "File", ")", "{", "$", "varFolder", "=", "$", "varFolder", "->", "value", ";", "}", "else", "{", "if", "(", "$", "varFolder", "instanceof", "\\", "FilesModel", ")", "{", "$", "varFolder", "=", "$", "varFolder", "->", "path", ";", "}", "}", "if", "(", "\\", "Validator", "::", "isUuid", "(", "$", "varFolder", ")", ")", "{", "$", "objFolder", "=", "static", "::", "getFolderFromUuid", "(", "$", "varFolder", ",", "$", "blnDoNotCreate", ")", ";", "$", "varFolder", "=", "$", "objFolder", "->", "value", ";", "}", "return", "$", "varFolder", ";", "}" ]
Get real folder from datacontainer attribute @param mixed $varFolder The folder as uuid, function, callback array('CLASS', 'method') or string (files/...) @param \DataContainer|null $dc Optional \DataContainer, required for function and callback @return mixed|null The folder path or null @throws \Exception If ../ is part of the path
[ "Get", "real", "folder", "from", "datacontainer", "attribute" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Files.php#L291-L332
train
heimrichhannot/contao-haste_plus
library/Haste/Util/Salutations.php
Salutations.createNameByFields
public static function createNameByFields($strLanguage, array $arrData) { if ($strLanguage) { \Controller::loadLanguageFile('default', $strLanguage, true); } $strName = ''; if ($arrData['firstname']) { $strName = $arrData['firstname'] . ($arrData['lastname'] ? ' ' . $arrData['lastname'] : ''); } elseif ($arrData['lastname']) { $strName = $arrData['lastname']; } if ($strName && $arrData['academicTitle']) { $strName = $arrData['academicTitle'] . ' ' . $strName; } if ($strName && $arrData['additionalTitle']) { $strName = $arrData['additionalTitle'] . ' ' . $strName; } if ($arrData['lastname'] && $arrData['gender'] && ($strLanguage != 'en' || !$arrData['academicTitle'])) { $strGender = $GLOBALS['TL_LANG']['MSC']['haste_plus']['gender' . ($arrData['gender'] == 'female' ? 'Female' : 'Male')]; $strName = $strGender . ' ' . $strName; } if ($strLanguage) { \Controller::loadLanguageFile('default', $GLOBALS['TL_LANGUAGE'], true); } return $strName; }
php
public static function createNameByFields($strLanguage, array $arrData) { if ($strLanguage) { \Controller::loadLanguageFile('default', $strLanguage, true); } $strName = ''; if ($arrData['firstname']) { $strName = $arrData['firstname'] . ($arrData['lastname'] ? ' ' . $arrData['lastname'] : ''); } elseif ($arrData['lastname']) { $strName = $arrData['lastname']; } if ($strName && $arrData['academicTitle']) { $strName = $arrData['academicTitle'] . ' ' . $strName; } if ($strName && $arrData['additionalTitle']) { $strName = $arrData['additionalTitle'] . ' ' . $strName; } if ($arrData['lastname'] && $arrData['gender'] && ($strLanguage != 'en' || !$arrData['academicTitle'])) { $strGender = $GLOBALS['TL_LANG']['MSC']['haste_plus']['gender' . ($arrData['gender'] == 'female' ? 'Female' : 'Male')]; $strName = $strGender . ' ' . $strName; } if ($strLanguage) { \Controller::loadLanguageFile('default', $GLOBALS['TL_LANGUAGE'], true); } return $strName; }
[ "public", "static", "function", "createNameByFields", "(", "$", "strLanguage", ",", "array", "$", "arrData", ")", "{", "if", "(", "$", "strLanguage", ")", "{", "\\", "Controller", "::", "loadLanguageFile", "(", "'default'", ",", "$", "strLanguage", ",", "true", ")", ";", "}", "$", "strName", "=", "''", ";", "if", "(", "$", "arrData", "[", "'firstname'", "]", ")", "{", "$", "strName", "=", "$", "arrData", "[", "'firstname'", "]", ".", "(", "$", "arrData", "[", "'lastname'", "]", "?", "' '", ".", "$", "arrData", "[", "'lastname'", "]", ":", "''", ")", ";", "}", "elseif", "(", "$", "arrData", "[", "'lastname'", "]", ")", "{", "$", "strName", "=", "$", "arrData", "[", "'lastname'", "]", ";", "}", "if", "(", "$", "strName", "&&", "$", "arrData", "[", "'academicTitle'", "]", ")", "{", "$", "strName", "=", "$", "arrData", "[", "'academicTitle'", "]", ".", "' '", ".", "$", "strName", ";", "}", "if", "(", "$", "strName", "&&", "$", "arrData", "[", "'additionalTitle'", "]", ")", "{", "$", "strName", "=", "$", "arrData", "[", "'additionalTitle'", "]", ".", "' '", ".", "$", "strName", ";", "}", "if", "(", "$", "arrData", "[", "'lastname'", "]", "&&", "$", "arrData", "[", "'gender'", "]", "&&", "(", "$", "strLanguage", "!=", "'en'", "||", "!", "$", "arrData", "[", "'academicTitle'", "]", ")", ")", "{", "$", "strGender", "=", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'MSC'", "]", "[", "'haste_plus'", "]", "[", "'gender'", ".", "(", "$", "arrData", "[", "'gender'", "]", "==", "'female'", "?", "'Female'", ":", "'Male'", ")", "]", ";", "$", "strName", "=", "$", "strGender", ".", "' '", ".", "$", "strName", ";", "}", "if", "(", "$", "strLanguage", ")", "{", "\\", "Controller", "::", "loadLanguageFile", "(", "'default'", ",", "$", "GLOBALS", "[", "'TL_LANGUAGE'", "]", ",", "true", ")", ";", "}", "return", "$", "strName", ";", "}" ]
Creates complete names by inserting an array of the person's data Supported field names: firstname, lastname, academicTitle, additionalTitle, gender If some of the fields shouldn't go into the processed name, just leave them out of $arrData @param array $arrData
[ "Creates", "complete", "names", "by", "inserting", "an", "array", "of", "the", "person", "s", "data" ]
b37e2d4b264bef613bd97916c47626f324dbecb7
https://github.com/heimrichhannot/contao-haste_plus/blob/b37e2d4b264bef613bd97916c47626f324dbecb7/library/Haste/Util/Salutations.php#L27-L68
train
helhum/typoscript_rendering
Classes/Configuration/RecordRenderingConfigurationBuilder.php
RecordRenderingConfigurationBuilder.resolveTableNameAndUidFromContextString
protected function resolveTableNameAndUidFromContextString(string $contextRecord) { if ($contextRecord === 'currentPage') { $tableNameAndUid = ['pages', $this->renderingContext->getFrontendController()->id]; } else { $tableNameAndUid = explode(':', $contextRecord); if (count($tableNameAndUid) !== 2 || empty($tableNameAndUid[0]) || empty($tableNameAndUid[1]) || !MathUtility::canBeInterpretedAsInteger($tableNameAndUid[1])) { $tableNameAndUid = ['pages', $this->renderingContext->getFrontendController()->id]; } } // TODO: maybe check if the record is available return $tableNameAndUid; }
php
protected function resolveTableNameAndUidFromContextString(string $contextRecord) { if ($contextRecord === 'currentPage') { $tableNameAndUid = ['pages', $this->renderingContext->getFrontendController()->id]; } else { $tableNameAndUid = explode(':', $contextRecord); if (count($tableNameAndUid) !== 2 || empty($tableNameAndUid[0]) || empty($tableNameAndUid[1]) || !MathUtility::canBeInterpretedAsInteger($tableNameAndUid[1])) { $tableNameAndUid = ['pages', $this->renderingContext->getFrontendController()->id]; } } // TODO: maybe check if the record is available return $tableNameAndUid; }
[ "protected", "function", "resolveTableNameAndUidFromContextString", "(", "string", "$", "contextRecord", ")", "{", "if", "(", "$", "contextRecord", "===", "'currentPage'", ")", "{", "$", "tableNameAndUid", "=", "[", "'pages'", ",", "$", "this", "->", "renderingContext", "->", "getFrontendController", "(", ")", "->", "id", "]", ";", "}", "else", "{", "$", "tableNameAndUid", "=", "explode", "(", "':'", ",", "$", "contextRecord", ")", ";", "if", "(", "count", "(", "$", "tableNameAndUid", ")", "!==", "2", "||", "empty", "(", "$", "tableNameAndUid", "[", "0", "]", ")", "||", "empty", "(", "$", "tableNameAndUid", "[", "1", "]", ")", "||", "!", "MathUtility", "::", "canBeInterpretedAsInteger", "(", "$", "tableNameAndUid", "[", "1", "]", ")", ")", "{", "$", "tableNameAndUid", "=", "[", "'pages'", ",", "$", "this", "->", "renderingContext", "->", "getFrontendController", "(", ")", "->", "id", "]", ";", "}", "}", "// TODO: maybe check if the record is available", "return", "$", "tableNameAndUid", ";", "}" ]
Resolves the table name and uid for the record the rendering is based upon. Falls back to current page if none is available @param string $contextRecord @return string[] table name as first and uid as second index of the array
[ "Resolves", "the", "table", "name", "and", "uid", "for", "the", "record", "the", "rendering", "is", "based", "upon", ".", "Falls", "back", "to", "current", "page", "if", "none", "is", "available" ]
c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76
https://github.com/helhum/typoscript_rendering/blob/c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76/Classes/Configuration/RecordRenderingConfigurationBuilder.php#L80-L92
train
helhum/typoscript_rendering
Classes/Configuration/RecordRenderingConfigurationBuilder.php
RecordRenderingConfigurationBuilder.buildPluginSignature
protected function buildPluginSignature($extensionName, $pluginName) { // Check if vendor name is prepended to extensionName in the format {vendorName}.{extensionName} $delimiterPosition = strrpos($extensionName, '.'); if ($delimiterPosition !== false) { $extensionName = substr($extensionName, $delimiterPosition + 1); } $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName))); return strtolower($extensionName . '_' . $pluginName); }
php
protected function buildPluginSignature($extensionName, $pluginName) { // Check if vendor name is prepended to extensionName in the format {vendorName}.{extensionName} $delimiterPosition = strrpos($extensionName, '.'); if ($delimiterPosition !== false) { $extensionName = substr($extensionName, $delimiterPosition + 1); } $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName))); return strtolower($extensionName . '_' . $pluginName); }
[ "protected", "function", "buildPluginSignature", "(", "$", "extensionName", ",", "$", "pluginName", ")", "{", "// Check if vendor name is prepended to extensionName in the format {vendorName}.{extensionName}", "$", "delimiterPosition", "=", "strrpos", "(", "$", "extensionName", ",", "'.'", ")", ";", "if", "(", "$", "delimiterPosition", "!==", "false", ")", "{", "$", "extensionName", "=", "substr", "(", "$", "extensionName", ",", "$", "delimiterPosition", "+", "1", ")", ";", "}", "$", "extensionName", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "extensionName", ")", ")", ")", ";", "return", "strtolower", "(", "$", "extensionName", ".", "'_'", ".", "$", "pluginName", ")", ";", "}" ]
Builds the plugin signature for the tt_content rendering @param string $extensionName @param string $pluginName @return string @see \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin()
[ "Builds", "the", "plugin", "signature", "for", "the", "tt_content", "rendering" ]
c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76
https://github.com/helhum/typoscript_rendering/blob/c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76/Classes/Configuration/RecordRenderingConfigurationBuilder.php#L104-L114
train
helhum/typoscript_rendering
Classes/ViewHelpers/Widget/LinkViewHelper.php
LinkViewHelper.getAjaxUri
protected function getAjaxUri() { $pluginName = $this->arguments['pluginName']; $extensionName = $this->arguments['extensionName']; $contextRecord = $this->arguments['contextRecord']; $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : []; if ($contextRecord === 'current') { if ( $pluginName !== $this->controllerContext->getRequest()->getPluginName() || $extensionName !== $this->controllerContext->getRequest()->getControllerExtensionName() ) { $contextRecord = 'currentPage'; } else { $contextRecord = $this->configurationManager->getContentObject()->currentRecord; } } $renderingConfiguration = $this->buildTypoScriptRenderingConfiguration($extensionName, $pluginName, $contextRecord); $additionalParams['tx_typoscriptrendering']['context'] = json_encode($renderingConfiguration); $uriBuilder = $this->controllerContext->getUriBuilder(); $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix(); $uriBuilder->reset() ->setArguments(array_merge([$argumentPrefix => $arguments], $additionalParams)) ->setSection($this->arguments['section']) ->setAddQueryString(true) ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash']) ->setFormat($this->arguments['format']) ->setUseCacheHash(true); // TYPO3 6.0 compatibility check: if (method_exists($uriBuilder, 'setAddQueryStringMethod')) { $uriBuilder->setAddQueryStringMethod($this->arguments['addQueryStringMethod']); } return $uriBuilder->build(); }
php
protected function getAjaxUri() { $pluginName = $this->arguments['pluginName']; $extensionName = $this->arguments['extensionName']; $contextRecord = $this->arguments['contextRecord']; $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : []; if ($contextRecord === 'current') { if ( $pluginName !== $this->controllerContext->getRequest()->getPluginName() || $extensionName !== $this->controllerContext->getRequest()->getControllerExtensionName() ) { $contextRecord = 'currentPage'; } else { $contextRecord = $this->configurationManager->getContentObject()->currentRecord; } } $renderingConfiguration = $this->buildTypoScriptRenderingConfiguration($extensionName, $pluginName, $contextRecord); $additionalParams['tx_typoscriptrendering']['context'] = json_encode($renderingConfiguration); $uriBuilder = $this->controllerContext->getUriBuilder(); $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix(); $uriBuilder->reset() ->setArguments(array_merge([$argumentPrefix => $arguments], $additionalParams)) ->setSection($this->arguments['section']) ->setAddQueryString(true) ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash']) ->setFormat($this->arguments['format']) ->setUseCacheHash(true); // TYPO3 6.0 compatibility check: if (method_exists($uriBuilder, 'setAddQueryStringMethod')) { $uriBuilder->setAddQueryStringMethod($this->arguments['addQueryStringMethod']); } return $uriBuilder->build(); }
[ "protected", "function", "getAjaxUri", "(", ")", "{", "$", "pluginName", "=", "$", "this", "->", "arguments", "[", "'pluginName'", "]", ";", "$", "extensionName", "=", "$", "this", "->", "arguments", "[", "'extensionName'", "]", ";", "$", "contextRecord", "=", "$", "this", "->", "arguments", "[", "'contextRecord'", "]", ";", "$", "arguments", "=", "$", "this", "->", "hasArgument", "(", "'arguments'", ")", "?", "$", "this", "->", "arguments", "[", "'arguments'", "]", ":", "[", "]", ";", "if", "(", "$", "contextRecord", "===", "'current'", ")", "{", "if", "(", "$", "pluginName", "!==", "$", "this", "->", "controllerContext", "->", "getRequest", "(", ")", "->", "getPluginName", "(", ")", "||", "$", "extensionName", "!==", "$", "this", "->", "controllerContext", "->", "getRequest", "(", ")", "->", "getControllerExtensionName", "(", ")", ")", "{", "$", "contextRecord", "=", "'currentPage'", ";", "}", "else", "{", "$", "contextRecord", "=", "$", "this", "->", "configurationManager", "->", "getContentObject", "(", ")", "->", "currentRecord", ";", "}", "}", "$", "renderingConfiguration", "=", "$", "this", "->", "buildTypoScriptRenderingConfiguration", "(", "$", "extensionName", ",", "$", "pluginName", ",", "$", "contextRecord", ")", ";", "$", "additionalParams", "[", "'tx_typoscriptrendering'", "]", "[", "'context'", "]", "=", "json_encode", "(", "$", "renderingConfiguration", ")", ";", "$", "uriBuilder", "=", "$", "this", "->", "controllerContext", "->", "getUriBuilder", "(", ")", ";", "$", "argumentPrefix", "=", "$", "this", "->", "controllerContext", "->", "getRequest", "(", ")", "->", "getArgumentPrefix", "(", ")", ";", "$", "uriBuilder", "->", "reset", "(", ")", "->", "setArguments", "(", "array_merge", "(", "[", "$", "argumentPrefix", "=>", "$", "arguments", "]", ",", "$", "additionalParams", ")", ")", "->", "setSection", "(", "$", "this", "->", "arguments", "[", "'section'", "]", ")", "->", "setAddQueryString", "(", "true", ")", "->", "setArgumentsToBeExcludedFromQueryString", "(", "[", "$", "argumentPrefix", ",", "'cHash'", "]", ")", "->", "setFormat", "(", "$", "this", "->", "arguments", "[", "'format'", "]", ")", "->", "setUseCacheHash", "(", "true", ")", ";", "// TYPO3 6.0 compatibility check:", "if", "(", "method_exists", "(", "$", "uriBuilder", ",", "'setAddQueryStringMethod'", ")", ")", "{", "$", "uriBuilder", "->", "setAddQueryStringMethod", "(", "$", "this", "->", "arguments", "[", "'addQueryStringMethod'", "]", ")", ";", "}", "return", "$", "uriBuilder", "->", "build", "(", ")", ";", "}" ]
Gets the URI for an Ajax Request. @throws \Helhum\TyposcriptRendering\Configuration\ConfigurationBuildingException @return string the Ajax URI
[ "Gets", "the", "URI", "for", "an", "Ajax", "Request", "." ]
c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76
https://github.com/helhum/typoscript_rendering/blob/c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76/Classes/ViewHelpers/Widget/LinkViewHelper.php#L85-L121
train
helhum/typoscript_rendering
Classes/ViewHelpers/Widget/LinkViewHelper.php
LinkViewHelper.getWidgetUri
protected function getWidgetUri() { $uriBuilder = $this->controllerContext->getUriBuilder(); $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix(); $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : []; if ($this->hasArgument('action')) { $arguments['action'] = $this->arguments['action']; } if ($this->hasArgument('format') && $this->arguments['format'] !== '') { $arguments['format'] = $this->arguments['format']; } if ($this->hasArgument('addQueryStringMethod') && $this->arguments['addQueryStringMethod'] !== '') { $arguments['addQueryStringMethod'] = $this->arguments['addQueryStringMethod']; } $uriBuilder->reset() ->setArguments([$argumentPrefix => $arguments]) ->setSection($this->arguments['section']) ->setAddQueryString(true) ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash']) ->setFormat($this->arguments['format']); // TYPO3 6.0 compatibility check: if (method_exists($uriBuilder, 'setAddQueryStringMethod')) { $uriBuilder->setAddQueryStringMethod($this->arguments['addQueryStringMethod']); } return $uriBuilder->build(); }
php
protected function getWidgetUri() { $uriBuilder = $this->controllerContext->getUriBuilder(); $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix(); $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : []; if ($this->hasArgument('action')) { $arguments['action'] = $this->arguments['action']; } if ($this->hasArgument('format') && $this->arguments['format'] !== '') { $arguments['format'] = $this->arguments['format']; } if ($this->hasArgument('addQueryStringMethod') && $this->arguments['addQueryStringMethod'] !== '') { $arguments['addQueryStringMethod'] = $this->arguments['addQueryStringMethod']; } $uriBuilder->reset() ->setArguments([$argumentPrefix => $arguments]) ->setSection($this->arguments['section']) ->setAddQueryString(true) ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash']) ->setFormat($this->arguments['format']); // TYPO3 6.0 compatibility check: if (method_exists($uriBuilder, 'setAddQueryStringMethod')) { $uriBuilder->setAddQueryStringMethod($this->arguments['addQueryStringMethod']); } return $uriBuilder->build(); }
[ "protected", "function", "getWidgetUri", "(", ")", "{", "$", "uriBuilder", "=", "$", "this", "->", "controllerContext", "->", "getUriBuilder", "(", ")", ";", "$", "argumentPrefix", "=", "$", "this", "->", "controllerContext", "->", "getRequest", "(", ")", "->", "getArgumentPrefix", "(", ")", ";", "$", "arguments", "=", "$", "this", "->", "hasArgument", "(", "'arguments'", ")", "?", "$", "this", "->", "arguments", "[", "'arguments'", "]", ":", "[", "]", ";", "if", "(", "$", "this", "->", "hasArgument", "(", "'action'", ")", ")", "{", "$", "arguments", "[", "'action'", "]", "=", "$", "this", "->", "arguments", "[", "'action'", "]", ";", "}", "if", "(", "$", "this", "->", "hasArgument", "(", "'format'", ")", "&&", "$", "this", "->", "arguments", "[", "'format'", "]", "!==", "''", ")", "{", "$", "arguments", "[", "'format'", "]", "=", "$", "this", "->", "arguments", "[", "'format'", "]", ";", "}", "if", "(", "$", "this", "->", "hasArgument", "(", "'addQueryStringMethod'", ")", "&&", "$", "this", "->", "arguments", "[", "'addQueryStringMethod'", "]", "!==", "''", ")", "{", "$", "arguments", "[", "'addQueryStringMethod'", "]", "=", "$", "this", "->", "arguments", "[", "'addQueryStringMethod'", "]", ";", "}", "$", "uriBuilder", "->", "reset", "(", ")", "->", "setArguments", "(", "[", "$", "argumentPrefix", "=>", "$", "arguments", "]", ")", "->", "setSection", "(", "$", "this", "->", "arguments", "[", "'section'", "]", ")", "->", "setAddQueryString", "(", "true", ")", "->", "setArgumentsToBeExcludedFromQueryString", "(", "[", "$", "argumentPrefix", ",", "'cHash'", "]", ")", "->", "setFormat", "(", "$", "this", "->", "arguments", "[", "'format'", "]", ")", ";", "// TYPO3 6.0 compatibility check:", "if", "(", "method_exists", "(", "$", "uriBuilder", ",", "'setAddQueryStringMethod'", ")", ")", "{", "$", "uriBuilder", "->", "setAddQueryStringMethod", "(", "$", "this", "->", "arguments", "[", "'addQueryStringMethod'", "]", ")", ";", "}", "return", "$", "uriBuilder", "->", "build", "(", ")", ";", "}" ]
Gets the URI for a non-Ajax Request. @return string the Widget URI
[ "Gets", "the", "URI", "for", "a", "non", "-", "Ajax", "Request", "." ]
c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76
https://github.com/helhum/typoscript_rendering/blob/c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76/Classes/ViewHelpers/Widget/LinkViewHelper.php#L128-L155
train
helhum/typoscript_rendering
Classes/Middleware/TypoScriptRenderingMiddleware.php
TypoScriptRenderingMiddleware.process
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $frontendController = $GLOBALS['TSFE']; if (!$frontendController->isGeneratePage() || !isset($request->getQueryParams()[self::argumentNamespace])) { return $handler->handle($request); } $this->ensureRequiredEnvironment(); $frontendController->config['config']['disableAllHeaderCode'] = 1; $frontendController->pSetup = [ '10' => 'TYPOSCRIPT_RENDERING', '10.' => [ 'request' => $request->getQueryParams()[self::argumentNamespace], ], ]; return $handler->handle($request); }
php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $frontendController = $GLOBALS['TSFE']; if (!$frontendController->isGeneratePage() || !isset($request->getQueryParams()[self::argumentNamespace])) { return $handler->handle($request); } $this->ensureRequiredEnvironment(); $frontendController->config['config']['disableAllHeaderCode'] = 1; $frontendController->pSetup = [ '10' => 'TYPOSCRIPT_RENDERING', '10.' => [ 'request' => $request->getQueryParams()[self::argumentNamespace], ], ]; return $handler->handle($request); }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "$", "frontendController", "=", "$", "GLOBALS", "[", "'TSFE'", "]", ";", "if", "(", "!", "$", "frontendController", "->", "isGeneratePage", "(", ")", "||", "!", "isset", "(", "$", "request", "->", "getQueryParams", "(", ")", "[", "self", "::", "argumentNamespace", "]", ")", ")", "{", "return", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "}", "$", "this", "->", "ensureRequiredEnvironment", "(", ")", ";", "$", "frontendController", "->", "config", "[", "'config'", "]", "[", "'disableAllHeaderCode'", "]", "=", "1", ";", "$", "frontendController", "->", "pSetup", "=", "[", "'10'", "=>", "'TYPOSCRIPT_RENDERING'", ",", "'10.'", "=>", "[", "'request'", "=>", "$", "request", "->", "getQueryParams", "(", ")", "[", "self", "::", "argumentNamespace", "]", ",", "]", ",", "]", ";", "return", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "}" ]
Dispatches the request to the corresponding typoscript_rendering configuration @param ServerRequestInterface $request @param RequestHandlerInterface $handler @throws Exception @return ResponseInterface
[ "Dispatches", "the", "request", "to", "the", "corresponding", "typoscript_rendering", "configuration" ]
c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76
https://github.com/helhum/typoscript_rendering/blob/c4ac9d2d6fd141dfb11fcaf1c929b1b631de0e76/Classes/Middleware/TypoScriptRenderingMiddleware.php#L37-L54
train
yiisoft/view
src/view/RenderEvent.php
RenderEvent.after
public static function after(string $viewFile, array $params, $result): self { return (new static(static::AFTER, $viewFile, $params))->setResult($result); }
php
public static function after(string $viewFile, array $params, $result): self { return (new static(static::AFTER, $viewFile, $params))->setResult($result); }
[ "public", "static", "function", "after", "(", "string", "$", "viewFile", ",", "array", "$", "params", ",", "$", "result", ")", ":", "self", "{", "return", "(", "new", "static", "(", "static", "::", "AFTER", ",", "$", "viewFile", ",", "$", "params", ")", ")", "->", "setResult", "(", "$", "result", ")", ";", "}" ]
Creates AFTER event with result. @param string $viewFile the view file being rendered. @param array $params array passed to the [[View::render()]] method. @param mixed $result view rendering result. @return self created event
[ "Creates", "AFTER", "event", "with", "result", "." ]
206f58f0c33a7a861984e4c67de470529b19ebb5
https://github.com/yiisoft/view/blob/206f58f0c33a7a861984e4c67de470529b19ebb5/src/view/RenderEvent.php#L49-L52
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php
DynamoDbStorage.validateKeyName
private function validateKeyName($name) { if (! is_string($name)) { throw InvalidArgumentException::invalidType('key', 'string', $name); } $len = strlen($name); if ($len > 255 || $len < 1) { throw InvalidArgumentException::invalidLength('name', 1, 255); } }
php
private function validateKeyName($name) { if (! is_string($name)) { throw InvalidArgumentException::invalidType('key', 'string', $name); } $len = strlen($name); if ($len > 255 || $len < 1) { throw InvalidArgumentException::invalidLength('name', 1, 255); } }
[ "private", "function", "validateKeyName", "(", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "throw", "InvalidArgumentException", "::", "invalidType", "(", "'key'", ",", "'string'", ",", "$", "name", ")", ";", "}", "$", "len", "=", "strlen", "(", "$", "name", ")", ";", "if", "(", "$", "len", ">", "255", "||", "$", "len", "<", "1", ")", "{", "throw", "InvalidArgumentException", "::", "invalidLength", "(", "'name'", ",", "1", ",", "255", ")", ";", "}", "}" ]
Validates a DynamoDB key name. @param $name mixed The name to validate. @throws InvalidArgumentException When the key name is invalid.
[ "Validates", "a", "DynamoDB", "key", "name", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php#L109-L119
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php
DynamoDbStorage.validateTableName
private function validateTableName($name) { if (! is_string($name)) { throw InvalidArgumentException::invalidType('key', 'string', $name); } if (! preg_match('/^[a-z0-9_.-]{3,255}$/i', $name)) { throw InvalidArgumentException::invalidTableName($name); } }
php
private function validateTableName($name) { if (! is_string($name)) { throw InvalidArgumentException::invalidType('key', 'string', $name); } if (! preg_match('/^[a-z0-9_.-]{3,255}$/i', $name)) { throw InvalidArgumentException::invalidTableName($name); } }
[ "private", "function", "validateTableName", "(", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "throw", "InvalidArgumentException", "::", "invalidType", "(", "'key'", ",", "'string'", ",", "$", "name", ")", ";", "}", "if", "(", "!", "preg_match", "(", "'/^[a-z0-9_.-]{3,255}$/i'", ",", "$", "name", ")", ")", "{", "throw", "InvalidArgumentException", "::", "invalidTableName", "(", "$", "name", ")", ";", "}", "}" ]
Validates a DynamoDB table name. @see http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html @param $name string The table name to validate. @throws InvalidArgumentException When the name is invalid.
[ "Validates", "a", "DynamoDB", "table", "name", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php#L130-L139
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php
DynamoDbStorage.setKeyForTable
private function setKeyForTable($table, $key) { $this->validateTableName($table); $this->validateKeyName($key); $this->tableKeys[$table] = $key; }
php
private function setKeyForTable($table, $key) { $this->validateTableName($table); $this->validateKeyName($key); $this->tableKeys[$table] = $key; }
[ "private", "function", "setKeyForTable", "(", "$", "table", ",", "$", "key", ")", "{", "$", "this", "->", "validateTableName", "(", "$", "table", ")", ";", "$", "this", "->", "validateKeyName", "(", "$", "key", ")", ";", "$", "this", "->", "tableKeys", "[", "$", "table", "]", "=", "$", "key", ";", "}" ]
Sets a key name for a specific table. @param $table string The name of the table. @param $key string The name of the string. @throws InvalidArgumentException When the key or table name is invalid.
[ "Sets", "a", "key", "name", "for", "a", "specific", "table", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php#L172-L177
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php
DynamoDbStorage.getKeyNameForTable
private function getKeyNameForTable($tableName) { return isset($this->tableKeys[$tableName]) ? $this->tableKeys[$tableName] : $this->defaultKeyName; }
php
private function getKeyNameForTable($tableName) { return isset($this->tableKeys[$tableName]) ? $this->tableKeys[$tableName] : $this->defaultKeyName; }
[ "private", "function", "getKeyNameForTable", "(", "$", "tableName", ")", "{", "return", "isset", "(", "$", "this", "->", "tableKeys", "[", "$", "tableName", "]", ")", "?", "$", "this", "->", "tableKeys", "[", "$", "tableName", "]", ":", "$", "this", "->", "defaultKeyName", ";", "}" ]
Retrieves a specific name for a key for a given table. The default is returned if this table does not have an actual override. @param string $tableName The name of the table. @return string
[ "Retrieves", "a", "specific", "name", "for", "a", "key", "for", "a", "given", "table", ".", "The", "default", "is", "returned", "if", "this", "table", "does", "not", "have", "an", "actual", "override", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php#L187-L192
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php
DynamoDbStorage.prepareKey
private function prepareKey($storageName, $key) { if (is_array($key)) { $keyValue = reset($key); $keyName = key($key); } else { $keyValue = $key; $keyName = $this->getKeyNameForTable($storageName); } return $this->marshaler->marshalItem([$keyName => $keyValue]); }
php
private function prepareKey($storageName, $key) { if (is_array($key)) { $keyValue = reset($key); $keyName = key($key); } else { $keyValue = $key; $keyName = $this->getKeyNameForTable($storageName); } return $this->marshaler->marshalItem([$keyName => $keyValue]); }
[ "private", "function", "prepareKey", "(", "$", "storageName", ",", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "keyValue", "=", "reset", "(", "$", "key", ")", ";", "$", "keyName", "=", "key", "(", "$", "key", ")", ";", "}", "else", "{", "$", "keyValue", "=", "$", "key", ";", "$", "keyName", "=", "$", "this", "->", "getKeyNameForTable", "(", "$", "storageName", ")", ";", "}", "return", "$", "this", "->", "marshaler", "->", "marshalItem", "(", "[", "$", "keyName", "=>", "$", "keyValue", "]", ")", ";", "}" ]
Prepares a key to be in a valid format for lookups for DynamoDB. If passing an array, that means that the key is the name of the key and the value is the actual value for the lookup. @param string $storageName Table name. @param string $key Key name. @return array The key in DynamoDB format.
[ "Prepares", "a", "key", "to", "be", "in", "a", "valid", "format", "for", "lookups", "for", "DynamoDB", ".", "If", "passing", "an", "array", "that", "means", "that", "the", "key", "is", "the", "name", "of", "the", "key", "and", "the", "value", "is", "the", "actual", "value", "for", "the", "lookup", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php#L203-L214
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php
DynamoDbStorage.prepareData
protected function prepareData($data) { $callback = function ($value) { return $value !== null && $value !== [] && $value !== ''; }; foreach ($data as &$value) { if (is_array($value)) { $value = $this->prepareData($value); } } return array_filter($data, $callback); }
php
protected function prepareData($data) { $callback = function ($value) { return $value !== null && $value !== [] && $value !== ''; }; foreach ($data as &$value) { if (is_array($value)) { $value = $this->prepareData($value); } } return array_filter($data, $callback); }
[ "protected", "function", "prepareData", "(", "$", "data", ")", "{", "$", "callback", "=", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", "&&", "$", "value", "!==", "[", "]", "&&", "$", "value", "!==", "''", ";", "}", ";", "foreach", "(", "$", "data", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "prepareData", "(", "$", "value", ")", ";", "}", "}", "return", "array_filter", "(", "$", "data", ",", "$", "callback", ")", ";", "}" ]
Prepare data by removing empty item attributes. @param array $data @return array
[ "Prepare", "data", "by", "removing", "empty", "item", "attributes", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php#L309-L321
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php
AzureSdkTableStorage.createEntity
private function createEntity(array $key, array $data) { list($partitonKey, $rowKey) = array_values($key); $entity = new Entity(); $entity->setPartitionKey((string) $partitonKey); $entity->setRowKey((string) $rowKey); foreach ($data as $variable => $value) { $type = $this->getPropertyType($value); $entity->addProperty($variable, $type, $value); } return $entity; }
php
private function createEntity(array $key, array $data) { list($partitonKey, $rowKey) = array_values($key); $entity = new Entity(); $entity->setPartitionKey((string) $partitonKey); $entity->setRowKey((string) $rowKey); foreach ($data as $variable => $value) { $type = $this->getPropertyType($value); $entity->addProperty($variable, $type, $value); } return $entity; }
[ "private", "function", "createEntity", "(", "array", "$", "key", ",", "array", "$", "data", ")", "{", "list", "(", "$", "partitonKey", ",", "$", "rowKey", ")", "=", "array_values", "(", "$", "key", ")", ";", "$", "entity", "=", "new", "Entity", "(", ")", ";", "$", "entity", "->", "setPartitionKey", "(", "(", "string", ")", "$", "partitonKey", ")", ";", "$", "entity", "->", "setRowKey", "(", "(", "string", ")", "$", "rowKey", ")", ";", "foreach", "(", "$", "data", "as", "$", "variable", "=>", "$", "value", ")", "{", "$", "type", "=", "$", "this", "->", "getPropertyType", "(", "$", "value", ")", ";", "$", "entity", "->", "addProperty", "(", "$", "variable", ",", "$", "type", ",", "$", "value", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Create entity object with key and data values. @param array $key @param array $data @return \WindowsAzure\Table\Model\Entity
[ "Create", "entity", "object", "with", "key", "and", "data", "values", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php#L221-L235
train
doctrine/KeyValueStore
lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php
AzureSdkTableStorage.getPropertyType
private function getPropertyType($propertyValue) { if ($propertyValue instanceof \DateTime) { return EdmType::DATETIME; } elseif (is_float($propertyValue)) { return EdmType::DOUBLE; } elseif (is_int($propertyValue)) { return EdmType::INT32; } elseif (is_bool($propertyValue)) { return EdmType::BOOLEAN; } return EdmType::STRING; }
php
private function getPropertyType($propertyValue) { if ($propertyValue instanceof \DateTime) { return EdmType::DATETIME; } elseif (is_float($propertyValue)) { return EdmType::DOUBLE; } elseif (is_int($propertyValue)) { return EdmType::INT32; } elseif (is_bool($propertyValue)) { return EdmType::BOOLEAN; } return EdmType::STRING; }
[ "private", "function", "getPropertyType", "(", "$", "propertyValue", ")", "{", "if", "(", "$", "propertyValue", "instanceof", "\\", "DateTime", ")", "{", "return", "EdmType", "::", "DATETIME", ";", "}", "elseif", "(", "is_float", "(", "$", "propertyValue", ")", ")", "{", "return", "EdmType", "::", "DOUBLE", ";", "}", "elseif", "(", "is_int", "(", "$", "propertyValue", ")", ")", "{", "return", "EdmType", "::", "INT32", ";", "}", "elseif", "(", "is_bool", "(", "$", "propertyValue", ")", ")", "{", "return", "EdmType", "::", "BOOLEAN", ";", "}", "return", "EdmType", "::", "STRING", ";", "}" ]
Infer the property type of variables.
[ "Infer", "the", "property", "type", "of", "variables", "." ]
8ba3db4ce7727f19cdb91519968ba4259b588277
https://github.com/doctrine/KeyValueStore/blob/8ba3db4ce7727f19cdb91519968ba4259b588277/lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php#L240-L253
train