id
int32
0
241k
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
19,200
xinix-technology/norm
src/Norm/Model.php
Model.prepare
public function prepare($key, $value, $schema = null) { if ($this->collection) { return $this->collection->prepare($key, $value, $schema); } else { return $value; } }
php
public function prepare($key, $value, $schema = null) { if ($this->collection) { return $this->collection->prepare($key, $value, $schema); } else { return $value; } }
[ "public", "function", "prepare", "(", "$", "key", ",", "$", "value", ",", "$", "schema", "=", "null", ")", "{", "if", "(", "$", "this", "->", "collection", ")", "{", "return", "$", "this", "->", "collection", "->", "prepare", "(", "$", "key", ",", "$", "value", ",", "$", "schema", ")", ";", "}", "else", "{", "return", "$", "value", ";", "}", "}" ]
Prepare model to be sync'd. @method prepare @param string $key @param string $value @param mixed $schema @return [type]
[ "Prepare", "model", "to", "be", "sync", "d", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L302-L309
19,201
xinix-technology/norm
src/Norm/Model.php
Model.toArray
public function toArray($fetchType = Model::FETCH_ALL) { if ($fetchType === Model::FETCH_RAW) { return $this->attributes; } $attributes = array(); if (empty($this->attributes)) { $this->attributes = array(); } if ($fetchType === Model::FETCH_ALL or $fetchType === Model::FETCH_HIDDEN) { $attributes['$type'] = $this->getClass(); $attributes['$id'] = $this->getId(); foreach ($this->attributes as $key => $value) { if ($key[0] === '$') { $attributes[$key] = $value; } } } if ($fetchType === Model::FETCH_ALL or $fetchType === Model::FETCH_PUBLISHED) { foreach ($this->attributes as $key => $value) { if ($key[0] !== '$') { $attributes[$key] = $value; } } } return $attributes; }
php
public function toArray($fetchType = Model::FETCH_ALL) { if ($fetchType === Model::FETCH_RAW) { return $this->attributes; } $attributes = array(); if (empty($this->attributes)) { $this->attributes = array(); } if ($fetchType === Model::FETCH_ALL or $fetchType === Model::FETCH_HIDDEN) { $attributes['$type'] = $this->getClass(); $attributes['$id'] = $this->getId(); foreach ($this->attributes as $key => $value) { if ($key[0] === '$') { $attributes[$key] = $value; } } } if ($fetchType === Model::FETCH_ALL or $fetchType === Model::FETCH_PUBLISHED) { foreach ($this->attributes as $key => $value) { if ($key[0] !== '$') { $attributes[$key] = $value; } } } return $attributes; }
[ "public", "function", "toArray", "(", "$", "fetchType", "=", "Model", "::", "FETCH_ALL", ")", "{", "if", "(", "$", "fetchType", "===", "Model", "::", "FETCH_RAW", ")", "{", "return", "$", "this", "->", "attributes", ";", "}", "$", "attributes", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "attributes", ")", ")", "{", "$", "this", "->", "attributes", "=", "array", "(", ")", ";", "}", "if", "(", "$", "fetchType", "===", "Model", "::", "FETCH_ALL", "or", "$", "fetchType", "===", "Model", "::", "FETCH_HIDDEN", ")", "{", "$", "attributes", "[", "'$type'", "]", "=", "$", "this", "->", "getClass", "(", ")", ";", "$", "attributes", "[", "'$id'", "]", "=", "$", "this", "->", "getId", "(", ")", ";", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "[", "0", "]", "===", "'$'", ")", "{", "$", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "if", "(", "$", "fetchType", "===", "Model", "::", "FETCH_ALL", "or", "$", "fetchType", "===", "Model", "::", "FETCH_PUBLISHED", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "[", "0", "]", "!==", "'$'", ")", "{", "$", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "attributes", ";", "}" ]
Get array structure of model @param mixed $fetchType @return array
[ "Get", "array", "structure", "of", "model" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L352-L384
19,202
xinix-technology/norm
src/Norm/Model.php
Model.jsonSerialize
public function jsonSerialize() { if (! Norm::options('include')) { return $this->toArray(); } $destination = array(); $source = $this->toArray(); $schema = $this->collection->schema(); foreach ($source as $key => $value) { if (isset($schema[$key]) and isset($value)) { $destination[$key] = $schema[$key]->toJSON($value); } else { $destination[$key] = $value; } $destination[$key] = JsonKit::replaceObject($destination[$key]); } return $destination; }
php
public function jsonSerialize() { if (! Norm::options('include')) { return $this->toArray(); } $destination = array(); $source = $this->toArray(); $schema = $this->collection->schema(); foreach ($source as $key => $value) { if (isset($schema[$key]) and isset($value)) { $destination[$key] = $schema[$key]->toJSON($value); } else { $destination[$key] = $value; } $destination[$key] = JsonKit::replaceObject($destination[$key]); } return $destination; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "if", "(", "!", "Norm", "::", "options", "(", "'include'", ")", ")", "{", "return", "$", "this", "->", "toArray", "(", ")", ";", "}", "$", "destination", "=", "array", "(", ")", ";", "$", "source", "=", "$", "this", "->", "toArray", "(", ")", ";", "$", "schema", "=", "$", "this", "->", "collection", "->", "schema", "(", ")", ";", "foreach", "(", "$", "source", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "schema", "[", "$", "key", "]", ")", "and", "isset", "(", "$", "value", ")", ")", "{", "$", "destination", "[", "$", "key", "]", "=", "$", "schema", "[", "$", "key", "]", "->", "toJSON", "(", "$", "value", ")", ";", "}", "else", "{", "$", "destination", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "destination", "[", "$", "key", "]", "=", "JsonKit", "::", "replaceObject", "(", "$", "destination", "[", "$", "key", "]", ")", ";", "}", "return", "$", "destination", ";", "}" ]
Implement the json serializer normalizing the data structures. @return array
[ "Implement", "the", "json", "serializer", "normalizing", "the", "data", "structures", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L448-L470
19,203
xinix-technology/norm
src/Norm/Model.php
Model.previous
public function previous($key = null) { if (is_null($key)) { return $this->oldAttributes; } return $this->oldAttributes[$key]; }
php
public function previous($key = null) { if (is_null($key)) { return $this->oldAttributes; } return $this->oldAttributes[$key]; }
[ "public", "function", "previous", "(", "$", "key", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "oldAttributes", ";", "}", "return", "$", "this", "->", "oldAttributes", "[", "$", "key", "]", ";", "}" ]
Get original attributes @method previous @param string $key @return mixed
[ "Get", "original", "attributes" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L493-L500
19,204
xinix-technology/norm
src/Norm/Model.php
Model.schemaByIndex
public function schemaByIndex($index) { $schema = array(); foreach ($this->collection->schema() as $value) { $schema[] = $value; } return (empty($schema[$index])) ? null : $schema[$index]; }
php
public function schemaByIndex($index) { $schema = array(); foreach ($this->collection->schema() as $value) { $schema[] = $value; } return (empty($schema[$index])) ? null : $schema[$index]; }
[ "public", "function", "schemaByIndex", "(", "$", "index", ")", "{", "$", "schema", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "collection", "->", "schema", "(", ")", "as", "$", "value", ")", "{", "$", "schema", "[", "]", "=", "$", "value", ";", "}", "return", "(", "empty", "(", "$", "schema", "[", "$", "index", "]", ")", ")", "?", "null", ":", "$", "schema", "[", "$", "index", "]", ";", "}" ]
Get schema configuration by offset name. @method schemaByIndex @param string $index @return mixed
[ "Get", "schema", "configuration", "by", "offset", "name", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L553-L562
19,205
xinix-technology/norm
src/Norm/Model.php
Model.format
public function format($field = null, $format = null) { $numArgs = func_num_args(); if ($numArgs === 0) { $formatter = $this->collection->option('format'); if (is_null($formatter)) { $schema = $this->schemaByIndex(0); if (!is_null($schema)) { return (isset($this[$schema['name']])) ? val($this[$schema['name']]) : null; } else { return '-- no formatter and schema --'; } } else { if ($formatter instanceof Closure) { return $formatter($this); } elseif (is_string($formatter)) { $result = preg_replace_callback('/{(\w+)}/', function($matches) { return $this->format($matches[1]); }, $formatter); return $result; } else { throw new Exception('Unknown format for Model formatter.'); } } } else { $format = $format ?: 'plain'; $schema = $this->schema($field); // TODO return value if no formatter or just throw exception? if (is_null($schema)) { throw new Exception("[Norm/Model] No formatter [$format] for field [$field]."); } else { $value = isset($this[$field]) ? val($this[$field]) : null; return $schema->format($format, $value, $this); } } }
php
public function format($field = null, $format = null) { $numArgs = func_num_args(); if ($numArgs === 0) { $formatter = $this->collection->option('format'); if (is_null($formatter)) { $schema = $this->schemaByIndex(0); if (!is_null($schema)) { return (isset($this[$schema['name']])) ? val($this[$schema['name']]) : null; } else { return '-- no formatter and schema --'; } } else { if ($formatter instanceof Closure) { return $formatter($this); } elseif (is_string($formatter)) { $result = preg_replace_callback('/{(\w+)}/', function($matches) { return $this->format($matches[1]); }, $formatter); return $result; } else { throw new Exception('Unknown format for Model formatter.'); } } } else { $format = $format ?: 'plain'; $schema = $this->schema($field); // TODO return value if no formatter or just throw exception? if (is_null($schema)) { throw new Exception("[Norm/Model] No formatter [$format] for field [$field]."); } else { $value = isset($this[$field]) ? val($this[$field]) : null; return $schema->format($format, $value, $this); } } }
[ "public", "function", "format", "(", "$", "field", "=", "null", ",", "$", "format", "=", "null", ")", "{", "$", "numArgs", "=", "func_num_args", "(", ")", ";", "if", "(", "$", "numArgs", "===", "0", ")", "{", "$", "formatter", "=", "$", "this", "->", "collection", "->", "option", "(", "'format'", ")", ";", "if", "(", "is_null", "(", "$", "formatter", ")", ")", "{", "$", "schema", "=", "$", "this", "->", "schemaByIndex", "(", "0", ")", ";", "if", "(", "!", "is_null", "(", "$", "schema", ")", ")", "{", "return", "(", "isset", "(", "$", "this", "[", "$", "schema", "[", "'name'", "]", "]", ")", ")", "?", "val", "(", "$", "this", "[", "$", "schema", "[", "'name'", "]", "]", ")", ":", "null", ";", "}", "else", "{", "return", "'-- no formatter and schema --'", ";", "}", "}", "else", "{", "if", "(", "$", "formatter", "instanceof", "Closure", ")", "{", "return", "$", "formatter", "(", "$", "this", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "formatter", ")", ")", "{", "$", "result", "=", "preg_replace_callback", "(", "'/{(\\w+)}/'", ",", "function", "(", "$", "matches", ")", "{", "return", "$", "this", "->", "format", "(", "$", "matches", "[", "1", "]", ")", ";", "}", ",", "$", "formatter", ")", ";", "return", "$", "result", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'Unknown format for Model formatter.'", ")", ";", "}", "}", "}", "else", "{", "$", "format", "=", "$", "format", "?", ":", "'plain'", ";", "$", "schema", "=", "$", "this", "->", "schema", "(", "$", "field", ")", ";", "// TODO return value if no formatter or just throw exception?", "if", "(", "is_null", "(", "$", "schema", ")", ")", "{", "throw", "new", "Exception", "(", "\"[Norm/Model] No formatter [$format] for field [$field].\"", ")", ";", "}", "else", "{", "$", "value", "=", "isset", "(", "$", "this", "[", "$", "field", "]", ")", "?", "val", "(", "$", "this", "[", "$", "field", "]", ")", ":", "null", ";", "return", "$", "schema", "->", "format", "(", "$", "format", ",", "$", "value", ",", "$", "this", ")", ";", "}", "}", "}" ]
Format the model to HTML file. Bind it's attributes to view. @method format @param string $field @param string $format @return mixed
[ "Format", "the", "model", "to", "HTML", "file", ".", "Bind", "it", "s", "attributes", "to", "view", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L574-L615
19,206
yuncms/framework
src/admin/widgets/Inspinia.php
Inspinia.endBodyToolbar
public function endBodyToolbar() { $this->_setBeginning(false); $toolbar = trim(ob_get_clean()); if (is_string($this->bodyToolbar)) { $this->bodyToolbar = [$this->bodyToolbar]; } $this->bodyToolbar[] = [ 'body' => $toolbar, 'options' => $this->_bodyToolbarLastOptions, ]; $this->_bodyToolbarLastOptions = []; }
php
public function endBodyToolbar() { $this->_setBeginning(false); $toolbar = trim(ob_get_clean()); if (is_string($this->bodyToolbar)) { $this->bodyToolbar = [$this->bodyToolbar]; } $this->bodyToolbar[] = [ 'body' => $toolbar, 'options' => $this->_bodyToolbarLastOptions, ]; $this->_bodyToolbarLastOptions = []; }
[ "public", "function", "endBodyToolbar", "(", ")", "{", "$", "this", "->", "_setBeginning", "(", "false", ")", ";", "$", "toolbar", "=", "trim", "(", "ob_get_clean", "(", ")", ")", ";", "if", "(", "is_string", "(", "$", "this", "->", "bodyToolbar", ")", ")", "{", "$", "this", "->", "bodyToolbar", "=", "[", "$", "this", "->", "bodyToolbar", "]", ";", "}", "$", "this", "->", "bodyToolbar", "[", "]", "=", "[", "'body'", "=>", "$", "toolbar", ",", "'options'", "=>", "$", "this", "->", "_bodyToolbarLastOptions", ",", "]", ";", "$", "this", "->", "_bodyToolbarLastOptions", "=", "[", "]", ";", "}" ]
End Body Toolbar @throws Exception
[ "End", "Body", "Toolbar" ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/widgets/Inspinia.php#L196-L208
19,207
yuncms/framework
src/admin/widgets/Inspinia.php
Inspinia._getBodyToolbar
private function _getBodyToolbar() { if ($this->bodyToolbar !== null) { Html::addCssClass($this->bodyToolbarOptions, 'widget-body-toolbar'); $toolbars = is_string($this->bodyToolbar) ? [$this->bodyToolbar] : $this->bodyToolbar; foreach ($toolbars as $toolbar) { if (is_array($toolbar)) { $body = isset($toolbar['body']) ? $toolbar['body'] : null; $options = isset($toolbar['options']) ? $toolbar['options'] : []; Html::addCssClass($options, 'widget-body-toolbar'); echo Html::tag('div', $body, $options); } else { echo Html::tag('div', $toolbar, $this->bodyToolbarOptions); } } } }
php
private function _getBodyToolbar() { if ($this->bodyToolbar !== null) { Html::addCssClass($this->bodyToolbarOptions, 'widget-body-toolbar'); $toolbars = is_string($this->bodyToolbar) ? [$this->bodyToolbar] : $this->bodyToolbar; foreach ($toolbars as $toolbar) { if (is_array($toolbar)) { $body = isset($toolbar['body']) ? $toolbar['body'] : null; $options = isset($toolbar['options']) ? $toolbar['options'] : []; Html::addCssClass($options, 'widget-body-toolbar'); echo Html::tag('div', $body, $options); } else { echo Html::tag('div', $toolbar, $this->bodyToolbarOptions); } } } }
[ "private", "function", "_getBodyToolbar", "(", ")", "{", "if", "(", "$", "this", "->", "bodyToolbar", "!==", "null", ")", "{", "Html", "::", "addCssClass", "(", "$", "this", "->", "bodyToolbarOptions", ",", "'widget-body-toolbar'", ")", ";", "$", "toolbars", "=", "is_string", "(", "$", "this", "->", "bodyToolbar", ")", "?", "[", "$", "this", "->", "bodyToolbar", "]", ":", "$", "this", "->", "bodyToolbar", ";", "foreach", "(", "$", "toolbars", "as", "$", "toolbar", ")", "{", "if", "(", "is_array", "(", "$", "toolbar", ")", ")", "{", "$", "body", "=", "isset", "(", "$", "toolbar", "[", "'body'", "]", ")", "?", "$", "toolbar", "[", "'body'", "]", ":", "null", ";", "$", "options", "=", "isset", "(", "$", "toolbar", "[", "'options'", "]", ")", "?", "$", "toolbar", "[", "'options'", "]", ":", "[", "]", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "'widget-body-toolbar'", ")", ";", "echo", "Html", "::", "tag", "(", "'div'", ",", "$", "body", ",", "$", "options", ")", ";", "}", "else", "{", "echo", "Html", "::", "tag", "(", "'div'", ",", "$", "toolbar", ",", "$", "this", "->", "bodyToolbarOptions", ")", ";", "}", "}", "}", "}" ]
Get body toolbar
[ "Get", "body", "toolbar" ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/widgets/Inspinia.php#L259-L275
19,208
activecollab/configfile
src/ConfigFile.php
ConfigFile.getFromConst
private function getFromConst($line) { $eq_pos = strpos($line, '='); $semicolon_pos = strrpos($line, ';'); $constant_name = trim(substr($line, 6, $eq_pos - 6)); $value = trim(substr($line, $eq_pos + 1, $semicolon_pos - $eq_pos - 1)); return [$constant_name, $this->getNativeValueFromDefinition($value)]; }
php
private function getFromConst($line) { $eq_pos = strpos($line, '='); $semicolon_pos = strrpos($line, ';'); $constant_name = trim(substr($line, 6, $eq_pos - 6)); $value = trim(substr($line, $eq_pos + 1, $semicolon_pos - $eq_pos - 1)); return [$constant_name, $this->getNativeValueFromDefinition($value)]; }
[ "private", "function", "getFromConst", "(", "$", "line", ")", "{", "$", "eq_pos", "=", "strpos", "(", "$", "line", ",", "'='", ")", ";", "$", "semicolon_pos", "=", "strrpos", "(", "$", "line", ",", "';'", ")", ";", "$", "constant_name", "=", "trim", "(", "substr", "(", "$", "line", ",", "6", ",", "$", "eq_pos", "-", "6", ")", ")", ";", "$", "value", "=", "trim", "(", "substr", "(", "$", "line", ",", "$", "eq_pos", "+", "1", ",", "$", "semicolon_pos", "-", "$", "eq_pos", "-", "1", ")", ")", ";", "return", "[", "$", "constant_name", ",", "$", "this", "->", "getNativeValueFromDefinition", "(", "$", "value", ")", "]", ";", "}" ]
Return single option from const DB_XYZ defition line @param string $line @return string
[ "Return", "single", "option", "from", "const", "DB_XYZ", "defition", "line" ]
fe0ae7da3466f26e49e54b6dd3508c85421c0bdf
https://github.com/activecollab/configfile/blob/fe0ae7da3466f26e49e54b6dd3508c85421c0bdf/src/ConfigFile.php#L113-L122
19,209
activecollab/configfile
src/ConfigFile.php
ConfigFile.getOptionNameFromDefinition
public function getOptionNameFromDefinition($constant_name) { if ($this->strStartsWith($constant_name, "'") && $this->strEndsWith($constant_name, "'")) { return trim(trim($constant_name, "'")); // single quote } else { if ($this->strStartsWith($constant_name, '"') && $this->strEndsWith($constant_name, '"')) { return trim(trim($constant_name, '"')); // double quote } else { return $constant_name; } } }
php
public function getOptionNameFromDefinition($constant_name) { if ($this->strStartsWith($constant_name, "'") && $this->strEndsWith($constant_name, "'")) { return trim(trim($constant_name, "'")); // single quote } else { if ($this->strStartsWith($constant_name, '"') && $this->strEndsWith($constant_name, '"')) { return trim(trim($constant_name, '"')); // double quote } else { return $constant_name; } } }
[ "public", "function", "getOptionNameFromDefinition", "(", "$", "constant_name", ")", "{", "if", "(", "$", "this", "->", "strStartsWith", "(", "$", "constant_name", ",", "\"'\"", ")", "&&", "$", "this", "->", "strEndsWith", "(", "$", "constant_name", ",", "\"'\"", ")", ")", "{", "return", "trim", "(", "trim", "(", "$", "constant_name", ",", "\"'\"", ")", ")", ";", "// single quote", "}", "else", "{", "if", "(", "$", "this", "->", "strStartsWith", "(", "$", "constant_name", ",", "'\"'", ")", "&&", "$", "this", "->", "strEndsWith", "(", "$", "constant_name", ",", "'\"'", ")", ")", "{", "return", "trim", "(", "trim", "(", "$", "constant_name", ",", "'\"'", ")", ")", ";", "// double quote", "}", "else", "{", "return", "$", "constant_name", ";", "}", "}", "}" ]
Return config option name from defintiion string @param string $constant_name @return string
[ "Return", "config", "option", "name", "from", "defintiion", "string" ]
fe0ae7da3466f26e49e54b6dd3508c85421c0bdf
https://github.com/activecollab/configfile/blob/fe0ae7da3466f26e49e54b6dd3508c85421c0bdf/src/ConfigFile.php#L189-L200
19,210
activecollab/configfile
src/ConfigFile.php
ConfigFile.getNativeValueFromDefinition
private function getNativeValueFromDefinition($value) { if ($this->strStartsWith($value, "'") && $this->strEndsWith($value, "'")) { $value = trim(trim($value, "'")); // single quote } else { if ($this->strStartsWith($value, '"') && $this->strEndsWith($value, '"')) { $value = trim(trim($value, '"')); // double quote } else { if ($value == 'true') { $value = true; } else { if ($value == 'false') { $value = false; } else { if (is_numeric($value)) { if (ctype_digit($value)) { return (integer)$value; } else { return (float)$value; } } } } } } return $value; }
php
private function getNativeValueFromDefinition($value) { if ($this->strStartsWith($value, "'") && $this->strEndsWith($value, "'")) { $value = trim(trim($value, "'")); // single quote } else { if ($this->strStartsWith($value, '"') && $this->strEndsWith($value, '"')) { $value = trim(trim($value, '"')); // double quote } else { if ($value == 'true') { $value = true; } else { if ($value == 'false') { $value = false; } else { if (is_numeric($value)) { if (ctype_digit($value)) { return (integer)$value; } else { return (float)$value; } } } } } } return $value; }
[ "private", "function", "getNativeValueFromDefinition", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "strStartsWith", "(", "$", "value", ",", "\"'\"", ")", "&&", "$", "this", "->", "strEndsWith", "(", "$", "value", ",", "\"'\"", ")", ")", "{", "$", "value", "=", "trim", "(", "trim", "(", "$", "value", ",", "\"'\"", ")", ")", ";", "// single quote", "}", "else", "{", "if", "(", "$", "this", "->", "strStartsWith", "(", "$", "value", ",", "'\"'", ")", "&&", "$", "this", "->", "strEndsWith", "(", "$", "value", ",", "'\"'", ")", ")", "{", "$", "value", "=", "trim", "(", "trim", "(", "$", "value", ",", "'\"'", ")", ")", ";", "// double quote", "}", "else", "{", "if", "(", "$", "value", "==", "'true'", ")", "{", "$", "value", "=", "true", ";", "}", "else", "{", "if", "(", "$", "value", "==", "'false'", ")", "{", "$", "value", "=", "false", ";", "}", "else", "{", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "if", "(", "ctype_digit", "(", "$", "value", ")", ")", "{", "return", "(", "integer", ")", "$", "value", ";", "}", "else", "{", "return", "(", "float", ")", "$", "value", ";", "}", "}", "}", "}", "}", "}", "return", "$", "value", ";", "}" ]
Cast declared value to internal type @param string $value @return mixed
[ "Cast", "declared", "value", "to", "internal", "type" ]
fe0ae7da3466f26e49e54b6dd3508c85421c0bdf
https://github.com/activecollab/configfile/blob/fe0ae7da3466f26e49e54b6dd3508c85421c0bdf/src/ConfigFile.php#L208-L235
19,211
activecollab/configfile
src/ConfigFile.php
ConfigFile.strStartsWith
private function strStartsWith($string, $niddle) { return mb_strtolower(substr($string, 0, mb_strlen($niddle))) == mb_strtolower($niddle); }
php
private function strStartsWith($string, $niddle) { return mb_strtolower(substr($string, 0, mb_strlen($niddle))) == mb_strtolower($niddle); }
[ "private", "function", "strStartsWith", "(", "$", "string", ",", "$", "niddle", ")", "{", "return", "mb_strtolower", "(", "substr", "(", "$", "string", ",", "0", ",", "mb_strlen", "(", "$", "niddle", ")", ")", ")", "==", "mb_strtolower", "(", "$", "niddle", ")", ";", "}" ]
Case insensitive string begins with @param string $string @param string $niddle @return boolean
[ "Case", "insensitive", "string", "begins", "with" ]
fe0ae7da3466f26e49e54b6dd3508c85421c0bdf
https://github.com/activecollab/configfile/blob/fe0ae7da3466f26e49e54b6dd3508c85421c0bdf/src/ConfigFile.php#L266-L269
19,212
activecollab/configfile
src/ConfigFile.php
ConfigFile.strEndsWith
private function strEndsWith($string, $niddle) { return mb_substr($string, mb_strlen($string) - mb_strlen($niddle), mb_strlen($niddle)) == $niddle; }
php
private function strEndsWith($string, $niddle) { return mb_substr($string, mb_strlen($string) - mb_strlen($niddle), mb_strlen($niddle)) == $niddle; }
[ "private", "function", "strEndsWith", "(", "$", "string", ",", "$", "niddle", ")", "{", "return", "mb_substr", "(", "$", "string", ",", "mb_strlen", "(", "$", "string", ")", "-", "mb_strlen", "(", "$", "niddle", ")", ",", "mb_strlen", "(", "$", "niddle", ")", ")", "==", "$", "niddle", ";", "}" ]
Case insensitive string ends with @param string $string @param string $niddle @return boolean
[ "Case", "insensitive", "string", "ends", "with" ]
fe0ae7da3466f26e49e54b6dd3508c85421c0bdf
https://github.com/activecollab/configfile/blob/fe0ae7da3466f26e49e54b6dd3508c85421c0bdf/src/ConfigFile.php#L290-L293
19,213
2amigos/yiifoundation
helpers/Typo.php
Typo.vCard
public static function vCard($name, $address = '', $locality = '', $state = '', $zip = '', $email = '') { $items = array(); $items[] = \CHtml::tag('li', array('class' => 'fn'), $name); $items[] = \CHtml::tag('li', array('class' => 'street-address'), $address); $items[] = \CHtml::tag('li', array('class' => 'locality'), $locality); $sub = array(); $sub[] = \CHtml::tag('span', array('class' => 'state'), $state); $sub[] = \CHtml::tag('span', array('class' => 'zip'), $zip); $items[] = \CHtml::tag('li', array(), implode(", ", $sub)); $items[] = \CHtml::tag('li', array('class' => 'email'), $email); return \CHtml::tag('ul', array('class' => 'vcard'), implode("\n", $items)); }
php
public static function vCard($name, $address = '', $locality = '', $state = '', $zip = '', $email = '') { $items = array(); $items[] = \CHtml::tag('li', array('class' => 'fn'), $name); $items[] = \CHtml::tag('li', array('class' => 'street-address'), $address); $items[] = \CHtml::tag('li', array('class' => 'locality'), $locality); $sub = array(); $sub[] = \CHtml::tag('span', array('class' => 'state'), $state); $sub[] = \CHtml::tag('span', array('class' => 'zip'), $zip); $items[] = \CHtml::tag('li', array(), implode(", ", $sub)); $items[] = \CHtml::tag('li', array('class' => 'email'), $email); return \CHtml::tag('ul', array('class' => 'vcard'), implode("\n", $items)); }
[ "public", "static", "function", "vCard", "(", "$", "name", ",", "$", "address", "=", "''", ",", "$", "locality", "=", "''", ",", "$", "state", "=", "''", ",", "$", "zip", "=", "''", ",", "$", "email", "=", "''", ")", "{", "$", "items", "=", "array", "(", ")", ";", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'fn'", ")", ",", "$", "name", ")", ";", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'street-address'", ")", ",", "$", "address", ")", ";", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'locality'", ")", ",", "$", "locality", ")", ";", "$", "sub", "=", "array", "(", ")", ";", "$", "sub", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'span'", ",", "array", "(", "'class'", "=>", "'state'", ")", ",", "$", "state", ")", ";", "$", "sub", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'span'", ",", "array", "(", "'class'", "=>", "'zip'", ")", ",", "$", "zip", ")", ";", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "array", "(", ")", ",", "implode", "(", "\", \"", ",", "$", "sub", ")", ")", ";", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'email'", ")", ",", "$", "email", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "'vcard'", ")", ",", "implode", "(", "\"\\n\"", ",", "$", "items", ")", ")", ";", "}" ]
Renders a handy microformat-friendly list for addresses @param string $name @param string $address @param string $locality @param string $state @param string $zip @param string $email @return string the generated vcard
[ "Renders", "a", "handy", "microformat", "-", "friendly", "list", "for", "addresses" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Typo.php#L64-L77
19,214
2amigos/yiifoundation
helpers/Typo.php
Typo.inlineList
public static function inlineList($items, $htmlOptions = array()) { $listItems = array(); Html::addCssClass($htmlOptions, 'inline-list'); foreach ($items as $item) { $listItems[] = \CHtml::tag('li', $htmlOptions, $item); } if (!empty($listItems)) { return \CHtml::tag('ul', $htmlOptions, implode("\n", $listItems)); } }
php
public static function inlineList($items, $htmlOptions = array()) { $listItems = array(); Html::addCssClass($htmlOptions, 'inline-list'); foreach ($items as $item) { $listItems[] = \CHtml::tag('li', $htmlOptions, $item); } if (!empty($listItems)) { return \CHtml::tag('ul', $htmlOptions, implode("\n", $listItems)); } }
[ "public", "static", "function", "inlineList", "(", "$", "items", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "$", "listItems", "=", "array", "(", ")", ";", "Html", "::", "addCssClass", "(", "$", "htmlOptions", ",", "'inline-list'", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "listItems", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "$", "htmlOptions", ",", "$", "item", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "listItems", ")", ")", "{", "return", "\\", "CHtml", "::", "tag", "(", "'ul'", ",", "$", "htmlOptions", ",", "implode", "(", "\"\\n\"", ",", "$", "listItems", ")", ")", ";", "}", "}" ]
Renders and inline list @param array $items the items to render @param array $htmlOptions the HTML attributes @return string the generated list
[ "Renders", "and", "inline", "list" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Typo.php#L85-L96
19,215
2amigos/yiifoundation
helpers/Typo.php
Typo.label
public static function label($text, $htmlOptions = array()) { ArrayHelper::addValue('class', 'label', $htmlOptions); return \CHtml::tag('span', $htmlOptions, $text); }
php
public static function label($text, $htmlOptions = array()) { ArrayHelper::addValue('class', 'label', $htmlOptions); return \CHtml::tag('span', $htmlOptions, $text); }
[ "public", "static", "function", "label", "(", "$", "text", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "ArrayHelper", "::", "addValue", "(", "'class'", ",", "'label'", ",", "$", "htmlOptions", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'span'", ",", "$", "htmlOptions", ",", "$", "text", ")", ";", "}" ]
Renders a Foundation label @param string $text the text to render within the label @param array $htmlOptions the HTML attributes @return string the generated label
[ "Renders", "a", "Foundation", "label" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Typo.php#L104-L108
19,216
austinkregel/Warden
src/Warden/Http/Controllers/ApiController.php
ApiController.modelHasBeenSaved
protected function modelHasBeenSaved($saved, $type, $request) { if (!$saved) { return response()->json(['message' => 'Failed to '.$type.' resource', 'code' => 422], 422); } $status = $request->ajax() ? 202 : 200; if ($request->ajax()) { return response()->json(['message' => 'Successfully '.$type.' resource', 'code' => $status], $status); } if ($request->has('_redirect')) { // Remove the base part of the url, and just grab the tail end of the desired redirect, that way the // User can't be redirected away from your website. return $this->returnRedirect('Successfully '.$type.' resource', $request); } return redirect()->back()->with(['message' => 'Successfully '.$type.' resource']); }
php
protected function modelHasBeenSaved($saved, $type, $request) { if (!$saved) { return response()->json(['message' => 'Failed to '.$type.' resource', 'code' => 422], 422); } $status = $request->ajax() ? 202 : 200; if ($request->ajax()) { return response()->json(['message' => 'Successfully '.$type.' resource', 'code' => $status], $status); } if ($request->has('_redirect')) { // Remove the base part of the url, and just grab the tail end of the desired redirect, that way the // User can't be redirected away from your website. return $this->returnRedirect('Successfully '.$type.' resource', $request); } return redirect()->back()->with(['message' => 'Successfully '.$type.' resource']); }
[ "protected", "function", "modelHasBeenSaved", "(", "$", "saved", ",", "$", "type", ",", "$", "request", ")", "{", "if", "(", "!", "$", "saved", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "'message'", "=>", "'Failed to '", ".", "$", "type", ".", "' resource'", ",", "'code'", "=>", "422", "]", ",", "422", ")", ";", "}", "$", "status", "=", "$", "request", "->", "ajax", "(", ")", "?", "202", ":", "200", ";", "if", "(", "$", "request", "->", "ajax", "(", ")", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "'message'", "=>", "'Successfully '", ".", "$", "type", ".", "' resource'", ",", "'code'", "=>", "$", "status", "]", ",", "$", "status", ")", ";", "}", "if", "(", "$", "request", "->", "has", "(", "'_redirect'", ")", ")", "{", "// Remove the base part of the url, and just grab the tail end of the desired redirect, that way the", "// User can't be redirected away from your website.", "return", "$", "this", "->", "returnRedirect", "(", "'Successfully '", ".", "$", "type", ".", "' resource'", ",", "$", "request", ")", ";", "}", "return", "redirect", "(", ")", "->", "back", "(", ")", "->", "with", "(", "[", "'message'", "=>", "'Successfully '", ".", "$", "type", ".", "' resource'", "]", ")", ";", "}" ]
This method handles how submitted quests are handle, the main related methods for it are POST and. @param $saved @param $request @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
[ "This", "method", "handles", "how", "submitted", "quests", "are", "handle", "the", "main", "related", "methods", "for", "it", "are", "POST", "and", "." ]
6f5a98bd79a488f0f300f4851061ac6f7d19f8a3
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/ApiController.php#L123-L139
19,217
austinkregel/Warden
src/Warden/Http/Controllers/ApiController.php
ApiController.validatePut
public function validatePut($input, $model, $model_name) { return collect($input)->filter(function ($value, $key) use ($model, $input) { // Remove _token if (!isset($value) || $key === '_token') { return false; } //Remove values that are the same. if (isset($model->$key)) { if ($model->$key === $value) { return false; } } // Is there a relation? If there is, unset it. if ($this->doesModelRelate($model, $key, $value)) { return false; } // If there is a password field, if (((stripos($key, 'password') !== false) || (stripos($key, 'passwd') !== false)) && !empty($model->$key)) { if (\Hash::check($value, $model->$key)) { return false; } else { $user_model = config('kregel.warden.models.user.model'); $user = new $user_model(); if (empty($user->hashable)) { $input[$key] = bcrypt($value); return true; } } } return true; }); }
php
public function validatePut($input, $model, $model_name) { return collect($input)->filter(function ($value, $key) use ($model, $input) { // Remove _token if (!isset($value) || $key === '_token') { return false; } //Remove values that are the same. if (isset($model->$key)) { if ($model->$key === $value) { return false; } } // Is there a relation? If there is, unset it. if ($this->doesModelRelate($model, $key, $value)) { return false; } // If there is a password field, if (((stripos($key, 'password') !== false) || (stripos($key, 'passwd') !== false)) && !empty($model->$key)) { if (\Hash::check($value, $model->$key)) { return false; } else { $user_model = config('kregel.warden.models.user.model'); $user = new $user_model(); if (empty($user->hashable)) { $input[$key] = bcrypt($value); return true; } } } return true; }); }
[ "public", "function", "validatePut", "(", "$", "input", ",", "$", "model", ",", "$", "model_name", ")", "{", "return", "collect", "(", "$", "input", ")", "->", "filter", "(", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "model", ",", "$", "input", ")", "{", "// Remove _token", "if", "(", "!", "isset", "(", "$", "value", ")", "||", "$", "key", "===", "'_token'", ")", "{", "return", "false", ";", "}", "//Remove values that are the same.", "if", "(", "isset", "(", "$", "model", "->", "$", "key", ")", ")", "{", "if", "(", "$", "model", "->", "$", "key", "===", "$", "value", ")", "{", "return", "false", ";", "}", "}", "// Is there a relation? If there is, unset it.", "if", "(", "$", "this", "->", "doesModelRelate", "(", "$", "model", ",", "$", "key", ",", "$", "value", ")", ")", "{", "return", "false", ";", "}", "// If there is a password field,", "if", "(", "(", "(", "stripos", "(", "$", "key", ",", "'password'", ")", "!==", "false", ")", "||", "(", "stripos", "(", "$", "key", ",", "'passwd'", ")", "!==", "false", ")", ")", "&&", "!", "empty", "(", "$", "model", "->", "$", "key", ")", ")", "{", "if", "(", "\\", "Hash", "::", "check", "(", "$", "value", ",", "$", "model", "->", "$", "key", ")", ")", "{", "return", "false", ";", "}", "else", "{", "$", "user_model", "=", "config", "(", "'kregel.warden.models.user.model'", ")", ";", "$", "user", "=", "new", "$", "user_model", "(", ")", ";", "if", "(", "empty", "(", "$", "user", "->", "hashable", ")", ")", "{", "$", "input", "[", "$", "key", "]", "=", "bcrypt", "(", "$", "value", ")", ";", "return", "true", ";", "}", "}", "}", "return", "true", ";", "}", ")", ";", "}" ]
This Checks for any values and the _token for csrf and removes it from any blank values and it also removes the _token from the input. If there is a password within the request it will compare it to the current hash. @param $input @param $model @return Collection
[ "This", "Checks", "for", "any", "values", "and", "the", "_token", "for", "csrf", "and", "removes", "it", "from", "any", "blank", "values", "and", "it", "also", "removes", "the", "_token", "from", "the", "input", ".", "If", "there", "is", "a", "password", "within", "the", "request", "it", "will", "compare", "it", "to", "the", "current", "hash", "." ]
6f5a98bd79a488f0f300f4851061ac6f7d19f8a3
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/ApiController.php#L248-L284
19,218
Chill-project/Main
Routing/MenuComposer.php
MenuComposer.resolveOrder
private function resolveOrder($routes, $order){ if (isset($routes[$order])) { return $this->resolveOrder($routes, $order + 1); } else { return $order; } }
php
private function resolveOrder($routes, $order){ if (isset($routes[$order])) { return $this->resolveOrder($routes, $order + 1); } else { return $order; } }
[ "private", "function", "resolveOrder", "(", "$", "routes", ",", "$", "order", ")", "{", "if", "(", "isset", "(", "$", "routes", "[", "$", "order", "]", ")", ")", "{", "return", "$", "this", "->", "resolveOrder", "(", "$", "routes", ",", "$", "order", "+", "1", ")", ";", "}", "else", "{", "return", "$", "order", ";", "}", "}" ]
recursive function to resolve the order of a array of routes. If the order chosen in routing.yml is already in used, find the first next order available. @param array $routes the routes previously added @param int $order @return int
[ "recursive", "function", "to", "resolve", "the", "order", "of", "a", "array", "of", "routes", ".", "If", "the", "order", "chosen", "in", "routing", ".", "yml", "is", "already", "in", "used", "find", "the", "first", "next", "order", "available", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Routing/MenuComposer.php#L95-L101
19,219
ondrakoupil/tools
src/Arrays.php
Arrays.normaliseValues
static public function normaliseValues($array) { $array=self::arrayize($array); if (!$array) return $array; $minValue=min($array); $maxValue=max($array); if ($maxValue==$minValue) { $minValue-=1; } foreach($array as $index=>$value) { $array[$index]=($value-$minValue)/($maxValue-$minValue); } return $array; }
php
static public function normaliseValues($array) { $array=self::arrayize($array); if (!$array) return $array; $minValue=min($array); $maxValue=max($array); if ($maxValue==$minValue) { $minValue-=1; } foreach($array as $index=>$value) { $array[$index]=($value-$minValue)/($maxValue-$minValue); } return $array; }
[ "static", "public", "function", "normaliseValues", "(", "$", "array", ")", "{", "$", "array", "=", "self", "::", "arrayize", "(", "$", "array", ")", ";", "if", "(", "!", "$", "array", ")", "return", "$", "array", ";", "$", "minValue", "=", "min", "(", "$", "array", ")", ";", "$", "maxValue", "=", "max", "(", "$", "array", ")", ";", "if", "(", "$", "maxValue", "==", "$", "minValue", ")", "{", "$", "minValue", "-=", "1", ";", "}", "foreach", "(", "$", "array", "as", "$", "index", "=>", "$", "value", ")", "{", "$", "array", "[", "$", "index", "]", "=", "(", "$", "value", "-", "$", "minValue", ")", "/", "(", "$", "maxValue", "-", "$", "minValue", ")", ";", "}", "return", "$", "array", ";", "}" ]
Normalizuje hodnoty v poli do rozsahu <0-1> @param array $array @return array
[ "Normalizuje", "hodnoty", "v", "poli", "do", "rozsahu", "&lt", ";", "0", "-", "1&gt", ";" ]
7ecbe3652e379802fbaabf4fe8f27b96dcbadb22
https://github.com/ondrakoupil/tools/blob/7ecbe3652e379802fbaabf4fe8f27b96dcbadb22/src/Arrays.php#L364-L376
19,220
lode/fem
src/login_password.php
login_password.get_by_email
public static function get_by_email($email_address) { $mysql = bootstrap::get_library('mysql'); $sql = "SELECT * FROM `login_passwords` WHERE `email_address` = '%s';"; $login = $mysql::select('row', $sql, $email_address); if (empty($login)) { return false; } return new static($login['id']); }
php
public static function get_by_email($email_address) { $mysql = bootstrap::get_library('mysql'); $sql = "SELECT * FROM `login_passwords` WHERE `email_address` = '%s';"; $login = $mysql::select('row', $sql, $email_address); if (empty($login)) { return false; } return new static($login['id']); }
[ "public", "static", "function", "get_by_email", "(", "$", "email_address", ")", "{", "$", "mysql", "=", "bootstrap", "::", "get_library", "(", "'mysql'", ")", ";", "$", "sql", "=", "\"SELECT * FROM `login_passwords` WHERE `email_address` = '%s';\"", ";", "$", "login", "=", "$", "mysql", "::", "select", "(", "'row'", ",", "$", "sql", ",", "$", "email_address", ")", ";", "if", "(", "empty", "(", "$", "login", ")", ")", "{", "return", "false", ";", "}", "return", "new", "static", "(", "$", "login", "[", "'id'", "]", ")", ";", "}" ]
checks whether the given email address match one on file @param string $email_address @return $this|boolean false when the email address is not found
[ "checks", "whether", "the", "given", "email", "address", "match", "one", "on", "file" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/login_password.php#L74-L84
19,221
lode/fem
src/login_password.php
login_password.is_valid
public function is_valid($password, $check_rehash=true) { if (password_verify($password, $this->data['hash']) == false) { return false; } if ($check_rehash && password_needs_rehash($this->data['hash'], PASSWORD_DEFAULT)) { $new_hash = self::hash_password($password); $this->set_new_hash($this->data['user_id'], $this->data['email_address'], $new_hash); } return true; }
php
public function is_valid($password, $check_rehash=true) { if (password_verify($password, $this->data['hash']) == false) { return false; } if ($check_rehash && password_needs_rehash($this->data['hash'], PASSWORD_DEFAULT)) { $new_hash = self::hash_password($password); $this->set_new_hash($this->data['user_id'], $this->data['email_address'], $new_hash); } return true; }
[ "public", "function", "is_valid", "(", "$", "password", ",", "$", "check_rehash", "=", "true", ")", "{", "if", "(", "password_verify", "(", "$", "password", ",", "$", "this", "->", "data", "[", "'hash'", "]", ")", "==", "false", ")", "{", "return", "false", ";", "}", "if", "(", "$", "check_rehash", "&&", "password_needs_rehash", "(", "$", "this", "->", "data", "[", "'hash'", "]", ",", "PASSWORD_DEFAULT", ")", ")", "{", "$", "new_hash", "=", "self", "::", "hash_password", "(", "$", "password", ")", ";", "$", "this", "->", "set_new_hash", "(", "$", "this", "->", "data", "[", "'user_id'", "]", ",", "$", "this", "->", "data", "[", "'email_address'", "]", ",", "$", "new_hash", ")", ";", "}", "return", "true", ";", "}" ]
check if the password gives access to the login also re-hashes the password hash if the algorithm is out of date @param string $password in plain text @param boolean $check_rehash set to false to skip re-hashing @return boolean
[ "check", "if", "the", "password", "gives", "access", "to", "the", "login", "also", "re", "-", "hashes", "the", "password", "hash", "if", "the", "algorithm", "is", "out", "of", "date" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/login_password.php#L94-L105
19,222
lode/fem
src/login_password.php
login_password.add
public function add($user_id, $email_address, $password) { $mysql = bootstrap::get_library('mysql'); $sql = "INSERT INTO `login_passwords` SET `user_id` = %d, `email_address` = '%s';"; $binds = [$user_id, $email_address]; $mysql::query($sql, $binds); $login = new static($mysql::$insert_id); $hash = self::hash_password($password); $login->set_new_hash($hash); }
php
public function add($user_id, $email_address, $password) { $mysql = bootstrap::get_library('mysql'); $sql = "INSERT INTO `login_passwords` SET `user_id` = %d, `email_address` = '%s';"; $binds = [$user_id, $email_address]; $mysql::query($sql, $binds); $login = new static($mysql::$insert_id); $hash = self::hash_password($password); $login->set_new_hash($hash); }
[ "public", "function", "add", "(", "$", "user_id", ",", "$", "email_address", ",", "$", "password", ")", "{", "$", "mysql", "=", "bootstrap", "::", "get_library", "(", "'mysql'", ")", ";", "$", "sql", "=", "\"INSERT INTO `login_passwords` SET `user_id` = %d, `email_address` = '%s';\"", ";", "$", "binds", "=", "[", "$", "user_id", ",", "$", "email_address", "]", ";", "$", "mysql", "::", "query", "(", "$", "sql", ",", "$", "binds", ")", ";", "$", "login", "=", "new", "static", "(", "$", "mysql", "::", "$", "insert_id", ")", ";", "$", "hash", "=", "self", "::", "hash_password", "(", "$", "password", ")", ";", "$", "login", "->", "set_new_hash", "(", "$", "hash", ")", ";", "}" ]
adds a login @param int $user_id @param string $email_address @param string $password in plain text
[ "adds", "a", "login" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/login_password.php#L123-L134
19,223
lode/fem
src/login_password.php
login_password.set_new_hash
public function set_new_hash($new_hash) { $mysql = bootstrap::get_library('mysql'); $sql = "UPDATE `login_passwords` SET `hash` = '%s' WHERE `id` = %d;"; $binds = [$new_hash, $this->data['id']]; $mysql::query($sql, $binds); $this->data['hash'] = $new_hash; }
php
public function set_new_hash($new_hash) { $mysql = bootstrap::get_library('mysql'); $sql = "UPDATE `login_passwords` SET `hash` = '%s' WHERE `id` = %d;"; $binds = [$new_hash, $this->data['id']]; $mysql::query($sql, $binds); $this->data['hash'] = $new_hash; }
[ "public", "function", "set_new_hash", "(", "$", "new_hash", ")", "{", "$", "mysql", "=", "bootstrap", "::", "get_library", "(", "'mysql'", ")", ";", "$", "sql", "=", "\"UPDATE `login_passwords` SET `hash` = '%s' WHERE `id` = %d;\"", ";", "$", "binds", "=", "[", "$", "new_hash", ",", "$", "this", "->", "data", "[", "'id'", "]", "]", ";", "$", "mysql", "::", "query", "(", "$", "sql", ",", "$", "binds", ")", ";", "$", "this", "->", "data", "[", "'hash'", "]", "=", "$", "new_hash", ";", "}" ]
stores a new hash for the current login @param string $new_hash @return void
[ "stores", "a", "new", "hash", "for", "the", "current", "login" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/login_password.php#L142-L150
19,224
lode/fem
src/login_password.php
login_password.hash_password
public static function hash_password($password) { $exception = bootstrap::get_library('exception'); if (mb_strlen($password) < self::MINIMUM_LENGTH) { throw new $exception('passwords need a minimum length of '.self::MINIMUM_LENGTH); } $hash = password_hash($password, PASSWORD_DEFAULT); if (empty($hash)) { throw new $exception('unable to hash password'); } return $hash; }
php
public static function hash_password($password) { $exception = bootstrap::get_library('exception'); if (mb_strlen($password) < self::MINIMUM_LENGTH) { throw new $exception('passwords need a minimum length of '.self::MINIMUM_LENGTH); } $hash = password_hash($password, PASSWORD_DEFAULT); if (empty($hash)) { throw new $exception('unable to hash password'); } return $hash; }
[ "public", "static", "function", "hash_password", "(", "$", "password", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "if", "(", "mb_strlen", "(", "$", "password", ")", "<", "self", "::", "MINIMUM_LENGTH", ")", "{", "throw", "new", "$", "exception", "(", "'passwords need a minimum length of '", ".", "self", "::", "MINIMUM_LENGTH", ")", ";", "}", "$", "hash", "=", "password_hash", "(", "$", "password", ",", "PASSWORD_DEFAULT", ")", ";", "if", "(", "empty", "(", "$", "hash", ")", ")", "{", "throw", "new", "$", "exception", "(", "'unable to hash password'", ")", ";", "}", "return", "$", "hash", ";", "}" ]
generates a new hash for the given password we wrap the native method to ensure a successful hash also enforces a minimum length for passwords @see ::MINIMUM_LENGTH @param string $password @return string
[ "generates", "a", "new", "hash", "for", "the", "given", "password", "we", "wrap", "the", "native", "method", "to", "ensure", "a", "successful", "hash" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/login_password.php#L162-L175
19,225
slashworks/control-bundle
src/Slashworks/BackendBundle/Controller/InstallController.php
InstallController.requirementsAction
public function requirementsAction() { // include symfony requirements class $sAppPath = $this->getParameter('kernel.root_dir'); require_once $sAppPath.'/SymfonyRequirements.php'; $symfonyRequirements = new \SymfonyRequirements(); // add additional requirement for mcrypt $symfonyRequirements->addRequirement(extension_loaded('mcrypt'), "Check if mcrypt ist loaded for RSA encryption", "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>"); // fetch all data $aRequirements = $symfonyRequirements->getRequirements(); $aRecommendations = $symfonyRequirements->getRecommendations(); $aFailedRequirements = $symfonyRequirements->getFailedRequirements(); $aFailedRecommendations = $symfonyRequirements->getFailedRecommendations(); $iniPath = $symfonyRequirements->getPhpIniConfigPath(); // render template return $this->render('SlashworksBackendBundle:Install:requirements.html.twig', array("iniPath" => $iniPath, "requirements" => $aRequirements, "recommendations" => $aRecommendations, "failedrequirements" => $aFailedRequirements, "failedrecommendations" => $aFailedRecommendations)); }
php
public function requirementsAction() { // include symfony requirements class $sAppPath = $this->getParameter('kernel.root_dir'); require_once $sAppPath.'/SymfonyRequirements.php'; $symfonyRequirements = new \SymfonyRequirements(); // add additional requirement for mcrypt $symfonyRequirements->addRequirement(extension_loaded('mcrypt'), "Check if mcrypt ist loaded for RSA encryption", "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>"); // fetch all data $aRequirements = $symfonyRequirements->getRequirements(); $aRecommendations = $symfonyRequirements->getRecommendations(); $aFailedRequirements = $symfonyRequirements->getFailedRequirements(); $aFailedRecommendations = $symfonyRequirements->getFailedRecommendations(); $iniPath = $symfonyRequirements->getPhpIniConfigPath(); // render template return $this->render('SlashworksBackendBundle:Install:requirements.html.twig', array("iniPath" => $iniPath, "requirements" => $aRequirements, "recommendations" => $aRecommendations, "failedrequirements" => $aFailedRequirements, "failedrecommendations" => $aFailedRecommendations)); }
[ "public", "function", "requirementsAction", "(", ")", "{", "// include symfony requirements class", "$", "sAppPath", "=", "$", "this", "->", "getParameter", "(", "'kernel.root_dir'", ")", ";", "require_once", "$", "sAppPath", ".", "'/SymfonyRequirements.php'", ";", "$", "symfonyRequirements", "=", "new", "\\", "SymfonyRequirements", "(", ")", ";", "// add additional requirement for mcrypt", "$", "symfonyRequirements", "->", "addRequirement", "(", "extension_loaded", "(", "'mcrypt'", ")", ",", "\"Check if mcrypt ist loaded for RSA encryption\"", ",", "\"Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>\"", ")", ";", "// fetch all data", "$", "aRequirements", "=", "$", "symfonyRequirements", "->", "getRequirements", "(", ")", ";", "$", "aRecommendations", "=", "$", "symfonyRequirements", "->", "getRecommendations", "(", ")", ";", "$", "aFailedRequirements", "=", "$", "symfonyRequirements", "->", "getFailedRequirements", "(", ")", ";", "$", "aFailedRecommendations", "=", "$", "symfonyRequirements", "->", "getFailedRecommendations", "(", ")", ";", "$", "iniPath", "=", "$", "symfonyRequirements", "->", "getPhpIniConfigPath", "(", ")", ";", "// render template", "return", "$", "this", "->", "render", "(", "'SlashworksBackendBundle:Install:requirements.html.twig'", ",", "array", "(", "\"iniPath\"", "=>", "$", "iniPath", ",", "\"requirements\"", "=>", "$", "aRequirements", ",", "\"recommendations\"", "=>", "$", "aRecommendations", ",", "\"failedrequirements\"", "=>", "$", "aFailedRequirements", ",", "\"failedrecommendations\"", "=>", "$", "aFailedRecommendations", ")", ")", ";", "}" ]
Check System Requirements @return \Symfony\Component\HttpFoundation\Response
[ "Check", "System", "Requirements" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Controller/InstallController.php#L43-L63
19,226
slashworks/control-bundle
src/Slashworks/BackendBundle/Controller/InstallController.php
InstallController.installAction
public function installAction() { // create install form $form = $this->createForm(new InstallType(), null, array('action' => $this->generateUrl('install_process'))); // redirect to login if config already filled if ($this->container->getParameter('database_password') !== null) { return $this->redirect($this->generateUrl('login')); } else { return $this->render('SlashworksBackendBundle:Install:install.html.twig', array("error" => false, "errorMessage" => false, "form" => $form->createView())); } }
php
public function installAction() { // create install form $form = $this->createForm(new InstallType(), null, array('action' => $this->generateUrl('install_process'))); // redirect to login if config already filled if ($this->container->getParameter('database_password') !== null) { return $this->redirect($this->generateUrl('login')); } else { return $this->render('SlashworksBackendBundle:Install:install.html.twig', array("error" => false, "errorMessage" => false, "form" => $form->createView())); } }
[ "public", "function", "installAction", "(", ")", "{", "// create install form", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "InstallType", "(", ")", ",", "null", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'install_process'", ")", ")", ")", ";", "// redirect to login if config already filled", "if", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'database_password'", ")", "!==", "null", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'login'", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "render", "(", "'SlashworksBackendBundle:Install:install.html.twig'", ",", "array", "(", "\"error\"", "=>", "false", ",", "\"errorMessage\"", "=>", "false", ",", "\"form\"", "=>", "$", "form", "->", "createView", "(", ")", ")", ")", ";", "}", "}" ]
Display install form @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
[ "Display", "install", "form" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Controller/InstallController.php#L96-L108
19,227
slashworks/control-bundle
src/Slashworks/BackendBundle/Controller/InstallController.php
InstallController.processInstallAction
public function processInstallAction(Request $request) { // include symfony requirements class $sAppPath = $this->getParameter('kernel.root_dir'); require_once $sAppPath.'/SymfonyRequirements.php'; // prevent from being called directly after install... if ($this->container->getParameter('database_password') !== null) { return $this->redirect($this->generateUrl('login')); } // get form type for validation $form = $this->createForm(new InstallType(), null, array('action' => $this->generateUrl('install_process'))); $form->handleRequest($request); if ($form->isValid()) { try { // get data and do install $aData = $request->request->all(); InstallHelper::doInstall($this->container, $aData); // goto login if successful return $this->redirect($this->generateUrl('login')); } catch (\Exception $e) { return $this->render('SlashworksBackendBundle:Install:install.html.twig', array("form" => $form->createView(), "error" => true, "errorMessage" => $e->getMessage())); } } else { return $this->render('SlashworksBackendBundle:Install:install.html.twig', array("form" => $form->createView(), "error" => true, "errorMessage" => false)); } }
php
public function processInstallAction(Request $request) { // include symfony requirements class $sAppPath = $this->getParameter('kernel.root_dir'); require_once $sAppPath.'/SymfonyRequirements.php'; // prevent from being called directly after install... if ($this->container->getParameter('database_password') !== null) { return $this->redirect($this->generateUrl('login')); } // get form type for validation $form = $this->createForm(new InstallType(), null, array('action' => $this->generateUrl('install_process'))); $form->handleRequest($request); if ($form->isValid()) { try { // get data and do install $aData = $request->request->all(); InstallHelper::doInstall($this->container, $aData); // goto login if successful return $this->redirect($this->generateUrl('login')); } catch (\Exception $e) { return $this->render('SlashworksBackendBundle:Install:install.html.twig', array("form" => $form->createView(), "error" => true, "errorMessage" => $e->getMessage())); } } else { return $this->render('SlashworksBackendBundle:Install:install.html.twig', array("form" => $form->createView(), "error" => true, "errorMessage" => false)); } }
[ "public", "function", "processInstallAction", "(", "Request", "$", "request", ")", "{", "// include symfony requirements class", "$", "sAppPath", "=", "$", "this", "->", "getParameter", "(", "'kernel.root_dir'", ")", ";", "require_once", "$", "sAppPath", ".", "'/SymfonyRequirements.php'", ";", "// prevent from being called directly after install...", "if", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'database_password'", ")", "!==", "null", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'login'", ")", ")", ";", "}", "// get form type for validation", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "InstallType", "(", ")", ",", "null", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'install_process'", ")", ")", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "try", "{", "// get data and do install", "$", "aData", "=", "$", "request", "->", "request", "->", "all", "(", ")", ";", "InstallHelper", "::", "doInstall", "(", "$", "this", "->", "container", ",", "$", "aData", ")", ";", "// goto login if successful", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'login'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "$", "this", "->", "render", "(", "'SlashworksBackendBundle:Install:install.html.twig'", ",", "array", "(", "\"form\"", "=>", "$", "form", "->", "createView", "(", ")", ",", "\"error\"", "=>", "true", ",", "\"errorMessage\"", "=>", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "}", "else", "{", "return", "$", "this", "->", "render", "(", "'SlashworksBackendBundle:Install:install.html.twig'", ",", "array", "(", "\"form\"", "=>", "$", "form", "->", "createView", "(", ")", ",", "\"error\"", "=>", "true", ",", "\"errorMessage\"", "=>", "false", ")", ")", ";", "}", "}" ]
Process provided informations and perform installation @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
[ "Process", "provided", "informations", "and", "perform", "installation" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Controller/InstallController.php#L118-L150
19,228
joomlatools/joomlatools-platform-legacy
code/request/request.php
JRequest.getVar
public static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0) { // Ensure hash and type are uppercase $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } $type = strtoupper($type); $sig = $hash . $type . $mask; // Get the input hash switch ($hash) { case 'GET': $input = &$_GET; break; case 'POST': $input = &$_POST; break; case 'FILES': $input = &$_FILES; break; case 'COOKIE': $input = &$_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = &$_REQUEST; $hash = 'REQUEST'; break; } if (isset($GLOBALS['_JREQUEST'][$name]['SET.' . $hash]) && ($GLOBALS['_JREQUEST'][$name]['SET.' . $hash] === true)) { // Get the variable from the input hash $var = (isset($input[$name]) && $input[$name] !== null) ? $input[$name] : $default; $var = self::_cleanVar($var, $mask, $type); } elseif (!isset($GLOBALS['_JREQUEST'][$name][$sig])) { if (isset($input[$name]) && $input[$name] !== null) { // Get the variable from the input hash and clean it $var = self::_cleanVar($input[$name], $mask, $type); $GLOBALS['_JREQUEST'][$name][$sig] = $var; } elseif ($default !== null) { // Clean the default value $var = self::_cleanVar($default, $mask, $type); } else { $var = $default; } } else { $var = $GLOBALS['_JREQUEST'][$name][$sig]; } return $var; }
php
public static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0) { // Ensure hash and type are uppercase $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } $type = strtoupper($type); $sig = $hash . $type . $mask; // Get the input hash switch ($hash) { case 'GET': $input = &$_GET; break; case 'POST': $input = &$_POST; break; case 'FILES': $input = &$_FILES; break; case 'COOKIE': $input = &$_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = &$_REQUEST; $hash = 'REQUEST'; break; } if (isset($GLOBALS['_JREQUEST'][$name]['SET.' . $hash]) && ($GLOBALS['_JREQUEST'][$name]['SET.' . $hash] === true)) { // Get the variable from the input hash $var = (isset($input[$name]) && $input[$name] !== null) ? $input[$name] : $default; $var = self::_cleanVar($var, $mask, $type); } elseif (!isset($GLOBALS['_JREQUEST'][$name][$sig])) { if (isset($input[$name]) && $input[$name] !== null) { // Get the variable from the input hash and clean it $var = self::_cleanVar($input[$name], $mask, $type); $GLOBALS['_JREQUEST'][$name][$sig] = $var; } elseif ($default !== null) { // Clean the default value $var = self::_cleanVar($default, $mask, $type); } else { $var = $default; } } else { $var = $GLOBALS['_JREQUEST'][$name][$sig]; } return $var; }
[ "public", "static", "function", "getVar", "(", "$", "name", ",", "$", "default", "=", "null", ",", "$", "hash", "=", "'default'", ",", "$", "type", "=", "'none'", ",", "$", "mask", "=", "0", ")", "{", "// Ensure hash and type are uppercase", "$", "hash", "=", "strtoupper", "(", "$", "hash", ")", ";", "if", "(", "$", "hash", "===", "'METHOD'", ")", "{", "$", "hash", "=", "strtoupper", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ")", ";", "}", "$", "type", "=", "strtoupper", "(", "$", "type", ")", ";", "$", "sig", "=", "$", "hash", ".", "$", "type", ".", "$", "mask", ";", "// Get the input hash", "switch", "(", "$", "hash", ")", "{", "case", "'GET'", ":", "$", "input", "=", "&", "$", "_GET", ";", "break", ";", "case", "'POST'", ":", "$", "input", "=", "&", "$", "_POST", ";", "break", ";", "case", "'FILES'", ":", "$", "input", "=", "&", "$", "_FILES", ";", "break", ";", "case", "'COOKIE'", ":", "$", "input", "=", "&", "$", "_COOKIE", ";", "break", ";", "case", "'ENV'", ":", "$", "input", "=", "&", "$", "_ENV", ";", "break", ";", "case", "'SERVER'", ":", "$", "input", "=", "&", "$", "_SERVER", ";", "break", ";", "default", ":", "$", "input", "=", "&", "$", "_REQUEST", ";", "$", "hash", "=", "'REQUEST'", ";", "break", ";", "}", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'_JREQUEST'", "]", "[", "$", "name", "]", "[", "'SET.'", ".", "$", "hash", "]", ")", "&&", "(", "$", "GLOBALS", "[", "'_JREQUEST'", "]", "[", "$", "name", "]", "[", "'SET.'", ".", "$", "hash", "]", "===", "true", ")", ")", "{", "// Get the variable from the input hash", "$", "var", "=", "(", "isset", "(", "$", "input", "[", "$", "name", "]", ")", "&&", "$", "input", "[", "$", "name", "]", "!==", "null", ")", "?", "$", "input", "[", "$", "name", "]", ":", "$", "default", ";", "$", "var", "=", "self", "::", "_cleanVar", "(", "$", "var", ",", "$", "mask", ",", "$", "type", ")", ";", "}", "elseif", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'_JREQUEST'", "]", "[", "$", "name", "]", "[", "$", "sig", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "input", "[", "$", "name", "]", ")", "&&", "$", "input", "[", "$", "name", "]", "!==", "null", ")", "{", "// Get the variable from the input hash and clean it", "$", "var", "=", "self", "::", "_cleanVar", "(", "$", "input", "[", "$", "name", "]", ",", "$", "mask", ",", "$", "type", ")", ";", "$", "GLOBALS", "[", "'_JREQUEST'", "]", "[", "$", "name", "]", "[", "$", "sig", "]", "=", "$", "var", ";", "}", "elseif", "(", "$", "default", "!==", "null", ")", "{", "// Clean the default value", "$", "var", "=", "self", "::", "_cleanVar", "(", "$", "default", ",", "$", "mask", ",", "$", "type", ")", ";", "}", "else", "{", "$", "var", "=", "$", "default", ";", "}", "}", "else", "{", "$", "var", "=", "$", "GLOBALS", "[", "'_JREQUEST'", "]", "[", "$", "name", "]", "[", "$", "sig", "]", ";", "}", "return", "$", "var", ";", "}" ]
Fetches and returns a given variable. The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning an entry from $_GET, POST and PUT will result in returning an entry from $_POST. You can force the source by setting the $hash parameter: post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST @param string $name Variable name. @param string $default Default value if the variable does not exist. @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). @param string $type Return type for the variable, for valid values see {@link JFilterInput::clean()}. @param integer $mask Filter mask for the variable. @return mixed Requested variable. @since 11.1 @deprecated 12.1 Use JInput::Get
[ "Fetches", "and", "returns", "a", "given", "variable", "." ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/request/request.php#L101-L172
19,229
joomlatools/joomlatools-platform-legacy
code/request/request.php
JRequest.get
public static function get($hash = 'default', $mask = 0) { $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } switch ($hash) { case 'GET': $input = $_GET; break; case 'POST': $input = $_POST; break; case 'FILES': $input = $_FILES; break; case 'COOKIE': $input = $_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = $_REQUEST; break; } $result = self::_cleanVar($input, $mask); return $result; }
php
public static function get($hash = 'default', $mask = 0) { $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } switch ($hash) { case 'GET': $input = $_GET; break; case 'POST': $input = $_POST; break; case 'FILES': $input = $_FILES; break; case 'COOKIE': $input = $_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = $_REQUEST; break; } $result = self::_cleanVar($input, $mask); return $result; }
[ "public", "static", "function", "get", "(", "$", "hash", "=", "'default'", ",", "$", "mask", "=", "0", ")", "{", "$", "hash", "=", "strtoupper", "(", "$", "hash", ")", ";", "if", "(", "$", "hash", "===", "'METHOD'", ")", "{", "$", "hash", "=", "strtoupper", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ")", ";", "}", "switch", "(", "$", "hash", ")", "{", "case", "'GET'", ":", "$", "input", "=", "$", "_GET", ";", "break", ";", "case", "'POST'", ":", "$", "input", "=", "$", "_POST", ";", "break", ";", "case", "'FILES'", ":", "$", "input", "=", "$", "_FILES", ";", "break", ";", "case", "'COOKIE'", ":", "$", "input", "=", "$", "_COOKIE", ";", "break", ";", "case", "'ENV'", ":", "$", "input", "=", "&", "$", "_ENV", ";", "break", ";", "case", "'SERVER'", ":", "$", "input", "=", "&", "$", "_SERVER", ";", "break", ";", "default", ":", "$", "input", "=", "$", "_REQUEST", ";", "break", ";", "}", "$", "result", "=", "self", "::", "_cleanVar", "(", "$", "input", ",", "$", "mask", ")", ";", "return", "$", "result", ";", "}" ]
Fetches and returns a request array. The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning $_GET, POST and PUT will result in returning $_POST. You can force the source by setting the $hash parameter: post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST @param string $hash to get (POST, GET, FILES, METHOD). @param integer $mask Filter mask for the variable. @return mixed Request hash. @deprecated 12.1 User JInput::get @see JInput @since 11.1
[ "Fetches", "and", "returns", "a", "request", "array", "." ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/request/request.php#L423-L466
19,230
joomlatools/joomlatools-platform-legacy
code/request/request.php
JRequest.set
public static function set($array, $hash = 'default', $overwrite = true) { foreach ($array as $key => $value) { self::setVar($key, $value, $hash, $overwrite); } }
php
public static function set($array, $hash = 'default', $overwrite = true) { foreach ($array as $key => $value) { self::setVar($key, $value, $hash, $overwrite); } }
[ "public", "static", "function", "set", "(", "$", "array", ",", "$", "hash", "=", "'default'", ",", "$", "overwrite", "=", "true", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "self", "::", "setVar", "(", "$", "key", ",", "$", "value", ",", "$", "hash", ",", "$", "overwrite", ")", ";", "}", "}" ]
Sets a request variable. @param array $array An associative array of key-value pairs. @param string $hash The request variable to set (POST, GET, FILES, METHOD). @param boolean $overwrite If true and an existing key is found, the value is overwritten, otherwise it is ignored. @return void @deprecated 12.1 Use JInput::set() @see JInput::set() @since 11.1
[ "Sets", "a", "request", "variable", "." ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/request/request.php#L481-L487
19,231
joomlatools/joomlatools-platform-legacy
code/request/request.php
JRequest._cleanVar
protected static function _cleanVar($var, $mask = 0, $type = null) { // If the no trim flag is not set, trim the variable if (!($mask & 1) && is_string($var)) { $var = trim($var); } // Now we handle input filtering if ($mask & 2) { // If the allow raw flag is set, do not modify the variable $var = $var; } elseif ($mask & 4) { // If the allow HTML flag is set, apply a safe HTML filter to the variable $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); $var = $safeHtmlFilter->clean($var, $type); } else { // Since no allow flags were set, we will apply the most strict filter to the variable // $tags, $attr, $tag_method, $attr_method, $xss_auto use defaults. $noHtmlFilter = JFilterInput::getInstance(); $var = $noHtmlFilter->clean($var, $type); } return $var; }
php
protected static function _cleanVar($var, $mask = 0, $type = null) { // If the no trim flag is not set, trim the variable if (!($mask & 1) && is_string($var)) { $var = trim($var); } // Now we handle input filtering if ($mask & 2) { // If the allow raw flag is set, do not modify the variable $var = $var; } elseif ($mask & 4) { // If the allow HTML flag is set, apply a safe HTML filter to the variable $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); $var = $safeHtmlFilter->clean($var, $type); } else { // Since no allow flags were set, we will apply the most strict filter to the variable // $tags, $attr, $tag_method, $attr_method, $xss_auto use defaults. $noHtmlFilter = JFilterInput::getInstance(); $var = $noHtmlFilter->clean($var, $type); } return $var; }
[ "protected", "static", "function", "_cleanVar", "(", "$", "var", ",", "$", "mask", "=", "0", ",", "$", "type", "=", "null", ")", "{", "// If the no trim flag is not set, trim the variable", "if", "(", "!", "(", "$", "mask", "&", "1", ")", "&&", "is_string", "(", "$", "var", ")", ")", "{", "$", "var", "=", "trim", "(", "$", "var", ")", ";", "}", "// Now we handle input filtering", "if", "(", "$", "mask", "&", "2", ")", "{", "// If the allow raw flag is set, do not modify the variable", "$", "var", "=", "$", "var", ";", "}", "elseif", "(", "$", "mask", "&", "4", ")", "{", "// If the allow HTML flag is set, apply a safe HTML filter to the variable", "$", "safeHtmlFilter", "=", "JFilterInput", "::", "getInstance", "(", "null", ",", "null", ",", "1", ",", "1", ")", ";", "$", "var", "=", "$", "safeHtmlFilter", "->", "clean", "(", "$", "var", ",", "$", "type", ")", ";", "}", "else", "{", "// Since no allow flags were set, we will apply the most strict filter to the variable", "// $tags, $attr, $tag_method, $attr_method, $xss_auto use defaults.", "$", "noHtmlFilter", "=", "JFilterInput", "::", "getInstance", "(", ")", ";", "$", "var", "=", "$", "noHtmlFilter", "->", "clean", "(", "$", "var", ",", "$", "type", ")", ";", "}", "return", "$", "var", ";", "}" ]
Clean up an input variable. @param mixed $var The input variable. @param integer $mask Filter bit mask. 1 = no trim: If this flag is cleared and the input is a string, the string will have leading and trailing whitespace trimmed. 2 = allow_raw: If set, no more filtering is performed, higher bits are ignored. 4 = allow_html: HTML is allowed, but passed through a safe HTML filter first. If set, no more filtering is performed. If no bits other than the 1 bit is set, a strict filter is applied. @param string $type The variable type {@see JFilterInput::clean()}. @return mixed Same as $var @deprecated 12.1 @since 11.1
[ "Clean", "up", "an", "input", "variable", "." ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/request/request.php#L528-L557
19,232
webforge-labs/psc-cms
lib/Psc/UI/Component/SingleImage.php
SingleImage.dpi
public function dpi(EntityMeta $entityMeta, DCPackage $dc) { $this->entityMeta = $entityMeta; $this->dc = $dc; return $this; }
php
public function dpi(EntityMeta $entityMeta, DCPackage $dc) { $this->entityMeta = $entityMeta; $this->dc = $dc; return $this; }
[ "public", "function", "dpi", "(", "EntityMeta", "$", "entityMeta", ",", "DCPackage", "$", "dc", ")", "{", "$", "this", "->", "entityMeta", "=", "$", "entityMeta", ";", "$", "this", "->", "dc", "=", "$", "dc", ";", "return", "$", "this", ";", "}" ]
EntityMeta der Bild-Klasse
[ "EntityMeta", "der", "Bild", "-", "Klasse" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/Component/SingleImage.php#L33-L37
19,233
netgen/ngopengraph
autoloads/opengraphoperator.php
OpenGraphOperator.modify
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters ) { switch ( $operatorName ) { case 'opengraph': { $operatorValue = $this->generateOpenGraphTags( $namedParameters['nodeid'] ); break; } case 'language_code': { $operatorValue = eZLocale::instance()->httpLocaleCode(); break; } } }
php
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters ) { switch ( $operatorName ) { case 'opengraph': { $operatorValue = $this->generateOpenGraphTags( $namedParameters['nodeid'] ); break; } case 'language_code': { $operatorValue = eZLocale::instance()->httpLocaleCode(); break; } } }
[ "function", "modify", "(", "&", "$", "tpl", ",", "&", "$", "operatorName", ",", "&", "$", "operatorParameters", ",", "&", "$", "rootNamespace", ",", "&", "$", "currentNamespace", ",", "&", "$", "operatorValue", ",", "&", "$", "namedParameters", ")", "{", "switch", "(", "$", "operatorName", ")", "{", "case", "'opengraph'", ":", "{", "$", "operatorValue", "=", "$", "this", "->", "generateOpenGraphTags", "(", "$", "namedParameters", "[", "'nodeid'", "]", ")", ";", "break", ";", "}", "case", "'language_code'", ":", "{", "$", "operatorValue", "=", "eZLocale", "::", "instance", "(", ")", "->", "httpLocaleCode", "(", ")", ";", "break", ";", "}", "}", "}" ]
Executes the operators @param eZTemplate $tpl @param string $operatorName @param array $operatorParameters @param string $rootNamespace @param string $currentNamespace @param mixed $operatorValue @param array $namedParameters
[ "Executes", "the", "operators" ]
68a99862f240ee74174ea9b888a9a33743142e27
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/autoloads/opengraphoperator.php#L78-L94
19,234
netgen/ngopengraph
autoloads/opengraphoperator.php
OpenGraphOperator.generateOpenGraphTags
function generateOpenGraphTags( $nodeID ) { $this->ogIni = eZINI::instance( 'ngopengraph.ini' ); $this->facebookCompatible = $this->ogIni->variable( 'General', 'FacebookCompatible' ); $this->debug = $this->ogIni->variable( 'General', 'Debug' ) == 'enabled'; $availableClasses = $this->ogIni->variable( 'General', 'Classes' ); if ( $nodeID instanceof eZContentObjectTreeNode ) { $contentNode = $nodeID; } else { $contentNode = eZContentObjectTreeNode::fetch( $nodeID ); if ( !$contentNode instanceof eZContentObjectTreeNode ) { return array(); } } $contentObject = $contentNode->object(); if ( !$contentObject instanceof eZContentObject || !in_array( $contentObject->contentClassIdentifier(), $availableClasses ) ) { return array(); } $returnArray = $this->processGenericData( $contentNode ); $returnArray = $this->processObject( $contentObject, $returnArray ); if ( $this->checkRequirements( $returnArray ) ) { return $returnArray; } else { if ( $this->debug ) { eZDebug::writeDebug( 'No', 'Facebook Compatible?' ); } return array(); } }
php
function generateOpenGraphTags( $nodeID ) { $this->ogIni = eZINI::instance( 'ngopengraph.ini' ); $this->facebookCompatible = $this->ogIni->variable( 'General', 'FacebookCompatible' ); $this->debug = $this->ogIni->variable( 'General', 'Debug' ) == 'enabled'; $availableClasses = $this->ogIni->variable( 'General', 'Classes' ); if ( $nodeID instanceof eZContentObjectTreeNode ) { $contentNode = $nodeID; } else { $contentNode = eZContentObjectTreeNode::fetch( $nodeID ); if ( !$contentNode instanceof eZContentObjectTreeNode ) { return array(); } } $contentObject = $contentNode->object(); if ( !$contentObject instanceof eZContentObject || !in_array( $contentObject->contentClassIdentifier(), $availableClasses ) ) { return array(); } $returnArray = $this->processGenericData( $contentNode ); $returnArray = $this->processObject( $contentObject, $returnArray ); if ( $this->checkRequirements( $returnArray ) ) { return $returnArray; } else { if ( $this->debug ) { eZDebug::writeDebug( 'No', 'Facebook Compatible?' ); } return array(); } }
[ "function", "generateOpenGraphTags", "(", "$", "nodeID", ")", "{", "$", "this", "->", "ogIni", "=", "eZINI", "::", "instance", "(", "'ngopengraph.ini'", ")", ";", "$", "this", "->", "facebookCompatible", "=", "$", "this", "->", "ogIni", "->", "variable", "(", "'General'", ",", "'FacebookCompatible'", ")", ";", "$", "this", "->", "debug", "=", "$", "this", "->", "ogIni", "->", "variable", "(", "'General'", ",", "'Debug'", ")", "==", "'enabled'", ";", "$", "availableClasses", "=", "$", "this", "->", "ogIni", "->", "variable", "(", "'General'", ",", "'Classes'", ")", ";", "if", "(", "$", "nodeID", "instanceof", "eZContentObjectTreeNode", ")", "{", "$", "contentNode", "=", "$", "nodeID", ";", "}", "else", "{", "$", "contentNode", "=", "eZContentObjectTreeNode", "::", "fetch", "(", "$", "nodeID", ")", ";", "if", "(", "!", "$", "contentNode", "instanceof", "eZContentObjectTreeNode", ")", "{", "return", "array", "(", ")", ";", "}", "}", "$", "contentObject", "=", "$", "contentNode", "->", "object", "(", ")", ";", "if", "(", "!", "$", "contentObject", "instanceof", "eZContentObject", "||", "!", "in_array", "(", "$", "contentObject", "->", "contentClassIdentifier", "(", ")", ",", "$", "availableClasses", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "returnArray", "=", "$", "this", "->", "processGenericData", "(", "$", "contentNode", ")", ";", "$", "returnArray", "=", "$", "this", "->", "processObject", "(", "$", "contentObject", ",", "$", "returnArray", ")", ";", "if", "(", "$", "this", "->", "checkRequirements", "(", "$", "returnArray", ")", ")", "{", "return", "$", "returnArray", ";", "}", "else", "{", "if", "(", "$", "this", "->", "debug", ")", "{", "eZDebug", "::", "writeDebug", "(", "'No'", ",", "'Facebook Compatible?'", ")", ";", "}", "return", "array", "(", ")", ";", "}", "}" ]
Executes opengraph operator @param int|eZContentObjectTreeNode $nodeID @return array
[ "Executes", "opengraph", "operator" ]
68a99862f240ee74174ea9b888a9a33743142e27
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/autoloads/opengraphoperator.php#L103-L148
19,235
netgen/ngopengraph
autoloads/opengraphoperator.php
OpenGraphOperator.processGenericData
function processGenericData( $contentNode ) { $returnArray = array(); $siteName = trim( eZINI::instance()->variable( 'SiteSettings', 'SiteName' ) ); if ( !empty( $siteName ) ) { $returnArray['og:site_name'] = $siteName; } $urlAlias = $contentNode->urlAlias(); eZURI::transformURI( $urlAlias, false, 'full' ); $returnArray['og:url'] = $urlAlias; if ( $this->facebookCompatible == 'true' ) { $appID = trim( $this->ogIni->variable( 'GenericData', 'app_id' ) ); if ( !empty( $appID ) ) { $returnArray['fb:app_id'] = $appID; } $defaultAdmin = trim( $this->ogIni->variable( 'GenericData', 'default_admin' ) ); $data = ''; if ( !empty( $defaultAdmin ) ) { $data = $defaultAdmin; $admins = $this->ogIni->variable( 'GenericData', 'admins' ); if ( !empty( $admins ) ) { $admins = trim( implode( ',', $admins ) ); $data = $data . ',' . $admins; } } if ( !empty( $data ) ) { $returnArray['fb:admins'] = $data; } } return $returnArray; }
php
function processGenericData( $contentNode ) { $returnArray = array(); $siteName = trim( eZINI::instance()->variable( 'SiteSettings', 'SiteName' ) ); if ( !empty( $siteName ) ) { $returnArray['og:site_name'] = $siteName; } $urlAlias = $contentNode->urlAlias(); eZURI::transformURI( $urlAlias, false, 'full' ); $returnArray['og:url'] = $urlAlias; if ( $this->facebookCompatible == 'true' ) { $appID = trim( $this->ogIni->variable( 'GenericData', 'app_id' ) ); if ( !empty( $appID ) ) { $returnArray['fb:app_id'] = $appID; } $defaultAdmin = trim( $this->ogIni->variable( 'GenericData', 'default_admin' ) ); $data = ''; if ( !empty( $defaultAdmin ) ) { $data = $defaultAdmin; $admins = $this->ogIni->variable( 'GenericData', 'admins' ); if ( !empty( $admins ) ) { $admins = trim( implode( ',', $admins ) ); $data = $data . ',' . $admins; } } if ( !empty( $data ) ) { $returnArray['fb:admins'] = $data; } } return $returnArray; }
[ "function", "processGenericData", "(", "$", "contentNode", ")", "{", "$", "returnArray", "=", "array", "(", ")", ";", "$", "siteName", "=", "trim", "(", "eZINI", "::", "instance", "(", ")", "->", "variable", "(", "'SiteSettings'", ",", "'SiteName'", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "siteName", ")", ")", "{", "$", "returnArray", "[", "'og:site_name'", "]", "=", "$", "siteName", ";", "}", "$", "urlAlias", "=", "$", "contentNode", "->", "urlAlias", "(", ")", ";", "eZURI", "::", "transformURI", "(", "$", "urlAlias", ",", "false", ",", "'full'", ")", ";", "$", "returnArray", "[", "'og:url'", "]", "=", "$", "urlAlias", ";", "if", "(", "$", "this", "->", "facebookCompatible", "==", "'true'", ")", "{", "$", "appID", "=", "trim", "(", "$", "this", "->", "ogIni", "->", "variable", "(", "'GenericData'", ",", "'app_id'", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "appID", ")", ")", "{", "$", "returnArray", "[", "'fb:app_id'", "]", "=", "$", "appID", ";", "}", "$", "defaultAdmin", "=", "trim", "(", "$", "this", "->", "ogIni", "->", "variable", "(", "'GenericData'", ",", "'default_admin'", ")", ")", ";", "$", "data", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "defaultAdmin", ")", ")", "{", "$", "data", "=", "$", "defaultAdmin", ";", "$", "admins", "=", "$", "this", "->", "ogIni", "->", "variable", "(", "'GenericData'", ",", "'admins'", ")", ";", "if", "(", "!", "empty", "(", "$", "admins", ")", ")", "{", "$", "admins", "=", "trim", "(", "implode", "(", "','", ",", "$", "admins", ")", ")", ";", "$", "data", "=", "$", "data", ".", "','", ".", "$", "admins", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "returnArray", "[", "'fb:admins'", "]", "=", "$", "data", ";", "}", "}", "return", "$", "returnArray", ";", "}" ]
Processes literal Open Graph metadata @param eZContentObjectTreeNode $contentNode @return array
[ "Processes", "literal", "Open", "Graph", "metadata" ]
68a99862f240ee74174ea9b888a9a33743142e27
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/autoloads/opengraphoperator.php#L157-L201
19,236
netgen/ngopengraph
autoloads/opengraphoperator.php
OpenGraphOperator.processObject
function processObject( $contentObject, $returnArray ) { if ( $this->ogIni->hasVariable( $contentObject->contentClassIdentifier(), 'LiteralMap' ) ) { $literalValues = $this->ogIni->variable( $contentObject->contentClassIdentifier(), 'LiteralMap' ); if ( $this->debug ) { eZDebug::writeDebug( $literalValues, 'LiteralMap' ); } if ( $literalValues ) { foreach ( $literalValues as $key => $value ) { if ( !empty( $value ) ) { $returnArray[$key] = $value; } } } } if ( $this->ogIni->hasVariable( $contentObject->contentClassIdentifier(), 'AttributeMap' ) ) { $attributeValues = $this->ogIni->variableArray( $contentObject->contentClassIdentifier(), 'AttributeMap' ); if ( $this->debug ) { eZDebug::writeDebug( $attributeValues, 'AttributeMap' ); } if ( $attributeValues ) { foreach ( $attributeValues as $key => $value ) { $contentObjectAttributeArray = $contentObject->fetchAttributesByIdentifier( array( $value[0] ) ); if ( !is_array( $contentObjectAttributeArray ) ) { continue; } $contentObjectAttributeArray = array_values( $contentObjectAttributeArray ); $contentObjectAttribute = $contentObjectAttributeArray[0]; if ( $contentObjectAttribute instanceof eZContentObjectAttribute ) { $openGraphHandler = ngOpenGraphBase::getInstance( $contentObjectAttribute ); if ( count( $value ) == 1 ) { $data = $openGraphHandler->getData(); } else if ( count( $value ) == 2 ) { $data = $openGraphHandler->getDataMember( $value[1] ); } else { $data = ""; } if ( !empty( $data ) ) { $returnArray[$key] = $data; } } } } } return $returnArray; }
php
function processObject( $contentObject, $returnArray ) { if ( $this->ogIni->hasVariable( $contentObject->contentClassIdentifier(), 'LiteralMap' ) ) { $literalValues = $this->ogIni->variable( $contentObject->contentClassIdentifier(), 'LiteralMap' ); if ( $this->debug ) { eZDebug::writeDebug( $literalValues, 'LiteralMap' ); } if ( $literalValues ) { foreach ( $literalValues as $key => $value ) { if ( !empty( $value ) ) { $returnArray[$key] = $value; } } } } if ( $this->ogIni->hasVariable( $contentObject->contentClassIdentifier(), 'AttributeMap' ) ) { $attributeValues = $this->ogIni->variableArray( $contentObject->contentClassIdentifier(), 'AttributeMap' ); if ( $this->debug ) { eZDebug::writeDebug( $attributeValues, 'AttributeMap' ); } if ( $attributeValues ) { foreach ( $attributeValues as $key => $value ) { $contentObjectAttributeArray = $contentObject->fetchAttributesByIdentifier( array( $value[0] ) ); if ( !is_array( $contentObjectAttributeArray ) ) { continue; } $contentObjectAttributeArray = array_values( $contentObjectAttributeArray ); $contentObjectAttribute = $contentObjectAttributeArray[0]; if ( $contentObjectAttribute instanceof eZContentObjectAttribute ) { $openGraphHandler = ngOpenGraphBase::getInstance( $contentObjectAttribute ); if ( count( $value ) == 1 ) { $data = $openGraphHandler->getData(); } else if ( count( $value ) == 2 ) { $data = $openGraphHandler->getDataMember( $value[1] ); } else { $data = ""; } if ( !empty( $data ) ) { $returnArray[$key] = $data; } } } } } return $returnArray; }
[ "function", "processObject", "(", "$", "contentObject", ",", "$", "returnArray", ")", "{", "if", "(", "$", "this", "->", "ogIni", "->", "hasVariable", "(", "$", "contentObject", "->", "contentClassIdentifier", "(", ")", ",", "'LiteralMap'", ")", ")", "{", "$", "literalValues", "=", "$", "this", "->", "ogIni", "->", "variable", "(", "$", "contentObject", "->", "contentClassIdentifier", "(", ")", ",", "'LiteralMap'", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "eZDebug", "::", "writeDebug", "(", "$", "literalValues", ",", "'LiteralMap'", ")", ";", "}", "if", "(", "$", "literalValues", ")", "{", "foreach", "(", "$", "literalValues", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "returnArray", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "}", "if", "(", "$", "this", "->", "ogIni", "->", "hasVariable", "(", "$", "contentObject", "->", "contentClassIdentifier", "(", ")", ",", "'AttributeMap'", ")", ")", "{", "$", "attributeValues", "=", "$", "this", "->", "ogIni", "->", "variableArray", "(", "$", "contentObject", "->", "contentClassIdentifier", "(", ")", ",", "'AttributeMap'", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "eZDebug", "::", "writeDebug", "(", "$", "attributeValues", ",", "'AttributeMap'", ")", ";", "}", "if", "(", "$", "attributeValues", ")", "{", "foreach", "(", "$", "attributeValues", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "contentObjectAttributeArray", "=", "$", "contentObject", "->", "fetchAttributesByIdentifier", "(", "array", "(", "$", "value", "[", "0", "]", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", "contentObjectAttributeArray", ")", ")", "{", "continue", ";", "}", "$", "contentObjectAttributeArray", "=", "array_values", "(", "$", "contentObjectAttributeArray", ")", ";", "$", "contentObjectAttribute", "=", "$", "contentObjectAttributeArray", "[", "0", "]", ";", "if", "(", "$", "contentObjectAttribute", "instanceof", "eZContentObjectAttribute", ")", "{", "$", "openGraphHandler", "=", "ngOpenGraphBase", "::", "getInstance", "(", "$", "contentObjectAttribute", ")", ";", "if", "(", "count", "(", "$", "value", ")", "==", "1", ")", "{", "$", "data", "=", "$", "openGraphHandler", "->", "getData", "(", ")", ";", "}", "else", "if", "(", "count", "(", "$", "value", ")", "==", "2", ")", "{", "$", "data", "=", "$", "openGraphHandler", "->", "getDataMember", "(", "$", "value", "[", "1", "]", ")", ";", "}", "else", "{", "$", "data", "=", "\"\"", ";", "}", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "returnArray", "[", "$", "key", "]", "=", "$", "data", ";", "}", "}", "}", "}", "}", "return", "$", "returnArray", ";", "}" ]
Processes Open Graph metadata from object attributes @param eZContentObject $contentObject @param array $returnArray @return array
[ "Processes", "Open", "Graph", "metadata", "from", "object", "attributes" ]
68a99862f240ee74174ea9b888a9a33743142e27
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/autoloads/opengraphoperator.php#L211-L281
19,237
netgen/ngopengraph
autoloads/opengraphoperator.php
OpenGraphOperator.checkRequirements
function checkRequirements( $returnArray ) { $arrayKeys = array_keys( $returnArray ); if ( !in_array( 'og:title', $arrayKeys ) || !in_array( 'og:type', $arrayKeys ) || !in_array( 'og:image', $arrayKeys ) || !in_array( 'og:url', $arrayKeys ) ) { if ( $this->debug ) { eZDebug::writeError( $arrayKeys, 'Missing an OG required field: title, image, type, or url' ); } return false; } if ( $this->facebookCompatible == 'true' ) { if ( !in_array( 'og:site_name', $arrayKeys ) || ( !in_array( 'fb:app_id', $arrayKeys ) && !in_array( 'fb:admins', $arrayKeys ) ) ) { if ( $this->debug ) { eZDebug::writeError( $arrayKeys, 'Missing a FB required field (in ngopengraph.ini): app_id, DefaultAdmin, or site name (site.ini)' ); } return false; } } return true; }
php
function checkRequirements( $returnArray ) { $arrayKeys = array_keys( $returnArray ); if ( !in_array( 'og:title', $arrayKeys ) || !in_array( 'og:type', $arrayKeys ) || !in_array( 'og:image', $arrayKeys ) || !in_array( 'og:url', $arrayKeys ) ) { if ( $this->debug ) { eZDebug::writeError( $arrayKeys, 'Missing an OG required field: title, image, type, or url' ); } return false; } if ( $this->facebookCompatible == 'true' ) { if ( !in_array( 'og:site_name', $arrayKeys ) || ( !in_array( 'fb:app_id', $arrayKeys ) && !in_array( 'fb:admins', $arrayKeys ) ) ) { if ( $this->debug ) { eZDebug::writeError( $arrayKeys, 'Missing a FB required field (in ngopengraph.ini): app_id, DefaultAdmin, or site name (site.ini)' ); } return false; } } return true; }
[ "function", "checkRequirements", "(", "$", "returnArray", ")", "{", "$", "arrayKeys", "=", "array_keys", "(", "$", "returnArray", ")", ";", "if", "(", "!", "in_array", "(", "'og:title'", ",", "$", "arrayKeys", ")", "||", "!", "in_array", "(", "'og:type'", ",", "$", "arrayKeys", ")", "||", "!", "in_array", "(", "'og:image'", ",", "$", "arrayKeys", ")", "||", "!", "in_array", "(", "'og:url'", ",", "$", "arrayKeys", ")", ")", "{", "if", "(", "$", "this", "->", "debug", ")", "{", "eZDebug", "::", "writeError", "(", "$", "arrayKeys", ",", "'Missing an OG required field: title, image, type, or url'", ")", ";", "}", "return", "false", ";", "}", "if", "(", "$", "this", "->", "facebookCompatible", "==", "'true'", ")", "{", "if", "(", "!", "in_array", "(", "'og:site_name'", ",", "$", "arrayKeys", ")", "||", "(", "!", "in_array", "(", "'fb:app_id'", ",", "$", "arrayKeys", ")", "&&", "!", "in_array", "(", "'fb:admins'", ",", "$", "arrayKeys", ")", ")", ")", "{", "if", "(", "$", "this", "->", "debug", ")", "{", "eZDebug", "::", "writeError", "(", "$", "arrayKeys", ",", "'Missing a FB required field (in ngopengraph.ini): app_id, DefaultAdmin, or site name (site.ini)'", ")", ";", "}", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if all required Open Graph metadata are present @param array $returnArray @return bool
[ "Checks", "if", "all", "required", "Open", "Graph", "metadata", "are", "present" ]
68a99862f240ee74174ea9b888a9a33743142e27
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/autoloads/opengraphoperator.php#L290-L319
19,238
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Base/BaseScanner.php
BaseScanner.scanFilesInPath
public function scanFilesInPath($sourcePath) { $filePattern = $this->filePattern; if (strpos($sourcePath, str_replace('*', null, $filePattern))) { $filePattern = $this->coverFishHelper->getFileNameFromPath($sourcePath); } $facade = new FinderFacade( array($sourcePath), $this->filePatternExclude, array($filePattern) ); return $this->removeExcludedPath($facade->findFiles(), $this->testExcludePath); }
php
public function scanFilesInPath($sourcePath) { $filePattern = $this->filePattern; if (strpos($sourcePath, str_replace('*', null, $filePattern))) { $filePattern = $this->coverFishHelper->getFileNameFromPath($sourcePath); } $facade = new FinderFacade( array($sourcePath), $this->filePatternExclude, array($filePattern) ); return $this->removeExcludedPath($facade->findFiles(), $this->testExcludePath); }
[ "public", "function", "scanFilesInPath", "(", "$", "sourcePath", ")", "{", "$", "filePattern", "=", "$", "this", "->", "filePattern", ";", "if", "(", "strpos", "(", "$", "sourcePath", ",", "str_replace", "(", "'*'", ",", "null", ",", "$", "filePattern", ")", ")", ")", "{", "$", "filePattern", "=", "$", "this", "->", "coverFishHelper", "->", "getFileNameFromPath", "(", "$", "sourcePath", ")", ";", "}", "$", "facade", "=", "new", "FinderFacade", "(", "array", "(", "$", "sourcePath", ")", ",", "$", "this", "->", "filePatternExclude", ",", "array", "(", "$", "filePattern", ")", ")", ";", "return", "$", "this", "->", "removeExcludedPath", "(", "$", "facade", "->", "findFiles", "(", ")", ",", "$", "this", "->", "testExcludePath", ")", ";", "}" ]
scan all files by given path recursively, if one php file will be provided within given path, this file will be returned in finder format @param string $sourcePath @return array
[ "scan", "all", "files", "by", "given", "path", "recursively", "if", "one", "php", "file", "will", "be", "provided", "within", "given", "path", "this", "file", "will", "be", "returned", "in", "finder", "format" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Base/BaseScanner.php#L397-L411
19,239
jfusion/org.jfusion.framework
src/Factory.php
Factory.&
public static function &getAuth($instance) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new authentication instance if it has not been created before if (!isset($instances[$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\Auth'; if (!class_exists($class)) { $class = '\JFusion\Plugin\Auth'; } $instances[$instance] = new $class($instance); } return $instances[$instance]; }
php
public static function &getAuth($instance) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new authentication instance if it has not been created before if (!isset($instances[$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\Auth'; if (!class_exists($class)) { $class = '\JFusion\Plugin\Auth'; } $instances[$instance] = new $class($instance); } return $instances[$instance]; }
[ "public", "static", "function", "&", "getAuth", "(", "$", "instance", ")", "{", "static", "$", "instances", ";", "if", "(", "!", "isset", "(", "$", "instances", ")", ")", "{", "$", "instances", "=", "array", "(", ")", ";", "}", "//only create a new authentication instance if it has not been created before", "if", "(", "!", "isset", "(", "$", "instances", "[", "$", "instance", "]", ")", ")", "{", "$", "name", "=", "static", "::", "getNameFromInstance", "(", "$", "instance", ")", ";", "static", "::", "pluginAutoLoad", "(", "$", "name", ")", ";", "$", "class", "=", "'\\JFusion\\Plugins\\\\'", ".", "$", "name", ".", "'\\Auth'", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "$", "class", "=", "'\\JFusion\\Plugin\\Auth'", ";", "}", "$", "instances", "[", "$", "instance", "]", "=", "new", "$", "class", "(", "$", "instance", ")", ";", "}", "return", "$", "instances", "[", "$", "instance", "]", ";", "}" ]
Gets an Authentication Class for the JFusion Plugin @param string $instance name of the JFusion plugin used @return Auth JFusion Authentication class for the JFusion plugin
[ "Gets", "an", "Authentication", "Class", "for", "the", "JFusion", "Plugin" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L203-L222
19,240
jfusion/org.jfusion.framework
src/Factory.php
Factory.&
public static function &getUser($instance) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new user instance if it has not been created before if (!isset($instances[$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\User'; if (!class_exists($class)) { $class = '\JFusion\Plugin\User'; } $instances[$instance] = new $class($instance); } return $instances[$instance]; }
php
public static function &getUser($instance) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new user instance if it has not been created before if (!isset($instances[$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\User'; if (!class_exists($class)) { $class = '\JFusion\Plugin\User'; } $instances[$instance] = new $class($instance); } return $instances[$instance]; }
[ "public", "static", "function", "&", "getUser", "(", "$", "instance", ")", "{", "static", "$", "instances", ";", "if", "(", "!", "isset", "(", "$", "instances", ")", ")", "{", "$", "instances", "=", "array", "(", ")", ";", "}", "//only create a new user instance if it has not been created before", "if", "(", "!", "isset", "(", "$", "instances", "[", "$", "instance", "]", ")", ")", "{", "$", "name", "=", "static", "::", "getNameFromInstance", "(", "$", "instance", ")", ";", "static", "::", "pluginAutoLoad", "(", "$", "name", ")", ";", "$", "class", "=", "'\\JFusion\\Plugins\\\\'", ".", "$", "name", ".", "'\\User'", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "$", "class", "=", "'\\JFusion\\Plugin\\User'", ";", "}", "$", "instances", "[", "$", "instance", "]", "=", "new", "$", "class", "(", "$", "instance", ")", ";", "}", "return", "$", "instances", "[", "$", "instance", "]", ";", "}" ]
Gets an User Class for the JFusion Plugin @param string $instance name of the JFusion plugin used @return User JFusion User class for the JFusion plugin
[ "Gets", "an", "User", "Class", "for", "the", "JFusion", "Plugin" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L231-L250
19,241
jfusion/org.jfusion.framework
src/Factory.php
Factory.&
public static function &getPlatform($platform, $instance) { static $instances; if (!isset($instances)) { $instances = array(); } $platform = ucfirst(strtolower($platform)); //only create a new thread instance if it has not been created before if (!isset($instances[$platform][$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\Platform\\' . $platform . '\\Platform'; if (!class_exists($class)) { $class = '\JFusion\Plugin\Platform\\' . $platform; } if (!class_exists($class)) { $class = '\JFusion\Plugin\Platform'; } $instances[$platform][$instance] = new $class($instance); } return $instances[$platform][$instance]; }
php
public static function &getPlatform($platform, $instance) { static $instances; if (!isset($instances)) { $instances = array(); } $platform = ucfirst(strtolower($platform)); //only create a new thread instance if it has not been created before if (!isset($instances[$platform][$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\Platform\\' . $platform . '\\Platform'; if (!class_exists($class)) { $class = '\JFusion\Plugin\Platform\\' . $platform; } if (!class_exists($class)) { $class = '\JFusion\Plugin\Platform'; } $instances[$platform][$instance] = new $class($instance); } return $instances[$platform][$instance]; }
[ "public", "static", "function", "&", "getPlatform", "(", "$", "platform", ",", "$", "instance", ")", "{", "static", "$", "instances", ";", "if", "(", "!", "isset", "(", "$", "instances", ")", ")", "{", "$", "instances", "=", "array", "(", ")", ";", "}", "$", "platform", "=", "ucfirst", "(", "strtolower", "(", "$", "platform", ")", ")", ";", "//only create a new thread instance if it has not been created before", "if", "(", "!", "isset", "(", "$", "instances", "[", "$", "platform", "]", "[", "$", "instance", "]", ")", ")", "{", "$", "name", "=", "static", "::", "getNameFromInstance", "(", "$", "instance", ")", ";", "static", "::", "pluginAutoLoad", "(", "$", "name", ")", ";", "$", "class", "=", "'\\JFusion\\Plugins\\\\'", ".", "$", "name", ".", "'\\Platform\\\\'", ".", "$", "platform", ".", "'\\\\Platform'", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "$", "class", "=", "'\\JFusion\\Plugin\\Platform\\\\'", ".", "$", "platform", ";", "}", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "$", "class", "=", "'\\JFusion\\Plugin\\Platform'", ";", "}", "$", "instances", "[", "$", "platform", "]", "[", "$", "instance", "]", "=", "new", "$", "class", "(", "$", "instance", ")", ";", "}", "return", "$", "instances", "[", "$", "platform", "]", "[", "$", "instance", "]", ";", "}" ]
Gets a Forum Class for the JFusion Plugin @param string $platform @param string $instance name of the JFusion plugin used @return Platform JFusion Thread class for the JFusion plugin
[ "Gets", "a", "Forum", "Class", "for", "the", "JFusion", "Plugin" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L260-L285
19,242
jfusion/org.jfusion.framework
src/Factory.php
Factory.&
public static function &getHelper($instance) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new thread instance if it has not been created before if (!isset($instances[$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\Helper'; if (!class_exists($class)) { $instances[$instance] = false; } else { $instances[$instance] = new $class($instance); } } return $instances[$instance]; }
php
public static function &getHelper($instance) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new thread instance if it has not been created before if (!isset($instances[$instance])) { $name = static::getNameFromInstance($instance); static::pluginAutoLoad($name); $class = '\JFusion\Plugins\\' . $name . '\Helper'; if (!class_exists($class)) { $instances[$instance] = false; } else { $instances[$instance] = new $class($instance); } } return $instances[$instance]; }
[ "public", "static", "function", "&", "getHelper", "(", "$", "instance", ")", "{", "static", "$", "instances", ";", "if", "(", "!", "isset", "(", "$", "instances", ")", ")", "{", "$", "instances", "=", "array", "(", ")", ";", "}", "//only create a new thread instance if it has not been created before", "if", "(", "!", "isset", "(", "$", "instances", "[", "$", "instance", "]", ")", ")", "{", "$", "name", "=", "static", "::", "getNameFromInstance", "(", "$", "instance", ")", ";", "static", "::", "pluginAutoLoad", "(", "$", "name", ")", ";", "$", "class", "=", "'\\JFusion\\Plugins\\\\'", ".", "$", "name", ".", "'\\Helper'", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "$", "instances", "[", "$", "instance", "]", "=", "false", ";", "}", "else", "{", "$", "instances", "[", "$", "instance", "]", "=", "new", "$", "class", "(", "$", "instance", ")", ";", "}", "}", "return", "$", "instances", "[", "$", "instance", "]", ";", "}" ]
Gets a Helper Class for the JFusion Plugin which is only used internally by the plugin @param string $instance name of the JFusion plugin used @return Plugin|false JFusion Helper class for the JFusion plugin
[ "Gets", "a", "Helper", "Class", "for", "the", "JFusion", "Plugin", "which", "is", "only", "used", "internally", "by", "the", "plugin" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L294-L314
19,243
jfusion/org.jfusion.framework
src/Factory.php
Factory.&
public static function &getDatabase($jname) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new database instance if it has not been created before if (!isset($instances[$jname])) { /** * TODO: MUST BE CHANGED! as do not rely on joomla_int */ if ($jname == 'joomla_int') { $db = self::getDBO(); } else { //get config values $params = static::getParams($jname); //prepare the data for creating a database connection $host = $params->get('database_host'); $user = $params->get('database_user'); $password = $params->get('database_password'); $database = $params->get('database_name'); $prefix = $params->get('database_prefix', ''); $driver = $params->get('database_type'); $charset = $params->get('database_charset', 'utf8'); //added extra code to prevent error when $driver is incorrect $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); $db = DatabaseFactory::getInstance()->getDriver($driver, $options); if ($driver != 'sqlite') { //add support for UTF8 $db->setQuery('SET names ' . $db->quote($charset)); $db->execute(); } //get the debug configuration setting $db->setDebug(Config::get()->get('debug')); } $instances[$jname] = $db; } return $instances[$jname]; }
php
public static function &getDatabase($jname) { static $instances; if (!isset($instances)) { $instances = array(); } //only create a new database instance if it has not been created before if (!isset($instances[$jname])) { /** * TODO: MUST BE CHANGED! as do not rely on joomla_int */ if ($jname == 'joomla_int') { $db = self::getDBO(); } else { //get config values $params = static::getParams($jname); //prepare the data for creating a database connection $host = $params->get('database_host'); $user = $params->get('database_user'); $password = $params->get('database_password'); $database = $params->get('database_name'); $prefix = $params->get('database_prefix', ''); $driver = $params->get('database_type'); $charset = $params->get('database_charset', 'utf8'); //added extra code to prevent error when $driver is incorrect $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); $db = DatabaseFactory::getInstance()->getDriver($driver, $options); if ($driver != 'sqlite') { //add support for UTF8 $db->setQuery('SET names ' . $db->quote($charset)); $db->execute(); } //get the debug configuration setting $db->setDebug(Config::get()->get('debug')); } $instances[$jname] = $db; } return $instances[$jname]; }
[ "public", "static", "function", "&", "getDatabase", "(", "$", "jname", ")", "{", "static", "$", "instances", ";", "if", "(", "!", "isset", "(", "$", "instances", ")", ")", "{", "$", "instances", "=", "array", "(", ")", ";", "}", "//only create a new database instance if it has not been created before", "if", "(", "!", "isset", "(", "$", "instances", "[", "$", "jname", "]", ")", ")", "{", "/**\n\t\t\t * TODO: MUST BE CHANGED! as do not rely on joomla_int\n\t\t\t */", "if", "(", "$", "jname", "==", "'joomla_int'", ")", "{", "$", "db", "=", "self", "::", "getDBO", "(", ")", ";", "}", "else", "{", "//get config values", "$", "params", "=", "static", "::", "getParams", "(", "$", "jname", ")", ";", "//prepare the data for creating a database connection", "$", "host", "=", "$", "params", "->", "get", "(", "'database_host'", ")", ";", "$", "user", "=", "$", "params", "->", "get", "(", "'database_user'", ")", ";", "$", "password", "=", "$", "params", "->", "get", "(", "'database_password'", ")", ";", "$", "database", "=", "$", "params", "->", "get", "(", "'database_name'", ")", ";", "$", "prefix", "=", "$", "params", "->", "get", "(", "'database_prefix'", ",", "''", ")", ";", "$", "driver", "=", "$", "params", "->", "get", "(", "'database_type'", ")", ";", "$", "charset", "=", "$", "params", "->", "get", "(", "'database_charset'", ",", "'utf8'", ")", ";", "//added extra code to prevent error when $driver is incorrect", "$", "options", "=", "array", "(", "'driver'", "=>", "$", "driver", ",", "'host'", "=>", "$", "host", ",", "'user'", "=>", "$", "user", ",", "'password'", "=>", "$", "password", ",", "'database'", "=>", "$", "database", ",", "'prefix'", "=>", "$", "prefix", ")", ";", "$", "db", "=", "DatabaseFactory", "::", "getInstance", "(", ")", "->", "getDriver", "(", "$", "driver", ",", "$", "options", ")", ";", "if", "(", "$", "driver", "!=", "'sqlite'", ")", "{", "//add support for UTF8", "$", "db", "->", "setQuery", "(", "'SET names '", ".", "$", "db", "->", "quote", "(", "$", "charset", ")", ")", ";", "$", "db", "->", "execute", "(", ")", ";", "}", "//get the debug configuration setting", "$", "db", "->", "setDebug", "(", "Config", "::", "get", "(", ")", "->", "get", "(", "'debug'", ")", ")", ";", "}", "$", "instances", "[", "$", "jname", "]", "=", "$", "db", ";", "}", "return", "$", "instances", "[", "$", "jname", "]", ";", "}" ]
Gets an Database Connection for the JFusion Plugin @param string $jname name of the JFusion plugin used @return DatabaseDriver Database connection for the JFusion plugin @throws RuntimeException
[ "Gets", "an", "Database", "Connection", "for", "the", "JFusion", "Plugin" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L338-L380
19,244
jfusion/org.jfusion.framework
src/Factory.php
Factory.&
public static function &getParams($jname, $reset = false) { static $instances; if (!isset($instances)) { $instances = array(); } try { //only create a new parameter instance if it has not been created before if (!isset($instances[$jname]) || $reset) { $db = self::getDBO(); $query = $db->getQuery(true) ->select('params') ->from('#__jfusion') ->where('name = ' . $db->quote($jname)); $db->setQuery($query); $params = $db->loadResult(); $instances[$jname] = new Registry($params); } return $instances[$jname]; } catch (Exception $e) { return new Registry(); } }
php
public static function &getParams($jname, $reset = false) { static $instances; if (!isset($instances)) { $instances = array(); } try { //only create a new parameter instance if it has not been created before if (!isset($instances[$jname]) || $reset) { $db = self::getDBO(); $query = $db->getQuery(true) ->select('params') ->from('#__jfusion') ->where('name = ' . $db->quote($jname)); $db->setQuery($query); $params = $db->loadResult(); $instances[$jname] = new Registry($params); } return $instances[$jname]; } catch (Exception $e) { return new Registry(); } }
[ "public", "static", "function", "&", "getParams", "(", "$", "jname", ",", "$", "reset", "=", "false", ")", "{", "static", "$", "instances", ";", "if", "(", "!", "isset", "(", "$", "instances", ")", ")", "{", "$", "instances", "=", "array", "(", ")", ";", "}", "try", "{", "//only create a new parameter instance if it has not been created before", "if", "(", "!", "isset", "(", "$", "instances", "[", "$", "jname", "]", ")", "||", "$", "reset", ")", "{", "$", "db", "=", "self", "::", "getDBO", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'params'", ")", "->", "from", "(", "'#__jfusion'", ")", "->", "where", "(", "'name = '", ".", "$", "db", "->", "quote", "(", "$", "jname", ")", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "params", "=", "$", "db", "->", "loadResult", "(", ")", ";", "$", "instances", "[", "$", "jname", "]", "=", "new", "Registry", "(", "$", "params", ")", ";", "}", "return", "$", "instances", "[", "$", "jname", "]", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "new", "Registry", "(", ")", ";", "}", "}" ]
Gets an Parameter Object for the JFusion Plugin @param string $jname name of the JFusion plugin used @param boolean $reset switch to force a recreate of the instance @return Registry JParam object for the JFusion plugin
[ "Gets", "an", "Parameter", "Object", "for", "the", "JFusion", "Plugin" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L390-L415
19,245
jfusion/org.jfusion.framework
src/Factory.php
Factory.getPlugins
public static function getPlugins($criteria = 'both', $exclude = false, $status = 2) { static $instances; if (!isset($instances)) { $instances = array(); } $db = self::getDBO(); $query = $db->getQuery(true) ->select('*') ->from('#__jfusion'); $key = $criteria . '_' . $exclude . '_' . $status; if (!isset($instances[$key])) { if ($exclude !== false) { $query->where('name NOT LIKE ' . $db->quote($exclude)); } $query->where('status >= ' . (int)$status); $query->order('ordering'); $db->setQuery($query); $list = $db->loadObjectList(); switch ($criteria) { case 'slave': if (isset($list[0])) { unset($list[0]); } break; case 'master': if (isset($list[0])) { $list = $list[0]; } else { $list = null; } break; } $instances[$key] = $list; } return $instances[$key]; }
php
public static function getPlugins($criteria = 'both', $exclude = false, $status = 2) { static $instances; if (!isset($instances)) { $instances = array(); } $db = self::getDBO(); $query = $db->getQuery(true) ->select('*') ->from('#__jfusion'); $key = $criteria . '_' . $exclude . '_' . $status; if (!isset($instances[$key])) { if ($exclude !== false) { $query->where('name NOT LIKE ' . $db->quote($exclude)); } $query->where('status >= ' . (int)$status); $query->order('ordering'); $db->setQuery($query); $list = $db->loadObjectList(); switch ($criteria) { case 'slave': if (isset($list[0])) { unset($list[0]); } break; case 'master': if (isset($list[0])) { $list = $list[0]; } else { $list = null; } break; } $instances[$key] = $list; } return $instances[$key]; }
[ "public", "static", "function", "getPlugins", "(", "$", "criteria", "=", "'both'", ",", "$", "exclude", "=", "false", ",", "$", "status", "=", "2", ")", "{", "static", "$", "instances", ";", "if", "(", "!", "isset", "(", "$", "instances", ")", ")", "{", "$", "instances", "=", "array", "(", ")", ";", "}", "$", "db", "=", "self", "::", "getDBO", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'*'", ")", "->", "from", "(", "'#__jfusion'", ")", ";", "$", "key", "=", "$", "criteria", ".", "'_'", ".", "$", "exclude", ".", "'_'", ".", "$", "status", ";", "if", "(", "!", "isset", "(", "$", "instances", "[", "$", "key", "]", ")", ")", "{", "if", "(", "$", "exclude", "!==", "false", ")", "{", "$", "query", "->", "where", "(", "'name NOT LIKE '", ".", "$", "db", "->", "quote", "(", "$", "exclude", ")", ")", ";", "}", "$", "query", "->", "where", "(", "'status >= '", ".", "(", "int", ")", "$", "status", ")", ";", "$", "query", "->", "order", "(", "'ordering'", ")", ";", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "list", "=", "$", "db", "->", "loadObjectList", "(", ")", ";", "switch", "(", "$", "criteria", ")", "{", "case", "'slave'", ":", "if", "(", "isset", "(", "$", "list", "[", "0", "]", ")", ")", "{", "unset", "(", "$", "list", "[", "0", "]", ")", ";", "}", "break", ";", "case", "'master'", ":", "if", "(", "isset", "(", "$", "list", "[", "0", "]", ")", ")", "{", "$", "list", "=", "$", "list", "[", "0", "]", ";", "}", "else", "{", "$", "list", "=", "null", ";", "}", "break", ";", "}", "$", "instances", "[", "$", "key", "]", "=", "$", "list", ";", "}", "return", "$", "instances", "[", "$", "key", "]", ";", "}" ]
returns array of plugins depending on the arguments @param string $criteria the type of plugins to retrieve Use: master | slave | both @param string|boolean $exclude should we exclude joomla_int @param int $status only plugins with status equal or higher. @return array|stdClass plugin details
[ "returns", "array", "of", "plugins", "depending", "on", "the", "arguments" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L426-L466
19,246
jfusion/org.jfusion.framework
src/Factory.php
Factory.getPluginNodeId
public static function getPluginNodeId($jname) { $params = static::getParams($jname); $source_url = $params->get('source_url'); return strtolower(rtrim(parse_url($source_url, PHP_URL_HOST) . parse_url($source_url, PHP_URL_PATH), '/')); }
php
public static function getPluginNodeId($jname) { $params = static::getParams($jname); $source_url = $params->get('source_url'); return strtolower(rtrim(parse_url($source_url, PHP_URL_HOST) . parse_url($source_url, PHP_URL_PATH), '/')); }
[ "public", "static", "function", "getPluginNodeId", "(", "$", "jname", ")", "{", "$", "params", "=", "static", "::", "getParams", "(", "$", "jname", ")", ";", "$", "source_url", "=", "$", "params", "->", "get", "(", "'source_url'", ")", ";", "return", "strtolower", "(", "rtrim", "(", "parse_url", "(", "$", "source_url", ",", "PHP_URL_HOST", ")", ".", "parse_url", "(", "$", "source_url", ",", "PHP_URL_PATH", ")", ",", "'/'", ")", ")", ";", "}" ]
Gets the jnode_id for the JFusion Plugin @param string $jname name of the JFusion plugin used @return string jnodeid for the JFusion Plugin
[ "Gets", "the", "jnode_id", "for", "the", "JFusion", "Plugin" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L473-L477
19,247
jfusion/org.jfusion.framework
src/Factory.php
Factory.&
public static function &getCookies() { static $instance; //only create a new plugin instance if it has not been created before if (!isset($instance)) { $instance = new Cookies(Config::get()->get('apikey')); } return $instance; }
php
public static function &getCookies() { static $instance; //only create a new plugin instance if it has not been created before if (!isset($instance)) { $instance = new Cookies(Config::get()->get('apikey')); } return $instance; }
[ "public", "static", "function", "&", "getCookies", "(", ")", "{", "static", "$", "instance", ";", "//only create a new plugin instance if it has not been created before", "if", "(", "!", "isset", "(", "$", "instance", ")", ")", "{", "$", "instance", "=", "new", "Cookies", "(", "Config", "::", "get", "(", ")", "->", "get", "(", "'apikey'", ")", ")", ";", "}", "return", "$", "instance", ";", "}" ]
Gets an JFusion cross domain cookie object @return Cookies object for the JFusion cookies
[ "Gets", "an", "JFusion", "cross", "domain", "cookie", "object" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L503-L510
19,248
jfusion/org.jfusion.framework
src/Factory.php
Factory.getDbo
public static function getDbo() { if (!self::$database) { //get config values $host = Config::get()->get('database.host'); $user = Config::get()->get('database.user'); $password = Config::get()->get('database.password'); $database = Config::get()->get('database.name'); $prefix = Config::get()->get('database.prefix'); $driver = Config::get()->get('database.driver'); $debug = Config::get()->get('database.debug'); //added extra code to prevent error when $driver is incorrect $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); self::$database = DatabaseFactory::getInstance()->getDriver($driver, $options); //get the debug configuration setting self::$database->setDebug(Config::get()->get('debug')); } return self::$database; }
php
public static function getDbo() { if (!self::$database) { //get config values $host = Config::get()->get('database.host'); $user = Config::get()->get('database.user'); $password = Config::get()->get('database.password'); $database = Config::get()->get('database.name'); $prefix = Config::get()->get('database.prefix'); $driver = Config::get()->get('database.driver'); $debug = Config::get()->get('database.debug'); //added extra code to prevent error when $driver is incorrect $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); self::$database = DatabaseFactory::getInstance()->getDriver($driver, $options); //get the debug configuration setting self::$database->setDebug(Config::get()->get('debug')); } return self::$database; }
[ "public", "static", "function", "getDbo", "(", ")", "{", "if", "(", "!", "self", "::", "$", "database", ")", "{", "//get config values", "$", "host", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'database.host'", ")", ";", "$", "user", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'database.user'", ")", ";", "$", "password", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'database.password'", ")", ";", "$", "database", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'database.name'", ")", ";", "$", "prefix", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'database.prefix'", ")", ";", "$", "driver", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'database.driver'", ")", ";", "$", "debug", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'database.debug'", ")", ";", "//added extra code to prevent error when $driver is incorrect", "$", "options", "=", "array", "(", "'driver'", "=>", "$", "driver", ",", "'host'", "=>", "$", "host", ",", "'user'", "=>", "$", "user", ",", "'password'", "=>", "$", "password", ",", "'database'", "=>", "$", "database", ",", "'prefix'", "=>", "$", "prefix", ")", ";", "self", "::", "$", "database", "=", "DatabaseFactory", "::", "getInstance", "(", ")", "->", "getDriver", "(", "$", "driver", ",", "$", "options", ")", ";", "//get the debug configuration setting", "self", "::", "$", "database", "->", "setDebug", "(", "Config", "::", "get", "(", ")", "->", "get", "(", "'debug'", ")", ")", ";", "}", "return", "self", "::", "$", "database", ";", "}" ]
Get a database object. Returns the global {@link Driver} object, only creating it if it doesn't already exist. @return DatabaseDriver
[ "Get", "a", "database", "object", "." ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L519-L543
19,249
jfusion/org.jfusion.framework
src/Factory.php
Factory.getLanguage
public static function getLanguage() { if (!self::$language) { $locale = Config::get()->get('language.language'); $debug = Config::get()->get('language.debug'); self::$language = Language::getInstance($locale, $debug); Text::setLanguage(self::$language); } return self::$language; }
php
public static function getLanguage() { if (!self::$language) { $locale = Config::get()->get('language.language'); $debug = Config::get()->get('language.debug'); self::$language = Language::getInstance($locale, $debug); Text::setLanguage(self::$language); } return self::$language; }
[ "public", "static", "function", "getLanguage", "(", ")", "{", "if", "(", "!", "self", "::", "$", "language", ")", "{", "$", "locale", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'language.language'", ")", ";", "$", "debug", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'language.debug'", ")", ";", "self", "::", "$", "language", "=", "Language", "::", "getInstance", "(", "$", "locale", ",", "$", "debug", ")", ";", "Text", "::", "setLanguage", "(", "self", "::", "$", "language", ")", ";", "}", "return", "self", "::", "$", "language", ";", "}" ]
Get a language object. Returns the global {@link JLanguage} object, only creating it if it doesn't already exist. @return Language object @see Language @since 11.1
[ "Get", "a", "language", "object", "." ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Factory.php#L555-L566
19,250
ClanCats/Core
src/classes/CCRouter.php
CCRouter._init
public static function _init() { // default string static::filter( 'any', '[a-zA-Z0-9'.ClanCats::$config->get( 'router.allowed_special_chars' ).']' ); // only numbers static::filter( 'num', '[0-9]' ); // only alpha characters static::filter( 'alpha', '[a-zA-Z]' ); // only alphanumeric characters static::filter( 'alphanum', '[a-zA-Z0-9]' ); // 404 not found error CCRouter::on( '#404', function() { return CCResponse::create( CCView::create( 'Core::CCF/404' )->render(), 404 ); }); }
php
public static function _init() { // default string static::filter( 'any', '[a-zA-Z0-9'.ClanCats::$config->get( 'router.allowed_special_chars' ).']' ); // only numbers static::filter( 'num', '[0-9]' ); // only alpha characters static::filter( 'alpha', '[a-zA-Z]' ); // only alphanumeric characters static::filter( 'alphanum', '[a-zA-Z0-9]' ); // 404 not found error CCRouter::on( '#404', function() { return CCResponse::create( CCView::create( 'Core::CCF/404' )->render(), 404 ); }); }
[ "public", "static", "function", "_init", "(", ")", "{", "// default string", "static", "::", "filter", "(", "'any'", ",", "'[a-zA-Z0-9'", ".", "ClanCats", "::", "$", "config", "->", "get", "(", "'router.allowed_special_chars'", ")", ".", "']'", ")", ";", "// only numbers", "static", "::", "filter", "(", "'num'", ",", "'[0-9]'", ")", ";", "// only alpha characters", "static", "::", "filter", "(", "'alpha'", ",", "'[a-zA-Z]'", ")", ";", "// only alphanumeric characters", "static", "::", "filter", "(", "'alphanum'", ",", "'[a-zA-Z0-9]'", ")", ";", "// 404 not found error", "CCRouter", "::", "on", "(", "'#404'", ",", "function", "(", ")", "{", "return", "CCResponse", "::", "create", "(", "CCView", "::", "create", "(", "'Core::CCF/404'", ")", "->", "render", "(", ")", ",", "404", ")", ";", "}", ")", ";", "}" ]
Set up the basic uri filters in our static init and also add a default 404 response @return void
[ "Set", "up", "the", "basic", "uri", "filters", "in", "our", "static", "init", "and", "also", "add", "a", "default", "404", "response" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRouter.php#L64-L83
19,251
ClanCats/Core
src/classes/CCRouter.php
CCRouter.alias
public static function alias( $key, $to = null ) { if ( is_null( $to ) || is_array( $to ) ) { if ( array_key_exists( $key, static::$aliases ) ) { if ( is_array( $to ) ) { // Workaround for HHVM: return preg_replace( "/\[\w+\]/e", 'array_shift($to)', static::$aliases[$key] ); $return = static::$aliases[$key]; foreach( $to as $rpl ) { $return = preg_replace( "/\[\w+\]/", $rpl, $return, 1 ); } return $return; } return static::$aliases[$key]; } return false; } static::$aliases[$key] = $to; }
php
public static function alias( $key, $to = null ) { if ( is_null( $to ) || is_array( $to ) ) { if ( array_key_exists( $key, static::$aliases ) ) { if ( is_array( $to ) ) { // Workaround for HHVM: return preg_replace( "/\[\w+\]/e", 'array_shift($to)', static::$aliases[$key] ); $return = static::$aliases[$key]; foreach( $to as $rpl ) { $return = preg_replace( "/\[\w+\]/", $rpl, $return, 1 ); } return $return; } return static::$aliases[$key]; } return false; } static::$aliases[$key] = $to; }
[ "public", "static", "function", "alias", "(", "$", "key", ",", "$", "to", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "to", ")", "||", "is_array", "(", "$", "to", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "static", "::", "$", "aliases", ")", ")", "{", "if", "(", "is_array", "(", "$", "to", ")", ")", "{", "// Workaround for HHVM: return preg_replace( \"/\\[\\w+\\]/e\", 'array_shift($to)', static::$aliases[$key] );", "$", "return", "=", "static", "::", "$", "aliases", "[", "$", "key", "]", ";", "foreach", "(", "$", "to", "as", "$", "rpl", ")", "{", "$", "return", "=", "preg_replace", "(", "\"/\\[\\w+\\]/\"", ",", "$", "rpl", ",", "$", "return", ",", "1", ")", ";", "}", "return", "$", "return", ";", "}", "return", "static", "::", "$", "aliases", "[", "$", "key", "]", ";", "}", "return", "false", ";", "}", "static", "::", "$", "aliases", "[", "$", "key", "]", "=", "$", "to", ";", "}" ]
Creates an alias to a route or gets one @param string $key @param string $to @return void | false
[ "Creates", "an", "alias", "to", "a", "route", "or", "gets", "one" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRouter.php#L92-L115
19,252
ClanCats/Core
src/classes/CCRouter.php
CCRouter.events_matching
public static function events_matching( $event, $rule ) { if ( !array_key_exists( $event, static::$events ) ) { return array(); } $callbacks = array(); foreach( static::$events[$event] as $route => $events ) { $rgx = "~^".str_replace( '*', '(.*)', $route )."$~"; if ( preg_match( $rgx, $rule ) ) { $callbacks = array_merge( $callbacks, $events ); } } return $callbacks; }
php
public static function events_matching( $event, $rule ) { if ( !array_key_exists( $event, static::$events ) ) { return array(); } $callbacks = array(); foreach( static::$events[$event] as $route => $events ) { $rgx = "~^".str_replace( '*', '(.*)', $route )."$~"; if ( preg_match( $rgx, $rule ) ) { $callbacks = array_merge( $callbacks, $events ); } } return $callbacks; }
[ "public", "static", "function", "events_matching", "(", "$", "event", ",", "$", "rule", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "event", ",", "static", "::", "$", "events", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "callbacks", "=", "array", "(", ")", ";", "foreach", "(", "static", "::", "$", "events", "[", "$", "event", "]", "as", "$", "route", "=>", "$", "events", ")", "{", "$", "rgx", "=", "\"~^\"", ".", "str_replace", "(", "'*'", ",", "'(.*)'", ",", "$", "route", ")", ".", "\"$~\"", ";", "if", "(", "preg_match", "(", "$", "rgx", ",", "$", "rule", ")", ")", "{", "$", "callbacks", "=", "array_merge", "(", "$", "callbacks", ",", "$", "events", ")", ";", "}", "}", "return", "$", "callbacks", ";", "}" ]
Get all events matching a rule @param string $event @param string $route @param mixed $callback @return void
[ "Get", "all", "events", "matching", "a", "rule" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRouter.php#L138-L157
19,253
ClanCats/Core
src/classes/CCRouter.php
CCRouter.prepare
protected static function prepare( $routes ) { // flatten if needed if ( ClanCats::$config->get( 'router.flatten_routes' ) ) { $routes = static::flatten( $routes ); } foreach( $routes as $uri => $route ) { // check for an alias to a private if ( is_string( $route ) ) { if ( substr( $route, 0, 1 ) == '#' ) { $route = static::$privates[$route]; } } // does this uri contain an alias? if ( strpos( $uri, '@' ) !== false ) { // is the entire route an alias if ( $uri[0] == '@' ) { static::$aliases[substr( $uri, 1 )] = $route; } // does it just contain an alias else { list( $uri, $alias ) = explode( '@', $uri ); static::$aliases[$alias] = $uri; } } // check for a private if ( substr( $uri, 0, 1 ) == '#' ) { static::$privates[$uri] = $route; } // just a normal one else { static::$routes[$uri] = $route; } } }
php
protected static function prepare( $routes ) { // flatten if needed if ( ClanCats::$config->get( 'router.flatten_routes' ) ) { $routes = static::flatten( $routes ); } foreach( $routes as $uri => $route ) { // check for an alias to a private if ( is_string( $route ) ) { if ( substr( $route, 0, 1 ) == '#' ) { $route = static::$privates[$route]; } } // does this uri contain an alias? if ( strpos( $uri, '@' ) !== false ) { // is the entire route an alias if ( $uri[0] == '@' ) { static::$aliases[substr( $uri, 1 )] = $route; } // does it just contain an alias else { list( $uri, $alias ) = explode( '@', $uri ); static::$aliases[$alias] = $uri; } } // check for a private if ( substr( $uri, 0, 1 ) == '#' ) { static::$privates[$uri] = $route; } // just a normal one else { static::$routes[$uri] = $route; } } }
[ "protected", "static", "function", "prepare", "(", "$", "routes", ")", "{", "// flatten if needed", "if", "(", "ClanCats", "::", "$", "config", "->", "get", "(", "'router.flatten_routes'", ")", ")", "{", "$", "routes", "=", "static", "::", "flatten", "(", "$", "routes", ")", ";", "}", "foreach", "(", "$", "routes", "as", "$", "uri", "=>", "$", "route", ")", "{", "// check for an alias to a private", "if", "(", "is_string", "(", "$", "route", ")", ")", "{", "if", "(", "substr", "(", "$", "route", ",", "0", ",", "1", ")", "==", "'#'", ")", "{", "$", "route", "=", "static", "::", "$", "privates", "[", "$", "route", "]", ";", "}", "}", "// does this uri contain an alias?", "if", "(", "strpos", "(", "$", "uri", ",", "'@'", ")", "!==", "false", ")", "{", "// is the entire route an alias", "if", "(", "$", "uri", "[", "0", "]", "==", "'@'", ")", "{", "static", "::", "$", "aliases", "[", "substr", "(", "$", "uri", ",", "1", ")", "]", "=", "$", "route", ";", "}", "// does it just contain an alias", "else", "{", "list", "(", "$", "uri", ",", "$", "alias", ")", "=", "explode", "(", "'@'", ",", "$", "uri", ")", ";", "static", "::", "$", "aliases", "[", "$", "alias", "]", "=", "$", "uri", ";", "}", "}", "// check for a private ", "if", "(", "substr", "(", "$", "uri", ",", "0", ",", "1", ")", "==", "'#'", ")", "{", "static", "::", "$", "privates", "[", "$", "uri", "]", "=", "$", "route", ";", "}", "// just a normal one", "else", "{", "static", "::", "$", "routes", "[", "$", "uri", "]", "=", "$", "route", ";", "}", "}", "}" ]
Prepare the routes assing them to their containers @param array $routes @return void
[ "Prepare", "the", "routes", "assing", "them", "to", "their", "containers" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRouter.php#L217-L263
19,254
ClanCats/Core
src/classes/CCRouter.php
CCRouter.flatten
protected static function flatten( $routes, $param_prefix = '' ) { $flattened = array(); foreach( $routes as $prefix => $route ) { if ( is_array( $route ) && !is_callable( $route ) ) { $flattened = array_merge( static::flatten( $route, $param_prefix.$prefix.'/' ), $flattened ); } else { if ( $prefix == '/' ) { $prefix = ''; $param_prefix = substr( $param_prefix, 0, -1 ); $flattened[$param_prefix.$prefix] = $route; $param_prefix.= '/'; } else { $flattened[$param_prefix.$prefix] = $route; } } } return $flattened; }
php
protected static function flatten( $routes, $param_prefix = '' ) { $flattened = array(); foreach( $routes as $prefix => $route ) { if ( is_array( $route ) && !is_callable( $route ) ) { $flattened = array_merge( static::flatten( $route, $param_prefix.$prefix.'/' ), $flattened ); } else { if ( $prefix == '/' ) { $prefix = ''; $param_prefix = substr( $param_prefix, 0, -1 ); $flattened[$param_prefix.$prefix] = $route; $param_prefix.= '/'; } else { $flattened[$param_prefix.$prefix] = $route; } } } return $flattened; }
[ "protected", "static", "function", "flatten", "(", "$", "routes", ",", "$", "param_prefix", "=", "''", ")", "{", "$", "flattened", "=", "array", "(", ")", ";", "foreach", "(", "$", "routes", "as", "$", "prefix", "=>", "$", "route", ")", "{", "if", "(", "is_array", "(", "$", "route", ")", "&&", "!", "is_callable", "(", "$", "route", ")", ")", "{", "$", "flattened", "=", "array_merge", "(", "static", "::", "flatten", "(", "$", "route", ",", "$", "param_prefix", ".", "$", "prefix", ".", "'/'", ")", ",", "$", "flattened", ")", ";", "}", "else", "{", "if", "(", "$", "prefix", "==", "'/'", ")", "{", "$", "prefix", "=", "''", ";", "$", "param_prefix", "=", "substr", "(", "$", "param_prefix", ",", "0", ",", "-", "1", ")", ";", "$", "flattened", "[", "$", "param_prefix", ".", "$", "prefix", "]", "=", "$", "route", ";", "$", "param_prefix", ".=", "'/'", ";", "}", "else", "{", "$", "flattened", "[", "$", "param_prefix", ".", "$", "prefix", "]", "=", "$", "route", ";", "}", "}", "}", "return", "$", "flattened", ";", "}" ]
Flatten the routes @param array $routes @param string $param_prefix @return array
[ "Flatten", "the", "routes" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRouter.php#L284-L311
19,255
ClanCats/Core
src/classes/CCRouter.php
CCRouter.configure
protected static function configure( $route, $raw_route ) { // deal with emptiness if ( is_null( $raw_route ) ) { return false; } // this might be a controller if ( is_string( $raw_route ) ) { // are there overwrite parameters? if ( strpos( $raw_route, '?' ) !== false ) { $route->params = explode( ',', CCStr::suffix( $raw_route, '?' ) ); $raw_route = CCStr::cut( $raw_route, '?' ); } // is there a overwrite action? if ( strpos( $raw_route, '@' ) !== false ) { $route->action = CCStr::suffix( $raw_route, '@' ); $raw_route = CCStr::cut( $raw_route, '@' ); } // try creating an controller instance $controller = CCController::create( $raw_route ); // set the callback on controller execute $route->callback = array( $controller, 'execute' ); } // is the route callable set it up elseif ( is_callable( $raw_route ) ) { $route->callback = $raw_route; } return $route; }
php
protected static function configure( $route, $raw_route ) { // deal with emptiness if ( is_null( $raw_route ) ) { return false; } // this might be a controller if ( is_string( $raw_route ) ) { // are there overwrite parameters? if ( strpos( $raw_route, '?' ) !== false ) { $route->params = explode( ',', CCStr::suffix( $raw_route, '?' ) ); $raw_route = CCStr::cut( $raw_route, '?' ); } // is there a overwrite action? if ( strpos( $raw_route, '@' ) !== false ) { $route->action = CCStr::suffix( $raw_route, '@' ); $raw_route = CCStr::cut( $raw_route, '@' ); } // try creating an controller instance $controller = CCController::create( $raw_route ); // set the callback on controller execute $route->callback = array( $controller, 'execute' ); } // is the route callable set it up elseif ( is_callable( $raw_route ) ) { $route->callback = $raw_route; } return $route; }
[ "protected", "static", "function", "configure", "(", "$", "route", ",", "$", "raw_route", ")", "{", "// deal with emptiness", "if", "(", "is_null", "(", "$", "raw_route", ")", ")", "{", "return", "false", ";", "}", "// this might be a controller", "if", "(", "is_string", "(", "$", "raw_route", ")", ")", "{", "// are there overwrite parameters?", "if", "(", "strpos", "(", "$", "raw_route", ",", "'?'", ")", "!==", "false", ")", "{", "$", "route", "->", "params", "=", "explode", "(", "','", ",", "CCStr", "::", "suffix", "(", "$", "raw_route", ",", "'?'", ")", ")", ";", "$", "raw_route", "=", "CCStr", "::", "cut", "(", "$", "raw_route", ",", "'?'", ")", ";", "}", "// is there a overwrite action?", "if", "(", "strpos", "(", "$", "raw_route", ",", "'@'", ")", "!==", "false", ")", "{", "$", "route", "->", "action", "=", "CCStr", "::", "suffix", "(", "$", "raw_route", ",", "'@'", ")", ";", "$", "raw_route", "=", "CCStr", "::", "cut", "(", "$", "raw_route", ",", "'@'", ")", ";", "}", "// try creating an controller instance", "$", "controller", "=", "CCController", "::", "create", "(", "$", "raw_route", ")", ";", "// set the callback on controller execute", "$", "route", "->", "callback", "=", "array", "(", "$", "controller", ",", "'execute'", ")", ";", "}", "// is the route callable set it up", "elseif", "(", "is_callable", "(", "$", "raw_route", ")", ")", "{", "$", "route", "->", "callback", "=", "$", "raw_route", ";", "}", "return", "$", "route", ";", "}" ]
Check and complete a route @param CCRoute $route @param mixed $raw_route @return false|CCRoute
[ "Check", "and", "complete", "a", "route" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRouter.php#L452-L489
19,256
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.selectionHandler
protected function selectionHandler() { $userCount = count($this->choices); if ($userCount > static::MAX_USER_CHOICES) { $this->autocomplete(); } elseif ($userCount > 1) { $this->selector(); } elseif (1 === $userCount) { $this->editor($this->choices[0]); } }
php
protected function selectionHandler() { $userCount = count($this->choices); if ($userCount > static::MAX_USER_CHOICES) { $this->autocomplete(); } elseif ($userCount > 1) { $this->selector(); } elseif (1 === $userCount) { $this->editor($this->choices[0]); } }
[ "protected", "function", "selectionHandler", "(", ")", "{", "$", "userCount", "=", "count", "(", "$", "this", "->", "choices", ")", ";", "if", "(", "$", "userCount", ">", "static", "::", "MAX_USER_CHOICES", ")", "{", "$", "this", "->", "autocomplete", "(", ")", ";", "}", "elseif", "(", "$", "userCount", ">", "1", ")", "{", "$", "this", "->", "selector", "(", ")", ";", "}", "elseif", "(", "1", "===", "$", "userCount", ")", "{", "$", "this", "->", "editor", "(", "$", "this", "->", "choices", "[", "0", "]", ")", ";", "}", "}" ]
Handle user selection depending on options and user count in db
[ "Handle", "user", "selection", "depending", "on", "options", "and", "user", "count", "in", "db" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L84-L94
19,257
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.selector
protected function selector(&$choices = null) { $choices = $choices ? $choices : $this->choices; $choices = $this->userEditor->getChoicesAsEmailUsername($choices); $question = new ChoiceQuestion(static::PLEASE_SELECT_A_USER, $choices); $selectedUser = $this->ask($question); $user = $this->getChoiceBySelection($selectedUser); if ($user) { $this->editor($user); } }
php
protected function selector(&$choices = null) { $choices = $choices ? $choices : $this->choices; $choices = $this->userEditor->getChoicesAsEmailUsername($choices); $question = new ChoiceQuestion(static::PLEASE_SELECT_A_USER, $choices); $selectedUser = $this->ask($question); $user = $this->getChoiceBySelection($selectedUser); if ($user) { $this->editor($user); } }
[ "protected", "function", "selector", "(", "&", "$", "choices", "=", "null", ")", "{", "$", "choices", "=", "$", "choices", "?", "$", "choices", ":", "$", "this", "->", "choices", ";", "$", "choices", "=", "$", "this", "->", "userEditor", "->", "getChoicesAsEmailUsername", "(", "$", "choices", ")", ";", "$", "question", "=", "new", "ChoiceQuestion", "(", "static", "::", "PLEASE_SELECT_A_USER", ",", "$", "choices", ")", ";", "$", "selectedUser", "=", "$", "this", "->", "ask", "(", "$", "question", ")", ";", "$", "user", "=", "$", "this", "->", "getChoiceBySelection", "(", "$", "selectedUser", ")", ";", "if", "(", "$", "user", ")", "{", "$", "this", "->", "editor", "(", "$", "user", ")", ";", "}", "}" ]
Multiple choices user select @param User[] $choices
[ "Multiple", "choices", "user", "select" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L101-L111
19,258
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.autocomplete
protected function autocomplete() { $question = new Question(static::PLEASE_SELECT_A_USER); $question->setAutocompleterValues($this->userEditor->getChoicesAsSeparateEmailUsername($this->choices)); $selectedUser = $this->ask($question); // nem választott usert, vége if ('' === $selectedUser) { return; } $user = $this->getChoiceByUsernameOrEmail($selectedUser); // kiválasztott egy usert if (!is_null($user)) { $this->editor($user); // nem választott konkrét usert } else { $choices = $this->userEditor->getChoices($selectedUser, $selectedUser, true, static::MAX_USER_CHOICES); $this->selector($choices); } }
php
protected function autocomplete() { $question = new Question(static::PLEASE_SELECT_A_USER); $question->setAutocompleterValues($this->userEditor->getChoicesAsSeparateEmailUsername($this->choices)); $selectedUser = $this->ask($question); // nem választott usert, vége if ('' === $selectedUser) { return; } $user = $this->getChoiceByUsernameOrEmail($selectedUser); // kiválasztott egy usert if (!is_null($user)) { $this->editor($user); // nem választott konkrét usert } else { $choices = $this->userEditor->getChoices($selectedUser, $selectedUser, true, static::MAX_USER_CHOICES); $this->selector($choices); } }
[ "protected", "function", "autocomplete", "(", ")", "{", "$", "question", "=", "new", "Question", "(", "static", "::", "PLEASE_SELECT_A_USER", ")", ";", "$", "question", "->", "setAutocompleterValues", "(", "$", "this", "->", "userEditor", "->", "getChoicesAsSeparateEmailUsername", "(", "$", "this", "->", "choices", ")", ")", ";", "$", "selectedUser", "=", "$", "this", "->", "ask", "(", "$", "question", ")", ";", "// nem választott usert, vége", "if", "(", "''", "===", "$", "selectedUser", ")", "{", "return", ";", "}", "$", "user", "=", "$", "this", "->", "getChoiceByUsernameOrEmail", "(", "$", "selectedUser", ")", ";", "// kiválasztott egy usert", "if", "(", "!", "is_null", "(", "$", "user", ")", ")", "{", "$", "this", "->", "editor", "(", "$", "user", ")", ";", "// nem választott konkrét usert", "}", "else", "{", "$", "choices", "=", "$", "this", "->", "userEditor", "->", "getChoices", "(", "$", "selectedUser", ",", "$", "selectedUser", ",", "true", ",", "static", "::", "MAX_USER_CHOICES", ")", ";", "$", "this", "->", "selector", "(", "$", "choices", ")", ";", "}", "}" ]
Autocomplete user select
[ "Autocomplete", "user", "select" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L116-L134
19,259
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.editor
protected function editor(User $user) { // store props $oldProps = new UserUpdater($user); $newProps = $this->getNewValues($user); // confirm $ln = <<<EOL Summary ------- Username: "{$newProps->getUsername()}" Email: "{$newProps->getEmail()}" Password: "{$newProps->getPassword()}" EOL; $this->logger->block($ln); // check changes $changedValues = $oldProps->getChanged($newProps); if (empty($changedValues)) { $this->logger->note('Nothing changed, exiting.'); return; } // persist if ($persist = $this->ask(new ConfirmationQuestion('Confirm user update?'))) { $this->userEditor->updateUser($user, $newProps); $this->logger->success('User updated!'); } // send mail if ($persist) { $dontSend = 'Don\'t send'; $emailChoices = [$dontSend, $oldProps->getEmail()]; if (isset($changedValues['email'])) { $emailChoices[] = $changedValues['email']; } $to = $this->ask(new ChoiceQuestion('Send notification to', $emailChoices)); if ($to !== $dontSend) { $this->sendNotification($to, $changedValues); } } }
php
protected function editor(User $user) { // store props $oldProps = new UserUpdater($user); $newProps = $this->getNewValues($user); // confirm $ln = <<<EOL Summary ------- Username: "{$newProps->getUsername()}" Email: "{$newProps->getEmail()}" Password: "{$newProps->getPassword()}" EOL; $this->logger->block($ln); // check changes $changedValues = $oldProps->getChanged($newProps); if (empty($changedValues)) { $this->logger->note('Nothing changed, exiting.'); return; } // persist if ($persist = $this->ask(new ConfirmationQuestion('Confirm user update?'))) { $this->userEditor->updateUser($user, $newProps); $this->logger->success('User updated!'); } // send mail if ($persist) { $dontSend = 'Don\'t send'; $emailChoices = [$dontSend, $oldProps->getEmail()]; if (isset($changedValues['email'])) { $emailChoices[] = $changedValues['email']; } $to = $this->ask(new ChoiceQuestion('Send notification to', $emailChoices)); if ($to !== $dontSend) { $this->sendNotification($to, $changedValues); } } }
[ "protected", "function", "editor", "(", "User", "$", "user", ")", "{", "// store props", "$", "oldProps", "=", "new", "UserUpdater", "(", "$", "user", ")", ";", "$", "newProps", "=", "$", "this", "->", "getNewValues", "(", "$", "user", ")", ";", "// confirm", "$", "ln", "=", " <<<EOL\nSummary\n-------\nUsername: \"{$newProps->getUsername()}\"\nEmail: \"{$newProps->getEmail()}\"\nPassword: \"{$newProps->getPassword()}\"\nEOL", ";", "$", "this", "->", "logger", "->", "block", "(", "$", "ln", ")", ";", "// check changes", "$", "changedValues", "=", "$", "oldProps", "->", "getChanged", "(", "$", "newProps", ")", ";", "if", "(", "empty", "(", "$", "changedValues", ")", ")", "{", "$", "this", "->", "logger", "->", "note", "(", "'Nothing changed, exiting.'", ")", ";", "return", ";", "}", "// persist", "if", "(", "$", "persist", "=", "$", "this", "->", "ask", "(", "new", "ConfirmationQuestion", "(", "'Confirm user update?'", ")", ")", ")", "{", "$", "this", "->", "userEditor", "->", "updateUser", "(", "$", "user", ",", "$", "newProps", ")", ";", "$", "this", "->", "logger", "->", "success", "(", "'User updated!'", ")", ";", "}", "// send mail", "if", "(", "$", "persist", ")", "{", "$", "dontSend", "=", "'Don\\'t send'", ";", "$", "emailChoices", "=", "[", "$", "dontSend", ",", "$", "oldProps", "->", "getEmail", "(", ")", "]", ";", "if", "(", "isset", "(", "$", "changedValues", "[", "'email'", "]", ")", ")", "{", "$", "emailChoices", "[", "]", "=", "$", "changedValues", "[", "'email'", "]", ";", "}", "$", "to", "=", "$", "this", "->", "ask", "(", "new", "ChoiceQuestion", "(", "'Send notification to'", ",", "$", "emailChoices", ")", ")", ";", "if", "(", "$", "to", "!==", "$", "dontSend", ")", "{", "$", "this", "->", "sendNotification", "(", "$", "to", ",", "$", "changedValues", ")", ";", "}", "}", "}" ]
Show user editor @param User $user
[ "Show", "user", "editor" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L141-L181
19,260
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.sendNotification
protected function sendNotification($to, array $changedValues) { $message = \Swift_Message::newInstance() ->setSubject('User details updated') ->setFrom($this->getContainer()->getParameter('fos_user.resetting.email.from_email')) ->setTo($to) ->setBody( $this->getContainer()->get('twig')->render( '@WebtownKunstmaanExtension/email/user_edit.html.twig', ['changes' => $changedValues] ), 'text/html' ); $this->getContainer()->get('mailer')->send($message); }
php
protected function sendNotification($to, array $changedValues) { $message = \Swift_Message::newInstance() ->setSubject('User details updated') ->setFrom($this->getContainer()->getParameter('fos_user.resetting.email.from_email')) ->setTo($to) ->setBody( $this->getContainer()->get('twig')->render( '@WebtownKunstmaanExtension/email/user_edit.html.twig', ['changes' => $changedValues] ), 'text/html' ); $this->getContainer()->get('mailer')->send($message); }
[ "protected", "function", "sendNotification", "(", "$", "to", ",", "array", "$", "changedValues", ")", "{", "$", "message", "=", "\\", "Swift_Message", "::", "newInstance", "(", ")", "->", "setSubject", "(", "'User details updated'", ")", "->", "setFrom", "(", "$", "this", "->", "getContainer", "(", ")", "->", "getParameter", "(", "'fos_user.resetting.email.from_email'", ")", ")", "->", "setTo", "(", "$", "to", ")", "->", "setBody", "(", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'twig'", ")", "->", "render", "(", "'@WebtownKunstmaanExtension/email/user_edit.html.twig'", ",", "[", "'changes'", "=>", "$", "changedValues", "]", ")", ",", "'text/html'", ")", ";", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'mailer'", ")", "->", "send", "(", "$", "message", ")", ";", "}" ]
Send email notification about changes @param $to @param array $changedValues
[ "Send", "email", "notification", "about", "changes" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L189-L203
19,261
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.getChoiceBySelection
protected function getChoiceBySelection($selection) { preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches); if (count($matches) < 2) { return; } $username = $matches[1]; foreach ($this->choices as $item) { if ($item->getUsername() === $username) { return $item; } } return; }
php
protected function getChoiceBySelection($selection) { preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches); if (count($matches) < 2) { return; } $username = $matches[1]; foreach ($this->choices as $item) { if ($item->getUsername() === $username) { return $item; } } return; }
[ "protected", "function", "getChoiceBySelection", "(", "$", "selection", ")", "{", "preg_match", "(", "'/^[^(]+\\(([^\\)]+)\\)$/'", ",", "$", "selection", ",", "$", "matches", ")", ";", "if", "(", "count", "(", "$", "matches", ")", "<", "2", ")", "{", "return", ";", "}", "$", "username", "=", "$", "matches", "[", "1", "]", ";", "foreach", "(", "$", "this", "->", "choices", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "getUsername", "(", ")", "===", "$", "username", ")", "{", "return", "$", "item", ";", "}", "}", "return", ";", "}" ]
Find User by username @param string $username @return User
[ "Find", "User", "by", "username" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L212-L226
19,262
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.getChoiceByUsernameOrEmail
protected function getChoiceByUsernameOrEmail($selection) { foreach ($this->choices as $item) { if ($item->getUsername() === $selection) { return $item; } if ($item->getEmail() === $selection) { return $item; } } return; }
php
protected function getChoiceByUsernameOrEmail($selection) { foreach ($this->choices as $item) { if ($item->getUsername() === $selection) { return $item; } if ($item->getEmail() === $selection) { return $item; } } return; }
[ "protected", "function", "getChoiceByUsernameOrEmail", "(", "$", "selection", ")", "{", "foreach", "(", "$", "this", "->", "choices", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "getUsername", "(", ")", "===", "$", "selection", ")", "{", "return", "$", "item", ";", "}", "if", "(", "$", "item", "->", "getEmail", "(", ")", "===", "$", "selection", ")", "{", "return", "$", "item", ";", "}", "}", "return", ";", "}" ]
Find User by username or email @param string $username @return User
[ "Find", "User", "by", "username", "or", "email" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L235-L247
19,263
webtown-php/KunstmaanExtensionBundle
src/Command/UserEditCommand.php
UserEditCommand.getNewValues
protected function getNewValues(User $user) { $newProps = new UserUpdater(); $this->logger->section('Editing user ' . $user->getEmail() . ' (' . $user->getUsername() . ')'); $this->logger->comment('leave empty to keep unchanged'); $newProps->setUsername($this->ask(new Question('Username', $user->getUsername()))); $newProps->setEmail($this->ask(new Question('E-mail address', $user->getEmail()))); $password = $this->ask(new Question('Password', '***')); // replace default *** value if empty is given $newProps->setPassword($password !== '***' ? $password : ''); return $newProps; }
php
protected function getNewValues(User $user) { $newProps = new UserUpdater(); $this->logger->section('Editing user ' . $user->getEmail() . ' (' . $user->getUsername() . ')'); $this->logger->comment('leave empty to keep unchanged'); $newProps->setUsername($this->ask(new Question('Username', $user->getUsername()))); $newProps->setEmail($this->ask(new Question('E-mail address', $user->getEmail()))); $password = $this->ask(new Question('Password', '***')); // replace default *** value if empty is given $newProps->setPassword($password !== '***' ? $password : ''); return $newProps; }
[ "protected", "function", "getNewValues", "(", "User", "$", "user", ")", "{", "$", "newProps", "=", "new", "UserUpdater", "(", ")", ";", "$", "this", "->", "logger", "->", "section", "(", "'Editing user '", ".", "$", "user", "->", "getEmail", "(", ")", ".", "' ('", ".", "$", "user", "->", "getUsername", "(", ")", ".", "')'", ")", ";", "$", "this", "->", "logger", "->", "comment", "(", "'leave empty to keep unchanged'", ")", ";", "$", "newProps", "->", "setUsername", "(", "$", "this", "->", "ask", "(", "new", "Question", "(", "'Username'", ",", "$", "user", "->", "getUsername", "(", ")", ")", ")", ")", ";", "$", "newProps", "->", "setEmail", "(", "$", "this", "->", "ask", "(", "new", "Question", "(", "'E-mail address'", ",", "$", "user", "->", "getEmail", "(", ")", ")", ")", ")", ";", "$", "password", "=", "$", "this", "->", "ask", "(", "new", "Question", "(", "'Password'", ",", "'***'", ")", ")", ";", "// replace default *** value if empty is given", "$", "newProps", "->", "setPassword", "(", "$", "password", "!==", "'***'", "?", "$", "password", ":", "''", ")", ";", "return", "$", "newProps", ";", "}" ]
Ask for new user properties @param User $user @return UserUpdater
[ "Ask", "for", "new", "user", "properties" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L268-L280
19,264
askupasoftware/amarkal
Extensions/WordPress/Admin/Notifier.php
Notifier.notify
static function notify( $message, $type, $page = null ) { global $pagenow; if( ( null != $page && $page == $pagenow ) || null == $page) { add_action( 'admin_notices', create_function( '',"echo '<div class=\"".$type."\"><p>".$message."</p></div>';" ) ); } }
php
static function notify( $message, $type, $page = null ) { global $pagenow; if( ( null != $page && $page == $pagenow ) || null == $page) { add_action( 'admin_notices', create_function( '',"echo '<div class=\"".$type."\"><p>".$message."</p></div>';" ) ); } }
[ "static", "function", "notify", "(", "$", "message", ",", "$", "type", ",", "$", "page", "=", "null", ")", "{", "global", "$", "pagenow", ";", "if", "(", "(", "null", "!=", "$", "page", "&&", "$", "page", "==", "$", "pagenow", ")", "||", "null", "==", "$", "page", ")", "{", "add_action", "(", "'admin_notices'", ",", "create_function", "(", "''", ",", "\"echo '<div class=\\\"\"", ".", "$", "type", ".", "\"\\\"><p>\"", ".", "$", "message", ".", "\"</p></div>';\"", ")", ")", ";", "}", "}" ]
Register an admin notification. @global string $pagenow The current admin page. @param string $message The message to print. @param string $type The type of notification [self::ERROR|self::SUCCESS]. @param string $page (optional) A specific admin page in which the notification should appear. If no page is specified the message will be visible in all admin pages.
[ "Register", "an", "admin", "notification", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/Notifier.php#L39-L47
19,265
factorio-item-browser/export-data
src/Registry/EntityRegistry.php
EntityRegistry.set
public function set(EntityInterface $entity): string { $hash = $entity->calculateHash(); $content = $this->encodeContent($entity->writeData()); $this->saveContent($hash, $content); return $hash; }
php
public function set(EntityInterface $entity): string { $hash = $entity->calculateHash(); $content = $this->encodeContent($entity->writeData()); $this->saveContent($hash, $content); return $hash; }
[ "public", "function", "set", "(", "EntityInterface", "$", "entity", ")", ":", "string", "{", "$", "hash", "=", "$", "entity", "->", "calculateHash", "(", ")", ";", "$", "content", "=", "$", "this", "->", "encodeContent", "(", "$", "entity", "->", "writeData", "(", ")", ")", ";", "$", "this", "->", "saveContent", "(", "$", "hash", ",", "$", "content", ")", ";", "return", "$", "hash", ";", "}" ]
Sets the specified entity into the registry. @param EntityInterface $entity @return string The hash used to save the entity.
[ "Sets", "the", "specified", "entity", "into", "the", "registry", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/EntityRegistry.php#L51-L57
19,266
factorio-item-browser/export-data
src/Registry/EntityRegistry.php
EntityRegistry.get
public function get(string $hash): ?EntityInterface { $result = null; $content = $this->loadContent($hash); if ($content !== null) { $result = $this->createEntityFromContent($content); } return $result; }
php
public function get(string $hash): ?EntityInterface { $result = null; $content = $this->loadContent($hash); if ($content !== null) { $result = $this->createEntityFromContent($content); } return $result; }
[ "public", "function", "get", "(", "string", "$", "hash", ")", ":", "?", "EntityInterface", "{", "$", "result", "=", "null", ";", "$", "content", "=", "$", "this", "->", "loadContent", "(", "$", "hash", ")", ";", "if", "(", "$", "content", "!==", "null", ")", "{", "$", "result", "=", "$", "this", "->", "createEntityFromContent", "(", "$", "content", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the entity with the specified hash. @param string $hash @return EntityInterface|null
[ "Returns", "the", "entity", "with", "the", "specified", "hash", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/EntityRegistry.php#L64-L72
19,267
factorio-item-browser/export-data
src/Registry/EntityRegistry.php
EntityRegistry.createEntityFromContent
protected function createEntityFromContent(string $content): EntityInterface { $result = $this->createEntity(); $result->readData(new DataContainer($this->decodeContent($content))); return $result; }
php
protected function createEntityFromContent(string $content): EntityInterface { $result = $this->createEntity(); $result->readData(new DataContainer($this->decodeContent($content))); return $result; }
[ "protected", "function", "createEntityFromContent", "(", "string", "$", "content", ")", ":", "EntityInterface", "{", "$", "result", "=", "$", "this", "->", "createEntity", "(", ")", ";", "$", "result", "->", "readData", "(", "new", "DataContainer", "(", "$", "this", "->", "decodeContent", "(", "$", "content", ")", ")", ")", ";", "return", "$", "result", ";", "}" ]
Creates an entity from the specified content. @param string $content @return EntityInterface
[ "Creates", "an", "entity", "from", "the", "specified", "content", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/EntityRegistry.php#L97-L102
19,268
redaigbaria/oauth2
src/Entity/SessionEntity.php
SessionEntity.associateScope
public function associateScope(ScopeEntity $scope) { if (!isset($this->scopes[$scope->getId()])) { $this->scopes[$scope->getId()] = $scope; } return $this; }
php
public function associateScope(ScopeEntity $scope) { if (!isset($this->scopes[$scope->getId()])) { $this->scopes[$scope->getId()] = $scope; } return $this; }
[ "public", "function", "associateScope", "(", "ScopeEntity", "$", "scope", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "scopes", "[", "$", "scope", "->", "getId", "(", ")", "]", ")", ")", "{", "$", "this", "->", "scopes", "[", "$", "scope", "->", "getId", "(", ")", "]", "=", "$", "scope", ";", "}", "return", "$", "this", ";", "}" ]
Associate a scope @param \League\OAuth2\Server\Entity\ScopeEntity $scope @return self
[ "Associate", "a", "scope" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L130-L137
19,269
redaigbaria/oauth2
src/Entity/SessionEntity.php
SessionEntity.hasScope
public function hasScope($scope) { if ($this->scopes === null) { $this->getScopes(); } return isset($this->scopes[$scope]); }
php
public function hasScope($scope) { if ($this->scopes === null) { $this->getScopes(); } return isset($this->scopes[$scope]); }
[ "public", "function", "hasScope", "(", "$", "scope", ")", "{", "if", "(", "$", "this", "->", "scopes", "===", "null", ")", "{", "$", "this", "->", "getScopes", "(", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "scopes", "[", "$", "scope", "]", ")", ";", "}" ]
Check if access token has an associated scope @param string $scope Scope to check @return bool
[ "Check", "if", "access", "token", "has", "an", "associated", "scope" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L146-L153
19,270
redaigbaria/oauth2
src/Entity/SessionEntity.php
SessionEntity.getClient
public function getClient() { if ($this->client instanceof ClientEntity) { return $this->client; } $this->client = $this->server->getClientStorage()->getBySession($this); return $this->client; }
php
public function getClient() { if ($this->client instanceof ClientEntity) { return $this->client; } $this->client = $this->server->getClientStorage()->getBySession($this); return $this->client; }
[ "public", "function", "getClient", "(", ")", "{", "if", "(", "$", "this", "->", "client", "instanceof", "ClientEntity", ")", "{", "return", "$", "this", "->", "client", ";", "}", "$", "this", "->", "client", "=", "$", "this", "->", "server", "->", "getClientStorage", "(", ")", "->", "getBySession", "(", "$", "this", ")", ";", "return", "$", "this", "->", "client", ";", "}" ]
Return the session client @return \League\OAuth2\Server\Entity\ClientEntity
[ "Return", "the", "session", "client" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L237-L246
19,271
redaigbaria/oauth2
src/Entity/SessionEntity.php
SessionEntity.setOwner
public function setOwner($type, $id) { $this->ownerType = $type; $this->ownerId = $id; $this->server->getEventEmitter()->emit(new SessionOwnerEvent($this)); return $this; }
php
public function setOwner($type, $id) { $this->ownerType = $type; $this->ownerId = $id; $this->server->getEventEmitter()->emit(new SessionOwnerEvent($this)); return $this; }
[ "public", "function", "setOwner", "(", "$", "type", ",", "$", "id", ")", "{", "$", "this", "->", "ownerType", "=", "$", "type", ";", "$", "this", "->", "ownerId", "=", "$", "id", ";", "$", "this", "->", "server", "->", "getEventEmitter", "(", ")", "->", "emit", "(", "new", "SessionOwnerEvent", "(", "$", "this", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set the session owner @param string $type The type of the owner (e.g. user, app) @param string $id The identifier of the owner @return self
[ "Set", "the", "session", "owner" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L256-L264
19,272
redaigbaria/oauth2
src/Entity/SessionEntity.php
SessionEntity.save
public function save() { // Save the session and get an identifier $id = $this->server->getSessionStorage()->create( $this->getOwnerType(), $this->getOwnerId(), $this->getClient()->getId(), $this->getClient()->getRedirectUri() ); $this->setId($id); // Associate the scope with the session foreach ($this->getScopes() as $scope) { $this->server->getSessionStorage()->associateScope($this, $scope); } }
php
public function save() { // Save the session and get an identifier $id = $this->server->getSessionStorage()->create( $this->getOwnerType(), $this->getOwnerId(), $this->getClient()->getId(), $this->getClient()->getRedirectUri() ); $this->setId($id); // Associate the scope with the session foreach ($this->getScopes() as $scope) { $this->server->getSessionStorage()->associateScope($this, $scope); } }
[ "public", "function", "save", "(", ")", "{", "// Save the session and get an identifier", "$", "id", "=", "$", "this", "->", "server", "->", "getSessionStorage", "(", ")", "->", "create", "(", "$", "this", "->", "getOwnerType", "(", ")", ",", "$", "this", "->", "getOwnerId", "(", ")", ",", "$", "this", "->", "getClient", "(", ")", "->", "getId", "(", ")", ",", "$", "this", "->", "getClient", "(", ")", "->", "getRedirectUri", "(", ")", ")", ";", "$", "this", "->", "setId", "(", "$", "id", ")", ";", "// Associate the scope with the session", "foreach", "(", "$", "this", "->", "getScopes", "(", ")", "as", "$", "scope", ")", "{", "$", "this", "->", "server", "->", "getSessionStorage", "(", ")", "->", "associateScope", "(", "$", "this", ",", "$", "scope", ")", ";", "}", "}" ]
Save the session @return void
[ "Save", "the", "session" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L291-L307
19,273
webforge-labs/psc-cms
lib/Psc/UI/DropBox2.php
DropBox2.convertButtons
protected function convertButtons() { $buttons = array(); $snippets = array(); if (isset($this->assignedValues)) { foreach ($this->assignedValues as $item) { if ($item instanceof \Psc\UI\ButtonInterface) { $button = $item; } elseif ($item instanceof \Psc\CMS\Entity) { $button = $this->entityMeta->getAdapter($item) ->setButtonMode(Buttonable::CLICK | Buttonable::DRAG) ->getDropBoxButton(); } else { throw new \InvalidArgumentException(Code::varInfo($item).' kann nicht in einen Button umgewandelt werden'); } if ($button instanceof \Psc\JS\JooseSnippetWidget) { $button->disableAutoLoad(); // das bevor getJooseSnippet() machen damit widgetSelector im snippet geht // aber NACH disableAutoLoad() $button->html()->addClass('assigned-item'); $snippets[] = $button->getJooseSnippet(); } else { $button->html()->addClass('assigned-item'); } $buttons[] = $button; } } return array($buttons, $snippets); }
php
protected function convertButtons() { $buttons = array(); $snippets = array(); if (isset($this->assignedValues)) { foreach ($this->assignedValues as $item) { if ($item instanceof \Psc\UI\ButtonInterface) { $button = $item; } elseif ($item instanceof \Psc\CMS\Entity) { $button = $this->entityMeta->getAdapter($item) ->setButtonMode(Buttonable::CLICK | Buttonable::DRAG) ->getDropBoxButton(); } else { throw new \InvalidArgumentException(Code::varInfo($item).' kann nicht in einen Button umgewandelt werden'); } if ($button instanceof \Psc\JS\JooseSnippetWidget) { $button->disableAutoLoad(); // das bevor getJooseSnippet() machen damit widgetSelector im snippet geht // aber NACH disableAutoLoad() $button->html()->addClass('assigned-item'); $snippets[] = $button->getJooseSnippet(); } else { $button->html()->addClass('assigned-item'); } $buttons[] = $button; } } return array($buttons, $snippets); }
[ "protected", "function", "convertButtons", "(", ")", "{", "$", "buttons", "=", "array", "(", ")", ";", "$", "snippets", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "assignedValues", ")", ")", "{", "foreach", "(", "$", "this", "->", "assignedValues", "as", "$", "item", ")", "{", "if", "(", "$", "item", "instanceof", "\\", "Psc", "\\", "UI", "\\", "ButtonInterface", ")", "{", "$", "button", "=", "$", "item", ";", "}", "elseif", "(", "$", "item", "instanceof", "\\", "Psc", "\\", "CMS", "\\", "Entity", ")", "{", "$", "button", "=", "$", "this", "->", "entityMeta", "->", "getAdapter", "(", "$", "item", ")", "->", "setButtonMode", "(", "Buttonable", "::", "CLICK", "|", "Buttonable", "::", "DRAG", ")", "->", "getDropBoxButton", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "Code", "::", "varInfo", "(", "$", "item", ")", ".", "' kann nicht in einen Button umgewandelt werden'", ")", ";", "}", "if", "(", "$", "button", "instanceof", "\\", "Psc", "\\", "JS", "\\", "JooseSnippetWidget", ")", "{", "$", "button", "->", "disableAutoLoad", "(", ")", ";", "// das bevor getJooseSnippet() machen damit widgetSelector im snippet geht", "// aber NACH disableAutoLoad()", "$", "button", "->", "html", "(", ")", "->", "addClass", "(", "'assigned-item'", ")", ";", "$", "snippets", "[", "]", "=", "$", "button", "->", "getJooseSnippet", "(", ")", ";", "}", "else", "{", "$", "button", "->", "html", "(", ")", "->", "addClass", "(", "'assigned-item'", ")", ";", "}", "$", "buttons", "[", "]", "=", "$", "button", ";", "}", "}", "return", "array", "(", "$", "buttons", ",", "$", "snippets", ")", ";", "}" ]
Wandelt die assignedValues in Buttons um die JooseSnippets werden gesammelt, wenn sie extrahierbar sind @return list($buttons, $snippets)
[ "Wandelt", "die", "assignedValues", "in", "Buttons", "um" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/DropBox2.php#L115-L150
19,274
atkrad/data-tables
src/Render.php
Render.prepareColumnsConfig
protected function prepareColumnsConfig() { $columns = []; foreach ($this->table->getColumns() as $column) { $columns[] = $column->getProperties(); } $this->table->setColumns($columns); }
php
protected function prepareColumnsConfig() { $columns = []; foreach ($this->table->getColumns() as $column) { $columns[] = $column->getProperties(); } $this->table->setColumns($columns); }
[ "protected", "function", "prepareColumnsConfig", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "table", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "$", "columns", "[", "]", "=", "$", "column", "->", "getProperties", "(", ")", ";", "}", "$", "this", "->", "table", "->", "setColumns", "(", "$", "columns", ")", ";", "}" ]
Prepare columns config
[ "Prepare", "columns", "config" ]
5afcc337ab624ca626e29d9674459c5105982b16
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Render.php#L136-L145
19,275
atkrad/data-tables
src/Render.php
Render.prepareExtensionsConfig
protected function prepareExtensionsConfig() { foreach ($this->table->getExtensions() as $extension) { $properties = $extension->getProperties(); if (isset($properties)) { $this->table->setProperty($extension->getPropertyName(), $properties); } } }
php
protected function prepareExtensionsConfig() { foreach ($this->table->getExtensions() as $extension) { $properties = $extension->getProperties(); if (isset($properties)) { $this->table->setProperty($extension->getPropertyName(), $properties); } } }
[ "protected", "function", "prepareExtensionsConfig", "(", ")", "{", "foreach", "(", "$", "this", "->", "table", "->", "getExtensions", "(", ")", "as", "$", "extension", ")", "{", "$", "properties", "=", "$", "extension", "->", "getProperties", "(", ")", ";", "if", "(", "isset", "(", "$", "properties", ")", ")", "{", "$", "this", "->", "table", "->", "setProperty", "(", "$", "extension", "->", "getPropertyName", "(", ")", ",", "$", "properties", ")", ";", "}", "}", "}" ]
Prepare extensions config
[ "Prepare", "extensions", "config" ]
5afcc337ab624ca626e29d9674459c5105982b16
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Render.php#L150-L158
19,276
CakeCMS/Core
src/Path/Path.php
Path.dirs
public function dirs($resource, $recursive = false, $filter = null) { return $this->ls($resource, self::LS_MODE_DIR, $recursive, $filter); }
php
public function dirs($resource, $recursive = false, $filter = null) { return $this->ls($resource, self::LS_MODE_DIR, $recursive, $filter); }
[ "public", "function", "dirs", "(", "$", "resource", ",", "$", "recursive", "=", "false", ",", "$", "filter", "=", "null", ")", "{", "return", "$", "this", "->", "ls", "(", "$", "resource", ",", "self", "::", "LS_MODE_DIR", ",", "$", "recursive", ",", "$", "filter", ")", ";", "}" ]
Get a list of directories from a resource. @param string $resource @param bool $recursive @param null $filter @return mixed
[ "Get", "a", "list", "of", "directories", "from", "a", "resource", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L50-L53
19,277
CakeCMS/Core
src/Path/Path.php
Path.ls
public function ls($resource, $mode = self::LS_MODE_FILE, $recursive = false, $filter = null) { $files = []; list (, $paths, $path) = $this->_parse($resource); foreach ((array) $paths as $_path) { if (file_exists($_path . '/' . $path)) { foreach ($this->_list(FS::clean($_path . '/' . $path), '', $mode, $recursive, $filter) as $file) { if (!Arr::in($file, $files)) { $files[] = $file; } } } } return $files; }
php
public function ls($resource, $mode = self::LS_MODE_FILE, $recursive = false, $filter = null) { $files = []; list (, $paths, $path) = $this->_parse($resource); foreach ((array) $paths as $_path) { if (file_exists($_path . '/' . $path)) { foreach ($this->_list(FS::clean($_path . '/' . $path), '', $mode, $recursive, $filter) as $file) { if (!Arr::in($file, $files)) { $files[] = $file; } } } } return $files; }
[ "public", "function", "ls", "(", "$", "resource", ",", "$", "mode", "=", "self", "::", "LS_MODE_FILE", ",", "$", "recursive", "=", "false", ",", "$", "filter", "=", "null", ")", "{", "$", "files", "=", "[", "]", ";", "list", "(", ",", "$", "paths", ",", "$", "path", ")", "=", "$", "this", "->", "_parse", "(", "$", "resource", ")", ";", "foreach", "(", "(", "array", ")", "$", "paths", "as", "$", "_path", ")", "{", "if", "(", "file_exists", "(", "$", "_path", ".", "'/'", ".", "$", "path", ")", ")", "{", "foreach", "(", "$", "this", "->", "_list", "(", "FS", "::", "clean", "(", "$", "_path", ".", "'/'", ".", "$", "path", ")", ",", "''", ",", "$", "mode", ",", "$", "recursive", ",", "$", "filter", ")", "as", "$", "file", ")", "{", "if", "(", "!", "Arr", "::", "in", "(", "$", "file", ",", "$", "files", ")", ")", "{", "$", "files", "[", "]", "=", "$", "file", ";", "}", "}", "}", "}", "return", "$", "files", ";", "}" ]
Get a list of files or diretories from a resource. @param string $resource @param string $mode @param bool $recursive @param null $filter @return array @SuppressWarnings(PHPMD.ShortMethodName)
[ "Get", "a", "list", "of", "files", "or", "diretories", "from", "a", "resource", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L105-L121
19,278
CakeCMS/Core
src/Path/Path.php
Path._list
protected function _list($path, $prefix = '', $mode = 'file', $recursive = false, $filter = null) { $files = []; $ignore = ['.', '..', '.DS_Store', '.svn', '.git', '.gitignore', '.gitmodules', 'cgi-bin']; if ($scan = @scandir($path)) { foreach ($scan as $file) { // continue if ignore match if (Arr::in($file, $ignore)) { continue; } if (is_dir($path . '/' . $file)) { // add dir if ($mode === 'dir') { // continue if no regex filter match if ($filter && !preg_match($filter, $file)) { continue; } $files[] = $prefix . $file; } // continue if not recursive if (!$recursive) { continue; } // read subdirectory $files = array_merge( $files, $this->_list($path . '/' . $file, $prefix . $file . '/', $mode, $recursive, $filter) ); } else { // add file if ($mode === 'file') { // continue if no regex filter match if ($filter && !preg_match($filter, $file)) { continue; } $files[] = $prefix.$file; } } } } return $files; }
php
protected function _list($path, $prefix = '', $mode = 'file', $recursive = false, $filter = null) { $files = []; $ignore = ['.', '..', '.DS_Store', '.svn', '.git', '.gitignore', '.gitmodules', 'cgi-bin']; if ($scan = @scandir($path)) { foreach ($scan as $file) { // continue if ignore match if (Arr::in($file, $ignore)) { continue; } if (is_dir($path . '/' . $file)) { // add dir if ($mode === 'dir') { // continue if no regex filter match if ($filter && !preg_match($filter, $file)) { continue; } $files[] = $prefix . $file; } // continue if not recursive if (!$recursive) { continue; } // read subdirectory $files = array_merge( $files, $this->_list($path . '/' . $file, $prefix . $file . '/', $mode, $recursive, $filter) ); } else { // add file if ($mode === 'file') { // continue if no regex filter match if ($filter && !preg_match($filter, $file)) { continue; } $files[] = $prefix.$file; } } } } return $files; }
[ "protected", "function", "_list", "(", "$", "path", ",", "$", "prefix", "=", "''", ",", "$", "mode", "=", "'file'", ",", "$", "recursive", "=", "false", ",", "$", "filter", "=", "null", ")", "{", "$", "files", "=", "[", "]", ";", "$", "ignore", "=", "[", "'.'", ",", "'..'", ",", "'.DS_Store'", ",", "'.svn'", ",", "'.git'", ",", "'.gitignore'", ",", "'.gitmodules'", ",", "'cgi-bin'", "]", ";", "if", "(", "$", "scan", "=", "@", "scandir", "(", "$", "path", ")", ")", "{", "foreach", "(", "$", "scan", "as", "$", "file", ")", "{", "// continue if ignore match", "if", "(", "Arr", "::", "in", "(", "$", "file", ",", "$", "ignore", ")", ")", "{", "continue", ";", "}", "if", "(", "is_dir", "(", "$", "path", ".", "'/'", ".", "$", "file", ")", ")", "{", "// add dir", "if", "(", "$", "mode", "===", "'dir'", ")", "{", "// continue if no regex filter match", "if", "(", "$", "filter", "&&", "!", "preg_match", "(", "$", "filter", ",", "$", "file", ")", ")", "{", "continue", ";", "}", "$", "files", "[", "]", "=", "$", "prefix", ".", "$", "file", ";", "}", "// continue if not recursive", "if", "(", "!", "$", "recursive", ")", "{", "continue", ";", "}", "// read subdirectory", "$", "files", "=", "array_merge", "(", "$", "files", ",", "$", "this", "->", "_list", "(", "$", "path", ".", "'/'", ".", "$", "file", ",", "$", "prefix", ".", "$", "file", ".", "'/'", ",", "$", "mode", ",", "$", "recursive", ",", "$", "filter", ")", ")", ";", "}", "else", "{", "// add file", "if", "(", "$", "mode", "===", "'file'", ")", "{", "// continue if no regex filter match", "if", "(", "$", "filter", "&&", "!", "preg_match", "(", "$", "filter", ",", "$", "file", ")", ")", "{", "continue", ";", "}", "$", "files", "[", "]", "=", "$", "prefix", ".", "$", "file", ";", "}", "}", "}", "}", "return", "$", "files", ";", "}" ]
Get the list of files or directories in a given path. @param string $path @param string $prefix @param string $mode @param bool $recursive @param null $filter @return array @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Get", "the", "list", "of", "files", "or", "directories", "in", "a", "given", "path", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L134-L183
19,279
zodream/thirdparty
src/API/Search.php
Search.putBaiDu
public function putBaiDu(array $urls) { return $this->getBaiDu()->setHeader([ 'Content-Type' => 'text/plain' ])->parameters($this->merge([ 'urls' => $urls ]))->encode(function ($data) { return implode("\n", $data['urls']); })->json(); }
php
public function putBaiDu(array $urls) { return $this->getBaiDu()->setHeader([ 'Content-Type' => 'text/plain' ])->parameters($this->merge([ 'urls' => $urls ]))->encode(function ($data) { return implode("\n", $data['urls']); })->json(); }
[ "public", "function", "putBaiDu", "(", "array", "$", "urls", ")", "{", "return", "$", "this", "->", "getBaiDu", "(", ")", "->", "setHeader", "(", "[", "'Content-Type'", "=>", "'text/plain'", "]", ")", "->", "parameters", "(", "$", "this", "->", "merge", "(", "[", "'urls'", "=>", "$", "urls", "]", ")", ")", "->", "encode", "(", "function", "(", "$", "data", ")", "{", "return", "implode", "(", "\"\\n\"", ",", "$", "data", "[", "'urls'", "]", ")", ";", "}", ")", "->", "json", "(", ")", ";", "}" ]
INITIATIVE PUT URLS TO BAIDU @param array $urls @return array @throws \Exception
[ "INITIATIVE", "PUT", "URLS", "TO", "BAIDU" ]
b9d39087913850f1c5c7c9165105fec22a128f8f
https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/API/Search.php#L29-L37
19,280
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.createCreateForm
private function createCreateForm(PermissionsGroup $permissionsGroup) { $form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array( 'action' => $this->generateUrl('admin_permissionsgroup_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(PermissionsGroup $permissionsGroup) { $form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array( 'action' => $this->generateUrl('admin_permissionsgroup_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "PermissionsGroup", "$", "permissionsGroup", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "PermissionsGroupType", "(", ")", ",", "$", "permissionsGroup", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_permissionsgroup_create'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a PermissionsGroup entity. @param PermissionsGroup $permissionsGroup The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "PermissionsGroup", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L68-L78
19,281
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.newAction
public function newAction() { $permissionsGroup = new PermissionsGroup(); $form = $this->createCreateForm($permissionsGroup); return $this->render('ChillMainBundle:PermissionsGroup:new.html.twig', array( 'entity' => $permissionsGroup, 'form' => $form->createView(), )); }
php
public function newAction() { $permissionsGroup = new PermissionsGroup(); $form = $this->createCreateForm($permissionsGroup); return $this->render('ChillMainBundle:PermissionsGroup:new.html.twig', array( 'entity' => $permissionsGroup, 'form' => $form->createView(), )); }
[ "public", "function", "newAction", "(", ")", "{", "$", "permissionsGroup", "=", "new", "PermissionsGroup", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "permissionsGroup", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:PermissionsGroup:new.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "permissionsGroup", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to create a new PermissionsGroup entity.
[ "Displays", "a", "form", "to", "create", "a", "new", "PermissionsGroup", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L84-L93
19,282
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.showAction
public function showAction($id) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } $translatableStringHelper = $this->get('chill.main.helper.translatable_string'); $roleScopes = $permissionsGroup->getRoleScopes()->toArray(); usort($roleScopes, function(RoleScope $a, RoleScope $b) use ($translatableStringHelper) { if ($a->getScope() === NULL) { return 1; } if ($b->getScope() === NULL) { return +1; } return strcmp( $translatableStringHelper->localize($a->getScope()->getName()), $translatableStringHelper->localize($b->getScope()->getName()) ); }); return $this->render('ChillMainBundle:PermissionsGroup:show.html.twig', array( 'entity' => $permissionsGroup, 'role_scopes' => $roleScopes, 'expanded_roles' => $this->getExpandedRoles($roleScopes) )); }
php
public function showAction($id) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } $translatableStringHelper = $this->get('chill.main.helper.translatable_string'); $roleScopes = $permissionsGroup->getRoleScopes()->toArray(); usort($roleScopes, function(RoleScope $a, RoleScope $b) use ($translatableStringHelper) { if ($a->getScope() === NULL) { return 1; } if ($b->getScope() === NULL) { return +1; } return strcmp( $translatableStringHelper->localize($a->getScope()->getName()), $translatableStringHelper->localize($b->getScope()->getName()) ); }); return $this->render('ChillMainBundle:PermissionsGroup:show.html.twig', array( 'entity' => $permissionsGroup, 'role_scopes' => $roleScopes, 'expanded_roles' => $this->getExpandedRoles($roleScopes) )); }
[ "public", "function", "showAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "permissionsGroup", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:PermissionsGroup'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "permissionsGroup", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find PermissionsGroup entity.'", ")", ";", "}", "$", "translatableStringHelper", "=", "$", "this", "->", "get", "(", "'chill.main.helper.translatable_string'", ")", ";", "$", "roleScopes", "=", "$", "permissionsGroup", "->", "getRoleScopes", "(", ")", "->", "toArray", "(", ")", ";", "usort", "(", "$", "roleScopes", ",", "function", "(", "RoleScope", "$", "a", ",", "RoleScope", "$", "b", ")", "use", "(", "$", "translatableStringHelper", ")", "{", "if", "(", "$", "a", "->", "getScope", "(", ")", "===", "NULL", ")", "{", "return", "1", ";", "}", "if", "(", "$", "b", "->", "getScope", "(", ")", "===", "NULL", ")", "{", "return", "+", "1", ";", "}", "return", "strcmp", "(", "$", "translatableStringHelper", "->", "localize", "(", "$", "a", "->", "getScope", "(", ")", "->", "getName", "(", ")", ")", ",", "$", "translatableStringHelper", "->", "localize", "(", "$", "b", "->", "getScope", "(", ")", "->", "getName", "(", ")", ")", ")", ";", "}", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:PermissionsGroup:show.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "permissionsGroup", ",", "'role_scopes'", "=>", "$", "roleScopes", ",", "'expanded_roles'", "=>", "$", "this", "->", "getExpandedRoles", "(", "$", "roleScopes", ")", ")", ")", ";", "}" ]
Finds and displays a PermissionsGroup entity.
[ "Finds", "and", "displays", "a", "PermissionsGroup", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L99-L131
19,283
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.getExpandedRoles
private function getExpandedRoles(array $roleScopes) { $expandedRoles = array(); foreach ($roleScopes as $roleScope) { if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { $expandedRoles[$roleScope->getRole()] = array_map( function(RoleInterface $role) { return $role->getRole(); }, $this->get('security.role_hierarchy') ->getReachableRoles( array(new Role($roleScope->getRole())) ) ); } } return $expandedRoles; }
php
private function getExpandedRoles(array $roleScopes) { $expandedRoles = array(); foreach ($roleScopes as $roleScope) { if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { $expandedRoles[$roleScope->getRole()] = array_map( function(RoleInterface $role) { return $role->getRole(); }, $this->get('security.role_hierarchy') ->getReachableRoles( array(new Role($roleScope->getRole())) ) ); } } return $expandedRoles; }
[ "private", "function", "getExpandedRoles", "(", "array", "$", "roleScopes", ")", "{", "$", "expandedRoles", "=", "array", "(", ")", ";", "foreach", "(", "$", "roleScopes", "as", "$", "roleScope", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "roleScope", "->", "getRole", "(", ")", ",", "$", "expandedRoles", ")", ")", "{", "$", "expandedRoles", "[", "$", "roleScope", "->", "getRole", "(", ")", "]", "=", "array_map", "(", "function", "(", "RoleInterface", "$", "role", ")", "{", "return", "$", "role", "->", "getRole", "(", ")", ";", "}", ",", "$", "this", "->", "get", "(", "'security.role_hierarchy'", ")", "->", "getReachableRoles", "(", "array", "(", "new", "Role", "(", "$", "roleScope", "->", "getRole", "(", ")", ")", ")", ")", ")", ";", "}", "}", "return", "$", "expandedRoles", ";", "}" ]
expand roleScopes to be easily shown in template @param array $roleScopes @return array
[ "expand", "roleScopes", "to", "be", "easily", "shown", "in", "template" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L139-L158
19,284
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.editAction
public function editAction($id) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } $editForm = $this->createEditForm($permissionsGroup); $deleteRoleScopesForm = array(); foreach ($permissionsGroup->getRoleScopes() as $roleScope) { $deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm( $permissionsGroup, $roleScope); } $addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup); return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array( 'entity' => $permissionsGroup, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), 'delete_role_scopes_form' => array_map( function($form) { return $form->createView(); }, $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView() )); }
php
public function editAction($id) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } $editForm = $this->createEditForm($permissionsGroup); $deleteRoleScopesForm = array(); foreach ($permissionsGroup->getRoleScopes() as $roleScope) { $deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm( $permissionsGroup, $roleScope); } $addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup); return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array( 'entity' => $permissionsGroup, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), 'delete_role_scopes_form' => array_map( function($form) { return $form->createView(); }, $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView() )); }
[ "public", "function", "editAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "permissionsGroup", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:PermissionsGroup'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "permissionsGroup", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find PermissionsGroup entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "permissionsGroup", ")", ";", "$", "deleteRoleScopesForm", "=", "array", "(", ")", ";", "foreach", "(", "$", "permissionsGroup", "->", "getRoleScopes", "(", ")", "as", "$", "roleScope", ")", "{", "$", "deleteRoleScopesForm", "[", "$", "roleScope", "->", "getId", "(", ")", "]", "=", "$", "this", "->", "createDeleteRoleScopeForm", "(", "$", "permissionsGroup", ",", "$", "roleScope", ")", ";", "}", "$", "addRoleScopesForm", "=", "$", "this", "->", "createAddRoleScopeForm", "(", "$", "permissionsGroup", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:PermissionsGroup:edit.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "permissionsGroup", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'expanded_roles'", "=>", "$", "this", "->", "getExpandedRoles", "(", "$", "permissionsGroup", "->", "getRoleScopes", "(", ")", "->", "toArray", "(", ")", ")", ",", "'delete_role_scopes_form'", "=>", "array_map", "(", "function", "(", "$", "form", ")", "{", "return", "$", "form", "->", "createView", "(", ")", ";", "}", ",", "$", "deleteRoleScopesForm", ")", ",", "'add_role_scopes_form'", "=>", "$", "addRoleScopesForm", "->", "createView", "(", ")", ")", ")", ";", "}" ]
Displays a form to edit an existing PermissionsGroup entity.
[ "Displays", "a", "form", "to", "edit", "an", "existing", "PermissionsGroup", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L164-L194
19,285
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.createEditForm
private function createEditForm(PermissionsGroup $permissionsGroup) { $form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array( 'action' => $this->generateUrl('admin_permissionsgroup_update', array('id' => $permissionsGroup->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
private function createEditForm(PermissionsGroup $permissionsGroup) { $form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array( 'action' => $this->generateUrl('admin_permissionsgroup_update', array('id' => $permissionsGroup->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
[ "private", "function", "createEditForm", "(", "PermissionsGroup", "$", "permissionsGroup", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "PermissionsGroupType", "(", ")", ",", "$", "permissionsGroup", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_permissionsgroup_update'", ",", "array", "(", "'id'", "=>", "$", "permissionsGroup", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to edit a PermissionsGroup entity. @param PermissionsGroup $permissionsGroup The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "PermissionsGroup", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L203-L213
19,286
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.updateAction
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } $editForm = $this->createEditForm($permissionsGroup); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $id))); } $deleteRoleScopesForm = array(); foreach ($permissionsGroup->getRoleScopes() as $roleScope) { $deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm( $permissionsGroup, $roleScope); } $addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup); return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array( 'entity' => $permissionsGroup, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), 'delete_role_scopes_form' => array_map( function($form) { return $form->createView(); }, $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView() )); }
php
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } $editForm = $this->createEditForm($permissionsGroup); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $id))); } $deleteRoleScopesForm = array(); foreach ($permissionsGroup->getRoleScopes() as $roleScope) { $deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm( $permissionsGroup, $roleScope); } $addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup); return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array( 'entity' => $permissionsGroup, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), 'delete_role_scopes_form' => array_map( function($form) { return $form->createView(); }, $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView() )); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "permissionsGroup", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:PermissionsGroup'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "permissionsGroup", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find PermissionsGroup entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "permissionsGroup", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_permissionsgroup_edit'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ")", ";", "}", "$", "deleteRoleScopesForm", "=", "array", "(", ")", ";", "foreach", "(", "$", "permissionsGroup", "->", "getRoleScopes", "(", ")", "as", "$", "roleScope", ")", "{", "$", "deleteRoleScopesForm", "[", "$", "roleScope", "->", "getId", "(", ")", "]", "=", "$", "this", "->", "createDeleteRoleScopeForm", "(", "$", "permissionsGroup", ",", "$", "roleScope", ")", ";", "}", "$", "addRoleScopesForm", "=", "$", "this", "->", "createAddRoleScopeForm", "(", "$", "permissionsGroup", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:PermissionsGroup:edit.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "permissionsGroup", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'expanded_roles'", "=>", "$", "this", "->", "getExpandedRoles", "(", "$", "permissionsGroup", "->", "getRoleScopes", "(", ")", "->", "toArray", "(", ")", ")", ",", "'delete_role_scopes_form'", "=>", "array_map", "(", "function", "(", "$", "form", ")", "{", "return", "$", "form", "->", "createView", "(", ")", ";", "}", ",", "$", "deleteRoleScopesForm", ")", ",", "'add_role_scopes_form'", "=>", "$", "addRoleScopesForm", "->", "createView", "(", ")", ")", ")", ";", "}" ]
Edits an existing PermissionsGroup entity.
[ "Edits", "an", "existing", "PermissionsGroup", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L219-L257
19,287
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.getPersistentRoleScopeBy
protected function getPersistentRoleScopeBy($role, Scope $scope = null) { $em = $this->getDoctrine()->getManager(); $roleScope = $em->getRepository('ChillMainBundle:RoleScope') ->findOneBy(array('role' => $role, 'scope' => $scope)); if ($roleScope === NULL) { $roleScope = (new RoleScope()) ->setRole($role) ->setScope($scope) ; $em->persist($roleScope); } return $roleScope; }
php
protected function getPersistentRoleScopeBy($role, Scope $scope = null) { $em = $this->getDoctrine()->getManager(); $roleScope = $em->getRepository('ChillMainBundle:RoleScope') ->findOneBy(array('role' => $role, 'scope' => $scope)); if ($roleScope === NULL) { $roleScope = (new RoleScope()) ->setRole($role) ->setScope($scope) ; $em->persist($roleScope); } return $roleScope; }
[ "protected", "function", "getPersistentRoleScopeBy", "(", "$", "role", ",", "Scope", "$", "scope", "=", "null", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "roleScope", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:RoleScope'", ")", "->", "findOneBy", "(", "array", "(", "'role'", "=>", "$", "role", ",", "'scope'", "=>", "$", "scope", ")", ")", ";", "if", "(", "$", "roleScope", "===", "NULL", ")", "{", "$", "roleScope", "=", "(", "new", "RoleScope", "(", ")", ")", "->", "setRole", "(", "$", "role", ")", "->", "setScope", "(", "$", "scope", ")", ";", "$", "em", "->", "persist", "(", "$", "roleScope", ")", ";", "}", "return", "$", "roleScope", ";", "}" ]
get a role scope by his parameters. The role scope is persisted if it doesn't exists in database. @param Scope $scope @param string $role @return RoleScope
[ "get", "a", "role", "scope", "by", "his", "parameters", ".", "The", "role", "scope", "is", "persisted", "if", "it", "doesn", "t", "exists", "in", "database", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L267-L284
19,288
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.deleteLinkRoleScopeAction
public function deleteLinkRoleScopeAction($pgid, $rsid) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid); $roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } if (!$roleScope) { throw $this->createNotFoundException('Unable to find RoleScope entity'); } try { $permissionsGroup->removeRoleScope($roleScope); } catch (\RuntimeException $ex) { $this->addFlash('notice', $this->get('translator')->trans("The role '%role%' and circle " . "'%scope%' is not associated with this permission group", array( '%role%' => $this->get('translator')->trans($roleScope->getRole()), '%scope%' => $this->get('chill.main.helper.translatable_string') ->localize($roleScope->getScope()->getName()) ))); return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $pgid))); } $em->flush(); $this->addFlash('notice', $this->get('translator')->trans("The role '%role%' on circle " . "'%scope%' has been removed", array( '%role%' => $this->get('translator')->trans($roleScope->getRole()), '%scope%' => $this->get('chill.main.helper.translatable_string') ->localize($roleScope->getScope()->getName()) ))); return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $pgid))); }
php
public function deleteLinkRoleScopeAction($pgid, $rsid) { $em = $this->getDoctrine()->getManager(); $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid); $roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid); if (!$permissionsGroup) { throw $this->createNotFoundException('Unable to find PermissionsGroup entity.'); } if (!$roleScope) { throw $this->createNotFoundException('Unable to find RoleScope entity'); } try { $permissionsGroup->removeRoleScope($roleScope); } catch (\RuntimeException $ex) { $this->addFlash('notice', $this->get('translator')->trans("The role '%role%' and circle " . "'%scope%' is not associated with this permission group", array( '%role%' => $this->get('translator')->trans($roleScope->getRole()), '%scope%' => $this->get('chill.main.helper.translatable_string') ->localize($roleScope->getScope()->getName()) ))); return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $pgid))); } $em->flush(); $this->addFlash('notice', $this->get('translator')->trans("The role '%role%' on circle " . "'%scope%' has been removed", array( '%role%' => $this->get('translator')->trans($roleScope->getRole()), '%scope%' => $this->get('chill.main.helper.translatable_string') ->localize($roleScope->getScope()->getName()) ))); return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $pgid))); }
[ "public", "function", "deleteLinkRoleScopeAction", "(", "$", "pgid", ",", "$", "rsid", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "permissionsGroup", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:PermissionsGroup'", ")", "->", "find", "(", "$", "pgid", ")", ";", "$", "roleScope", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:RoleScope'", ")", "->", "find", "(", "$", "rsid", ")", ";", "if", "(", "!", "$", "permissionsGroup", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find PermissionsGroup entity.'", ")", ";", "}", "if", "(", "!", "$", "roleScope", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find RoleScope entity'", ")", ";", "}", "try", "{", "$", "permissionsGroup", "->", "removeRoleScope", "(", "$", "roleScope", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "ex", ")", "{", "$", "this", "->", "addFlash", "(", "'notice'", ",", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "\"The role '%role%' and circle \"", ".", "\"'%scope%' is not associated with this permission group\"", ",", "array", "(", "'%role%'", "=>", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "$", "roleScope", "->", "getRole", "(", ")", ")", ",", "'%scope%'", "=>", "$", "this", "->", "get", "(", "'chill.main.helper.translatable_string'", ")", "->", "localize", "(", "$", "roleScope", "->", "getScope", "(", ")", "->", "getName", "(", ")", ")", ")", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_permissionsgroup_edit'", ",", "array", "(", "'id'", "=>", "$", "pgid", ")", ")", ")", ";", "}", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "addFlash", "(", "'notice'", ",", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "\"The role '%role%' on circle \"", ".", "\"'%scope%' has been removed\"", ",", "array", "(", "'%role%'", "=>", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "$", "roleScope", "->", "getRole", "(", ")", ")", ",", "'%scope%'", "=>", "$", "this", "->", "get", "(", "'chill.main.helper.translatable_string'", ")", "->", "localize", "(", "$", "roleScope", "->", "getScope", "(", ")", "->", "getName", "(", ")", ")", ")", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_permissionsgroup_edit'", ",", "array", "(", "'id'", "=>", "$", "pgid", ")", ")", ")", ";", "}" ]
remove an association between permissionsGroup and roleScope @param int $pgid permissionsGroup id @param int $rsid roleScope id @return redirection to edit form
[ "remove", "an", "association", "between", "permissionsGroup", "and", "roleScope" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L293-L335
19,289
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.createDeleteRoleScopeForm
private function createDeleteRoleScopeForm(PermissionsGroup $permissionsGroup, RoleScope $roleScope) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_permissionsgroup_delete_role_scope', array('pgid' => $permissionsGroup->getId(), 'rsid' => $roleScope->getId()))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() ; }
php
private function createDeleteRoleScopeForm(PermissionsGroup $permissionsGroup, RoleScope $roleScope) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_permissionsgroup_delete_role_scope', array('pgid' => $permissionsGroup->getId(), 'rsid' => $roleScope->getId()))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() ; }
[ "private", "function", "createDeleteRoleScopeForm", "(", "PermissionsGroup", "$", "permissionsGroup", ",", "RoleScope", "$", "roleScope", ")", "{", "return", "$", "this", "->", "createFormBuilder", "(", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'admin_permissionsgroup_delete_role_scope'", ",", "array", "(", "'pgid'", "=>", "$", "permissionsGroup", "->", "getId", "(", ")", ",", "'rsid'", "=>", "$", "roleScope", "->", "getId", "(", ")", ")", ")", ")", "->", "setMethod", "(", "'DELETE'", ")", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Delete'", ")", ")", "->", "getForm", "(", ")", ";", "}" ]
Creates a form to delete a link to roleScope. @param mixed $permissionsGroup The entity id @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "delete", "a", "link", "to", "roleScope", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L416-L426
19,290
Chill-project/Main
Controller/PermissionsGroupController.php
PermissionsGroupController.createAddRoleScopeForm
private function createAddRoleScopeForm(PermissionsGroup $permissionsGroup) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_permissionsgroup_add_role_scope', array('id' => $permissionsGroup->getId()))) ->setMethod('PUT') ->add('composed_role_scope', 'composed_role_scope') ->add('submit', 'submit', array('label' => 'Add permission')) ->getForm() ; }
php
private function createAddRoleScopeForm(PermissionsGroup $permissionsGroup) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_permissionsgroup_add_role_scope', array('id' => $permissionsGroup->getId()))) ->setMethod('PUT') ->add('composed_role_scope', 'composed_role_scope') ->add('submit', 'submit', array('label' => 'Add permission')) ->getForm() ; }
[ "private", "function", "createAddRoleScopeForm", "(", "PermissionsGroup", "$", "permissionsGroup", ")", "{", "return", "$", "this", "->", "createFormBuilder", "(", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'admin_permissionsgroup_add_role_scope'", ",", "array", "(", "'id'", "=>", "$", "permissionsGroup", "->", "getId", "(", ")", ")", ")", ")", "->", "setMethod", "(", "'PUT'", ")", "->", "add", "(", "'composed_role_scope'", ",", "'composed_role_scope'", ")", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Add permission'", ")", ")", "->", "getForm", "(", ")", ";", "}" ]
creates a form to add a role scope to permissionsgroup @param PermissionsGroup $permissionsGroup @return \Symfony\Component\Form\Form The form
[ "creates", "a", "form", "to", "add", "a", "role", "scope", "to", "permissionsgroup" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L434-L444
19,291
aedart/laravel-helpers
src/Traits/Queue/QueueTrait.php
QueueTrait.getDefaultQueue
public function getDefaultQueue(): ?Queue { // By default, the Queue Facade does not return the // any actual database connection, but rather an // instance of \Illuminate\Queue\QueueManager. // Therefore, we make sure only to obtain its // "connection", to make sure that its only the connection // instance that we obtain. $manager = QueueFacade::getFacadeRoot(); if (isset($manager)) { return $manager->connection(); } return $manager; }
php
public function getDefaultQueue(): ?Queue { // By default, the Queue Facade does not return the // any actual database connection, but rather an // instance of \Illuminate\Queue\QueueManager. // Therefore, we make sure only to obtain its // "connection", to make sure that its only the connection // instance that we obtain. $manager = QueueFacade::getFacadeRoot(); if (isset($manager)) { return $manager->connection(); } return $manager; }
[ "public", "function", "getDefaultQueue", "(", ")", ":", "?", "Queue", "{", "// By default, the Queue Facade does not return the", "// any actual database connection, but rather an", "// instance of \\Illuminate\\Queue\\QueueManager.", "// Therefore, we make sure only to obtain its", "// \"connection\", to make sure that its only the connection", "// instance that we obtain.", "$", "manager", "=", "QueueFacade", "::", "getFacadeRoot", "(", ")", ";", "if", "(", "isset", "(", "$", "manager", ")", ")", "{", "return", "$", "manager", "->", "connection", "(", ")", ";", "}", "return", "$", "manager", ";", "}" ]
Get a default queue value, if any is available @return Queue|null A default queue value or Null if no default value is available
[ "Get", "a", "default", "queue", "value", "if", "any", "is", "available" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Queue/QueueTrait.php#L76-L89
19,292
SAREhub/PHP_Commons
src/SAREhub/Commons/Misc/SqliteHashStorage.php
SqliteHashStorage.insertMulti
public function insertMulti(array $hashes) { $valuesString = ''; foreach ($hashes as $id => $hash) { $valuesString .= "('$id','$hash'),"; } $this->storage->exec("INSERT INTO " . $this->tableName . "(id, hash) VALUES " . rtrim($valuesString, ',')); }
php
public function insertMulti(array $hashes) { $valuesString = ''; foreach ($hashes as $id => $hash) { $valuesString .= "('$id','$hash'),"; } $this->storage->exec("INSERT INTO " . $this->tableName . "(id, hash) VALUES " . rtrim($valuesString, ',')); }
[ "public", "function", "insertMulti", "(", "array", "$", "hashes", ")", "{", "$", "valuesString", "=", "''", ";", "foreach", "(", "$", "hashes", "as", "$", "id", "=>", "$", "hash", ")", "{", "$", "valuesString", ".=", "\"('$id','$hash'),\"", ";", "}", "$", "this", "->", "storage", "->", "exec", "(", "\"INSERT INTO \"", ".", "$", "this", "->", "tableName", ".", "\"(id, hash) VALUES \"", ".", "rtrim", "(", "$", "valuesString", ",", "','", ")", ")", ";", "}" ]
Inserts hashes in batch for better performance @param array $hashes 'id' => 'hash'
[ "Inserts", "hashes", "in", "batch", "for", "better", "performance" ]
4e1769ab6411a584112df1151dcc90e6b82fe2bb
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/SqliteHashStorage.php#L83-L91
19,293
SAREhub/PHP_Commons
src/SAREhub/Commons/Misc/SqliteHashStorage.php
SqliteHashStorage.updateMulti
public function updateMulti(array $hashes) { $startSql = "UPDATE " . $this->tableName; $this->storage->exec('BEGIN TRANSACTION'); foreach ($hashes as $id => $hash) { $this->storage->exec($startSql . " SET hash='$hash' WHERE id='$id'"); } $this->storage->exec('END TRANSACTION'); }
php
public function updateMulti(array $hashes) { $startSql = "UPDATE " . $this->tableName; $this->storage->exec('BEGIN TRANSACTION'); foreach ($hashes as $id => $hash) { $this->storage->exec($startSql . " SET hash='$hash' WHERE id='$id'"); } $this->storage->exec('END TRANSACTION'); }
[ "public", "function", "updateMulti", "(", "array", "$", "hashes", ")", "{", "$", "startSql", "=", "\"UPDATE \"", ".", "$", "this", "->", "tableName", ";", "$", "this", "->", "storage", "->", "exec", "(", "'BEGIN TRANSACTION'", ")", ";", "foreach", "(", "$", "hashes", "as", "$", "id", "=>", "$", "hash", ")", "{", "$", "this", "->", "storage", "->", "exec", "(", "$", "startSql", ".", "\" SET hash='$hash' WHERE id='$id'\"", ")", ";", "}", "$", "this", "->", "storage", "->", "exec", "(", "'END TRANSACTION'", ")", ";", "}" ]
Updating hashes in batch for better performance @param array $hashes 'id' => 'hash'
[ "Updating", "hashes", "in", "batch", "for", "better", "performance" ]
4e1769ab6411a584112df1151dcc90e6b82fe2bb
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/SqliteHashStorage.php#L97-L105
19,294
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Style.php
PHPWord_Style.addParagraphStyle
public static function addParagraphStyle($styleName, $styles) { if(!array_key_exists($styleName, self::$_styleElements)) { $style = new PHPWord_Style_Paragraph(); foreach($styles as $key => $value) { if(substr($key, 0, 1) != '_') { $key = '_'.$key; } $style->setStyleValue($key, $value); } self::$_styleElements[$styleName] = $style; } }
php
public static function addParagraphStyle($styleName, $styles) { if(!array_key_exists($styleName, self::$_styleElements)) { $style = new PHPWord_Style_Paragraph(); foreach($styles as $key => $value) { if(substr($key, 0, 1) != '_') { $key = '_'.$key; } $style->setStyleValue($key, $value); } self::$_styleElements[$styleName] = $style; } }
[ "public", "static", "function", "addParagraphStyle", "(", "$", "styleName", ",", "$", "styles", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "styleName", ",", "self", "::", "$", "_styleElements", ")", ")", "{", "$", "style", "=", "new", "PHPWord_Style_Paragraph", "(", ")", ";", "foreach", "(", "$", "styles", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "1", ")", "!=", "'_'", ")", "{", "$", "key", "=", "'_'", ".", "$", "key", ";", "}", "$", "style", "->", "setStyleValue", "(", "$", "key", ",", "$", "value", ")", ";", "}", "self", "::", "$", "_styleElements", "[", "$", "styleName", "]", "=", "$", "style", ";", "}", "}" ]
Add a paragraph style @param string $styleName @param array $styles
[ "Add", "a", "paragraph", "style" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L52-L64
19,295
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Style.php
PHPWord_Style.addFontStyle
public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) { if(!array_key_exists($styleName, self::$_styleElements)) { $font = new PHPWord_Style_Font('text', $styleParagraph); foreach($styleFont as $key => $value) { if(substr($key, 0, 1) != '_') { $key = '_'.$key; } $font->setStyleValue($key, $value); } self::$_styleElements[$styleName] = $font; } }
php
public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) { if(!array_key_exists($styleName, self::$_styleElements)) { $font = new PHPWord_Style_Font('text', $styleParagraph); foreach($styleFont as $key => $value) { if(substr($key, 0, 1) != '_') { $key = '_'.$key; } $font->setStyleValue($key, $value); } self::$_styleElements[$styleName] = $font; } }
[ "public", "static", "function", "addFontStyle", "(", "$", "styleName", ",", "$", "styleFont", ",", "$", "styleParagraph", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "styleName", ",", "self", "::", "$", "_styleElements", ")", ")", "{", "$", "font", "=", "new", "PHPWord_Style_Font", "(", "'text'", ",", "$", "styleParagraph", ")", ";", "foreach", "(", "$", "styleFont", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "1", ")", "!=", "'_'", ")", "{", "$", "key", "=", "'_'", ".", "$", "key", ";", "}", "$", "font", "->", "setStyleValue", "(", "$", "key", ",", "$", "value", ")", ";", "}", "self", "::", "$", "_styleElements", "[", "$", "styleName", "]", "=", "$", "font", ";", "}", "}" ]
Add a font style @param string $styleName @param array $styleFont @param array $styleParagraph
[ "Add", "a", "font", "style" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L73-L84
19,296
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Style.php
PHPWord_Style.addLinkStyle
public static function addLinkStyle($styleName, $styles) { if(!array_key_exists($styleName, self::$_styleElements)) { $style = new PHPWord_Style_Font('link'); foreach($styles as $key => $value) { if(substr($key, 0, 1) != '_') { $key = '_'.$key; } $style->setStyleValue($key, $value); } self::$_styleElements[$styleName] = $style; } }
php
public static function addLinkStyle($styleName, $styles) { if(!array_key_exists($styleName, self::$_styleElements)) { $style = new PHPWord_Style_Font('link'); foreach($styles as $key => $value) { if(substr($key, 0, 1) != '_') { $key = '_'.$key; } $style->setStyleValue($key, $value); } self::$_styleElements[$styleName] = $style; } }
[ "public", "static", "function", "addLinkStyle", "(", "$", "styleName", ",", "$", "styles", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "styleName", ",", "self", "::", "$", "_styleElements", ")", ")", "{", "$", "style", "=", "new", "PHPWord_Style_Font", "(", "'link'", ")", ";", "foreach", "(", "$", "styles", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "1", ")", "!=", "'_'", ")", "{", "$", "key", "=", "'_'", ".", "$", "key", ";", "}", "$", "style", "->", "setStyleValue", "(", "$", "key", ",", "$", "value", ")", ";", "}", "self", "::", "$", "_styleElements", "[", "$", "styleName", "]", "=", "$", "style", ";", "}", "}" ]
Add a link style @param string $styleName @param array $styles
[ "Add", "a", "link", "style" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L92-L104
19,297
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Style.php
PHPWord_Style.addTableStyle
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) { if(!array_key_exists($styleName, self::$_styleElements)) { $style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow); self::$_styleElements[$styleName] = $style; } }
php
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) { if(!array_key_exists($styleName, self::$_styleElements)) { $style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow); self::$_styleElements[$styleName] = $style; } }
[ "public", "static", "function", "addTableStyle", "(", "$", "styleName", ",", "$", "styleTable", ",", "$", "styleFirstRow", "=", "null", ",", "$", "styleLastRow", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "styleName", ",", "self", "::", "$", "_styleElements", ")", ")", "{", "$", "style", "=", "new", "PHPWord_Style_TableFull", "(", "$", "styleTable", ",", "$", "styleFirstRow", ",", "$", "styleLastRow", ")", ";", "self", "::", "$", "_styleElements", "[", "$", "styleName", "]", "=", "$", "style", ";", "}", "}" ]
Add a table style @param string $styleName @param array $styles
[ "Add", "a", "table", "style" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L112-L118
19,298
struzik-vladislav/php-error-handler
src/ErrorHandler.php
ErrorHandler.setProcessorsStack
public function setProcessorsStack(array $stack) { $this->processorsStack = []; foreach (array_reverse($stack) as $processor) { $this->pushProcessor($processor); } return $this; }
php
public function setProcessorsStack(array $stack) { $this->processorsStack = []; foreach (array_reverse($stack) as $processor) { $this->pushProcessor($processor); } return $this; }
[ "public", "function", "setProcessorsStack", "(", "array", "$", "stack", ")", "{", "$", "this", "->", "processorsStack", "=", "[", "]", ";", "foreach", "(", "array_reverse", "(", "$", "stack", ")", "as", "$", "processor", ")", "{", "$", "this", "->", "pushProcessor", "(", "$", "processor", ")", ";", "}", "return", "$", "this", ";", "}" ]
Setting the processors stack as array. @param ProcessorInterface[] $stack processors stack @return ErrorHandler
[ "Setting", "the", "processors", "stack", "as", "array", "." ]
87fa9f56edca7011f78e00659bb094b4fe713ebe
https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/ErrorHandler.php#L102-L110
19,299
webforge-labs/psc-cms
lib/Psc/CMS/Action.php
Action.getEntityMeta
public function getEntityMeta(EntityMetaProvider $entityMetaProvider = NULL) { if (!isset($this->entityMeta) && $this->type === self::SPECIFIC) { if (!isset($entityMetaProvider)) throw new \LogicException('Missing Parameter 1 (EntityMetaProvider) for '.__FUNCTION__); $this->entityMeta = $entityMetaProvider->getEntityMeta($this->entity->getEntityName()); } return $this->entityMeta; }
php
public function getEntityMeta(EntityMetaProvider $entityMetaProvider = NULL) { if (!isset($this->entityMeta) && $this->type === self::SPECIFIC) { if (!isset($entityMetaProvider)) throw new \LogicException('Missing Parameter 1 (EntityMetaProvider) for '.__FUNCTION__); $this->entityMeta = $entityMetaProvider->getEntityMeta($this->entity->getEntityName()); } return $this->entityMeta; }
[ "public", "function", "getEntityMeta", "(", "EntityMetaProvider", "$", "entityMetaProvider", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "entityMeta", ")", "&&", "$", "this", "->", "type", "===", "self", "::", "SPECIFIC", ")", "{", "if", "(", "!", "isset", "(", "$", "entityMetaProvider", ")", ")", "throw", "new", "\\", "LogicException", "(", "'Missing Parameter 1 (EntityMetaProvider) for '", ".", "__FUNCTION__", ")", ";", "$", "this", "->", "entityMeta", "=", "$", "entityMetaProvider", "->", "getEntityMeta", "(", "$", "this", "->", "entity", "->", "getEntityName", "(", ")", ")", ";", "}", "return", "$", "this", "->", "entityMeta", ";", "}" ]
Returns the EntityMeta for specific or general type Attention: When type is specific $dc is not optional! @return Psc\CMS\EntityMeta
[ "Returns", "the", "EntityMeta", "for", "specific", "or", "general", "type" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Action.php#L48-L56