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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
10,300 | phossa2/libs | src/Phossa2/Query/Traits/Clause/GroupTrait.php | GroupTrait.realGroup | protected function realGroup(
$col,
/*# sting */ $suffix = '',
/*# bool */ $rawMode = false
) {
if (is_array($col)) {
$this->multipleGroup($col, $suffix);
} else {
$clause = &$this->getClause('GROUP BY');
$part = [$col, $this->isRaw($col, $rawMode)];
if (!empty($suffix)) {
$part[] = $suffix;
}
$clause[] = $part;
}
return $this;
} | php | protected function realGroup(
$col,
/*# sting */ $suffix = '',
/*# bool */ $rawMode = false
) {
if (is_array($col)) {
$this->multipleGroup($col, $suffix);
} else {
$clause = &$this->getClause('GROUP BY');
$part = [$col, $this->isRaw($col, $rawMode)];
if (!empty($suffix)) {
$part[] = $suffix;
}
$clause[] = $part;
}
return $this;
} | [
"protected",
"function",
"realGroup",
"(",
"$",
"col",
",",
"/*# sting */",
"$",
"suffix",
"=",
"''",
",",
"/*# bool */",
"$",
"rawMode",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"col",
")",
")",
"{",
"$",
"this",
"->",
"multipleGroup",
"(",
"$",
"col",
",",
"$",
"suffix",
")",
";",
"}",
"else",
"{",
"$",
"clause",
"=",
"&",
"$",
"this",
"->",
"getClause",
"(",
"'GROUP BY'",
")",
";",
"$",
"part",
"=",
"[",
"$",
"col",
",",
"$",
"this",
"->",
"isRaw",
"(",
"$",
"col",
",",
"$",
"rawMode",
")",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"suffix",
")",
")",
"{",
"$",
"part",
"[",
"]",
"=",
"$",
"suffix",
";",
"}",
"$",
"clause",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | real group by
@param string|string[]|Template $col column[s]
@param string $suffix ''|ASC|DESC
@param bool $rawMode
@return $this
@access protected | [
"real",
"group",
"by"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/GroupTrait.php#L79-L96 |
10,301 | squire-assistant/finder | Glob.php | Glob.toRegex | public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
{
$firstByte = true;
$escaping = false;
$inCurlies = 0;
$regex = '';
$sizeGlob = strlen($glob);
for ($i = 0; $i < $sizeGlob; ++$i) {
$car = $glob[$i];
if ($firstByte) {
if ($strictLeadingDot && '.' !== $car) {
$regex .= '(?=[^\.])';
}
$firstByte = false;
}
if ('/' === $car) {
$firstByte = true;
}
if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
$regex .= "\\$car";
} elseif ('*' === $car) {
$regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
} elseif ('?' === $car) {
$regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
} elseif ('{' === $car) {
$regex .= $escaping ? '\\{' : '(';
if (!$escaping) {
++$inCurlies;
}
} elseif ('}' === $car && $inCurlies) {
$regex .= $escaping ? '}' : ')';
if (!$escaping) {
--$inCurlies;
}
} elseif (',' === $car && $inCurlies) {
$regex .= $escaping ? ',' : '|';
} elseif ('\\' === $car) {
if ($escaping) {
$regex .= '\\\\';
$escaping = false;
} else {
$escaping = true;
}
continue;
} else {
$regex .= $car;
}
$escaping = false;
}
return $delimiter.'^'.$regex.'$'.$delimiter;
} | php | public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
{
$firstByte = true;
$escaping = false;
$inCurlies = 0;
$regex = '';
$sizeGlob = strlen($glob);
for ($i = 0; $i < $sizeGlob; ++$i) {
$car = $glob[$i];
if ($firstByte) {
if ($strictLeadingDot && '.' !== $car) {
$regex .= '(?=[^\.])';
}
$firstByte = false;
}
if ('/' === $car) {
$firstByte = true;
}
if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
$regex .= "\\$car";
} elseif ('*' === $car) {
$regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
} elseif ('?' === $car) {
$regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
} elseif ('{' === $car) {
$regex .= $escaping ? '\\{' : '(';
if (!$escaping) {
++$inCurlies;
}
} elseif ('}' === $car && $inCurlies) {
$regex .= $escaping ? '}' : ')';
if (!$escaping) {
--$inCurlies;
}
} elseif (',' === $car && $inCurlies) {
$regex .= $escaping ? ',' : '|';
} elseif ('\\' === $car) {
if ($escaping) {
$regex .= '\\\\';
$escaping = false;
} else {
$escaping = true;
}
continue;
} else {
$regex .= $car;
}
$escaping = false;
}
return $delimiter.'^'.$regex.'$'.$delimiter;
} | [
"public",
"static",
"function",
"toRegex",
"(",
"$",
"glob",
",",
"$",
"strictLeadingDot",
"=",
"true",
",",
"$",
"strictWildcardSlash",
"=",
"true",
",",
"$",
"delimiter",
"=",
"'#'",
")",
"{",
"$",
"firstByte",
"=",
"true",
";",
"$",
"escaping",
"=",
"false",
";",
"$",
"inCurlies",
"=",
"0",
";",
"$",
"regex",
"=",
"''",
";",
"$",
"sizeGlob",
"=",
"strlen",
"(",
"$",
"glob",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"sizeGlob",
";",
"++",
"$",
"i",
")",
"{",
"$",
"car",
"=",
"$",
"glob",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"firstByte",
")",
"{",
"if",
"(",
"$",
"strictLeadingDot",
"&&",
"'.'",
"!==",
"$",
"car",
")",
"{",
"$",
"regex",
".=",
"'(?=[^\\.])'",
";",
"}",
"$",
"firstByte",
"=",
"false",
";",
"}",
"if",
"(",
"'/'",
"===",
"$",
"car",
")",
"{",
"$",
"firstByte",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"delimiter",
"===",
"$",
"car",
"||",
"'.'",
"===",
"$",
"car",
"||",
"'('",
"===",
"$",
"car",
"||",
"')'",
"===",
"$",
"car",
"||",
"'|'",
"===",
"$",
"car",
"||",
"'+'",
"===",
"$",
"car",
"||",
"'^'",
"===",
"$",
"car",
"||",
"'$'",
"===",
"$",
"car",
")",
"{",
"$",
"regex",
".=",
"\"\\\\$car\"",
";",
"}",
"elseif",
"(",
"'*'",
"===",
"$",
"car",
")",
"{",
"$",
"regex",
".=",
"$",
"escaping",
"?",
"'\\\\*'",
":",
"(",
"$",
"strictWildcardSlash",
"?",
"'[^/]*'",
":",
"'.*'",
")",
";",
"}",
"elseif",
"(",
"'?'",
"===",
"$",
"car",
")",
"{",
"$",
"regex",
".=",
"$",
"escaping",
"?",
"'\\\\?'",
":",
"(",
"$",
"strictWildcardSlash",
"?",
"'[^/]'",
":",
"'.'",
")",
";",
"}",
"elseif",
"(",
"'{'",
"===",
"$",
"car",
")",
"{",
"$",
"regex",
".=",
"$",
"escaping",
"?",
"'\\\\{'",
":",
"'('",
";",
"if",
"(",
"!",
"$",
"escaping",
")",
"{",
"++",
"$",
"inCurlies",
";",
"}",
"}",
"elseif",
"(",
"'}'",
"===",
"$",
"car",
"&&",
"$",
"inCurlies",
")",
"{",
"$",
"regex",
".=",
"$",
"escaping",
"?",
"'}'",
":",
"')'",
";",
"if",
"(",
"!",
"$",
"escaping",
")",
"{",
"--",
"$",
"inCurlies",
";",
"}",
"}",
"elseif",
"(",
"','",
"===",
"$",
"car",
"&&",
"$",
"inCurlies",
")",
"{",
"$",
"regex",
".=",
"$",
"escaping",
"?",
"','",
":",
"'|'",
";",
"}",
"elseif",
"(",
"'\\\\'",
"===",
"$",
"car",
")",
"{",
"if",
"(",
"$",
"escaping",
")",
"{",
"$",
"regex",
".=",
"'\\\\\\\\'",
";",
"$",
"escaping",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"escaping",
"=",
"true",
";",
"}",
"continue",
";",
"}",
"else",
"{",
"$",
"regex",
".=",
"$",
"car",
";",
"}",
"$",
"escaping",
"=",
"false",
";",
"}",
"return",
"$",
"delimiter",
".",
"'^'",
".",
"$",
"regex",
".",
"'$'",
".",
"$",
"delimiter",
";",
"}"
] | Returns a regexp which is the equivalent of the glob pattern.
@param string $glob The glob pattern
@param bool $strictLeadingDot
@param bool $strictWildcardSlash
@param string $delimiter Optional delimiter
@return string regex The regexp | [
"Returns",
"a",
"regexp",
"which",
"is",
"the",
"equivalent",
"of",
"the",
"glob",
"pattern",
"."
] | cc77a69d0cdb9d004fa5c116e81862b08326deee | https://github.com/squire-assistant/finder/blob/cc77a69d0cdb9d004fa5c116e81862b08326deee/Glob.php#L48-L103 |
10,302 | sios13/simox | src/Router/Router.php | Router._createRoute | private function _createRoute( $options )
{
$url = $this->_di->getService( "url" );
/**
* All route uris should have the uri prefix
*/
$options["uri"] = $url->getUriPrefix() . $options["uri"];
if (isset($options["controller_action"]))
{
$controller_action_exploded = explode( "#", $options["controller_action"] );
$options["controllerName"] = $controller_action_exploded[0];
$options["actionName"] = $controller_action_exploded[1];
}
// $uri = $settings["uri"];
//
// $controllerName = $settings["controllerName"];
//
// $actionName = $settings["actionName"];
//
// $params = $settigns["params"];
return new Route($options);
} | php | private function _createRoute( $options )
{
$url = $this->_di->getService( "url" );
/**
* All route uris should have the uri prefix
*/
$options["uri"] = $url->getUriPrefix() . $options["uri"];
if (isset($options["controller_action"]))
{
$controller_action_exploded = explode( "#", $options["controller_action"] );
$options["controllerName"] = $controller_action_exploded[0];
$options["actionName"] = $controller_action_exploded[1];
}
// $uri = $settings["uri"];
//
// $controllerName = $settings["controllerName"];
//
// $actionName = $settings["actionName"];
//
// $params = $settigns["params"];
return new Route($options);
} | [
"private",
"function",
"_createRoute",
"(",
"$",
"options",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_di",
"->",
"getService",
"(",
"\"url\"",
")",
";",
"/**\n * All route uris should have the uri prefix\n */",
"$",
"options",
"[",
"\"uri\"",
"]",
"=",
"$",
"url",
"->",
"getUriPrefix",
"(",
")",
".",
"$",
"options",
"[",
"\"uri\"",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"\"controller_action\"",
"]",
")",
")",
"{",
"$",
"controller_action_exploded",
"=",
"explode",
"(",
"\"#\"",
",",
"$",
"options",
"[",
"\"controller_action\"",
"]",
")",
";",
"$",
"options",
"[",
"\"controllerName\"",
"]",
"=",
"$",
"controller_action_exploded",
"[",
"0",
"]",
";",
"$",
"options",
"[",
"\"actionName\"",
"]",
"=",
"$",
"controller_action_exploded",
"[",
"1",
"]",
";",
"}",
"// $uri = $settings[\"uri\"];",
"//",
"// $controllerName = $settings[\"controllerName\"];",
"//",
"// $actionName = $settings[\"actionName\"];",
"//",
"// $params = $settigns[\"params\"];",
"return",
"new",
"Route",
"(",
"$",
"options",
")",
";",
"}"
] | Helper function to create a route | [
"Helper",
"function",
"to",
"create",
"a",
"route"
] | 8be964949ef179aba7eceb3fc6439815a1af2ad2 | https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Router/Router.php#L49-L75 |
10,303 | sios13/simox | src/Router/Router.php | Router.reverseRoute | public function reverseRoute( $controllerName, $actionName )
{
// Create a temp route because formatting
$tempRoute = new Route( ["controllerName" => $controllerName, "actionName" => $actionName] );
foreach ( $this->_routeDefinitions as $routeDefinition )
{
$route = call_user_func($routeDefinition);
if ( $tempRoute->getControllerName() == $route->getControllerName() && $tempRoute->getActionName() == $route->getActionName() )
{
return $route->getUri();
}
}
} | php | public function reverseRoute( $controllerName, $actionName )
{
// Create a temp route because formatting
$tempRoute = new Route( ["controllerName" => $controllerName, "actionName" => $actionName] );
foreach ( $this->_routeDefinitions as $routeDefinition )
{
$route = call_user_func($routeDefinition);
if ( $tempRoute->getControllerName() == $route->getControllerName() && $tempRoute->getActionName() == $route->getActionName() )
{
return $route->getUri();
}
}
} | [
"public",
"function",
"reverseRoute",
"(",
"$",
"controllerName",
",",
"$",
"actionName",
")",
"{",
"// Create a temp route because formatting",
"$",
"tempRoute",
"=",
"new",
"Route",
"(",
"[",
"\"controllerName\"",
"=>",
"$",
"controllerName",
",",
"\"actionName\"",
"=>",
"$",
"actionName",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_routeDefinitions",
"as",
"$",
"routeDefinition",
")",
"{",
"$",
"route",
"=",
"call_user_func",
"(",
"$",
"routeDefinition",
")",
";",
"if",
"(",
"$",
"tempRoute",
"->",
"getControllerName",
"(",
")",
"==",
"$",
"route",
"->",
"getControllerName",
"(",
")",
"&&",
"$",
"tempRoute",
"->",
"getActionName",
"(",
")",
"==",
"$",
"route",
"->",
"getActionName",
"(",
")",
")",
"{",
"return",
"$",
"route",
"->",
"getUri",
"(",
")",
";",
"}",
"}",
"}"
] | Returns a route uri given controller name and action name | [
"Returns",
"a",
"route",
"uri",
"given",
"controller",
"name",
"and",
"action",
"name"
] | 8be964949ef179aba7eceb3fc6439815a1af2ad2 | https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Router/Router.php#L104-L118 |
10,304 | sios13/simox | src/Router/Router.php | Router.handle | public function handle( $requestUri )
{
$url = $this->_di->getService( "url" );
/**
* Remove the uri prefix from the request uri
* (the uri prefix is added when route is created)
*/
$requestUri = str_replace( $url->getUriPrefix(), "", $requestUri );
$request_route = $this->_createRoute( ["uri" => $requestUri] );
/**
* Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
*/
//$request_route->setUri( $url->get( $request_route->getUri() ) );
$request_route_uri_fragments = explode( "/", $request_route->getUri() );
foreach ($this->_routeDefinitions as $routeDefinition)
{
$route = call_user_func($routeDefinition);
/**
* Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
*/
//$route->setUri( $url->get( $route->getUri() ) );
$route_uri_fragments = explode( "/", $route->getUri() );
/**
* Check if request uri and route uri has the same number of fragments.
* If not, continue to next route.
*/
if ( count($route_uri_fragments) != count($request_route_uri_fragments) )
{
continue;
}
$params = array();
/**
* Compare every fragment of the uris
*/
for ( $i = 0; $i < count($route_uri_fragments); $i++ )
{
/**
* Parameters are not compared
*/
if ( $route_uri_fragments[$i] == "{param}" )
{
$params[] = $request_route_uri_fragments[$i];
continue;
}
/**
* If a fragment is not equal -> continue to next route
*/
if ( $route_uri_fragments[$i] != $request_route_uri_fragments[$i] )
{
continue 2;
}
}
$route->setParams( $params );
/**
* We have a match!
*/
$this->_matchRoute = $route;
return;
}
/**
* No match :(
* If not found route has been set -> set as out match route
*/
if ( isset($this->_notFoundRoute) )
{
$this->_matchRoute = $this->_notFoundRoute;
return;
}
/**
* With no other options, we set the match route to a default route
*/
$this->_matchRoute = new Route();
} | php | public function handle( $requestUri )
{
$url = $this->_di->getService( "url" );
/**
* Remove the uri prefix from the request uri
* (the uri prefix is added when route is created)
*/
$requestUri = str_replace( $url->getUriPrefix(), "", $requestUri );
$request_route = $this->_createRoute( ["uri" => $requestUri] );
/**
* Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
*/
//$request_route->setUri( $url->get( $request_route->getUri() ) );
$request_route_uri_fragments = explode( "/", $request_route->getUri() );
foreach ($this->_routeDefinitions as $routeDefinition)
{
$route = call_user_func($routeDefinition);
/**
* Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
*/
//$route->setUri( $url->get( $route->getUri() ) );
$route_uri_fragments = explode( "/", $route->getUri() );
/**
* Check if request uri and route uri has the same number of fragments.
* If not, continue to next route.
*/
if ( count($route_uri_fragments) != count($request_route_uri_fragments) )
{
continue;
}
$params = array();
/**
* Compare every fragment of the uris
*/
for ( $i = 0; $i < count($route_uri_fragments); $i++ )
{
/**
* Parameters are not compared
*/
if ( $route_uri_fragments[$i] == "{param}" )
{
$params[] = $request_route_uri_fragments[$i];
continue;
}
/**
* If a fragment is not equal -> continue to next route
*/
if ( $route_uri_fragments[$i] != $request_route_uri_fragments[$i] )
{
continue 2;
}
}
$route->setParams( $params );
/**
* We have a match!
*/
$this->_matchRoute = $route;
return;
}
/**
* No match :(
* If not found route has been set -> set as out match route
*/
if ( isset($this->_notFoundRoute) )
{
$this->_matchRoute = $this->_notFoundRoute;
return;
}
/**
* With no other options, we set the match route to a default route
*/
$this->_matchRoute = new Route();
} | [
"public",
"function",
"handle",
"(",
"$",
"requestUri",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_di",
"->",
"getService",
"(",
"\"url\"",
")",
";",
"/**\n * Remove the uri prefix from the request uri\n * (the uri prefix is added when route is created)\n */",
"$",
"requestUri",
"=",
"str_replace",
"(",
"$",
"url",
"->",
"getUriPrefix",
"(",
")",
",",
"\"\"",
",",
"$",
"requestUri",
")",
";",
"$",
"request_route",
"=",
"$",
"this",
"->",
"_createRoute",
"(",
"[",
"\"uri\"",
"=>",
"$",
"requestUri",
"]",
")",
";",
"/**\n * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format\n */",
"//$request_route->setUri( $url->get( $request_route->getUri() ) );",
"$",
"request_route_uri_fragments",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"request_route",
"->",
"getUri",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_routeDefinitions",
"as",
"$",
"routeDefinition",
")",
"{",
"$",
"route",
"=",
"call_user_func",
"(",
"$",
"routeDefinition",
")",
";",
"/**\n * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format\n */",
"//$route->setUri( $url->get( $route->getUri() ) );",
"$",
"route_uri_fragments",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"route",
"->",
"getUri",
"(",
")",
")",
";",
"/**\n * Check if request uri and route uri has the same number of fragments.\n * If not, continue to next route.\n */",
"if",
"(",
"count",
"(",
"$",
"route_uri_fragments",
")",
"!=",
"count",
"(",
"$",
"request_route_uri_fragments",
")",
")",
"{",
"continue",
";",
"}",
"$",
"params",
"=",
"array",
"(",
")",
";",
"/**\n * Compare every fragment of the uris\n */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"route_uri_fragments",
")",
";",
"$",
"i",
"++",
")",
"{",
"/**\n * Parameters are not compared\n */",
"if",
"(",
"$",
"route_uri_fragments",
"[",
"$",
"i",
"]",
"==",
"\"{param}\"",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"request_route_uri_fragments",
"[",
"$",
"i",
"]",
";",
"continue",
";",
"}",
"/**\n * If a fragment is not equal -> continue to next route\n */",
"if",
"(",
"$",
"route_uri_fragments",
"[",
"$",
"i",
"]",
"!=",
"$",
"request_route_uri_fragments",
"[",
"$",
"i",
"]",
")",
"{",
"continue",
"2",
";",
"}",
"}",
"$",
"route",
"->",
"setParams",
"(",
"$",
"params",
")",
";",
"/**\n * We have a match!\n */",
"$",
"this",
"->",
"_matchRoute",
"=",
"$",
"route",
";",
"return",
";",
"}",
"/**\n * No match :(\n * If not found route has been set -> set as out match route\n */",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_notFoundRoute",
")",
")",
"{",
"$",
"this",
"->",
"_matchRoute",
"=",
"$",
"this",
"->",
"_notFoundRoute",
";",
"return",
";",
"}",
"/**\n * With no other options, we set the match route to a default route\n */",
"$",
"this",
"->",
"_matchRoute",
"=",
"new",
"Route",
"(",
")",
";",
"}"
] | Match a request uri with the route uris registered in this service | [
"Match",
"a",
"request",
"uri",
"with",
"the",
"route",
"uris",
"registered",
"in",
"this",
"service"
] | 8be964949ef179aba7eceb3fc6439815a1af2ad2 | https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Router/Router.php#L123-L213 |
10,305 | pdenis/osrc-client | src/Snide/Osrc/Client.php | Client.fetchUser | public function fetchUser(User $user)
{
$response = $this->getResponse(
sprintf('%s.json',
$user->getUsername()
)
);
return $this->hydrator->hydrate($user, $response);
} | php | public function fetchUser(User $user)
{
$response = $this->getResponse(
sprintf('%s.json',
$user->getUsername()
)
);
return $this->hydrator->hydrate($user, $response);
} | [
"public",
"function",
"fetchUser",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
"sprintf",
"(",
"'%s.json'",
",",
"$",
"user",
"->",
"getUsername",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"user",
",",
"$",
"response",
")",
";",
"}"
] | Fetch data from User URL
@param Model\User $user
@return Model\User | [
"Fetch",
"data",
"from",
"User",
"URL"
] | 6eaa15387d874e440a6136613ebb6d6f1d38523b | https://github.com/pdenis/osrc-client/blob/6eaa15387d874e440a6136613ebb6d6f1d38523b/src/Snide/Osrc/Client.php#L69-L78 |
10,306 | TonyBogdanov/dom-crawler | Field/ChoiceFormField.php | ChoiceFormField.buildOptionValue | private function buildOptionValue(\DOMElement $node): array
{
$option = array();
$defaultDefaultValue = 'select' === $this->node->nodeName ? '' : 'on';
$defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : $defaultDefaultValue;
$option['value'] = $node->hasAttribute('value') ? $node->getAttribute('value') : $defaultValue;
$option['disabled'] = $node->hasAttribute('disabled');
return $option;
} | php | private function buildOptionValue(\DOMElement $node): array
{
$option = array();
$defaultDefaultValue = 'select' === $this->node->nodeName ? '' : 'on';
$defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : $defaultDefaultValue;
$option['value'] = $node->hasAttribute('value') ? $node->getAttribute('value') : $defaultValue;
$option['disabled'] = $node->hasAttribute('disabled');
return $option;
} | [
"private",
"function",
"buildOptionValue",
"(",
"\\",
"DOMElement",
"$",
"node",
")",
":",
"array",
"{",
"$",
"option",
"=",
"array",
"(",
")",
";",
"$",
"defaultDefaultValue",
"=",
"'select'",
"===",
"$",
"this",
"->",
"node",
"->",
"nodeName",
"?",
"''",
":",
"'on'",
";",
"$",
"defaultValue",
"=",
"(",
"isset",
"(",
"$",
"node",
"->",
"nodeValue",
")",
"&&",
"!",
"empty",
"(",
"$",
"node",
"->",
"nodeValue",
")",
")",
"?",
"$",
"node",
"->",
"nodeValue",
":",
"$",
"defaultDefaultValue",
";",
"$",
"option",
"[",
"'value'",
"]",
"=",
"$",
"node",
"->",
"hasAttribute",
"(",
"'value'",
")",
"?",
"$",
"node",
"->",
"getAttribute",
"(",
"'value'",
")",
":",
"$",
"defaultValue",
";",
"$",
"option",
"[",
"'disabled'",
"]",
"=",
"$",
"node",
"->",
"hasAttribute",
"(",
"'disabled'",
")",
";",
"return",
"$",
"option",
";",
"}"
] | Returns option value with associated disabled flag. | [
"Returns",
"option",
"value",
"with",
"associated",
"disabled",
"flag",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Field/ChoiceFormField.php#L258-L268 |
10,307 | squire-assistant/console | Application.php | Application.findNamespace | public function findNamespace($namespace)
{
$allNamespaces = $this->getNamespaces();
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
$namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
if (empty($namespaces)) {
$message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
if (1 == count($alternatives)) {
$message .= "\n\nDid you mean this?\n ";
} else {
$message .= "\n\nDid you mean one of these?\n ";
}
$message .= implode("\n ", $alternatives);
}
throw new CommandNotFoundException($message, $alternatives);
}
$exact = in_array($namespace, $namespaces, true);
if (count($namespaces) > 1 && !$exact) {
throw new CommandNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
}
return $exact ? $namespace : reset($namespaces);
} | php | public function findNamespace($namespace)
{
$allNamespaces = $this->getNamespaces();
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
$namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
if (empty($namespaces)) {
$message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
if (1 == count($alternatives)) {
$message .= "\n\nDid you mean this?\n ";
} else {
$message .= "\n\nDid you mean one of these?\n ";
}
$message .= implode("\n ", $alternatives);
}
throw new CommandNotFoundException($message, $alternatives);
}
$exact = in_array($namespace, $namespaces, true);
if (count($namespaces) > 1 && !$exact) {
throw new CommandNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
}
return $exact ? $namespace : reset($namespaces);
} | [
"public",
"function",
"findNamespace",
"(",
"$",
"namespace",
")",
"{",
"$",
"allNamespaces",
"=",
"$",
"this",
"->",
"getNamespaces",
"(",
")",
";",
"$",
"expr",
"=",
"preg_replace_callback",
"(",
"'{([^:]+|)}'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"preg_quote",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
".",
"'[^:]*'",
";",
"}",
",",
"$",
"namespace",
")",
";",
"$",
"namespaces",
"=",
"preg_grep",
"(",
"'{^'",
".",
"$",
"expr",
".",
"'}'",
",",
"$",
"allNamespaces",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"namespaces",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'There are no commands defined in the \"%s\" namespace.'",
",",
"$",
"namespace",
")",
";",
"if",
"(",
"$",
"alternatives",
"=",
"$",
"this",
"->",
"findAlternatives",
"(",
"$",
"namespace",
",",
"$",
"allNamespaces",
")",
")",
"{",
"if",
"(",
"1",
"==",
"count",
"(",
"$",
"alternatives",
")",
")",
"{",
"$",
"message",
".=",
"\"\\n\\nDid you mean this?\\n \"",
";",
"}",
"else",
"{",
"$",
"message",
".=",
"\"\\n\\nDid you mean one of these?\\n \"",
";",
"}",
"$",
"message",
".=",
"implode",
"(",
"\"\\n \"",
",",
"$",
"alternatives",
")",
";",
"}",
"throw",
"new",
"CommandNotFoundException",
"(",
"$",
"message",
",",
"$",
"alternatives",
")",
";",
"}",
"$",
"exact",
"=",
"in_array",
"(",
"$",
"namespace",
",",
"$",
"namespaces",
",",
"true",
")",
";",
"if",
"(",
"count",
"(",
"$",
"namespaces",
")",
">",
"1",
"&&",
"!",
"$",
"exact",
")",
"{",
"throw",
"new",
"CommandNotFoundException",
"(",
"sprintf",
"(",
"\"The namespace \\\"%s\\\" is ambiguous.\\nDid you mean one of these?\\n%s\"",
",",
"$",
"namespace",
",",
"$",
"this",
"->",
"getAbbreviationSuggestions",
"(",
"array_values",
"(",
"$",
"namespaces",
")",
")",
")",
",",
"array_values",
"(",
"$",
"namespaces",
")",
")",
";",
"}",
"return",
"$",
"exact",
"?",
"$",
"namespace",
":",
"reset",
"(",
"$",
"namespaces",
")",
";",
"}"
] | Finds a registered namespace by a name or an abbreviation.
@param string $namespace A namespace or abbreviation to search for
@return string A registered namespace
@throws CommandNotFoundException When namespace is incorrect or ambiguous | [
"Finds",
"a",
"registered",
"namespace",
"by",
"a",
"name",
"or",
"an",
"abbreviation",
"."
] | 9e16b975a3b9403af52e2d1b465a625e8936076c | https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Application.php#L514-L542 |
10,308 | squire-assistant/console | Application.php | Application.getAbbreviations | public static function getAbbreviations($names)
{
$abbrevs = array();
foreach ($names as $name) {
for ($len = strlen($name); $len > 0; --$len) {
$abbrev = substr($name, 0, $len);
$abbrevs[$abbrev][] = $name;
}
}
return $abbrevs;
} | php | public static function getAbbreviations($names)
{
$abbrevs = array();
foreach ($names as $name) {
for ($len = strlen($name); $len > 0; --$len) {
$abbrev = substr($name, 0, $len);
$abbrevs[$abbrev][] = $name;
}
}
return $abbrevs;
} | [
"public",
"static",
"function",
"getAbbreviations",
"(",
"$",
"names",
")",
"{",
"$",
"abbrevs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"for",
"(",
"$",
"len",
"=",
"strlen",
"(",
"$",
"name",
")",
";",
"$",
"len",
">",
"0",
";",
"--",
"$",
"len",
")",
"{",
"$",
"abbrev",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"$",
"len",
")",
";",
"$",
"abbrevs",
"[",
"$",
"abbrev",
"]",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"return",
"$",
"abbrevs",
";",
"}"
] | Returns an array of possible abbreviations given a set of names.
@param array $names An array of names
@return array An array of abbreviations | [
"Returns",
"an",
"array",
"of",
"possible",
"abbreviations",
"given",
"a",
"set",
"of",
"names",
"."
] | 9e16b975a3b9403af52e2d1b465a625e8936076c | https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Application.php#L645-L656 |
10,309 | squire-assistant/console | Application.php | Application.getTerminalDimensions | public function getTerminalDimensions()
{
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED);
return array($this->terminal->getWidth(), $this->terminal->getHeight());
} | php | public function getTerminalDimensions()
{
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED);
return array($this->terminal->getWidth(), $this->terminal->getHeight());
} | [
"public",
"function",
"getTerminalDimensions",
"(",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.'",
",",
"__METHOD__",
")",
",",
"E_USER_DEPRECATED",
")",
";",
"return",
"array",
"(",
"$",
"this",
"->",
"terminal",
"->",
"getWidth",
"(",
")",
",",
"$",
"this",
"->",
"terminal",
"->",
"getHeight",
"(",
")",
")",
";",
"}"
] | Tries to figure out the terminal dimensions based on the current environment.
@return array Array containing width and height
@deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead. | [
"Tries",
"to",
"figure",
"out",
"the",
"terminal",
"dimensions",
"based",
"on",
"the",
"current",
"environment",
"."
] | 9e16b975a3b9403af52e2d1b465a625e8936076c | https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Application.php#L771-L776 |
10,310 | squire-assistant/console | Application.php | Application.setTerminalDimensions | public function setTerminalDimensions($width, $height)
{
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__), E_USER_DEPRECATED);
putenv('COLUMNS='.$width);
putenv('LINES='.$height);
return $this;
} | php | public function setTerminalDimensions($width, $height)
{
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__), E_USER_DEPRECATED);
putenv('COLUMNS='.$width);
putenv('LINES='.$height);
return $this;
} | [
"public",
"function",
"setTerminalDimensions",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.'",
",",
"__METHOD__",
")",
",",
"E_USER_DEPRECATED",
")",
";",
"putenv",
"(",
"'COLUMNS='",
".",
"$",
"width",
")",
";",
"putenv",
"(",
"'LINES='",
".",
"$",
"height",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets terminal dimensions.
Can be useful to force terminal dimensions for functional tests.
@param int $width The width
@param int $height The height
@return $this
@deprecated since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead. | [
"Sets",
"terminal",
"dimensions",
"."
] | 9e16b975a3b9403af52e2d1b465a625e8936076c | https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Application.php#L790-L798 |
10,311 | squire-assistant/console | Application.php | Application.doRunCommand | protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
foreach ($command->getHelperSet() as $helper) {
if ($helper instanceof InputAwareInterface) {
$helper->setInput($input);
}
}
if (null === $this->dispatcher) {
return $command->run($input, $output);
}
// bind before the console.command event, so the listeners have access to input options/arguments
try {
$command->mergeApplicationDefinition();
$input->bind($command->getDefinition());
} catch (ExceptionInterface $e) {
// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
}
$event = new ConsoleCommandEvent($command, $input, $output);
$e = null;
try {
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
if ($event->commandShouldRun()) {
$exitCode = $command->run($input, $output);
} else {
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (null !== $e) {
if ($this->dispatcher->hasListeners(ConsoleEvents::EXCEPTION)) {
$x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
$event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
if ($x !== $event->getException()) {
$e = $event->getException();
}
}
$event = new ConsoleErrorEvent($input, $output, $e, $command);
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
$e = $event->getError();
if (0 === $exitCode = $event->getExitCode()) {
$e = null;
}
}
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
if (null !== $e) {
throw $e;
}
return $event->getExitCode();
} | php | protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
foreach ($command->getHelperSet() as $helper) {
if ($helper instanceof InputAwareInterface) {
$helper->setInput($input);
}
}
if (null === $this->dispatcher) {
return $command->run($input, $output);
}
// bind before the console.command event, so the listeners have access to input options/arguments
try {
$command->mergeApplicationDefinition();
$input->bind($command->getDefinition());
} catch (ExceptionInterface $e) {
// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
}
$event = new ConsoleCommandEvent($command, $input, $output);
$e = null;
try {
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
if ($event->commandShouldRun()) {
$exitCode = $command->run($input, $output);
} else {
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (null !== $e) {
if ($this->dispatcher->hasListeners(ConsoleEvents::EXCEPTION)) {
$x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
$event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
if ($x !== $event->getException()) {
$e = $event->getException();
}
}
$event = new ConsoleErrorEvent($input, $output, $e, $command);
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
$e = $event->getError();
if (0 === $exitCode = $event->getExitCode()) {
$e = null;
}
}
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
if (null !== $e) {
throw $e;
}
return $event->getExitCode();
} | [
"protected",
"function",
"doRunCommand",
"(",
"Command",
"$",
"command",
",",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"foreach",
"(",
"$",
"command",
"->",
"getHelperSet",
"(",
")",
"as",
"$",
"helper",
")",
"{",
"if",
"(",
"$",
"helper",
"instanceof",
"InputAwareInterface",
")",
"{",
"$",
"helper",
"->",
"setInput",
"(",
"$",
"input",
")",
";",
"}",
"}",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"dispatcher",
")",
"{",
"return",
"$",
"command",
"->",
"run",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}",
"// bind before the console.command event, so the listeners have access to input options/arguments",
"try",
"{",
"$",
"command",
"->",
"mergeApplicationDefinition",
"(",
")",
";",
"$",
"input",
"->",
"bind",
"(",
"$",
"command",
"->",
"getDefinition",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ExceptionInterface",
"$",
"e",
")",
"{",
"// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition",
"}",
"$",
"event",
"=",
"new",
"ConsoleCommandEvent",
"(",
"$",
"command",
",",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"e",
"=",
"null",
";",
"try",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"ConsoleEvents",
"::",
"COMMAND",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"commandShouldRun",
"(",
")",
")",
"{",
"$",
"exitCode",
"=",
"$",
"command",
"->",
"run",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}",
"else",
"{",
"$",
"exitCode",
"=",
"ConsoleCommandEvent",
"::",
"RETURN_CODE_DISABLED",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"}",
"if",
"(",
"null",
"!==",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dispatcher",
"->",
"hasListeners",
"(",
"ConsoleEvents",
"::",
"EXCEPTION",
")",
")",
"{",
"$",
"x",
"=",
"$",
"e",
"instanceof",
"\\",
"Exception",
"?",
"$",
"e",
":",
"new",
"FatalThrowableError",
"(",
"$",
"e",
")",
";",
"$",
"event",
"=",
"new",
"ConsoleExceptionEvent",
"(",
"$",
"command",
",",
"$",
"input",
",",
"$",
"output",
",",
"$",
"x",
",",
"$",
"x",
"->",
"getCode",
"(",
")",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"ConsoleEvents",
"::",
"EXCEPTION",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"x",
"!==",
"$",
"event",
"->",
"getException",
"(",
")",
")",
"{",
"$",
"e",
"=",
"$",
"event",
"->",
"getException",
"(",
")",
";",
"}",
"}",
"$",
"event",
"=",
"new",
"ConsoleErrorEvent",
"(",
"$",
"input",
",",
"$",
"output",
",",
"$",
"e",
",",
"$",
"command",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"ConsoleEvents",
"::",
"ERROR",
",",
"$",
"event",
")",
";",
"$",
"e",
"=",
"$",
"event",
"->",
"getError",
"(",
")",
";",
"if",
"(",
"0",
"===",
"$",
"exitCode",
"=",
"$",
"event",
"->",
"getExitCode",
"(",
")",
")",
"{",
"$",
"e",
"=",
"null",
";",
"}",
"}",
"$",
"event",
"=",
"new",
"ConsoleTerminateEvent",
"(",
"$",
"command",
",",
"$",
"input",
",",
"$",
"output",
",",
"$",
"exitCode",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"ConsoleEvents",
"::",
"TERMINATE",
",",
"$",
"event",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"event",
"->",
"getExitCode",
"(",
")",
";",
"}"
] | Runs the current command.
If an event dispatcher has been attached to the application,
events are also dispatched during the life-cycle of the command.
@param Command $command A Command instance
@param InputInterface $input An Input instance
@param OutputInterface $output An Output instance
@return int 0 if everything went fine, or an error code | [
"Runs",
"the",
"current",
"command",
"."
] | 9e16b975a3b9403af52e2d1b465a625e8936076c | https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Application.php#L860-L921 |
10,312 | squire-assistant/console | Application.php | Application.extractAllNamespaces | private function extractAllNamespaces($name)
{
// -1 as third argument is needed to skip the command short name when exploding
$parts = explode(':', $name, -1);
$namespaces = array();
foreach ($parts as $part) {
if (count($namespaces)) {
$namespaces[] = end($namespaces).':'.$part;
} else {
$namespaces[] = $part;
}
}
return $namespaces;
} | php | private function extractAllNamespaces($name)
{
// -1 as third argument is needed to skip the command short name when exploding
$parts = explode(':', $name, -1);
$namespaces = array();
foreach ($parts as $part) {
if (count($namespaces)) {
$namespaces[] = end($namespaces).':'.$part;
} else {
$namespaces[] = $part;
}
}
return $namespaces;
} | [
"private",
"function",
"extractAllNamespaces",
"(",
"$",
"name",
")",
"{",
"// -1 as third argument is needed to skip the command short name when exploding",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"name",
",",
"-",
"1",
")",
";",
"$",
"namespaces",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"namespaces",
")",
")",
"{",
"$",
"namespaces",
"[",
"]",
"=",
"end",
"(",
"$",
"namespaces",
")",
".",
"':'",
".",
"$",
"part",
";",
"}",
"else",
"{",
"$",
"namespaces",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"}",
"return",
"$",
"namespaces",
";",
"}"
] | Returns all namespaces of the command name.
@param string $name The full name of the command
@return string[] The namespaces of the command | [
"Returns",
"all",
"namespaces",
"of",
"the",
"command",
"name",
"."
] | 9e16b975a3b9403af52e2d1b465a625e8936076c | https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Application.php#L1121-L1136 |
10,313 | phplegends/routes | src/UrlGenerator.php | UrlGenerator.action | public function action($action, $parameters = [], array $query = [])
{
$callback = function (Route $route) use ($action) {
return $route->getActionName() === $action && $route->acceptedVerb('GET');
};
$route = $this->getRouteCollection()->firstOrFail($callback);
return $this->to($route->toUri((array) $parameters), $query);
} | php | public function action($action, $parameters = [], array $query = [])
{
$callback = function (Route $route) use ($action) {
return $route->getActionName() === $action && $route->acceptedVerb('GET');
};
$route = $this->getRouteCollection()->firstOrFail($callback);
return $this->to($route->toUri((array) $parameters), $query);
} | [
"public",
"function",
"action",
"(",
"$",
"action",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"callback",
"=",
"function",
"(",
"Route",
"$",
"route",
")",
"use",
"(",
"$",
"action",
")",
"{",
"return",
"$",
"route",
"->",
"getActionName",
"(",
")",
"===",
"$",
"action",
"&&",
"$",
"route",
"->",
"acceptedVerb",
"(",
"'GET'",
")",
";",
"}",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"getRouteCollection",
"(",
")",
"->",
"firstOrFail",
"(",
"$",
"callback",
")",
";",
"return",
"$",
"this",
"->",
"to",
"(",
"$",
"route",
"->",
"toUri",
"(",
"(",
"array",
")",
"$",
"parameters",
")",
",",
"$",
"query",
")",
";",
"}"
] | Generate url via string action
@param string $action
@param string|array $parameters
@param array $query | [
"Generate",
"url",
"via",
"string",
"action"
] | 7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec | https://github.com/phplegends/routes/blob/7b571362c4d9b190ad51bc5e8c4d96bfd03f31ec/src/UrlGenerator.php#L81-L91 |
10,314 | ntentan/ntentan | src/Router.php | Router.route | public function route($route, $prefix = null)
{
$this->route = substr($route, strlen($prefix));
$parameters = [];
// Go through predefined routes till a match is found
foreach ($this->routeOrder as $routeName) {
$routeDescription = $this->routes[$routeName];
$parameters = $this->match($this->route, $routeDescription);
if ($parameters !== false) {
return [
'route' => $this->route,
'parameters' => $this->fillInDefaultParameters($routeDescription, $parameters),
'description' => $routeDescription
];
}
}
return [
'route' => $this->route,
'parameters' => $parameters,
'description' => $this->routes['default']
];
} | php | public function route($route, $prefix = null)
{
$this->route = substr($route, strlen($prefix));
$parameters = [];
// Go through predefined routes till a match is found
foreach ($this->routeOrder as $routeName) {
$routeDescription = $this->routes[$routeName];
$parameters = $this->match($this->route, $routeDescription);
if ($parameters !== false) {
return [
'route' => $this->route,
'parameters' => $this->fillInDefaultParameters($routeDescription, $parameters),
'description' => $routeDescription
];
}
}
return [
'route' => $this->route,
'parameters' => $parameters,
'description' => $this->routes['default']
];
} | [
"public",
"function",
"route",
"(",
"$",
"route",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"route",
"=",
"substr",
"(",
"$",
"route",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
";",
"$",
"parameters",
"=",
"[",
"]",
";",
"// Go through predefined routes till a match is found",
"foreach",
"(",
"$",
"this",
"->",
"routeOrder",
"as",
"$",
"routeName",
")",
"{",
"$",
"routeDescription",
"=",
"$",
"this",
"->",
"routes",
"[",
"$",
"routeName",
"]",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"match",
"(",
"$",
"this",
"->",
"route",
",",
"$",
"routeDescription",
")",
";",
"if",
"(",
"$",
"parameters",
"!==",
"false",
")",
"{",
"return",
"[",
"'route'",
"=>",
"$",
"this",
"->",
"route",
",",
"'parameters'",
"=>",
"$",
"this",
"->",
"fillInDefaultParameters",
"(",
"$",
"routeDescription",
",",
"$",
"parameters",
")",
",",
"'description'",
"=>",
"$",
"routeDescription",
"]",
";",
"}",
"}",
"return",
"[",
"'route'",
"=>",
"$",
"this",
"->",
"route",
",",
"'parameters'",
"=>",
"$",
"parameters",
",",
"'description'",
"=>",
"$",
"this",
"->",
"routes",
"[",
"'default'",
"]",
"]",
";",
"}"
] | Invoke the router to load a route.
@param string $route
@param string $prefix
@return array | [
"Invoke",
"the",
"router",
"to",
"load",
"a",
"route",
"."
] | a6e89de5999bfafe5be9152bcd51ecfef3e928fb | https://github.com/ntentan/ntentan/blob/a6e89de5999bfafe5be9152bcd51ecfef3e928fb/src/Router.php#L45-L67 |
10,315 | RhubarbPHP/Module.Leaf.CommonControls | src/SelectionControls/RadioButtons/RadioButtons.php | RadioButtons.getIndividualRadioButtonHtml | public function getIndividualRadioButtonHtml($value)
{
return $this->view->getInputHtml($this->model->leafPath, $value, null);
} | php | public function getIndividualRadioButtonHtml($value)
{
return $this->view->getInputHtml($this->model->leafPath, $value, null);
} | [
"public",
"function",
"getIndividualRadioButtonHtml",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"view",
"->",
"getInputHtml",
"(",
"$",
"this",
"->",
"model",
"->",
"leafPath",
",",
"$",
"value",
",",
"null",
")",
";",
"}"
] | Call this from a hosting view to get a single radio button presented.
Used when a custom layout of radio buttons is required.
@param $value
@return mixed | [
"Call",
"this",
"from",
"a",
"hosting",
"view",
"to",
"get",
"a",
"single",
"radio",
"button",
"presented",
"."
] | fd12390c470304a436ebd78f315e29af7552cc15 | https://github.com/RhubarbPHP/Module.Leaf.CommonControls/blob/fd12390c470304a436ebd78f315e29af7552cc15/src/SelectionControls/RadioButtons/RadioButtons.php#L43-L46 |
10,316 | bkdotcom/Form | src/Persist.php | Persist.appendPages | public function appendPages($pages = array())
{
$iCur = $this->data['i'];
if (isset($this->data['pages'][$iCur])) {
$pageCount = \count($this->data['pages']);
$range = \range($pageCount, $pageCount+\count($pages)-1);
$this->data['pages'][$iCur]['addPages'] = \array_merge($this->data['pages'][$iCur]['addPages'], $range);
}
foreach ($pages as $pageName) {
$this->data['pages'][] = array(
'name' => $pageName,
'completed' => false,
'values' => array(),
'addPages' => array(),
);
}
} | php | public function appendPages($pages = array())
{
$iCur = $this->data['i'];
if (isset($this->data['pages'][$iCur])) {
$pageCount = \count($this->data['pages']);
$range = \range($pageCount, $pageCount+\count($pages)-1);
$this->data['pages'][$iCur]['addPages'] = \array_merge($this->data['pages'][$iCur]['addPages'], $range);
}
foreach ($pages as $pageName) {
$this->data['pages'][] = array(
'name' => $pageName,
'completed' => false,
'values' => array(),
'addPages' => array(),
);
}
} | [
"public",
"function",
"appendPages",
"(",
"$",
"pages",
"=",
"array",
"(",
")",
")",
"{",
"$",
"iCur",
"=",
"$",
"this",
"->",
"data",
"[",
"'i'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'pages'",
"]",
"[",
"$",
"iCur",
"]",
")",
")",
"{",
"$",
"pageCount",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"data",
"[",
"'pages'",
"]",
")",
";",
"$",
"range",
"=",
"\\",
"range",
"(",
"$",
"pageCount",
",",
"$",
"pageCount",
"+",
"\\",
"count",
"(",
"$",
"pages",
")",
"-",
"1",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'pages'",
"]",
"[",
"$",
"iCur",
"]",
"[",
"'addPages'",
"]",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"data",
"[",
"'pages'",
"]",
"[",
"$",
"iCur",
"]",
"[",
"'addPages'",
"]",
",",
"$",
"range",
")",
";",
"}",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"pageName",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'pages'",
"]",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"pageName",
",",
"'completed'",
"=>",
"false",
",",
"'values'",
"=>",
"array",
"(",
")",
",",
"'addPages'",
"=>",
"array",
"(",
")",
",",
")",
";",
"}",
"}"
] | Append additional pages to the end
@param array $pages array/list of page names
@return void | [
"Append",
"additional",
"pages",
"to",
"the",
"end"
] | 6aa5704b20300e1c8bd1c187a4fa88db9d442cee | https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Persist.php#L185-L201 |
10,317 | bkdotcom/Form | src/Persist.php | Persist.remove | public function remove()
{
$this->debug->groupCollapsed(__METHOD__);
$name = $this->data['name'];
$this->trashCollectFiles($this->data);
$this->data = array();
unset($_SESSION['form_persist'][$name]);
if (empty($_SESSION['form_persist'])) {
unset($_SESSION['form_persist']);
}
$this->debug->groupEnd();
} | php | public function remove()
{
$this->debug->groupCollapsed(__METHOD__);
$name = $this->data['name'];
$this->trashCollectFiles($this->data);
$this->data = array();
unset($_SESSION['form_persist'][$name]);
if (empty($_SESSION['form_persist'])) {
unset($_SESSION['form_persist']);
}
$this->debug->groupEnd();
} | [
"public",
"function",
"remove",
"(",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__METHOD__",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"data",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"trashCollectFiles",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"data",
"=",
"array",
"(",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
"[",
"$",
"name",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"}"
] | remove current form's perist data
@return void | [
"remove",
"current",
"form",
"s",
"perist",
"data"
] | 6aa5704b20300e1c8bd1c187a4fa88db9d442cee | https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Persist.php#L230-L241 |
10,318 | bkdotcom/Form | src/Persist.php | Persist.trashCollect | public function trashCollect()
{
$this->debug->groupCollapsed(__METHOD__);
// $cfg = $this->cfg;
$tsNow = \microtime(true);
// $this->debug->log('this->data', $this->data);
if (isset($_SESSION['form_persist']) && \is_array($_SESSION['form_persist'])) {
foreach ($_SESSION['form_persist'] as $formName => $data) {
if (!isset($data['ver'])) {
continue;
}
$tsDiff = $tsNow - $data['timestamp'];
$this->debug->log($formName.' created '.\number_format($tsDiff, 4).' sec ago');
// && ( empty($_SERVER['HTTP_USER_AGENT']) || \strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') )
/*
primarily a Safari issue
<img src="" />, imgNode.setAttribute('src', ''), etc
will get interepreted as <img src=" {request_uri} " />...
these requests can be seen in the browser's development console and network requests as
"Resource interpreted as Image but transferred with MIME type text/html."
which will effectevely come in as a GET request after the page is loaded.
this GET request will end up here triggering trash collection!!
*/
$remove = false;
if (isset($this->data['name']) && $formName == $this->data['name']) {
$this->debug->warn('not trashing current form');
continue;
} elseif ($data['trashCollectable'] && $tsDiff > 10) {
$remove = true;
}
if ($remove) {
$this->debug->warn('removing', $formName);
$this->trashCollectFiles($data);
unset($_SESSION['form_persist'][$formName]);
}
}
}
if (empty($_SESSION['form_persist'])) {
unset($_SESSION['form_persist']);
}
$this->debug->groupEnd();
} | php | public function trashCollect()
{
$this->debug->groupCollapsed(__METHOD__);
// $cfg = $this->cfg;
$tsNow = \microtime(true);
// $this->debug->log('this->data', $this->data);
if (isset($_SESSION['form_persist']) && \is_array($_SESSION['form_persist'])) {
foreach ($_SESSION['form_persist'] as $formName => $data) {
if (!isset($data['ver'])) {
continue;
}
$tsDiff = $tsNow - $data['timestamp'];
$this->debug->log($formName.' created '.\number_format($tsDiff, 4).' sec ago');
// && ( empty($_SERVER['HTTP_USER_AGENT']) || \strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') )
/*
primarily a Safari issue
<img src="" />, imgNode.setAttribute('src', ''), etc
will get interepreted as <img src=" {request_uri} " />...
these requests can be seen in the browser's development console and network requests as
"Resource interpreted as Image but transferred with MIME type text/html."
which will effectevely come in as a GET request after the page is loaded.
this GET request will end up here triggering trash collection!!
*/
$remove = false;
if (isset($this->data['name']) && $formName == $this->data['name']) {
$this->debug->warn('not trashing current form');
continue;
} elseif ($data['trashCollectable'] && $tsDiff > 10) {
$remove = true;
}
if ($remove) {
$this->debug->warn('removing', $formName);
$this->trashCollectFiles($data);
unset($_SESSION['form_persist'][$formName]);
}
}
}
if (empty($_SESSION['form_persist'])) {
unset($_SESSION['form_persist']);
}
$this->debug->groupEnd();
} | [
"public",
"function",
"trashCollect",
"(",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__METHOD__",
")",
";",
"// $cfg = $this->cfg;",
"$",
"tsNow",
"=",
"\\",
"microtime",
"(",
"true",
")",
";",
"// $this->debug->log('this->data', $this->data);",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
"as",
"$",
"formName",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'ver'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"tsDiff",
"=",
"$",
"tsNow",
"-",
"$",
"data",
"[",
"'timestamp'",
"]",
";",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"$",
"formName",
".",
"' created '",
".",
"\\",
"number_format",
"(",
"$",
"tsDiff",
",",
"4",
")",
".",
"' sec ago'",
")",
";",
"// && ( empty($_SERVER['HTTP_USER_AGENT']) || \\strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') )",
"/*\n primarily a Safari issue\n <img src=\"\" />, imgNode.setAttribute('src', ''), etc\n will get interepreted as <img src=\" {request_uri} \" />...\n these requests can be seen in the browser's development console and network requests as\n \"Resource interpreted as Image but transferred with MIME type text/html.\"\n which will effectevely come in as a GET request after the page is loaded.\n this GET request will end up here triggering trash collection!!\n */",
"$",
"remove",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'name'",
"]",
")",
"&&",
"$",
"formName",
"==",
"$",
"this",
"->",
"data",
"[",
"'name'",
"]",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"warn",
"(",
"'not trashing current form'",
")",
";",
"continue",
";",
"}",
"elseif",
"(",
"$",
"data",
"[",
"'trashCollectable'",
"]",
"&&",
"$",
"tsDiff",
">",
"10",
")",
"{",
"$",
"remove",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"remove",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"warn",
"(",
"'removing'",
",",
"$",
"formName",
")",
";",
"$",
"this",
"->",
"trashCollectFiles",
"(",
"$",
"data",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
"[",
"$",
"formName",
"]",
")",
";",
"}",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"_SESSION",
"[",
"'form_persist'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"}"
] | Remove session data
@return void | [
"Remove",
"session",
"data"
] | 6aa5704b20300e1c8bd1c187a4fa88db9d442cee | https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Persist.php#L248-L289 |
10,319 | bkdotcom/Form | src/Persist.php | Persist.trashCollectFiles | private function trashCollectFiles($data = null)
{
$this->debug->groupCollapsed(__METHOD__);
$data = isset($data)
? $data
: $this->data;
foreach ($data['pages'] as $info) {
foreach ($info['values'] as $a) {
if (\is_array($a) && !empty($a['tmp_name']) && \file_exists($a['tmp_name'])) {
$this->debug->log('deleting '.$a['tmp_name']);
\unlink($a['tmp_name']);
}
}
}
$this->debug->groupEnd();
return;
} | php | private function trashCollectFiles($data = null)
{
$this->debug->groupCollapsed(__METHOD__);
$data = isset($data)
? $data
: $this->data;
foreach ($data['pages'] as $info) {
foreach ($info['values'] as $a) {
if (\is_array($a) && !empty($a['tmp_name']) && \file_exists($a['tmp_name'])) {
$this->debug->log('deleting '.$a['tmp_name']);
\unlink($a['tmp_name']);
}
}
}
$this->debug->groupEnd();
return;
} | [
"private",
"function",
"trashCollectFiles",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__METHOD__",
")",
";",
"$",
"data",
"=",
"isset",
"(",
"$",
"data",
")",
"?",
"$",
"data",
":",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"$",
"data",
"[",
"'pages'",
"]",
"as",
"$",
"info",
")",
"{",
"foreach",
"(",
"$",
"info",
"[",
"'values'",
"]",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"a",
")",
"&&",
"!",
"empty",
"(",
"$",
"a",
"[",
"'tmp_name'",
"]",
")",
"&&",
"\\",
"file_exists",
"(",
"$",
"a",
"[",
"'tmp_name'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'deleting '",
".",
"$",
"a",
"[",
"'tmp_name'",
"]",
")",
";",
"\\",
"unlink",
"(",
"$",
"a",
"[",
"'tmp_name'",
"]",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
";",
"}"
] | remove temporary upload files
@param array $data persist data
@return void | [
"remove",
"temporary",
"upload",
"files"
] | 6aa5704b20300e1c8bd1c187a4fa88db9d442cee | https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Persist.php#L298-L314 |
10,320 | arkanmgerges/multi-tier-architecture | src/MultiTierArchitecture/Library/Pagination/Limit.php | Limit.getItems | public function getItems()
{
if (count($this->items) > $this->itemsPerPage) {
$items = [];
$counter = 0;
foreach ($this->items as $key => $value) {
$items[$key] = $value;
$counter++;
if ($counter == $this->itemsPerPage) {
return $items;
}
}
}
return $this->items;
} | php | public function getItems()
{
if (count($this->items) > $this->itemsPerPage) {
$items = [];
$counter = 0;
foreach ($this->items as $key => $value) {
$items[$key] = $value;
$counter++;
if ($counter == $this->itemsPerPage) {
return $items;
}
}
}
return $this->items;
} | [
"public",
"function",
"getItems",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"items",
")",
">",
"$",
"this",
"->",
"itemsPerPage",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"$",
"counter",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"items",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"counter",
"++",
";",
"if",
"(",
"$",
"counter",
"==",
"$",
"this",
"->",
"itemsPerPage",
")",
"{",
"return",
"$",
"items",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"items",
";",
"}"
] | Get all the items that are set for this pagination
@return array|null | [
"Get",
"all",
"the",
"items",
"that",
"are",
"set",
"for",
"this",
"pagination"
] | e8729841db66de7de0bdc9ed79ab73fe2bc262c0 | https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Library/Pagination/Limit.php#L50-L65 |
10,321 | arkanmgerges/multi-tier-architecture | src/MultiTierArchitecture/Library/Pagination/Limit.php | Limit.getTotalPages | public function getTotalPages()
{
if ($this->totalItems > 0 && $this->itemsPerPage > 0) {
if (($this->totalItems%$this->itemsPerPage) != 0) {
return (int)($this->totalItems/$this->itemsPerPage) + 1;
}
else {
return (int)($this->totalItems/$this->itemsPerPage);
}
}
return 0;
} | php | public function getTotalPages()
{
if ($this->totalItems > 0 && $this->itemsPerPage > 0) {
if (($this->totalItems%$this->itemsPerPage) != 0) {
return (int)($this->totalItems/$this->itemsPerPage) + 1;
}
else {
return (int)($this->totalItems/$this->itemsPerPage);
}
}
return 0;
} | [
"public",
"function",
"getTotalPages",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"totalItems",
">",
"0",
"&&",
"$",
"this",
"->",
"itemsPerPage",
">",
"0",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"totalItems",
"%",
"$",
"this",
"->",
"itemsPerPage",
")",
"!=",
"0",
")",
"{",
"return",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"totalItems",
"/",
"$",
"this",
"->",
"itemsPerPage",
")",
"+",
"1",
";",
"}",
"else",
"{",
"return",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"totalItems",
"/",
"$",
"this",
"->",
"itemsPerPage",
")",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Get total number of pages
@return int | [
"Get",
"total",
"number",
"of",
"pages"
] | e8729841db66de7de0bdc9ed79ab73fe2bc262c0 | https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Library/Pagination/Limit.php#L196-L208 |
10,322 | stubbles/stubbles-values | src/main/php/ModifiableProperties.php | ModifiableProperties.setSection | public function setSection(string $section, array $data): self
{
$this->propertyData[$section] = $data;
return $this;
} | php | public function setSection(string $section, array $data): self
{
$this->propertyData[$section] = $data;
return $this;
} | [
"public",
"function",
"setSection",
"(",
"string",
"$",
"section",
",",
"array",
"$",
"data",
")",
":",
"self",
"{",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
"=",
"$",
"data",
";",
"return",
"$",
"this",
";",
"}"
] | sets a section
If a section with this name already exists it will be replaced.
@api
@param string $section
@param array $data
@return \stubbles\values\ModifiableProperties | [
"sets",
"a",
"section"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/ModifiableProperties.php#L29-L33 |
10,323 | stubbles/stubbles-values | src/main/php/ModifiableProperties.php | ModifiableProperties.setValue | public function setValue(string $section, string $name, $value): self
{
if (!isset($this->propertyData[$section])) {
$this->propertyData[$section] = [];
}
$this->propertyData[$section][$name] = (string) $value;
return $this;
} | php | public function setValue(string $section, string $name, $value): self
{
if (!isset($this->propertyData[$section])) {
$this->propertyData[$section] = [];
}
$this->propertyData[$section][$name] = (string) $value;
return $this;
} | [
"public",
"function",
"setValue",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"self",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
")",
")",
"{",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"propertyData",
"[",
"$",
"section",
"]",
"[",
"$",
"name",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | sets value of property in given section
If a property with this name in the given section already exists it will
be replaced.
@api
@param string $section
@param string $name
@param mixed $value
@return \stubbles\values\ModifiableProperties | [
"sets",
"value",
"of",
"property",
"in",
"given",
"section"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/ModifiableProperties.php#L47-L55 |
10,324 | stubbles/stubbles-values | src/main/php/ModifiableProperties.php | ModifiableProperties.setBooleanValue | public function setBooleanValue(string $section, string $name, $value): self
{
return $this->setValue($section, $name, ((true === $value) ? ('true') : ('false')));
} | php | public function setBooleanValue(string $section, string $name, $value): self
{
return $this->setValue($section, $name, ((true === $value) ? ('true') : ('false')));
} | [
"public",
"function",
"setBooleanValue",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"setValue",
"(",
"$",
"section",
",",
"$",
"name",
",",
"(",
"(",
"true",
"===",
"$",
"value",
")",
"?",
"(",
"'true'",
")",
":",
"(",
"'false'",
")",
")",
")",
";",
"}"
] | sets a boolean property value in given section
If a property with this name in the given section already exists it will
be replaced.
@api
@param string $section
@param string $name
@param bool $value
@return \stubbles\values\ModifiableProperties | [
"sets",
"a",
"boolean",
"property",
"value",
"in",
"given",
"section"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/ModifiableProperties.php#L69-L72 |
10,325 | stubbles/stubbles-values | src/main/php/ModifiableProperties.php | ModifiableProperties.setArrayValue | public function setArrayValue(string $section, string $name, array $value): self
{
return $this->setValue($section, $name, join('|', $value));
} | php | public function setArrayValue(string $section, string $name, array $value): self
{
return $this->setValue($section, $name, join('|', $value));
} | [
"public",
"function",
"setArrayValue",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"name",
",",
"array",
"$",
"value",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"setValue",
"(",
"$",
"section",
",",
"$",
"name",
",",
"join",
"(",
"'|'",
",",
"$",
"value",
")",
")",
";",
"}"
] | sets an array as property value in given section
If a property with this name in the given section already exists it will
be replaced.
@api
@param string $section
@param string $name
@param array $value
@return \stubbles\values\ModifiableProperties | [
"sets",
"an",
"array",
"as",
"property",
"value",
"in",
"given",
"section"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/ModifiableProperties.php#L86-L89 |
10,326 | stubbles/stubbles-values | src/main/php/ModifiableProperties.php | ModifiableProperties.setHashValue | public function setHashValue(string $section, string $name, array $hash): self
{
$values = [];
foreach($hash as $key => $val) {
$values[] = $key . ':' . $val;
}
return $this->setArrayValue($section, $name, $values);
} | php | public function setHashValue(string $section, string $name, array $hash): self
{
$values = [];
foreach($hash as $key => $val) {
$values[] = $key . ':' . $val;
}
return $this->setArrayValue($section, $name, $values);
} | [
"public",
"function",
"setHashValue",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"name",
",",
"array",
"$",
"hash",
")",
":",
"self",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"hash",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"key",
".",
"':'",
".",
"$",
"val",
";",
"}",
"return",
"$",
"this",
"->",
"setArrayValue",
"(",
"$",
"section",
",",
"$",
"name",
",",
"$",
"values",
")",
";",
"}"
] | sets a hash map as property value in given section
If a property with this name in the given section already exists it will
be replaced.
@api
@param string $section
@param string $name
@param array $hash
@return \stubbles\values\ModifiableProperties | [
"sets",
"a",
"hash",
"map",
"as",
"property",
"value",
"in",
"given",
"section"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/ModifiableProperties.php#L103-L111 |
10,327 | stubbles/stubbles-values | src/main/php/ModifiableProperties.php | ModifiableProperties.setRangeValue | public function setRangeValue(string $section, string $name, array $range): self
{
return $this->setValue($section, $name, array_shift($range) . '..' . array_pop($range));
} | php | public function setRangeValue(string $section, string $name, array $range): self
{
return $this->setValue($section, $name, array_shift($range) . '..' . array_pop($range));
} | [
"public",
"function",
"setRangeValue",
"(",
"string",
"$",
"section",
",",
"string",
"$",
"name",
",",
"array",
"$",
"range",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"setValue",
"(",
"$",
"section",
",",
"$",
"name",
",",
"array_shift",
"(",
"$",
"range",
")",
".",
"'..'",
".",
"array_pop",
"(",
"$",
"range",
")",
")",
";",
"}"
] | sets a range as property value in given section
If a property with this name in the given section already exists it will
be replaced.
@api
@param string $section
@param string $name
@param array $range
@return \stubbles\values\ModifiableProperties | [
"sets",
"a",
"range",
"as",
"property",
"value",
"in",
"given",
"section"
] | 505e016715f7d7f96e180f2e8a1d711a12a3c4c2 | https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/ModifiableProperties.php#L125-L128 |
10,328 | chippyash/Validation | src/Chippyash/Validation/Common/ISO8601/MatchDate.php | MatchDate.matchDate | public function matchDate($date)
{
return $this->matchPart(
$date,
$this->formatRegex[$this->format][self::STRDATE]
);
} | php | public function matchDate($date)
{
return $this->matchPart(
$date,
$this->formatRegex[$this->format][self::STRDATE]
);
} | [
"public",
"function",
"matchDate",
"(",
"$",
"date",
")",
"{",
"return",
"$",
"this",
"->",
"matchPart",
"(",
"$",
"date",
",",
"$",
"this",
"->",
"formatRegex",
"[",
"$",
"this",
"->",
"format",
"]",
"[",
"self",
"::",
"STRDATE",
"]",
")",
";",
"}"
] | Match a date part
@param string $date
@return boolean | [
"Match",
"a",
"date",
"part"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Common/ISO8601/MatchDate.php#L74-L80 |
10,329 | chippyash/Validation | src/Chippyash/Validation/Common/ISO8601/MatchDate.php | MatchDate.matchTime | public function matchTime($time)
{
return $this->matchPart(
$time,
$this->formatRegex[$this->format][self::STRTIME]
);
} | php | public function matchTime($time)
{
return $this->matchPart(
$time,
$this->formatRegex[$this->format][self::STRTIME]
);
} | [
"public",
"function",
"matchTime",
"(",
"$",
"time",
")",
"{",
"return",
"$",
"this",
"->",
"matchPart",
"(",
"$",
"time",
",",
"$",
"this",
"->",
"formatRegex",
"[",
"$",
"this",
"->",
"format",
"]",
"[",
"self",
"::",
"STRTIME",
"]",
")",
";",
"}"
] | Match a time part
@param string $time
@return boolean | [
"Match",
"a",
"time",
"part"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Common/ISO8601/MatchDate.php#L88-L94 |
10,330 | chippyash/Validation | src/Chippyash/Validation/Common/ISO8601/MatchDate.php | MatchDate.matchZone | public function matchZone($zone)
{
return $this->matchPart(
$zone,
$this->formatRegex[$this->format][self::STRZONE]
);
} | php | public function matchZone($zone)
{
return $this->matchPart(
$zone,
$this->formatRegex[$this->format][self::STRZONE]
);
} | [
"public",
"function",
"matchZone",
"(",
"$",
"zone",
")",
"{",
"return",
"$",
"this",
"->",
"matchPart",
"(",
"$",
"zone",
",",
"$",
"this",
"->",
"formatRegex",
"[",
"$",
"this",
"->",
"format",
"]",
"[",
"self",
"::",
"STRZONE",
"]",
")",
";",
"}"
] | Match a zone part
@param string $zone
@return boolean | [
"Match",
"a",
"zone",
"part"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Common/ISO8601/MatchDate.php#L102-L108 |
10,331 | chippyash/Validation | src/Chippyash/Validation/Common/ISO8601/MatchDate.php | MatchDate.matchDateAndTimeAndZone | public function matchDateAndTimeAndZone($date, $time, $zone)
{
return $this->matchDate($date)
&& $this->matchTime($time)
&& $this->matchZone($zone);
} | php | public function matchDateAndTimeAndZone($date, $time, $zone)
{
return $this->matchDate($date)
&& $this->matchTime($time)
&& $this->matchZone($zone);
} | [
"public",
"function",
"matchDateAndTimeAndZone",
"(",
"$",
"date",
",",
"$",
"time",
",",
"$",
"zone",
")",
"{",
"return",
"$",
"this",
"->",
"matchDate",
"(",
"$",
"date",
")",
"&&",
"$",
"this",
"->",
"matchTime",
"(",
"$",
"time",
")",
"&&",
"$",
"this",
"->",
"matchZone",
"(",
"$",
"zone",
")",
";",
"}"
] | Match a date, time and zone datestring part
@param string $date
@param string $time
@param string $zone
@return boolean | [
"Match",
"a",
"date",
"time",
"and",
"zone",
"datestring",
"part"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Common/ISO8601/MatchDate.php#L131-L136 |
10,332 | chippyash/Validation | src/Chippyash/Validation/Common/ISO8601/MatchDate.php | MatchDate.matchPart | protected function matchPart($value, array $patterns)
{
foreach ($patterns as $key => $pattern) {
if (preg_match($pattern, $value) === 1) {
$this->messenger->add(new StringType($key));
return true;
}
}
return false;
} | php | protected function matchPart($value, array $patterns)
{
foreach ($patterns as $key => $pattern) {
if (preg_match($pattern, $value) === 1) {
$this->messenger->add(new StringType($key));
return true;
}
}
return false;
} | [
"protected",
"function",
"matchPart",
"(",
"$",
"value",
",",
"array",
"$",
"patterns",
")",
"{",
"foreach",
"(",
"$",
"patterns",
"as",
"$",
"key",
"=>",
"$",
"pattern",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"value",
")",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"messenger",
"->",
"add",
"(",
"new",
"StringType",
"(",
"$",
"key",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Match a datestring part
@param string $value
@param array $patterns
@return boolean | [
"Match",
"a",
"datestring",
"part"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Common/ISO8601/MatchDate.php#L145-L155 |
10,333 | tekkla/core-security | Core/Security/Login/Autologin.php | Autologin.doAutoLogin | public function doAutoLogin()
{
// User already logged in?
if ($this->session['logged_in']) {
return true;
}
// No autologin when autologin already failed
if (isset($this->session['autologin_failed'])) {
// Remove fragments/all of autologin cookies
setcookie($this->cookie_name, '', 1);
// Remove the flag which forces the log off
unset($this->session['autologin_failed']);
return false;
}
// No autologin cookie no autologin ;)
if (!isset($_COOKIE[$this->cookie_name])) {
return false;
}
// Let's find the user for the token in cookie
list ($selector, $token) = explode(':', $_COOKIE[$this->cookie_name]);
$this->db->qb([
'table' => 'core_auth_tokens',
'fields' => [
'id_auth_token',
'id',
'token',
'selector',
'expires'
],
'filter' => 'selector=:selector',
'params' => [
':selector' => $selector
]
]);
$data = $this->db->all();
foreach ($data as $auth_token) {
// Check if token is expired?
if (strtotime($auth_token['expires']) < time()) {
$this->removeAutoLoginTokenAndCookie($auth_token['id']);
continue;
}
// Matches the hash in db with the provided token?
if (hash_equals($auth_token['token'], $token)) {
// Refresh session id and delete old session
session_regenerate_id(true);
// Refresh autologin cookie so the user stays logged in
// as long as he comes back before his cookie has been expired.
$this->createAutoLoginTokenAndCookie($auth_token['id']);
// Login user, set session flags and return true
$this->session['logged_in'] = true;
$this->session['user'] = $auth_token['id'];
// Remove possible autologin failed flag
unset($this->session['autologin_failed']);
return $this->session['user'];
}
}
// !!! Reaching this point means autologin validation failed in all ways
// Clean up the mess and return a big bad fucking false as failed autologin result.
// Remove token cookie
if (isset($_COOKIE[$this->cookie_name])) {
unset($_COOKIE[$this->cookie_name]);
}
// Set flag that autologin failed
$this->session['autologin_failed'] = true;
// Set logged in flag explicit to false
$this->session['logged_in'] = false;
// Set id of user explicit to 0 (guest)
$this->session['user'] = 0;
// sorry, no autologin
return false;
} | php | public function doAutoLogin()
{
// User already logged in?
if ($this->session['logged_in']) {
return true;
}
// No autologin when autologin already failed
if (isset($this->session['autologin_failed'])) {
// Remove fragments/all of autologin cookies
setcookie($this->cookie_name, '', 1);
// Remove the flag which forces the log off
unset($this->session['autologin_failed']);
return false;
}
// No autologin cookie no autologin ;)
if (!isset($_COOKIE[$this->cookie_name])) {
return false;
}
// Let's find the user for the token in cookie
list ($selector, $token) = explode(':', $_COOKIE[$this->cookie_name]);
$this->db->qb([
'table' => 'core_auth_tokens',
'fields' => [
'id_auth_token',
'id',
'token',
'selector',
'expires'
],
'filter' => 'selector=:selector',
'params' => [
':selector' => $selector
]
]);
$data = $this->db->all();
foreach ($data as $auth_token) {
// Check if token is expired?
if (strtotime($auth_token['expires']) < time()) {
$this->removeAutoLoginTokenAndCookie($auth_token['id']);
continue;
}
// Matches the hash in db with the provided token?
if (hash_equals($auth_token['token'], $token)) {
// Refresh session id and delete old session
session_regenerate_id(true);
// Refresh autologin cookie so the user stays logged in
// as long as he comes back before his cookie has been expired.
$this->createAutoLoginTokenAndCookie($auth_token['id']);
// Login user, set session flags and return true
$this->session['logged_in'] = true;
$this->session['user'] = $auth_token['id'];
// Remove possible autologin failed flag
unset($this->session['autologin_failed']);
return $this->session['user'];
}
}
// !!! Reaching this point means autologin validation failed in all ways
// Clean up the mess and return a big bad fucking false as failed autologin result.
// Remove token cookie
if (isset($_COOKIE[$this->cookie_name])) {
unset($_COOKIE[$this->cookie_name]);
}
// Set flag that autologin failed
$this->session['autologin_failed'] = true;
// Set logged in flag explicit to false
$this->session['logged_in'] = false;
// Set id of user explicit to 0 (guest)
$this->session['user'] = 0;
// sorry, no autologin
return false;
} | [
"public",
"function",
"doAutoLogin",
"(",
")",
"{",
"// User already logged in?",
"if",
"(",
"$",
"this",
"->",
"session",
"[",
"'logged_in'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"// No autologin when autologin already failed",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"session",
"[",
"'autologin_failed'",
"]",
")",
")",
"{",
"// Remove fragments/all of autologin cookies",
"setcookie",
"(",
"$",
"this",
"->",
"cookie_name",
",",
"''",
",",
"1",
")",
";",
"// Remove the flag which forces the log off",
"unset",
"(",
"$",
"this",
"->",
"session",
"[",
"'autologin_failed'",
"]",
")",
";",
"return",
"false",
";",
"}",
"// No autologin cookie no autologin ;)",
"if",
"(",
"!",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookie_name",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Let's find the user for the token in cookie",
"list",
"(",
"$",
"selector",
",",
"$",
"token",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookie_name",
"]",
")",
";",
"$",
"this",
"->",
"db",
"->",
"qb",
"(",
"[",
"'table'",
"=>",
"'core_auth_tokens'",
",",
"'fields'",
"=>",
"[",
"'id_auth_token'",
",",
"'id'",
",",
"'token'",
",",
"'selector'",
",",
"'expires'",
"]",
",",
"'filter'",
"=>",
"'selector=:selector'",
",",
"'params'",
"=>",
"[",
"':selector'",
"=>",
"$",
"selector",
"]",
"]",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"db",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"auth_token",
")",
"{",
"// Check if token is expired?",
"if",
"(",
"strtotime",
"(",
"$",
"auth_token",
"[",
"'expires'",
"]",
")",
"<",
"time",
"(",
")",
")",
"{",
"$",
"this",
"->",
"removeAutoLoginTokenAndCookie",
"(",
"$",
"auth_token",
"[",
"'id'",
"]",
")",
";",
"continue",
";",
"}",
"// Matches the hash in db with the provided token?",
"if",
"(",
"hash_equals",
"(",
"$",
"auth_token",
"[",
"'token'",
"]",
",",
"$",
"token",
")",
")",
"{",
"// Refresh session id and delete old session",
"session_regenerate_id",
"(",
"true",
")",
";",
"// Refresh autologin cookie so the user stays logged in",
"// as long as he comes back before his cookie has been expired.",
"$",
"this",
"->",
"createAutoLoginTokenAndCookie",
"(",
"$",
"auth_token",
"[",
"'id'",
"]",
")",
";",
"// Login user, set session flags and return true",
"$",
"this",
"->",
"session",
"[",
"'logged_in'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"session",
"[",
"'user'",
"]",
"=",
"$",
"auth_token",
"[",
"'id'",
"]",
";",
"// Remove possible autologin failed flag",
"unset",
"(",
"$",
"this",
"->",
"session",
"[",
"'autologin_failed'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"session",
"[",
"'user'",
"]",
";",
"}",
"}",
"// !!! Reaching this point means autologin validation failed in all ways",
"// Clean up the mess and return a big bad fucking false as failed autologin result.",
"// Remove token cookie",
"if",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookie_name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookie_name",
"]",
")",
";",
"}",
"// Set flag that autologin failed",
"$",
"this",
"->",
"session",
"[",
"'autologin_failed'",
"]",
"=",
"true",
";",
"// Set logged in flag explicit to false",
"$",
"this",
"->",
"session",
"[",
"'logged_in'",
"]",
"=",
"false",
";",
"// Set id of user explicit to 0 (guest)",
"$",
"this",
"->",
"session",
"[",
"'user'",
"]",
"=",
"0",
";",
"// sorry, no autologin",
"return",
"false",
";",
"}"
] | Tries to autologin the user by comparing token stored in cookie with a generated token created of user
credentials.
@return boolean | [
"Tries",
"to",
"autologin",
"the",
"user",
"by",
"comparing",
"token",
"stored",
"in",
"cookie",
"with",
"a",
"generated",
"token",
"created",
"of",
"user",
"credentials",
"."
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Login/Autologin.php#L46-L137 |
10,334 | tekkla/core-security | Core/Security/Login/Autologin.php | Autologin.createAutoLoginTokenAndCookie | public function createAutoLoginTokenAndCookie(int $id)
{
$authtok = new AuthToken($this->db);
$authtok->setId($id);
$authtok->setExpires($this->expires_after);
setcookie($this->cookie_name, $authtok->generate(), $authtok->getExpiresTimestamp(), '/');
} | php | public function createAutoLoginTokenAndCookie(int $id)
{
$authtok = new AuthToken($this->db);
$authtok->setId($id);
$authtok->setExpires($this->expires_after);
setcookie($this->cookie_name, $authtok->generate(), $authtok->getExpiresTimestamp(), '/');
} | [
"public",
"function",
"createAutoLoginTokenAndCookie",
"(",
"int",
"$",
"id",
")",
"{",
"$",
"authtok",
"=",
"new",
"AuthToken",
"(",
"$",
"this",
"->",
"db",
")",
";",
"$",
"authtok",
"->",
"setId",
"(",
"$",
"id",
")",
";",
"$",
"authtok",
"->",
"setExpires",
"(",
"$",
"this",
"->",
"expires_after",
")",
";",
"setcookie",
"(",
"$",
"this",
"->",
"cookie_name",
",",
"$",
"authtok",
"->",
"generate",
"(",
")",
",",
"$",
"authtok",
"->",
"getExpiresTimestamp",
"(",
")",
",",
"'/'",
")",
";",
"}"
] | Set auto login cookies with user generated token
@param int $id | [
"Set",
"auto",
"login",
"cookies",
"with",
"user",
"generated",
"token"
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Login/Autologin.php#L144-L151 |
10,335 | tekkla/core-security | Core/Security/Login/Autologin.php | Autologin.removeAutoLoginTokenAndCookie | public function removeAutoLoginTokenAndCookie(int $id)
{
$authtok = new AuthToken($this->db);
$authtok->setId($id);
$authtok->deleteUserToken();
setcookie($this->cookie_name, '', 1, '/');
} | php | public function removeAutoLoginTokenAndCookie(int $id)
{
$authtok = new AuthToken($this->db);
$authtok->setId($id);
$authtok->deleteUserToken();
setcookie($this->cookie_name, '', 1, '/');
} | [
"public",
"function",
"removeAutoLoginTokenAndCookie",
"(",
"int",
"$",
"id",
")",
"{",
"$",
"authtok",
"=",
"new",
"AuthToken",
"(",
"$",
"this",
"->",
"db",
")",
";",
"$",
"authtok",
"->",
"setId",
"(",
"$",
"id",
")",
";",
"$",
"authtok",
"->",
"deleteUserToken",
"(",
")",
";",
"setcookie",
"(",
"$",
"this",
"->",
"cookie_name",
",",
"''",
",",
"1",
",",
"'/'",
")",
";",
"}"
] | Removes autologin cookies with user generated token
@param int $id | [
"Removes",
"autologin",
"cookies",
"with",
"user",
"generated",
"token"
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Login/Autologin.php#L158-L165 |
10,336 | Label305/Auja-PHP | src/Label305/Auja/Utils/Utils.php | Utils.array_insert | public static function array_insert(&$array, $item, $position) {
if ($position == 0) {
/* Prepend the item */
array_unshift($array, $item);
} else {
if (count($array) == $position) {
$array[] = $item;
} else {
array_splice($array, $position, 0, array($item));
}
}
} | php | public static function array_insert(&$array, $item, $position) {
if ($position == 0) {
/* Prepend the item */
array_unshift($array, $item);
} else {
if (count($array) == $position) {
$array[] = $item;
} else {
array_splice($array, $position, 0, array($item));
}
}
} | [
"public",
"static",
"function",
"array_insert",
"(",
"&",
"$",
"array",
",",
"$",
"item",
",",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"position",
"==",
"0",
")",
"{",
"/* Prepend the item */",
"array_unshift",
"(",
"$",
"array",
",",
"$",
"item",
")",
";",
"}",
"else",
"{",
"if",
"(",
"count",
"(",
"$",
"array",
")",
"==",
"$",
"position",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"else",
"{",
"array_splice",
"(",
"$",
"array",
",",
"$",
"position",
",",
"0",
",",
"array",
"(",
"$",
"item",
")",
")",
";",
"}",
"}",
"}"
] | Inserts given item into given array at given position.
@param array $array The array to insert the item in.
@param mixed $item The item to insert.
@param integer $position The position to insert the item at. | [
"Inserts",
"given",
"item",
"into",
"given",
"array",
"at",
"given",
"position",
"."
] | 64712af949c4b80e6ca19ed1936e6b37f8965a4c | https://github.com/Label305/Auja-PHP/blob/64712af949c4b80e6ca19ed1936e6b37f8965a4c/src/Label305/Auja/Utils/Utils.php#L43-L54 |
10,337 | Rehyved/php-http-client | src/rehyved/Http/HttpStatus.php | HttpStatus.isInformational | public static function isInformational(int $statusCode): bool
{
return ($statusCode >= HttpStatus::INFORMATIONAL) && ($statusCode < HttpStatus::SUCCESSFUL);
} | php | public static function isInformational(int $statusCode): bool
{
return ($statusCode >= HttpStatus::INFORMATIONAL) && ($statusCode < HttpStatus::SUCCESSFUL);
} | [
"public",
"static",
"function",
"isInformational",
"(",
"int",
"$",
"statusCode",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"statusCode",
">=",
"HttpStatus",
"::",
"INFORMATIONAL",
")",
"&&",
"(",
"$",
"statusCode",
"<",
"HttpStatus",
"::",
"SUCCESSFUL",
")",
";",
"}"
] | Checks if the provided status code falls in the Informational range of HTTP statuses
@param int $statusCode the status code to check
@return bool TRUE if it falls into the Informational range, FALSE if not | [
"Checks",
"if",
"the",
"provided",
"status",
"code",
"falls",
"in",
"the",
"Informational",
"range",
"of",
"HTTP",
"statuses"
] | 1a4a7d3d30d710ce4062c7628010ee4f06d2359c | https://github.com/Rehyved/php-http-client/blob/1a4a7d3d30d710ce4062c7628010ee4f06d2359c/src/rehyved/Http/HttpStatus.php#L122-L125 |
10,338 | Rehyved/php-http-client | src/rehyved/Http/HttpStatus.php | HttpStatus.isSuccessful | public static function isSuccessful(int $statusCode): bool
{
return ($statusCode >= HttpStatus::SUCCESSFUL) && ($statusCode < HttpStatus::REDIRECTION);
} | php | public static function isSuccessful(int $statusCode): bool
{
return ($statusCode >= HttpStatus::SUCCESSFUL) && ($statusCode < HttpStatus::REDIRECTION);
} | [
"public",
"static",
"function",
"isSuccessful",
"(",
"int",
"$",
"statusCode",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"statusCode",
">=",
"HttpStatus",
"::",
"SUCCESSFUL",
")",
"&&",
"(",
"$",
"statusCode",
"<",
"HttpStatus",
"::",
"REDIRECTION",
")",
";",
"}"
] | Checks if the provided status code falls in the Successful range of HTTP statuses
@param int $statusCode the status code to check
@return bool TRUE if it falls into the Successful range, FALSE if not | [
"Checks",
"if",
"the",
"provided",
"status",
"code",
"falls",
"in",
"the",
"Successful",
"range",
"of",
"HTTP",
"statuses"
] | 1a4a7d3d30d710ce4062c7628010ee4f06d2359c | https://github.com/Rehyved/php-http-client/blob/1a4a7d3d30d710ce4062c7628010ee4f06d2359c/src/rehyved/Http/HttpStatus.php#L132-L135 |
10,339 | Rehyved/php-http-client | src/rehyved/Http/HttpStatus.php | HttpStatus.isRedirection | public static function isRedirection(int $statusCode): bool
{
return ($statusCode >= HttpStatus::REDIRECTION) && ($statusCode < HttpStatus::CLIENT_ERROR);
} | php | public static function isRedirection(int $statusCode): bool
{
return ($statusCode >= HttpStatus::REDIRECTION) && ($statusCode < HttpStatus::CLIENT_ERROR);
} | [
"public",
"static",
"function",
"isRedirection",
"(",
"int",
"$",
"statusCode",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"statusCode",
">=",
"HttpStatus",
"::",
"REDIRECTION",
")",
"&&",
"(",
"$",
"statusCode",
"<",
"HttpStatus",
"::",
"CLIENT_ERROR",
")",
";",
"}"
] | Checks if the provided status code falls in the Redirection range of HTTP statuses
@param int $statusCode the status code to check
@return bool TRUE if it falls into the Redirection range, FALSE if not | [
"Checks",
"if",
"the",
"provided",
"status",
"code",
"falls",
"in",
"the",
"Redirection",
"range",
"of",
"HTTP",
"statuses"
] | 1a4a7d3d30d710ce4062c7628010ee4f06d2359c | https://github.com/Rehyved/php-http-client/blob/1a4a7d3d30d710ce4062c7628010ee4f06d2359c/src/rehyved/Http/HttpStatus.php#L142-L145 |
10,340 | Rehyved/php-http-client | src/rehyved/Http/HttpStatus.php | HttpStatus.isClientError | public static function isClientError(int $statusCode): bool
{
return ($statusCode >= HttpStatus::CLIENT_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR);
} | php | public static function isClientError(int $statusCode): bool
{
return ($statusCode >= HttpStatus::CLIENT_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR);
} | [
"public",
"static",
"function",
"isClientError",
"(",
"int",
"$",
"statusCode",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"statusCode",
">=",
"HttpStatus",
"::",
"CLIENT_ERROR",
")",
"&&",
"(",
"$",
"statusCode",
"<",
"HttpStatus",
"::",
"SERVER_ERROR",
")",
";",
"}"
] | Checks if the provided status code falls in the Client error range of HTTP statuses
@param int $statusCode the status code to check
@return bool TRUE if it falls into the Client error range, FALSE if not | [
"Checks",
"if",
"the",
"provided",
"status",
"code",
"falls",
"in",
"the",
"Client",
"error",
"range",
"of",
"HTTP",
"statuses"
] | 1a4a7d3d30d710ce4062c7628010ee4f06d2359c | https://github.com/Rehyved/php-http-client/blob/1a4a7d3d30d710ce4062c7628010ee4f06d2359c/src/rehyved/Http/HttpStatus.php#L152-L155 |
10,341 | Rehyved/php-http-client | src/rehyved/Http/HttpStatus.php | HttpStatus.isServerError | public static function isServerError(int $statusCode): bool
{
return ($statusCode >= HttpStatus::SERVER_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR_END);
} | php | public static function isServerError(int $statusCode): bool
{
return ($statusCode >= HttpStatus::SERVER_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR_END);
} | [
"public",
"static",
"function",
"isServerError",
"(",
"int",
"$",
"statusCode",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"statusCode",
">=",
"HttpStatus",
"::",
"SERVER_ERROR",
")",
"&&",
"(",
"$",
"statusCode",
"<",
"HttpStatus",
"::",
"SERVER_ERROR_END",
")",
";",
"}"
] | Checks if the provided status code falls in the Server error range of HTTP statuses
@param int $statusCode the status code to check
@return bool TRUE if it falls into the Server error range, FALSE if not | [
"Checks",
"if",
"the",
"provided",
"status",
"code",
"falls",
"in",
"the",
"Server",
"error",
"range",
"of",
"HTTP",
"statuses"
] | 1a4a7d3d30d710ce4062c7628010ee4f06d2359c | https://github.com/Rehyved/php-http-client/blob/1a4a7d3d30d710ce4062c7628010ee4f06d2359c/src/rehyved/Http/HttpStatus.php#L162-L165 |
10,342 | Rehyved/php-http-client | src/rehyved/Http/HttpStatus.php | HttpStatus.isError | public static function isError(int $statusCode): bool
{
return ($statusCode >= HttpStatus::CLIENT_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR_END);
} | php | public static function isError(int $statusCode): bool
{
return ($statusCode >= HttpStatus::CLIENT_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR_END);
} | [
"public",
"static",
"function",
"isError",
"(",
"int",
"$",
"statusCode",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"statusCode",
">=",
"HttpStatus",
"::",
"CLIENT_ERROR",
")",
"&&",
"(",
"$",
"statusCode",
"<",
"HttpStatus",
"::",
"SERVER_ERROR_END",
")",
";",
"}"
] | Checks if the provided status code falls in the Client or Server error range of HTTP statuses
@param int $statusCode the status code to check
@return bool TRUE if it falls into the Client or Server error range, FALSE if not | [
"Checks",
"if",
"the",
"provided",
"status",
"code",
"falls",
"in",
"the",
"Client",
"or",
"Server",
"error",
"range",
"of",
"HTTP",
"statuses"
] | 1a4a7d3d30d710ce4062c7628010ee4f06d2359c | https://github.com/Rehyved/php-http-client/blob/1a4a7d3d30d710ce4062c7628010ee4f06d2359c/src/rehyved/Http/HttpStatus.php#L172-L175 |
10,343 | Rehyved/php-http-client | src/rehyved/Http/HttpStatus.php | HttpStatus.getReasonPhrase | public static function getReasonPhrase(int $statusCode): string
{
if (array_key_exists($statusCode, HttpStatus::REASON_PHRASES)) {
return HttpStatus::REASON_PHRASES[$statusCode];
}
throw new \InvalidArgumentException("Invalid status code");
} | php | public static function getReasonPhrase(int $statusCode): string
{
if (array_key_exists($statusCode, HttpStatus::REASON_PHRASES)) {
return HttpStatus::REASON_PHRASES[$statusCode];
}
throw new \InvalidArgumentException("Invalid status code");
} | [
"public",
"static",
"function",
"getReasonPhrase",
"(",
"int",
"$",
"statusCode",
")",
":",
"string",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"statusCode",
",",
"HttpStatus",
"::",
"REASON_PHRASES",
")",
")",
"{",
"return",
"HttpStatus",
"::",
"REASON_PHRASES",
"[",
"$",
"statusCode",
"]",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid status code\"",
")",
";",
"}"
] | Retrieve the reason phrase for the provided HTTP status code
@param int $statusCode the status code for which to retrieve the reason phrase
@return string the reason phrase
@throws \InvalidArgumentException if the provided value is not a valid HTTP status code | [
"Retrieve",
"the",
"reason",
"phrase",
"for",
"the",
"provided",
"HTTP",
"status",
"code"
] | 1a4a7d3d30d710ce4062c7628010ee4f06d2359c | https://github.com/Rehyved/php-http-client/blob/1a4a7d3d30d710ce4062c7628010ee4f06d2359c/src/rehyved/Http/HttpStatus.php#L183-L189 |
10,344 | phlexible/tree-bundle | Controller/ListController.php | ListController.sortAction | public function sortAction(Request $request)
{
$tid = $request->get('tid');
$mode = $request->get('mode');
$dir = strtolower($request->get('dir'));
$sortTids = $request->get('sort_ids');
$sortTids = json_decode($sortTids, true);
$treeManager = $this->get('phlexible_tree.tree_manager');
$nodeSorter = $this->get('phlexible_tree.node_sorter');
$tree = $treeManager->getByNodeId($tid);
$node = $tree->get($tid);
$node->setSortMode($mode);
$node->setSortDir($dir);
if ($mode !== TreeInterface::SORT_MODE_FREE) {
$sortTids = $nodeSorter->sort($node);
}
if (count($sortTids)) {
$tree->reorderChildren($node, $sortTids);
}
return new ResultResponse(true, 'Tree sort published.');
} | php | public function sortAction(Request $request)
{
$tid = $request->get('tid');
$mode = $request->get('mode');
$dir = strtolower($request->get('dir'));
$sortTids = $request->get('sort_ids');
$sortTids = json_decode($sortTids, true);
$treeManager = $this->get('phlexible_tree.tree_manager');
$nodeSorter = $this->get('phlexible_tree.node_sorter');
$tree = $treeManager->getByNodeId($tid);
$node = $tree->get($tid);
$node->setSortMode($mode);
$node->setSortDir($dir);
if ($mode !== TreeInterface::SORT_MODE_FREE) {
$sortTids = $nodeSorter->sort($node);
}
if (count($sortTids)) {
$tree->reorderChildren($node, $sortTids);
}
return new ResultResponse(true, 'Tree sort published.');
} | [
"public",
"function",
"sortAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"tid",
"=",
"$",
"request",
"->",
"get",
"(",
"'tid'",
")",
";",
"$",
"mode",
"=",
"$",
"request",
"->",
"get",
"(",
"'mode'",
")",
";",
"$",
"dir",
"=",
"strtolower",
"(",
"$",
"request",
"->",
"get",
"(",
"'dir'",
")",
")",
";",
"$",
"sortTids",
"=",
"$",
"request",
"->",
"get",
"(",
"'sort_ids'",
")",
";",
"$",
"sortTids",
"=",
"json_decode",
"(",
"$",
"sortTids",
",",
"true",
")",
";",
"$",
"treeManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_tree.tree_manager'",
")",
";",
"$",
"nodeSorter",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_tree.node_sorter'",
")",
";",
"$",
"tree",
"=",
"$",
"treeManager",
"->",
"getByNodeId",
"(",
"$",
"tid",
")",
";",
"$",
"node",
"=",
"$",
"tree",
"->",
"get",
"(",
"$",
"tid",
")",
";",
"$",
"node",
"->",
"setSortMode",
"(",
"$",
"mode",
")",
";",
"$",
"node",
"->",
"setSortDir",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"$",
"mode",
"!==",
"TreeInterface",
"::",
"SORT_MODE_FREE",
")",
"{",
"$",
"sortTids",
"=",
"$",
"nodeSorter",
"->",
"sort",
"(",
"$",
"node",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"sortTids",
")",
")",
"{",
"$",
"tree",
"->",
"reorderChildren",
"(",
"$",
"node",
",",
"$",
"sortTids",
")",
";",
"}",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"'Tree sort published.'",
")",
";",
"}"
] | Node reordering.
@param Request $request
@return ResultResponse
@Route("/sort", name="tree_list_sort") | [
"Node",
"reordering",
"."
] | 0fd07efdf1edf2d0f74f71519c476d534457701c | https://github.com/phlexible/tree-bundle/blob/0fd07efdf1edf2d0f74f71519c476d534457701c/Controller/ListController.php#L180-L206 |
10,345 | avassilenko/route-locale | src/Routelocale.php | Routelocale.loadConfig | public function loadConfig() {
$this->allLocales = config('app.all_locales');
$this->defaultLocales = config('app.fallback_locale');
$this->usePrefixForDefault = config('routelocale.default_prefix');
} | php | public function loadConfig() {
$this->allLocales = config('app.all_locales');
$this->defaultLocales = config('app.fallback_locale');
$this->usePrefixForDefault = config('routelocale.default_prefix');
} | [
"public",
"function",
"loadConfig",
"(",
")",
"{",
"$",
"this",
"->",
"allLocales",
"=",
"config",
"(",
"'app.all_locales'",
")",
";",
"$",
"this",
"->",
"defaultLocales",
"=",
"config",
"(",
"'app.fallback_locale'",
")",
";",
"$",
"this",
"->",
"usePrefixForDefault",
"=",
"config",
"(",
"'routelocale.default_prefix'",
")",
";",
"}"
] | Load Routelocale configuration. All avalable locales and default locale. | [
"Load",
"Routelocale",
"configuration",
".",
"All",
"avalable",
"locales",
"and",
"default",
"locale",
"."
] | 0ac7f72eed3f2e850160061c96c0bf3a94f5b36e | https://github.com/avassilenko/route-locale/blob/0ac7f72eed3f2e850160061c96c0bf3a94f5b36e/src/Routelocale.php#L22-L26 |
10,346 | avassilenko/route-locale | src/Routelocale.php | Routelocale.getLocaleFromRoute | public function getLocaleFromRoute($segments = null) {
// if segmets are not set - get from current request
if (is_null($segments)) {
$segments = \Request::segments();
}
$locale = $this->getDefaultRoutelocale();
if ($allLocales = \Routelocale::getAllRoutelocales()) {
// reduce array of segments to [0] and find by value
if ($curLocaleIndex = array_search(array_shift($segments), $allLocales)) {
$locale = $allLocales[$curLocaleIndex];
}
}
return $locale;
} | php | public function getLocaleFromRoute($segments = null) {
// if segmets are not set - get from current request
if (is_null($segments)) {
$segments = \Request::segments();
}
$locale = $this->getDefaultRoutelocale();
if ($allLocales = \Routelocale::getAllRoutelocales()) {
// reduce array of segments to [0] and find by value
if ($curLocaleIndex = array_search(array_shift($segments), $allLocales)) {
$locale = $allLocales[$curLocaleIndex];
}
}
return $locale;
} | [
"public",
"function",
"getLocaleFromRoute",
"(",
"$",
"segments",
"=",
"null",
")",
"{",
"// if segmets are not set - get from current request\r",
"if",
"(",
"is_null",
"(",
"$",
"segments",
")",
")",
"{",
"$",
"segments",
"=",
"\\",
"Request",
"::",
"segments",
"(",
")",
";",
"}",
"$",
"locale",
"=",
"$",
"this",
"->",
"getDefaultRoutelocale",
"(",
")",
";",
"if",
"(",
"$",
"allLocales",
"=",
"\\",
"Routelocale",
"::",
"getAllRoutelocales",
"(",
")",
")",
"{",
"// reduce array of segments to [0] and find by value\r",
"if",
"(",
"$",
"curLocaleIndex",
"=",
"array_search",
"(",
"array_shift",
"(",
"$",
"segments",
")",
",",
"$",
"allLocales",
")",
")",
"{",
"$",
"locale",
"=",
"$",
"allLocales",
"[",
"$",
"curLocaleIndex",
"]",
";",
"}",
"}",
"return",
"$",
"locale",
";",
"}"
] | Returns the route locale. Fallback to default locale.
@param array|null $segments. The route segments. If null - segments will be pulled from current request
@return string Locale | [
"Returns",
"the",
"route",
"locale",
".",
"Fallback",
"to",
"default",
"locale",
"."
] | 0ac7f72eed3f2e850160061c96c0bf3a94f5b36e | https://github.com/avassilenko/route-locale/blob/0ac7f72eed3f2e850160061c96c0bf3a94f5b36e/src/Routelocale.php#L86-L99 |
10,347 | avassilenko/route-locale | src/Routelocale.php | Routelocale.getRouteLocalePrefix | public function getRouteLocalePrefix($locale = null) {
if (is_null($locale)) {
$locale = $this->getLocaleFromRoute();
}
return $this->getDefaultRoutelocale() === $locale ? ($this->isUsePrefixForDefaultLocale() ? $locale : '') : $locale;
} | php | public function getRouteLocalePrefix($locale = null) {
if (is_null($locale)) {
$locale = $this->getLocaleFromRoute();
}
return $this->getDefaultRoutelocale() === $locale ? ($this->isUsePrefixForDefaultLocale() ? $locale : '') : $locale;
} | [
"public",
"function",
"getRouteLocalePrefix",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"locale",
")",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"getLocaleFromRoute",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getDefaultRoutelocale",
"(",
")",
"===",
"$",
"locale",
"?",
"(",
"$",
"this",
"->",
"isUsePrefixForDefaultLocale",
"(",
")",
"?",
"$",
"locale",
":",
"''",
")",
":",
"$",
"locale",
";",
"}"
] | Returns locale to set as prefix to the route.
Returns empty string it is default locale and if configuration set to "no prefix" for default locale
@param type $locale
@return string Prefix to localized route. Like 'en'. | [
"Returns",
"locale",
"to",
"set",
"as",
"prefix",
"to",
"the",
"route",
".",
"Returns",
"empty",
"string",
"it",
"is",
"default",
"locale",
"and",
"if",
"configuration",
"set",
"to",
"no",
"prefix",
"for",
"default",
"locale"
] | 0ac7f72eed3f2e850160061c96c0bf3a94f5b36e | https://github.com/avassilenko/route-locale/blob/0ac7f72eed3f2e850160061c96c0bf3a94f5b36e/src/Routelocale.php#L207-L212 |
10,348 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.AddBreadcrumb | public function AddBreadcrumb($Name, $Link = NULL, $Position = 'back') {
$Breadcrumb = array(
'Name' => T($Name),
'Url' => $Link
);
$Breadcrumbs = $this->Data('Breadcrumbs', array());
switch ($Position) {
case 'back':
$Breadcrumbs = array_merge($Breadcrumbs, array($Breadcrumb));
break;
case 'front':
$Breadcrumbs = array_merge(array($Breadcrumb), $Breadcrumbs);
break;
}
$this->SetData('Breadcrumbs', $Breadcrumbs);
} | php | public function AddBreadcrumb($Name, $Link = NULL, $Position = 'back') {
$Breadcrumb = array(
'Name' => T($Name),
'Url' => $Link
);
$Breadcrumbs = $this->Data('Breadcrumbs', array());
switch ($Position) {
case 'back':
$Breadcrumbs = array_merge($Breadcrumbs, array($Breadcrumb));
break;
case 'front':
$Breadcrumbs = array_merge(array($Breadcrumb), $Breadcrumbs);
break;
}
$this->SetData('Breadcrumbs', $Breadcrumbs);
} | [
"public",
"function",
"AddBreadcrumb",
"(",
"$",
"Name",
",",
"$",
"Link",
"=",
"NULL",
",",
"$",
"Position",
"=",
"'back'",
")",
"{",
"$",
"Breadcrumb",
"=",
"array",
"(",
"'Name'",
"=>",
"T",
"(",
"$",
"Name",
")",
",",
"'Url'",
"=>",
"$",
"Link",
")",
";",
"$",
"Breadcrumbs",
"=",
"$",
"this",
"->",
"Data",
"(",
"'Breadcrumbs'",
",",
"array",
"(",
")",
")",
";",
"switch",
"(",
"$",
"Position",
")",
"{",
"case",
"'back'",
":",
"$",
"Breadcrumbs",
"=",
"array_merge",
"(",
"$",
"Breadcrumbs",
",",
"array",
"(",
"$",
"Breadcrumb",
")",
")",
";",
"break",
";",
"case",
"'front'",
":",
"$",
"Breadcrumbs",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"Breadcrumb",
")",
",",
"$",
"Breadcrumbs",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"SetData",
"(",
"'Breadcrumbs'",
",",
"$",
"Breadcrumbs",
")",
";",
"}"
] | Add a breadcrumb to the list
@param string $Name Translation code
@param string $Link Optional. Hyperlink this breadcrumb somewhere.
@param string $Position Optional. Where in the list to add it? 'front', 'back' | [
"Add",
"a",
"breadcrumb",
"to",
"the",
"list"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L390-L406 |
10,349 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.AddModule | public function AddModule($Module, $AssetTarget = '') {
$this->FireEvent('BeforeAddModule');
$AssetModule = $Module;
if (!is_object($AssetModule)) {
if (property_exists($this, $Module) && is_object($this->$Module)) {
$AssetModule = $this->$Module;
} else {
$ModuleClassExists = class_exists($Module);
if ($ModuleClassExists) {
// Make sure that the class implements Gdn_IModule
$ReflectionClass = new ReflectionClass($Module);
if ($ReflectionClass->implementsInterface("Gdn_IModule"))
$AssetModule = new $Module($this);
}
}
}
if (is_object($AssetModule)) {
$AssetTarget = ($AssetTarget == '' ? $AssetModule->AssetTarget() : $AssetTarget);
// echo '<div>adding: '.get_class($AssetModule).' ('.(property_exists($AssetModule, 'HtmlId') ? $AssetModule->HtmlId : '').') to '.$AssetTarget.' <textarea>'.$AssetModule->ToString().'</textarea></div>';
$this->AddAsset($AssetTarget, $AssetModule, $AssetModule->Name());
}
$this->FireEvent('AfterAddModule');
} | php | public function AddModule($Module, $AssetTarget = '') {
$this->FireEvent('BeforeAddModule');
$AssetModule = $Module;
if (!is_object($AssetModule)) {
if (property_exists($this, $Module) && is_object($this->$Module)) {
$AssetModule = $this->$Module;
} else {
$ModuleClassExists = class_exists($Module);
if ($ModuleClassExists) {
// Make sure that the class implements Gdn_IModule
$ReflectionClass = new ReflectionClass($Module);
if ($ReflectionClass->implementsInterface("Gdn_IModule"))
$AssetModule = new $Module($this);
}
}
}
if (is_object($AssetModule)) {
$AssetTarget = ($AssetTarget == '' ? $AssetModule->AssetTarget() : $AssetTarget);
// echo '<div>adding: '.get_class($AssetModule).' ('.(property_exists($AssetModule, 'HtmlId') ? $AssetModule->HtmlId : '').') to '.$AssetTarget.' <textarea>'.$AssetModule->ToString().'</textarea></div>';
$this->AddAsset($AssetTarget, $AssetModule, $AssetModule->Name());
}
$this->FireEvent('AfterAddModule');
} | [
"public",
"function",
"AddModule",
"(",
"$",
"Module",
",",
"$",
"AssetTarget",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"FireEvent",
"(",
"'BeforeAddModule'",
")",
";",
"$",
"AssetModule",
"=",
"$",
"Module",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"AssetModule",
")",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"Module",
")",
"&&",
"is_object",
"(",
"$",
"this",
"->",
"$",
"Module",
")",
")",
"{",
"$",
"AssetModule",
"=",
"$",
"this",
"->",
"$",
"Module",
";",
"}",
"else",
"{",
"$",
"ModuleClassExists",
"=",
"class_exists",
"(",
"$",
"Module",
")",
";",
"if",
"(",
"$",
"ModuleClassExists",
")",
"{",
"// Make sure that the class implements Gdn_IModule",
"$",
"ReflectionClass",
"=",
"new",
"ReflectionClass",
"(",
"$",
"Module",
")",
";",
"if",
"(",
"$",
"ReflectionClass",
"->",
"implementsInterface",
"(",
"\"Gdn_IModule\"",
")",
")",
"$",
"AssetModule",
"=",
"new",
"$",
"Module",
"(",
"$",
"this",
")",
";",
"}",
"}",
"}",
"if",
"(",
"is_object",
"(",
"$",
"AssetModule",
")",
")",
"{",
"$",
"AssetTarget",
"=",
"(",
"$",
"AssetTarget",
"==",
"''",
"?",
"$",
"AssetModule",
"->",
"AssetTarget",
"(",
")",
":",
"$",
"AssetTarget",
")",
";",
"// echo '<div>adding: '.get_class($AssetModule).' ('.(property_exists($AssetModule, 'HtmlId') ? $AssetModule->HtmlId : '').') to '.$AssetTarget.' <textarea>'.$AssetModule->ToString().'</textarea></div>';",
"$",
"this",
"->",
"AddAsset",
"(",
"$",
"AssetTarget",
",",
"$",
"AssetModule",
",",
"$",
"AssetModule",
"->",
"Name",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"FireEvent",
"(",
"'AfterAddModule'",
")",
";",
"}"
] | Adds the specified module to the specified asset target.
If no asset target is defined, it will use the asset target defined by the
module's AssetTarget method.
@param mixed $Module A module or the name of a module to add to the page.
@param string $AssetTarget
@todo $AssetTarget need the correct variable type and description. | [
"Adds",
"the",
"specified",
"module",
"to",
"the",
"specified",
"asset",
"target",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L497-L523 |
10,350 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.AddStache | public function AddStache($Template = '', $ControllerName = FALSE, $ApplicationFolder = FALSE) {
$Template = StringEndsWith($Template, '.stache', TRUE, TRUE);
$StacheTemplate = "{$Template}.stache";
$TemplateData = $this->FetchView($StacheTemplate, $ControllerName, $ApplicationFolder);
if ($TemplateData === FALSE) return FALSE;
$this->_Staches[$Template] = $TemplateData;
} | php | public function AddStache($Template = '', $ControllerName = FALSE, $ApplicationFolder = FALSE) {
$Template = StringEndsWith($Template, '.stache', TRUE, TRUE);
$StacheTemplate = "{$Template}.stache";
$TemplateData = $this->FetchView($StacheTemplate, $ControllerName, $ApplicationFolder);
if ($TemplateData === FALSE) return FALSE;
$this->_Staches[$Template] = $TemplateData;
} | [
"public",
"function",
"AddStache",
"(",
"$",
"Template",
"=",
"''",
",",
"$",
"ControllerName",
"=",
"FALSE",
",",
"$",
"ApplicationFolder",
"=",
"FALSE",
")",
"{",
"$",
"Template",
"=",
"StringEndsWith",
"(",
"$",
"Template",
",",
"'.stache'",
",",
"TRUE",
",",
"TRUE",
")",
";",
"$",
"StacheTemplate",
"=",
"\"{$Template}.stache\"",
";",
"$",
"TemplateData",
"=",
"$",
"this",
"->",
"FetchView",
"(",
"$",
"StacheTemplate",
",",
"$",
"ControllerName",
",",
"$",
"ApplicationFolder",
")",
";",
"if",
"(",
"$",
"TemplateData",
"===",
"FALSE",
")",
"return",
"FALSE",
";",
"$",
"this",
"->",
"_Staches",
"[",
"$",
"Template",
"]",
"=",
"$",
"TemplateData",
";",
"}"
] | Add a Mustache template to the output
@param string $Template
@param string $ControllerName Optional.
@param string $ApplicationFolder Optional.
@return boolean | [
"Add",
"a",
"Mustache",
"template",
"to",
"the",
"output"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L534-L542 |
10,351 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.Data | public function Data($Path, $Default = '' ) {
$Result = GetValueR($Path, $this->Data, $Default);
return $Result;
} | php | public function Data($Path, $Default = '' ) {
$Result = GetValueR($Path, $this->Data, $Default);
return $Result;
} | [
"public",
"function",
"Data",
"(",
"$",
"Path",
",",
"$",
"Default",
"=",
"''",
")",
"{",
"$",
"Result",
"=",
"GetValueR",
"(",
"$",
"Path",
",",
"$",
"this",
"->",
"Data",
",",
"$",
"Default",
")",
";",
"return",
"$",
"Result",
";",
"}"
] | Get a value out of the controller's data array.
@param string $Path The path to the data.
@param mixed $Default The default value if the data array doesn't contain the path.
@return mixed
@see GetValueR() | [
"Get",
"a",
"value",
"out",
"of",
"the",
"controller",
"s",
"data",
"array",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L615-L618 |
10,352 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.FetchView | public function FetchView($View = '', $ControllerName = FALSE, $ApplicationFolder = FALSE) {
$ViewPath = $this->FetchViewLocation($View, $ControllerName, $ApplicationFolder);
// Check to see if there is a handler for this particular extension.
$ViewHandler = Gdn::Factory('ViewHandler' . strtolower(strrchr($ViewPath, '.')));
$ViewContents = '';
ob_start();
if(is_null($ViewHandler)) {
// Parse the view and place it into the asset container if it was found.
include($ViewPath);
} else {
// Use the view handler to parse the view.
$ViewHandler->Render($ViewPath, $this);
}
$ViewContents = ob_get_clean();
return $ViewContents;
} | php | public function FetchView($View = '', $ControllerName = FALSE, $ApplicationFolder = FALSE) {
$ViewPath = $this->FetchViewLocation($View, $ControllerName, $ApplicationFolder);
// Check to see if there is a handler for this particular extension.
$ViewHandler = Gdn::Factory('ViewHandler' . strtolower(strrchr($ViewPath, '.')));
$ViewContents = '';
ob_start();
if(is_null($ViewHandler)) {
// Parse the view and place it into the asset container if it was found.
include($ViewPath);
} else {
// Use the view handler to parse the view.
$ViewHandler->Render($ViewPath, $this);
}
$ViewContents = ob_get_clean();
return $ViewContents;
} | [
"public",
"function",
"FetchView",
"(",
"$",
"View",
"=",
"''",
",",
"$",
"ControllerName",
"=",
"FALSE",
",",
"$",
"ApplicationFolder",
"=",
"FALSE",
")",
"{",
"$",
"ViewPath",
"=",
"$",
"this",
"->",
"FetchViewLocation",
"(",
"$",
"View",
",",
"$",
"ControllerName",
",",
"$",
"ApplicationFolder",
")",
";",
"// Check to see if there is a handler for this particular extension.",
"$",
"ViewHandler",
"=",
"Gdn",
"::",
"Factory",
"(",
"'ViewHandler'",
".",
"strtolower",
"(",
"strrchr",
"(",
"$",
"ViewPath",
",",
"'.'",
")",
")",
")",
";",
"$",
"ViewContents",
"=",
"''",
";",
"ob_start",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"ViewHandler",
")",
")",
"{",
"// Parse the view and place it into the asset container if it was found.",
"include",
"(",
"$",
"ViewPath",
")",
";",
"}",
"else",
"{",
"// Use the view handler to parse the view.",
"$",
"ViewHandler",
"->",
"Render",
"(",
"$",
"ViewPath",
",",
"$",
"this",
")",
";",
"}",
"$",
"ViewContents",
"=",
"ob_get_clean",
"(",
")",
";",
"return",
"$",
"ViewContents",
";",
"}"
] | Fetches the contents of a view into a string and returns it. Returns
false on failure.
@param string $View The name of the view to fetch. If not specified, it will use the value
of $this->View. If $this->View is not specified, it will use the value
of $this->RequestMethod (which is defined by the dispatcher class).
@param string $ControllerName The name of the controller that owns the view if it is not $this.
@param string $ApplicationFolder The name of the application folder that contains the requested controller
if it is not $this->ApplicationFolder. | [
"Fetches",
"the",
"contents",
"of",
"a",
"view",
"into",
"a",
"string",
"and",
"returns",
"it",
".",
"Returns",
"false",
"on",
"failure",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L757-L775 |
10,353 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.Image | public function Image($Img = FALSE) {
if ($Img) {
if (!is_array($Img))
$Img = array($Img);
$CurrentImages = $this->Data('_Images');
if (!is_array($CurrentImages))
$this->SetData('_Images', $Img);
else {
$Images = array_unique(array_merge($CurrentImages, $Img));
$this->SetData('_Images', $Images);
}
}
$Images = $this->Data('_Images');
return is_array($Images) ? $Images : array();
} | php | public function Image($Img = FALSE) {
if ($Img) {
if (!is_array($Img))
$Img = array($Img);
$CurrentImages = $this->Data('_Images');
if (!is_array($CurrentImages))
$this->SetData('_Images', $Img);
else {
$Images = array_unique(array_merge($CurrentImages, $Img));
$this->SetData('_Images', $Images);
}
}
$Images = $this->Data('_Images');
return is_array($Images) ? $Images : array();
} | [
"public",
"function",
"Image",
"(",
"$",
"Img",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"Img",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"Img",
")",
")",
"$",
"Img",
"=",
"array",
"(",
"$",
"Img",
")",
";",
"$",
"CurrentImages",
"=",
"$",
"this",
"->",
"Data",
"(",
"'_Images'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"CurrentImages",
")",
")",
"$",
"this",
"->",
"SetData",
"(",
"'_Images'",
",",
"$",
"Img",
")",
";",
"else",
"{",
"$",
"Images",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"CurrentImages",
",",
"$",
"Img",
")",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'_Images'",
",",
"$",
"Images",
")",
";",
"}",
"}",
"$",
"Images",
"=",
"$",
"this",
"->",
"Data",
"(",
"'_Images'",
")",
";",
"return",
"is_array",
"(",
"$",
"Images",
")",
"?",
"$",
"Images",
":",
"array",
"(",
")",
";",
"}"
] | Allows images to be specified for the page, to be used by the head module
to add facebook open graph information.
@param mixed $Img An image or array of image urls.
@return array The array of image urls. | [
"Allows",
"images",
"to",
"be",
"specified",
"for",
"the",
"page",
"to",
"be",
"used",
"by",
"the",
"head",
"module",
"to",
"add",
"facebook",
"open",
"graph",
"information",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1014-L1029 |
10,354 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.InformMessage | public function InformMessage($Message, $Options = 'Dismissable AutoDismiss') {
// If $Options isn't an array of options, accept it as a string of css classes to be assigned to the message.
if (!is_array($Options))
$Options = array('CssClass' => $Options);
if (!$Message && !array_key_exists('id', $Options))
return;
$Options['Message'] = $Message;
$this->_InformMessages[] = $Options;
} | php | public function InformMessage($Message, $Options = 'Dismissable AutoDismiss') {
// If $Options isn't an array of options, accept it as a string of css classes to be assigned to the message.
if (!is_array($Options))
$Options = array('CssClass' => $Options);
if (!$Message && !array_key_exists('id', $Options))
return;
$Options['Message'] = $Message;
$this->_InformMessages[] = $Options;
} | [
"public",
"function",
"InformMessage",
"(",
"$",
"Message",
",",
"$",
"Options",
"=",
"'Dismissable AutoDismiss'",
")",
"{",
"// If $Options isn't an array of options, accept it as a string of css classes to be assigned to the message.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"Options",
")",
")",
"$",
"Options",
"=",
"array",
"(",
"'CssClass'",
"=>",
"$",
"Options",
")",
";",
"if",
"(",
"!",
"$",
"Message",
"&&",
"!",
"array_key_exists",
"(",
"'id'",
",",
"$",
"Options",
")",
")",
"return",
";",
"$",
"Options",
"[",
"'Message'",
"]",
"=",
"$",
"Message",
";",
"$",
"this",
"->",
"_InformMessages",
"[",
"]",
"=",
"$",
"Options",
";",
"}"
] | Add an "inform" message to be displayed to the user.
@since 2.0.18
@param string $Message The message to be displayed.
@param mixed $Options An array of options for the message. If not an array, it is assumed to be a string of CSS classes to apply to the message. | [
"Add",
"an",
"inform",
"message",
"to",
"be",
"displayed",
"to",
"the",
"user",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1039-L1049 |
10,355 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.Initialize | public function Initialize() {
if (in_array($this->SyndicationMethod, array(SYNDICATION_ATOM, SYNDICATION_RSS))) {
$this->_Headers['Content-Type'] = 'text/xml; charset='.C('Garden.Charset', '');
}
if (is_object($this->Menu))
$this->Menu->Sort = Gdn::Config('Garden.Menu.Sort');
$ResolvedPath = strtolower(CombinePaths(array(Gdn::Dispatcher()->Application(), Gdn::Dispatcher()->ControllerName, Gdn::Dispatcher()->ControllerMethod)));
$this->ResolvedPath = $ResolvedPath;
$this->FireEvent('Initialize');
} | php | public function Initialize() {
if (in_array($this->SyndicationMethod, array(SYNDICATION_ATOM, SYNDICATION_RSS))) {
$this->_Headers['Content-Type'] = 'text/xml; charset='.C('Garden.Charset', '');
}
if (is_object($this->Menu))
$this->Menu->Sort = Gdn::Config('Garden.Menu.Sort');
$ResolvedPath = strtolower(CombinePaths(array(Gdn::Dispatcher()->Application(), Gdn::Dispatcher()->ControllerName, Gdn::Dispatcher()->ControllerMethod)));
$this->ResolvedPath = $ResolvedPath;
$this->FireEvent('Initialize');
} | [
"public",
"function",
"Initialize",
"(",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"SyndicationMethod",
",",
"array",
"(",
"SYNDICATION_ATOM",
",",
"SYNDICATION_RSS",
")",
")",
")",
"{",
"$",
"this",
"->",
"_Headers",
"[",
"'Content-Type'",
"]",
"=",
"'text/xml; charset='",
".",
"C",
"(",
"'Garden.Charset'",
",",
"''",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"Menu",
")",
")",
"$",
"this",
"->",
"Menu",
"->",
"Sort",
"=",
"Gdn",
"::",
"Config",
"(",
"'Garden.Menu.Sort'",
")",
";",
"$",
"ResolvedPath",
"=",
"strtolower",
"(",
"CombinePaths",
"(",
"array",
"(",
"Gdn",
"::",
"Dispatcher",
"(",
")",
"->",
"Application",
"(",
")",
",",
"Gdn",
"::",
"Dispatcher",
"(",
")",
"->",
"ControllerName",
",",
"Gdn",
"::",
"Dispatcher",
"(",
")",
"->",
"ControllerMethod",
")",
")",
")",
";",
"$",
"this",
"->",
"ResolvedPath",
"=",
"$",
"ResolvedPath",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'Initialize'",
")",
";",
"}"
] | The initialize method is called by the dispatcher after the constructor
has completed, objects have been passed along, assets have been
retrieved, and before the requested method fires. Use it in any extended
controller to do things like loading script and CSS into the head. | [
"The",
"initialize",
"method",
"is",
"called",
"by",
"the",
"dispatcher",
"after",
"the",
"constructor",
"has",
"completed",
"objects",
"have",
"been",
"passed",
"along",
"assets",
"have",
"been",
"retrieved",
"and",
"before",
"the",
"requested",
"method",
"fires",
".",
"Use",
"it",
"in",
"any",
"extended",
"controller",
"to",
"do",
"things",
"like",
"loading",
"script",
"and",
"CSS",
"into",
"the",
"head",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1057-L1069 |
10,356 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.Json | public function Json($Key, $Value = NULL) {
if(!is_null($Value)) {
$this->_Json[$Key] = $Value;
}
return ArrayValue($Key, $this->_Json, NULL);
} | php | public function Json($Key, $Value = NULL) {
if(!is_null($Value)) {
$this->_Json[$Key] = $Value;
}
return ArrayValue($Key, $this->_Json, NULL);
} | [
"public",
"function",
"Json",
"(",
"$",
"Key",
",",
"$",
"Value",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Value",
")",
")",
"{",
"$",
"this",
"->",
"_Json",
"[",
"$",
"Key",
"]",
"=",
"$",
"Value",
";",
"}",
"return",
"ArrayValue",
"(",
"$",
"Key",
",",
"$",
"this",
"->",
"_Json",
",",
"NULL",
")",
";",
"}"
] | If JSON is going to be sent to the client, this method allows you to add
extra values to the JSON array.
@param string $Key The name of the array key to add.
@param mixed $Value The value to be added. If null, then it won't be set.
@return mixed The value at the key. | [
"If",
"JSON",
"is",
"going",
"to",
"be",
"sent",
"to",
"the",
"client",
"this",
"method",
"allows",
"you",
"to",
"add",
"extra",
"values",
"to",
"the",
"JSON",
"array",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1083-L1088 |
10,357 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.MasterView | public function MasterView() {
// Define some default master views unless one was explicitly defined
if ($this->MasterView == '') {
// If this is a syndication request, use the appropriate master view
if ($this->SyndicationMethod == SYNDICATION_ATOM)
$this->MasterView = 'atom';
else if ($this->SyndicationMethod == SYNDICATION_RSS)
$this->MasterView = 'rss';
else
$this->MasterView = 'default'; // Otherwise go with the default
}
return $this->MasterView;
} | php | public function MasterView() {
// Define some default master views unless one was explicitly defined
if ($this->MasterView == '') {
// If this is a syndication request, use the appropriate master view
if ($this->SyndicationMethod == SYNDICATION_ATOM)
$this->MasterView = 'atom';
else if ($this->SyndicationMethod == SYNDICATION_RSS)
$this->MasterView = 'rss';
else
$this->MasterView = 'default'; // Otherwise go with the default
}
return $this->MasterView;
} | [
"public",
"function",
"MasterView",
"(",
")",
"{",
"// Define some default master views unless one was explicitly defined",
"if",
"(",
"$",
"this",
"->",
"MasterView",
"==",
"''",
")",
"{",
"// If this is a syndication request, use the appropriate master view",
"if",
"(",
"$",
"this",
"->",
"SyndicationMethod",
"==",
"SYNDICATION_ATOM",
")",
"$",
"this",
"->",
"MasterView",
"=",
"'atom'",
";",
"else",
"if",
"(",
"$",
"this",
"->",
"SyndicationMethod",
"==",
"SYNDICATION_RSS",
")",
"$",
"this",
"->",
"MasterView",
"=",
"'rss'",
";",
"else",
"$",
"this",
"->",
"MasterView",
"=",
"'default'",
";",
"// Otherwise go with the default",
"}",
"return",
"$",
"this",
"->",
"MasterView",
";",
"}"
] | Define & return the master view. | [
"Define",
"&",
"return",
"the",
"master",
"view",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1102-L1114 |
10,358 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.PageName | public function PageName($Value = NULL) {
if ($Value !== NULL) {
$this->_PageName = $Value;
return $Value;
}
if ($this->_PageName === NULL) {
if ($this->ControllerName)
$Name = $this->ControllerName;
else
$Name = get_class($this);
$Name = strtolower($Name);
if (StringEndsWith($Name, 'controller', FALSE))
$Name = substr($Name, 0, -strlen('controller'));
return $Name;
} else {
return $this->_PageName;
}
} | php | public function PageName($Value = NULL) {
if ($Value !== NULL) {
$this->_PageName = $Value;
return $Value;
}
if ($this->_PageName === NULL) {
if ($this->ControllerName)
$Name = $this->ControllerName;
else
$Name = get_class($this);
$Name = strtolower($Name);
if (StringEndsWith($Name, 'controller', FALSE))
$Name = substr($Name, 0, -strlen('controller'));
return $Name;
} else {
return $this->_PageName;
}
} | [
"public",
"function",
"PageName",
"(",
"$",
"Value",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"Value",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
"_PageName",
"=",
"$",
"Value",
";",
"return",
"$",
"Value",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_PageName",
"===",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ControllerName",
")",
"$",
"Name",
"=",
"$",
"this",
"->",
"ControllerName",
";",
"else",
"$",
"Name",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"Name",
"=",
"strtolower",
"(",
"$",
"Name",
")",
";",
"if",
"(",
"StringEndsWith",
"(",
"$",
"Name",
",",
"'controller'",
",",
"FALSE",
")",
")",
"$",
"Name",
"=",
"substr",
"(",
"$",
"Name",
",",
"0",
",",
"-",
"strlen",
"(",
"'controller'",
")",
")",
";",
"return",
"$",
"Name",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_PageName",
";",
"}",
"}"
] | Gets or sets the name of the page for the controller.
The page name is meant to be a friendly name suitable to be consumed by developers.
@param string|NULL $Value A new value to set. | [
"Gets",
"or",
"sets",
"the",
"name",
"of",
"the",
"page",
"for",
"the",
"controller",
".",
"The",
"page",
"name",
"is",
"meant",
"to",
"be",
"a",
"friendly",
"name",
"suitable",
"to",
"be",
"consumed",
"by",
"developers",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1124-L1144 |
10,359 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.Permission | public function Permission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '') {
$Session = Gdn::Session();
if (!$Session->CheckPermission($Permission, $FullMatch, $JunctionTable, $JunctionID)) {
if (!$Session->IsValid() && $this->DeliveryType() == DELIVERY_TYPE_ALL) {
Redirect('/entry/signin?Target='.urlencode($this->SelfUrl));
} else {
Gdn::Dispatcher()->Dispatch('DefaultPermission');
exit();
}
}
} | php | public function Permission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '') {
$Session = Gdn::Session();
if (!$Session->CheckPermission($Permission, $FullMatch, $JunctionTable, $JunctionID)) {
if (!$Session->IsValid() && $this->DeliveryType() == DELIVERY_TYPE_ALL) {
Redirect('/entry/signin?Target='.urlencode($this->SelfUrl));
} else {
Gdn::Dispatcher()->Dispatch('DefaultPermission');
exit();
}
}
} | [
"public",
"function",
"Permission",
"(",
"$",
"Permission",
",",
"$",
"FullMatch",
"=",
"TRUE",
",",
"$",
"JunctionTable",
"=",
"''",
",",
"$",
"JunctionID",
"=",
"''",
")",
"{",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"!",
"$",
"Session",
"->",
"CheckPermission",
"(",
"$",
"Permission",
",",
"$",
"FullMatch",
",",
"$",
"JunctionTable",
",",
"$",
"JunctionID",
")",
")",
"{",
"if",
"(",
"!",
"$",
"Session",
"->",
"IsValid",
"(",
")",
"&&",
"$",
"this",
"->",
"DeliveryType",
"(",
")",
"==",
"DELIVERY_TYPE_ALL",
")",
"{",
"Redirect",
"(",
"'/entry/signin?Target='",
".",
"urlencode",
"(",
"$",
"this",
"->",
"SelfUrl",
")",
")",
";",
"}",
"else",
"{",
"Gdn",
"::",
"Dispatcher",
"(",
")",
"->",
"Dispatch",
"(",
"'DefaultPermission'",
")",
";",
"exit",
"(",
")",
";",
"}",
"}",
"}"
] | Checks that the user has the specified permissions. If the user does not, they are redirected to the DefaultPermission route.
@param mixed $Permission A permission or array of permission names required to access this resource.
@param bool $FullMatch If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions.
@param string $JunctionTable The name of the junction table for a junction permission.
@param in $JunctionID The ID of the junction permission. | [
"Checks",
"that",
"the",
"user",
"has",
"the",
"specified",
"permissions",
".",
"If",
"the",
"user",
"does",
"not",
"they",
"are",
"redirected",
"to",
"the",
"DefaultPermission",
"route",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1153-L1164 |
10,360 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.RemoveCssFile | public function RemoveCssFile($FileName) {
foreach ($this->_CssFiles as $Key => $FileInfo) {
if ($FileInfo['FileName'] == $FileName) {
unset($this->_CssFiles[$Key]);
return;
}
}
} | php | public function RemoveCssFile($FileName) {
foreach ($this->_CssFiles as $Key => $FileInfo) {
if ($FileInfo['FileName'] == $FileName) {
unset($this->_CssFiles[$Key]);
return;
}
}
} | [
"public",
"function",
"RemoveCssFile",
"(",
"$",
"FileName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_CssFiles",
"as",
"$",
"Key",
"=>",
"$",
"FileInfo",
")",
"{",
"if",
"(",
"$",
"FileInfo",
"[",
"'FileName'",
"]",
"==",
"$",
"FileName",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_CssFiles",
"[",
"$",
"Key",
"]",
")",
";",
"return",
";",
"}",
"}",
"}"
] | Removes a CSS file from the collection.
@param string $FileName The CSS file to search for. | [
"Removes",
"a",
"CSS",
"file",
"from",
"the",
"collection",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1171-L1178 |
10,361 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.RemoveJsFile | public function RemoveJsFile($FileName) {
foreach ($this->_JsFiles as $Key => $FileInfo) {
if ($FileInfo['FileName'] == $FileName) {
unset($this->_JsFiles[$Key]);
return;
}
}
} | php | public function RemoveJsFile($FileName) {
foreach ($this->_JsFiles as $Key => $FileInfo) {
if ($FileInfo['FileName'] == $FileName) {
unset($this->_JsFiles[$Key]);
return;
}
}
} | [
"public",
"function",
"RemoveJsFile",
"(",
"$",
"FileName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_JsFiles",
"as",
"$",
"Key",
"=>",
"$",
"FileInfo",
")",
"{",
"if",
"(",
"$",
"FileInfo",
"[",
"'FileName'",
"]",
"==",
"$",
"FileName",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_JsFiles",
"[",
"$",
"Key",
"]",
")",
";",
"return",
";",
"}",
"}",
"}"
] | Removes a JS file from the collection.
@param string $FileName The JS file to search for. | [
"Removes",
"a",
"JS",
"file",
"from",
"the",
"collection",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1185-L1192 |
10,362 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller._RenderXml | protected function _RenderXml($Data, $Node = 'Data', $Indent = '') {
// Handle numeric arrays.
if (is_numeric($Node))
$Node = 'Item';
if (!$Node)
return;
echo "$Indent<$Node>";
if (is_scalar($Data)) {
echo htmlspecialchars($Data);
} else {
$Data = (array)$Data;
if (count($Data) > 0) {
foreach ($Data as $Key => $Value) {
echo "\n";
$this->_RenderXml($Value, $Key, $Indent.' ');
}
echo "\n";
}
}
echo "</$Node>";
} | php | protected function _RenderXml($Data, $Node = 'Data', $Indent = '') {
// Handle numeric arrays.
if (is_numeric($Node))
$Node = 'Item';
if (!$Node)
return;
echo "$Indent<$Node>";
if (is_scalar($Data)) {
echo htmlspecialchars($Data);
} else {
$Data = (array)$Data;
if (count($Data) > 0) {
foreach ($Data as $Key => $Value) {
echo "\n";
$this->_RenderXml($Value, $Key, $Indent.' ');
}
echo "\n";
}
}
echo "</$Node>";
} | [
"protected",
"function",
"_RenderXml",
"(",
"$",
"Data",
",",
"$",
"Node",
"=",
"'Data'",
",",
"$",
"Indent",
"=",
"''",
")",
"{",
"// Handle numeric arrays.",
"if",
"(",
"is_numeric",
"(",
"$",
"Node",
")",
")",
"$",
"Node",
"=",
"'Item'",
";",
"if",
"(",
"!",
"$",
"Node",
")",
"return",
";",
"echo",
"\"$Indent<$Node>\"",
";",
"if",
"(",
"is_scalar",
"(",
"$",
"Data",
")",
")",
"{",
"echo",
"htmlspecialchars",
"(",
"$",
"Data",
")",
";",
"}",
"else",
"{",
"$",
"Data",
"=",
"(",
"array",
")",
"$",
"Data",
";",
"if",
"(",
"count",
"(",
"$",
"Data",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"Data",
"as",
"$",
"Key",
"=>",
"$",
"Value",
")",
"{",
"echo",
"\"\\n\"",
";",
"$",
"this",
"->",
"_RenderXml",
"(",
"$",
"Value",
",",
"$",
"Key",
",",
"$",
"Indent",
".",
"' '",
")",
";",
"}",
"echo",
"\"\\n\"",
";",
"}",
"}",
"echo",
"\"</$Node>\"",
";",
"}"
] | A simple default method for rendering xml.
@param mixed $Data The data to render. This is usually $this->Data.
@param string $Node The name of the root node.
@param string $Indent The indent before the data for layout that is easier to read. | [
"A",
"simple",
"default",
"method",
"for",
"rendering",
"xml",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1468-L1491 |
10,363 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.SetData | public function SetData($Key, $Value = NULL, $AddProperty = FALSE) {
if (is_array($Key)) {
$this->Data = array_merge($this->Data, $Key);
if ($AddProperty === TRUE) {
foreach ($Key as $Name => $Value) {
$this->$Name = $Value;
}
}
return;
}
$this->Data[$Key] = $Value;
if($AddProperty === TRUE) {
$this->$Key = $Value;
}
return $Value;
} | php | public function SetData($Key, $Value = NULL, $AddProperty = FALSE) {
if (is_array($Key)) {
$this->Data = array_merge($this->Data, $Key);
if ($AddProperty === TRUE) {
foreach ($Key as $Name => $Value) {
$this->$Name = $Value;
}
}
return;
}
$this->Data[$Key] = $Value;
if($AddProperty === TRUE) {
$this->$Key = $Value;
}
return $Value;
} | [
"public",
"function",
"SetData",
"(",
"$",
"Key",
",",
"$",
"Value",
"=",
"NULL",
",",
"$",
"AddProperty",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"Key",
")",
")",
"{",
"$",
"this",
"->",
"Data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"Data",
",",
"$",
"Key",
")",
";",
"if",
"(",
"$",
"AddProperty",
"===",
"TRUE",
")",
"{",
"foreach",
"(",
"$",
"Key",
"as",
"$",
"Name",
"=>",
"$",
"Value",
")",
"{",
"$",
"this",
"->",
"$",
"Name",
"=",
"$",
"Value",
";",
"}",
"}",
"return",
";",
"}",
"$",
"this",
"->",
"Data",
"[",
"$",
"Key",
"]",
"=",
"$",
"Value",
";",
"if",
"(",
"$",
"AddProperty",
"===",
"TRUE",
")",
"{",
"$",
"this",
"->",
"$",
"Key",
"=",
"$",
"Value",
";",
"}",
"return",
"$",
"Value",
";",
"}"
] | Set data from a method call.
@param string $Key The key that identifies the data.
@param mixed $Value The data.
@param mixed $AddProperty Whether or not to also set the data as a property of this object.
@return mixed The $Value that was set. | [
"Set",
"data",
"from",
"a",
"method",
"call",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1889-L1906 |
10,364 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.SetLastModified | public function SetLastModified($LastModifiedDate) {
$GMD = gmdate('D, d M Y H:i:s', $LastModifiedDate) . ' GMT';
$this->SetHeader('Etag', '"'.$GMD.'"');
$this->SetHeader('Last-Modified', $GMD);
$IncomingHeaders = getallheaders();
if (
isset($IncomingHeaders['If-Modified-Since'])
&& isset ($IncomingHeaders['If-None-Match'])
) {
$IfNoneMatch = $IncomingHeaders['If-None-Match'];
$IfModifiedSince = $IncomingHeaders['If-Modified-Since'];
if($GMD == $IfNoneMatch && $IfModifiedSince == $GMD) {
$Database = Gdn::Database();
if(!is_null($Database))
$Database->CloseConnection();
$this->SetHeader('Content-Length', '0');
$this->SendHeaders();
header('HTTP/1.1 304 Not Modified');
exit("\n\n"); // Send two linefeeds so that the client knows the response is complete
}
}
} | php | public function SetLastModified($LastModifiedDate) {
$GMD = gmdate('D, d M Y H:i:s', $LastModifiedDate) . ' GMT';
$this->SetHeader('Etag', '"'.$GMD.'"');
$this->SetHeader('Last-Modified', $GMD);
$IncomingHeaders = getallheaders();
if (
isset($IncomingHeaders['If-Modified-Since'])
&& isset ($IncomingHeaders['If-None-Match'])
) {
$IfNoneMatch = $IncomingHeaders['If-None-Match'];
$IfModifiedSince = $IncomingHeaders['If-Modified-Since'];
if($GMD == $IfNoneMatch && $IfModifiedSince == $GMD) {
$Database = Gdn::Database();
if(!is_null($Database))
$Database->CloseConnection();
$this->SetHeader('Content-Length', '0');
$this->SendHeaders();
header('HTTP/1.1 304 Not Modified');
exit("\n\n"); // Send two linefeeds so that the client knows the response is complete
}
}
} | [
"public",
"function",
"SetLastModified",
"(",
"$",
"LastModifiedDate",
")",
"{",
"$",
"GMD",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s'",
",",
"$",
"LastModifiedDate",
")",
".",
"' GMT'",
";",
"$",
"this",
"->",
"SetHeader",
"(",
"'Etag'",
",",
"'\"'",
".",
"$",
"GMD",
".",
"'\"'",
")",
";",
"$",
"this",
"->",
"SetHeader",
"(",
"'Last-Modified'",
",",
"$",
"GMD",
")",
";",
"$",
"IncomingHeaders",
"=",
"getallheaders",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"IncomingHeaders",
"[",
"'If-Modified-Since'",
"]",
")",
"&&",
"isset",
"(",
"$",
"IncomingHeaders",
"[",
"'If-None-Match'",
"]",
")",
")",
"{",
"$",
"IfNoneMatch",
"=",
"$",
"IncomingHeaders",
"[",
"'If-None-Match'",
"]",
";",
"$",
"IfModifiedSince",
"=",
"$",
"IncomingHeaders",
"[",
"'If-Modified-Since'",
"]",
";",
"if",
"(",
"$",
"GMD",
"==",
"$",
"IfNoneMatch",
"&&",
"$",
"IfModifiedSince",
"==",
"$",
"GMD",
")",
"{",
"$",
"Database",
"=",
"Gdn",
"::",
"Database",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Database",
")",
")",
"$",
"Database",
"->",
"CloseConnection",
"(",
")",
";",
"$",
"this",
"->",
"SetHeader",
"(",
"'Content-Length'",
",",
"'0'",
")",
";",
"$",
"this",
"->",
"SendHeaders",
"(",
")",
";",
"header",
"(",
"'HTTP/1.1 304 Not Modified'",
")",
";",
"exit",
"(",
"\"\\n\\n\"",
")",
";",
"// Send two linefeeds so that the client knows the response is complete",
"}",
"}",
"}"
] | Looks for a Last-Modified header from the browser and compares it to the
supplied date. If the Last-Modified date is after the supplied date, the
controller will send a "304 Not Modified" response code to the web
browser and stop all execution. Otherwise it sets the Last-Modified
header for this page and continues processing.
@param string $LastModifiedDate A unix timestamp representing the date that the current page was last
modified. | [
"Looks",
"for",
"a",
"Last",
"-",
"Modified",
"header",
"from",
"the",
"browser",
"and",
"compares",
"it",
"to",
"the",
"supplied",
"date",
".",
"If",
"the",
"Last",
"-",
"Modified",
"date",
"is",
"after",
"the",
"supplied",
"date",
"the",
"controller",
"will",
"send",
"a",
"304",
"Not",
"Modified",
"response",
"code",
"to",
"the",
"web",
"browser",
"and",
"stop",
"all",
"execution",
".",
"Otherwise",
"it",
"sets",
"the",
"Last",
"-",
"Modified",
"header",
"for",
"this",
"page",
"and",
"continues",
"processing",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L1930-L1952 |
10,365 | bishopb/vanilla | library/core/class.controller.php | Gdn_Controller.Title | public function Title($Title = NULL, $Subtitle = NULL) {
if (!is_null($Title))
$this->SetData('Title', $Title);
if (!is_null($Subtitle))
$this->SetData('_Subtitle', $Subtitle);
return $this->Data('Title');
} | php | public function Title($Title = NULL, $Subtitle = NULL) {
if (!is_null($Title))
$this->SetData('Title', $Title);
if (!is_null($Subtitle))
$this->SetData('_Subtitle', $Subtitle);
return $this->Data('Title');
} | [
"public",
"function",
"Title",
"(",
"$",
"Title",
"=",
"NULL",
",",
"$",
"Subtitle",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Title",
")",
")",
"$",
"this",
"->",
"SetData",
"(",
"'Title'",
",",
"$",
"Title",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"Subtitle",
")",
")",
"$",
"this",
"->",
"SetData",
"(",
"'_Subtitle'",
",",
"$",
"Subtitle",
")",
";",
"return",
"$",
"this",
"->",
"Data",
"(",
"'Title'",
")",
";",
"}"
] | If this object has a "Head" object as a property, this will set it's Title value.
@param string $Title The value to pass to $this->Head->Title(). | [
"If",
"this",
"object",
"has",
"a",
"Head",
"object",
"as",
"a",
"property",
"this",
"will",
"set",
"it",
"s",
"Title",
"value",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.controller.php#L2030-L2038 |
10,366 | loopsframework/base | src/Loops/Element.php | Element.__getLoopsId | protected function __getLoopsId($refkey = NULL) {
if($this->__parent) {
return $this->__parent->__getLoopsId($this->__name)."-".$this->__name;
}
return spl_object_hash($this);
} | php | protected function __getLoopsId($refkey = NULL) {
if($this->__parent) {
return $this->__parent->__getLoopsId($this->__name)."-".$this->__name;
}
return spl_object_hash($this);
} | [
"protected",
"function",
"__getLoopsId",
"(",
"$",
"refkey",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"__parent",
")",
"{",
"return",
"$",
"this",
"->",
"__parent",
"->",
"__getLoopsId",
"(",
"$",
"this",
"->",
"__name",
")",
".",
"\"-\"",
".",
"$",
"this",
"->",
"__name",
";",
"}",
"return",
"spl_object_hash",
"(",
"$",
"this",
")",
";",
"}"
] | Generate the Loops id of this object.
If the object has no parent use its hash as the Loops id.
Otherwise add its name to the parents Loops id separated with a dash
@param string|NULL $refkey Defines the offset of a child which is requesting the Loops id
@return string The Loops id | [
"Generate",
"the",
"Loops",
"id",
"of",
"this",
"object",
"."
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Element.php#L122-L128 |
10,367 | loopsframework/base | src/Loops/Element.php | Element.offsetGet | public function offsetGet($offset) {
$value = parent::offsetGet($offset);
return $offset === "context" ? $value : $this->initChild($offset, $value);
} | php | public function offsetGet($offset) {
$value = parent::offsetGet($offset);
return $offset === "context" ? $value : $this->initChild($offset, $value);
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"$",
"value",
"=",
"parent",
"::",
"offsetGet",
"(",
"$",
"offset",
")",
";",
"return",
"$",
"offset",
"===",
"\"context\"",
"?",
"$",
"value",
":",
"$",
"this",
"->",
"initChild",
"(",
"$",
"offset",
",",
"$",
"value",
")",
";",
"}"
] | Automatically initializes child elements in case they were not initialized yet
@param string $offset The element offset | [
"Automatically",
"initializes",
"child",
"elements",
"in",
"case",
"they",
"were",
"not",
"initialized",
"yet"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Element.php#L206-L209 |
10,368 | loopsframework/base | src/Loops/Element.php | Element.offsetSet | public function offsetSet($offset, $value) {
parent::offsetSet($offset, $value);
$this->initChild($offset, $value, TRUE);
} | php | public function offsetSet($offset, $value) {
parent::offsetSet($offset, $value);
$this->initChild($offset, $value, TRUE);
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"parent",
"::",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"initChild",
"(",
"$",
"offset",
",",
"$",
"value",
",",
"TRUE",
")",
";",
"}"
] | Automatically initailizes child elements in case they were not initialized yet
If a element was already set on another element object, it will be detached.
@param string $offset The offset
@param mixed $value The value to be set at offset | [
"Automatically",
"initailizes",
"child",
"elements",
"in",
"case",
"they",
"were",
"not",
"initialized",
"yet"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Element.php#L219-L222 |
10,369 | loopsframework/base | src/Loops/Element.php | Element.offsetUnset | public function offsetUnset($offset) {
$detach = NULL;
if(parent::offsetExists($offset)) {
$child = parent::offsetGet($offset);
if($child instanceof Element && $child->__parent === $this) {
$detach = $child;
}
}
parent::offsetUnset($offset);
if($detach) {
$detach->detach();
}
} | php | public function offsetUnset($offset) {
$detach = NULL;
if(parent::offsetExists($offset)) {
$child = parent::offsetGet($offset);
if($child instanceof Element && $child->__parent === $this) {
$detach = $child;
}
}
parent::offsetUnset($offset);
if($detach) {
$detach->detach();
}
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"$",
"detach",
"=",
"NULL",
";",
"if",
"(",
"parent",
"::",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"child",
"=",
"parent",
"::",
"offsetGet",
"(",
"$",
"offset",
")",
";",
"if",
"(",
"$",
"child",
"instanceof",
"Element",
"&&",
"$",
"child",
"->",
"__parent",
"===",
"$",
"this",
")",
"{",
"$",
"detach",
"=",
"$",
"child",
";",
"}",
"}",
"parent",
"::",
"offsetUnset",
"(",
"$",
"offset",
")",
";",
"if",
"(",
"$",
"detach",
")",
"{",
"$",
"detach",
"->",
"detach",
"(",
")",
";",
"}",
"}"
] | Automatically detaches child elements if they belong to this element
@param string The offset | [
"Automatically",
"detaches",
"child",
"elements",
"if",
"they",
"belong",
"to",
"this",
"element"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Element.php#L229-L244 |
10,370 | loopsframework/base | src/Loops/Element.php | Element.action | public function action($parameter) {
$result = FALSE;
if($parameter) {
$name = $parameter[0];
$method_name = $name."Action";
if(method_exists($this, $method_name)) {
$result = $this->$method_name(array_slice($parameter, 1));
}
if(in_array($result, [FALSE, NULL], TRUE)) {
if($parameter && $this->offsetExists($name)) {
$child = $this->offsetGet($name);
if($child instanceof ElementInterface) {
$result = $child->action(array_slice($parameter, 1));
}
}
}
}
if(in_array($result, [FALSE, NULL], TRUE)) {
if($this->delegate_action) {
if($this->offsetExists($this->delegate_action)) {
$child = $this->offsetGet($this->delegate_action);
if($child instanceof ElementInterface) {
$result = $child->action($parameter);
}
}
}
}
if(in_array($result, [FALSE, NULL], TRUE)) {
if(!$parameter) {
if($this->direct_access) {
$result = TRUE;
}
else {
$loops = $this->getLoops();
if($loops->hasService("request") && $loops->getService("request")->isAjax() && $this->ajax_access) {
$result = TRUE;
}
}
}
}
if($result === TRUE) {
$result = $this;
}
return $result;
} | php | public function action($parameter) {
$result = FALSE;
if($parameter) {
$name = $parameter[0];
$method_name = $name."Action";
if(method_exists($this, $method_name)) {
$result = $this->$method_name(array_slice($parameter, 1));
}
if(in_array($result, [FALSE, NULL], TRUE)) {
if($parameter && $this->offsetExists($name)) {
$child = $this->offsetGet($name);
if($child instanceof ElementInterface) {
$result = $child->action(array_slice($parameter, 1));
}
}
}
}
if(in_array($result, [FALSE, NULL], TRUE)) {
if($this->delegate_action) {
if($this->offsetExists($this->delegate_action)) {
$child = $this->offsetGet($this->delegate_action);
if($child instanceof ElementInterface) {
$result = $child->action($parameter);
}
}
}
}
if(in_array($result, [FALSE, NULL], TRUE)) {
if(!$parameter) {
if($this->direct_access) {
$result = TRUE;
}
else {
$loops = $this->getLoops();
if($loops->hasService("request") && $loops->getService("request")->isAjax() && $this->ajax_access) {
$result = TRUE;
}
}
}
}
if($result === TRUE) {
$result = $this;
}
return $result;
} | [
"public",
"function",
"action",
"(",
"$",
"parameter",
")",
"{",
"$",
"result",
"=",
"FALSE",
";",
"if",
"(",
"$",
"parameter",
")",
"{",
"$",
"name",
"=",
"$",
"parameter",
"[",
"0",
"]",
";",
"$",
"method_name",
"=",
"$",
"name",
".",
"\"Action\"",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method_name",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"$",
"method_name",
"(",
"array_slice",
"(",
"$",
"parameter",
",",
"1",
")",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"result",
",",
"[",
"FALSE",
",",
"NULL",
"]",
",",
"TRUE",
")",
")",
"{",
"if",
"(",
"$",
"parameter",
"&&",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"child",
"=",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"child",
"instanceof",
"ElementInterface",
")",
"{",
"$",
"result",
"=",
"$",
"child",
"->",
"action",
"(",
"array_slice",
"(",
"$",
"parameter",
",",
"1",
")",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"in_array",
"(",
"$",
"result",
",",
"[",
"FALSE",
",",
"NULL",
"]",
",",
"TRUE",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"delegate_action",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"this",
"->",
"delegate_action",
")",
")",
"{",
"$",
"child",
"=",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"this",
"->",
"delegate_action",
")",
";",
"if",
"(",
"$",
"child",
"instanceof",
"ElementInterface",
")",
"{",
"$",
"result",
"=",
"$",
"child",
"->",
"action",
"(",
"$",
"parameter",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"in_array",
"(",
"$",
"result",
",",
"[",
"FALSE",
",",
"NULL",
"]",
",",
"TRUE",
")",
")",
"{",
"if",
"(",
"!",
"$",
"parameter",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"direct_access",
")",
"{",
"$",
"result",
"=",
"TRUE",
";",
"}",
"else",
"{",
"$",
"loops",
"=",
"$",
"this",
"->",
"getLoops",
"(",
")",
";",
"if",
"(",
"$",
"loops",
"->",
"hasService",
"(",
"\"request\"",
")",
"&&",
"$",
"loops",
"->",
"getService",
"(",
"\"request\"",
")",
"->",
"isAjax",
"(",
")",
"&&",
"$",
"this",
"->",
"ajax_access",
")",
"{",
"$",
"result",
"=",
"TRUE",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"result",
"===",
"TRUE",
")",
"{",
"$",
"result",
"=",
"$",
"this",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Default action processing
The default behaviour of an element is to not accept a request.
An element only accepts requests on default, when no parameter were passed and direct_access has been set to TRUE.
In an ajax call, it is also possible to set ajax_access to TRUE for accepting the request. The service request will
be checked if this currently is an ajax call.
The action method will return itself (rather than TRUE) when accepting a request. This makes it possible to determine
which (sub) element actually accepted the request.
If parameters are given, the following logic can be used to determine if a request should be accepted:
1. Take the first parameter and check for a method named "{param}Action", pass all parameters to it and use the resulting value.
If such a method does not exist or the value is NULL or FALSE do not accept the request, continue.
2. Take the first parameter and check if there is another Loops\Element instance at the offset defined by the parameter (->offsetExists($param) & ->offsetGet($param))
If such object exists execute that objects action, pass the rest of the parameter and use its return value, continue if it was NULL or FALSE.
3. Check if the element defines a property delegate_action and, prepend it to the action parameters and apply step 2.
@param array $parameter The action parameter.
@return mixed The processed value | [
"Default",
"action",
"processing"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Element.php#L283-L336 |
10,371 | loopsframework/base | src/Loops/Element.php | Element.detach | public function detach() {
if($this->__parent) {
$this->__parent->offsetUnset($this->__name);
}
$this->__parent = NULL;
$this->__name = NULL;
return $this;
} | php | public function detach() {
if($this->__parent) {
$this->__parent->offsetUnset($this->__name);
}
$this->__parent = NULL;
$this->__name = NULL;
return $this;
} | [
"public",
"function",
"detach",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"__parent",
")",
"{",
"$",
"this",
"->",
"__parent",
"->",
"offsetUnset",
"(",
"$",
"this",
"->",
"__name",
")",
";",
"}",
"$",
"this",
"->",
"__parent",
"=",
"NULL",
";",
"$",
"this",
"->",
"__name",
"=",
"NULL",
";",
"return",
"$",
"this",
";",
"}"
] | Reset the internal caching mechanism of the parent element and name.
This may be needed if you want to assign the element on a different object.
@return Loops\Element Returns $this for method chaining. | [
"Reset",
"the",
"internal",
"caching",
"mechanism",
"of",
"the",
"parent",
"element",
"and",
"name",
".",
"This",
"may",
"be",
"needed",
"if",
"you",
"want",
"to",
"assign",
"the",
"element",
"on",
"a",
"different",
"object",
"."
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Element.php#L344-L352 |
10,372 | luxorphp/mysql | src/ResultSetMYSQL.php | ResultSetMYSQL.each | public function each(callable $func) {
for ($index = 0; $index < count($this->fetch); $index++) {
call_user_func($func, $this->fetch[$index]);
}
} | php | public function each(callable $func) {
for ($index = 0; $index < count($this->fetch); $index++) {
call_user_func($func, $this->fetch[$index]);
}
} | [
"public",
"function",
"each",
"(",
"callable",
"$",
"func",
")",
"{",
"for",
"(",
"$",
"index",
"=",
"0",
";",
"$",
"index",
"<",
"count",
"(",
"$",
"this",
"->",
"fetch",
")",
";",
"$",
"index",
"++",
")",
"{",
"call_user_func",
"(",
"$",
"func",
",",
"$",
"this",
"->",
"fetch",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}"
] | Metodo que mapea el ResultSet y devuelve cada una de las filas.
@param callable Resive una funcion anonima como parametro, la cual se ejecuta
cuando se encuentra un fila dentro del ResulSet, cabe destacar que cada fila
encontrada se pasa como parametro a la funcion anonima. | [
"Metodo",
"que",
"mapea",
"el",
"ResultSet",
"y",
"devuelve",
"cada",
"una",
"de",
"las",
"filas",
"."
] | ca6ad7a82edd776d4a703f45a01bcaaf297af344 | https://github.com/luxorphp/mysql/blob/ca6ad7a82edd776d4a703f45a01bcaaf297af344/src/ResultSetMYSQL.php#L70-L74 |
10,373 | cekurte/component-bundle | src/Service/ResourceManager/DoctrineResourceManager.php | DoctrineResourceManager.setResourceClassName | protected function setResourceClassName($resourceClassName)
{
if (!is_string($resourceClassName)) {
throw new \InvalidArgumentException('The resource class name could be a string.');
}
if (empty($resourceClassName)) {
throw new \InvalidArgumentException('The resource class name could not be empty.');
}
$this->resourceClassName = $resourceClassName;
} | php | protected function setResourceClassName($resourceClassName)
{
if (!is_string($resourceClassName)) {
throw new \InvalidArgumentException('The resource class name could be a string.');
}
if (empty($resourceClassName)) {
throw new \InvalidArgumentException('The resource class name could not be empty.');
}
$this->resourceClassName = $resourceClassName;
} | [
"protected",
"function",
"setResourceClassName",
"(",
"$",
"resourceClassName",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"resourceClassName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The resource class name could be a string.'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"resourceClassName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The resource class name could not be empty.'",
")",
";",
"}",
"$",
"this",
"->",
"resourceClassName",
"=",
"$",
"resourceClassName",
";",
"}"
] | Set a resource class name.
@param string $resourceClassName | [
"Set",
"a",
"resource",
"class",
"name",
"."
] | 0c9b802068492095362e29a61180396463ff9904 | https://github.com/cekurte/component-bundle/blob/0c9b802068492095362e29a61180396463ff9904/src/Service/ResourceManager/DoctrineResourceManager.php#L59-L70 |
10,374 | laasti/lazydata | src/Data.php | Data.add | public function add($data, $overwrite = true)
{
foreach ($data as $property => $value) {
if ($overwrite || !$this->offsetExists($property)) {
$this->set($property, $value);
}
}
return $this;
} | php | public function add($data, $overwrite = true)
{
foreach ($data as $property => $value) {
if ($overwrite || !$this->offsetExists($property)) {
$this->set($property, $value);
}
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"data",
",",
"$",
"overwrite",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"overwrite",
"||",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"property",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Add data in batch from an array
@param array $data
@param bool $overwrite
@return Data | [
"Add",
"data",
"in",
"batch",
"from",
"an",
"array"
] | 44ceab7475177fc94eeb4fa3b8b630f5fc4fa301 | https://github.com/laasti/lazydata/blob/44ceab7475177fc94eeb4fa3b8b630f5fc4fa301/src/Data.php#L137-L145 |
10,375 | webforge-labs/webforge-dom | lib/Webforge/DOM/Query.php | Query.constructQuery | protected function constructQuery(Query $query, $selector = NULL) {
if ($selector !== NULL) {
throw new InvalidArgumentException('You must not provide a selector if query is first argument. Use find for that(!)');
}
$this->setSelector($query->getSelector());
$this->document = $query->getDocument();
parent::__construct($query->toArray());
$this->length = count($this);
} | php | protected function constructQuery(Query $query, $selector = NULL) {
if ($selector !== NULL) {
throw new InvalidArgumentException('You must not provide a selector if query is first argument. Use find for that(!)');
}
$this->setSelector($query->getSelector());
$this->document = $query->getDocument();
parent::__construct($query->toArray());
$this->length = count($this);
} | [
"protected",
"function",
"constructQuery",
"(",
"Query",
"$",
"query",
",",
"$",
"selector",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"selector",
"!==",
"NULL",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'You must not provide a selector if query is first argument. Use find for that(!)'",
")",
";",
"}",
"$",
"this",
"->",
"setSelector",
"(",
"$",
"query",
"->",
"getSelector",
"(",
")",
")",
";",
"$",
"this",
"->",
"document",
"=",
"$",
"query",
"->",
"getDocument",
"(",
")",
";",
"parent",
"::",
"__construct",
"(",
"$",
"query",
"->",
"toArray",
"(",
")",
")",
";",
"$",
"this",
"->",
"length",
"=",
"count",
"(",
"$",
"this",
")",
";",
"}"
] | Clones a Query Object | [
"Clones",
"a",
"Query",
"Object"
] | 79bc03e8cb1a483e122e700d15bbb9ac607dd39b | https://github.com/webforge-labs/webforge-dom/blob/79bc03e8cb1a483e122e700d15bbb9ac607dd39b/lib/Webforge/DOM/Query.php#L144-L153 |
10,376 | webforge-labs/webforge-dom | lib/Webforge/DOM/Query.php | Query.find | public function find($selector) {
if (!is_string($selector)) throw new \InvalidArgumentException('Kann bis jetzt nur string als find Parameter');
$cnt = count($this);
if ($cnt != 1) {
throw new Exception('Kann bis jetzt nur find() auf Query-Objekten mit genau 1 Element. '.$this->selector.' ('.$cnt.')');
}
// erstellt ein Objekt mit dem Document als unser Element
// mit den matched Elements als das Ergebnis des Selectors in diesem Document
$Query = new self($selector, $this->getElement());
$Query->setPrevObject($this);
$Query->setSelector($this->selector.' '.$selector);
return $Query;
} | php | public function find($selector) {
if (!is_string($selector)) throw new \InvalidArgumentException('Kann bis jetzt nur string als find Parameter');
$cnt = count($this);
if ($cnt != 1) {
throw new Exception('Kann bis jetzt nur find() auf Query-Objekten mit genau 1 Element. '.$this->selector.' ('.$cnt.')');
}
// erstellt ein Objekt mit dem Document als unser Element
// mit den matched Elements als das Ergebnis des Selectors in diesem Document
$Query = new self($selector, $this->getElement());
$Query->setPrevObject($this);
$Query->setSelector($this->selector.' '.$selector);
return $Query;
} | [
"public",
"function",
"find",
"(",
"$",
"selector",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"selector",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Kann bis jetzt nur string als find Parameter'",
")",
";",
"$",
"cnt",
"=",
"count",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"cnt",
"!=",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Kann bis jetzt nur find() auf Query-Objekten mit genau 1 Element. '",
".",
"$",
"this",
"->",
"selector",
".",
"' ('",
".",
"$",
"cnt",
".",
"')'",
")",
";",
"}",
"// erstellt ein Objekt mit dem Document als unser Element",
"// mit den matched Elements als das Ergebnis des Selectors in diesem Document",
"$",
"Query",
"=",
"new",
"self",
"(",
"$",
"selector",
",",
"$",
"this",
"->",
"getElement",
"(",
")",
")",
";",
"$",
"Query",
"->",
"setPrevObject",
"(",
"$",
"this",
")",
";",
"$",
"Query",
"->",
"setSelector",
"(",
"$",
"this",
"->",
"selector",
".",
"' '",
".",
"$",
"selector",
")",
";",
"return",
"$",
"Query",
";",
"}"
] | Find an Element in the matched elements of this element
@return Query | [
"Find",
"an",
"Element",
"in",
"the",
"matched",
"elements",
"of",
"this",
"element"
] | 79bc03e8cb1a483e122e700d15bbb9ac607dd39b | https://github.com/webforge-labs/webforge-dom/blob/79bc03e8cb1a483e122e700d15bbb9ac607dd39b/lib/Webforge/DOM/Query.php#L168-L184 |
10,377 | webforge-labs/webforge-dom | lib/Webforge/DOM/Query.php | Query.setSelector | public function setSelector($selector) {
$this->literalSelector = $selector;
$this->selector = $selector;
$this->selector = str_replace(':first', ':nth-of-type(1)', $this->selector);
// nth-of-type is a NOT nice alias for eq but its 1-based (eq ist 0-based)
// but its not the same! fix me!
$this->selector = Preg::replace_callback(
$this->selector,
'/:eq\(([0-9]+)\)/',
function ($m) {
return sprintf(':nth-of-type(%d)', $m[1]+1);
}
);
return $this;
} | php | public function setSelector($selector) {
$this->literalSelector = $selector;
$this->selector = $selector;
$this->selector = str_replace(':first', ':nth-of-type(1)', $this->selector);
// nth-of-type is a NOT nice alias for eq but its 1-based (eq ist 0-based)
// but its not the same! fix me!
$this->selector = Preg::replace_callback(
$this->selector,
'/:eq\(([0-9]+)\)/',
function ($m) {
return sprintf(':nth-of-type(%d)', $m[1]+1);
}
);
return $this;
} | [
"public",
"function",
"setSelector",
"(",
"$",
"selector",
")",
"{",
"$",
"this",
"->",
"literalSelector",
"=",
"$",
"selector",
";",
"$",
"this",
"->",
"selector",
"=",
"$",
"selector",
";",
"$",
"this",
"->",
"selector",
"=",
"str_replace",
"(",
"':first'",
",",
"':nth-of-type(1)'",
",",
"$",
"this",
"->",
"selector",
")",
";",
"// nth-of-type is a NOT nice alias for eq but its 1-based (eq ist 0-based)",
"// but its not the same! fix me!",
"$",
"this",
"->",
"selector",
"=",
"Preg",
"::",
"replace_callback",
"(",
"$",
"this",
"->",
"selector",
",",
"'/:eq\\(([0-9]+)\\)/'",
",",
"function",
"(",
"$",
"m",
")",
"{",
"return",
"sprintf",
"(",
"':nth-of-type(%d)'",
",",
"$",
"m",
"[",
"1",
"]",
"+",
"1",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets and parses the selector
The result set is not re-callculated | [
"Sets",
"and",
"parses",
"the",
"selector"
] | 79bc03e8cb1a483e122e700d15bbb9ac607dd39b | https://github.com/webforge-labs/webforge-dom/blob/79bc03e8cb1a483e122e700d15bbb9ac607dd39b/lib/Webforge/DOM/Query.php#L202-L218 |
10,378 | webforge-labs/webforge-dom | lib/Webforge/DOM/Query.php | Query.attr | public function attr($name, $value = NULL) {
if (($el = $this->getElement()) === NULL) return NULL;
if ($el->hasAttribute($name)) {
if (func_num_args() == 2) {
$el->setAttribute($name, $value);
}
return $el->getAttribute($name);
}
return NULL;
} | php | public function attr($name, $value = NULL) {
if (($el = $this->getElement()) === NULL) return NULL;
if ($el->hasAttribute($name)) {
if (func_num_args() == 2) {
$el->setAttribute($name, $value);
}
return $el->getAttribute($name);
}
return NULL;
} | [
"public",
"function",
"attr",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"if",
"(",
"(",
"$",
"el",
"=",
"$",
"this",
"->",
"getElement",
"(",
")",
")",
"===",
"NULL",
")",
"return",
"NULL",
";",
"if",
"(",
"$",
"el",
"->",
"hasAttribute",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"2",
")",
"{",
"$",
"el",
"->",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"el",
"->",
"getAttribute",
"(",
"$",
"name",
")",
";",
"}",
"return",
"NULL",
";",
"}"
] | Returns or sets the attribute of the first matched Element
@param mixed $value if $value is provided the attribute is set to this value
@return string|NULL | [
"Returns",
"or",
"sets",
"the",
"attribute",
"of",
"the",
"first",
"matched",
"Element"
] | 79bc03e8cb1a483e122e700d15bbb9ac607dd39b | https://github.com/webforge-labs/webforge-dom/blob/79bc03e8cb1a483e122e700d15bbb9ac607dd39b/lib/Webforge/DOM/Query.php#L303-L315 |
10,379 | webforge-labs/webforge-dom | lib/Webforge/DOM/Query.php | Query.outerHtml | public function outerHtml() {
if (($el = $this->getElement()) === NULL) return NULL;
return $el->ownerDocument->saveXML($el);
} | php | public function outerHtml() {
if (($el = $this->getElement()) === NULL) return NULL;
return $el->ownerDocument->saveXML($el);
} | [
"public",
"function",
"outerHtml",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"el",
"=",
"$",
"this",
"->",
"getElement",
"(",
")",
")",
"===",
"NULL",
")",
"return",
"NULL",
";",
"return",
"$",
"el",
"->",
"ownerDocument",
"->",
"saveXML",
"(",
"$",
"el",
")",
";",
"}"
] | Returns the whole HTML of the first matched element
@return string | [
"Returns",
"the",
"whole",
"HTML",
"of",
"the",
"first",
"matched",
"element"
] | 79bc03e8cb1a483e122e700d15bbb9ac607dd39b | https://github.com/webforge-labs/webforge-dom/blob/79bc03e8cb1a483e122e700d15bbb9ac607dd39b/lib/Webforge/DOM/Query.php#L333-L337 |
10,380 | AthensFramework/Core | src/writer/TwigTemplateWriter.php | TwigTemplateWriter.getEnvironment | protected function getEnvironment()
{
if ($this->environment === null) {
$loader = new \Twig_Loader_Filesystem($this->getTemplatesDirectories());
$this->environment = new \Twig_Environment($loader);
$filter = new Twig_SimpleFilter(
'write',
function (WritableInterface $host) {
return $host->accept($this);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'slugify',
function ($string) {
return StringUtils::slugify($string);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'html_attribute',
function ($string) {
return preg_replace(array('/[^a-zA-Z0-9 -]/','/^-|-$/'), array('',''), $string);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'md5',
function ($string) {
return md5($string);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'stripForm',
function ($string) {
$string = str_replace("<form", "<div", $string);
$string = preg_replace('#<div class="form-actions">(.*?)</div>#', '', $string);
$string = str_replace("form-actions", "form-actions hidden", $string);
$string = str_replace(" form-errors", " form-errors hidden", $string);
$string = str_replace('"form-errors', '"form-errors hidden', $string);
$string = str_replace("</form>", "</div>", $string);
return $string;
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'saferaw',
function ($string) {
if ($string instanceof SafeString) {
$string = (string)$string;
} else {
$string = htmlentities($string);
}
return $string;
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'writedata',
function ($data) {
$string = ' ';
foreach ($data as $key => $value) {
$key = htmlentities($key);
$value = htmlentities($value);
$string .= "data-$key=\"$value\" ";
}
return trim($string);
}
);
$this->environment->addFilter($filter);
$requestURI = array_key_exists("REQUEST_URI", $_SERVER) === true ? $_SERVER["REQUEST_URI"] : "";
$this->environment->addGlobal("requestURI", $requestURI);
}
return $this->environment;
} | php | protected function getEnvironment()
{
if ($this->environment === null) {
$loader = new \Twig_Loader_Filesystem($this->getTemplatesDirectories());
$this->environment = new \Twig_Environment($loader);
$filter = new Twig_SimpleFilter(
'write',
function (WritableInterface $host) {
return $host->accept($this);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'slugify',
function ($string) {
return StringUtils::slugify($string);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'html_attribute',
function ($string) {
return preg_replace(array('/[^a-zA-Z0-9 -]/','/^-|-$/'), array('',''), $string);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'md5',
function ($string) {
return md5($string);
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'stripForm',
function ($string) {
$string = str_replace("<form", "<div", $string);
$string = preg_replace('#<div class="form-actions">(.*?)</div>#', '', $string);
$string = str_replace("form-actions", "form-actions hidden", $string);
$string = str_replace(" form-errors", " form-errors hidden", $string);
$string = str_replace('"form-errors', '"form-errors hidden', $string);
$string = str_replace("</form>", "</div>", $string);
return $string;
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'saferaw',
function ($string) {
if ($string instanceof SafeString) {
$string = (string)$string;
} else {
$string = htmlentities($string);
}
return $string;
}
);
$this->environment->addFilter($filter);
$filter = new Twig_SimpleFilter(
'writedata',
function ($data) {
$string = ' ';
foreach ($data as $key => $value) {
$key = htmlentities($key);
$value = htmlentities($value);
$string .= "data-$key=\"$value\" ";
}
return trim($string);
}
);
$this->environment->addFilter($filter);
$requestURI = array_key_exists("REQUEST_URI", $_SERVER) === true ? $_SERVER["REQUEST_URI"] : "";
$this->environment->addGlobal("requestURI", $requestURI);
}
return $this->environment;
} | [
"protected",
"function",
"getEnvironment",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"environment",
"===",
"null",
")",
"{",
"$",
"loader",
"=",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
"$",
"this",
"->",
"getTemplatesDirectories",
"(",
")",
")",
";",
"$",
"this",
"->",
"environment",
"=",
"new",
"\\",
"Twig_Environment",
"(",
"$",
"loader",
")",
";",
"$",
"filter",
"=",
"new",
"Twig_SimpleFilter",
"(",
"'write'",
",",
"function",
"(",
"WritableInterface",
"$",
"host",
")",
"{",
"return",
"$",
"host",
"->",
"accept",
"(",
"$",
"this",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"$",
"filter",
"=",
"new",
"Twig_SimpleFilter",
"(",
"'slugify'",
",",
"function",
"(",
"$",
"string",
")",
"{",
"return",
"StringUtils",
"::",
"slugify",
"(",
"$",
"string",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"$",
"filter",
"=",
"new",
"Twig_SimpleFilter",
"(",
"'html_attribute'",
",",
"function",
"(",
"$",
"string",
")",
"{",
"return",
"preg_replace",
"(",
"array",
"(",
"'/[^a-zA-Z0-9 -]/'",
",",
"'/^-|-$/'",
")",
",",
"array",
"(",
"''",
",",
"''",
")",
",",
"$",
"string",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"$",
"filter",
"=",
"new",
"Twig_SimpleFilter",
"(",
"'md5'",
",",
"function",
"(",
"$",
"string",
")",
"{",
"return",
"md5",
"(",
"$",
"string",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"$",
"filter",
"=",
"new",
"Twig_SimpleFilter",
"(",
"'stripForm'",
",",
"function",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"\"<form\"",
",",
"\"<div\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'#<div class=\"form-actions\">(.*?)</div>#'",
",",
"''",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"\"form-actions\"",
",",
"\"form-actions hidden\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"\" form-errors\"",
",",
"\" form-errors hidden\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"'\"form-errors'",
",",
"'\"form-errors hidden'",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"\"</form>\"",
",",
"\"</div>\"",
",",
"$",
"string",
")",
";",
"return",
"$",
"string",
";",
"}",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"$",
"filter",
"=",
"new",
"Twig_SimpleFilter",
"(",
"'saferaw'",
",",
"function",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"string",
"instanceof",
"SafeString",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"string",
";",
"}",
"else",
"{",
"$",
"string",
"=",
"htmlentities",
"(",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"$",
"filter",
"=",
"new",
"Twig_SimpleFilter",
"(",
"'writedata'",
",",
"function",
"(",
"$",
"data",
")",
"{",
"$",
"string",
"=",
"' '",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"htmlentities",
"(",
"$",
"key",
")",
";",
"$",
"value",
"=",
"htmlentities",
"(",
"$",
"value",
")",
";",
"$",
"string",
".=",
"\"data-$key=\\\"$value\\\" \"",
";",
"}",
"return",
"trim",
"(",
"$",
"string",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"$",
"requestURI",
"=",
"array_key_exists",
"(",
"\"REQUEST_URI\"",
",",
"$",
"_SERVER",
")",
"===",
"true",
"?",
"$",
"_SERVER",
"[",
"\"REQUEST_URI\"",
"]",
":",
"\"\"",
";",
"$",
"this",
"->",
"environment",
"->",
"addGlobal",
"(",
"\"requestURI\"",
",",
"$",
"requestURI",
")",
";",
"}",
"return",
"$",
"this",
"->",
"environment",
";",
"}"
] | Get this Writer's Twig_Environment; create if it doesn't exist;
@return \Twig_Environment | [
"Get",
"this",
"Writer",
"s",
"Twig_Environment",
";",
"create",
"if",
"it",
"doesn",
"t",
"exist",
";"
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/TwigTemplateWriter.php#L53-L141 |
10,381 | GustavoGutierrez/PostType | src/Taxonomy/Builder.php | Builder.register | private function register() {
$this->options['labels'] = $this->label;
if (!isset($this->options['rewrite'])) {
$this->options['rewrite'] = array('slug' => $this->singular);
}
$_self = &$this;
add_action('init', function () use (&$_self) {
register_taxonomy($_self->singular, $_self->post_types, $this->options);
});
} | php | private function register() {
$this->options['labels'] = $this->label;
if (!isset($this->options['rewrite'])) {
$this->options['rewrite'] = array('slug' => $this->singular);
}
$_self = &$this;
add_action('init', function () use (&$_self) {
register_taxonomy($_self->singular, $_self->post_types, $this->options);
});
} | [
"private",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'labels'",
"]",
"=",
"$",
"this",
"->",
"label",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'rewrite'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'rewrite'",
"]",
"=",
"array",
"(",
"'slug'",
"=>",
"$",
"this",
"->",
"singular",
")",
";",
"}",
"$",
"_self",
"=",
"&",
"$",
"this",
";",
"add_action",
"(",
"'init'",
",",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"_self",
")",
"{",
"register_taxonomy",
"(",
"$",
"_self",
"->",
"singular",
",",
"$",
"_self",
"->",
"post_types",
",",
"$",
"this",
"->",
"options",
")",
";",
"}",
")",
";",
"}"
] | Register the Taxonomy
@return void | [
"Register",
"the",
"Taxonomy"
] | 3e9951eca67596e5160453bc8f90b46b2cc264f9 | https://github.com/GustavoGutierrez/PostType/blob/3e9951eca67596e5160453bc8f90b46b2cc264f9/src/Taxonomy/Builder.php#L91-L104 |
10,382 | GustavoGutierrez/PostType | src/Taxonomy/Builder.php | Builder._setLabel | private function _setLabel($label) {
if ($label && is_array($label)) {
$this->label = $label;
return true;
}
$singular = $this->singular;
$plural = $this->plural ?: $singular . $this->plural_end;
$this->label = array(
'name' => ucfirst($plural),
'singular' => ucfirst($singular),
'menu_name' => ucfirst($singular),
'all_items' => __('All', 'wba_taxonomy') . ' ' . $plural,
'parent_item' => __('Parent', 'wba_taxonomy') . ' ' . $singular,
'parent_item_colon' => __('Parent', 'wba_taxonomy') . ' ' . $singular,
'new_item_name' => __('New', 'wba_taxonomy') . ' ' . $singular,
'add_new_item' => __('Add New', 'wba_taxonomy') . ' ' . $singular,
'edit_item' => __('Edit', 'wba_taxonomy') . ' ' . $singular,
'update_item' => __('Update', 'wba_taxonomy') . ' ' . $singular,
'view_item' => __('View', 'wba_taxonomy') . ' ' . $singular,
'separate_items_with_commas' => __('Separate', 'wba_taxonomy') . strtolower($singular) . ' ' . __('with commas', 'wba_taxonomy'),
'add_or_remove_items' => __('Add or remove', 'wba_taxonomy') . strtolower($singular),
'choose_from_most_used' => __('Choose from the most used', 'wba_taxonomy'),
'popular_items' => ucfirst($plural),
'search_items' => __('Search', 'wba_taxonomy') . ' ' . $singular,
'not_found' => __('Not Found', 'wba_taxonomy'),
'no_terms' => __('No', 'wba_taxonomy') . ' ' . $singular,
'items_list' => ucfirst($singular) . ' ' . __('list', 'wba_taxonomy'),
'items_list_navigation' => ucfirst($singular) . ' ' . __('list navigation', 'wba_taxonomy'),
);
return true;
} | php | private function _setLabel($label) {
if ($label && is_array($label)) {
$this->label = $label;
return true;
}
$singular = $this->singular;
$plural = $this->plural ?: $singular . $this->plural_end;
$this->label = array(
'name' => ucfirst($plural),
'singular' => ucfirst($singular),
'menu_name' => ucfirst($singular),
'all_items' => __('All', 'wba_taxonomy') . ' ' . $plural,
'parent_item' => __('Parent', 'wba_taxonomy') . ' ' . $singular,
'parent_item_colon' => __('Parent', 'wba_taxonomy') . ' ' . $singular,
'new_item_name' => __('New', 'wba_taxonomy') . ' ' . $singular,
'add_new_item' => __('Add New', 'wba_taxonomy') . ' ' . $singular,
'edit_item' => __('Edit', 'wba_taxonomy') . ' ' . $singular,
'update_item' => __('Update', 'wba_taxonomy') . ' ' . $singular,
'view_item' => __('View', 'wba_taxonomy') . ' ' . $singular,
'separate_items_with_commas' => __('Separate', 'wba_taxonomy') . strtolower($singular) . ' ' . __('with commas', 'wba_taxonomy'),
'add_or_remove_items' => __('Add or remove', 'wba_taxonomy') . strtolower($singular),
'choose_from_most_used' => __('Choose from the most used', 'wba_taxonomy'),
'popular_items' => ucfirst($plural),
'search_items' => __('Search', 'wba_taxonomy') . ' ' . $singular,
'not_found' => __('Not Found', 'wba_taxonomy'),
'no_terms' => __('No', 'wba_taxonomy') . ' ' . $singular,
'items_list' => ucfirst($singular) . ' ' . __('list', 'wba_taxonomy'),
'items_list_navigation' => ucfirst($singular) . ' ' . __('list navigation', 'wba_taxonomy'),
);
return true;
} | [
"private",
"function",
"_setLabel",
"(",
"$",
"label",
")",
"{",
"if",
"(",
"$",
"label",
"&&",
"is_array",
"(",
"$",
"label",
")",
")",
"{",
"$",
"this",
"->",
"label",
"=",
"$",
"label",
";",
"return",
"true",
";",
"}",
"$",
"singular",
"=",
"$",
"this",
"->",
"singular",
";",
"$",
"plural",
"=",
"$",
"this",
"->",
"plural",
"?",
":",
"$",
"singular",
".",
"$",
"this",
"->",
"plural_end",
";",
"$",
"this",
"->",
"label",
"=",
"array",
"(",
"'name'",
"=>",
"ucfirst",
"(",
"$",
"plural",
")",
",",
"'singular'",
"=>",
"ucfirst",
"(",
"$",
"singular",
")",
",",
"'menu_name'",
"=>",
"ucfirst",
"(",
"$",
"singular",
")",
",",
"'all_items'",
"=>",
"__",
"(",
"'All'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"plural",
",",
"'parent_item'",
"=>",
"__",
"(",
"'Parent'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'parent_item_colon'",
"=>",
"__",
"(",
"'Parent'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'new_item_name'",
"=>",
"__",
"(",
"'New'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'add_new_item'",
"=>",
"__",
"(",
"'Add New'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'edit_item'",
"=>",
"__",
"(",
"'Edit'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'update_item'",
"=>",
"__",
"(",
"'Update'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'view_item'",
"=>",
"__",
"(",
"'View'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'separate_items_with_commas'",
"=>",
"__",
"(",
"'Separate'",
",",
"'wba_taxonomy'",
")",
".",
"strtolower",
"(",
"$",
"singular",
")",
".",
"' '",
".",
"__",
"(",
"'with commas'",
",",
"'wba_taxonomy'",
")",
",",
"'add_or_remove_items'",
"=>",
"__",
"(",
"'Add or remove'",
",",
"'wba_taxonomy'",
")",
".",
"strtolower",
"(",
"$",
"singular",
")",
",",
"'choose_from_most_used'",
"=>",
"__",
"(",
"'Choose from the most used'",
",",
"'wba_taxonomy'",
")",
",",
"'popular_items'",
"=>",
"ucfirst",
"(",
"$",
"plural",
")",
",",
"'search_items'",
"=>",
"__",
"(",
"'Search'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'not_found'",
"=>",
"__",
"(",
"'Not Found'",
",",
"'wba_taxonomy'",
")",
",",
"'no_terms'",
"=>",
"__",
"(",
"'No'",
",",
"'wba_taxonomy'",
")",
".",
"' '",
".",
"$",
"singular",
",",
"'items_list'",
"=>",
"ucfirst",
"(",
"$",
"singular",
")",
".",
"' '",
".",
"__",
"(",
"'list'",
",",
"'wba_taxonomy'",
")",
",",
"'items_list_navigation'",
"=>",
"ucfirst",
"(",
"$",
"singular",
")",
".",
"' '",
".",
"__",
"(",
"'list navigation'",
",",
"'wba_taxonomy'",
")",
",",
")",
";",
"return",
"true",
";",
"}"
] | Sets the The labels for post type.
@param array $label the label
@return self | [
"Sets",
"the",
"The",
"labels",
"for",
"post",
"type",
"."
] | 3e9951eca67596e5160453bc8f90b46b2cc264f9 | https://github.com/GustavoGutierrez/PostType/blob/3e9951eca67596e5160453bc8f90b46b2cc264f9/src/Taxonomy/Builder.php#L183-L216 |
10,383 | as3io/modlr-persister-mongodb | src/StorageMetadataFactory.php | StorageMetadataFactory.rksort | private function rksort(array $array)
{
ksort($array);
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = $this->rksort($v);
}
}
return $array;
} | php | private function rksort(array $array)
{
ksort($array);
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = $this->rksort($v);
}
}
return $array;
} | [
"private",
"function",
"rksort",
"(",
"array",
"$",
"array",
")",
"{",
"ksort",
"(",
"$",
"array",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"array",
"[",
"$",
"k",
"]",
"=",
"$",
"this",
"->",
"rksort",
"(",
"$",
"v",
")",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] | Recursively ksorts an array
@param array
@return array | [
"Recursively",
"ksorts",
"an",
"array"
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/StorageMetadataFactory.php#L80-L89 |
10,384 | as3io/modlr-persister-mongodb | src/StorageMetadataFactory.php | StorageMetadataFactory.validateCollectionNaming | private function validateCollectionNaming(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
if (false === $this->entityUtil->isEntityTypeValid($persistence->collection)) {
throw MetadataException::invalidMetadata(
$metadata->type,
sprintf('The entity persistence collection "%s" is invalid based on the configured name format "%s"',
$persistence->collection,
$this->entityUtil->getRestConfig()->getEntityFormat()
)
);
}
} | php | private function validateCollectionNaming(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
if (false === $this->entityUtil->isEntityTypeValid($persistence->collection)) {
throw MetadataException::invalidMetadata(
$metadata->type,
sprintf('The entity persistence collection "%s" is invalid based on the configured name format "%s"',
$persistence->collection,
$this->entityUtil->getRestConfig()->getEntityFormat()
)
);
}
} | [
"private",
"function",
"validateCollectionNaming",
"(",
"EntityMetadata",
"$",
"metadata",
")",
"{",
"$",
"persistence",
"=",
"$",
"metadata",
"->",
"persistence",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"entityUtil",
"->",
"isEntityTypeValid",
"(",
"$",
"persistence",
"->",
"collection",
")",
")",
"{",
"throw",
"MetadataException",
"::",
"invalidMetadata",
"(",
"$",
"metadata",
"->",
"type",
",",
"sprintf",
"(",
"'The entity persistence collection \"%s\" is invalid based on the configured name format \"%s\"'",
",",
"$",
"persistence",
"->",
"collection",
",",
"$",
"this",
"->",
"entityUtil",
"->",
"getRestConfig",
"(",
")",
"->",
"getEntityFormat",
"(",
")",
")",
")",
";",
"}",
"}"
] | Validates that the collection naming is correct, based on entity format config.
@param EntityMetadata $metadata
@throws MetadataException | [
"Validates",
"that",
"the",
"collection",
"naming",
"is",
"correct",
"based",
"on",
"entity",
"format",
"config",
"."
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/StorageMetadataFactory.php#L97-L109 |
10,385 | as3io/modlr-persister-mongodb | src/StorageMetadataFactory.php | StorageMetadataFactory.validateDatabase | private function validateDatabase(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
if (false === $metadata->isChildEntity() && (empty($persistence->db) || empty($persistence->collection))) {
throw MetadataException::invalidMetadata($metadata->type, 'The persistence database and collection names cannot be empty.');
}
} | php | private function validateDatabase(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
if (false === $metadata->isChildEntity() && (empty($persistence->db) || empty($persistence->collection))) {
throw MetadataException::invalidMetadata($metadata->type, 'The persistence database and collection names cannot be empty.');
}
} | [
"private",
"function",
"validateDatabase",
"(",
"EntityMetadata",
"$",
"metadata",
")",
"{",
"$",
"persistence",
"=",
"$",
"metadata",
"->",
"persistence",
";",
"if",
"(",
"false",
"===",
"$",
"metadata",
"->",
"isChildEntity",
"(",
")",
"&&",
"(",
"empty",
"(",
"$",
"persistence",
"->",
"db",
")",
"||",
"empty",
"(",
"$",
"persistence",
"->",
"collection",
")",
")",
")",
"{",
"throw",
"MetadataException",
"::",
"invalidMetadata",
"(",
"$",
"metadata",
"->",
"type",
",",
"'The persistence database and collection names cannot be empty.'",
")",
";",
"}",
"}"
] | Validates that the proper database properties are set.
@param EntityMetadata $metadata
@throws MetadataException | [
"Validates",
"that",
"the",
"proper",
"database",
"properties",
"are",
"set",
"."
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/StorageMetadataFactory.php#L117-L123 |
10,386 | as3io/modlr-persister-mongodb | src/StorageMetadataFactory.php | StorageMetadataFactory.validateIdStrategy | private function validateIdStrategy(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
$validIdStrategies = ['object'];
if (!in_array($persistence->idStrategy, $validIdStrategies)) {
throw MetadataException::invalidMetadata($metadata->type, sprintf('The persistence id strategy "%s" is invalid. Valid types are "%s"', $persistence->idStrategy, implode('", "', $validIdStrategies)));
}
} | php | private function validateIdStrategy(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
$validIdStrategies = ['object'];
if (!in_array($persistence->idStrategy, $validIdStrategies)) {
throw MetadataException::invalidMetadata($metadata->type, sprintf('The persistence id strategy "%s" is invalid. Valid types are "%s"', $persistence->idStrategy, implode('", "', $validIdStrategies)));
}
} | [
"private",
"function",
"validateIdStrategy",
"(",
"EntityMetadata",
"$",
"metadata",
")",
"{",
"$",
"persistence",
"=",
"$",
"metadata",
"->",
"persistence",
";",
"$",
"validIdStrategies",
"=",
"[",
"'object'",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"persistence",
"->",
"idStrategy",
",",
"$",
"validIdStrategies",
")",
")",
"{",
"throw",
"MetadataException",
"::",
"invalidMetadata",
"(",
"$",
"metadata",
"->",
"type",
",",
"sprintf",
"(",
"'The persistence id strategy \"%s\" is invalid. Valid types are \"%s\"'",
",",
"$",
"persistence",
"->",
"idStrategy",
",",
"implode",
"(",
"'\", \"'",
",",
"$",
"validIdStrategies",
")",
")",
")",
";",
"}",
"}"
] | Validates the proper id strategy.
@param EntityMetadata $metadata
@throws MetadataException | [
"Validates",
"the",
"proper",
"id",
"strategy",
"."
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/StorageMetadataFactory.php#L131-L138 |
10,387 | as3io/modlr-persister-mongodb | src/StorageMetadataFactory.php | StorageMetadataFactory.validateSchemata | private function validateSchemata(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
foreach ($persistence->schemata as $k => $schema) {
if (!isset($schema['keys']) || empty($schema['keys'])) {
throw MetadataException::invalidMetadata($metadata->type, 'At least one key must be specified to define an index.');
}
$persistence->schemata[$k]['options']['name'] = sprintf('modlr_%s', md5(json_encode($schema)));
}
} | php | private function validateSchemata(EntityMetadata $metadata)
{
$persistence = $metadata->persistence;
foreach ($persistence->schemata as $k => $schema) {
if (!isset($schema['keys']) || empty($schema['keys'])) {
throw MetadataException::invalidMetadata($metadata->type, 'At least one key must be specified to define an index.');
}
$persistence->schemata[$k]['options']['name'] = sprintf('modlr_%s', md5(json_encode($schema)));
}
} | [
"private",
"function",
"validateSchemata",
"(",
"EntityMetadata",
"$",
"metadata",
")",
"{",
"$",
"persistence",
"=",
"$",
"metadata",
"->",
"persistence",
";",
"foreach",
"(",
"$",
"persistence",
"->",
"schemata",
"as",
"$",
"k",
"=>",
"$",
"schema",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"schema",
"[",
"'keys'",
"]",
")",
"||",
"empty",
"(",
"$",
"schema",
"[",
"'keys'",
"]",
")",
")",
"{",
"throw",
"MetadataException",
"::",
"invalidMetadata",
"(",
"$",
"metadata",
"->",
"type",
",",
"'At least one key must be specified to define an index.'",
")",
";",
"}",
"$",
"persistence",
"->",
"schemata",
"[",
"$",
"k",
"]",
"[",
"'options'",
"]",
"[",
"'name'",
"]",
"=",
"sprintf",
"(",
"'modlr_%s'",
",",
"md5",
"(",
"json_encode",
"(",
"$",
"schema",
")",
")",
")",
";",
"}",
"}"
] | Validates the schema definitions
@param EntityMetadata $metadata
@throws MetadataException | [
"Validates",
"the",
"schema",
"definitions"
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/StorageMetadataFactory.php#L146-L155 |
10,388 | webriq/core | module/Core/src/Grid/Core/Model/Package/EnabledListServiceFactory.php | EnabledListServiceFactory.createService | public function createService( ServiceLocatorInterface $serviceLocator )
{
// Configure the definitions
$config = $serviceLocator->get( 'Configuration' );
$coreConfig = isset( $config['modules']['Grid\Core'] )
? (array) $config['modules']['Grid\Core']
: array();
return new EnabledList(
isset( $coreConfig['enabledPackages'] )
? (array) $coreConfig['enabledPackages']
: array(),
isset( $coreConfig['modifyPackages'] )
? (bool) $coreConfig['modifyPackages']
: true
);
} | php | public function createService( ServiceLocatorInterface $serviceLocator )
{
// Configure the definitions
$config = $serviceLocator->get( 'Configuration' );
$coreConfig = isset( $config['modules']['Grid\Core'] )
? (array) $config['modules']['Grid\Core']
: array();
return new EnabledList(
isset( $coreConfig['enabledPackages'] )
? (array) $coreConfig['enabledPackages']
: array(),
isset( $coreConfig['modifyPackages'] )
? (bool) $coreConfig['modifyPackages']
: true
);
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"// Configure the definitions",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Configuration'",
")",
";",
"$",
"coreConfig",
"=",
"isset",
"(",
"$",
"config",
"[",
"'modules'",
"]",
"[",
"'Grid\\Core'",
"]",
")",
"?",
"(",
"array",
")",
"$",
"config",
"[",
"'modules'",
"]",
"[",
"'Grid\\Core'",
"]",
":",
"array",
"(",
")",
";",
"return",
"new",
"EnabledList",
"(",
"isset",
"(",
"$",
"coreConfig",
"[",
"'enabledPackages'",
"]",
")",
"?",
"(",
"array",
")",
"$",
"coreConfig",
"[",
"'enabledPackages'",
"]",
":",
"array",
"(",
")",
",",
"isset",
"(",
"$",
"coreConfig",
"[",
"'modifyPackages'",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"coreConfig",
"[",
"'modifyPackages'",
"]",
":",
"true",
")",
";",
"}"
] | Create the enabled-list-service
@param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
@return \Grid\Core\Model\Package\EnabledList | [
"Create",
"the",
"enabled",
"-",
"list",
"-",
"service"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Package/EnabledListServiceFactory.php#L22-L38 |
10,389 | ARCANESOFT/Tracker | src/Providers/PackagesServiceProvider.php | PackagesServiceProvider.registerLaravelTrackerPackage | private function registerLaravelTrackerPackage()
{
$this->registerProvider(LaravelTrackerServiceProvider::class);
$config = $this->config();
$items = $config->get('arcanesoft.tracker');
$config->set('laravel-tracker.database', Arr::get($items, 'database'));
$config->set('laravel-tracker.models', Arr::get($items, 'models'));
$config->set('laravel-tracker.tracking', Arr::get($items, 'tracking'));
$config->set('laravel-tracker.routes', Arr::get($items, 'routes'));
} | php | private function registerLaravelTrackerPackage()
{
$this->registerProvider(LaravelTrackerServiceProvider::class);
$config = $this->config();
$items = $config->get('arcanesoft.tracker');
$config->set('laravel-tracker.database', Arr::get($items, 'database'));
$config->set('laravel-tracker.models', Arr::get($items, 'models'));
$config->set('laravel-tracker.tracking', Arr::get($items, 'tracking'));
$config->set('laravel-tracker.routes', Arr::get($items, 'routes'));
} | [
"private",
"function",
"registerLaravelTrackerPackage",
"(",
")",
"{",
"$",
"this",
"->",
"registerProvider",
"(",
"LaravelTrackerServiceProvider",
"::",
"class",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"(",
")",
";",
"$",
"items",
"=",
"$",
"config",
"->",
"get",
"(",
"'arcanesoft.tracker'",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'laravel-tracker.database'",
",",
"Arr",
"::",
"get",
"(",
"$",
"items",
",",
"'database'",
")",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'laravel-tracker.models'",
",",
"Arr",
"::",
"get",
"(",
"$",
"items",
",",
"'models'",
")",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'laravel-tracker.tracking'",
",",
"Arr",
"::",
"get",
"(",
"$",
"items",
",",
"'tracking'",
")",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'laravel-tracker.routes'",
",",
"Arr",
"::",
"get",
"(",
"$",
"items",
",",
"'routes'",
")",
")",
";",
"}"
] | Register Laravel Tracker package. | [
"Register",
"Laravel",
"Tracker",
"package",
"."
] | d106209b32ddbb192066715f0ef99afccfc22dcb | https://github.com/ARCANESOFT/Tracker/blob/d106209b32ddbb192066715f0ef99afccfc22dcb/src/Providers/PackagesServiceProvider.php#L60-L71 |
10,390 | loginbox/loginbox-awt-php | AuthToken.php | AuthToken.generate | public static function generate(array $payload, $key)
{
// Check if payload is array
if (!is_array($payload)) {
throw new InvalidArgumentException('Token payload must be an array');
}
// Check if payload or key is empty
if (empty($payload) || empty($key)) {
throw new InvalidArgumentException('Both payload and key must have a value');
}
// Encode with json and base64
$payloadEncoded = base64_encode(json_encode($payload, JSON_FORCE_OBJECT));
// Create signature
$signature = hash_hmac($algo = 'SHA256', $data = $payloadEncoded, $key);
// Return combined key
return implode('.', [$payloadEncoded, $signature]);
} | php | public static function generate(array $payload, $key)
{
// Check if payload is array
if (!is_array($payload)) {
throw new InvalidArgumentException('Token payload must be an array');
}
// Check if payload or key is empty
if (empty($payload) || empty($key)) {
throw new InvalidArgumentException('Both payload and key must have a value');
}
// Encode with json and base64
$payloadEncoded = base64_encode(json_encode($payload, JSON_FORCE_OBJECT));
// Create signature
$signature = hash_hmac($algo = 'SHA256', $data = $payloadEncoded, $key);
// Return combined key
return implode('.', [$payloadEncoded, $signature]);
} | [
"public",
"static",
"function",
"generate",
"(",
"array",
"$",
"payload",
",",
"$",
"key",
")",
"{",
"// Check if payload is array",
"if",
"(",
"!",
"is_array",
"(",
"$",
"payload",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Token payload must be an array'",
")",
";",
"}",
"// Check if payload or key is empty",
"if",
"(",
"empty",
"(",
"$",
"payload",
")",
"||",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Both payload and key must have a value'",
")",
";",
"}",
"// Encode with json and base64",
"$",
"payloadEncoded",
"=",
"base64_encode",
"(",
"json_encode",
"(",
"$",
"payload",
",",
"JSON_FORCE_OBJECT",
")",
")",
";",
"// Create signature",
"$",
"signature",
"=",
"hash_hmac",
"(",
"$",
"algo",
"=",
"'SHA256'",
",",
"$",
"data",
"=",
"$",
"payloadEncoded",
",",
"$",
"key",
")",
";",
"// Return combined key",
"return",
"implode",
"(",
"'.'",
",",
"[",
"$",
"payloadEncoded",
",",
"$",
"signature",
"]",
")",
";",
"}"
] | Generate an authentication token.
@param array $payload The payload in the form of array.
@param string $key The key to sign the token.
@return string
@throws InvalidArgumentException | [
"Generate",
"an",
"authentication",
"token",
"."
] | 36094f95323ff43a18f787a617e89a416cb33527 | https://github.com/loginbox/loginbox-awt-php/blob/36094f95323ff43a18f787a617e89a416cb33527/AuthToken.php#L32-L52 |
10,391 | loginbox/loginbox-awt-php | AuthToken.php | AuthToken.getPayload | public static function getPayload($token, $jsonDecode = true)
{
// Split parts
list($payload, $signature) = explode('.', $token);
// Decode first part
$payloadJSON = base64_decode($payload);
// Choose to decode or not
if ($jsonDecode) {
return json_decode($payloadJSON, true);
}
// Return json
return $payloadJSON;
} | php | public static function getPayload($token, $jsonDecode = true)
{
// Split parts
list($payload, $signature) = explode('.', $token);
// Decode first part
$payloadJSON = base64_decode($payload);
// Choose to decode or not
if ($jsonDecode) {
return json_decode($payloadJSON, true);
}
// Return json
return $payloadJSON;
} | [
"public",
"static",
"function",
"getPayload",
"(",
"$",
"token",
",",
"$",
"jsonDecode",
"=",
"true",
")",
"{",
"// Split parts",
"list",
"(",
"$",
"payload",
",",
"$",
"signature",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"token",
")",
";",
"// Decode first part",
"$",
"payloadJSON",
"=",
"base64_decode",
"(",
"$",
"payload",
")",
";",
"// Choose to decode or not",
"if",
"(",
"$",
"jsonDecode",
")",
"{",
"return",
"json_decode",
"(",
"$",
"payloadJSON",
",",
"true",
")",
";",
"}",
"// Return json",
"return",
"$",
"payloadJSON",
";",
"}"
] | Get the payload from the token.
@param string $token The authentication token.
@param boolean $jsonDecode Whether to decode the payload from json to array.
@return mixed Array or json string according to $jsonDecode value. | [
"Get",
"the",
"payload",
"from",
"the",
"token",
"."
] | 36094f95323ff43a18f787a617e89a416cb33527 | https://github.com/loginbox/loginbox-awt-php/blob/36094f95323ff43a18f787a617e89a416cb33527/AuthToken.php#L62-L77 |
10,392 | loginbox/loginbox-awt-php | AuthToken.php | AuthToken.verify | public static function verify($token, $key)
{
// Check values
if (empty($token) || empty($key)) {
return false;
}
// Split parts
list($payloadJSON_encoded, $signature) = explode('.', $token);
// Generate signature to verify
$signatureGenerated = hash_hmac('SHA256', $payloadJSON_encoded, $key);
return ($signature === $signatureGenerated);
} | php | public static function verify($token, $key)
{
// Check values
if (empty($token) || empty($key)) {
return false;
}
// Split parts
list($payloadJSON_encoded, $signature) = explode('.', $token);
// Generate signature to verify
$signatureGenerated = hash_hmac('SHA256', $payloadJSON_encoded, $key);
return ($signature === $signatureGenerated);
} | [
"public",
"static",
"function",
"verify",
"(",
"$",
"token",
",",
"$",
"key",
")",
"{",
"// Check values",
"if",
"(",
"empty",
"(",
"$",
"token",
")",
"||",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Split parts",
"list",
"(",
"$",
"payloadJSON_encoded",
",",
"$",
"signature",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"token",
")",
";",
"// Generate signature to verify",
"$",
"signatureGenerated",
"=",
"hash_hmac",
"(",
"'SHA256'",
",",
"$",
"payloadJSON_encoded",
",",
"$",
"key",
")",
";",
"return",
"(",
"$",
"signature",
"===",
"$",
"signatureGenerated",
")",
";",
"}"
] | Verify the given token with the given signature key.
@param string $token The authentication token.
@param string $key The signature secret key.
@return boolean True if valid, false otherwise. | [
"Verify",
"the",
"given",
"token",
"with",
"the",
"given",
"signature",
"key",
"."
] | 36094f95323ff43a18f787a617e89a416cb33527 | https://github.com/loginbox/loginbox-awt-php/blob/36094f95323ff43a18f787a617e89a416cb33527/AuthToken.php#L87-L101 |
10,393 | matudelatower/ubicacion-bundle | Controller/DepartamentoController.php | DepartamentoController.showAction | public function showAction(Departamento $departamento)
{
$deleteForm = $this->createDeleteForm($departamento);
return $this->render('UbicacionBundle:departamento:show.html.twig', array(
'departamento' => $departamento,
'delete_form' => $deleteForm->createView(),
));
} | php | public function showAction(Departamento $departamento)
{
$deleteForm = $this->createDeleteForm($departamento);
return $this->render('UbicacionBundle:departamento:show.html.twig', array(
'departamento' => $departamento,
'delete_form' => $deleteForm->createView(),
));
} | [
"public",
"function",
"showAction",
"(",
"Departamento",
"$",
"departamento",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"departamento",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'UbicacionBundle:departamento:show.html.twig'",
",",
"array",
"(",
"'departamento'",
"=>",
"$",
"departamento",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] | Finds and displays a Departamento entity. | [
"Finds",
"and",
"displays",
"a",
"Departamento",
"entity",
"."
] | f2daef3f72ae3120386cb9fb8d67fc5fcbb5b5df | https://github.com/matudelatower/ubicacion-bundle/blob/f2daef3f72ae3120386cb9fb8d67fc5fcbb5b5df/Controller/DepartamentoController.php#L59-L67 |
10,394 | matudelatower/ubicacion-bundle | Controller/DepartamentoController.php | DepartamentoController.deleteAction | public function deleteAction(Request $request, Departamento $departamento)
{
$form = $this->createDeleteForm($departamento);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($departamento);
$em->flush();
}
return $this->redirectToRoute('departamento_index');
} | php | public function deleteAction(Request $request, Departamento $departamento)
{
$form = $this->createDeleteForm($departamento);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($departamento);
$em->flush();
}
return $this->redirectToRoute('departamento_index');
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"Departamento",
"$",
"departamento",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"departamento",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"remove",
"(",
"$",
"departamento",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'departamento_index'",
")",
";",
"}"
] | Deletes a Departamento entity. | [
"Deletes",
"a",
"Departamento",
"entity",
"."
] | f2daef3f72ae3120386cb9fb8d67fc5fcbb5b5df | https://github.com/matudelatower/ubicacion-bundle/blob/f2daef3f72ae3120386cb9fb8d67fc5fcbb5b5df/Controller/DepartamentoController.php#L98-L110 |
10,395 | matudelatower/ubicacion-bundle | Controller/DepartamentoController.php | DepartamentoController.createDeleteForm | private function createDeleteForm(Departamento $departamento)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('departamento_delete', array('id' => $departamento->getId())))
->setMethod('DELETE')
->getForm()
;
} | php | private function createDeleteForm(Departamento $departamento)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('departamento_delete', array('id' => $departamento->getId())))
->setMethod('DELETE')
->getForm()
;
} | [
"private",
"function",
"createDeleteForm",
"(",
"Departamento",
"$",
"departamento",
")",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'departamento_delete'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"departamento",
"->",
"getId",
"(",
")",
")",
")",
")",
"->",
"setMethod",
"(",
"'DELETE'",
")",
"->",
"getForm",
"(",
")",
";",
"}"
] | Creates a form to delete a Departamento entity.
@param Departamento $departamento The Departamento entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"delete",
"a",
"Departamento",
"entity",
"."
] | f2daef3f72ae3120386cb9fb8d67fc5fcbb5b5df | https://github.com/matudelatower/ubicacion-bundle/blob/f2daef3f72ae3120386cb9fb8d67fc5fcbb5b5df/Controller/DepartamentoController.php#L119-L126 |
10,396 | daiko/php-files | app/File.php | File.copy | public function copy($dest)
{
// La source n'existe pas
if (!file_exists($this->path)) {
throw new \Exception("Source don't exist : " . $this->path, 1);
}
// La destination ne doit pas exister.
if (file_exists($dest)) {
throw new \Exception("Destination already exist : $dest", 1);
}
if (is_file($this->path)) {
// Copie d'un fichier dans un dossier.
if (is_dir($dest)) {
$dest = $this->addSlash($dest) . basename($this->path);
}
copy($this->path, $dest);
return;
}
$dest = $this->addSlash($dest);
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$this->path,
\RecursiveDirectoryIterator::SKIP_DOTS
)
);
foreach ($iterator as $path => $file) {
$fileDest = $dest . $iterator->getSubPathName();
if (!file_exists(dirname($fileDest))) {
mkdir(dirname($fileDest), 0777, true);
}
copy($path, $fileDest);
}
} | php | public function copy($dest)
{
// La source n'existe pas
if (!file_exists($this->path)) {
throw new \Exception("Source don't exist : " . $this->path, 1);
}
// La destination ne doit pas exister.
if (file_exists($dest)) {
throw new \Exception("Destination already exist : $dest", 1);
}
if (is_file($this->path)) {
// Copie d'un fichier dans un dossier.
if (is_dir($dest)) {
$dest = $this->addSlash($dest) . basename($this->path);
}
copy($this->path, $dest);
return;
}
$dest = $this->addSlash($dest);
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$this->path,
\RecursiveDirectoryIterator::SKIP_DOTS
)
);
foreach ($iterator as $path => $file) {
$fileDest = $dest . $iterator->getSubPathName();
if (!file_exists(dirname($fileDest))) {
mkdir(dirname($fileDest), 0777, true);
}
copy($path, $fileDest);
}
} | [
"public",
"function",
"copy",
"(",
"$",
"dest",
")",
"{",
"// La source n'existe pas",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Source don't exist : \"",
".",
"$",
"this",
"->",
"path",
",",
"1",
")",
";",
"}",
"// La destination ne doit pas exister.",
"if",
"(",
"file_exists",
"(",
"$",
"dest",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Destination already exist : $dest\"",
",",
"1",
")",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"path",
")",
")",
"{",
"// Copie d'un fichier dans un dossier.",
"if",
"(",
"is_dir",
"(",
"$",
"dest",
")",
")",
"{",
"$",
"dest",
"=",
"$",
"this",
"->",
"addSlash",
"(",
"$",
"dest",
")",
".",
"basename",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}",
"copy",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"dest",
")",
";",
"return",
";",
"}",
"$",
"dest",
"=",
"$",
"this",
"->",
"addSlash",
"(",
"$",
"dest",
")",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"this",
"->",
"path",
",",
"\\",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"path",
"=>",
"$",
"file",
")",
"{",
"$",
"fileDest",
"=",
"$",
"dest",
".",
"$",
"iterator",
"->",
"getSubPathName",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"fileDest",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"fileDest",
")",
",",
"0777",
",",
"true",
")",
";",
"}",
"copy",
"(",
"$",
"path",
",",
"$",
"fileDest",
")",
";",
"}",
"}"
] | Copy this file to destination
@param [type] $destination [description]
@return [type] [description] | [
"Copy",
"this",
"file",
"to",
"destination"
] | 4c4d77f05f1ffe3590c71d653cacf5ab2ec545b9 | https://github.com/daiko/php-files/blob/4c4d77f05f1ffe3590c71d653cacf5ab2ec545b9/app/File.php#L24-L61 |
10,397 | crater-framework/crater-php-framework | Orm/Gateway/TableAbstract.php | TableAbstract._delete | protected function _delete($where)
{
$params = array();
$query = "DELETE FROM $this->_name";
$iWhere = 0;
$query .= " WHERE (";
foreach ($where as $key => $value) {
if (!is_int($key)) {
$query .= "$key = :where$iWhere AND ";
$params[":where$iWhere"] = $value;
$iWhere++;
} else {
$query .= "$value AND";
}
}
$query = substr($query, 0, -4);
$query .= ")";
$db = $this->db;
$sth = $db->prepare($query);
foreach ($params as $key => $val) {
if (is_int($val)) {
$sth->bindValue("$key", $val, $db::PARAM_INT);
} else {
$sth->bindValue("$key", $val);
}
}
$response = $sth->execute();
if ($response) {
return true;
}
return false;
} | php | protected function _delete($where)
{
$params = array();
$query = "DELETE FROM $this->_name";
$iWhere = 0;
$query .= " WHERE (";
foreach ($where as $key => $value) {
if (!is_int($key)) {
$query .= "$key = :where$iWhere AND ";
$params[":where$iWhere"] = $value;
$iWhere++;
} else {
$query .= "$value AND";
}
}
$query = substr($query, 0, -4);
$query .= ")";
$db = $this->db;
$sth = $db->prepare($query);
foreach ($params as $key => $val) {
if (is_int($val)) {
$sth->bindValue("$key", $val, $db::PARAM_INT);
} else {
$sth->bindValue("$key", $val);
}
}
$response = $sth->execute();
if ($response) {
return true;
}
return false;
} | [
"protected",
"function",
"_delete",
"(",
"$",
"where",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"query",
"=",
"\"DELETE FROM $this->_name\"",
";",
"$",
"iWhere",
"=",
"0",
";",
"$",
"query",
".=",
"\" WHERE (\"",
";",
"foreach",
"(",
"$",
"where",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"query",
".=",
"\"$key = :where$iWhere AND \"",
";",
"$",
"params",
"[",
"\":where$iWhere\"",
"]",
"=",
"$",
"value",
";",
"$",
"iWhere",
"++",
";",
"}",
"else",
"{",
"$",
"query",
".=",
"\"$value AND\"",
";",
"}",
"}",
"$",
"query",
"=",
"substr",
"(",
"$",
"query",
",",
"0",
",",
"-",
"4",
")",
";",
"$",
"query",
".=",
"\")\"",
";",
"$",
"db",
"=",
"$",
"this",
"->",
"db",
";",
"$",
"sth",
"=",
"$",
"db",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"val",
")",
")",
"{",
"$",
"sth",
"->",
"bindValue",
"(",
"\"$key\"",
",",
"$",
"val",
",",
"$",
"db",
"::",
"PARAM_INT",
")",
";",
"}",
"else",
"{",
"$",
"sth",
"->",
"bindValue",
"(",
"\"$key\"",
",",
"$",
"val",
")",
";",
"}",
"}",
"$",
"response",
"=",
"$",
"sth",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"$",
"response",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Delete a row or rowset
@param array $where Where conditions array
@return bool | [
"Delete",
"a",
"row",
"or",
"rowset"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Orm/Gateway/TableAbstract.php#L252-L290 |
10,398 | wisquimas/valleysofsorcery | admin/mf_custom_taxonomy.php | mf_custom_taxonomy.edit_custom_taxonomy | public function edit_custom_taxonomy() {
if(!isset($_GET['custom_taxonomy_id']) ){
$this->mf_redirect(null,null,array('message' => 'success'));
}
$custom_taxonomy = $this->get_custom_taxonomy($_GET['custom_taxonomy_id']);
if( !$custom_taxonomy ){
$this->mf_redirect(null,null,array('message' => 'error'));
}
$data = $this->fields_form();
$post_types = array();
if( isset($custom_taxonomy['post_types']) ){
foreach($custom_taxonomy['post_types'] as $k => $v){
array_push($post_types,$v);
}
$data['taxonomy']['post_type'] = $post_types;
}
// update fields
$perm = array('core','option','label');
foreach($custom_taxonomy as $key => $value){
if( in_array($key,$perm) ){
foreach($value as $id => $val){
$data[$key][$id]['value'] = $val;
}
}
}
$this->form_custom_taxonomy($data);
} | php | public function edit_custom_taxonomy() {
if(!isset($_GET['custom_taxonomy_id']) ){
$this->mf_redirect(null,null,array('message' => 'success'));
}
$custom_taxonomy = $this->get_custom_taxonomy($_GET['custom_taxonomy_id']);
if( !$custom_taxonomy ){
$this->mf_redirect(null,null,array('message' => 'error'));
}
$data = $this->fields_form();
$post_types = array();
if( isset($custom_taxonomy['post_types']) ){
foreach($custom_taxonomy['post_types'] as $k => $v){
array_push($post_types,$v);
}
$data['taxonomy']['post_type'] = $post_types;
}
// update fields
$perm = array('core','option','label');
foreach($custom_taxonomy as $key => $value){
if( in_array($key,$perm) ){
foreach($value as $id => $val){
$data[$key][$id]['value'] = $val;
}
}
}
$this->form_custom_taxonomy($data);
} | [
"public",
"function",
"edit_custom_taxonomy",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_GET",
"[",
"'custom_taxonomy_id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"mf_redirect",
"(",
"null",
",",
"null",
",",
"array",
"(",
"'message'",
"=>",
"'success'",
")",
")",
";",
"}",
"$",
"custom_taxonomy",
"=",
"$",
"this",
"->",
"get_custom_taxonomy",
"(",
"$",
"_GET",
"[",
"'custom_taxonomy_id'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"custom_taxonomy",
")",
"{",
"$",
"this",
"->",
"mf_redirect",
"(",
"null",
",",
"null",
",",
"array",
"(",
"'message'",
"=>",
"'error'",
")",
")",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"fields_form",
"(",
")",
";",
"$",
"post_types",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"custom_taxonomy",
"[",
"'post_types'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"custom_taxonomy",
"[",
"'post_types'",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"array_push",
"(",
"$",
"post_types",
",",
"$",
"v",
")",
";",
"}",
"$",
"data",
"[",
"'taxonomy'",
"]",
"[",
"'post_type'",
"]",
"=",
"$",
"post_types",
";",
"}",
"// update fields",
"$",
"perm",
"=",
"array",
"(",
"'core'",
",",
"'option'",
",",
"'label'",
")",
";",
"foreach",
"(",
"$",
"custom_taxonomy",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"perm",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"id",
"=>",
"$",
"val",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"[",
"$",
"id",
"]",
"[",
"'value'",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"form_custom_taxonomy",
"(",
"$",
"data",
")",
";",
"}"
] | Edit custom taxonomy | [
"Edit",
"custom",
"taxonomy"
] | 78a8d8f1d1102c5043e2cf7c98762e63464d2d7a | https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_taxonomy.php#L24-L54 |
10,399 | wisquimas/valleysofsorcery | admin/mf_custom_taxonomy.php | mf_custom_taxonomy.get_custom_taxonomy | public function get_custom_taxonomy($custom_taxonomy_id){
global $wpdb;
$query = sprintf('SELECT * FROM %s WHERE id = %s',MF_TABLE_CUSTOM_TAXONOMY,$custom_taxonomy_id);
$custom_taxonomy = $wpdb->get_row( $query, ARRAY_A );
if($custom_taxonomy){
$custom_taxonomy = unserialize($custom_taxonomy['arguments']);
$custom_taxonomy['core']['id'] = $custom_taxonomy_id;
return $custom_taxonomy;
}
return false;
} | php | public function get_custom_taxonomy($custom_taxonomy_id){
global $wpdb;
$query = sprintf('SELECT * FROM %s WHERE id = %s',MF_TABLE_CUSTOM_TAXONOMY,$custom_taxonomy_id);
$custom_taxonomy = $wpdb->get_row( $query, ARRAY_A );
if($custom_taxonomy){
$custom_taxonomy = unserialize($custom_taxonomy['arguments']);
$custom_taxonomy['core']['id'] = $custom_taxonomy_id;
return $custom_taxonomy;
}
return false;
} | [
"public",
"function",
"get_custom_taxonomy",
"(",
"$",
"custom_taxonomy_id",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"query",
"=",
"sprintf",
"(",
"'SELECT * FROM %s WHERE id = %s'",
",",
"MF_TABLE_CUSTOM_TAXONOMY",
",",
"$",
"custom_taxonomy_id",
")",
";",
"$",
"custom_taxonomy",
"=",
"$",
"wpdb",
"->",
"get_row",
"(",
"$",
"query",
",",
"ARRAY_A",
")",
";",
"if",
"(",
"$",
"custom_taxonomy",
")",
"{",
"$",
"custom_taxonomy",
"=",
"unserialize",
"(",
"$",
"custom_taxonomy",
"[",
"'arguments'",
"]",
")",
";",
"$",
"custom_taxonomy",
"[",
"'core'",
"]",
"[",
"'id'",
"]",
"=",
"$",
"custom_taxonomy_id",
";",
"return",
"$",
"custom_taxonomy",
";",
"}",
"return",
"false",
";",
"}"
] | get a specific post type | [
"get",
"a",
"specific",
"post",
"type"
] | 78a8d8f1d1102c5043e2cf7c98762e63464d2d7a | https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_taxonomy.php#L59-L70 |
Subsets and Splits