repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php | BaseCountryQuery.prune | public function prune($country = null)
{
if ($country) {
$this->addUsingAlias(CountryPeer::ID, $country->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | php | public function prune($country = null)
{
if ($country) {
$this->addUsingAlias(CountryPeer::ID, $country->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | [
"public",
"function",
"prune",
"(",
"$",
"country",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"country",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CountryPeer",
"::",
"ID",
",",
"$",
"country",
"->",
"getId",
"(",
")",
",",
"Criteria",
"::",
"NOT_EQUAL",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Exclude object from result
@param Country $country Object to remove from the list of results
@return CountryQuery The current query, for fluid interface | [
"Exclude",
"object",
"from",
"result"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php#L454-L461 |
phrest/sdk | src/Generator/Controller/ControllerGenerator.php | ControllerGenerator.create | public function create()
{
$class = ClassGen::classGen(
$this->entityName . 'Controller',
$this->namespace,
['Phrest\API\Controllers\RESTController'],
'RESTController'
);
foreach ($this->entityDefinition->requests as $requestMethod => $actions)
{
foreach ($actions as $actionName => $action)
{
if (empty($action))
{
continue;
}
$getParams = $this->generateGetParamsFromUrl($action->url);
$postParams = $this->generatePostParams($action);
$docblock = $this->createDocblockForMethod(
$requestMethod,
$action,
$getParams,
$postParams
);
$method = ClassGen::method($actionName, $getParams, 'public');
$method->setDocBlock($docblock);
$body = $this->createBodyForMethod($action);
$method->setBody($body);
$class->addMethodFromGenerator($method);
}
}
foreach ($this->uses as $use)
{
$class->addUse($use);
}
return $class;
} | php | public function create()
{
$class = ClassGen::classGen(
$this->entityName . 'Controller',
$this->namespace,
['Phrest\API\Controllers\RESTController'],
'RESTController'
);
foreach ($this->entityDefinition->requests as $requestMethod => $actions)
{
foreach ($actions as $actionName => $action)
{
if (empty($action))
{
continue;
}
$getParams = $this->generateGetParamsFromUrl($action->url);
$postParams = $this->generatePostParams($action);
$docblock = $this->createDocblockForMethod(
$requestMethod,
$action,
$getParams,
$postParams
);
$method = ClassGen::method($actionName, $getParams, 'public');
$method->setDocBlock($docblock);
$body = $this->createBodyForMethod($action);
$method->setBody($body);
$class->addMethodFromGenerator($method);
}
}
foreach ($this->uses as $use)
{
$class->addUse($use);
}
return $class;
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"class",
"=",
"ClassGen",
"::",
"classGen",
"(",
"$",
"this",
"->",
"entityName",
".",
"'Controller'",
",",
"$",
"this",
"->",
"namespace",
",",
"[",
"'Phrest\\API\\Controllers\\RESTController'",
"]",
",",
"'RESTController'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"entityDefinition",
"->",
"requests",
"as",
"$",
"requestMethod",
"=>",
"$",
"actions",
")",
"{",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"actionName",
"=>",
"$",
"action",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"action",
")",
")",
"{",
"continue",
";",
"}",
"$",
"getParams",
"=",
"$",
"this",
"->",
"generateGetParamsFromUrl",
"(",
"$",
"action",
"->",
"url",
")",
";",
"$",
"postParams",
"=",
"$",
"this",
"->",
"generatePostParams",
"(",
"$",
"action",
")",
";",
"$",
"docblock",
"=",
"$",
"this",
"->",
"createDocblockForMethod",
"(",
"$",
"requestMethod",
",",
"$",
"action",
",",
"$",
"getParams",
",",
"$",
"postParams",
")",
";",
"$",
"method",
"=",
"ClassGen",
"::",
"method",
"(",
"$",
"actionName",
",",
"$",
"getParams",
",",
"'public'",
")",
";",
"$",
"method",
"->",
"setDocBlock",
"(",
"$",
"docblock",
")",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"createBodyForMethod",
"(",
"$",
"action",
")",
";",
"$",
"method",
"->",
"setBody",
"(",
"$",
"body",
")",
";",
"$",
"class",
"->",
"addMethodFromGenerator",
"(",
"$",
"method",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"uses",
"as",
"$",
"use",
")",
"{",
"$",
"class",
"->",
"addUse",
"(",
"$",
"use",
")",
";",
"}",
"return",
"$",
"class",
";",
"}"
] | Process and create code/files
@return ClassGenerator | [
"Process",
"and",
"create",
"code",
"/",
"files"
] | train | https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator/Controller/ControllerGenerator.php#L49-L93 |
phrest/sdk | src/Generator/Controller/ControllerGenerator.php | ControllerGenerator.createDocblockForMethod | private function createDocblockForMethod(
$requestMethod,
$action,
$getParams,
$postParams
)
{
if (empty($action->doc))
{
$action->doc = 'TODO';
}
/*
* $action->doc
* METHOD: /{url:[a-z]+}
*/
$docblock = new DocBlockGenerator(
$action->doc,
strtoupper($requestMethod) . ': ' . $action->url
);
foreach ($getParams as $param)
{
//@param $paramName
$docblock->setTag(new GenericTag('param', "\${$param->getName()}"));
}
foreach ($postParams as $postParam)
{
//@postParam('paramName')
$docblock->setTag(new GenericTag('postParam', "('{$postParam->getName()}')"));
}
if (!empty($action->throws))
{
//@throws \Name\Space\Version\Exceptions\EntityName\SomethingException
$docblock->setTag(
new GenericTag(
'throws',
sprintf(
"\\%s\\%s\\Exceptions\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->throws->exception
)
)
);
}
if (!empty($action->returns))
{
//@returns \Name\Space\Version\EntityName\EntityName(s)?Response
$docblock->setTag(
new GenericTag(
'returns',
sprintf(
"\\%s\\%s\\Responses\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->returns
)
)
);
}
return $docblock;
} | php | private function createDocblockForMethod(
$requestMethod,
$action,
$getParams,
$postParams
)
{
if (empty($action->doc))
{
$action->doc = 'TODO';
}
/*
* $action->doc
* METHOD: /{url:[a-z]+}
*/
$docblock = new DocBlockGenerator(
$action->doc,
strtoupper($requestMethod) . ': ' . $action->url
);
foreach ($getParams as $param)
{
//@param $paramName
$docblock->setTag(new GenericTag('param', "\${$param->getName()}"));
}
foreach ($postParams as $postParam)
{
//@postParam('paramName')
$docblock->setTag(new GenericTag('postParam', "('{$postParam->getName()}')"));
}
if (!empty($action->throws))
{
//@throws \Name\Space\Version\Exceptions\EntityName\SomethingException
$docblock->setTag(
new GenericTag(
'throws',
sprintf(
"\\%s\\%s\\Exceptions\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->throws->exception
)
)
);
}
if (!empty($action->returns))
{
//@returns \Name\Space\Version\EntityName\EntityName(s)?Response
$docblock->setTag(
new GenericTag(
'returns',
sprintf(
"\\%s\\%s\\Responses\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->returns
)
)
);
}
return $docblock;
} | [
"private",
"function",
"createDocblockForMethod",
"(",
"$",
"requestMethod",
",",
"$",
"action",
",",
"$",
"getParams",
",",
"$",
"postParams",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"action",
"->",
"doc",
")",
")",
"{",
"$",
"action",
"->",
"doc",
"=",
"'TODO'",
";",
"}",
"/*\n * $action->doc\n * METHOD: /{url:[a-z]+}\n */",
"$",
"docblock",
"=",
"new",
"DocBlockGenerator",
"(",
"$",
"action",
"->",
"doc",
",",
"strtoupper",
"(",
"$",
"requestMethod",
")",
".",
"': '",
".",
"$",
"action",
"->",
"url",
")",
";",
"foreach",
"(",
"$",
"getParams",
"as",
"$",
"param",
")",
"{",
"//@param $paramName",
"$",
"docblock",
"->",
"setTag",
"(",
"new",
"GenericTag",
"(",
"'param'",
",",
"\"\\${$param->getName()}\"",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"postParams",
"as",
"$",
"postParam",
")",
"{",
"//@postParam('paramName')",
"$",
"docblock",
"->",
"setTag",
"(",
"new",
"GenericTag",
"(",
"'postParam'",
",",
"\"('{$postParam->getName()}')\"",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"action",
"->",
"throws",
")",
")",
"{",
"//@throws \\Name\\Space\\Version\\Exceptions\\EntityName\\SomethingException",
"$",
"docblock",
"->",
"setTag",
"(",
"new",
"GenericTag",
"(",
"'throws'",
",",
"sprintf",
"(",
"\"\\\\%s\\\\%s\\\\Exceptions\\\\%s\\\\%s\"",
",",
"Generator",
"::",
"$",
"namespace",
",",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"entityName",
",",
"$",
"action",
"->",
"throws",
"->",
"exception",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"action",
"->",
"returns",
")",
")",
"{",
"//@returns \\Name\\Space\\Version\\EntityName\\EntityName(s)?Response",
"$",
"docblock",
"->",
"setTag",
"(",
"new",
"GenericTag",
"(",
"'returns'",
",",
"sprintf",
"(",
"\"\\\\%s\\\\%s\\\\Responses\\\\%s\\\\%s\"",
",",
"Generator",
"::",
"$",
"namespace",
",",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"entityName",
",",
"$",
"action",
"->",
"returns",
")",
")",
")",
";",
"}",
"return",
"$",
"docblock",
";",
"}"
] | @param string $requestMethod
@param Config $action
@param ParameterGenerator[] $getParams
@param ParameterGenerator[] $postParams
@return DocBlockGenerator | [
"@param",
"string",
"$requestMethod",
"@param",
"Config",
"$action",
"@param",
"ParameterGenerator",
"[]",
"$getParams",
"@param",
"ParameterGenerator",
"[]",
"$postParams"
] | train | https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator/Controller/ControllerGenerator.php#L103-L171 |
phrest/sdk | src/Generator/Controller/ControllerGenerator.php | ControllerGenerator.createBodyForMethod | private function createBodyForMethod($action)
{
$body = '//todo' . PHP_EOL;
if (!empty($action->postParams))
{
foreach ($action->postParams as $param => $type)
{
$body .= sprintf(
'$%s = $this->request->getPost(\'%s\', \'%s\');%s',
$param,
$param,
$type,
PHP_EOL
);
}
$body .= PHP_EOL;
}
if (!empty($action->throws))
{
$exceptionClass = sprintf(
"\\%s\\%s\\Exceptions\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->throws->exception
);
$this->addUse($exceptionClass);
$body .= sprintf(
"if (false)" . PHP_EOL
. "{" . PHP_EOL
. "%sthrow new %s('%s');" . PHP_EOL
. "}" . PHP_EOL,
Generator::$indentation,
$action->throws->exception,
$action->throws->message
);
$body .= PHP_EOL;
}
if (!empty($action->returns))
{
$responseClass = sprintf(
"\\%s\\%s\\Responses\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->returns
);
$this->addUse($responseClass);
$params = [];
if (class_exists($responseClass))
{
if (method_exists($responseClass, '__construct'))
{
$constructor = new \ReflectionMethod($responseClass, '__construct');
foreach ($constructor->getParameters() as $param)
{
$params[] = '$' . $param->getName();
}
}
}
$body .= sprintf(
"return new %s(%s);",
$action->returns,
implode(', ', $params)
);
}
return $body;
} | php | private function createBodyForMethod($action)
{
$body = '//todo' . PHP_EOL;
if (!empty($action->postParams))
{
foreach ($action->postParams as $param => $type)
{
$body .= sprintf(
'$%s = $this->request->getPost(\'%s\', \'%s\');%s',
$param,
$param,
$type,
PHP_EOL
);
}
$body .= PHP_EOL;
}
if (!empty($action->throws))
{
$exceptionClass = sprintf(
"\\%s\\%s\\Exceptions\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->throws->exception
);
$this->addUse($exceptionClass);
$body .= sprintf(
"if (false)" . PHP_EOL
. "{" . PHP_EOL
. "%sthrow new %s('%s');" . PHP_EOL
. "}" . PHP_EOL,
Generator::$indentation,
$action->throws->exception,
$action->throws->message
);
$body .= PHP_EOL;
}
if (!empty($action->returns))
{
$responseClass = sprintf(
"\\%s\\%s\\Responses\\%s\\%s",
Generator::$namespace,
$this->version,
$this->entityName,
$action->returns
);
$this->addUse($responseClass);
$params = [];
if (class_exists($responseClass))
{
if (method_exists($responseClass, '__construct'))
{
$constructor = new \ReflectionMethod($responseClass, '__construct');
foreach ($constructor->getParameters() as $param)
{
$params[] = '$' . $param->getName();
}
}
}
$body .= sprintf(
"return new %s(%s);",
$action->returns,
implode(', ', $params)
);
}
return $body;
} | [
"private",
"function",
"createBodyForMethod",
"(",
"$",
"action",
")",
"{",
"$",
"body",
"=",
"'//todo'",
".",
"PHP_EOL",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"action",
"->",
"postParams",
")",
")",
"{",
"foreach",
"(",
"$",
"action",
"->",
"postParams",
"as",
"$",
"param",
"=>",
"$",
"type",
")",
"{",
"$",
"body",
".=",
"sprintf",
"(",
"'$%s = $this->request->getPost(\\'%s\\', \\'%s\\');%s'",
",",
"$",
"param",
",",
"$",
"param",
",",
"$",
"type",
",",
"PHP_EOL",
")",
";",
"}",
"$",
"body",
".=",
"PHP_EOL",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"action",
"->",
"throws",
")",
")",
"{",
"$",
"exceptionClass",
"=",
"sprintf",
"(",
"\"\\\\%s\\\\%s\\\\Exceptions\\\\%s\\\\%s\"",
",",
"Generator",
"::",
"$",
"namespace",
",",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"entityName",
",",
"$",
"action",
"->",
"throws",
"->",
"exception",
")",
";",
"$",
"this",
"->",
"addUse",
"(",
"$",
"exceptionClass",
")",
";",
"$",
"body",
".=",
"sprintf",
"(",
"\"if (false)\"",
".",
"PHP_EOL",
".",
"\"{\"",
".",
"PHP_EOL",
".",
"\"%sthrow new %s('%s');\"",
".",
"PHP_EOL",
".",
"\"}\"",
".",
"PHP_EOL",
",",
"Generator",
"::",
"$",
"indentation",
",",
"$",
"action",
"->",
"throws",
"->",
"exception",
",",
"$",
"action",
"->",
"throws",
"->",
"message",
")",
";",
"$",
"body",
".=",
"PHP_EOL",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"action",
"->",
"returns",
")",
")",
"{",
"$",
"responseClass",
"=",
"sprintf",
"(",
"\"\\\\%s\\\\%s\\\\Responses\\\\%s\\\\%s\"",
",",
"Generator",
"::",
"$",
"namespace",
",",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"entityName",
",",
"$",
"action",
"->",
"returns",
")",
";",
"$",
"this",
"->",
"addUse",
"(",
"$",
"responseClass",
")",
";",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"class_exists",
"(",
"$",
"responseClass",
")",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"responseClass",
",",
"'__construct'",
")",
")",
"{",
"$",
"constructor",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"responseClass",
",",
"'__construct'",
")",
";",
"foreach",
"(",
"$",
"constructor",
"->",
"getParameters",
"(",
")",
"as",
"$",
"param",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"'$'",
".",
"$",
"param",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"}",
"$",
"body",
".=",
"sprintf",
"(",
"\"return new %s(%s);\"",
",",
"$",
"action",
"->",
"returns",
",",
"implode",
"(",
"', '",
",",
"$",
"params",
")",
")",
";",
"}",
"return",
"$",
"body",
";",
"}"
] | @param Config $action
@return string | [
"@param",
"Config",
"$action"
] | train | https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator/Controller/ControllerGenerator.php#L178-L254 |
phrest/sdk | src/Generator/Controller/ControllerGenerator.php | ControllerGenerator.generateGetParamsFromUrl | private function generateGetParamsFromUrl($url)
{
$matches = [];
preg_match_all('#\{(\w+):[^\}]+\}#i', $url, $matches);
$params = [];
foreach ($matches[1] as $param)
{
$params[] = new ParameterGenerator($param);
}
return $params;
} | php | private function generateGetParamsFromUrl($url)
{
$matches = [];
preg_match_all('#\{(\w+):[^\}]+\}#i', $url, $matches);
$params = [];
foreach ($matches[1] as $param)
{
$params[] = new ParameterGenerator($param);
}
return $params;
} | [
"private",
"function",
"generateGetParamsFromUrl",
"(",
"$",
"url",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"preg_match_all",
"(",
"'#\\{(\\w+):[^\\}]+\\}#i'",
",",
"$",
"url",
",",
"$",
"matches",
")",
";",
"$",
"params",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"param",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"new",
"ParameterGenerator",
"(",
"$",
"param",
")",
";",
"}",
"return",
"$",
"params",
";",
"}"
] | Parse E.G. /{id:[0-9]+}/{name:[a-z]+} into ['id', 'name']
@param $url
@return ParameterGenerator[] | [
"Parse",
"E",
".",
"G",
".",
"/",
"{",
"id",
":",
"[",
"0",
"-",
"9",
"]",
"+",
"}",
"/",
"{",
"name",
":",
"[",
"a",
"-",
"z",
"]",
"+",
"}",
"into",
"[",
"id",
"name",
"]"
] | train | https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator/Controller/ControllerGenerator.php#L263-L275 |
phrest/sdk | src/Generator/Controller/ControllerGenerator.php | ControllerGenerator.generatePostParams | private function generatePostParams($action)
{
$params = [];
if (!empty($action->postParams))
{
foreach ($action->postParams as $param => $type)
{
$params[] = new ParameterGenerator($param, $type);
}
}
return $params;
} | php | private function generatePostParams($action)
{
$params = [];
if (!empty($action->postParams))
{
foreach ($action->postParams as $param => $type)
{
$params[] = new ParameterGenerator($param, $type);
}
}
return $params;
} | [
"private",
"function",
"generatePostParams",
"(",
"$",
"action",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"action",
"->",
"postParams",
")",
")",
"{",
"foreach",
"(",
"$",
"action",
"->",
"postParams",
"as",
"$",
"param",
"=>",
"$",
"type",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"new",
"ParameterGenerator",
"(",
"$",
"param",
",",
"$",
"type",
")",
";",
"}",
"}",
"return",
"$",
"params",
";",
"}"
] | @param Config $action
@return ParameterGenerator[] | [
"@param",
"Config",
"$action"
] | train | https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator/Controller/ControllerGenerator.php#L282-L295 |
flipboxstudio/orm-manager | src/Flipbox/OrmManager/BothRelations/MorphOneToMany.php | MorphOneToMany.buildRelations | public function buildRelations()
{
$this->command->buildMethod($this->model, 'morphTo', null, $this->options);
foreach ($this->toModels as $key => $toModel) {
$options = $this->options;
$options['primary_key'] = $this->options['primary_key'][$key];
$this->command->buildMethod($toModel, 'morphMany', $this->model, $options);
}
} | php | public function buildRelations()
{
$this->command->buildMethod($this->model, 'morphTo', null, $this->options);
foreach ($this->toModels as $key => $toModel) {
$options = $this->options;
$options['primary_key'] = $this->options['primary_key'][$key];
$this->command->buildMethod($toModel, 'morphMany', $this->model, $options);
}
} | [
"public",
"function",
"buildRelations",
"(",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"buildMethod",
"(",
"$",
"this",
"->",
"model",
",",
"'morphTo'",
",",
"null",
",",
"$",
"this",
"->",
"options",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"toModels",
"as",
"$",
"key",
"=>",
"$",
"toModel",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"$",
"options",
"[",
"'primary_key'",
"]",
"=",
"$",
"this",
"->",
"options",
"[",
"'primary_key'",
"]",
"[",
"$",
"key",
"]",
";",
"$",
"this",
"->",
"command",
"->",
"buildMethod",
"(",
"$",
"toModel",
",",
"'morphMany'",
",",
"$",
"this",
"->",
"model",
",",
"$",
"options",
")",
";",
"}",
"}"
] | build relations between models
@return void | [
"build",
"relations",
"between",
"models"
] | train | https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/MorphOneToMany.php#L12-L21 |
steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.addStyle | public function addStyle(Style $style)
{
if (!in_array($style, $this->styles, true)) {
array_push($this->styles, $style);
}
return $this;
} | php | public function addStyle(Style $style)
{
if (!in_array($style, $this->styles, true)) {
array_push($this->styles, $style);
}
return $this;
} | [
"public",
"function",
"addStyle",
"(",
"Style",
"$",
"style",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"style",
",",
"$",
"this",
"->",
"styles",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"styles",
",",
"$",
"style",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a new Style
@api
@param Style $style The Style to be added
@return static | [
"Add",
"a",
"new",
"Style"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L59-L65 |
steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.addStyle3d | public function addStyle3d(Style3d $style3d)
{
if (!in_array($style3d, $this->styles3d, true)) {
array_push($this->styles3d, $style3d);
}
return $this;
} | php | public function addStyle3d(Style3d $style3d)
{
if (!in_array($style3d, $this->styles3d, true)) {
array_push($this->styles3d, $style3d);
}
return $this;
} | [
"public",
"function",
"addStyle3d",
"(",
"Style3d",
"$",
"style3d",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"style3d",
",",
"$",
"this",
"->",
"styles3d",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"styles3d",
",",
"$",
"style3d",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a new Style3d
@api
@param Style3d $style3d The Style3d to be added
@return static | [
"Add",
"a",
"new",
"Style3d"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L97-L103 |
steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.getMood | public function getMood($createIfEmpty = true)
{
if (!$this->mood && $createIfEmpty) {
$this->createMood();
}
return $this->mood;
} | php | public function getMood($createIfEmpty = true)
{
if (!$this->mood && $createIfEmpty) {
$this->createMood();
}
return $this->mood;
} | [
"public",
"function",
"getMood",
"(",
"$",
"createIfEmpty",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"mood",
"&&",
"$",
"createIfEmpty",
")",
"{",
"$",
"this",
"->",
"createMood",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"mood",
";",
"}"
] | Get the Mood
@api
@param bool $createIfEmpty (optional) If the Mood should be created if it doesn't exist yet
@return Mood | [
"Get",
"the",
"Mood"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L138-L144 |
steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.createMood | public function createMood()
{
if ($this->mood) {
return $this->mood;
}
$mood = new Mood();
$this->setMood($mood);
return $this->mood;
} | php | public function createMood()
{
if ($this->mood) {
return $this->mood;
}
$mood = new Mood();
$this->setMood($mood);
return $this->mood;
} | [
"public",
"function",
"createMood",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mood",
")",
"{",
"return",
"$",
"this",
"->",
"mood",
";",
"}",
"$",
"mood",
"=",
"new",
"Mood",
"(",
")",
";",
"$",
"this",
"->",
"setMood",
"(",
"$",
"mood",
")",
";",
"return",
"$",
"this",
"->",
"mood",
";",
"}"
] | Create a new Mood if necessary
@api
@return Mood | [
"Create",
"a",
"new",
"Mood",
"if",
"necessary"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L165-L173 |
steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.render | public function render(\DOMDocument $domDocument)
{
$stylesheetXml = $domDocument->createElement("stylesheet");
if ($this->styles3d) {
$stylesXml = $domDocument->createElement("frame3dstyles");
$stylesheetXml->appendChild($stylesXml);
foreach ($this->styles3d as $style3d) {
$style3dXml = $style3d->render($domDocument);
$stylesXml->appendChild($style3dXml);
}
}
if ($this->mood) {
$moodXml = $this->mood->render($domDocument);
$stylesheetXml->appendChild($moodXml);
}
return $stylesheetXml;
} | php | public function render(\DOMDocument $domDocument)
{
$stylesheetXml = $domDocument->createElement("stylesheet");
if ($this->styles3d) {
$stylesXml = $domDocument->createElement("frame3dstyles");
$stylesheetXml->appendChild($stylesXml);
foreach ($this->styles3d as $style3d) {
$style3dXml = $style3d->render($domDocument);
$stylesXml->appendChild($style3dXml);
}
}
if ($this->mood) {
$moodXml = $this->mood->render($domDocument);
$stylesheetXml->appendChild($moodXml);
}
return $stylesheetXml;
} | [
"public",
"function",
"render",
"(",
"\\",
"DOMDocument",
"$",
"domDocument",
")",
"{",
"$",
"stylesheetXml",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"stylesheet\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"styles3d",
")",
"{",
"$",
"stylesXml",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"frame3dstyles\"",
")",
";",
"$",
"stylesheetXml",
"->",
"appendChild",
"(",
"$",
"stylesXml",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"styles3d",
"as",
"$",
"style3d",
")",
"{",
"$",
"style3dXml",
"=",
"$",
"style3d",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"stylesXml",
"->",
"appendChild",
"(",
"$",
"style3dXml",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"mood",
")",
"{",
"$",
"moodXml",
"=",
"$",
"this",
"->",
"mood",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"stylesheetXml",
"->",
"appendChild",
"(",
"$",
"moodXml",
")",
";",
"}",
"return",
"$",
"stylesheetXml",
";",
"}"
] | Render the Stylesheet
@param \DOMDocument $domDocument DOMDocument for which the Stylesheet should be rendered
@return \DOMElement | [
"Render",
"the",
"Stylesheet"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L181-L197 |
Lansoweb/LosReCaptcha | src/Form/View/Helper/Captcha/Invisible.php | Invisible.renderHiddenInput | private function renderHiddenInput($responseName, $responseId)
{
$pattern = '<input type="hidden" %s%s';
$closingBracket = $this->getInlineClosingBracket();
$attributes = $this->createAttributesString([
'name' => $responseName,
'id' => $responseId,
]);
$response = sprintf($pattern, $attributes, $closingBracket);
return $response;
} | php | private function renderHiddenInput($responseName, $responseId)
{
$pattern = '<input type="hidden" %s%s';
$closingBracket = $this->getInlineClosingBracket();
$attributes = $this->createAttributesString([
'name' => $responseName,
'id' => $responseId,
]);
$response = sprintf($pattern, $attributes, $closingBracket);
return $response;
} | [
"private",
"function",
"renderHiddenInput",
"(",
"$",
"responseName",
",",
"$",
"responseId",
")",
"{",
"$",
"pattern",
"=",
"'<input type=\"hidden\" %s%s'",
";",
"$",
"closingBracket",
"=",
"$",
"this",
"->",
"getInlineClosingBracket",
"(",
")",
";",
"$",
"attributes",
"=",
"$",
"this",
"->",
"createAttributesString",
"(",
"[",
"'name'",
"=>",
"$",
"responseName",
",",
"'id'",
"=>",
"$",
"responseId",
",",
"]",
")",
";",
"$",
"response",
"=",
"sprintf",
"(",
"$",
"pattern",
",",
"$",
"attributes",
",",
"$",
"closingBracket",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Render hidden input elements for the response
@param string $responseName
@param string $responseId
@return string | [
"Render",
"hidden",
"input",
"elements",
"for",
"the",
"response"
] | train | https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Form/View/Helper/Captcha/Invisible.php#L74-L86 |
xinix-technology/norm | src/Norm/Dialect/OracleDialect.php | OracleDialect.grammarUpdate | public function grammarUpdate($collectionName, $data)
{
$sets = array();
foreach ($data as $key => $value) {
$k = $key;
$sets[] = $this->grammarEscape($k).' = :'.$k;
}
$sql = 'UPDATE '.$collectionName.' SET '.implode(', ', $sets) . ' WHERE id = :id';
return $sql;
} | php | public function grammarUpdate($collectionName, $data)
{
$sets = array();
foreach ($data as $key => $value) {
$k = $key;
$sets[] = $this->grammarEscape($k).' = :'.$k;
}
$sql = 'UPDATE '.$collectionName.' SET '.implode(', ', $sets) . ' WHERE id = :id';
return $sql;
} | [
"public",
"function",
"grammarUpdate",
"(",
"$",
"collectionName",
",",
"$",
"data",
")",
"{",
"$",
"sets",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"k",
"=",
"$",
"key",
";",
"$",
"sets",
"[",
"]",
"=",
"$",
"this",
"->",
"grammarEscape",
"(",
"$",
"k",
")",
".",
"' = :'",
".",
"$",
"k",
";",
"}",
"$",
"sql",
"=",
"'UPDATE '",
".",
"$",
"collectionName",
".",
"' SET '",
".",
"implode",
"(",
"', '",
",",
"$",
"sets",
")",
".",
"' WHERE id = :id'",
";",
"return",
"$",
"sql",
";",
"}"
] | } | [
"}"
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Dialect/OracleDialect.php#L50-L62 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/Match/Plugin.php | Plugin.onTick | function onTick()
{
$this->tick++;
switch ($this->state)
{
case self::OVER:
case self::SLEEPING:
break;
case self::WAITING:
case self::DECIDING:
case self::PLAYING:
break;
case self::PLAYER_LEFT:
case self::WAITING_BACKUPS:
break;
}
if(new \DateTime() < $this->nextTick) return;
switch($this->state)
{
case self::SLEEPING:
//Waiting for a match in database
$match = $this->matchMakingService->getServerCurrentMatch($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
if ($match)
{
$this->prepare($match);
}
else
{
$this->sleep();
}
break;
case self::WAITING:
//Waiting for players, if Match change or cancel, change state and wait
$this->waitingTime += 5;
\ManiaLive\Utilities\Logger::debug(sprintf('waiting time %d',$this->waitingTime));
$match = $this->matchMakingService->getServerCurrentMatch($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
if($this->waitingTime > static::TIME_WAITING_CONNECTION)
{
\ManiaLive\Utilities\Logger::debug('Waiting time over');
foreach($this->players as $login => $state)
{
if($state == Services\PlayerInfo::PLAYER_STATE_NOT_CONNECTED)
{
$this->updateMatchPlayerState($login,Services\PlayerInfo::PLAYER_STATE_QUITTER);
}
}
$this->waitBackups();
break;
}
if($match === false)
{
\ManiaLive\Utilities\Logger::debug('Match was prepared but not in database anymore (canceled on lobby ?');
$this->cancel(false);
break;
}
if($this->match->isDifferent($match))
{
$this->prepare($match);
break;
}
$this->changeState(self::WAITING);
break;
case self::DECIDING:
\ManiaLive\Utilities\Logger::debug('tick: DECIDING');
$this->play();
break;
case static::PLAYING:
$this->changeState(static::PLAYING);
break;
case self::PLAYER_LEFT:
\ManiaLive\Utilities\Logger::debug('tick: PLAYER_LEFT');
$this->waitBackups();
break;
case self::WAITING_BACKUPS:
switch($this->config->waitingForBackups)
{
case 0:
$isWaitingTimeOver = true;
break;
case 2:
$isWaitingTimeOver = false;
break;
case 1:
//nobreak
default:
$isWaitingTimeOver = (++$this->waitingBackupTime > static::TIME_WAITING_BACKUP);
break;
}
if($isWaitingTimeOver)
{
\ManiaLive\Utilities\Logger::debug('tick: WAITING_BACKUPS over');
$this->cancel();
}
else
{
$match = $this->matchMakingService->getServerCurrentMatch($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
if($match && $this->match->isDifferent($match))
{
$this->updatePlayerList($match);
}
$this->changeState(self::WAITING_BACKUPS);
}
break;
case self::OVER:
\ManiaLive\Utilities\Logger::debug('tick: OVER');
$this->end();
}
} | php | function onTick()
{
$this->tick++;
switch ($this->state)
{
case self::OVER:
case self::SLEEPING:
break;
case self::WAITING:
case self::DECIDING:
case self::PLAYING:
break;
case self::PLAYER_LEFT:
case self::WAITING_BACKUPS:
break;
}
if(new \DateTime() < $this->nextTick) return;
switch($this->state)
{
case self::SLEEPING:
//Waiting for a match in database
$match = $this->matchMakingService->getServerCurrentMatch($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
if ($match)
{
$this->prepare($match);
}
else
{
$this->sleep();
}
break;
case self::WAITING:
//Waiting for players, if Match change or cancel, change state and wait
$this->waitingTime += 5;
\ManiaLive\Utilities\Logger::debug(sprintf('waiting time %d',$this->waitingTime));
$match = $this->matchMakingService->getServerCurrentMatch($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
if($this->waitingTime > static::TIME_WAITING_CONNECTION)
{
\ManiaLive\Utilities\Logger::debug('Waiting time over');
foreach($this->players as $login => $state)
{
if($state == Services\PlayerInfo::PLAYER_STATE_NOT_CONNECTED)
{
$this->updateMatchPlayerState($login,Services\PlayerInfo::PLAYER_STATE_QUITTER);
}
}
$this->waitBackups();
break;
}
if($match === false)
{
\ManiaLive\Utilities\Logger::debug('Match was prepared but not in database anymore (canceled on lobby ?');
$this->cancel(false);
break;
}
if($this->match->isDifferent($match))
{
$this->prepare($match);
break;
}
$this->changeState(self::WAITING);
break;
case self::DECIDING:
\ManiaLive\Utilities\Logger::debug('tick: DECIDING');
$this->play();
break;
case static::PLAYING:
$this->changeState(static::PLAYING);
break;
case self::PLAYER_LEFT:
\ManiaLive\Utilities\Logger::debug('tick: PLAYER_LEFT');
$this->waitBackups();
break;
case self::WAITING_BACKUPS:
switch($this->config->waitingForBackups)
{
case 0:
$isWaitingTimeOver = true;
break;
case 2:
$isWaitingTimeOver = false;
break;
case 1:
//nobreak
default:
$isWaitingTimeOver = (++$this->waitingBackupTime > static::TIME_WAITING_BACKUP);
break;
}
if($isWaitingTimeOver)
{
\ManiaLive\Utilities\Logger::debug('tick: WAITING_BACKUPS over');
$this->cancel();
}
else
{
$match = $this->matchMakingService->getServerCurrentMatch($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
if($match && $this->match->isDifferent($match))
{
$this->updatePlayerList($match);
}
$this->changeState(self::WAITING_BACKUPS);
}
break;
case self::OVER:
\ManiaLive\Utilities\Logger::debug('tick: OVER');
$this->end();
}
} | [
"function",
"onTick",
"(",
")",
"{",
"$",
"this",
"->",
"tick",
"++",
";",
"switch",
"(",
"$",
"this",
"->",
"state",
")",
"{",
"case",
"self",
"::",
"OVER",
":",
"case",
"self",
"::",
"SLEEPING",
":",
"break",
";",
"case",
"self",
"::",
"WAITING",
":",
"case",
"self",
"::",
"DECIDING",
":",
"case",
"self",
"::",
"PLAYING",
":",
"break",
";",
"case",
"self",
"::",
"PLAYER_LEFT",
":",
"case",
"self",
"::",
"WAITING_BACKUPS",
":",
"break",
";",
"}",
"if",
"(",
"new",
"\\",
"DateTime",
"(",
")",
"<",
"$",
"this",
"->",
"nextTick",
")",
"return",
";",
"switch",
"(",
"$",
"this",
"->",
"state",
")",
"{",
"case",
"self",
"::",
"SLEEPING",
":",
"//Waiting for a match in database\r",
"$",
"match",
"=",
"$",
"this",
"->",
"matchMakingService",
"->",
"getServerCurrentMatch",
"(",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"this",
"->",
"scriptName",
",",
"$",
"this",
"->",
"titleIdString",
")",
";",
"if",
"(",
"$",
"match",
")",
"{",
"$",
"this",
"->",
"prepare",
"(",
"$",
"match",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"sleep",
"(",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"WAITING",
":",
"//Waiting for players, if Match change or cancel, change state and wait\r",
"$",
"this",
"->",
"waitingTime",
"+=",
"5",
";",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"sprintf",
"(",
"'waiting time %d'",
",",
"$",
"this",
"->",
"waitingTime",
")",
")",
";",
"$",
"match",
"=",
"$",
"this",
"->",
"matchMakingService",
"->",
"getServerCurrentMatch",
"(",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"this",
"->",
"scriptName",
",",
"$",
"this",
"->",
"titleIdString",
")",
";",
"if",
"(",
"$",
"this",
"->",
"waitingTime",
">",
"static",
"::",
"TIME_WAITING_CONNECTION",
")",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'Waiting time over'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"players",
"as",
"$",
"login",
"=>",
"$",
"state",
")",
"{",
"if",
"(",
"$",
"state",
"==",
"Services",
"\\",
"PlayerInfo",
"::",
"PLAYER_STATE_NOT_CONNECTED",
")",
"{",
"$",
"this",
"->",
"updateMatchPlayerState",
"(",
"$",
"login",
",",
"Services",
"\\",
"PlayerInfo",
"::",
"PLAYER_STATE_QUITTER",
")",
";",
"}",
"}",
"$",
"this",
"->",
"waitBackups",
"(",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"match",
"===",
"false",
")",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'Match was prepared but not in database anymore (canceled on lobby ?'",
")",
";",
"$",
"this",
"->",
"cancel",
"(",
"false",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"match",
"->",
"isDifferent",
"(",
"$",
"match",
")",
")",
"{",
"$",
"this",
"->",
"prepare",
"(",
"$",
"match",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"changeState",
"(",
"self",
"::",
"WAITING",
")",
";",
"break",
";",
"case",
"self",
"::",
"DECIDING",
":",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'tick: DECIDING'",
")",
";",
"$",
"this",
"->",
"play",
"(",
")",
";",
"break",
";",
"case",
"static",
"::",
"PLAYING",
":",
"$",
"this",
"->",
"changeState",
"(",
"static",
"::",
"PLAYING",
")",
";",
"break",
";",
"case",
"self",
"::",
"PLAYER_LEFT",
":",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'tick: PLAYER_LEFT'",
")",
";",
"$",
"this",
"->",
"waitBackups",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"WAITING_BACKUPS",
":",
"switch",
"(",
"$",
"this",
"->",
"config",
"->",
"waitingForBackups",
")",
"{",
"case",
"0",
":",
"$",
"isWaitingTimeOver",
"=",
"true",
";",
"break",
";",
"case",
"2",
":",
"$",
"isWaitingTimeOver",
"=",
"false",
";",
"break",
";",
"case",
"1",
":",
"//nobreak\r",
"default",
":",
"$",
"isWaitingTimeOver",
"=",
"(",
"++",
"$",
"this",
"->",
"waitingBackupTime",
">",
"static",
"::",
"TIME_WAITING_BACKUP",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"isWaitingTimeOver",
")",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'tick: WAITING_BACKUPS over'",
")",
";",
"$",
"this",
"->",
"cancel",
"(",
")",
";",
"}",
"else",
"{",
"$",
"match",
"=",
"$",
"this",
"->",
"matchMakingService",
"->",
"getServerCurrentMatch",
"(",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"this",
"->",
"scriptName",
",",
"$",
"this",
"->",
"titleIdString",
")",
";",
"if",
"(",
"$",
"match",
"&&",
"$",
"this",
"->",
"match",
"->",
"isDifferent",
"(",
"$",
"match",
")",
")",
"{",
"$",
"this",
"->",
"updatePlayerList",
"(",
"$",
"match",
")",
";",
"}",
"$",
"this",
"->",
"changeState",
"(",
"self",
"::",
"WAITING_BACKUPS",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"OVER",
":",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'tick: OVER'",
")",
";",
"$",
"this",
"->",
"end",
"(",
")",
";",
"}",
"}"
] | Core of the plugin | [
"Core",
"of",
"the",
"plugin"
] | train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Match/Plugin.php#L246-L357 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/Match/Plugin.php | Plugin.prepare | protected function prepare($match)
{
\ManiaLive\Utilities\Logger::debug($match);
$this->players = array_fill_keys($match->players, Services\PlayerInfo::PLAYER_STATE_NOT_CONNECTED);
$this->match = $match;
$this->matchId = $match->id;
Label::EraseAll();
foreach($match->players as $login)
{
$this->connection->addGuest((string)$login, true);
}
$this->connection->restartMap(false, true);
$this->connection->executeMulticall();
$this->enableDedicatedEvents(
ServerEvent::ON_PLAYER_CONNECT |
ServerEvent::ON_PLAYER_DISCONNECT |
ServerEvent::ON_END_MATCH |
ServerEvent::ON_END_ROUND |
ServerEvent::ON_PLAYER_INFO_CHANGED |
ServerEvent::ON_MODE_SCRIPT_CALLBACK |
ServerEvent::ON_MODE_SCRIPT_CALLBACK_ARRAY
);
\ManiaLive\Utilities\Logger::debug(sprintf('Preparing match for %s (%s)',$this->lobby->login, implode(',', array_keys($this->players))));
$this->changeState(self::WAITING);
$this->waitingTime = 0;
$this->connection->setForcedTeams(true);
} | php | protected function prepare($match)
{
\ManiaLive\Utilities\Logger::debug($match);
$this->players = array_fill_keys($match->players, Services\PlayerInfo::PLAYER_STATE_NOT_CONNECTED);
$this->match = $match;
$this->matchId = $match->id;
Label::EraseAll();
foreach($match->players as $login)
{
$this->connection->addGuest((string)$login, true);
}
$this->connection->restartMap(false, true);
$this->connection->executeMulticall();
$this->enableDedicatedEvents(
ServerEvent::ON_PLAYER_CONNECT |
ServerEvent::ON_PLAYER_DISCONNECT |
ServerEvent::ON_END_MATCH |
ServerEvent::ON_END_ROUND |
ServerEvent::ON_PLAYER_INFO_CHANGED |
ServerEvent::ON_MODE_SCRIPT_CALLBACK |
ServerEvent::ON_MODE_SCRIPT_CALLBACK_ARRAY
);
\ManiaLive\Utilities\Logger::debug(sprintf('Preparing match for %s (%s)',$this->lobby->login, implode(',', array_keys($this->players))));
$this->changeState(self::WAITING);
$this->waitingTime = 0;
$this->connection->setForcedTeams(true);
} | [
"protected",
"function",
"prepare",
"(",
"$",
"match",
")",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"$",
"match",
")",
";",
"$",
"this",
"->",
"players",
"=",
"array_fill_keys",
"(",
"$",
"match",
"->",
"players",
",",
"Services",
"\\",
"PlayerInfo",
"::",
"PLAYER_STATE_NOT_CONNECTED",
")",
";",
"$",
"this",
"->",
"match",
"=",
"$",
"match",
";",
"$",
"this",
"->",
"matchId",
"=",
"$",
"match",
"->",
"id",
";",
"Label",
"::",
"EraseAll",
"(",
")",
";",
"foreach",
"(",
"$",
"match",
"->",
"players",
"as",
"$",
"login",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"addGuest",
"(",
"(",
"string",
")",
"$",
"login",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"restartMap",
"(",
"false",
",",
"true",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"executeMulticall",
"(",
")",
";",
"$",
"this",
"->",
"enableDedicatedEvents",
"(",
"ServerEvent",
"::",
"ON_PLAYER_CONNECT",
"|",
"ServerEvent",
"::",
"ON_PLAYER_DISCONNECT",
"|",
"ServerEvent",
"::",
"ON_END_MATCH",
"|",
"ServerEvent",
"::",
"ON_END_ROUND",
"|",
"ServerEvent",
"::",
"ON_PLAYER_INFO_CHANGED",
"|",
"ServerEvent",
"::",
"ON_MODE_SCRIPT_CALLBACK",
"|",
"ServerEvent",
"::",
"ON_MODE_SCRIPT_CALLBACK_ARRAY",
")",
";",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"sprintf",
"(",
"'Preparing match for %s (%s)'",
",",
"$",
"this",
"->",
"lobby",
"->",
"login",
",",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"$",
"this",
"->",
"players",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"changeState",
"(",
"self",
"::",
"WAITING",
")",
";",
"$",
"this",
"->",
"waitingTime",
"=",
"0",
";",
"$",
"this",
"->",
"connection",
"->",
"setForcedTeams",
"(",
"true",
")",
";",
"}"
] | Prepare the server config to host a match
Then wait players' connection
@param Services\Match $match | [
"Prepare",
"the",
"server",
"config",
"to",
"host",
"a",
"match",
"Then",
"wait",
"players",
"connection"
] | train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Match/Plugin.php#L569-L598 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/Match/Plugin.php | Plugin.end | protected function end()
{
\ManiaLive\Utilities\Logger::debug('end()');
$this->showTansfertLabel(null, -50);
foreach($this->storage->players as $player)
{
try
{
$this->connection->sendOpenLink((string) $player->login, '#qjoin='.$this->lobby->backLink, 1);
}
catch (\DedicatedApi\Xmlrpc\Exception $e)
{
//do nothing
}
}
$this->connection->cleanGuestList();
$this->match = null;
$this->matchId = null;
$this->matchMakingService->updateServerCurrentMatchId(
null,
$this->storage->serverLogin,
$this->scriptName,
$this->titleIdString
);
$this->connection->setForcedTeams(false);
$this->sleep();
} | php | protected function end()
{
\ManiaLive\Utilities\Logger::debug('end()');
$this->showTansfertLabel(null, -50);
foreach($this->storage->players as $player)
{
try
{
$this->connection->sendOpenLink((string) $player->login, '#qjoin='.$this->lobby->backLink, 1);
}
catch (\DedicatedApi\Xmlrpc\Exception $e)
{
//do nothing
}
}
$this->connection->cleanGuestList();
$this->match = null;
$this->matchId = null;
$this->matchMakingService->updateServerCurrentMatchId(
null,
$this->storage->serverLogin,
$this->scriptName,
$this->titleIdString
);
$this->connection->setForcedTeams(false);
$this->sleep();
} | [
"protected",
"function",
"end",
"(",
")",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'end()'",
")",
";",
"$",
"this",
"->",
"showTansfertLabel",
"(",
"null",
",",
"-",
"50",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"storage",
"->",
"players",
"as",
"$",
"player",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"connection",
"->",
"sendOpenLink",
"(",
"(",
"string",
")",
"$",
"player",
"->",
"login",
",",
"'#qjoin='",
".",
"$",
"this",
"->",
"lobby",
"->",
"backLink",
",",
"1",
")",
";",
"}",
"catch",
"(",
"\\",
"DedicatedApi",
"\\",
"Xmlrpc",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//do nothing\r",
"}",
"}",
"$",
"this",
"->",
"connection",
"->",
"cleanGuestList",
"(",
")",
";",
"$",
"this",
"->",
"match",
"=",
"null",
";",
"$",
"this",
"->",
"matchId",
"=",
"null",
";",
"$",
"this",
"->",
"matchMakingService",
"->",
"updateServerCurrentMatchId",
"(",
"null",
",",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"this",
"->",
"scriptName",
",",
"$",
"this",
"->",
"titleIdString",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"setForcedTeams",
"(",
"false",
")",
";",
"$",
"this",
"->",
"sleep",
"(",
")",
";",
"}"
] | Free the match for the lobby | [
"Free",
"the",
"match",
"for",
"the",
"lobby"
] | train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Match/Plugin.php#L775-L803 |
titon/db | src/Titon/Db/Behavior/SlugBehavior.php | SlugBehavior.makeUnique | public function makeUnique($id, $slug) {
$repo = $this->getRepository();
$scope = $this->getConfig('scope');
/** @type \Titon\Db\Query $query */
foreach ([
$repo->select()->where($this->getConfig('slug'), $slug),
$repo->select()->where($this->getConfig('slug'), 'like', $slug . '%')
] as $i => $query) {
if ($scope) {
$query->bindCallback($scope);
}
if ($id) {
$query->where($repo->getPrimaryKey(), '!=', $id);
}
$count = $query->count();
if ($count <= 0) {
break;
} else if ($i) {
return $slug . '-' . $count;
}
}
return $slug;
} | php | public function makeUnique($id, $slug) {
$repo = $this->getRepository();
$scope = $this->getConfig('scope');
/** @type \Titon\Db\Query $query */
foreach ([
$repo->select()->where($this->getConfig('slug'), $slug),
$repo->select()->where($this->getConfig('slug'), 'like', $slug . '%')
] as $i => $query) {
if ($scope) {
$query->bindCallback($scope);
}
if ($id) {
$query->where($repo->getPrimaryKey(), '!=', $id);
}
$count = $query->count();
if ($count <= 0) {
break;
} else if ($i) {
return $slug . '-' . $count;
}
}
return $slug;
} | [
"public",
"function",
"makeUnique",
"(",
"$",
"id",
",",
"$",
"slug",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"$",
"scope",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'scope'",
")",
";",
"/** @type \\Titon\\Db\\Query $query */",
"foreach",
"(",
"[",
"$",
"repo",
"->",
"select",
"(",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'slug'",
")",
",",
"$",
"slug",
")",
",",
"$",
"repo",
"->",
"select",
"(",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'slug'",
")",
",",
"'like'",
",",
"$",
"slug",
".",
"'%'",
")",
"]",
"as",
"$",
"i",
"=>",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"scope",
")",
"{",
"$",
"query",
"->",
"bindCallback",
"(",
"$",
"scope",
")",
";",
"}",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"repo",
"->",
"getPrimaryKey",
"(",
")",
",",
"'!='",
",",
"$",
"id",
")",
";",
"}",
"$",
"count",
"=",
"$",
"query",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"count",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"else",
"if",
"(",
"$",
"i",
")",
"{",
"return",
"$",
"slug",
".",
"'-'",
".",
"$",
"count",
";",
"}",
"}",
"return",
"$",
"slug",
";",
"}"
] | Validate the slug is unique by querying for other slugs.
If the slug is not unique, append a count to it.
@param int|int[] $id
@param string $slug
@return string | [
"Validate",
"the",
"slug",
"is",
"unique",
"by",
"querying",
"for",
"other",
"slugs",
".",
"If",
"the",
"slug",
"is",
"not",
"unique",
"append",
"a",
"count",
"to",
"it",
"."
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/SlugBehavior.php#L50-L78 |
titon/db | src/Titon/Db/Behavior/SlugBehavior.php | SlugBehavior.preSave | public function preSave(Event $event, Query $query, $id, array &$data) {
$config = $this->allConfig();
if (empty($data) || empty($data[$config['field']]) || !empty($data[$config['slug']])) {
return true;
} else if ($query->getType() === Query::UPDATE && !$config['onUpdate']) {
return true;
}
$slug = static::slugify($data[$config['field']]);
// Leave a gap of 3 to account for the appended numbers
if (mb_strlen($slug) > ($config['length'] - 3)) {
$slug = mb_substr($slug, 0, ($config['length'] - 3));
}
if ($config['unique']) {
$slug = $this->makeUnique($id, $slug);
}
$data[$config['slug']] = $slug;
return true;
} | php | public function preSave(Event $event, Query $query, $id, array &$data) {
$config = $this->allConfig();
if (empty($data) || empty($data[$config['field']]) || !empty($data[$config['slug']])) {
return true;
} else if ($query->getType() === Query::UPDATE && !$config['onUpdate']) {
return true;
}
$slug = static::slugify($data[$config['field']]);
// Leave a gap of 3 to account for the appended numbers
if (mb_strlen($slug) > ($config['length'] - 3)) {
$slug = mb_substr($slug, 0, ($config['length'] - 3));
}
if ($config['unique']) {
$slug = $this->makeUnique($id, $slug);
}
$data[$config['slug']] = $slug;
return true;
} | [
"public",
"function",
"preSave",
"(",
"Event",
"$",
"event",
",",
"Query",
"$",
"query",
",",
"$",
"id",
",",
"array",
"&",
"$",
"data",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"allConfig",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
"||",
"empty",
"(",
"$",
"data",
"[",
"$",
"config",
"[",
"'field'",
"]",
"]",
")",
"||",
"!",
"empty",
"(",
"$",
"data",
"[",
"$",
"config",
"[",
"'slug'",
"]",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"$",
"query",
"->",
"getType",
"(",
")",
"===",
"Query",
"::",
"UPDATE",
"&&",
"!",
"$",
"config",
"[",
"'onUpdate'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"$",
"slug",
"=",
"static",
"::",
"slugify",
"(",
"$",
"data",
"[",
"$",
"config",
"[",
"'field'",
"]",
"]",
")",
";",
"// Leave a gap of 3 to account for the appended numbers",
"if",
"(",
"mb_strlen",
"(",
"$",
"slug",
")",
">",
"(",
"$",
"config",
"[",
"'length'",
"]",
"-",
"3",
")",
")",
"{",
"$",
"slug",
"=",
"mb_substr",
"(",
"$",
"slug",
",",
"0",
",",
"(",
"$",
"config",
"[",
"'length'",
"]",
"-",
"3",
")",
")",
";",
"}",
"if",
"(",
"$",
"config",
"[",
"'unique'",
"]",
")",
"{",
"$",
"slug",
"=",
"$",
"this",
"->",
"makeUnique",
"(",
"$",
"id",
",",
"$",
"slug",
")",
";",
"}",
"$",
"data",
"[",
"$",
"config",
"[",
"'slug'",
"]",
"]",
"=",
"$",
"slug",
";",
"return",
"true",
";",
"}"
] | Before a save occurs, generate a unique slug using another field as the base.
If no data exists, or the base doesn't exist, or the slug is already set, exit early.
@param \Titon\Event\Event $event
@param \Titon\Db\Query $query
@param int|int[] $id
@param array $data
@return bool | [
"Before",
"a",
"save",
"occurs",
"generate",
"a",
"unique",
"slug",
"using",
"another",
"field",
"as",
"the",
"base",
".",
"If",
"no",
"data",
"exists",
"or",
"the",
"base",
"doesn",
"t",
"exist",
"or",
"the",
"slug",
"is",
"already",
"set",
"exit",
"early",
"."
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/SlugBehavior.php#L90-L114 |
titon/db | src/Titon/Db/Behavior/SlugBehavior.php | SlugBehavior.slugify | public static function slugify($string) {
$string = strip_tags($string);
$string = str_replace(['&', '&'], 'and', $string);
$string = str_replace('@', 'at', $string);
// @codeCoverageIgnoreStart
if (class_exists('Titon\G11n\Utility\Inflector')) {
return \Titon\G11n\Utility\Inflector::slug($string);
}
// @codeCoverageIgnoreEnd
return Inflector::slug($string);
} | php | public static function slugify($string) {
$string = strip_tags($string);
$string = str_replace(['&', '&'], 'and', $string);
$string = str_replace('@', 'at', $string);
// @codeCoverageIgnoreStart
if (class_exists('Titon\G11n\Utility\Inflector')) {
return \Titon\G11n\Utility\Inflector::slug($string);
}
// @codeCoverageIgnoreEnd
return Inflector::slug($string);
} | [
"public",
"static",
"function",
"slugify",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"strip_tags",
"(",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"[",
"'&'",
",",
"'&'",
"]",
",",
"'and'",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"'@'",
",",
"'at'",
",",
"$",
"string",
")",
";",
"// @codeCoverageIgnoreStart",
"if",
"(",
"class_exists",
"(",
"'Titon\\G11n\\Utility\\Inflector'",
")",
")",
"{",
"return",
"\\",
"Titon",
"\\",
"G11n",
"\\",
"Utility",
"\\",
"Inflector",
"::",
"slug",
"(",
"$",
"string",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"return",
"Inflector",
"::",
"slug",
"(",
"$",
"string",
")",
";",
"}"
] | Return a slugged version of a string.
@param string $string
@return string | [
"Return",
"a",
"slugged",
"version",
"of",
"a",
"string",
"."
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/SlugBehavior.php#L131-L143 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.create | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof UserQuery) {
return $criteria;
}
$query = new UserQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | php | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof UserQuery) {
return $criteria;
}
$query = new UserQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelAlias",
"=",
"null",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"criteria",
"instanceof",
"UserQuery",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"query",
"=",
"new",
"UserQuery",
"(",
"null",
",",
"null",
",",
"$",
"modelAlias",
")",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"query",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Returns a new UserQuery object.
@param string $modelAlias The alias of a model in the query
@param UserQuery|Criteria $criteria Optional Criteria to build the query from
@return UserQuery | [
"Returns",
"a",
"new",
"UserQuery",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L120-L132 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByUsername | public function filterByUsername($username = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($username)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $username)) {
$username = str_replace('*', '%', $username);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::USERNAME, $username, $comparison);
} | php | public function filterByUsername($username = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($username)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $username)) {
$username = str_replace('*', '%', $username);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::USERNAME, $username, $comparison);
} | [
"public",
"function",
"filterByUsername",
"(",
"$",
"username",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"username",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"username",
")",
")",
"{",
"$",
"username",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"username",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"USERNAME",
",",
"$",
"username",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the username column
Example usage:
<code>
$query->filterByUsername('fooValue'); // WHERE username = 'fooValue'
$query->filterByUsername('%fooValue%'); // WHERE username LIKE '%fooValue%'
</code>
@param string $username The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"username",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L342-L354 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByPassword | public function filterByPassword($password = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($password)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $password)) {
$password = str_replace('*', '%', $password);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::PASSWORD, $password, $comparison);
} | php | public function filterByPassword($password = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($password)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $password)) {
$password = str_replace('*', '%', $password);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::PASSWORD, $password, $comparison);
} | [
"public",
"function",
"filterByPassword",
"(",
"$",
"password",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"password",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"password",
")",
")",
"{",
"$",
"password",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"password",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"PASSWORD",
",",
"$",
"password",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the password column
Example usage:
<code>
$query->filterByPassword('fooValue'); // WHERE password = 'fooValue'
$query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
</code>
@param string $password The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"password",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L371-L383 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterBySalt | public function filterBySalt($salt = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($salt)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $salt)) {
$salt = str_replace('*', '%', $salt);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::SALT, $salt, $comparison);
} | php | public function filterBySalt($salt = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($salt)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $salt)) {
$salt = str_replace('*', '%', $salt);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::SALT, $salt, $comparison);
} | [
"public",
"function",
"filterBySalt",
"(",
"$",
"salt",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"salt",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"salt",
")",
")",
"{",
"$",
"salt",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"salt",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"SALT",
",",
"$",
"salt",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the salt column
Example usage:
<code>
$query->filterBySalt('fooValue'); // WHERE salt = 'fooValue'
$query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%'
</code>
@param string $salt The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"salt",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L400-L412 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByFirstname | public function filterByFirstname($firstname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($firstname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $firstname)) {
$firstname = str_replace('*', '%', $firstname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::FIRSTNAME, $firstname, $comparison);
} | php | public function filterByFirstname($firstname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($firstname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $firstname)) {
$firstname = str_replace('*', '%', $firstname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::FIRSTNAME, $firstname, $comparison);
} | [
"public",
"function",
"filterByFirstname",
"(",
"$",
"firstname",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"firstname",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"firstname",
")",
")",
"{",
"$",
"firstname",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"firstname",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"FIRSTNAME",
",",
"$",
"firstname",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the firstname column
Example usage:
<code>
$query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
$query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
</code>
@param string $firstname The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"firstname",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L429-L441 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByLastname | public function filterByLastname($lastname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($lastname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $lastname)) {
$lastname = str_replace('*', '%', $lastname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::LASTNAME, $lastname, $comparison);
} | php | public function filterByLastname($lastname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($lastname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $lastname)) {
$lastname = str_replace('*', '%', $lastname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::LASTNAME, $lastname, $comparison);
} | [
"public",
"function",
"filterByLastname",
"(",
"$",
"lastname",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"lastname",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"lastname",
")",
")",
"{",
"$",
"lastname",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"lastname",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LASTNAME",
",",
"$",
"lastname",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the lastname column
Example usage:
<code>
$query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
$query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
</code>
@param string $lastname The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"lastname",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L458-L470 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByPhone | public function filterByPhone($phone = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($phone)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $phone)) {
$phone = str_replace('*', '%', $phone);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::PHONE, $phone, $comparison);
} | php | public function filterByPhone($phone = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($phone)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $phone)) {
$phone = str_replace('*', '%', $phone);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::PHONE, $phone, $comparison);
} | [
"public",
"function",
"filterByPhone",
"(",
"$",
"phone",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"phone",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"phone",
")",
")",
"{",
"$",
"phone",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"phone",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"PHONE",
",",
"$",
"phone",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the phone column
Example usage:
<code>
$query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
$query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
</code>
@param string $phone The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"phone",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L516-L528 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByMemo | public function filterByMemo($memo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($memo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $memo)) {
$memo = str_replace('*', '%', $memo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::MEMO, $memo, $comparison);
} | php | public function filterByMemo($memo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($memo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $memo)) {
$memo = str_replace('*', '%', $memo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::MEMO, $memo, $comparison);
} | [
"public",
"function",
"filterByMemo",
"(",
"$",
"memo",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"memo",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"memo",
")",
")",
"{",
"$",
"memo",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"memo",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"MEMO",
",",
"$",
"memo",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the memo column
Example usage:
<code>
$query->filterByMemo('fooValue'); // WHERE memo = 'fooValue'
$query->filterByMemo('%fooValue%'); // WHERE memo LIKE '%fooValue%'
</code>
@param string $memo The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"memo",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L545-L557 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByActivated | public function filterByActivated($activated = null, $comparison = null)
{
if (is_string($activated)) {
$activated = in_array(strtolower($activated), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(UserPeer::ACTIVATED, $activated, $comparison);
} | php | public function filterByActivated($activated = null, $comparison = null)
{
if (is_string($activated)) {
$activated = in_array(strtolower($activated), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(UserPeer::ACTIVATED, $activated, $comparison);
} | [
"public",
"function",
"filterByActivated",
"(",
"$",
"activated",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"activated",
")",
")",
"{",
"$",
"activated",
"=",
"in_array",
"(",
"strtolower",
"(",
"$",
"activated",
")",
",",
"array",
"(",
"'false'",
",",
"'off'",
",",
"'-'",
",",
"'no'",
",",
"'n'",
",",
"'0'",
",",
"''",
")",
")",
"?",
"false",
":",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"ACTIVATED",
",",
"$",
"activated",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the activated column
Example usage:
<code>
$query->filterByActivated(true); // WHERE activated = true
$query->filterByActivated('yes'); // WHERE activated = true
</code>
@param boolean|string $activated The value to use as filter.
Non-boolean arguments are converted using the following rules:
* 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* 0, '0', 'false', 'off', and 'no' are converted to boolean false
Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"activated",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L577-L584 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByLastLogin | public function filterByLastLogin($lastLogin = null, $comparison = null)
{
if (is_array($lastLogin)) {
$useMinMax = false;
if (isset($lastLogin['min'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($lastLogin['max'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin, $comparison);
} | php | public function filterByLastLogin($lastLogin = null, $comparison = null)
{
if (is_array($lastLogin)) {
$useMinMax = false;
if (isset($lastLogin['min'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($lastLogin['max'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin, $comparison);
} | [
"public",
"function",
"filterByLastLogin",
"(",
"$",
"lastLogin",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"lastLogin",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"lastLogin",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LAST_LOGIN",
",",
"$",
"lastLogin",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"lastLogin",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LAST_LOGIN",
",",
"$",
"lastLogin",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LAST_LOGIN",
",",
"$",
"lastLogin",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the last_login column
Example usage:
<code>
$query->filterByLastLogin('2011-03-14'); // WHERE last_login = '2011-03-14'
$query->filterByLastLogin('now'); // WHERE last_login = '2011-03-14'
$query->filterByLastLogin(array('max' => 'yesterday')); // WHERE last_login < '2011-03-13'
</code>
@param mixed $lastLogin The value to use as filter.
Values can be integers (unix timestamps), DateTime objects, or strings.
Empty strings are treated as NULL.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"last_login",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L606-L627 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByUserCustomerRelation | public function filterByUserCustomerRelation($userCustomerRelation, $comparison = null)
{
if ($userCustomerRelation instanceof UserCustomerRelation) {
return $this
->addUsingAlias(UserPeer::ID, $userCustomerRelation->getUserId(), $comparison);
} elseif ($userCustomerRelation instanceof PropelObjectCollection) {
return $this
->useUserCustomerRelationQuery()
->filterByPrimaryKeys($userCustomerRelation->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByUserCustomerRelation() only accepts arguments of type UserCustomerRelation or PropelCollection');
}
} | php | public function filterByUserCustomerRelation($userCustomerRelation, $comparison = null)
{
if ($userCustomerRelation instanceof UserCustomerRelation) {
return $this
->addUsingAlias(UserPeer::ID, $userCustomerRelation->getUserId(), $comparison);
} elseif ($userCustomerRelation instanceof PropelObjectCollection) {
return $this
->useUserCustomerRelationQuery()
->filterByPrimaryKeys($userCustomerRelation->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByUserCustomerRelation() only accepts arguments of type UserCustomerRelation or PropelCollection');
}
} | [
"public",
"function",
"filterByUserCustomerRelation",
"(",
"$",
"userCustomerRelation",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"userCustomerRelation",
"instanceof",
"UserCustomerRelation",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"ID",
",",
"$",
"userCustomerRelation",
"->",
"getUserId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"userCustomerRelation",
"instanceof",
"PropelObjectCollection",
")",
"{",
"return",
"$",
"this",
"->",
"useUserCustomerRelationQuery",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"userCustomerRelation",
"->",
"getPrimaryKeys",
"(",
")",
")",
"->",
"endUse",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByUserCustomerRelation() only accepts arguments of type UserCustomerRelation or PropelCollection'",
")",
";",
"}",
"}"
] | Filter the query by a related UserCustomerRelation object
@param UserCustomerRelation|PropelObjectCollection $userCustomerRelation the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface
@throws PropelException - if the provided filter is invalid. | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"UserCustomerRelation",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L692-L705 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByUserRole | public function filterByUserRole($userRole, $comparison = null)
{
if ($userRole instanceof UserRole) {
return $this
->addUsingAlias(UserPeer::ID, $userRole->getUserId(), $comparison);
} elseif ($userRole instanceof PropelObjectCollection) {
return $this
->useUserRoleQuery()
->filterByPrimaryKeys($userRole->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByUserRole() only accepts arguments of type UserRole or PropelCollection');
}
} | php | public function filterByUserRole($userRole, $comparison = null)
{
if ($userRole instanceof UserRole) {
return $this
->addUsingAlias(UserPeer::ID, $userRole->getUserId(), $comparison);
} elseif ($userRole instanceof PropelObjectCollection) {
return $this
->useUserRoleQuery()
->filterByPrimaryKeys($userRole->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByUserRole() only accepts arguments of type UserRole or PropelCollection');
}
} | [
"public",
"function",
"filterByUserRole",
"(",
"$",
"userRole",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"userRole",
"instanceof",
"UserRole",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"ID",
",",
"$",
"userRole",
"->",
"getUserId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"userRole",
"instanceof",
"PropelObjectCollection",
")",
"{",
"return",
"$",
"this",
"->",
"useUserRoleQuery",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"userRole",
"->",
"getPrimaryKeys",
"(",
")",
")",
"->",
"endUse",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByUserRole() only accepts arguments of type UserRole or PropelCollection'",
")",
";",
"}",
"}"
] | Filter the query by a related UserRole object
@param UserRole|PropelObjectCollection $userRole the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface
@throws PropelException - if the provided filter is invalid. | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"UserRole",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L766-L779 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.prune | public function prune($user = null)
{
if ($user) {
$this->addUsingAlias(UserPeer::ID, $user->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | php | public function prune($user = null)
{
if ($user) {
$this->addUsingAlias(UserPeer::ID, $user->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | [
"public",
"function",
"prune",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"ID",
",",
"$",
"user",
"->",
"getId",
"(",
")",
",",
"Criteria",
"::",
"NOT_EQUAL",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Exclude object from result
@param User $user Object to remove from the list of results
@return UserQuery The current query, for fluid interface | [
"Exclude",
"object",
"from",
"result"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L838-L845 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._create_cache_dir | private function _create_cache_dir()
{
if (! file_exists($this->config['cache_dir'])) {
try {
mkdir($this->config['cache_dir'], 0755, TRUE);
} catch (Exception $e) {
throw $e;
}
}
// Set the cache dir
$this->cache_dir = $this->config['cache_dir'];
} | php | private function _create_cache_dir()
{
if (! file_exists($this->config['cache_dir'])) {
try {
mkdir($this->config['cache_dir'], 0755, TRUE);
} catch (Exception $e) {
throw $e;
}
}
// Set the cache dir
$this->cache_dir = $this->config['cache_dir'];
} | [
"private",
"function",
"_create_cache_dir",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"config",
"[",
"'cache_dir'",
"]",
")",
")",
"{",
"try",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'cache_dir'",
"]",
",",
"0755",
",",
"TRUE",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"// Set the cache dir",
"$",
"this",
"->",
"cache_dir",
"=",
"$",
"this",
"->",
"config",
"[",
"'cache_dir'",
"]",
";",
"}"
] | Try to create the config cache dir if required
Set $cache_dir | [
"Try",
"to",
"create",
"the",
"config",
"cache",
"dir",
"if",
"required",
"Set",
"$cache_dir"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L124-L136 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._create_mimic_cache_dir | private function _create_mimic_cache_dir()
{
if ($this->config['mimic_source_dir']) {
// Get the dir from the source file
$mimic_dir = $this->config['cache_dir'] . pathinfo($this->source_file, PATHINFO_DIRNAME);
// Try to create if it does not exist
if (! file_exists($mimic_dir)) {
try {
mkdir($mimic_dir, 0755, TRUE);
} catch (Exception $e) {
throw $e;
}
}
// Set the cache dir, with trailling slash
$this->cache_dir = $mimic_dir . '/';
}
} | php | private function _create_mimic_cache_dir()
{
if ($this->config['mimic_source_dir']) {
// Get the dir from the source file
$mimic_dir = $this->config['cache_dir'] . pathinfo($this->source_file, PATHINFO_DIRNAME);
// Try to create if it does not exist
if (! file_exists($mimic_dir)) {
try {
mkdir($mimic_dir, 0755, TRUE);
} catch (Exception $e) {
throw $e;
}
}
// Set the cache dir, with trailling slash
$this->cache_dir = $mimic_dir . '/';
}
} | [
"private",
"function",
"_create_mimic_cache_dir",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'mimic_source_dir'",
"]",
")",
"{",
"// Get the dir from the source file",
"$",
"mimic_dir",
"=",
"$",
"this",
"->",
"config",
"[",
"'cache_dir'",
"]",
".",
"pathinfo",
"(",
"$",
"this",
"->",
"source_file",
",",
"PATHINFO_DIRNAME",
")",
";",
"// Try to create if it does not exist",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"mimic_dir",
")",
")",
"{",
"try",
"{",
"mkdir",
"(",
"$",
"mimic_dir",
",",
"0755",
",",
"TRUE",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"// Set the cache dir, with trailling slash",
"$",
"this",
"->",
"cache_dir",
"=",
"$",
"mimic_dir",
".",
"'/'",
";",
"}",
"}"
] | Try to create the mimic cache dir from the source path if required
Set $cache_dir | [
"Try",
"to",
"create",
"the",
"mimic",
"cache",
"dir",
"from",
"the",
"source",
"path",
"if",
"required",
"Set",
"$cache_dir"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L142-L160 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._set_params | private function _set_params()
{
// Get values from request
$params = \Request::route('params');
$filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath');
// echo $params; exit;
// If enforcing params, ensure it's a match
if ($this->config['enforce_presets'] && !in_array($params, $this->config['presets'])) {
abort(404);
}
$image = new Image();
$image->configure(config('image'));
if (function_exists('exif_read_data')) {
$this->image = $image->make($filepath)->orientate();
} else {
$this->image = $image->make($filepath);
}
// The parameters are separated by hyphens
$raw_params = explode('-', $params);
// Update param values from passed values
foreach ($raw_params as $raw_param) {
$name = $raw_param[0];
$value = substr($raw_param, 1, strlen($raw_param) - 1);
if ($name == 'c') {
$this->url_params[$name] = TRUE;
// When croping, we must have a width and height to pass to imagecreatetruecolor method
// Make width the height or vice versa if either is not passed
if (empty($this->url_params['w'])) {
$this->url_params['w'] = $this->url_params['h'];
}
if (empty($this->url_params['h'])) {
$this->url_params['h'] = $this->url_params['w'];
}
} elseif (key_exists($name, $this->url_params)) {
// Remaining expected params (w, h, q)
$this->url_params[$name] = $value;
} else {
// Watermarks or invalid params
$this->url_params[$raw_param] = $raw_param;
}
}
// Do not scale up images
if (! $this->config['scale_up']) {
if ($this->url_params['w'] > $this->image->width()) {
$this->url_params['w'] = $this->image->width();
}
if ($this->url_params['h'] > $this->image->height()) {
$this->url_params['h'] = $this->image->height();
}
}
// Must have at least a width or height
if (empty($this->url_params['w']) and empty($this->url_params['h'])) {
throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(
':uri' => Request::$current->uri()
));
}
// Set the url filepath
$this->source_file = $filepath;
} | php | private function _set_params()
{
// Get values from request
$params = \Request::route('params');
$filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath');
// echo $params; exit;
// If enforcing params, ensure it's a match
if ($this->config['enforce_presets'] && !in_array($params, $this->config['presets'])) {
abort(404);
}
$image = new Image();
$image->configure(config('image'));
if (function_exists('exif_read_data')) {
$this->image = $image->make($filepath)->orientate();
} else {
$this->image = $image->make($filepath);
}
// The parameters are separated by hyphens
$raw_params = explode('-', $params);
// Update param values from passed values
foreach ($raw_params as $raw_param) {
$name = $raw_param[0];
$value = substr($raw_param, 1, strlen($raw_param) - 1);
if ($name == 'c') {
$this->url_params[$name] = TRUE;
// When croping, we must have a width and height to pass to imagecreatetruecolor method
// Make width the height or vice versa if either is not passed
if (empty($this->url_params['w'])) {
$this->url_params['w'] = $this->url_params['h'];
}
if (empty($this->url_params['h'])) {
$this->url_params['h'] = $this->url_params['w'];
}
} elseif (key_exists($name, $this->url_params)) {
// Remaining expected params (w, h, q)
$this->url_params[$name] = $value;
} else {
// Watermarks or invalid params
$this->url_params[$raw_param] = $raw_param;
}
}
// Do not scale up images
if (! $this->config['scale_up']) {
if ($this->url_params['w'] > $this->image->width()) {
$this->url_params['w'] = $this->image->width();
}
if ($this->url_params['h'] > $this->image->height()) {
$this->url_params['h'] = $this->image->height();
}
}
// Must have at least a width or height
if (empty($this->url_params['w']) and empty($this->url_params['h'])) {
throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(
':uri' => Request::$current->uri()
));
}
// Set the url filepath
$this->source_file = $filepath;
} | [
"private",
"function",
"_set_params",
"(",
")",
"{",
"// Get values from request",
"$",
"params",
"=",
"\\",
"Request",
"::",
"route",
"(",
"'params'",
")",
";",
"$",
"filepath",
"=",
"$",
"this",
"->",
"config",
"[",
"'abs_path'",
"]",
".",
"'/'",
".",
"\\",
"Request",
"::",
"route",
"(",
"'imagepath'",
")",
";",
"// echo $params; exit;",
"// If enforcing params, ensure it's a match",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'enforce_presets'",
"]",
"&&",
"!",
"in_array",
"(",
"$",
"params",
",",
"$",
"this",
"->",
"config",
"[",
"'presets'",
"]",
")",
")",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"$",
"image",
"=",
"new",
"Image",
"(",
")",
";",
"$",
"image",
"->",
"configure",
"(",
"config",
"(",
"'image'",
")",
")",
";",
"if",
"(",
"function_exists",
"(",
"'exif_read_data'",
")",
")",
"{",
"$",
"this",
"->",
"image",
"=",
"$",
"image",
"->",
"make",
"(",
"$",
"filepath",
")",
"->",
"orientate",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"image",
"=",
"$",
"image",
"->",
"make",
"(",
"$",
"filepath",
")",
";",
"}",
"// The parameters are separated by hyphens",
"$",
"raw_params",
"=",
"explode",
"(",
"'-'",
",",
"$",
"params",
")",
";",
"// Update param values from passed values",
"foreach",
"(",
"$",
"raw_params",
"as",
"$",
"raw_param",
")",
"{",
"$",
"name",
"=",
"$",
"raw_param",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"substr",
"(",
"$",
"raw_param",
",",
"1",
",",
"strlen",
"(",
"$",
"raw_param",
")",
"-",
"1",
")",
";",
"if",
"(",
"$",
"name",
"==",
"'c'",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"$",
"name",
"]",
"=",
"TRUE",
";",
"// When croping, we must have a width and height to pass to imagecreatetruecolor method",
"// Make width the height or vice versa if either is not passed",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
"=",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
"=",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
";",
"}",
"}",
"elseif",
"(",
"key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"url_params",
")",
")",
"{",
"// Remaining expected params (w, h, q)",
"$",
"this",
"->",
"url_params",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"// Watermarks or invalid params",
"$",
"this",
"->",
"url_params",
"[",
"$",
"raw_param",
"]",
"=",
"$",
"raw_param",
";",
"}",
"}",
"// Do not scale up images",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"'scale_up'",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
">",
"$",
"this",
"->",
"image",
"->",
"width",
"(",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
"=",
"$",
"this",
"->",
"image",
"->",
"width",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
">",
"$",
"this",
"->",
"image",
"->",
"height",
"(",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
"=",
"$",
"this",
"->",
"image",
"->",
"height",
"(",
")",
";",
"}",
"}",
"// Must have at least a width or height",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
")",
"and",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
")",
")",
"{",
"throw",
"new",
"HTTP_Exception_404",
"(",
"'The requested URL :uri was not found on this server.'",
",",
"array",
"(",
"':uri'",
"=>",
"Request",
"::",
"$",
"current",
"->",
"uri",
"(",
")",
")",
")",
";",
"}",
"// Set the url filepath",
"$",
"this",
"->",
"source_file",
"=",
"$",
"filepath",
";",
"}"
] | Sets the operations params from the url | [
"Sets",
"the",
"operations",
"params",
"from",
"the",
"url"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L165-L233 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._cached_required | private function _cached_required()
{
$image_info = getimagesize($this->source_file);
if (($this->url_params['w'] == $image_info[0]) and ($this->url_params['h'] == $image_info[1])) {
$this->serve_default = TRUE;
return FALSE;
}
return TRUE;
} | php | private function _cached_required()
{
$image_info = getimagesize($this->source_file);
if (($this->url_params['w'] == $image_info[0]) and ($this->url_params['h'] == $image_info[1])) {
$this->serve_default = TRUE;
return FALSE;
}
return TRUE;
} | [
"private",
"function",
"_cached_required",
"(",
")",
"{",
"$",
"image_info",
"=",
"getimagesize",
"(",
"$",
"this",
"->",
"source_file",
")",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
"==",
"$",
"image_info",
"[",
"0",
"]",
")",
"and",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
"==",
"$",
"image_info",
"[",
"1",
"]",
")",
")",
"{",
"$",
"this",
"->",
"serve_default",
"=",
"TRUE",
";",
"return",
"FALSE",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Checks that the param dimensions are are lower then current image dimensions
@return boolean | [
"Checks",
"that",
"the",
"param",
"dimensions",
"are",
"are",
"lower",
"then",
"current",
"image",
"dimensions"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L250-L260 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._encoded_filename | private function _encoded_filename()
{
$ext = strtolower(pathinfo($this->source_file, PATHINFO_EXTENSION));
$encode = md5($this->source_file . http_build_query($this->url_params));
// Build the parts of the filename
$encoded_name = $encode . '-' . $this->source_modified . '.' . $ext;
return $encoded_name;
} | php | private function _encoded_filename()
{
$ext = strtolower(pathinfo($this->source_file, PATHINFO_EXTENSION));
$encode = md5($this->source_file . http_build_query($this->url_params));
// Build the parts of the filename
$encoded_name = $encode . '-' . $this->source_modified . '.' . $ext;
return $encoded_name;
} | [
"private",
"function",
"_encoded_filename",
"(",
")",
"{",
"$",
"ext",
"=",
"strtolower",
"(",
"pathinfo",
"(",
"$",
"this",
"->",
"source_file",
",",
"PATHINFO_EXTENSION",
")",
")",
";",
"$",
"encode",
"=",
"md5",
"(",
"$",
"this",
"->",
"source_file",
".",
"http_build_query",
"(",
"$",
"this",
"->",
"url_params",
")",
")",
";",
"// Build the parts of the filename",
"$",
"encoded_name",
"=",
"$",
"encode",
".",
"'-'",
".",
"$",
"this",
"->",
"source_modified",
".",
"'.'",
".",
"$",
"ext",
";",
"return",
"$",
"encoded_name",
";",
"}"
] | Returns a hash of the filepath and params plus last modified of source to be used as a unique filename
@return string | [
"Returns",
"a",
"hash",
"of",
"the",
"filepath",
"and",
"params",
"plus",
"last",
"modified",
"of",
"source",
"to",
"be",
"used",
"as",
"a",
"unique",
"filename"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L267-L276 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._create_cached | private function _create_cached()
{
if (isset($this->url_params['c']) && $this->url_params['c']) {
// Resize to highest width or height with overflow on the larger side
$this->resize($this->url_params['w'], $this->url_params['h'], self::INVERSE);
// $this->image->resize($this->url_params['w'], $this->url_params['h']);
// Crop any overflow from the larger side
$this->image->crop($this->url_params['w'], $this->url_params['h'], 0, 0);
} elseif (isset($this->url_params['nc']) && $this->url_params['nc']) {
$img = Image::canvas($this->url_params['w'], $this->url_params['h'], $this->config['nc_color']);
// Resize to width and height
$this->resize($this->url_params['w'], $this->url_params['h'], self::AUTO);
$img->insert($this->image, 'center');
$this->image = $img;
} elseif (isset($this->url_params['a']) && $this->url_params['a']) {
// Just Resize automatically
$this->resize($this->url_params['w'], $this->url_params['h']);
} else {
// Just Resize
$this->resize($this->url_params['w'], $this->url_params['h'], self::INVERSE);
}
// Apply any valid watermark params
// $watermarks = array_get($this->config, 'watermarks');
// if ( ! empty($watermarks))
// {
// foreach ($watermarks as $key => $watermark)
// {
// if (key_exists($key, $this->url_params))
// {
// $image = Image::factory($watermark['image']);
// $this->image->watermark($image, $watermark['offset_x'], $watermark['offset_y'], $watermark['opacity']);
// }
// }
// }
// Save
if ($this->url_params['q']) {
// Save image with quality param
$this->image->save($this->cached_file, $this->url_params['q']);
} else {
// Save image with default quality
$this->image->save($this->cached_file, array_get($this->config, 'quality', 80));
}
} | php | private function _create_cached()
{
if (isset($this->url_params['c']) && $this->url_params['c']) {
// Resize to highest width or height with overflow on the larger side
$this->resize($this->url_params['w'], $this->url_params['h'], self::INVERSE);
// $this->image->resize($this->url_params['w'], $this->url_params['h']);
// Crop any overflow from the larger side
$this->image->crop($this->url_params['w'], $this->url_params['h'], 0, 0);
} elseif (isset($this->url_params['nc']) && $this->url_params['nc']) {
$img = Image::canvas($this->url_params['w'], $this->url_params['h'], $this->config['nc_color']);
// Resize to width and height
$this->resize($this->url_params['w'], $this->url_params['h'], self::AUTO);
$img->insert($this->image, 'center');
$this->image = $img;
} elseif (isset($this->url_params['a']) && $this->url_params['a']) {
// Just Resize automatically
$this->resize($this->url_params['w'], $this->url_params['h']);
} else {
// Just Resize
$this->resize($this->url_params['w'], $this->url_params['h'], self::INVERSE);
}
// Apply any valid watermark params
// $watermarks = array_get($this->config, 'watermarks');
// if ( ! empty($watermarks))
// {
// foreach ($watermarks as $key => $watermark)
// {
// if (key_exists($key, $this->url_params))
// {
// $image = Image::factory($watermark['image']);
// $this->image->watermark($image, $watermark['offset_x'], $watermark['offset_y'], $watermark['opacity']);
// }
// }
// }
// Save
if ($this->url_params['q']) {
// Save image with quality param
$this->image->save($this->cached_file, $this->url_params['q']);
} else {
// Save image with default quality
$this->image->save($this->cached_file, array_get($this->config, 'quality', 80));
}
} | [
"private",
"function",
"_create_cached",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'c'",
"]",
")",
"&&",
"$",
"this",
"->",
"url_params",
"[",
"'c'",
"]",
")",
"{",
"// Resize to highest width or height with overflow on the larger side",
"$",
"this",
"->",
"resize",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
",",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
",",
"self",
"::",
"INVERSE",
")",
";",
"// $this->image->resize($this->url_params['w'], $this->url_params['h']);",
"// Crop any overflow from the larger side",
"$",
"this",
"->",
"image",
"->",
"crop",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
",",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
",",
"0",
",",
"0",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'nc'",
"]",
")",
"&&",
"$",
"this",
"->",
"url_params",
"[",
"'nc'",
"]",
")",
"{",
"$",
"img",
"=",
"Image",
"::",
"canvas",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
",",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'nc_color'",
"]",
")",
";",
"// Resize to width and height",
"$",
"this",
"->",
"resize",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
",",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
",",
"self",
"::",
"AUTO",
")",
";",
"$",
"img",
"->",
"insert",
"(",
"$",
"this",
"->",
"image",
",",
"'center'",
")",
";",
"$",
"this",
"->",
"image",
"=",
"$",
"img",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'a'",
"]",
")",
"&&",
"$",
"this",
"->",
"url_params",
"[",
"'a'",
"]",
")",
"{",
"// Just Resize automatically",
"$",
"this",
"->",
"resize",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
",",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
")",
";",
"}",
"else",
"{",
"// Just Resize",
"$",
"this",
"->",
"resize",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
",",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
",",
"self",
"::",
"INVERSE",
")",
";",
"}",
"// Apply any valid watermark params",
"// $watermarks = array_get($this->config, 'watermarks');",
"// if ( ! empty($watermarks))",
"// {",
"// foreach ($watermarks as $key => $watermark)",
"// {",
"// if (key_exists($key, $this->url_params))",
"// {",
"// $image = Image::factory($watermark['image']);",
"// $this->image->watermark($image, $watermark['offset_x'], $watermark['offset_y'], $watermark['opacity']);",
"// }",
"// }",
"// }",
"// Save",
"if",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'q'",
"]",
")",
"{",
"// Save image with quality param",
"$",
"this",
"->",
"image",
"->",
"save",
"(",
"$",
"this",
"->",
"cached_file",
",",
"$",
"this",
"->",
"url_params",
"[",
"'q'",
"]",
")",
";",
"}",
"else",
"{",
"// Save image with default quality",
"$",
"this",
"->",
"image",
"->",
"save",
"(",
"$",
"this",
"->",
"cached_file",
",",
"array_get",
"(",
"$",
"this",
"->",
"config",
",",
"'quality'",
",",
"80",
")",
")",
";",
"}",
"}"
] | Creates a cached cropped/resized version of the file | [
"Creates",
"a",
"cached",
"cropped",
"/",
"resized",
"version",
"of",
"the",
"file"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L281-L328 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._create_headers | private function _create_headers($file_data)
{
// Create the required header vars
$last_modified = gmdate('D, d M Y H:i:s', filemtime($file_data)) . ' GMT';
$filesystem = new \Illuminate\Filesystem\Filesystem;
$content_type = $filesystem->mimeType($file_data);
// $content_type = \Illuminate\Filesystem\Filesystem::mimeType($file_data);
$content_length = filesize($file_data);
$expires = gmdate('D, d M Y H:i:s', (time() + $this->config['cache_expire'])) . ' GMT';
$max_age = 'max-age=' . $this->config['cache_expire'] . ', public';
// Some required headers
header("Last-Modified: $last_modified");
header("Content-Type: $content_type");
header("Content-Length: $content_length");
// How long to hold in the browser cache
header("Expires: $expires");
/**
* Public in the Cache-Control lets proxies know that it is okay to
* cache this content.
* If this is being served over HTTPS, there may be
* sensitive content and therefore should probably not be cached by
* proxy servers.
*/
header("Cache-Control: $max_age");
// Set the 304 Not Modified if required
$this->_modified_headers($last_modified);
/**
* The "Connection: close" header allows us to serve the file and let
* the browser finish processing the script so we can do extra work
* without making the user wait.
* This header must come last or the file
* size will not properly work for images in the browser's cache
*/
header("Connection: close");
} | php | private function _create_headers($file_data)
{
// Create the required header vars
$last_modified = gmdate('D, d M Y H:i:s', filemtime($file_data)) . ' GMT';
$filesystem = new \Illuminate\Filesystem\Filesystem;
$content_type = $filesystem->mimeType($file_data);
// $content_type = \Illuminate\Filesystem\Filesystem::mimeType($file_data);
$content_length = filesize($file_data);
$expires = gmdate('D, d M Y H:i:s', (time() + $this->config['cache_expire'])) . ' GMT';
$max_age = 'max-age=' . $this->config['cache_expire'] . ', public';
// Some required headers
header("Last-Modified: $last_modified");
header("Content-Type: $content_type");
header("Content-Length: $content_length");
// How long to hold in the browser cache
header("Expires: $expires");
/**
* Public in the Cache-Control lets proxies know that it is okay to
* cache this content.
* If this is being served over HTTPS, there may be
* sensitive content and therefore should probably not be cached by
* proxy servers.
*/
header("Cache-Control: $max_age");
// Set the 304 Not Modified if required
$this->_modified_headers($last_modified);
/**
* The "Connection: close" header allows us to serve the file and let
* the browser finish processing the script so we can do extra work
* without making the user wait.
* This header must come last or the file
* size will not properly work for images in the browser's cache
*/
header("Connection: close");
} | [
"private",
"function",
"_create_headers",
"(",
"$",
"file_data",
")",
"{",
"// Create the required header vars",
"$",
"last_modified",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s'",
",",
"filemtime",
"(",
"$",
"file_data",
")",
")",
".",
"' GMT'",
";",
"$",
"filesystem",
"=",
"new",
"\\",
"Illuminate",
"\\",
"Filesystem",
"\\",
"Filesystem",
";",
"$",
"content_type",
"=",
"$",
"filesystem",
"->",
"mimeType",
"(",
"$",
"file_data",
")",
";",
"// $content_type = \\Illuminate\\Filesystem\\Filesystem::mimeType($file_data);",
"$",
"content_length",
"=",
"filesize",
"(",
"$",
"file_data",
")",
";",
"$",
"expires",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s'",
",",
"(",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"config",
"[",
"'cache_expire'",
"]",
")",
")",
".",
"' GMT'",
";",
"$",
"max_age",
"=",
"'max-age='",
".",
"$",
"this",
"->",
"config",
"[",
"'cache_expire'",
"]",
".",
"', public'",
";",
"// Some required headers",
"header",
"(",
"\"Last-Modified: $last_modified\"",
")",
";",
"header",
"(",
"\"Content-Type: $content_type\"",
")",
";",
"header",
"(",
"\"Content-Length: $content_length\"",
")",
";",
"// How long to hold in the browser cache",
"header",
"(",
"\"Expires: $expires\"",
")",
";",
"/**\n * Public in the Cache-Control lets proxies know that it is okay to\n * cache this content.\n * If this is being served over HTTPS, there may be\n * sensitive content and therefore should probably not be cached by\n * proxy servers.\n */",
"header",
"(",
"\"Cache-Control: $max_age\"",
")",
";",
"// Set the 304 Not Modified if required",
"$",
"this",
"->",
"_modified_headers",
"(",
"$",
"last_modified",
")",
";",
"/**\n * The \"Connection: close\" header allows us to serve the file and let\n * the browser finish processing the script so we can do extra work\n * without making the user wait.\n * This header must come last or the file\n * size will not properly work for images in the browser's cache\n */",
"header",
"(",
"\"Connection: close\"",
")",
";",
"}"
] | Create the image HTTP headers
@param
string path to the file to server (either default or cached version) | [
"Create",
"the",
"image",
"HTTP",
"headers"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L336-L375 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._modified_headers | private function _modified_headers($last_modified)
{
$modified_since = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
if (! $modified_since or $modified_since != $last_modified)
return;
// Nothing has changed since their last request - serve a 304 and exit
header('HTTP/1.1 304 Not Modified');
header('Connection: close');
exit();
} | php | private function _modified_headers($last_modified)
{
$modified_since = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
if (! $modified_since or $modified_since != $last_modified)
return;
// Nothing has changed since their last request - serve a 304 and exit
header('HTTP/1.1 304 Not Modified');
header('Connection: close');
exit();
} | [
"private",
"function",
"_modified_headers",
"(",
"$",
"last_modified",
")",
"{",
"$",
"modified_since",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_IF_MODIFIED_SINCE'",
"]",
")",
")",
"?",
"stripslashes",
"(",
"$",
"_SERVER",
"[",
"'HTTP_IF_MODIFIED_SINCE'",
"]",
")",
":",
"FALSE",
";",
"if",
"(",
"!",
"$",
"modified_since",
"or",
"$",
"modified_since",
"!=",
"$",
"last_modified",
")",
"return",
";",
"// Nothing has changed since their last request - serve a 304 and exit",
"header",
"(",
"'HTTP/1.1 304 Not Modified'",
")",
";",
"header",
"(",
"'Connection: close'",
")",
";",
"exit",
"(",
")",
";",
"}"
] | Rerurns 304 Not Modified HTTP headers if required and exits
@param
string header formatted date | [
"Rerurns",
"304",
"Not",
"Modified",
"HTTP",
"headers",
"if",
"required",
"and",
"exits"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L383-L394 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._serve_file | private function _serve_file()
{
// Set either the source or cache file as our datasource
if ($this->serve_default) {
$file_data = $this->source_file;
} else {
$file_data = $this->cached_file;
}
// Output the file
$this->_output_file($file_data);
} | php | private function _serve_file()
{
// Set either the source or cache file as our datasource
if ($this->serve_default) {
$file_data = $this->source_file;
} else {
$file_data = $this->cached_file;
}
// Output the file
$this->_output_file($file_data);
} | [
"private",
"function",
"_serve_file",
"(",
")",
"{",
"// Set either the source or cache file as our datasource",
"if",
"(",
"$",
"this",
"->",
"serve_default",
")",
"{",
"$",
"file_data",
"=",
"$",
"this",
"->",
"source_file",
";",
"}",
"else",
"{",
"$",
"file_data",
"=",
"$",
"this",
"->",
"cached_file",
";",
"}",
"// Output the file",
"$",
"this",
"->",
"_output_file",
"(",
"$",
"file_data",
")",
";",
"}"
] | Decide which filesource we are using and serve | [
"Decide",
"which",
"filesource",
"we",
"are",
"using",
"and",
"serve"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L399-L410 |
ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._output_file | private function _output_file($file_data)
{
// Create the headers
$this->_create_headers($file_data);
// Get the file data
$data = file_get_contents($file_data);
// Send the image to the browser in bite-sized chunks
$chunk_size = 1024 * 8;
$fp = fopen('php://memory', 'r+b');
// Process file data
fwrite($fp, $data);
rewind($fp);
while (! feof($fp)) {
echo fread($fp, $chunk_size);
flush();
}
fclose($fp);
exit();
} | php | private function _output_file($file_data)
{
// Create the headers
$this->_create_headers($file_data);
// Get the file data
$data = file_get_contents($file_data);
// Send the image to the browser in bite-sized chunks
$chunk_size = 1024 * 8;
$fp = fopen('php://memory', 'r+b');
// Process file data
fwrite($fp, $data);
rewind($fp);
while (! feof($fp)) {
echo fread($fp, $chunk_size);
flush();
}
fclose($fp);
exit();
} | [
"private",
"function",
"_output_file",
"(",
"$",
"file_data",
")",
"{",
"// Create the headers",
"$",
"this",
"->",
"_create_headers",
"(",
"$",
"file_data",
")",
";",
"// Get the file data",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"file_data",
")",
";",
"// Send the image to the browser in bite-sized chunks",
"$",
"chunk_size",
"=",
"1024",
"*",
"8",
";",
"$",
"fp",
"=",
"fopen",
"(",
"'php://memory'",
",",
"'r+b'",
")",
";",
"// Process file data",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"data",
")",
";",
"rewind",
"(",
"$",
"fp",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"fp",
")",
")",
"{",
"echo",
"fread",
"(",
"$",
"fp",
",",
"$",
"chunk_size",
")",
";",
"flush",
"(",
")",
";",
"}",
"fclose",
"(",
"$",
"fp",
")",
";",
"exit",
"(",
")",
";",
"}"
] | Outputs the cached image file and exits
@param
string path to the file to server (either default or cached version) | [
"Outputs",
"the",
"cached",
"image",
"file",
"and",
"exits"
] | train | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L418-L440 |
devmobgroup/postcodes | src/Providers/HttpProvider.php | HttpProvider.getClient | public function getClient(): ClientInterface
{
if (! isset($this->client)) {
$this->client = new GuzzleClient();
}
return $this->client;
} | php | public function getClient(): ClientInterface
{
if (! isset($this->client)) {
$this->client = new GuzzleClient();
}
return $this->client;
} | [
"public",
"function",
"getClient",
"(",
")",
":",
"ClientInterface",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"client",
")",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"new",
"GuzzleClient",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"client",
";",
"}"
] | Get the Http client.
@return \GuzzleHttp\ClientInterface | [
"Get",
"the",
"Http",
"client",
"."
] | train | https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Providers/HttpProvider.php#L39-L46 |
devmobgroup/postcodes | src/Providers/HttpProvider.php | HttpProvider.lookup | public function lookup(string $postcode, string $number): array
{
$input = [
'postcode' => $postcode,
'number' => $number
];
// Create http request to send
$request = $this->request($input);
$response = null;
try {
// Make request and parse response
return $this->parse(
$response = $this->client->send($request),
$input
);
} catch (GuzzleException $e) {
// Catch request exceptions and try to parse the response
if ($e instanceof RequestException && $e->hasResponse()) {
return $this->parse($e->getResponse(), $input);
}
throw new HttpException('Guzzle: ' . $e->getMessage(), $request, $response, $e);
} catch (Throwable $e) {
// Only rethrow exceptions from our own package
if ($e instanceof PostcodesException) {
throw $e;
}
throw new LogicException('Uncaught exception: ' . $e->getMessage(), 0, $e);
}
} | php | public function lookup(string $postcode, string $number): array
{
$input = [
'postcode' => $postcode,
'number' => $number
];
// Create http request to send
$request = $this->request($input);
$response = null;
try {
// Make request and parse response
return $this->parse(
$response = $this->client->send($request),
$input
);
} catch (GuzzleException $e) {
// Catch request exceptions and try to parse the response
if ($e instanceof RequestException && $e->hasResponse()) {
return $this->parse($e->getResponse(), $input);
}
throw new HttpException('Guzzle: ' . $e->getMessage(), $request, $response, $e);
} catch (Throwable $e) {
// Only rethrow exceptions from our own package
if ($e instanceof PostcodesException) {
throw $e;
}
throw new LogicException('Uncaught exception: ' . $e->getMessage(), 0, $e);
}
} | [
"public",
"function",
"lookup",
"(",
"string",
"$",
"postcode",
",",
"string",
"$",
"number",
")",
":",
"array",
"{",
"$",
"input",
"=",
"[",
"'postcode'",
"=>",
"$",
"postcode",
",",
"'number'",
"=>",
"$",
"number",
"]",
";",
"// Create http request to send",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"input",
")",
";",
"$",
"response",
"=",
"null",
";",
"try",
"{",
"// Make request and parse response",
"return",
"$",
"this",
"->",
"parse",
"(",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
",",
"$",
"input",
")",
";",
"}",
"catch",
"(",
"GuzzleException",
"$",
"e",
")",
"{",
"// Catch request exceptions and try to parse the response",
"if",
"(",
"$",
"e",
"instanceof",
"RequestException",
"&&",
"$",
"e",
"->",
"hasResponse",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parse",
"(",
"$",
"e",
"->",
"getResponse",
"(",
")",
",",
"$",
"input",
")",
";",
"}",
"throw",
"new",
"HttpException",
"(",
"'Guzzle: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"request",
",",
"$",
"response",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"// Only rethrow exceptions from our own package",
"if",
"(",
"$",
"e",
"instanceof",
"PostcodesException",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"throw",
"new",
"LogicException",
"(",
"'Uncaught exception: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Lookup an address by postcode and house number.
@param string $postcode
@param string $number
@return \DevMob\Postcodes\Address\Address[]
@throws \DevMob\Postcodes\Exceptions\NoSuchCombinationException
@throws \DevMob\Postcodes\Exceptions\PostcodesException | [
"Lookup",
"an",
"address",
"by",
"postcode",
"and",
"house",
"number",
"."
] | train | https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Providers/HttpProvider.php#L58-L90 |
nguyenanhung/td-send-sms | src/SendSMS/SendSmsCallback.php | SendSmsCallback.setSdkConfig | public function setSdkConfig($sdkConfig = array())
{
$this->sdkConfig = $sdkConfig;
$this->debug->debug(__FUNCTION__, 'SDK Config => ' . json_encode($this->sdkConfig));
return $this;
} | php | public function setSdkConfig($sdkConfig = array())
{
$this->sdkConfig = $sdkConfig;
$this->debug->debug(__FUNCTION__, 'SDK Config => ' . json_encode($this->sdkConfig));
return $this;
} | [
"public",
"function",
"setSdkConfig",
"(",
"$",
"sdkConfig",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"sdkConfig",
"=",
"$",
"sdkConfig",
";",
"$",
"this",
"->",
"debug",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SDK Config => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sdkConfig",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function setSdkConfig
@author: 713uk13m <[email protected]>
@time : 11/21/18 10:24
@param array $sdkConfig
@return $this | [
"Function",
"setSdkConfig"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSmsCallback.php#L93-L99 |
nguyenanhung/td-send-sms | src/SendSMS/SendSmsCallback.php | SendSmsCallback.initializeCallback | public function initializeCallback($callbackCode = '', $statusCode = '')
{
$callback = $this->getConfigData();
if (!empty($callbackCode)) {
$decodeData = base64_decode(trim($callbackCode));
$initData = explode(self::NOTE_PREFIX, $decodeData);
if (is_array($initData) && count($initData) >= 2) {
/**
* Phân tích dữ liệu,
* chia thành nhiều mảng callback với những kiểu dữ liệu khác nhau
*/
$listId = array(self::SEND_SMS_ID, self::FORWARD_SMS_ID, self::DAILY_SMS_ID, self::PUSH_SMS_ID);
$json = in_array($initData[0], $listId) ? json_decode(trim($initData[1])) : NULL;
if ($json !== NULL) {
switch ($initData[0]) {
case self::SEND_SMS_ID:
$msgLog = sprintf($callback[self::SEND_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->msg) ? $json->msg : NULL, $statusCode);
break;
case self::FORWARD_SMS_ID:
$msgLog = sprintf($callback[self::FORWARD_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->msg) ? $json->msg : NULL, $statusCode);
break;
case self::DAILY_SMS_ID:
$msgLog = sprintf($callback[self::FORWARD_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->serviceId) ? $json->serviceId : NULL, isset($json->packageId) ? $json->packageId : NULL, isset($json->msg) ? $json->msg : NULL, $statusCode);
break;
case self::PUSH_SMS_ID:
$msgLog = sprintf($callback[self::FORWARD_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->serviceId) ? $json->serviceId : NULL, isset($json->optionId) ? $json->optionId : NULL, $statusCode);
break;
default:
$msgLog = 'Missing Callback with statusCode: ' . $statusCode;
}
$this->debug->info('callbackMsg', $msgLog);
return self::EXIT_SUCCESS;
}
}
}
return self::EXIT_ERROR;
} | php | public function initializeCallback($callbackCode = '', $statusCode = '')
{
$callback = $this->getConfigData();
if (!empty($callbackCode)) {
$decodeData = base64_decode(trim($callbackCode));
$initData = explode(self::NOTE_PREFIX, $decodeData);
if (is_array($initData) && count($initData) >= 2) {
/**
* Phân tích dữ liệu,
* chia thành nhiều mảng callback với những kiểu dữ liệu khác nhau
*/
$listId = array(self::SEND_SMS_ID, self::FORWARD_SMS_ID, self::DAILY_SMS_ID, self::PUSH_SMS_ID);
$json = in_array($initData[0], $listId) ? json_decode(trim($initData[1])) : NULL;
if ($json !== NULL) {
switch ($initData[0]) {
case self::SEND_SMS_ID:
$msgLog = sprintf($callback[self::SEND_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->msg) ? $json->msg : NULL, $statusCode);
break;
case self::FORWARD_SMS_ID:
$msgLog = sprintf($callback[self::FORWARD_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->msg) ? $json->msg : NULL, $statusCode);
break;
case self::DAILY_SMS_ID:
$msgLog = sprintf($callback[self::FORWARD_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->serviceId) ? $json->serviceId : NULL, isset($json->packageId) ? $json->packageId : NULL, isset($json->msg) ? $json->msg : NULL, $statusCode);
break;
case self::PUSH_SMS_ID:
$msgLog = sprintf($callback[self::FORWARD_SMS_ID], isset($json->time) ? $json->time : NULL, isset($json->shortcode) ? $json->shortcode : NULL, isset($json->msisdn) ? $json->msisdn : NULL, isset($json->serviceId) ? $json->serviceId : NULL, isset($json->optionId) ? $json->optionId : NULL, $statusCode);
break;
default:
$msgLog = 'Missing Callback with statusCode: ' . $statusCode;
}
$this->debug->info('callbackMsg', $msgLog);
return self::EXIT_SUCCESS;
}
}
}
return self::EXIT_ERROR;
} | [
"public",
"function",
"initializeCallback",
"(",
"$",
"callbackCode",
"=",
"''",
",",
"$",
"statusCode",
"=",
"''",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"getConfigData",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"callbackCode",
")",
")",
"{",
"$",
"decodeData",
"=",
"base64_decode",
"(",
"trim",
"(",
"$",
"callbackCode",
")",
")",
";",
"$",
"initData",
"=",
"explode",
"(",
"self",
"::",
"NOTE_PREFIX",
",",
"$",
"decodeData",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"initData",
")",
"&&",
"count",
"(",
"$",
"initData",
")",
">=",
"2",
")",
"{",
"/**\n * Phân tích dữ liệu,\n * chia thành nhiều mảng callback với những kiểu dữ liệu khác nhau\n */",
"$",
"listId",
"=",
"array",
"(",
"self",
"::",
"SEND_SMS_ID",
",",
"self",
"::",
"FORWARD_SMS_ID",
",",
"self",
"::",
"DAILY_SMS_ID",
",",
"self",
"::",
"PUSH_SMS_ID",
")",
";",
"$",
"json",
"=",
"in_array",
"(",
"$",
"initData",
"[",
"0",
"]",
",",
"$",
"listId",
")",
"?",
"json_decode",
"(",
"trim",
"(",
"$",
"initData",
"[",
"1",
"]",
")",
")",
":",
"NULL",
";",
"if",
"(",
"$",
"json",
"!==",
"NULL",
")",
"{",
"switch",
"(",
"$",
"initData",
"[",
"0",
"]",
")",
"{",
"case",
"self",
"::",
"SEND_SMS_ID",
":",
"$",
"msgLog",
"=",
"sprintf",
"(",
"$",
"callback",
"[",
"self",
"::",
"SEND_SMS_ID",
"]",
",",
"isset",
"(",
"$",
"json",
"->",
"time",
")",
"?",
"$",
"json",
"->",
"time",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"shortcode",
")",
"?",
"$",
"json",
"->",
"shortcode",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"msisdn",
")",
"?",
"$",
"json",
"->",
"msisdn",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"msg",
")",
"?",
"$",
"json",
"->",
"msg",
":",
"NULL",
",",
"$",
"statusCode",
")",
";",
"break",
";",
"case",
"self",
"::",
"FORWARD_SMS_ID",
":",
"$",
"msgLog",
"=",
"sprintf",
"(",
"$",
"callback",
"[",
"self",
"::",
"FORWARD_SMS_ID",
"]",
",",
"isset",
"(",
"$",
"json",
"->",
"time",
")",
"?",
"$",
"json",
"->",
"time",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"shortcode",
")",
"?",
"$",
"json",
"->",
"shortcode",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"msisdn",
")",
"?",
"$",
"json",
"->",
"msisdn",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"msg",
")",
"?",
"$",
"json",
"->",
"msg",
":",
"NULL",
",",
"$",
"statusCode",
")",
";",
"break",
";",
"case",
"self",
"::",
"DAILY_SMS_ID",
":",
"$",
"msgLog",
"=",
"sprintf",
"(",
"$",
"callback",
"[",
"self",
"::",
"FORWARD_SMS_ID",
"]",
",",
"isset",
"(",
"$",
"json",
"->",
"time",
")",
"?",
"$",
"json",
"->",
"time",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"shortcode",
")",
"?",
"$",
"json",
"->",
"shortcode",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"msisdn",
")",
"?",
"$",
"json",
"->",
"msisdn",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"serviceId",
")",
"?",
"$",
"json",
"->",
"serviceId",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"packageId",
")",
"?",
"$",
"json",
"->",
"packageId",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"msg",
")",
"?",
"$",
"json",
"->",
"msg",
":",
"NULL",
",",
"$",
"statusCode",
")",
";",
"break",
";",
"case",
"self",
"::",
"PUSH_SMS_ID",
":",
"$",
"msgLog",
"=",
"sprintf",
"(",
"$",
"callback",
"[",
"self",
"::",
"FORWARD_SMS_ID",
"]",
",",
"isset",
"(",
"$",
"json",
"->",
"time",
")",
"?",
"$",
"json",
"->",
"time",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"shortcode",
")",
"?",
"$",
"json",
"->",
"shortcode",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"msisdn",
")",
"?",
"$",
"json",
"->",
"msisdn",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"serviceId",
")",
"?",
"$",
"json",
"->",
"serviceId",
":",
"NULL",
",",
"isset",
"(",
"$",
"json",
"->",
"optionId",
")",
"?",
"$",
"json",
"->",
"optionId",
":",
"NULL",
",",
"$",
"statusCode",
")",
";",
"break",
";",
"default",
":",
"$",
"msgLog",
"=",
"'Missing Callback with statusCode: '",
".",
"$",
"statusCode",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"info",
"(",
"'callbackMsg'",
",",
"$",
"msgLog",
")",
";",
"return",
"self",
"::",
"EXIT_SUCCESS",
";",
"}",
"}",
"}",
"return",
"self",
"::",
"EXIT_ERROR",
";",
"}"
] | Function initializeCallback
@author: 713uk13m <[email protected]>
@time : 11/21/18 23:16
@param string $callbackCode
@param string $statusCode
@return int | [
"Function",
"initializeCallback"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSmsCallback.php#L142-L180 |
webforge-labs/psc-cms | lib/Psc/Data/FileCache.php | FileCache.load | public function load($key, &$loaded) {
$file = $this->getFile($this->getKey($key));
if ($this->validate($file)) {
$loaded = TRUE;
return $this->direct ? $file : $file->getContents();
}
$loaded = FALSE;
} | php | public function load($key, &$loaded) {
$file = $this->getFile($this->getKey($key));
if ($this->validate($file)) {
$loaded = TRUE;
return $this->direct ? $file : $file->getContents();
}
$loaded = FALSE;
} | [
"public",
"function",
"load",
"(",
"$",
"key",
",",
"&",
"$",
"loaded",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
"$",
"file",
")",
")",
"{",
"$",
"loaded",
"=",
"TRUE",
";",
"return",
"$",
"this",
"->",
"direct",
"?",
"$",
"file",
":",
"$",
"file",
"->",
"getContents",
"(",
")",
";",
"}",
"$",
"loaded",
"=",
"FALSE",
";",
"}"
] | Gibt den Inhalt der Datei (direct = FALSE) oder die Datei zurück (direct = TRUE)
@return string (binärdaten aus der Datei) | [
"Gibt",
"den",
"Inhalt",
"der",
"Datei",
"(",
"direct",
"=",
"FALSE",
")",
"oder",
"die",
"Datei",
"zurück",
"(",
"direct",
"=",
"TRUE",
")"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Data/FileCache.php#L74-L82 |
webforge-labs/psc-cms | lib/Psc/Data/FileCache.php | FileCache.remove | public function remove($key) {
$file = $this->getFile($this->getKey($key));
$file->delete();
return $this;
} | php | public function remove($key) {
$file = $this->getFile($this->getKey($key));
$file->delete();
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
")",
")",
";",
"$",
"file",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Entfernt die Dateia us dem Cache
@chainable | [
"Entfernt",
"die",
"Dateia",
"us",
"dem",
"Cache"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Data/FileCache.php#L96-L100 |
jfusion/org.jfusion.framework | src/Installer/Framework.php | Framework.update | public static function update()
{
$results = array();
$db = Factory::getDBO();
/***
* UPGRADES FOR 1.1.0 Patch 2
***/
//see if the columns exists
$query = 'SHOW COLUMNS FROM #__jfusion';
$db->setQuery($query);
$columns = $db->loadColumn();
/**
* for 2.0
*/
$query = 'ALTER TABLE #__jfusion_sync_details CHANGE `message` `message` TEXT';
$db->setQuery($query);
$db->execute();
$query = 'SHOW COLUMNS FROM #__jfusion';
$db->setQuery($query);
$columns = $db->loadColumn();
//remove the plugin_files if it exists
if (in_array('plugin_files', $columns)) {
//remove the column
$query = 'ALTER TABLE #__jfusion DROP column plugin_files';
$db->setQuery($query);
$db->execute();
}
// let's update to json
$query = $db->getQuery(true)
->select('params, id')
->from('#__jfusion');
$db->setQuery($query);
$rows = $db->loadObjectList();
if(!empty($rows)) {
foreach ($rows as $row) {
if ($row->params) {
$params = base64_decode($row->params);
if (strpos($params, 'a:') === 0) {
ob_start();
$params = unserialize($params);
ob_end_clean();
if (is_array($params)) {
$params = new Registry($params);
$row->params = $params->toString();
$db->updateObject('#__jfusion', $row, 'id');
}
}
}
}
}
/**
* 3.0
*/
//remove the plugin_files if it exists
if (in_array('master', $columns)) {
//remove master
$query = 'ALTER TABLE #__jfusion DROP column master';
$db->setQuery($query);
$db->execute();
//remove slave
$query = 'ALTER TABLE #__jfusion DROP column slave';
$db->setQuery($query);
$db->execute();
//remove search
$query = 'ALTER TABLE #__jfusion DROP column search';
$db->setQuery($query);
$db->execute();
//remove discussion
$query = 'ALTER TABLE #__jfusion DROP column discussion';
$db->setQuery($query);
$db->execute();
}
//add a active column for user sync
$query = 'SHOW COLUMNS FROM #__jfusion_sync';
$db->setQuery($query);
$columns = $db->loadColumn();
if (!in_array('type', $columns)) {
$query = 'ALTER TABLE #__jfusion_sync
ADD COLUMN `type` VARCHAR(50) DEFAULT NULL';
$db->setQuery($query);
$db->execute();
}
//cleanup unused plugins
$query = $db->getQuery(true)
->select('name')
->from('#__jfusion')
->where('(params IS NULL OR params = ' . $db->quote('') . ' OR params = ' . $db->quote('0') . ')')
->where('status = 0');
$db->setQuery($query);
$rows = $db->loadObjectList();
if(!empty($rows)) {
foreach ($rows as $row) {
$query = $db->getQuery(true)
->select('count(*)')
->from('#__jfusion')
->where('original_name LIKE ' . $db->quote($row->name));
$db->setQuery($query);
$copys = $db->loadResult();
if (!$copys) {
$model = new Plugin();
$model->uninstall($row->name);
}
}
}
return true;
} | php | public static function update()
{
$results = array();
$db = Factory::getDBO();
/***
* UPGRADES FOR 1.1.0 Patch 2
***/
//see if the columns exists
$query = 'SHOW COLUMNS FROM #__jfusion';
$db->setQuery($query);
$columns = $db->loadColumn();
/**
* for 2.0
*/
$query = 'ALTER TABLE #__jfusion_sync_details CHANGE `message` `message` TEXT';
$db->setQuery($query);
$db->execute();
$query = 'SHOW COLUMNS FROM #__jfusion';
$db->setQuery($query);
$columns = $db->loadColumn();
//remove the plugin_files if it exists
if (in_array('plugin_files', $columns)) {
//remove the column
$query = 'ALTER TABLE #__jfusion DROP column plugin_files';
$db->setQuery($query);
$db->execute();
}
// let's update to json
$query = $db->getQuery(true)
->select('params, id')
->from('#__jfusion');
$db->setQuery($query);
$rows = $db->loadObjectList();
if(!empty($rows)) {
foreach ($rows as $row) {
if ($row->params) {
$params = base64_decode($row->params);
if (strpos($params, 'a:') === 0) {
ob_start();
$params = unserialize($params);
ob_end_clean();
if (is_array($params)) {
$params = new Registry($params);
$row->params = $params->toString();
$db->updateObject('#__jfusion', $row, 'id');
}
}
}
}
}
/**
* 3.0
*/
//remove the plugin_files if it exists
if (in_array('master', $columns)) {
//remove master
$query = 'ALTER TABLE #__jfusion DROP column master';
$db->setQuery($query);
$db->execute();
//remove slave
$query = 'ALTER TABLE #__jfusion DROP column slave';
$db->setQuery($query);
$db->execute();
//remove search
$query = 'ALTER TABLE #__jfusion DROP column search';
$db->setQuery($query);
$db->execute();
//remove discussion
$query = 'ALTER TABLE #__jfusion DROP column discussion';
$db->setQuery($query);
$db->execute();
}
//add a active column for user sync
$query = 'SHOW COLUMNS FROM #__jfusion_sync';
$db->setQuery($query);
$columns = $db->loadColumn();
if (!in_array('type', $columns)) {
$query = 'ALTER TABLE #__jfusion_sync
ADD COLUMN `type` VARCHAR(50) DEFAULT NULL';
$db->setQuery($query);
$db->execute();
}
//cleanup unused plugins
$query = $db->getQuery(true)
->select('name')
->from('#__jfusion')
->where('(params IS NULL OR params = ' . $db->quote('') . ' OR params = ' . $db->quote('0') . ')')
->where('status = 0');
$db->setQuery($query);
$rows = $db->loadObjectList();
if(!empty($rows)) {
foreach ($rows as $row) {
$query = $db->getQuery(true)
->select('count(*)')
->from('#__jfusion')
->where('original_name LIKE ' . $db->quote($row->name));
$db->setQuery($query);
$copys = $db->loadResult();
if (!$copys) {
$model = new Plugin();
$model->uninstall($row->name);
}
}
}
return true;
} | [
"public",
"static",
"function",
"update",
"(",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"/***\n\t\t * UPGRADES FOR 1.1.0 Patch 2\n\t\t ***/",
"//see if the columns exists",
"$",
"query",
"=",
"'SHOW COLUMNS FROM #__jfusion'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"columns",
"=",
"$",
"db",
"->",
"loadColumn",
"(",
")",
";",
"/**\n\t\t * for 2.0\n\t\t */",
"$",
"query",
"=",
"'ALTER TABLE #__jfusion_sync_details CHANGE `message` `message` TEXT'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"=",
"'SHOW COLUMNS FROM #__jfusion'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"columns",
"=",
"$",
"db",
"->",
"loadColumn",
"(",
")",
";",
"//remove the plugin_files if it exists",
"if",
"(",
"in_array",
"(",
"'plugin_files'",
",",
"$",
"columns",
")",
")",
"{",
"//remove the column",
"$",
"query",
"=",
"'ALTER TABLE #__jfusion DROP column plugin_files'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}",
"// let's update to json",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'params, id'",
")",
"->",
"from",
"(",
"'#__jfusion'",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"rows",
"=",
"$",
"db",
"->",
"loadObjectList",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"rows",
")",
")",
"{",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"->",
"params",
")",
"{",
"$",
"params",
"=",
"base64_decode",
"(",
"$",
"row",
"->",
"params",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"params",
",",
"'a:'",
")",
"===",
"0",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"params",
"=",
"unserialize",
"(",
"$",
"params",
")",
";",
"ob_end_clean",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"new",
"Registry",
"(",
"$",
"params",
")",
";",
"$",
"row",
"->",
"params",
"=",
"$",
"params",
"->",
"toString",
"(",
")",
";",
"$",
"db",
"->",
"updateObject",
"(",
"'#__jfusion'",
",",
"$",
"row",
",",
"'id'",
")",
";",
"}",
"}",
"}",
"}",
"}",
"/**\n\t\t * 3.0\n\t\t */",
"//remove the plugin_files if it exists",
"if",
"(",
"in_array",
"(",
"'master'",
",",
"$",
"columns",
")",
")",
"{",
"//remove master",
"$",
"query",
"=",
"'ALTER TABLE #__jfusion DROP column master'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"//remove slave",
"$",
"query",
"=",
"'ALTER TABLE #__jfusion DROP column slave'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"//remove search",
"$",
"query",
"=",
"'ALTER TABLE #__jfusion DROP column search'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"//remove discussion",
"$",
"query",
"=",
"'ALTER TABLE #__jfusion DROP column discussion'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}",
"//add a active column for user sync",
"$",
"query",
"=",
"'SHOW COLUMNS FROM #__jfusion_sync'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"columns",
"=",
"$",
"db",
"->",
"loadColumn",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"'type'",
",",
"$",
"columns",
")",
")",
"{",
"$",
"query",
"=",
"'ALTER TABLE #__jfusion_sync\n\t\t\t\t\tADD COLUMN `type` VARCHAR(50) DEFAULT NULL'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}",
"//cleanup unused plugins",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'name'",
")",
"->",
"from",
"(",
"'#__jfusion'",
")",
"->",
"where",
"(",
"'(params IS NULL OR params = '",
".",
"$",
"db",
"->",
"quote",
"(",
"''",
")",
".",
"' OR params = '",
".",
"$",
"db",
"->",
"quote",
"(",
"'0'",
")",
".",
"')'",
")",
"->",
"where",
"(",
"'status = 0'",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"rows",
"=",
"$",
"db",
"->",
"loadObjectList",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"rows",
")",
")",
"{",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'count(*)'",
")",
"->",
"from",
"(",
"'#__jfusion'",
")",
"->",
"where",
"(",
"'original_name LIKE '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"row",
"->",
"name",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"copys",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"if",
"(",
"!",
"$",
"copys",
")",
"{",
"$",
"model",
"=",
"new",
"Plugin",
"(",
")",
";",
"$",
"model",
"->",
"uninstall",
"(",
"$",
"row",
"->",
"name",
")",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | method to update the component
@return boolean | [
"method",
"to",
"update",
"the",
"component"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Framework.php#L102-L219 |
jfusion/org.jfusion.framework | src/Installer/Framework.php | Framework.uninstall | public static function uninstall()
{
$results = array();
//see if any mods from jfusion plugins need to be removed
$plugins = Factory::getPlugins('all', false, 0);
foreach($plugins as $plugin) {
$model = new Plugin();
$result = $model->uninstall($plugin->name);
$r = new stdClass();
$result['status'] = 1;
$r->status = $result['status'];
if (!$r->status) {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('FAILED');
} else {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('SUCCESS');
}
$results[] = $r;
}
//remove the jfusion tables.
$db = Factory::getDBO();
$query = 'DROP TABLE IF EXISTS #__jfusion';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync_details';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_users';
$db->setQuery($query);
$db->execute();
return $results;
} | php | public static function uninstall()
{
$results = array();
//see if any mods from jfusion plugins need to be removed
$plugins = Factory::getPlugins('all', false, 0);
foreach($plugins as $plugin) {
$model = new Plugin();
$result = $model->uninstall($plugin->name);
$r = new stdClass();
$result['status'] = 1;
$r->status = $result['status'];
if (!$r->status) {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('FAILED');
} else {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('SUCCESS');
}
$results[] = $r;
}
//remove the jfusion tables.
$db = Factory::getDBO();
$query = 'DROP TABLE IF EXISTS #__jfusion';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync_details';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_users';
$db->setQuery($query);
$db->execute();
return $results;
} | [
"public",
"static",
"function",
"uninstall",
"(",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"//see if any mods from jfusion plugins need to be removed",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
"'all'",
",",
"false",
",",
"0",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"model",
"=",
"new",
"Plugin",
"(",
")",
";",
"$",
"result",
"=",
"$",
"model",
"->",
"uninstall",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"r",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"1",
";",
"$",
"r",
"->",
"status",
"=",
"$",
"result",
"[",
"'status'",
"]",
";",
"if",
"(",
"!",
"$",
"r",
"->",
"status",
")",
"{",
"$",
"r",
"->",
"message",
"=",
"Text",
"::",
"_",
"(",
"'UNINSTALL'",
")",
".",
"' '",
".",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'FAILED'",
")",
";",
"}",
"else",
"{",
"$",
"r",
"->",
"message",
"=",
"Text",
"::",
"_",
"(",
"'UNINSTALL'",
")",
".",
"' '",
".",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'SUCCESS'",
")",
";",
"}",
"$",
"results",
"[",
"]",
"=",
"$",
"r",
";",
"}",
"//remove the jfusion tables.",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion_sync'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion_sync_details'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion_users'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"results",
";",
"}"
] | method to uninstall the component
@return stdClass[] with status/message field for plugin uninstall info | [
"method",
"to",
"uninstall",
"the",
"component"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Framework.php#L226-L267 |
yuncms/framework | src/admin/widgets/Box.php | Box.renderHeader | protected function renderHeader()
{
$tools = $this->renderTools();
if ($this->header !== null) {
$header = Html::tag('h5', "\n" . $this->header . "\n", $this->headerOptions) . "\n" . ($tools !== null ? $tools : '');
return Html::tag('div', $header, ['class' => 'ibox-title']);
} else {
return null;
}
} | php | protected function renderHeader()
{
$tools = $this->renderTools();
if ($this->header !== null) {
$header = Html::tag('h5', "\n" . $this->header . "\n", $this->headerOptions) . "\n" . ($tools !== null ? $tools : '');
return Html::tag('div', $header, ['class' => 'ibox-title']);
} else {
return null;
}
} | [
"protected",
"function",
"renderHeader",
"(",
")",
"{",
"$",
"tools",
"=",
"$",
"this",
"->",
"renderTools",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"header",
"!==",
"null",
")",
"{",
"$",
"header",
"=",
"Html",
"::",
"tag",
"(",
"'h5'",
",",
"\"\\n\"",
".",
"$",
"this",
"->",
"header",
".",
"\"\\n\"",
",",
"$",
"this",
"->",
"headerOptions",
")",
".",
"\"\\n\"",
".",
"(",
"$",
"tools",
"!==",
"null",
"?",
"$",
"tools",
":",
"''",
")",
";",
"return",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"$",
"header",
",",
"[",
"'class'",
"=>",
"'ibox-title'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | 渲染盒子外框头部
@return string the rendering result | [
"渲染盒子外框头部"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/widgets/Box.php#L101-L110 |
yuncms/framework | src/admin/widgets/Box.php | Box.renderTools | protected function renderTools()
{
$tools = '';
if($this->collapseButton !== false){
$tools .= '<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>';
}
if ($this->closeButton !== false) {
$tools .= '<a class="close-link"><i class="fa fa-times"></i></a>';
}
if (!empty($tools)) {
return Html::tag('div', $tools, ['class' => 'ibox-tools']);
} else {
return null;
}
} | php | protected function renderTools()
{
$tools = '';
if($this->collapseButton !== false){
$tools .= '<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>';
}
if ($this->closeButton !== false) {
$tools .= '<a class="close-link"><i class="fa fa-times"></i></a>';
}
if (!empty($tools)) {
return Html::tag('div', $tools, ['class' => 'ibox-tools']);
} else {
return null;
}
} | [
"protected",
"function",
"renderTools",
"(",
")",
"{",
"$",
"tools",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"collapseButton",
"!==",
"false",
")",
"{",
"$",
"tools",
".=",
"'<a class=\"collapse-link\"><i class=\"fa fa-chevron-up\"></i></a>'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"closeButton",
"!==",
"false",
")",
"{",
"$",
"tools",
".=",
"'<a class=\"close-link\"><i class=\"fa fa-times\"></i></a>'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"tools",
")",
")",
"{",
"return",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"$",
"tools",
",",
"[",
"'class'",
"=>",
"'ibox-tools'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Renders the tools
@return string the rendering result | [
"Renders",
"the",
"tools"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/widgets/Box.php#L148-L162 |
yuncms/framework | src/admin/widgets/Box.php | Box.initOptions | protected function initOptions()
{
$this->options = array_merge([
'class' => 'ibox float-e-margins',
'tabindex' => -1,
], $this->options);
Html::addCssClass($this->bodyOptions, 'ibox-content');
} | php | protected function initOptions()
{
$this->options = array_merge([
'class' => 'ibox float-e-margins',
'tabindex' => -1,
], $this->options);
Html::addCssClass($this->bodyOptions, 'ibox-content');
} | [
"protected",
"function",
"initOptions",
"(",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"(",
"[",
"'class'",
"=>",
"'ibox float-e-margins'",
",",
"'tabindex'",
"=>",
"-",
"1",
",",
"]",
",",
"$",
"this",
"->",
"options",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"bodyOptions",
",",
"'ibox-content'",
")",
";",
"}"
] | Initializes the widget options.
This method sets the default values for various options. | [
"Initializes",
"the",
"widget",
"options",
".",
"This",
"method",
"sets",
"the",
"default",
"values",
"for",
"various",
"options",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/widgets/Box.php#L178-L187 |
jfusion/org.jfusion.framework | src/User/User.php | User.login | public function login(Userinfo $userinfo, $options = array())
{
$success = 0;
$this->debugger->set(null, array());
$this->debugger->set('init', array());
try {
Factory::getStatus()->set('active.jfusion', true);
//php 5.3 does not allow plugins to contain pass by references
//use a global for the login checker instead
if (!isset($options['skipplugin'])) {
$options['skipplugin'] = array();
}
if (!isset($options['overwrite'])) {
$options['overwrite'] = 0;
}
if (!isset($options['mask'])) {
$options['mask'] = true;
}
if (Factory::getStatus()->get('active.plugin')) {
$options['skipplugin'][] = Factory::getStatus()->get('active.plugin');
}
//allow for the detection of external mods to exclude jfusion plugins
if (isset($options['nodeid']) && !empty($options['nodeid'])) {
Factory::getStatus()->set('active.plugin', $options['nodeid']);
$options['skipplugin'][] = $options['nodeid'];
}
$authUserinfo = User::search($userinfo, true);
if ($authUserinfo instanceof Userinfo) {
$authUserinfo->password_clear = $userinfo->password_clear;
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
if (!in_array($plugin->name, $options['skipplugin'])) {
$userPlugin = Factory::getUser($plugin->name);
$autoregister = $userPlugin->params->get('autoregister', 0);
try {
$userinfo = $userPlugin->getUser($authUserinfo);
} catch (Exception $e) {
$userinfo = null;
}
if (!$userinfo instanceof Userinfo) {
if ($autoregister == 1) {
try {
$this->debugger->add('init', $plugin->name . ' ' .Text::_('CREATING_USER'));
//try to create a Master user
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($authUserinfo)) {
$userinfo = $userPlugin->doCreateUser($authUserinfo);
$this->debugger->add('init', Text::_('MASTER') . ' ' . Text::_('USER') . ' ' . Text::_('CREATE') . ' ' . Text::_('SUCCESS'));
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, Text::_('USER') . ' ' . Text::_('CREATE') . ' ' . Text::_('ERROR') . ' ' . $e->getMessage(), $plugin->name);
$this->debugger->add($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('CREATE') . ' ' . Text::_('ERROR'), $e->getMessage());
}
}
} else {
try {
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($userinfo)) {
$userinfo = $userPlugin->updateUser($authUserinfo, $options['overwrite']);
$debug = $userPlugin->debugger->get();
if (!$userinfo instanceof UserInfo) {
//make sure the userinfo is available
$userinfo = $userPlugin->getUser($authUserinfo);
}
if (!empty($debug[LogLevel::ERROR])) {
$this->debugger->set($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE') . ' ' . Text::_('ERROR'), $debug[LogLevel::ERROR]);
}
if (!empty($debug[LogLevel::DEBUG])) {
$this->debugger->set($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE') . ' ' . Text::_('DEBUG'), $debug[LogLevel::DEBUG]);
}
if ($userinfo instanceof UserInfo) {
if ($options['mask']) {
$details = $userinfo->getAnonymizeed();
} else {
$details = $userinfo->toObject();
}
} else {
$details = null;
}
$this->debugger->set($plugin->name . ' ' . Text::_('USERINFO'), $details);
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e, $plugin->name);
$this->debugger->add($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE') . ' ' . Text::_('ERROR'), $e->getMessage());
}
}
}
}
if ($authUserinfo->canLogin()) {
foreach ($plugins as $plugin) {
if (!in_array($plugin->name, $options['skipplugin']) && $plugin->dual_login == 1) {
$userPlugin = Factory::getUser($plugin->name);
try {
$userinfo = $userPlugin->getUser($authUserinfo);
} catch (Exception $e) {
$userinfo = null;
}
if ($userinfo instanceof UserInfo) {
$userinfo->password_clear = $authUserinfo->password_clear;
try {
$session = $userPlugin->createSession($userinfo, $options);
if (!empty($session[LogLevel::ERROR])) {
$this->debugger->set($plugin->name . ' ' . Text::_('SESSION') . ' ' . Text::_('ERROR'), $session[LogLevel::ERROR]);
Framework::raise(LogLevel::ERROR, $session[LogLevel::ERROR], $plugin->name . ': ' . Text::_('SESSION') . ' ' . Text::_('CREATE'));
}
if (!empty($session[LogLevel::DEBUG])) {
$this->debugger->set($plugin->name . ' ' . Text::_('SESSION') . ' ' . Text::_('DEBUG'), $session[LogLevel::DEBUG]);
//report the error back
}
$success = 1;
} catch (Exception $e) {
$this->debugger->set($plugin->name . ' ' . Text::_('SESSION') . ' ' . Text::_('ERROR'), $e->getMessage());
Framework::raise(LogLevel::ERROR, $e, $plugin->name . ': ' . Text::_('SESSION') . ' ' . Text::_('CREATE'));
}
}
}
}
} else if ($authUserinfo->block) {
throw new RuntimeException(Text::_('FUSION_BLOCKED_USER'));
} else {
throw new RuntimeException(Text::_('FUSION_INACTIVE_USER'));
}
} else {
//return an error
$this->debugger->add('init', Text::_('COULD_NOT_FIND_USER'));
throw new RuntimeException(Text::_('COULD_NOT_FIND_USER'));
}
} catch (Exception $e) {
$success = 0;
Framework::raise(LogLevel::ERROR, $e);
$this->debugger->addError($e->getMessage());
}
return ($success === 1);
} | php | public function login(Userinfo $userinfo, $options = array())
{
$success = 0;
$this->debugger->set(null, array());
$this->debugger->set('init', array());
try {
Factory::getStatus()->set('active.jfusion', true);
//php 5.3 does not allow plugins to contain pass by references
//use a global for the login checker instead
if (!isset($options['skipplugin'])) {
$options['skipplugin'] = array();
}
if (!isset($options['overwrite'])) {
$options['overwrite'] = 0;
}
if (!isset($options['mask'])) {
$options['mask'] = true;
}
if (Factory::getStatus()->get('active.plugin')) {
$options['skipplugin'][] = Factory::getStatus()->get('active.plugin');
}
//allow for the detection of external mods to exclude jfusion plugins
if (isset($options['nodeid']) && !empty($options['nodeid'])) {
Factory::getStatus()->set('active.plugin', $options['nodeid']);
$options['skipplugin'][] = $options['nodeid'];
}
$authUserinfo = User::search($userinfo, true);
if ($authUserinfo instanceof Userinfo) {
$authUserinfo->password_clear = $userinfo->password_clear;
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
if (!in_array($plugin->name, $options['skipplugin'])) {
$userPlugin = Factory::getUser($plugin->name);
$autoregister = $userPlugin->params->get('autoregister', 0);
try {
$userinfo = $userPlugin->getUser($authUserinfo);
} catch (Exception $e) {
$userinfo = null;
}
if (!$userinfo instanceof Userinfo) {
if ($autoregister == 1) {
try {
$this->debugger->add('init', $plugin->name . ' ' .Text::_('CREATING_USER'));
//try to create a Master user
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($authUserinfo)) {
$userinfo = $userPlugin->doCreateUser($authUserinfo);
$this->debugger->add('init', Text::_('MASTER') . ' ' . Text::_('USER') . ' ' . Text::_('CREATE') . ' ' . Text::_('SUCCESS'));
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, Text::_('USER') . ' ' . Text::_('CREATE') . ' ' . Text::_('ERROR') . ' ' . $e->getMessage(), $plugin->name);
$this->debugger->add($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('CREATE') . ' ' . Text::_('ERROR'), $e->getMessage());
}
}
} else {
try {
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($userinfo)) {
$userinfo = $userPlugin->updateUser($authUserinfo, $options['overwrite']);
$debug = $userPlugin->debugger->get();
if (!$userinfo instanceof UserInfo) {
//make sure the userinfo is available
$userinfo = $userPlugin->getUser($authUserinfo);
}
if (!empty($debug[LogLevel::ERROR])) {
$this->debugger->set($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE') . ' ' . Text::_('ERROR'), $debug[LogLevel::ERROR]);
}
if (!empty($debug[LogLevel::DEBUG])) {
$this->debugger->set($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE') . ' ' . Text::_('DEBUG'), $debug[LogLevel::DEBUG]);
}
if ($userinfo instanceof UserInfo) {
if ($options['mask']) {
$details = $userinfo->getAnonymizeed();
} else {
$details = $userinfo->toObject();
}
} else {
$details = null;
}
$this->debugger->set($plugin->name . ' ' . Text::_('USERINFO'), $details);
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e, $plugin->name);
$this->debugger->add($plugin->name . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE') . ' ' . Text::_('ERROR'), $e->getMessage());
}
}
}
}
if ($authUserinfo->canLogin()) {
foreach ($plugins as $plugin) {
if (!in_array($plugin->name, $options['skipplugin']) && $plugin->dual_login == 1) {
$userPlugin = Factory::getUser($plugin->name);
try {
$userinfo = $userPlugin->getUser($authUserinfo);
} catch (Exception $e) {
$userinfo = null;
}
if ($userinfo instanceof UserInfo) {
$userinfo->password_clear = $authUserinfo->password_clear;
try {
$session = $userPlugin->createSession($userinfo, $options);
if (!empty($session[LogLevel::ERROR])) {
$this->debugger->set($plugin->name . ' ' . Text::_('SESSION') . ' ' . Text::_('ERROR'), $session[LogLevel::ERROR]);
Framework::raise(LogLevel::ERROR, $session[LogLevel::ERROR], $plugin->name . ': ' . Text::_('SESSION') . ' ' . Text::_('CREATE'));
}
if (!empty($session[LogLevel::DEBUG])) {
$this->debugger->set($plugin->name . ' ' . Text::_('SESSION') . ' ' . Text::_('DEBUG'), $session[LogLevel::DEBUG]);
//report the error back
}
$success = 1;
} catch (Exception $e) {
$this->debugger->set($plugin->name . ' ' . Text::_('SESSION') . ' ' . Text::_('ERROR'), $e->getMessage());
Framework::raise(LogLevel::ERROR, $e, $plugin->name . ': ' . Text::_('SESSION') . ' ' . Text::_('CREATE'));
}
}
}
}
} else if ($authUserinfo->block) {
throw new RuntimeException(Text::_('FUSION_BLOCKED_USER'));
} else {
throw new RuntimeException(Text::_('FUSION_INACTIVE_USER'));
}
} else {
//return an error
$this->debugger->add('init', Text::_('COULD_NOT_FIND_USER'));
throw new RuntimeException(Text::_('COULD_NOT_FIND_USER'));
}
} catch (Exception $e) {
$success = 0;
Framework::raise(LogLevel::ERROR, $e);
$this->debugger->addError($e->getMessage());
}
return ($success === 1);
} | [
"public",
"function",
"login",
"(",
"Userinfo",
"$",
"userinfo",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"success",
"=",
"0",
";",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"null",
",",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"'init'",
",",
"array",
"(",
")",
")",
";",
"try",
"{",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"set",
"(",
"'active.jfusion'",
",",
"true",
")",
";",
"//php 5.3 does not allow plugins to contain pass by references",
"//use a global for the login checker instead",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'skipplugin'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'skipplugin'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'overwrite'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'overwrite'",
"]",
"=",
"0",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'mask'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'mask'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"get",
"(",
"'active.plugin'",
")",
")",
"{",
"$",
"options",
"[",
"'skipplugin'",
"]",
"[",
"]",
"=",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"get",
"(",
"'active.plugin'",
")",
";",
"}",
"//allow for the detection of external mods to exclude jfusion plugins",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'nodeid'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"options",
"[",
"'nodeid'",
"]",
")",
")",
"{",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"set",
"(",
"'active.plugin'",
",",
"$",
"options",
"[",
"'nodeid'",
"]",
")",
";",
"$",
"options",
"[",
"'skipplugin'",
"]",
"[",
"]",
"=",
"$",
"options",
"[",
"'nodeid'",
"]",
";",
"}",
"$",
"authUserinfo",
"=",
"User",
"::",
"search",
"(",
"$",
"userinfo",
",",
"true",
")",
";",
"if",
"(",
"$",
"authUserinfo",
"instanceof",
"Userinfo",
")",
"{",
"$",
"authUserinfo",
"->",
"password_clear",
"=",
"$",
"userinfo",
"->",
"password_clear",
";",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"plugin",
"->",
"name",
",",
"$",
"options",
"[",
"'skipplugin'",
"]",
")",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"autoregister",
"=",
"$",
"userPlugin",
"->",
"params",
"->",
"get",
"(",
"'autoregister'",
",",
"0",
")",
";",
"try",
"{",
"$",
"userinfo",
"=",
"$",
"userPlugin",
"->",
"getUser",
"(",
"$",
"authUserinfo",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"userinfo",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"userinfo",
"instanceof",
"Userinfo",
")",
"{",
"if",
"(",
"$",
"autoregister",
"==",
"1",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"debugger",
"->",
"add",
"(",
"'init'",
",",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'CREATING_USER'",
")",
")",
";",
"//try to create a Master user",
"$",
"userPlugin",
"->",
"resetDebugger",
"(",
")",
";",
"if",
"(",
"$",
"userPlugin",
"->",
"validateUser",
"(",
"$",
"authUserinfo",
")",
")",
"{",
"$",
"userinfo",
"=",
"$",
"userPlugin",
"->",
"doCreateUser",
"(",
"$",
"authUserinfo",
")",
";",
"$",
"this",
"->",
"debugger",
"->",
"add",
"(",
"'init'",
",",
"Text",
"::",
"_",
"(",
"'MASTER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'CREATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'SUCCESS'",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'CREATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
".",
"' '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"this",
"->",
"debugger",
"->",
"add",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'CREATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"try",
"{",
"$",
"userPlugin",
"->",
"resetDebugger",
"(",
")",
";",
"if",
"(",
"$",
"userPlugin",
"->",
"validateUser",
"(",
"$",
"userinfo",
")",
")",
"{",
"$",
"userinfo",
"=",
"$",
"userPlugin",
"->",
"updateUser",
"(",
"$",
"authUserinfo",
",",
"$",
"options",
"[",
"'overwrite'",
"]",
")",
";",
"$",
"debug",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"$",
"userinfo",
"instanceof",
"UserInfo",
")",
"{",
"//make sure the userinfo is available",
"$",
"userinfo",
"=",
"$",
"userPlugin",
"->",
"getUser",
"(",
"$",
"authUserinfo",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"debug",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
",",
"$",
"debug",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"debug",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'DEBUG'",
")",
",",
"$",
"debug",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
";",
"}",
"if",
"(",
"$",
"userinfo",
"instanceof",
"UserInfo",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'mask'",
"]",
")",
"{",
"$",
"details",
"=",
"$",
"userinfo",
"->",
"getAnonymizeed",
"(",
")",
";",
"}",
"else",
"{",
"$",
"details",
"=",
"$",
"userinfo",
"->",
"toObject",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"details",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USERINFO'",
")",
",",
"$",
"details",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
",",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"this",
"->",
"debugger",
"->",
"add",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"authUserinfo",
"->",
"canLogin",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"plugin",
"->",
"name",
",",
"$",
"options",
"[",
"'skipplugin'",
"]",
")",
"&&",
"$",
"plugin",
"->",
"dual_login",
"==",
"1",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"try",
"{",
"$",
"userinfo",
"=",
"$",
"userPlugin",
"->",
"getUser",
"(",
"$",
"authUserinfo",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"userinfo",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"userinfo",
"instanceof",
"UserInfo",
")",
"{",
"$",
"userinfo",
"->",
"password_clear",
"=",
"$",
"authUserinfo",
"->",
"password_clear",
";",
"try",
"{",
"$",
"session",
"=",
"$",
"userPlugin",
"->",
"createSession",
"(",
"$",
"userinfo",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"session",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'SESSION'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
",",
"$",
"session",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
";",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"session",
"[",
"LogLevel",
"::",
"ERROR",
"]",
",",
"$",
"plugin",
"->",
"name",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'SESSION'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'CREATE'",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"session",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'SESSION'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'DEBUG'",
")",
",",
"$",
"session",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
";",
"//report the error back",
"}",
"$",
"success",
"=",
"1",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'SESSION'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
",",
"$",
"plugin",
"->",
"name",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'SESSION'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'CREATE'",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"authUserinfo",
"->",
"block",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'FUSION_BLOCKED_USER'",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'FUSION_INACTIVE_USER'",
")",
")",
";",
"}",
"}",
"else",
"{",
"//return an error",
"$",
"this",
"->",
"debugger",
"->",
"add",
"(",
"'init'",
",",
"Text",
"::",
"_",
"(",
"'COULD_NOT_FIND_USER'",
")",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'COULD_NOT_FIND_USER'",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"success",
"=",
"0",
";",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
")",
";",
"$",
"this",
"->",
"debugger",
"->",
"addError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"(",
"$",
"success",
"===",
"1",
")",
";",
"}"
] | Login authentication function.
Username and encoded password are passed the onUserLogin event which
is responsible for the user validation. A successful validation updates
the current session record with the user's details.
Username and encoded password are sent as credentials (along with other
possibilities) to each observer (authentication plugin) for user
validation. Successful validation will update the current session with
the user details.
@param Userinfo $userinfo
@param array $options Array('remember' => boolean)
@return boolean True on success.
@since 3.2 | [
"Login",
"authentication",
"function",
"."
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L92-L241 |
jfusion/org.jfusion.framework | src/User/User.php | User.logout | public function logout(Userinfo $userinfo, $options = array())
{
//initialise some vars
Factory::getStatus()->set('active.jfusion', true);
if (!isset($options['skipplugin'])) {
$options['skipplugin'] = array();
}
if (!isset($options['mask'])) {
$options['mask'] = true;
}
//allow for the detection of external mods to exclude jfusion plugins
if (Factory::getStatus()->get('active.plugin')) {
$options['skipplugin'][] = Factory::getStatus()->get('active.plugin');
}
if (isset($options['nodeid']) && !empty($options['nodeid'])) {
Factory::getStatus()->set('active.plugin', $options['nodeid']);
$options['skipplugin'][] = $options['nodeid'];
}
//prevent any output by the plugins (this could prevent cookies from being passed to the header)
//logout from the JFusion plugins if done through frontend
$userlookup = static::search($userinfo);
if ($userlookup instanceof Userinfo) {
if ($options['mask']) {
$this->debugger->set('userlookup', $userlookup->getAnonymizeed());
} else {
$this->debugger->set('userlookup', $userlookup->toObject());
}
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
if (!in_array($plugin->name, $options['skipplugin'])) {
if ($plugin->dual_login == 1) {
$userPlugin = Factory::getUser($plugin->name);
$details = null;
try {
$pluginuser = $userPlugin->getUser($userlookup);
} catch (Exception $e) {
$pluginuser = null;
}
if ($pluginuser instanceof Userinfo) {
if ($options['mask']) {
$details = $pluginuser->getAnonymizeed();
} else {
$details = $pluginuser->toObject();
}
try {
$session = $userPlugin->destroySession($pluginuser, $options);
if (!empty($session[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $session[LogLevel::ERROR], $plugin->name . ': ' . Text::_('SESSION') . ' ' . Text::_('DESTROY'));
}
if (!empty($session[LogLevel::DEBUG])) {
$this->debugger->set($plugin->name . ' logout', $session[LogLevel::DEBUG]);
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e, $userPlugin->getJname());
}
} else {
Framework::raise(LogLevel::NOTICE, Text::_('LOGOUT') . ' ' . Text::_('COULD_NOT_FIND_USER'), $plugin->name);
}
$this->debugger->set($plugin->name . ' user', $details);
}
}
}
}
return true;
} | php | public function logout(Userinfo $userinfo, $options = array())
{
//initialise some vars
Factory::getStatus()->set('active.jfusion', true);
if (!isset($options['skipplugin'])) {
$options['skipplugin'] = array();
}
if (!isset($options['mask'])) {
$options['mask'] = true;
}
//allow for the detection of external mods to exclude jfusion plugins
if (Factory::getStatus()->get('active.plugin')) {
$options['skipplugin'][] = Factory::getStatus()->get('active.plugin');
}
if (isset($options['nodeid']) && !empty($options['nodeid'])) {
Factory::getStatus()->set('active.plugin', $options['nodeid']);
$options['skipplugin'][] = $options['nodeid'];
}
//prevent any output by the plugins (this could prevent cookies from being passed to the header)
//logout from the JFusion plugins if done through frontend
$userlookup = static::search($userinfo);
if ($userlookup instanceof Userinfo) {
if ($options['mask']) {
$this->debugger->set('userlookup', $userlookup->getAnonymizeed());
} else {
$this->debugger->set('userlookup', $userlookup->toObject());
}
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
if (!in_array($plugin->name, $options['skipplugin'])) {
if ($plugin->dual_login == 1) {
$userPlugin = Factory::getUser($plugin->name);
$details = null;
try {
$pluginuser = $userPlugin->getUser($userlookup);
} catch (Exception $e) {
$pluginuser = null;
}
if ($pluginuser instanceof Userinfo) {
if ($options['mask']) {
$details = $pluginuser->getAnonymizeed();
} else {
$details = $pluginuser->toObject();
}
try {
$session = $userPlugin->destroySession($pluginuser, $options);
if (!empty($session[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $session[LogLevel::ERROR], $plugin->name . ': ' . Text::_('SESSION') . ' ' . Text::_('DESTROY'));
}
if (!empty($session[LogLevel::DEBUG])) {
$this->debugger->set($plugin->name . ' logout', $session[LogLevel::DEBUG]);
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e, $userPlugin->getJname());
}
} else {
Framework::raise(LogLevel::NOTICE, Text::_('LOGOUT') . ' ' . Text::_('COULD_NOT_FIND_USER'), $plugin->name);
}
$this->debugger->set($plugin->name . ' user', $details);
}
}
}
}
return true;
} | [
"public",
"function",
"logout",
"(",
"Userinfo",
"$",
"userinfo",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"//initialise some vars",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"set",
"(",
"'active.jfusion'",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'skipplugin'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'skipplugin'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'mask'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'mask'",
"]",
"=",
"true",
";",
"}",
"//allow for the detection of external mods to exclude jfusion plugins",
"if",
"(",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"get",
"(",
"'active.plugin'",
")",
")",
"{",
"$",
"options",
"[",
"'skipplugin'",
"]",
"[",
"]",
"=",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"get",
"(",
"'active.plugin'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'nodeid'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"options",
"[",
"'nodeid'",
"]",
")",
")",
"{",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"set",
"(",
"'active.plugin'",
",",
"$",
"options",
"[",
"'nodeid'",
"]",
")",
";",
"$",
"options",
"[",
"'skipplugin'",
"]",
"[",
"]",
"=",
"$",
"options",
"[",
"'nodeid'",
"]",
";",
"}",
"//prevent any output by the plugins (this could prevent cookies from being passed to the header)",
"//logout from the JFusion plugins if done through frontend",
"$",
"userlookup",
"=",
"static",
"::",
"search",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"userlookup",
"instanceof",
"Userinfo",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'mask'",
"]",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"'userlookup'",
",",
"$",
"userlookup",
"->",
"getAnonymizeed",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"'userlookup'",
",",
"$",
"userlookup",
"->",
"toObject",
"(",
")",
")",
";",
"}",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"plugin",
"->",
"name",
",",
"$",
"options",
"[",
"'skipplugin'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"dual_login",
"==",
"1",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"details",
"=",
"null",
";",
"try",
"{",
"$",
"pluginuser",
"=",
"$",
"userPlugin",
"->",
"getUser",
"(",
"$",
"userlookup",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"pluginuser",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"pluginuser",
"instanceof",
"Userinfo",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'mask'",
"]",
")",
"{",
"$",
"details",
"=",
"$",
"pluginuser",
"->",
"getAnonymizeed",
"(",
")",
";",
"}",
"else",
"{",
"$",
"details",
"=",
"$",
"pluginuser",
"->",
"toObject",
"(",
")",
";",
"}",
"try",
"{",
"$",
"session",
"=",
"$",
"userPlugin",
"->",
"destroySession",
"(",
"$",
"pluginuser",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"session",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"session",
"[",
"LogLevel",
"::",
"ERROR",
"]",
",",
"$",
"plugin",
"->",
"name",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'SESSION'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'DESTROY'",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"session",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' logout'",
",",
"$",
"session",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
",",
"$",
"userPlugin",
"->",
"getJname",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'LOGOUT'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'COULD_NOT_FIND_USER'",
")",
",",
"$",
"plugin",
"->",
"name",
")",
";",
"}",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"$",
"plugin",
"->",
"name",
".",
"' user'",
",",
"$",
"details",
")",
";",
"}",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Logout authentication function.
Passed the current user information to the onUserLogout event and reverts the current
session record back to 'anonymous' parameters.
If any of the authentication plugins did not successfully complete
the logout routine then the whole method fails. Any errors raised
should be done in the plugin as this provides the ability to give
much more information about why the routine may have failed.
@param Userinfo $userinfo The user to load - Can be an integer or string - If string, it is converted to ID automatically
@param array $options
@return boolean True on success
@since 3.2 | [
"Logout",
"authentication",
"function",
"."
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L260-L332 |
jfusion/org.jfusion.framework | src/User/User.php | User.delete | public function delete(Userinfo $userinfo)
{
$result = false;
$this->debugger->set(null, array());
//create an array to store the debug info
$debug_info = array();
$error_info = array();
$plugins = Factory::getPlugins();
$userinfo = User::search($userinfo);
if ($userinfo instanceof Userinfo) {
foreach ($plugins as $plugin) {
$params = Factory::getParams($plugin->name);
if ($params->get('allow_delete_users', 0)) {
$userPlugin = Factory::getUser($plugin->name);
try {
$pluginUser = $userPlugin->getUser($userinfo);
if ($pluginUser instanceof Userinfo) {
$userPlugin->resetDebugger();
$deleteStatus = $userPlugin->deleteUser($pluginUser);
$status = $userPlugin->debugger->get();
if ($deleteStatus) {
//remove userlookup data
User::remove($pluginUser);
$status[LogLevel::DEBUG][] = Text::_('USER_DELETION') . ': ' . $userinfo->userid . ' ( ' . $userinfo->username . ' )';
}
if (!empty($status[LogLevel::ERROR])) {
$error_info[$plugin->name . ' ' . Text::_('USER_DELETION_ERROR') ] = $status[LogLevel::ERROR];
}
if (!empty($status[LogLevel::DEBUG])) {
$debug_info[$plugin->name] = $status[LogLevel::DEBUG];
}
} else {
$debug_info[$plugin->name] = Text::_('NO_USER_DATA_FOUND');
}
} catch (Exception $e) {
$error_info[$plugin->name . ' ' . Text::_('USER_DELETION_ERROR') ] = $e->getMessage();
}
} else {
$debug_info[$plugin->name] = Text::_('DELETE_DISABLED');
}
}
$result = true;
} else {
$result = false;
}
$this->debugger->set('debug', $debug_info);
$this->debugger->set('error', $error_info);
return $result;
} | php | public function delete(Userinfo $userinfo)
{
$result = false;
$this->debugger->set(null, array());
//create an array to store the debug info
$debug_info = array();
$error_info = array();
$plugins = Factory::getPlugins();
$userinfo = User::search($userinfo);
if ($userinfo instanceof Userinfo) {
foreach ($plugins as $plugin) {
$params = Factory::getParams($plugin->name);
if ($params->get('allow_delete_users', 0)) {
$userPlugin = Factory::getUser($plugin->name);
try {
$pluginUser = $userPlugin->getUser($userinfo);
if ($pluginUser instanceof Userinfo) {
$userPlugin->resetDebugger();
$deleteStatus = $userPlugin->deleteUser($pluginUser);
$status = $userPlugin->debugger->get();
if ($deleteStatus) {
//remove userlookup data
User::remove($pluginUser);
$status[LogLevel::DEBUG][] = Text::_('USER_DELETION') . ': ' . $userinfo->userid . ' ( ' . $userinfo->username . ' )';
}
if (!empty($status[LogLevel::ERROR])) {
$error_info[$plugin->name . ' ' . Text::_('USER_DELETION_ERROR') ] = $status[LogLevel::ERROR];
}
if (!empty($status[LogLevel::DEBUG])) {
$debug_info[$plugin->name] = $status[LogLevel::DEBUG];
}
} else {
$debug_info[$plugin->name] = Text::_('NO_USER_DATA_FOUND');
}
} catch (Exception $e) {
$error_info[$plugin->name . ' ' . Text::_('USER_DELETION_ERROR') ] = $e->getMessage();
}
} else {
$debug_info[$plugin->name] = Text::_('DELETE_DISABLED');
}
}
$result = true;
} else {
$result = false;
}
$this->debugger->set('debug', $debug_info);
$this->debugger->set('error', $error_info);
return $result;
} | [
"public",
"function",
"delete",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"null",
",",
"array",
"(",
")",
")",
";",
"//create an array to store the debug info",
"$",
"debug_info",
"=",
"array",
"(",
")",
";",
"$",
"error_info",
"=",
"array",
"(",
")",
";",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
")",
";",
"$",
"userinfo",
"=",
"User",
"::",
"search",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"userinfo",
"instanceof",
"Userinfo",
")",
"{",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"params",
"=",
"Factory",
"::",
"getParams",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"if",
"(",
"$",
"params",
"->",
"get",
"(",
"'allow_delete_users'",
",",
"0",
")",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"try",
"{",
"$",
"pluginUser",
"=",
"$",
"userPlugin",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"pluginUser",
"instanceof",
"Userinfo",
")",
"{",
"$",
"userPlugin",
"->",
"resetDebugger",
"(",
")",
";",
"$",
"deleteStatus",
"=",
"$",
"userPlugin",
"->",
"deleteUser",
"(",
"$",
"pluginUser",
")",
";",
"$",
"status",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"$",
"deleteStatus",
")",
"{",
"//remove userlookup data",
"User",
"::",
"remove",
"(",
"$",
"pluginUser",
")",
";",
"$",
"status",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
"[",
"]",
"=",
"Text",
"::",
"_",
"(",
"'USER_DELETION'",
")",
".",
"': '",
".",
"$",
"userinfo",
"->",
"userid",
".",
"' ( '",
".",
"$",
"userinfo",
"->",
"username",
".",
"' )'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"$",
"error_info",
"[",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER_DELETION_ERROR'",
")",
"]",
"=",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
")",
"{",
"$",
"debug_info",
"[",
"$",
"plugin",
"->",
"name",
"]",
"=",
"$",
"status",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"debug_info",
"[",
"$",
"plugin",
"->",
"name",
"]",
"=",
"Text",
"::",
"_",
"(",
"'NO_USER_DATA_FOUND'",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"error_info",
"[",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER_DELETION_ERROR'",
")",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"debug_info",
"[",
"$",
"plugin",
"->",
"name",
"]",
"=",
"Text",
"::",
"_",
"(",
"'DELETE_DISABLED'",
")",
";",
"}",
"}",
"$",
"result",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"'debug'",
",",
"$",
"debug_info",
")",
";",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"'error'",
",",
"$",
"error_info",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Delete user
@param Userinfo $userinfo
@return boolean | [
"Delete",
"user"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L341-L394 |
jfusion/org.jfusion.framework | src/User/User.php | User.save | public function save(Userinfo $userinfo, Userinfo $olduserinfo = null, $new = false)
{
$this->debugger->set(null, array());
//create an array to store the debug info
$debug_info = array();
$error_info = array();
$plugins = Factory::getPlugins();
if ($userinfo instanceof Userinfo) {
// Recover the old data of the user
// This is then used to determine if the username was changed
$updateUsername = false;
if ($userinfo->getJname() !== null && $olduserinfo->getJname() !== null) {
if ($new == false && $userinfo instanceof Userinfo && $olduserinfo instanceof Userinfo) {
if ($userinfo->getJname() == $olduserinfo->getJname() && $userinfo->username != $olduserinfo->username) {
$updateUsername = true;
}
}
}
$exsistingUser = User::search($olduserinfo, true);
foreach ($plugins as $plugin) {
try {
$userPlugin = Factory::getUser($plugin->name);
if ($userPlugin->validateUser($userinfo)) {
if ($updateUsername) {
if ($exsistingUser instanceof Userinfo) {
$pluginUserinfo = $userPlugin->getUser($exsistingUser);
if ($pluginUserinfo instanceof Userinfo) {
try {
$userPlugin->resetDebugger();
$userPlugin->updateUsername($userinfo, $pluginUserinfo);
if (!$userPlugin->debugger->isEmpty('error')) {
$error_info[$plugin->name . ' ' . Text::_('USERNAME') . ' ' . Text::_('UPDATE') . ' ' . Text::_('ERROR') ] = $userPlugin->debugger->get('error');
}
if (!$userPlugin->debugger->isEmpty('debug')) {
$debug_info[$plugin->name . ' ' . Text::_('USERNAME') . ' ' . Text::_('UPDATE') . ' ' . Text::_('DEBUG') ] = $userPlugin->debugger->get('debug');
}
} catch (Exception $e) {
$status[LogLevel::ERROR][] = Text::_('USERNAME_UPDATE_ERROR') . ': ' . $e->getMessage();
}
} else {
$error_info[$plugin->name] = Text::_('NO_USER_DATA_FOUND');
}
}
}
//run the update user to ensure any other userinfo is updated as well
$userPlugin->resetDebugger();
$pluginUserinfo = $userPlugin->updateUser($userinfo, 1);
$debug = $userPlugin->debugger->get();
if (!empty($debug[LogLevel::ERROR])) {
$error_info[$plugin->name] = $debug[LogLevel::ERROR];
}
if (!empty($debug[LogLevel::DEBUG])) {
$debug_info[$plugin->name] = $debug[LogLevel::DEBUG];
}
if (!$pluginUserinfo instanceof Userinfo) {
//make sure the userinfo is available
$pluginUserinfo = $userPlugin->getUser($userinfo);
}
//update the jfusion_users table
if ($pluginUserinfo instanceof Userinfo) {
$userPlugin->updateLookup($pluginUserinfo, $userinfo);
}
}
} catch (Exception $e) {
$error_info[$plugin->name] = array($e->getMessage());
}
}
}
$this->debugger->set('debug', $debug_info);
$this->debugger->set('error', $error_info);
return true;
} | php | public function save(Userinfo $userinfo, Userinfo $olduserinfo = null, $new = false)
{
$this->debugger->set(null, array());
//create an array to store the debug info
$debug_info = array();
$error_info = array();
$plugins = Factory::getPlugins();
if ($userinfo instanceof Userinfo) {
// Recover the old data of the user
// This is then used to determine if the username was changed
$updateUsername = false;
if ($userinfo->getJname() !== null && $olduserinfo->getJname() !== null) {
if ($new == false && $userinfo instanceof Userinfo && $olduserinfo instanceof Userinfo) {
if ($userinfo->getJname() == $olduserinfo->getJname() && $userinfo->username != $olduserinfo->username) {
$updateUsername = true;
}
}
}
$exsistingUser = User::search($olduserinfo, true);
foreach ($plugins as $plugin) {
try {
$userPlugin = Factory::getUser($plugin->name);
if ($userPlugin->validateUser($userinfo)) {
if ($updateUsername) {
if ($exsistingUser instanceof Userinfo) {
$pluginUserinfo = $userPlugin->getUser($exsistingUser);
if ($pluginUserinfo instanceof Userinfo) {
try {
$userPlugin->resetDebugger();
$userPlugin->updateUsername($userinfo, $pluginUserinfo);
if (!$userPlugin->debugger->isEmpty('error')) {
$error_info[$plugin->name . ' ' . Text::_('USERNAME') . ' ' . Text::_('UPDATE') . ' ' . Text::_('ERROR') ] = $userPlugin->debugger->get('error');
}
if (!$userPlugin->debugger->isEmpty('debug')) {
$debug_info[$plugin->name . ' ' . Text::_('USERNAME') . ' ' . Text::_('UPDATE') . ' ' . Text::_('DEBUG') ] = $userPlugin->debugger->get('debug');
}
} catch (Exception $e) {
$status[LogLevel::ERROR][] = Text::_('USERNAME_UPDATE_ERROR') . ': ' . $e->getMessage();
}
} else {
$error_info[$plugin->name] = Text::_('NO_USER_DATA_FOUND');
}
}
}
//run the update user to ensure any other userinfo is updated as well
$userPlugin->resetDebugger();
$pluginUserinfo = $userPlugin->updateUser($userinfo, 1);
$debug = $userPlugin->debugger->get();
if (!empty($debug[LogLevel::ERROR])) {
$error_info[$plugin->name] = $debug[LogLevel::ERROR];
}
if (!empty($debug[LogLevel::DEBUG])) {
$debug_info[$plugin->name] = $debug[LogLevel::DEBUG];
}
if (!$pluginUserinfo instanceof Userinfo) {
//make sure the userinfo is available
$pluginUserinfo = $userPlugin->getUser($userinfo);
}
//update the jfusion_users table
if ($pluginUserinfo instanceof Userinfo) {
$userPlugin->updateLookup($pluginUserinfo, $userinfo);
}
}
} catch (Exception $e) {
$error_info[$plugin->name] = array($e->getMessage());
}
}
}
$this->debugger->set('debug', $debug_info);
$this->debugger->set('error', $error_info);
return true;
} | [
"public",
"function",
"save",
"(",
"Userinfo",
"$",
"userinfo",
",",
"Userinfo",
"$",
"olduserinfo",
"=",
"null",
",",
"$",
"new",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"null",
",",
"array",
"(",
")",
")",
";",
"//create an array to store the debug info",
"$",
"debug_info",
"=",
"array",
"(",
")",
";",
"$",
"error_info",
"=",
"array",
"(",
")",
";",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
")",
";",
"if",
"(",
"$",
"userinfo",
"instanceof",
"Userinfo",
")",
"{",
"// Recover the old data of the user",
"// This is then used to determine if the username was changed",
"$",
"updateUsername",
"=",
"false",
";",
"if",
"(",
"$",
"userinfo",
"->",
"getJname",
"(",
")",
"!==",
"null",
"&&",
"$",
"olduserinfo",
"->",
"getJname",
"(",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"new",
"==",
"false",
"&&",
"$",
"userinfo",
"instanceof",
"Userinfo",
"&&",
"$",
"olduserinfo",
"instanceof",
"Userinfo",
")",
"{",
"if",
"(",
"$",
"userinfo",
"->",
"getJname",
"(",
")",
"==",
"$",
"olduserinfo",
"->",
"getJname",
"(",
")",
"&&",
"$",
"userinfo",
"->",
"username",
"!=",
"$",
"olduserinfo",
"->",
"username",
")",
"{",
"$",
"updateUsername",
"=",
"true",
";",
"}",
"}",
"}",
"$",
"exsistingUser",
"=",
"User",
"::",
"search",
"(",
"$",
"olduserinfo",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"try",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"if",
"(",
"$",
"userPlugin",
"->",
"validateUser",
"(",
"$",
"userinfo",
")",
")",
"{",
"if",
"(",
"$",
"updateUsername",
")",
"{",
"if",
"(",
"$",
"exsistingUser",
"instanceof",
"Userinfo",
")",
"{",
"$",
"pluginUserinfo",
"=",
"$",
"userPlugin",
"->",
"getUser",
"(",
"$",
"exsistingUser",
")",
";",
"if",
"(",
"$",
"pluginUserinfo",
"instanceof",
"Userinfo",
")",
"{",
"try",
"{",
"$",
"userPlugin",
"->",
"resetDebugger",
"(",
")",
";",
"$",
"userPlugin",
"->",
"updateUsername",
"(",
"$",
"userinfo",
",",
"$",
"pluginUserinfo",
")",
";",
"if",
"(",
"!",
"$",
"userPlugin",
"->",
"debugger",
"->",
"isEmpty",
"(",
"'error'",
")",
")",
"{",
"$",
"error_info",
"[",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USERNAME'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
"]",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
"'error'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"userPlugin",
"->",
"debugger",
"->",
"isEmpty",
"(",
"'debug'",
")",
")",
"{",
"$",
"debug_info",
"[",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USERNAME'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'DEBUG'",
")",
"]",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
"'debug'",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
"[",
"]",
"=",
"Text",
"::",
"_",
"(",
"'USERNAME_UPDATE_ERROR'",
")",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"error_info",
"[",
"$",
"plugin",
"->",
"name",
"]",
"=",
"Text",
"::",
"_",
"(",
"'NO_USER_DATA_FOUND'",
")",
";",
"}",
"}",
"}",
"//run the update user to ensure any other userinfo is updated as well",
"$",
"userPlugin",
"->",
"resetDebugger",
"(",
")",
";",
"$",
"pluginUserinfo",
"=",
"$",
"userPlugin",
"->",
"updateUser",
"(",
"$",
"userinfo",
",",
"1",
")",
";",
"$",
"debug",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"debug",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"$",
"error_info",
"[",
"$",
"plugin",
"->",
"name",
"]",
"=",
"$",
"debug",
"[",
"LogLevel",
"::",
"ERROR",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"debug",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
")",
"{",
"$",
"debug_info",
"[",
"$",
"plugin",
"->",
"name",
"]",
"=",
"$",
"debug",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"pluginUserinfo",
"instanceof",
"Userinfo",
")",
"{",
"//make sure the userinfo is available",
"$",
"pluginUserinfo",
"=",
"$",
"userPlugin",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"}",
"//update the jfusion_users table",
"if",
"(",
"$",
"pluginUserinfo",
"instanceof",
"Userinfo",
")",
"{",
"$",
"userPlugin",
"->",
"updateLookup",
"(",
"$",
"pluginUserinfo",
",",
"$",
"userinfo",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"error_info",
"[",
"$",
"plugin",
"->",
"name",
"]",
"=",
"array",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"'debug'",
",",
"$",
"debug_info",
")",
";",
"$",
"this",
"->",
"debugger",
"->",
"set",
"(",
"'error'",
",",
"$",
"error_info",
")",
";",
"return",
"true",
";",
"}"
] | Delete user
@param Userinfo $userinfo
@param Userinfo $olduserinfo
@param bool $new
@return boolean False on Error | [
"Delete",
"user"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L405-L484 |
jfusion/org.jfusion.framework | src/User/User.php | User.search | public static function search(Userinfo $userinfo, $lookup = false)
{
$exsistingUser = null;
if ($lookup && $userinfo->getJname() !== null) {
$userPlugin = Factory::getUser($userinfo->getJname());
$exsistingUser = $userPlugin->lookupUser($userinfo);
}
if (!$exsistingUser instanceof Userinfo) {
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
try {
$JFusionSlave = Factory::getUser($plugin->name);
$exsistingUser = $JFusionSlave->getUser($userinfo);
if ($exsistingUser instanceof Userinfo) {
break;
}
} catch (Exception $e) {
}
}
}
return $exsistingUser;
} | php | public static function search(Userinfo $userinfo, $lookup = false)
{
$exsistingUser = null;
if ($lookup && $userinfo->getJname() !== null) {
$userPlugin = Factory::getUser($userinfo->getJname());
$exsistingUser = $userPlugin->lookupUser($userinfo);
}
if (!$exsistingUser instanceof Userinfo) {
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
try {
$JFusionSlave = Factory::getUser($plugin->name);
$exsistingUser = $JFusionSlave->getUser($userinfo);
if ($exsistingUser instanceof Userinfo) {
break;
}
} catch (Exception $e) {
}
}
}
return $exsistingUser;
} | [
"public",
"static",
"function",
"search",
"(",
"Userinfo",
"$",
"userinfo",
",",
"$",
"lookup",
"=",
"false",
")",
"{",
"$",
"exsistingUser",
"=",
"null",
";",
"if",
"(",
"$",
"lookup",
"&&",
"$",
"userinfo",
"->",
"getJname",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"userinfo",
"->",
"getJname",
"(",
")",
")",
";",
"$",
"exsistingUser",
"=",
"$",
"userPlugin",
"->",
"lookupUser",
"(",
"$",
"userinfo",
")",
";",
"}",
"if",
"(",
"!",
"$",
"exsistingUser",
"instanceof",
"Userinfo",
")",
"{",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"try",
"{",
"$",
"JFusionSlave",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"exsistingUser",
"=",
"$",
"JFusionSlave",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"exsistingUser",
"instanceof",
"Userinfo",
")",
"{",
"break",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"}",
"return",
"$",
"exsistingUser",
";",
"}"
] | Finds the first user that match starting with master
@param Userinfo $userinfo
@param bool $lookup
@return null|Userinfo returns first used founed | [
"Finds",
"the",
"first",
"user",
"that",
"match",
"starting",
"with",
"master"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L494-L518 |
jfusion/org.jfusion.framework | src/User/User.php | User.remove | public static function remove(Userinfo $userinfo)
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->delete('#__jfusion_users')
->where('userid = ' . $db->quote($userinfo->userid));
$db->setQuery($query);
$db->execute();
} | php | public static function remove(Userinfo $userinfo)
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->delete('#__jfusion_users')
->where('userid = ' . $db->quote($userinfo->userid));
$db->setQuery($query);
$db->execute();
} | [
"public",
"static",
"function",
"remove",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"delete",
"(",
"'#__jfusion_users'",
")",
"->",
"where",
"(",
"'userid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"userinfo",
"->",
"userid",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}"
] | Delete old user data in the lookup table
@param Userinfo $userinfo userinfo of the user to be deleted | [
"Delete",
"old",
"user",
"data",
"in",
"the",
"lookup",
"table"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L525-L535 |
RobinMalfait/l4-laracasts-feed | src/Malfaitrobin/Laracasts/Laracasts.php | Laracasts.meta | public function meta()
{
$xml = (array) $this->xml;
unset($xml['entry']);
$xml['link'] = (object) $xml['link']->{"@attributes"};
return (object) $xml;
} | php | public function meta()
{
$xml = (array) $this->xml;
unset($xml['entry']);
$xml['link'] = (object) $xml['link']->{"@attributes"};
return (object) $xml;
} | [
"public",
"function",
"meta",
"(",
")",
"{",
"$",
"xml",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"xml",
";",
"unset",
"(",
"$",
"xml",
"[",
"'entry'",
"]",
")",
";",
"$",
"xml",
"[",
"'link'",
"]",
"=",
"(",
"object",
")",
"$",
"xml",
"[",
"'link'",
"]",
"->",
"{",
"\"@attributes\"",
"}",
";",
"return",
"(",
"object",
")",
"$",
"xml",
";",
"}"
] | Get the meta information of the xml feed
@return object | [
"Get",
"the",
"meta",
"information",
"of",
"the",
"xml",
"feed"
] | train | https://github.com/RobinMalfait/l4-laracasts-feed/blob/26033545dc42dd15fa5c2ed64c28868cdd43f933/src/Malfaitrobin/Laracasts/Laracasts.php#L59-L67 |
RobinMalfait/l4-laracasts-feed | src/Malfaitrobin/Laracasts/Laracasts.php | Laracasts.getXML | protected function getXML()
{
$key = 'xml_' . md5($this->url); // Everybody loves md5!
if ($this->cache->has($key)) {
$this->xml = $this->cache->get($key);
} else {
$this->xml = $this->fetchXML();
$this->xml = $this->changeLinkElements($this->xml);
$this->cache->put($key, $this->xml, $this->cacheTime);
}
} | php | protected function getXML()
{
$key = 'xml_' . md5($this->url); // Everybody loves md5!
if ($this->cache->has($key)) {
$this->xml = $this->cache->get($key);
} else {
$this->xml = $this->fetchXML();
$this->xml = $this->changeLinkElements($this->xml);
$this->cache->put($key, $this->xml, $this->cacheTime);
}
} | [
"protected",
"function",
"getXML",
"(",
")",
"{",
"$",
"key",
"=",
"'xml_'",
".",
"md5",
"(",
"$",
"this",
"->",
"url",
")",
";",
"// Everybody loves md5!",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"fetchXML",
"(",
")",
";",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"changeLinkElements",
"(",
"$",
"this",
"->",
"xml",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"xml",
",",
"$",
"this",
"->",
"cacheTime",
")",
";",
"}",
"}"
] | Get the xml from the server, and cache the result
@return void | [
"Get",
"the",
"xml",
"from",
"the",
"server",
"and",
"cache",
"the",
"result"
] | train | https://github.com/RobinMalfait/l4-laracasts-feed/blob/26033545dc42dd15fa5c2ed64c28868cdd43f933/src/Malfaitrobin/Laracasts/Laracasts.php#L84-L97 |
askupasoftware/amarkal | Autoloader.php | Autoloader.autoload | public static function autoload( $class )
{
// Verify that the base namespace is Amarkal
if (0 !== strpos($class, __NAMESPACE__)) {
return;
}
// UI classes
if( strpos( $class, "Amarkal\UI\Components" ) === 0 )
{
$class .= "\controller";
}
// Widget UI classes
if( strpos( $class, "Amarkal\Extensions\WordPress\Widget\UI" ) === 0 )
{
$class .= "\controller";
}
// Options UI classes
if( strpos( $class, "Amarkal\Extensions\WordPress\Options\UI" ) === 0 )
{
$class .= "\controller";
}
$fileName = dirname(__FILE__).str_replace(array(__NAMESPACE__, '\\'), array('',DIRECTORY_SEPARATOR), $class).'.php';
if ( is_file( $fileName ) ) {
require $fileName;
return true;
}
else return false;
} | php | public static function autoload( $class )
{
// Verify that the base namespace is Amarkal
if (0 !== strpos($class, __NAMESPACE__)) {
return;
}
// UI classes
if( strpos( $class, "Amarkal\UI\Components" ) === 0 )
{
$class .= "\controller";
}
// Widget UI classes
if( strpos( $class, "Amarkal\Extensions\WordPress\Widget\UI" ) === 0 )
{
$class .= "\controller";
}
// Options UI classes
if( strpos( $class, "Amarkal\Extensions\WordPress\Options\UI" ) === 0 )
{
$class .= "\controller";
}
$fileName = dirname(__FILE__).str_replace(array(__NAMESPACE__, '\\'), array('',DIRECTORY_SEPARATOR), $class).'.php';
if ( is_file( $fileName ) ) {
require $fileName;
return true;
}
else return false;
} | [
"public",
"static",
"function",
"autoload",
"(",
"$",
"class",
")",
"{",
"// Verify that the base namespace is Amarkal",
"if",
"(",
"0",
"!==",
"strpos",
"(",
"$",
"class",
",",
"__NAMESPACE__",
")",
")",
"{",
"return",
";",
"}",
"// UI classes",
"if",
"(",
"strpos",
"(",
"$",
"class",
",",
"\"Amarkal\\UI\\Components\"",
")",
"===",
"0",
")",
"{",
"$",
"class",
".=",
"\"\\controller\"",
";",
"}",
"// Widget UI classes",
"if",
"(",
"strpos",
"(",
"$",
"class",
",",
"\"Amarkal\\Extensions\\WordPress\\Widget\\UI\"",
")",
"===",
"0",
")",
"{",
"$",
"class",
".=",
"\"\\controller\"",
";",
"}",
"// Options UI classes",
"if",
"(",
"strpos",
"(",
"$",
"class",
",",
"\"Amarkal\\Extensions\\WordPress\\Options\\UI\"",
")",
"===",
"0",
")",
"{",
"$",
"class",
".=",
"\"\\controller\"",
";",
"}",
"$",
"fileName",
"=",
"dirname",
"(",
"__FILE__",
")",
".",
"str_replace",
"(",
"array",
"(",
"__NAMESPACE__",
",",
"'\\\\'",
")",
",",
"array",
"(",
"''",
",",
"DIRECTORY_SEPARATOR",
")",
",",
"$",
"class",
")",
".",
"'.php'",
";",
"if",
"(",
"is_file",
"(",
"$",
"fileName",
")",
")",
"{",
"require",
"$",
"fileName",
";",
"return",
"true",
";",
"}",
"else",
"return",
"false",
";",
"}"
] | Loads the given class or interface
@param string $class The name of the class
@return null|boolean True/false if class was loaded | [
"Loads",
"the",
"given",
"class",
"or",
"interface"
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Autoloader.php#L36-L65 |
askupasoftware/amarkal | Autoloader.php | Autoloader.register_assets | static function register_assets()
{
\wp_enqueue_script( 'jquery' );
\wp_enqueue_script( 'jquery-ui' );
\wp_enqueue_script( 'jquery-ui-datepicker' );
\wp_enqueue_script( 'jquery-ui-spinner' );
\wp_enqueue_script( 'jquery-ui-slider' );
\wp_enqueue_script( 'jquery-ui-resizable' );
\wp_enqueue_script( 'wp-color-picker' );
\wp_enqueue_script( 'amarkal', AMARKAL_ASSETS_URL.'js/amarkal.min.js', array('jquery'), AMARKAL_VERSION, true );
\wp_enqueue_script( 'select2', AMARKAL_ASSETS_URL.'js/select2.min.js', array('jquery'), '4.0.3', true );
\wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js', array(), '1.2.6', true );
\wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', array(), '4.7.0' );
\wp_enqueue_style( 'amarkal', AMARKAL_ASSETS_URL.'css/amarkal.min.css', array('wp-color-picker'), AMARKAL_VERSION );
\wp_enqueue_style( 'select2', AMARKAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.3' );
} | php | static function register_assets()
{
\wp_enqueue_script( 'jquery' );
\wp_enqueue_script( 'jquery-ui' );
\wp_enqueue_script( 'jquery-ui-datepicker' );
\wp_enqueue_script( 'jquery-ui-spinner' );
\wp_enqueue_script( 'jquery-ui-slider' );
\wp_enqueue_script( 'jquery-ui-resizable' );
\wp_enqueue_script( 'wp-color-picker' );
\wp_enqueue_script( 'amarkal', AMARKAL_ASSETS_URL.'js/amarkal.min.js', array('jquery'), AMARKAL_VERSION, true );
\wp_enqueue_script( 'select2', AMARKAL_ASSETS_URL.'js/select2.min.js', array('jquery'), '4.0.3', true );
\wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js', array(), '1.2.6', true );
\wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', array(), '4.7.0' );
\wp_enqueue_style( 'amarkal', AMARKAL_ASSETS_URL.'css/amarkal.min.css', array('wp-color-picker'), AMARKAL_VERSION );
\wp_enqueue_style( 'select2', AMARKAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.3' );
} | [
"static",
"function",
"register_assets",
"(",
")",
"{",
"\\",
"wp_enqueue_script",
"(",
"'jquery'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-datepicker'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-spinner'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-slider'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-resizable'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'wp-color-picker'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'amarkal'",
",",
"AMARKAL_ASSETS_URL",
".",
"'js/amarkal.min.js'",
",",
"array",
"(",
"'jquery'",
")",
",",
"AMARKAL_VERSION",
",",
"true",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'select2'",
",",
"AMARKAL_ASSETS_URL",
".",
"'js/select2.min.js'",
",",
"array",
"(",
"'jquery'",
")",
",",
"'4.0.3'",
",",
"true",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'ace-editor'",
",",
"'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js'",
",",
"array",
"(",
")",
",",
"'1.2.6'",
",",
"true",
")",
";",
"\\",
"wp_enqueue_style",
"(",
"'font-awesome'",
",",
"'//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'",
",",
"array",
"(",
")",
",",
"'4.7.0'",
")",
";",
"\\",
"wp_enqueue_style",
"(",
"'amarkal'",
",",
"AMARKAL_ASSETS_URL",
".",
"'css/amarkal.min.css'",
",",
"array",
"(",
"'wp-color-picker'",
")",
",",
"AMARKAL_VERSION",
")",
";",
"\\",
"wp_enqueue_style",
"(",
"'select2'",
",",
"AMARKAL_ASSETS_URL",
".",
"'css/select2.min.css'",
",",
"array",
"(",
")",
",",
"'4.0.3'",
")",
";",
"}"
] | Register Amarkal Scripts and Stylesheets | [
"Register",
"Amarkal",
"Scripts",
"and",
"Stylesheets"
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Autoloader.php#L70-L87 |
jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.getDefaultUsergroup | function getDefaultUsergroup()
{
$usergroups = Groups::get($this->getJname(), true);
$groups = array();
if ($usergroups !== null) {
$list = $this->getUsergroupList();
foreach ($list as $group) {
if(in_array($group->id, $usergroups)){
$groups[] = $group->name;
}
}
}
return $groups;
} | php | function getDefaultUsergroup()
{
$usergroups = Groups::get($this->getJname(), true);
$groups = array();
if ($usergroups !== null) {
$list = $this->getUsergroupList();
foreach ($list as $group) {
if(in_array($group->id, $usergroups)){
$groups[] = $group->name;
}
}
}
return $groups;
} | [
"function",
"getDefaultUsergroup",
"(",
")",
"{",
"$",
"usergroups",
"=",
"Groups",
"::",
"get",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
",",
"true",
")",
";",
"$",
"groups",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"usergroups",
"!==",
"null",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"getUsergroupList",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"group",
"->",
"id",
",",
"$",
"usergroups",
")",
")",
"{",
"$",
"groups",
"[",
"]",
"=",
"$",
"group",
"->",
"name",
";",
"}",
"}",
"}",
"return",
"$",
"groups",
";",
"}"
] | Function used to display the default usergroup in the JFusion plugin overview
@return array Default usergroup name | [
"Function",
"used",
"to",
"display",
"the",
"default",
"usergroup",
"in",
"the",
"JFusion",
"plugin",
"overview"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L89-L103 |
jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.checkConfig | function checkConfig()
{
//for joomla_int check to see if the source_url does not equal the default
try {
$db = Factory::getDatabase($this->getJname());
} catch (Exception $e) {
throw new RuntimeException(Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
}
try {
$jdb = Factory::getDBO();
} catch (Exception $e) {
throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
}
if (!$db->connected()) {
throw new RuntimeException(Text::_('NO_DATABASE'));
} elseif (!$jdb->connected()) {
throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE'));
} else {
//added check for missing files of copied plugins after upgrade
$admin = Factory::getAdmin($this->getJname());
$adminclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\Admin';
$user = Factory::getUser($this->getJname());
$userclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\User';
if (!$admin instanceof $adminclass) {
throw new RuntimeException(Text::_('NO_FILES') . ' '. $adminclass);
} else if (!$user instanceof $userclass) {
throw new RuntimeException(Text::_('NO_FILES') . ' '. $userclass);
} else {
$cookie_domain = $this->params->get('cookie_domain');
$jfc = Factory::getCookies();
list($url) = $jfc->getApiUrl($cookie_domain);
if ($url) {
$api = new Api($url, Factory::getParams('joomla_int')->get('secret'));
if (!$api->ping()) {
list ($message) = $api->getError();
throw new RuntimeException($api->url . ' ' . $message);
}
}
$source_path = $this->params->get('source_path');
if ($source_path && (strpos($source_path, 'http://') === 0 || strpos($source_path, 'https://') === 0)) {
throw new RuntimeException(Text::_('ERROR_SOURCE_PATH') . ' : ' . $source_path);
} else {
//get the user table name
$tablename = $this->getTablename();
// lets check if the table exists, now using the Joomla API
$table_list = $db->getTableList();
$table_prefix = $db->getPrefix();
if (!is_array($table_list)) {
throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
} else {
if (array_search($table_prefix . $tablename, $table_list) === false) {
//do a final check for case insensitive windows servers
if (array_search(strtolower($table_prefix . $tablename), $table_list) === false) {
throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
}
}
}
}
}
}
return true;
} | php | function checkConfig()
{
//for joomla_int check to see if the source_url does not equal the default
try {
$db = Factory::getDatabase($this->getJname());
} catch (Exception $e) {
throw new RuntimeException(Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
}
try {
$jdb = Factory::getDBO();
} catch (Exception $e) {
throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
}
if (!$db->connected()) {
throw new RuntimeException(Text::_('NO_DATABASE'));
} elseif (!$jdb->connected()) {
throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE'));
} else {
//added check for missing files of copied plugins after upgrade
$admin = Factory::getAdmin($this->getJname());
$adminclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\Admin';
$user = Factory::getUser($this->getJname());
$userclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\User';
if (!$admin instanceof $adminclass) {
throw new RuntimeException(Text::_('NO_FILES') . ' '. $adminclass);
} else if (!$user instanceof $userclass) {
throw new RuntimeException(Text::_('NO_FILES') . ' '. $userclass);
} else {
$cookie_domain = $this->params->get('cookie_domain');
$jfc = Factory::getCookies();
list($url) = $jfc->getApiUrl($cookie_domain);
if ($url) {
$api = new Api($url, Factory::getParams('joomla_int')->get('secret'));
if (!$api->ping()) {
list ($message) = $api->getError();
throw new RuntimeException($api->url . ' ' . $message);
}
}
$source_path = $this->params->get('source_path');
if ($source_path && (strpos($source_path, 'http://') === 0 || strpos($source_path, 'https://') === 0)) {
throw new RuntimeException(Text::_('ERROR_SOURCE_PATH') . ' : ' . $source_path);
} else {
//get the user table name
$tablename = $this->getTablename();
// lets check if the table exists, now using the Joomla API
$table_list = $db->getTableList();
$table_prefix = $db->getPrefix();
if (!is_array($table_list)) {
throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
} else {
if (array_search($table_prefix . $tablename, $table_list) === false) {
//do a final check for case insensitive windows servers
if (array_search(strtolower($table_prefix . $tablename), $table_list) === false) {
throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
}
}
}
}
}
}
return true;
} | [
"function",
"checkConfig",
"(",
")",
"{",
"//for joomla_int check to see if the source_url does not equal the default",
"try",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDatabase",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'NO_DATABASE'",
")",
".",
"' : '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"try",
"{",
"$",
"jdb",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
".",
"' -> joomla_int '",
".",
"Text",
"::",
"_",
"(",
"'NO_DATABASE'",
")",
".",
"' : '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"db",
"->",
"connected",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'NO_DATABASE'",
")",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"jdb",
"->",
"connected",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
".",
"' -> joomla_int '",
".",
"Text",
"::",
"_",
"(",
"'NO_DATABASE'",
")",
")",
";",
"}",
"else",
"{",
"//added check for missing files of copied plugins after upgrade",
"$",
"admin",
"=",
"Factory",
"::",
"getAdmin",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
")",
";",
"$",
"adminclass",
"=",
"'JFusion\\\\Plugins\\\\'",
".",
"$",
"this",
"->",
"getJname",
"(",
")",
".",
"'\\\\Admin'",
";",
"$",
"user",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
")",
";",
"$",
"userclass",
"=",
"'JFusion\\\\Plugins\\\\'",
".",
"$",
"this",
"->",
"getJname",
"(",
")",
".",
"'\\\\User'",
";",
"if",
"(",
"!",
"$",
"admin",
"instanceof",
"$",
"adminclass",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'NO_FILES'",
")",
".",
"' '",
".",
"$",
"adminclass",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"user",
"instanceof",
"$",
"userclass",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'NO_FILES'",
")",
".",
"' '",
".",
"$",
"userclass",
")",
";",
"}",
"else",
"{",
"$",
"cookie_domain",
"=",
"$",
"this",
"->",
"params",
"->",
"get",
"(",
"'cookie_domain'",
")",
";",
"$",
"jfc",
"=",
"Factory",
"::",
"getCookies",
"(",
")",
";",
"list",
"(",
"$",
"url",
")",
"=",
"$",
"jfc",
"->",
"getApiUrl",
"(",
"$",
"cookie_domain",
")",
";",
"if",
"(",
"$",
"url",
")",
"{",
"$",
"api",
"=",
"new",
"Api",
"(",
"$",
"url",
",",
"Factory",
"::",
"getParams",
"(",
"'joomla_int'",
")",
"->",
"get",
"(",
"'secret'",
")",
")",
";",
"if",
"(",
"!",
"$",
"api",
"->",
"ping",
"(",
")",
")",
"{",
"list",
"(",
"$",
"message",
")",
"=",
"$",
"api",
"->",
"getError",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"api",
"->",
"url",
".",
"' '",
".",
"$",
"message",
")",
";",
"}",
"}",
"$",
"source_path",
"=",
"$",
"this",
"->",
"params",
"->",
"get",
"(",
"'source_path'",
")",
";",
"if",
"(",
"$",
"source_path",
"&&",
"(",
"strpos",
"(",
"$",
"source_path",
",",
"'http://'",
")",
"===",
"0",
"||",
"strpos",
"(",
"$",
"source_path",
",",
"'https://'",
")",
"===",
"0",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'ERROR_SOURCE_PATH'",
")",
".",
"' : '",
".",
"$",
"source_path",
")",
";",
"}",
"else",
"{",
"//get the user table name",
"$",
"tablename",
"=",
"$",
"this",
"->",
"getTablename",
"(",
")",
";",
"// lets check if the table exists, now using the Joomla API",
"$",
"table_list",
"=",
"$",
"db",
"->",
"getTableList",
"(",
")",
";",
"$",
"table_prefix",
"=",
"$",
"db",
"->",
"getPrefix",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"table_list",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"table_prefix",
".",
"$",
"tablename",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'NO_TABLE'",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"array_search",
"(",
"$",
"table_prefix",
".",
"$",
"tablename",
",",
"$",
"table_list",
")",
"===",
"false",
")",
"{",
"//do a final check for case insensitive windows servers",
"if",
"(",
"array_search",
"(",
"strtolower",
"(",
"$",
"table_prefix",
".",
"$",
"tablename",
")",
",",
"$",
"table_list",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"table_prefix",
".",
"$",
"tablename",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'NO_TABLE'",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Function that checks if the plugin has a valid config
@throws RuntimeException
@return boolean return true for success false for error, if you want a message to be included you need to use throw. | [
"Function",
"that",
"checks",
"if",
"the",
"plugin",
"has",
"a",
"valid",
"config"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L143-L208 |
jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.debugConfig | function debugConfig()
{
$jname = $this->getJname();
//get registration status
$new_registration = $this->allowRegistration();
if ($new_registration) {
$plugins = Framework::getSlaves();
foreach ($plugins as $plugin) {
if ($plugin->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('DISABLE_REGISTRATION'), $jname);
}
}
} else {
$master = Framework::getMaster();
if ($master && $master->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('ENABLE_REGISTRATION'), $jname);
}
}
//most dual login problems are due to incorrect cookie domain settings
//therefore we should check it and output a warning if needed.
$cookie_domain = $this->params->get('cookie_domain',-1);
if ($cookie_domain!==-1) {
$cookie_domain = str_replace(array('http://', 'https://'), array('', ''), $cookie_domain);
$correct_array = explode('.', html_entity_decode($_SERVER['SERVER_NAME']));
//check for domain names with double extentions
if (isset($correct_array[count($correct_array) - 2]) && isset($correct_array[count($correct_array) - 1])) {
//domain array
$domain_array = array('com', 'net', 'org', 'co', 'me');
if (in_array($correct_array[count($correct_array) - 2], $domain_array)) {
$correct_domain = '.' . $correct_array[count($correct_array) - 3] . '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
} else {
$correct_domain = '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
}
if ($correct_domain != $cookie_domain && !$this->allowEmptyCookieDomain()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_DOMAIN') . ' ' . $correct_domain, $jname);
}
}
}
//also check the cookie path as it can interfere with frameless
$cookie_path = $this->params->get('cookie_path',-1);
if ($cookie_path !== -1) {
if ($cookie_path != '/' && !$this->allowEmptyCookiePath()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_PATH') . ' /', $jname);
}
}
// allow additional checking of the configuration
$this->debugConfigExtra();
} | php | function debugConfig()
{
$jname = $this->getJname();
//get registration status
$new_registration = $this->allowRegistration();
if ($new_registration) {
$plugins = Framework::getSlaves();
foreach ($plugins as $plugin) {
if ($plugin->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('DISABLE_REGISTRATION'), $jname);
}
}
} else {
$master = Framework::getMaster();
if ($master && $master->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('ENABLE_REGISTRATION'), $jname);
}
}
//most dual login problems are due to incorrect cookie domain settings
//therefore we should check it and output a warning if needed.
$cookie_domain = $this->params->get('cookie_domain',-1);
if ($cookie_domain!==-1) {
$cookie_domain = str_replace(array('http://', 'https://'), array('', ''), $cookie_domain);
$correct_array = explode('.', html_entity_decode($_SERVER['SERVER_NAME']));
//check for domain names with double extentions
if (isset($correct_array[count($correct_array) - 2]) && isset($correct_array[count($correct_array) - 1])) {
//domain array
$domain_array = array('com', 'net', 'org', 'co', 'me');
if (in_array($correct_array[count($correct_array) - 2], $domain_array)) {
$correct_domain = '.' . $correct_array[count($correct_array) - 3] . '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
} else {
$correct_domain = '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
}
if ($correct_domain != $cookie_domain && !$this->allowEmptyCookieDomain()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_DOMAIN') . ' ' . $correct_domain, $jname);
}
}
}
//also check the cookie path as it can interfere with frameless
$cookie_path = $this->params->get('cookie_path',-1);
if ($cookie_path !== -1) {
if ($cookie_path != '/' && !$this->allowEmptyCookiePath()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_PATH') . ' /', $jname);
}
}
// allow additional checking of the configuration
$this->debugConfigExtra();
} | [
"function",
"debugConfig",
"(",
")",
"{",
"$",
"jname",
"=",
"$",
"this",
"->",
"getJname",
"(",
")",
";",
"//get registration status",
"$",
"new_registration",
"=",
"$",
"this",
"->",
"allowRegistration",
"(",
")",
";",
"if",
"(",
"$",
"new_registration",
")",
"{",
"$",
"plugins",
"=",
"Framework",
"::",
"getSlaves",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"name",
"==",
"$",
"jname",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'DISABLE_REGISTRATION'",
")",
",",
"$",
"jname",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"master",
"=",
"Framework",
"::",
"getMaster",
"(",
")",
";",
"if",
"(",
"$",
"master",
"&&",
"$",
"master",
"->",
"name",
"==",
"$",
"jname",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'ENABLE_REGISTRATION'",
")",
",",
"$",
"jname",
")",
";",
"}",
"}",
"//most dual login problems are due to incorrect cookie domain settings",
"//therefore we should check it and output a warning if needed.",
"$",
"cookie_domain",
"=",
"$",
"this",
"->",
"params",
"->",
"get",
"(",
"'cookie_domain'",
",",
"-",
"1",
")",
";",
"if",
"(",
"$",
"cookie_domain",
"!==",
"-",
"1",
")",
"{",
"$",
"cookie_domain",
"=",
"str_replace",
"(",
"array",
"(",
"'http://'",
",",
"'https://'",
")",
",",
"array",
"(",
"''",
",",
"''",
")",
",",
"$",
"cookie_domain",
")",
";",
"$",
"correct_array",
"=",
"explode",
"(",
"'.'",
",",
"html_entity_decode",
"(",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
")",
")",
";",
"//check for domain names with double extentions",
"if",
"(",
"isset",
"(",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
")",
"&&",
"isset",
"(",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"1",
"]",
")",
")",
"{",
"//domain array",
"$",
"domain_array",
"=",
"array",
"(",
"'com'",
",",
"'net'",
",",
"'org'",
",",
"'co'",
",",
"'me'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
",",
"$",
"domain_array",
")",
")",
"{",
"$",
"correct_domain",
"=",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"3",
"]",
".",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
".",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"correct_domain",
"=",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
".",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"1",
"]",
";",
"}",
"if",
"(",
"$",
"correct_domain",
"!=",
"$",
"cookie_domain",
"&&",
"!",
"$",
"this",
"->",
"allowEmptyCookieDomain",
"(",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'BEST_COOKIE_DOMAIN'",
")",
".",
"' '",
".",
"$",
"correct_domain",
",",
"$",
"jname",
")",
";",
"}",
"}",
"}",
"//also check the cookie path as it can interfere with frameless",
"$",
"cookie_path",
"=",
"$",
"this",
"->",
"params",
"->",
"get",
"(",
"'cookie_path'",
",",
"-",
"1",
")",
";",
"if",
"(",
"$",
"cookie_path",
"!==",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"cookie_path",
"!=",
"'/'",
"&&",
"!",
"$",
"this",
"->",
"allowEmptyCookiePath",
"(",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'BEST_COOKIE_PATH'",
")",
".",
"' /'",
",",
"$",
"jname",
")",
";",
"}",
"}",
"// allow additional checking of the configuration",
"$",
"this",
"->",
"debugConfigExtra",
"(",
")",
";",
"}"
] | Function that checks if the plugin has a valid config
jerror is used for output
@return void | [
"Function",
"that",
"checks",
"if",
"the",
"plugin",
"has",
"a",
"valid",
"config",
"jerror",
"is",
"used",
"for",
"output"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L234-L287 |
jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.readFile | function readFile($file)
{
$fh = @fopen($file, 'r');
$lines = false;
if ($fh !== false) {
$lines = array();
while (!feof($fh)) {
$lines[] = fgets($fh);
}
fclose($fh);
}
return $lines;
} | php | function readFile($file)
{
$fh = @fopen($file, 'r');
$lines = false;
if ($fh !== false) {
$lines = array();
while (!feof($fh)) {
$lines[] = fgets($fh);
}
fclose($fh);
}
return $lines;
} | [
"function",
"readFile",
"(",
"$",
"file",
")",
"{",
"$",
"fh",
"=",
"@",
"fopen",
"(",
"$",
"file",
",",
"'r'",
")",
";",
"$",
"lines",
"=",
"false",
";",
"if",
"(",
"$",
"fh",
"!==",
"false",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"fh",
")",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"fgets",
"(",
"$",
"fh",
")",
";",
"}",
"fclose",
"(",
"$",
"fh",
")",
";",
"}",
"return",
"$",
"lines",
";",
"}"
] | read a given file (use to read config files)
@param $file
@return bool|array returns false or file content | [
"read",
"a",
"given",
"file",
"(",
"use",
"to",
"read",
"config",
"files",
")"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L365-L378 |
jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.saveParameters | final public function saveParameters($post, $wizard = false)
{
$jname = $this->getJname();
$result = false;
try {
if (!empty($jname)) {
$db = Factory::getDBO();
if (isset($post['source_url'])) {
//check for trailing slash in URL, in order for us not to worry about it later
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
//now also check to see that the url starts with http:// or https://
if (substr($post['source_url'], 0, 7) != 'http://' && substr($post['source_url'], 0, 8) != 'https://') {
if (substr($post['source_url'], 0, 1) != '/') {
$post['source_url'] = 'http://' . $post['source_url'];
}
}
}
if (isset($post['source_path'])) {
if (!empty($post['source_path'])) {
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
if (!is_dir($post['source_path'])) {
Framework::raise(LogLevel::WARNING, Text::_('SOURCE_PATH_NOT_FOUND'));
}
}
}
if ($wizard) {
//data submitted by the wizard so merge the data with existing params if they do indeed exist
$query = $db->getQuery(true)
->select('params')
->from('#__jfusion')
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$params = $db->loadResult();
$params = new Registry($params);
$existing_params = $params->toArray();
if (is_array($existing_params)) {
$post = array_merge($existing_params, $post);
}
}
$data = new Registry($post);
//set the current parameters in the jfusion table
$query = $db->getQuery(true)
->update('#__jfusion')
->set('params = ' . $db->quote($data->toString()))
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$db->execute();
//reset the params instance for this plugin
Factory::getParams($jname, true);
$result = true;
}
} catch (Exception $e ) {
//there was an error saving the parameters
Framework::raise(LogLevel::ERROR, $e, $jname);
}
return $result;
} | php | final public function saveParameters($post, $wizard = false)
{
$jname = $this->getJname();
$result = false;
try {
if (!empty($jname)) {
$db = Factory::getDBO();
if (isset($post['source_url'])) {
//check for trailing slash in URL, in order for us not to worry about it later
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
//now also check to see that the url starts with http:// or https://
if (substr($post['source_url'], 0, 7) != 'http://' && substr($post['source_url'], 0, 8) != 'https://') {
if (substr($post['source_url'], 0, 1) != '/') {
$post['source_url'] = 'http://' . $post['source_url'];
}
}
}
if (isset($post['source_path'])) {
if (!empty($post['source_path'])) {
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
if (!is_dir($post['source_path'])) {
Framework::raise(LogLevel::WARNING, Text::_('SOURCE_PATH_NOT_FOUND'));
}
}
}
if ($wizard) {
//data submitted by the wizard so merge the data with existing params if they do indeed exist
$query = $db->getQuery(true)
->select('params')
->from('#__jfusion')
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$params = $db->loadResult();
$params = new Registry($params);
$existing_params = $params->toArray();
if (is_array($existing_params)) {
$post = array_merge($existing_params, $post);
}
}
$data = new Registry($post);
//set the current parameters in the jfusion table
$query = $db->getQuery(true)
->update('#__jfusion')
->set('params = ' . $db->quote($data->toString()))
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$db->execute();
//reset the params instance for this plugin
Factory::getParams($jname, true);
$result = true;
}
} catch (Exception $e ) {
//there was an error saving the parameters
Framework::raise(LogLevel::ERROR, $e, $jname);
}
return $result;
} | [
"final",
"public",
"function",
"saveParameters",
"(",
"$",
"post",
",",
"$",
"wizard",
"=",
"false",
")",
"{",
"$",
"jname",
"=",
"$",
"this",
"->",
"getJname",
"(",
")",
";",
"$",
"result",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"jname",
")",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
")",
")",
"{",
"//check for trailing slash in URL, in order for us not to worry about it later",
"$",
"post",
"[",
"'source_path'",
"]",
"=",
"rtrim",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
",",
"'/\\\\'",
")",
";",
"$",
"post",
"[",
"'source_path'",
"]",
".=",
"'/'",
";",
"//now also check to see that the url starts with http:// or https://",
"if",
"(",
"substr",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
",",
"0",
",",
"7",
")",
"!=",
"'http://'",
"&&",
"substr",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
",",
"0",
",",
"8",
")",
"!=",
"'https://'",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
",",
"0",
",",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"post",
"[",
"'source_url'",
"]",
"=",
"'http://'",
".",
"$",
"post",
"[",
"'source_url'",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
")",
")",
"{",
"$",
"post",
"[",
"'source_path'",
"]",
"=",
"rtrim",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
",",
"'/\\\\'",
")",
";",
"$",
"post",
"[",
"'source_path'",
"]",
".=",
"'/'",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"WARNING",
",",
"Text",
"::",
"_",
"(",
"'SOURCE_PATH_NOT_FOUND'",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"wizard",
")",
"{",
"//data submitted by the wizard so merge the data with existing params if they do indeed exist",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'params'",
")",
"->",
"from",
"(",
"'#__jfusion'",
")",
"->",
"where",
"(",
"'name = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"jname",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"params",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"$",
"params",
"=",
"new",
"Registry",
"(",
"$",
"params",
")",
";",
"$",
"existing_params",
"=",
"$",
"params",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"existing_params",
")",
")",
"{",
"$",
"post",
"=",
"array_merge",
"(",
"$",
"existing_params",
",",
"$",
"post",
")",
";",
"}",
"}",
"$",
"data",
"=",
"new",
"Registry",
"(",
"$",
"post",
")",
";",
"//set the current parameters in the jfusion table",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"update",
"(",
"'#__jfusion'",
")",
"->",
"set",
"(",
"'params = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"data",
"->",
"toString",
"(",
")",
")",
")",
"->",
"where",
"(",
"'name = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"jname",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"//reset the params instance for this plugin",
"Factory",
"::",
"getParams",
"(",
"$",
"jname",
",",
"true",
")",
";",
"$",
"result",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"//there was an error saving the parameters",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
",",
"$",
"jname",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Saves the posted JFusion component variables
@param array $post Array of JFusion plugin parameters posted to the JFusion component
@param boolean $wizard Notes if function was called by wizardresult();
@return boolean returns true if successful and false if an error occurred | [
"Saves",
"the",
"posted",
"JFusion",
"component",
"variables"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L402-L472 |
austinkregel/Warden | src/Warden/Warden.php | Warden.clearInput | public static function clearInput($input)
{
if (is_array($input)) {
foreach ($input as $key => $value) {
if (!isset($value) || $value === '') {
unset($input[$key]);
}
}
return $input;
}
return $input;
} | php | public static function clearInput($input)
{
if (is_array($input)) {
foreach ($input as $key => $value) {
if (!isset($value) || $value === '') {
unset($input[$key]);
}
}
return $input;
}
return $input;
} | [
"public",
"static",
"function",
"clearInput",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"===",
"''",
")",
"{",
"unset",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"input",
";",
"}",
"return",
"$",
"input",
";",
"}"
] | This will look through the input and remove any unset values.
@param $input
@return mixed | [
"This",
"will",
"look",
"through",
"the",
"input",
"and",
"remove",
"any",
"unset",
"values",
"."
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Warden.php#L16-L29 |
austinkregel/Warden | src/Warden/Warden.php | Warden.apiRoutes | public static function apiRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route').'/api/v1.0',
'as' => 'warden::api.',
'middleware' => config('kregel.warden.auth.middleware_api'),
], function ($router) {
Route::get('media/{model}/{uuid}', ['as' => 'media', 'uses' => 'ApiController@displayMediaPage']);
// Should retrieve almost all items...
Route::get('{model}s', ['as' => 'get-all', 'uses' => 'ApiController@getAllModels']);
// Should retrieve some items...
Route::get('{model}', ['as' => 'get-models', 'uses' => 'ApiController@getSomeModels']);
// Should get an item...
Route::get('{model}/{id}', ['as' => 'get-model', 'uses' => 'ApiController@findModel']);
// Should create a model using /warden/api/v1.0/user/
Route::post('{model}', ['as' => 'create-model', 'uses' => 'ApiController@postModel']);
// Should update a model.
Route::post('{model}/{id}', ['as' => 'update-model-post', 'uses' => 'ApiController@putModel']);
Route::put('{model}/{id}', ['as' => 'update-model', 'uses' => 'ApiController@putModel']);
// Should delete a model.
Route::delete('d/{model}/{id}', ['as' => 'delete-model', 'uses' => 'ApiController@deleteModel']);
});
} | php | public static function apiRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route').'/api/v1.0',
'as' => 'warden::api.',
'middleware' => config('kregel.warden.auth.middleware_api'),
], function ($router) {
Route::get('media/{model}/{uuid}', ['as' => 'media', 'uses' => 'ApiController@displayMediaPage']);
// Should retrieve almost all items...
Route::get('{model}s', ['as' => 'get-all', 'uses' => 'ApiController@getAllModels']);
// Should retrieve some items...
Route::get('{model}', ['as' => 'get-models', 'uses' => 'ApiController@getSomeModels']);
// Should get an item...
Route::get('{model}/{id}', ['as' => 'get-model', 'uses' => 'ApiController@findModel']);
// Should create a model using /warden/api/v1.0/user/
Route::post('{model}', ['as' => 'create-model', 'uses' => 'ApiController@postModel']);
// Should update a model.
Route::post('{model}/{id}', ['as' => 'update-model-post', 'uses' => 'ApiController@putModel']);
Route::put('{model}/{id}', ['as' => 'update-model', 'uses' => 'ApiController@putModel']);
// Should delete a model.
Route::delete('d/{model}/{id}', ['as' => 'delete-model', 'uses' => 'ApiController@deleteModel']);
});
} | [
"public",
"static",
"function",
"apiRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'namespace'",
"=>",
"'Kregel\\\\Warden\\\\Http\\\\Controllers'",
",",
"'prefix'",
"=>",
"config",
"(",
"'kregel.warden.route'",
")",
".",
"'/api/v1.0'",
",",
"'as'",
"=>",
"'warden::api.'",
",",
"'middleware'",
"=>",
"config",
"(",
"'kregel.warden.auth.middleware_api'",
")",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"Route",
"::",
"get",
"(",
"'media/{model}/{uuid}'",
",",
"[",
"'as'",
"=>",
"'media'",
",",
"'uses'",
"=>",
"'ApiController@displayMediaPage'",
"]",
")",
";",
"// Should retrieve almost all items...",
"Route",
"::",
"get",
"(",
"'{model}s'",
",",
"[",
"'as'",
"=>",
"'get-all'",
",",
"'uses'",
"=>",
"'ApiController@getAllModels'",
"]",
")",
";",
"// Should retrieve some items...",
"Route",
"::",
"get",
"(",
"'{model}'",
",",
"[",
"'as'",
"=>",
"'get-models'",
",",
"'uses'",
"=>",
"'ApiController@getSomeModels'",
"]",
")",
";",
"// Should get an item...",
"Route",
"::",
"get",
"(",
"'{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'get-model'",
",",
"'uses'",
"=>",
"'ApiController@findModel'",
"]",
")",
";",
"// Should create a model using /warden/api/v1.0/user/",
"Route",
"::",
"post",
"(",
"'{model}'",
",",
"[",
"'as'",
"=>",
"'create-model'",
",",
"'uses'",
"=>",
"'ApiController@postModel'",
"]",
")",
";",
"// Should update a model.",
"Route",
"::",
"post",
"(",
"'{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'update-model-post'",
",",
"'uses'",
"=>",
"'ApiController@putModel'",
"]",
")",
";",
"Route",
"::",
"put",
"(",
"'{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'update-model'",
",",
"'uses'",
"=>",
"'ApiController@putModel'",
"]",
")",
";",
"// Should delete a model.",
"Route",
"::",
"delete",
"(",
"'d/{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'delete-model'",
",",
"'uses'",
"=>",
"'ApiController@deleteModel'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Define the api routes more dynamically. | [
"Define",
"the",
"api",
"routes",
"more",
"dynamically",
"."
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Warden.php#L45-L71 |
austinkregel/Warden | src/Warden/Warden.php | Warden.webRoutes | public static function webRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route'),
'as' => 'warden::',
'middleware' => config('kregel.warden.auth.middleware'),
], function ($router) {
Route::get('/', function () {
return view('warden::base');
});
Route::get('{model}/manage/new', ['as' => 'new-model', 'uses' => 'ModelController@getNewModel']);
Route::get('{model}s/manage', ['as' => 'models', 'uses' => 'ModelController@getModelList']);
Route::get('{model}/manage/{id}', ['as' => 'model', 'uses' => 'ModelController@getModel']);
});
} | php | public static function webRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route'),
'as' => 'warden::',
'middleware' => config('kregel.warden.auth.middleware'),
], function ($router) {
Route::get('/', function () {
return view('warden::base');
});
Route::get('{model}/manage/new', ['as' => 'new-model', 'uses' => 'ModelController@getNewModel']);
Route::get('{model}s/manage', ['as' => 'models', 'uses' => 'ModelController@getModelList']);
Route::get('{model}/manage/{id}', ['as' => 'model', 'uses' => 'ModelController@getModel']);
});
} | [
"public",
"static",
"function",
"webRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'namespace'",
"=>",
"'Kregel\\\\Warden\\\\Http\\\\Controllers'",
",",
"'prefix'",
"=>",
"config",
"(",
"'kregel.warden.route'",
")",
",",
"'as'",
"=>",
"'warden::'",
",",
"'middleware'",
"=>",
"config",
"(",
"'kregel.warden.auth.middleware'",
")",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"Route",
"::",
"get",
"(",
"'/'",
",",
"function",
"(",
")",
"{",
"return",
"view",
"(",
"'warden::base'",
")",
";",
"}",
")",
";",
"Route",
"::",
"get",
"(",
"'{model}/manage/new'",
",",
"[",
"'as'",
"=>",
"'new-model'",
",",
"'uses'",
"=>",
"'ModelController@getNewModel'",
"]",
")",
";",
"Route",
"::",
"get",
"(",
"'{model}s/manage'",
",",
"[",
"'as'",
"=>",
"'models'",
",",
"'uses'",
"=>",
"'ModelController@getModelList'",
"]",
")",
";",
"Route",
"::",
"get",
"(",
"'{model}/manage/{id}'",
",",
"[",
"'as'",
"=>",
"'model'",
",",
"'uses'",
"=>",
"'ModelController@getModel'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Define the web routes more dynamically. | [
"Define",
"the",
"web",
"routes",
"more",
"dynamically",
"."
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Warden.php#L76-L92 |
ARCANEDEV/Agent | src/AgentServiceProvider.php | AgentServiceProvider.register | public function register()
{
parent::register();
$this->singleton(Contracts\Agent::class, function ($app) {
/** @var \Illuminate\Http\Request $request */
$request = $app['request'];
return new Agent($request->server->all());
});
} | php | public function register()
{
parent::register();
$this->singleton(Contracts\Agent::class, function ($app) {
/** @var \Illuminate\Http\Request $request */
$request = $app['request'];
return new Agent($request->server->all());
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"parent",
"::",
"register",
"(",
")",
";",
"$",
"this",
"->",
"singleton",
"(",
"Contracts",
"\\",
"Agent",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"/** @var \\Illuminate\\Http\\Request $request */",
"$",
"request",
"=",
"$",
"app",
"[",
"'request'",
"]",
";",
"return",
"new",
"Agent",
"(",
"$",
"request",
"->",
"server",
"->",
"all",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] | Register the service provider. | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/AgentServiceProvider.php#L33-L43 |
Double-Opt-in/php-client-api | src/Client/Commands/Responses/Models/Action.php | Action.createFromStdClass | public static function createFromStdClass(stdClass $class)
{
$hash = isset($class->hash) ? $class->hash : null;
$scope = isset($class->scope) ? $class->scope : null;
$action = isset($class->action) ? $class->action : null;
$data = isset($class->data) ? $class->data : null;
$state = isset($class->state) ? $class->state : null;
$ip = isset($class->ip) ? $class->ip : null;
$useragent = isset($class->useragent) ? $class->useragent : null;
$createdAt = isset($class->created_at) ? $class->created_at : null;
return new Action($hash, $scope, $action, $data, $state, $ip, $useragent, $createdAt);
} | php | public static function createFromStdClass(stdClass $class)
{
$hash = isset($class->hash) ? $class->hash : null;
$scope = isset($class->scope) ? $class->scope : null;
$action = isset($class->action) ? $class->action : null;
$data = isset($class->data) ? $class->data : null;
$state = isset($class->state) ? $class->state : null;
$ip = isset($class->ip) ? $class->ip : null;
$useragent = isset($class->useragent) ? $class->useragent : null;
$createdAt = isset($class->created_at) ? $class->created_at : null;
return new Action($hash, $scope, $action, $data, $state, $ip, $useragent, $createdAt);
} | [
"public",
"static",
"function",
"createFromStdClass",
"(",
"stdClass",
"$",
"class",
")",
"{",
"$",
"hash",
"=",
"isset",
"(",
"$",
"class",
"->",
"hash",
")",
"?",
"$",
"class",
"->",
"hash",
":",
"null",
";",
"$",
"scope",
"=",
"isset",
"(",
"$",
"class",
"->",
"scope",
")",
"?",
"$",
"class",
"->",
"scope",
":",
"null",
";",
"$",
"action",
"=",
"isset",
"(",
"$",
"class",
"->",
"action",
")",
"?",
"$",
"class",
"->",
"action",
":",
"null",
";",
"$",
"data",
"=",
"isset",
"(",
"$",
"class",
"->",
"data",
")",
"?",
"$",
"class",
"->",
"data",
":",
"null",
";",
"$",
"state",
"=",
"isset",
"(",
"$",
"class",
"->",
"state",
")",
"?",
"$",
"class",
"->",
"state",
":",
"null",
";",
"$",
"ip",
"=",
"isset",
"(",
"$",
"class",
"->",
"ip",
")",
"?",
"$",
"class",
"->",
"ip",
":",
"null",
";",
"$",
"useragent",
"=",
"isset",
"(",
"$",
"class",
"->",
"useragent",
")",
"?",
"$",
"class",
"->",
"useragent",
":",
"null",
";",
"$",
"createdAt",
"=",
"isset",
"(",
"$",
"class",
"->",
"created_at",
")",
"?",
"$",
"class",
"->",
"created_at",
":",
"null",
";",
"return",
"new",
"Action",
"(",
"$",
"hash",
",",
"$",
"scope",
",",
"$",
"action",
",",
"$",
"data",
",",
"$",
"state",
",",
"$",
"ip",
",",
"$",
"useragent",
",",
"$",
"createdAt",
")",
";",
"}"
] | creates from a stdClass
@param stdClass $class
@return \DoubleOptIn\ClientApi\Client\Commands\Responses\Models\Action | [
"creates",
"from",
"a",
"stdClass"
] | train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Models/Action.php#L99-L111 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.register | public static function register($useZepto = false, $ie8Support = false)
{
static::registerCoreCss();
static::registerCoreScripts($useZepto);
if ($ie8Support)
static::registerBlockGridIeSupport();
} | php | public static function register($useZepto = false, $ie8Support = false)
{
static::registerCoreCss();
static::registerCoreScripts($useZepto);
if ($ie8Support)
static::registerBlockGridIeSupport();
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"useZepto",
"=",
"false",
",",
"$",
"ie8Support",
"=",
"false",
")",
"{",
"static",
"::",
"registerCoreCss",
"(",
")",
";",
"static",
"::",
"registerCoreScripts",
"(",
"$",
"useZepto",
")",
";",
"if",
"(",
"$",
"ie8Support",
")",
"static",
"::",
"registerBlockGridIeSupport",
"(",
")",
";",
"}"
] | Registers all core css and js scripts for foundation | [
"Registers",
"all",
"core",
"css",
"and",
"js",
"scripts",
"for",
"foundation"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L27-L34 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerCoreScripts | public static function registerCoreScripts(
$useZepto = false,
$minimized = true,
$position = \CClientScript::POS_END
) {
/** @var CClientScript $cs */
$cs = \Yii::app()->getClientScript();
if ($useZepto) {
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/zepto.js');
} else {
$cs->registerCoreScript('jquery');
}
// normalizer goes at the head no matter what
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/custom.modernizr.js', \CClientScript::POS_HEAD);
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
$cs->registerScriptFile(static::getAssetsUrl() . $script, $position);
$cs->registerScript(__CLASS__, '$(document).foundation();');
} | php | public static function registerCoreScripts(
$useZepto = false,
$minimized = true,
$position = \CClientScript::POS_END
) {
/** @var CClientScript $cs */
$cs = \Yii::app()->getClientScript();
if ($useZepto) {
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/zepto.js');
} else {
$cs->registerCoreScript('jquery');
}
// normalizer goes at the head no matter what
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/custom.modernizr.js', \CClientScript::POS_HEAD);
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
$cs->registerScriptFile(static::getAssetsUrl() . $script, $position);
$cs->registerScript(__CLASS__, '$(document).foundation();');
} | [
"public",
"static",
"function",
"registerCoreScripts",
"(",
"$",
"useZepto",
"=",
"false",
",",
"$",
"minimized",
"=",
"true",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"/** @var CClientScript $cs */",
"$",
"cs",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"getClientScript",
"(",
")",
";",
"if",
"(",
"$",
"useZepto",
")",
"{",
"$",
"cs",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/js/vendor/zepto.js'",
")",
";",
"}",
"else",
"{",
"$",
"cs",
"->",
"registerCoreScript",
"(",
"'jquery'",
")",
";",
"}",
"// normalizer goes at the head no matter what",
"$",
"cs",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/js/vendor/custom.modernizr.js'",
",",
"\\",
"CClientScript",
"::",
"POS_HEAD",
")",
";",
"$",
"script",
"=",
"$",
"minimized",
"?",
"'/js/foundation.min.js'",
":",
"'/js/foundation/foundation.js'",
";",
"$",
"cs",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"$",
"script",
",",
"$",
"position",
")",
";",
"$",
"cs",
"->",
"registerScript",
"(",
"__CLASS__",
",",
"'$(document).foundation();'",
")",
";",
"}"
] | Registers jQuery and Foundation JavaScript.
@param bool $useZepto whether to use zepto or not
@param bool $minimized whether to register full minimized library or not
@param int $position the position to register the core script | [
"Registers",
"jQuery",
"and",
"Foundation",
"JavaScript",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L42-L62 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.isCoreRegistered | public static function isCoreRegistered($minimized = true, $position = \CClientScript::POS_END)
{
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
return \Yii::app()->getClientScript()
->isScriptFileRegistered(static::getAssetsUrl() . $script, $position);
} | php | public static function isCoreRegistered($minimized = true, $position = \CClientScript::POS_END)
{
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
return \Yii::app()->getClientScript()
->isScriptFileRegistered(static::getAssetsUrl() . $script, $position);
} | [
"public",
"static",
"function",
"isCoreRegistered",
"(",
"$",
"minimized",
"=",
"true",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"$",
"script",
"=",
"$",
"minimized",
"?",
"'/js/foundation.min.js'",
":",
"'/js/foundation/foundation.js'",
";",
"return",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"getClientScript",
"(",
")",
"->",
"isScriptFileRegistered",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"$",
"script",
",",
"$",
"position",
")",
";",
"}"
] | Checks whether the core script has been registered or not
@param bool $minimized whether to check full minimized library or not
@param int $position the position to register the core script
@return bool | [
"Checks",
"whether",
"the",
"core",
"script",
"has",
"been",
"registered",
"or",
"not"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L70-L78 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerFonts | public static function registerFonts($fonts = array())
{
if (empty($fonts))
return;
foreach ($fonts as $font) {
Icon::registerIconFontSet($font);
}
} | php | public static function registerFonts($fonts = array())
{
if (empty($fonts))
return;
foreach ($fonts as $font) {
Icon::registerIconFontSet($font);
}
} | [
"public",
"static",
"function",
"registerFonts",
"(",
"$",
"fonts",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"fonts",
")",
")",
"return",
";",
"foreach",
"(",
"$",
"fonts",
"as",
"$",
"font",
")",
"{",
"Icon",
"::",
"registerIconFontSet",
"(",
"$",
"font",
")",
";",
"}",
"}"
] | Registers foundation fonts
@param mixed $fonts the array or string name to register. | [
"Registers",
"foundation",
"fonts"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L84-L92 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerCoreCss | public static function registerCoreCss()
{
$fileName = \YII_DEBUG ? 'foundation.css' : 'foundation.min.css';
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/normalize.css');
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/' . $fileName);
} | php | public static function registerCoreCss()
{
$fileName = \YII_DEBUG ? 'foundation.css' : 'foundation.min.css';
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/normalize.css');
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/' . $fileName);
} | [
"public",
"static",
"function",
"registerCoreCss",
"(",
")",
"{",
"$",
"fileName",
"=",
"\\",
"YII_DEBUG",
"?",
"'foundation.css'",
":",
"'foundation.min.css'",
";",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerCssFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/css/normalize.css'",
")",
";",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerCssFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/css/'",
".",
"$",
"fileName",
")",
";",
"}"
] | Registers the Foundation CSS. | [
"Registers",
"the",
"Foundation",
"CSS",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L97-L103 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.getAssetsUrl | public static function getAssetsUrl($forceCopyAssets = false, $cdn = false)
{
if (!isset(static::$assetsUrl)) {
if ($cdn) {
static::$assetsUrl = '//cdn.jsdelivr.net/foundation/4.3.1/';
} else {
$assetsPath = static::getAssetsPath();
static::$assetsUrl = \Yii::app()->assetManager->publish($assetsPath, true, -1, $forceCopyAssets);
}
}
return static::$assetsUrl;
} | php | public static function getAssetsUrl($forceCopyAssets = false, $cdn = false)
{
if (!isset(static::$assetsUrl)) {
if ($cdn) {
static::$assetsUrl = '//cdn.jsdelivr.net/foundation/4.3.1/';
} else {
$assetsPath = static::getAssetsPath();
static::$assetsUrl = \Yii::app()->assetManager->publish($assetsPath, true, -1, $forceCopyAssets);
}
}
return static::$assetsUrl;
} | [
"public",
"static",
"function",
"getAssetsUrl",
"(",
"$",
"forceCopyAssets",
"=",
"false",
",",
"$",
"cdn",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"assetsUrl",
")",
")",
"{",
"if",
"(",
"$",
"cdn",
")",
"{",
"static",
"::",
"$",
"assetsUrl",
"=",
"'//cdn.jsdelivr.net/foundation/4.3.1/'",
";",
"}",
"else",
"{",
"$",
"assetsPath",
"=",
"static",
"::",
"getAssetsPath",
"(",
")",
";",
"static",
"::",
"$",
"assetsUrl",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"assetManager",
"->",
"publish",
"(",
"$",
"assetsPath",
",",
"true",
",",
"-",
"1",
",",
"$",
"forceCopyAssets",
")",
";",
"}",
"}",
"return",
"static",
"::",
"$",
"assetsUrl",
";",
"}"
] | Returns the url to the published assets folder.
@param bool $forceCopyAssets whether to force assets registration or not
@param bool $cdn whether to use CDN version or not
@return string the url. | [
"Returns",
"the",
"url",
"to",
"the",
"published",
"assets",
"folder",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L111-L122 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerPlugin | public static function registerPlugin($name, $selector, $options = array(), $position = \CClientScript::POS_READY)
{
$options = !empty($options) ? \CJavaScript::encode($options) : '';
$script = ";jQuery('{$selector}').{$name}({$options});";
\Yii::app()->clientScript->registerScript(static::getUniqueScriptId(), $script, $position);
} | php | public static function registerPlugin($name, $selector, $options = array(), $position = \CClientScript::POS_READY)
{
$options = !empty($options) ? \CJavaScript::encode($options) : '';
$script = ";jQuery('{$selector}').{$name}({$options});";
\Yii::app()->clientScript->registerScript(static::getUniqueScriptId(), $script, $position);
} | [
"public",
"static",
"function",
"registerPlugin",
"(",
"$",
"name",
",",
"$",
"selector",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_READY",
")",
"{",
"$",
"options",
"=",
"!",
"empty",
"(",
"$",
"options",
")",
"?",
"\\",
"CJavaScript",
"::",
"encode",
"(",
"$",
"options",
")",
":",
"''",
";",
"$",
"script",
"=",
"\";jQuery('{$selector}').{$name}({$options});\"",
";",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerScript",
"(",
"static",
"::",
"getUniqueScriptId",
"(",
")",
",",
"$",
"script",
",",
"$",
"position",
")",
";",
"}"
] | Registers a specific plugin using the given selector and options.
@param string $name the plugin name.
@param string $selector the CSS selector.
@param array $options the JavaScript options for the plugin.
@param int $position the position of the JavaScript code. | [
"Registers",
"a",
"specific",
"plugin",
"using",
"the",
"given",
"selector",
"and",
"options",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L140-L145 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerScriptFile | public static function registerScriptFile($asset, $position = \CClientScript::POS_END)
{
\Yii::app()->clientScript->registerScriptFile(static::getAssetsUrl() . "/{$asset}", $position);
} | php | public static function registerScriptFile($asset, $position = \CClientScript::POS_END)
{
\Yii::app()->clientScript->registerScriptFile(static::getAssetsUrl() . "/{$asset}", $position);
} | [
"public",
"static",
"function",
"registerScriptFile",
"(",
"$",
"asset",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"\"/{$asset}\"",
",",
"$",
"position",
")",
";",
"}"
] | Registers a specific js assets file
@param string $asset the assets file (ie 'foundation/foundation.abide.js'
@param int $position the position where the script should be registered on the page | [
"Registers",
"a",
"specific",
"js",
"assets",
"file"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L152-L155 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerEvents | public static function registerEvents($selector, $events, $position = \CClientScript::POS_READY)
{
if (empty($events)) {
return;
}
$script = '';
foreach ($events as $name => $handler) {
$handler = ($handler instanceof \CJavaScriptExpression)
? $handler
: new \CJavaScriptExpression($handler);
$script .= ";jQuery('{$selector}').on('{$name}', {$handler});";
}
\Yii::app()->clientScript->registerScript(static::getUniqueScriptId(), $script, $position);
} | php | public static function registerEvents($selector, $events, $position = \CClientScript::POS_READY)
{
if (empty($events)) {
return;
}
$script = '';
foreach ($events as $name => $handler) {
$handler = ($handler instanceof \CJavaScriptExpression)
? $handler
: new \CJavaScriptExpression($handler);
$script .= ";jQuery('{$selector}').on('{$name}', {$handler});";
}
\Yii::app()->clientScript->registerScript(static::getUniqueScriptId(), $script, $position);
} | [
"public",
"static",
"function",
"registerEvents",
"(",
"$",
"selector",
",",
"$",
"events",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_READY",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"events",
")",
")",
"{",
"return",
";",
"}",
"$",
"script",
"=",
"''",
";",
"foreach",
"(",
"$",
"events",
"as",
"$",
"name",
"=>",
"$",
"handler",
")",
"{",
"$",
"handler",
"=",
"(",
"$",
"handler",
"instanceof",
"\\",
"CJavaScriptExpression",
")",
"?",
"$",
"handler",
":",
"new",
"\\",
"CJavaScriptExpression",
"(",
"$",
"handler",
")",
";",
"$",
"script",
".=",
"\";jQuery('{$selector}').on('{$name}', {$handler});\"",
";",
"}",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerScript",
"(",
"static",
"::",
"getUniqueScriptId",
"(",
")",
",",
"$",
"script",
",",
"$",
"position",
")",
";",
"}"
] | Registers events using the given selector.
@param string $selector the CSS selector.
@param string[] $events the JavaScript event configuration (name=>handler).
@param int $position the position of the JavaScript code. | [
"Registers",
"events",
"using",
"the",
"given",
"selector",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L163-L178 |
2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerBlockGridIeSupport | public static function registerBlockGridIeSupport($position = \CClientScript::POS_END)
{
\Yii::app()->getClientScript()
->registerScript(
__CLASS__,
"(function($){ $(function(){
$('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});
$('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});
$('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});
$('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});
});})(jQuery);
",
$position
);
} | php | public static function registerBlockGridIeSupport($position = \CClientScript::POS_END)
{
\Yii::app()->getClientScript()
->registerScript(
__CLASS__,
"(function($){ $(function(){
$('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});
$('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});
$('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});
$('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});
});})(jQuery);
",
$position
);
} | [
"public",
"static",
"function",
"registerBlockGridIeSupport",
"(",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"getClientScript",
"(",
")",
"->",
"registerScript",
"(",
"__CLASS__",
",",
"\"(function($){ $(function(){\n $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});\n $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});\n $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});\n $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});\n });})(jQuery);\n \"",
",",
"$",
"position",
")",
";",
"}"
] | Registers block-grid support for ie8 if set by its `ie8Support` attribute.
@param int $position the position to render the script | [
"Registers",
"block",
"-",
"grid",
"support",
"for",
"ie8",
"if",
"set",
"by",
"its",
"ie8Support",
"attribute",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L193-L207 |
titon/db | src/Titon/Db/Query/SubQuery.php | SubQuery.withFilter | public function withFilter($filter) {
if (!in_array($filter, [self::ALL, self::ANY, self::SOME, self::EXISTS, self::NOT_EXISTS, self::IN, self::NOT_IN], true)) {
throw new InvalidArgumentException('Invalid filter type for sub-query');
}
$this->_filter = $filter;
return $this;
} | php | public function withFilter($filter) {
if (!in_array($filter, [self::ALL, self::ANY, self::SOME, self::EXISTS, self::NOT_EXISTS, self::IN, self::NOT_IN], true)) {
throw new InvalidArgumentException('Invalid filter type for sub-query');
}
$this->_filter = $filter;
return $this;
} | [
"public",
"function",
"withFilter",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"filter",
",",
"[",
"self",
"::",
"ALL",
",",
"self",
"::",
"ANY",
",",
"self",
"::",
"SOME",
",",
"self",
"::",
"EXISTS",
",",
"self",
"::",
"NOT_EXISTS",
",",
"self",
"::",
"IN",
",",
"self",
"::",
"NOT_IN",
"]",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid filter type for sub-query'",
")",
";",
"}",
"$",
"this",
"->",
"_filter",
"=",
"$",
"filter",
";",
"return",
"$",
"this",
";",
"}"
] | Set the filter type.
@param string $filter
@return $this
@throws \Titon\Db\Exception\InvalidArgumentException | [
"Set",
"the",
"filter",
"type",
"."
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/SubQuery.php#L53-L61 |
lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.setVariants | public function setVariants(Collection $variants)
{
foreach ($variants as $variant) {
$this->addVariant($variant);
}
return $this;
} | php | public function setVariants(Collection $variants)
{
foreach ($variants as $variant) {
$this->addVariant($variant);
}
return $this;
} | [
"public",
"function",
"setVariants",
"(",
"Collection",
"$",
"variants",
")",
"{",
"foreach",
"(",
"$",
"variants",
"as",
"$",
"variant",
")",
"{",
"$",
"this",
"->",
"addVariant",
"(",
"$",
"variant",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set variants
@param Collection $variants
@return $this | [
"Set",
"variants"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L51-L58 |
lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.setMasterVariant | public function setMasterVariant(VariantInterface $masterVariant)
{
$masterVariant->setMaster(true);
/** @var VariantInterface $variant */
foreach ($this->variants as $variant) {
if ($variant->isMaster() && $variant !== $masterVariant) {
$variant->setMaster(false);
}
}
if (!$this->variants->contains($masterVariant)) {
$masterVariant->setObject($this);
$this->variants->add($masterVariant);
}
return $this;
} | php | public function setMasterVariant(VariantInterface $masterVariant)
{
$masterVariant->setMaster(true);
/** @var VariantInterface $variant */
foreach ($this->variants as $variant) {
if ($variant->isMaster() && $variant !== $masterVariant) {
$variant->setMaster(false);
}
}
if (!$this->variants->contains($masterVariant)) {
$masterVariant->setObject($this);
$this->variants->add($masterVariant);
}
return $this;
} | [
"public",
"function",
"setMasterVariant",
"(",
"VariantInterface",
"$",
"masterVariant",
")",
"{",
"$",
"masterVariant",
"->",
"setMaster",
"(",
"true",
")",
";",
"/** @var VariantInterface $variant */",
"foreach",
"(",
"$",
"this",
"->",
"variants",
"as",
"$",
"variant",
")",
"{",
"if",
"(",
"$",
"variant",
"->",
"isMaster",
"(",
")",
"&&",
"$",
"variant",
"!==",
"$",
"masterVariant",
")",
"{",
"$",
"variant",
"->",
"setMaster",
"(",
"false",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"variants",
"->",
"contains",
"(",
"$",
"masterVariant",
")",
")",
"{",
"$",
"masterVariant",
"->",
"setObject",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"variants",
"->",
"add",
"(",
"$",
"masterVariant",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the master variant
@param VariantInterface $masterVariant
@return $this | [
"Set",
"the",
"master",
"variant"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L84-L101 |
lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.addVariant | public function addVariant(VariantInterface $variant)
{
if (!$this->hasVariant($variant)) {
$variant->setObject($this);
$this->variants->add($variant);
}
return $this;
} | php | public function addVariant(VariantInterface $variant)
{
if (!$this->hasVariant($variant)) {
$variant->setObject($this);
$this->variants->add($variant);
}
return $this;
} | [
"public",
"function",
"addVariant",
"(",
"VariantInterface",
"$",
"variant",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVariant",
"(",
"$",
"variant",
")",
")",
"{",
"$",
"variant",
"->",
"setObject",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"variants",
"->",
"add",
"(",
"$",
"variant",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a variant
@param VariantInterface $variant
@return $this | [
"Adds",
"a",
"variant"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L120-L128 |
lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.removeVariant | public function removeVariant(VariantInterface $variant)
{
if ($this->hasVariant($variant)) {
$variant->setObject(null);
$this->variants->removeElement($variant);
}
return $this;
} | php | public function removeVariant(VariantInterface $variant)
{
if ($this->hasVariant($variant)) {
$variant->setObject(null);
$this->variants->removeElement($variant);
}
return $this;
} | [
"public",
"function",
"removeVariant",
"(",
"VariantInterface",
"$",
"variant",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasVariant",
"(",
"$",
"variant",
")",
")",
"{",
"$",
"variant",
"->",
"setObject",
"(",
"null",
")",
";",
"$",
"this",
"->",
"variants",
"->",
"removeElement",
"(",
"$",
"variant",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a variant
@param VariantInterface $variant
@return $this | [
"Removes",
"a",
"variant"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L137-L145 |
lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.setVariabilityOptions | public function setVariabilityOptions(Collection $variabilityOptions)
{
foreach ($variabilityOptions as $variabilityOption) {
$this->addVariabilityOption($variabilityOption);
}
return $this;
} | php | public function setVariabilityOptions(Collection $variabilityOptions)
{
foreach ($variabilityOptions as $variabilityOption) {
$this->addVariabilityOption($variabilityOption);
}
return $this;
} | [
"public",
"function",
"setVariabilityOptions",
"(",
"Collection",
"$",
"variabilityOptions",
")",
"{",
"foreach",
"(",
"$",
"variabilityOptions",
"as",
"$",
"variabilityOption",
")",
"{",
"$",
"this",
"->",
"addVariabilityOption",
"(",
"$",
"variabilityOption",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets all variability options
@param Collection $variabilityOptions
@return $this | [
"Sets",
"all",
"variability",
"options"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L186-L193 |
lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.addVariabilityOption | public function addVariabilityOption(OptionInterface $variabilityOption)
{
if (!$this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->add($variabilityOption);
}
return $this;
} | php | public function addVariabilityOption(OptionInterface $variabilityOption)
{
if (!$this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->add($variabilityOption);
}
return $this;
} | [
"public",
"function",
"addVariabilityOption",
"(",
"OptionInterface",
"$",
"variabilityOption",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVariabilityOption",
"(",
"$",
"variabilityOption",
")",
")",
"{",
"$",
"this",
"->",
"variabilityOptions",
"->",
"add",
"(",
"$",
"variabilityOption",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a given variability option
@param OptionInterface $variabilityOption
@return $this | [
"Adds",
"a",
"given",
"variability",
"option"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L202-L209 |
lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.removeVariabilityOption | public function removeVariabilityOption(OptionInterface $variabilityOption)
{
if ($this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->removeElement($variabilityOption);
}
return $this;
} | php | public function removeVariabilityOption(OptionInterface $variabilityOption)
{
if ($this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->removeElement($variabilityOption);
}
return $this;
} | [
"public",
"function",
"removeVariabilityOption",
"(",
"OptionInterface",
"$",
"variabilityOption",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasVariabilityOption",
"(",
"$",
"variabilityOption",
")",
")",
"{",
"$",
"this",
"->",
"variabilityOptions",
"->",
"removeElement",
"(",
"$",
"variabilityOption",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a given variability option
@param OptionInterface $variabilityOption
@return $this | [
"Removes",
"a",
"given",
"variability",
"option"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L218-L225 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php | EzPlatformAdapter.setLogger | public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
$this->objectService->setLogger($logger);
$this->treeService->setLogger($logger);
} | php | public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
$this->objectService->setLogger($logger);
$this->treeService->setLogger($logger);
} | [
"public",
"function",
"setLogger",
"(",
"LoggerInterface",
"$",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"=",
"$",
"logger",
";",
"$",
"this",
"->",
"objectService",
"->",
"setLogger",
"(",
"$",
"logger",
")",
";",
"$",
"this",
"->",
"treeService",
"->",
"setLogger",
"(",
"$",
"logger",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php#L95-L100 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php | EzPlatformAdapter.send | public function send(Request $request)
{
$this->repository->beginTransaction();
if ($this->logger) {
$this->treeService->setLogger($this->logger);
$this->objectService->setLogger($this->logger);
}
$response = new Response();
$objects = array();
foreach ($request as $object) {
$service = $this->getService($object);
try {
$objects[] = $this->executeAction($object, $service);
} catch (\Exception $e) {
$this->repository->rollback();
throw $e;
}
if (!empty($objects)) {
$response->setData(new \ArrayIterator($objects));
}
}
$this->repository->commit();
return $response;
} | php | public function send(Request $request)
{
$this->repository->beginTransaction();
if ($this->logger) {
$this->treeService->setLogger($this->logger);
$this->objectService->setLogger($this->logger);
}
$response = new Response();
$objects = array();
foreach ($request as $object) {
$service = $this->getService($object);
try {
$objects[] = $this->executeAction($object, $service);
} catch (\Exception $e) {
$this->repository->rollback();
throw $e;
}
if (!empty($objects)) {
$response->setData(new \ArrayIterator($objects));
}
}
$this->repository->commit();
return $response;
} | [
"public",
"function",
"send",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"repository",
"->",
"beginTransaction",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"treeService",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"$",
"this",
"->",
"objectService",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"objects",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"request",
"as",
"$",
"object",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"object",
")",
";",
"try",
"{",
"$",
"objects",
"[",
"]",
"=",
"$",
"this",
"->",
"executeAction",
"(",
"$",
"object",
",",
"$",
"service",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"repository",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"objects",
")",
")",
"{",
"$",
"response",
"->",
"setData",
"(",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"objects",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"repository",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"response",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php#L105-L135 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php | EzPlatformAdapter.executeAction | protected function executeAction(ObjectInterface $object, AbstractRepositoryService $service)
{
if (is_a($object, EzPlatformObject::class)) {
/** @var EzPlatformObject $object */
switch ($object->getAction()) {
case Action::CREATEORUPDATE:
return $service->createOrUpdate($object);
case Action::DELETE:
return $service->remove($object);
case Action::SKIP:
default:
}
} else {
return $service->createOrUpdate($object);
}
return;
} | php | protected function executeAction(ObjectInterface $object, AbstractRepositoryService $service)
{
if (is_a($object, EzPlatformObject::class)) {
/** @var EzPlatformObject $object */
switch ($object->getAction()) {
case Action::CREATEORUPDATE:
return $service->createOrUpdate($object);
case Action::DELETE:
return $service->remove($object);
case Action::SKIP:
default:
}
} else {
return $service->createOrUpdate($object);
}
return;
} | [
"protected",
"function",
"executeAction",
"(",
"ObjectInterface",
"$",
"object",
",",
"AbstractRepositoryService",
"$",
"service",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"object",
",",
"EzPlatformObject",
"::",
"class",
")",
")",
"{",
"/** @var EzPlatformObject $object */",
"switch",
"(",
"$",
"object",
"->",
"getAction",
"(",
")",
")",
"{",
"case",
"Action",
"::",
"CREATEORUPDATE",
":",
"return",
"$",
"service",
"->",
"createOrUpdate",
"(",
"$",
"object",
")",
";",
"case",
"Action",
"::",
"DELETE",
":",
"return",
"$",
"service",
"->",
"remove",
"(",
"$",
"object",
")",
";",
"case",
"Action",
"::",
"SKIP",
":",
"default",
":",
"}",
"}",
"else",
"{",
"return",
"$",
"service",
"->",
"createOrUpdate",
"(",
"$",
"object",
")",
";",
"}",
"return",
";",
"}"
] | @param ObjectInterface $object
@param AbstractRepositoryService $service
@return ObjectInterface|null | [
"@param",
"ObjectInterface",
"$object",
"@param",
"AbstractRepositoryService",
"$service"
] | train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php#L143-L160 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php | EzPlatformAdapter.getService | protected function getService($object)
{
if ($object instanceof TreeObject) {
$service = $this->treeService;
} else {
$service = $this->objectService;
}
if ($this->options['current_user']) {
$service->setCurrentUser($this->options['current_user']);
}
return $service;
} | php | protected function getService($object)
{
if ($object instanceof TreeObject) {
$service = $this->treeService;
} else {
$service = $this->objectService;
}
if ($this->options['current_user']) {
$service->setCurrentUser($this->options['current_user']);
}
return $service;
} | [
"protected",
"function",
"getService",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"TreeObject",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"treeService",
";",
"}",
"else",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"objectService",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'current_user'",
"]",
")",
"{",
"$",
"service",
"->",
"setCurrentUser",
"(",
"$",
"this",
"->",
"options",
"[",
"'current_user'",
"]",
")",
";",
"}",
"return",
"$",
"service",
";",
"}"
] | Decides which service to use, based on the type of $object given.
@param ObjectInterface $object
@return ContentTreeService|ObjectService | [
"Decides",
"which",
"service",
"to",
"use",
"based",
"on",
"the",
"type",
"of",
"$object",
"given",
"."
] | train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Adapter/EzPlatformAdapter.php#L169-L182 |
yuncms/framework | src/console/controllers/UserController.php | UserController.actionCreate | public function actionCreate($email, $nickname, $password = null)
{
$user = new User(['scenario' => User::SCENARIO_CREATE, 'email' => $email, 'nickname' => $nickname, 'password' => $password]);
if ($user->createUser()) {
$this->stdout(Yii::t('yuncms', 'User has been created') . "!\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('yuncms', 'Please fix following errors:') . "\n", Console::FG_RED);
foreach ($user->errors as $errors) {
foreach ($errors as $error) {
$this->stdout(' - ' . $error . "\n", Console::FG_RED);
}
}
}
} | php | public function actionCreate($email, $nickname, $password = null)
{
$user = new User(['scenario' => User::SCENARIO_CREATE, 'email' => $email, 'nickname' => $nickname, 'password' => $password]);
if ($user->createUser()) {
$this->stdout(Yii::t('yuncms', 'User has been created') . "!\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('yuncms', 'Please fix following errors:') . "\n", Console::FG_RED);
foreach ($user->errors as $errors) {
foreach ($errors as $error) {
$this->stdout(' - ' . $error . "\n", Console::FG_RED);
}
}
}
} | [
"public",
"function",
"actionCreate",
"(",
"$",
"email",
",",
"$",
"nickname",
",",
"$",
"password",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"new",
"User",
"(",
"[",
"'scenario'",
"=>",
"User",
"::",
"SCENARIO_CREATE",
",",
"'email'",
"=>",
"$",
"email",
",",
"'nickname'",
"=>",
"$",
"nickname",
",",
"'password'",
"=>",
"$",
"password",
"]",
")",
";",
"if",
"(",
"$",
"user",
"->",
"createUser",
"(",
")",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'User has been created'",
")",
".",
"\"!\\n\"",
",",
"Console",
"::",
"FG_GREEN",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"stdout",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Please fix following errors:'",
")",
".",
"\"\\n\"",
",",
"Console",
"::",
"FG_RED",
")",
";",
"foreach",
"(",
"$",
"user",
"->",
"errors",
"as",
"$",
"errors",
")",
"{",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"' - '",
".",
"$",
"error",
".",
"\"\\n\"",
",",
"Console",
"::",
"FG_RED",
")",
";",
"}",
"}",
"}",
"}"
] | This command creates new user account. If password is not set, this command will generate new 8-char password.
After saving user to database, this command uses mailer component to send credentials (username and password) to
user via email.
@param string $email Email address
@param string $nickname Nickname
@param null|string $password Password (if null it will be generated automatically) | [
"This",
"command",
"creates",
"new",
"user",
"account",
".",
"If",
"password",
"is",
"not",
"set",
"this",
"command",
"will",
"generate",
"new",
"8",
"-",
"char",
"password",
".",
"After",
"saving",
"user",
"to",
"database",
"this",
"command",
"uses",
"mailer",
"component",
"to",
"send",
"credentials",
"(",
"username",
"and",
"password",
")",
"to",
"user",
"via",
"email",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/console/controllers/UserController.php#L30-L43 |
yuncms/framework | src/console/controllers/UserController.php | UserController.actionDelete | public function actionDelete($search)
{
if ($this->confirm(Yii::t('yuncms', 'Are you sure? Deleted user can not be restored'))) {
$user = User::findByEmailOrMobile($search);
if ($user === null) {
$this->stdout(Yii::t('yuncms', 'User is not found') . "\n", Console::FG_RED);
} else {
if ($user->delete()) {
$this->stdout(Yii::t('yuncms', 'User has been deleted') . "\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('yuncms', 'Error occurred while deleting user') . "\n", Console::FG_RED);
}
}
}
} | php | public function actionDelete($search)
{
if ($this->confirm(Yii::t('yuncms', 'Are you sure? Deleted user can not be restored'))) {
$user = User::findByEmailOrMobile($search);
if ($user === null) {
$this->stdout(Yii::t('yuncms', 'User is not found') . "\n", Console::FG_RED);
} else {
if ($user->delete()) {
$this->stdout(Yii::t('yuncms', 'User has been deleted') . "\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('yuncms', 'Error occurred while deleting user') . "\n", Console::FG_RED);
}
}
}
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"search",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Are you sure? Deleted user can not be restored'",
")",
")",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findByEmailOrMobile",
"(",
"$",
"search",
")",
";",
"if",
"(",
"$",
"user",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'User is not found'",
")",
".",
"\"\\n\"",
",",
"Console",
"::",
"FG_RED",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"user",
"->",
"delete",
"(",
")",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'User has been deleted'",
")",
".",
"\"\\n\"",
",",
"Console",
"::",
"FG_GREEN",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"stdout",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Error occurred while deleting user'",
")",
".",
"\"\\n\"",
",",
"Console",
"::",
"FG_RED",
")",
";",
"}",
"}",
"}",
"}"
] | Deletes a user.
@param string $search Email or username
@throws \Exception
@throws \Throwable
@throws \yii\db\StaleObjectException | [
"Deletes",
"a",
"user",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/console/controllers/UserController.php#L92-L106 |
lmammino/e-foundation | src/Order/Model/OrderAdjustment.php | OrderAdjustment.setAdjustable | public function setAdjustable(AdjustableInterface $adjustable = null)
{
$this->adjustable = $this->order = $adjustable;
return $this;
} | php | public function setAdjustable(AdjustableInterface $adjustable = null)
{
$this->adjustable = $this->order = $adjustable;
return $this;
} | [
"public",
"function",
"setAdjustable",
"(",
"AdjustableInterface",
"$",
"adjustable",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"adjustable",
"=",
"$",
"this",
"->",
"order",
"=",
"$",
"adjustable",
";",
"return",
"$",
"this",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Order/Model/OrderAdjustment.php#L39-L44 |
TeamOffshoot/http | lib/Offshoot/HttpClient/CurlHttpClient.php | CurlHttpClient.makeRequest | protected function makeRequest($ch)
{
if ($this->hasHeaders()) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHttpHeaders());
}
$response = curl_exec($ch);
$error = curl_error($ch);
$code = curl_errno($ch);
if ($error) {
curl_close($ch);
throw new \RuntimeException($error, $code);
}
curl_close($ch);
return $response;
} | php | protected function makeRequest($ch)
{
if ($this->hasHeaders()) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHttpHeaders());
}
$response = curl_exec($ch);
$error = curl_error($ch);
$code = curl_errno($ch);
if ($error) {
curl_close($ch);
throw new \RuntimeException($error, $code);
}
curl_close($ch);
return $response;
} | [
"protected",
"function",
"makeRequest",
"(",
"$",
"ch",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasHeaders",
"(",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"this",
"->",
"getHttpHeaders",
"(",
")",
")",
";",
"}",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"error",
"=",
"curl_error",
"(",
"$",
"ch",
")",
";",
"$",
"code",
"=",
"curl_errno",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"curl_close",
"(",
"$",
"ch",
")",
";",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"error",
",",
"$",
"code",
")",
";",
"}",
"curl_close",
"(",
"$",
"ch",
")",
";",
"return",
"$",
"response",
";",
"}"
] | make the cURL request
@param resource $ch
@return mixed | [
"make",
"the",
"cURL",
"request"
] | train | https://github.com/TeamOffshoot/http/blob/e423486262913f131d6aef005eb087849b60f77f/lib/Offshoot/HttpClient/CurlHttpClient.php#L131-L151 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.