id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
17,500 | aryelgois/yasql-php | src/Controller.php | Controller.generate | public static function generate(
string $yasql,
string $name = null,
int $indent = null
) {
$model = new Parser($yasql, $name);
$view = new Generator($model, $indent);
return $view->output();
} | php | public static function generate(
string $yasql,
string $name = null,
int $indent = null
) {
$model = new Parser($yasql, $name);
$view = new Generator($model, $indent);
return $view->output();
} | [
"public",
"static",
"function",
"generate",
"(",
"string",
"$",
"yasql",
",",
"string",
"$",
"name",
"=",
"null",
",",
"int",
"$",
"indent",
"=",
"null",
")",
"{",
"$",
"model",
"=",
"new",
"Parser",
"(",
"$",
"yasql",
",",
"$",
"name",
")",
";",
"$",
"view",
"=",
"new",
"Generator",
"(",
"$",
"model",
",",
"$",
"indent",
")",
";",
"return",
"$",
"view",
"->",
"output",
"(",
")",
";",
"}"
]
| Generates the SQL from a YASQL
@param string $yasql A string following YAML Ain't SQL specifications
@param string $name Overwrite database's name
@param int $indent How many spaces per indentation level
@return string | [
"Generates",
"the",
"SQL",
"from",
"a",
"YASQL"
]
| f428b180d35bfc1ddf1f9b3323f9b085fbc09ac7 | https://github.com/aryelgois/yasql-php/blob/f428b180d35bfc1ddf1f9b3323f9b085fbc09ac7/src/Controller.php#L55-L63 |
17,501 | aryelgois/yasql-php | src/Controller.php | Controller.parse | public static function parse(string $yasql, string $name = null)
{
$parser = new Parser($yasql, $name);
return $parser->getData();
} | php | public static function parse(string $yasql, string $name = null)
{
$parser = new Parser($yasql, $name);
return $parser->getData();
} | [
"public",
"static",
"function",
"parse",
"(",
"string",
"$",
"yasql",
",",
"string",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"parser",
"=",
"new",
"Parser",
"(",
"$",
"yasql",
",",
"$",
"name",
")",
";",
"return",
"$",
"parser",
"->",
"getData",
"(",
")",
";",
"}"
]
| Parses a YASQL and returns the parsed data
@param string $yasql A string following YAML Ain't SQL specifications
@param string $name Overwrite database's name
@return array | [
"Parses",
"a",
"YASQL",
"and",
"returns",
"the",
"parsed",
"data"
]
| f428b180d35bfc1ddf1f9b3323f9b085fbc09ac7 | https://github.com/aryelgois/yasql-php/blob/f428b180d35bfc1ddf1f9b3323f9b085fbc09ac7/src/Controller.php#L73-L77 |
17,502 | aedart/laravel-helpers | src/Traits/Cache/CacheFactoryTrait.php | CacheFactoryTrait.getCacheFactory | public function getCacheFactory(): ?Factory
{
if (!$this->hasCacheFactory()) {
$this->setCacheFactory($this->getDefaultCacheFactory());
}
return $this->cacheFactory;
} | php | public function getCacheFactory(): ?Factory
{
if (!$this->hasCacheFactory()) {
$this->setCacheFactory($this->getDefaultCacheFactory());
}
return $this->cacheFactory;
} | [
"public",
"function",
"getCacheFactory",
"(",
")",
":",
"?",
"Factory",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCacheFactory",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setCacheFactory",
"(",
"$",
"this",
"->",
"getDefaultCacheFactory",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cacheFactory",
";",
"}"
]
| Get cache factory
If no cache factory has been set, this method will
set and return a default cache factory, if any such
value is available
@see getDefaultCacheFactory()
@return Factory|null cache factory or null if none cache factory has been set | [
"Get",
"cache",
"factory"
]
| 8b81a2d6658f3f8cb62b6be2c34773aaa2df219a | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Cache/CacheFactoryTrait.php#L53-L59 |
17,503 | nyeholt/silverstripe-external-content | thirdparty/Zend/Feed/Atom.php | Zend_Feed_Atom.saveXml | public function saveXml()
{
// Return a complete document including XML prologue.
$doc = new DOMDocument($this->_element->ownerDocument->version,
$this->_element->ownerDocument->actualEncoding);
$doc->appendChild($doc->importNode($this->_element, true));
$doc->formatOutput = true;
return $doc->saveXML();
} | php | public function saveXml()
{
// Return a complete document including XML prologue.
$doc = new DOMDocument($this->_element->ownerDocument->version,
$this->_element->ownerDocument->actualEncoding);
$doc->appendChild($doc->importNode($this->_element, true));
$doc->formatOutput = true;
return $doc->saveXML();
} | [
"public",
"function",
"saveXml",
"(",
")",
"{",
"// Return a complete document including XML prologue.",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
"$",
"this",
"->",
"_element",
"->",
"ownerDocument",
"->",
"version",
",",
"$",
"this",
"->",
"_element",
"->",
"ownerDocument",
"->",
"actualEncoding",
")",
";",
"$",
"doc",
"->",
"appendChild",
"(",
"$",
"doc",
"->",
"importNode",
"(",
"$",
"this",
"->",
"_element",
",",
"true",
")",
")",
";",
"$",
"doc",
"->",
"formatOutput",
"=",
"true",
";",
"return",
"$",
"doc",
"->",
"saveXML",
"(",
")",
";",
"}"
]
| Override Zend_Feed_Element to allow formated feeds
@return string | [
"Override",
"Zend_Feed_Element",
"to",
"allow",
"formated",
"feeds"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Atom.php#L359-L368 |
17,504 | nyeholt/silverstripe-external-content | thirdparty/Zend/Feed/Atom.php | Zend_Feed_Atom.send | public function send()
{
if (headers_sent()) {
/**
* @see Zend_Feed_Exception
*/
require_once 'Zend/Feed/Exception.php';
throw new Zend_Feed_Exception('Cannot send ATOM because headers have already been sent.');
}
header('Content-Type: application/atom+xml; charset=' . $this->_element->ownerDocument->actualEncoding);
echo $this->saveXML();
} | php | public function send()
{
if (headers_sent()) {
/**
* @see Zend_Feed_Exception
*/
require_once 'Zend/Feed/Exception.php';
throw new Zend_Feed_Exception('Cannot send ATOM because headers have already been sent.');
}
header('Content-Type: application/atom+xml; charset=' . $this->_element->ownerDocument->actualEncoding);
echo $this->saveXML();
} | [
"public",
"function",
"send",
"(",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"/** \n * @see Zend_Feed_Exception\n */",
"require_once",
"'Zend/Feed/Exception.php'",
";",
"throw",
"new",
"Zend_Feed_Exception",
"(",
"'Cannot send ATOM because headers have already been sent.'",
")",
";",
"}",
"header",
"(",
"'Content-Type: application/atom+xml; charset='",
".",
"$",
"this",
"->",
"_element",
"->",
"ownerDocument",
"->",
"actualEncoding",
")",
";",
"echo",
"$",
"this",
"->",
"saveXML",
"(",
")",
";",
"}"
]
| Send feed to a http client with the correct header
@return void
@throws Zend_Feed_Exception if headers have already been sent | [
"Send",
"feed",
"to",
"a",
"http",
"client",
"with",
"the",
"correct",
"header"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Atom.php#L376-L389 |
17,505 | aedart/laravel-helpers | src/Traits/Redis/RedisFactoryTrait.php | RedisFactoryTrait.getRedisFactory | public function getRedisFactory(): ?Factory
{
if (!$this->hasRedisFactory()) {
$this->setRedisFactory($this->getDefaultRedisFactory());
}
return $this->redisFactory;
} | php | public function getRedisFactory(): ?Factory
{
if (!$this->hasRedisFactory()) {
$this->setRedisFactory($this->getDefaultRedisFactory());
}
return $this->redisFactory;
} | [
"public",
"function",
"getRedisFactory",
"(",
")",
":",
"?",
"Factory",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasRedisFactory",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setRedisFactory",
"(",
"$",
"this",
"->",
"getDefaultRedisFactory",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redisFactory",
";",
"}"
]
| Get redis factory
If no redis factory has been set, this method will
set and return a default redis factory, if any such
value is available
@see getDefaultRedisFactory()
@return Factory|null redis factory or null if none redis factory has been set | [
"Get",
"redis",
"factory"
]
| 8b81a2d6658f3f8cb62b6be2c34773aaa2df219a | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Redis/RedisFactoryTrait.php#L53-L59 |
17,506 | djgadd/themosis-illuminate | src/Validation/ValidationServiceProvider.php | ValidationServiceProvider.boot | public function boot ()
{
ValidatorFacade::extend('valid_nonce', function ($attaribute, $value, $params, $validator) {
$action = $params[0];
return (bool) wp_verify_nonce($value, $action);
});
} | php | public function boot ()
{
ValidatorFacade::extend('valid_nonce', function ($attaribute, $value, $params, $validator) {
$action = $params[0];
return (bool) wp_verify_nonce($value, $action);
});
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"ValidatorFacade",
"::",
"extend",
"(",
"'valid_nonce'",
",",
"function",
"(",
"$",
"attaribute",
",",
"$",
"value",
",",
"$",
"params",
",",
"$",
"validator",
")",
"{",
"$",
"action",
"=",
"$",
"params",
"[",
"0",
"]",
";",
"return",
"(",
"bool",
")",
"wp_verify_nonce",
"(",
"$",
"value",
",",
"$",
"action",
")",
";",
"}",
")",
";",
"}"
]
| Add valid_nonce validation rule
@return void | [
"Add",
"valid_nonce",
"validation",
"rule"
]
| 13ee4c3413cddd85a2f262ac361f35c81da0c53c | https://github.com/djgadd/themosis-illuminate/blob/13ee4c3413cddd85a2f262ac361f35c81da0c53c/src/Validation/ValidationServiceProvider.php#L23-L29 |
17,507 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.getEntity | public function getEntity($id, $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
return $this->getQueryBuilder(['id' => $id])
->getQuery()
->setMaxResults(1)
->getOneOrNullResult($hydrationMode);
} | php | public function getEntity($id, $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
return $this->getQueryBuilder(['id' => $id])
->getQuery()
->setMaxResults(1)
->getOneOrNullResult($hydrationMode);
} | [
"public",
"function",
"getEntity",
"(",
"$",
"id",
",",
"$",
"hydrationMode",
"=",
"AbstractQuery",
"::",
"HYDRATE_OBJECT",
")",
"{",
"return",
"$",
"this",
"->",
"getQueryBuilder",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
"->",
"getQuery",
"(",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getOneOrNullResult",
"(",
"$",
"hydrationMode",
")",
";",
"}"
]
| Returns an entity by its ID.
@param mixed $id
@param integer $hydrationMode
@return mixed
@deprecated Deprecated since 2.0.4; to be removed in 3.0.0. Use the basic `find()` method instead | [
"Returns",
"an",
"entity",
"by",
"its",
"ID",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L37-L43 |
17,508 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.getEntitiesById | public function getEntitiesById(array $ids, $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
return $this->getQueryBuilder(['id' => $ids])
->getQuery()
->execute(null, $hydrationMode);
} | php | public function getEntitiesById(array $ids, $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
return $this->getQueryBuilder(['id' => $ids])
->getQuery()
->execute(null, $hydrationMode);
} | [
"public",
"function",
"getEntitiesById",
"(",
"array",
"$",
"ids",
",",
"$",
"hydrationMode",
"=",
"AbstractQuery",
"::",
"HYDRATE_OBJECT",
")",
"{",
"return",
"$",
"this",
"->",
"getQueryBuilder",
"(",
"[",
"'id'",
"=>",
"$",
"ids",
"]",
")",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
"null",
",",
"$",
"hydrationMode",
")",
";",
"}"
]
| Returns a list of entities extracted by their IDs.
@param array $ids
@param integer $hydrationMode
@return array | [
"Returns",
"a",
"list",
"of",
"entities",
"extracted",
"by",
"their",
"IDs",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L65-L70 |
17,509 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.getEntities | public function getEntities(array $options = [], $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
$options = EntityRepositoryOptionsResolver::createAndResolve($options);
return $this->getQueryBuilder($options['filters'], $options['sorting'])
->getQuery()
->execute(null, $hydrationMode);
} | php | public function getEntities(array $options = [], $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
$options = EntityRepositoryOptionsResolver::createAndResolve($options);
return $this->getQueryBuilder($options['filters'], $options['sorting'])
->getQuery()
->execute(null, $hydrationMode);
} | [
"public",
"function",
"getEntities",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"hydrationMode",
"=",
"AbstractQuery",
"::",
"HYDRATE_OBJECT",
")",
"{",
"$",
"options",
"=",
"EntityRepositoryOptionsResolver",
"::",
"createAndResolve",
"(",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"getQueryBuilder",
"(",
"$",
"options",
"[",
"'filters'",
"]",
",",
"$",
"options",
"[",
"'sorting'",
"]",
")",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
"null",
",",
"$",
"hydrationMode",
")",
";",
"}"
]
| Returns a list of all the entities.
@param array $options
@param integer $hydrationMode
@return array | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"entities",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L79-L85 |
17,510 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.getPaginatedEntities | public function getPaginatedEntities(array $options = [], $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
$options = PaginatedEntityRepositoryOptionsResolver::createAndResolve($options);
$queryBuilder = $this->addPagination(
$this->getQueryBuilder($options['filters'], $options['sorting']),
$options['elementsPerPage'],
$options['page']
);
return new Paginator($queryBuilder->getQuery()->setHydrationMode($hydrationMode));
} | php | public function getPaginatedEntities(array $options = [], $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{
$options = PaginatedEntityRepositoryOptionsResolver::createAndResolve($options);
$queryBuilder = $this->addPagination(
$this->getQueryBuilder($options['filters'], $options['sorting']),
$options['elementsPerPage'],
$options['page']
);
return new Paginator($queryBuilder->getQuery()->setHydrationMode($hydrationMode));
} | [
"public",
"function",
"getPaginatedEntities",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"hydrationMode",
"=",
"AbstractQuery",
"::",
"HYDRATE_OBJECT",
")",
"{",
"$",
"options",
"=",
"PaginatedEntityRepositoryOptionsResolver",
"::",
"createAndResolve",
"(",
"$",
"options",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"addPagination",
"(",
"$",
"this",
"->",
"getQueryBuilder",
"(",
"$",
"options",
"[",
"'filters'",
"]",
",",
"$",
"options",
"[",
"'sorting'",
"]",
")",
",",
"$",
"options",
"[",
"'elementsPerPage'",
"]",
",",
"$",
"options",
"[",
"'page'",
"]",
")",
";",
"return",
"new",
"Paginator",
"(",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"setHydrationMode",
"(",
"$",
"hydrationMode",
")",
")",
";",
"}"
]
| Returns a paginated list of entities.
@param array $options
@param integer $hydrationMode
@return \Doctrine\ORM\Tools\Pagination\Paginator | [
"Returns",
"a",
"paginated",
"list",
"of",
"entities",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L94-L104 |
17,511 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.getQueryBuilder | protected function getQueryBuilder(array $filters = [], array $sorting = [])
{
$queryBuilder = $this->getBaseQueryBuilder();
if (!empty($filters)) {
$this->addFilters($queryBuilder, $filters);
}
if (empty($sorting)) {
$this->addSorting($queryBuilder, $this->getDefaultSorting());
} else {
$this->addSorting($queryBuilder, $sorting);
}
return $queryBuilder;
} | php | protected function getQueryBuilder(array $filters = [], array $sorting = [])
{
$queryBuilder = $this->getBaseQueryBuilder();
if (!empty($filters)) {
$this->addFilters($queryBuilder, $filters);
}
if (empty($sorting)) {
$this->addSorting($queryBuilder, $this->getDefaultSorting());
} else {
$this->addSorting($queryBuilder, $sorting);
}
return $queryBuilder;
} | [
"protected",
"function",
"getQueryBuilder",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
",",
"array",
"$",
"sorting",
"=",
"[",
"]",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getBaseQueryBuilder",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"filters",
")",
")",
"{",
"$",
"this",
"->",
"addFilters",
"(",
"$",
"queryBuilder",
",",
"$",
"filters",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"sorting",
")",
")",
"{",
"$",
"this",
"->",
"addSorting",
"(",
"$",
"queryBuilder",
",",
"$",
"this",
"->",
"getDefaultSorting",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addSorting",
"(",
"$",
"queryBuilder",
",",
"$",
"sorting",
")",
";",
"}",
"return",
"$",
"queryBuilder",
";",
"}"
]
| Returns a complete QueryBuilder instance for the current entity.
@param array $filters
@param array $sorting
@return \Doctrine\ORM\QueryBuilder | [
"Returns",
"a",
"complete",
"QueryBuilder",
"instance",
"for",
"the",
"current",
"entity",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L113-L127 |
17,512 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.addFilters | protected function addFilters(QueryBuilder $queryBuilder, $filters = array())
{
foreach ($filters as $field => $value) {
$methodName = sprintf('add%sFilter', ucfirst($field));
if (method_exists($this, $methodName)) {
// This field has a custom filtering method
$this->$methodName($queryBuilder, $value);
continue;
}
if (null === $value || '' === $value || (is_array($value) && 0 == count($value))) {
// Skip: value is blank
continue;
}
$field = $this->addEntityAlias($field);
if (is_array($value)) {
$queryBuilder->andWhere($queryBuilder->expr()->in($field, $value));
} else {
$queryBuilder->andWhere($queryBuilder->expr()->eq($field, $queryBuilder->expr()->literal($value)));
}
}
return $queryBuilder;
} | php | protected function addFilters(QueryBuilder $queryBuilder, $filters = array())
{
foreach ($filters as $field => $value) {
$methodName = sprintf('add%sFilter', ucfirst($field));
if (method_exists($this, $methodName)) {
// This field has a custom filtering method
$this->$methodName($queryBuilder, $value);
continue;
}
if (null === $value || '' === $value || (is_array($value) && 0 == count($value))) {
// Skip: value is blank
continue;
}
$field = $this->addEntityAlias($field);
if (is_array($value)) {
$queryBuilder->andWhere($queryBuilder->expr()->in($field, $value));
} else {
$queryBuilder->andWhere($queryBuilder->expr()->eq($field, $queryBuilder->expr()->literal($value)));
}
}
return $queryBuilder;
} | [
"protected",
"function",
"addFilters",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"$",
"filters",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"methodName",
"=",
"sprintf",
"(",
"'add%sFilter'",
",",
"ucfirst",
"(",
"$",
"field",
")",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
")",
"{",
"// This field has a custom filtering method",
"$",
"this",
"->",
"$",
"methodName",
"(",
"$",
"queryBuilder",
",",
"$",
"value",
")",
";",
"continue",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"value",
"||",
"''",
"===",
"$",
"value",
"||",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"0",
"==",
"count",
"(",
"$",
"value",
")",
")",
")",
"{",
"// Skip: value is blank",
"continue",
";",
"}",
"$",
"field",
"=",
"$",
"this",
"->",
"addEntityAlias",
"(",
"$",
"field",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"$",
"field",
",",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"$",
"field",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"literal",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"queryBuilder",
";",
"}"
]
| Adds filters to the QueryBuilder instance.
@param \Doctrine\ORM\QueryBuilder $queryBuilder
@param array $filters
@return \Doctrine\ORM\QueryBuilder | [
"Adds",
"filters",
"to",
"the",
"QueryBuilder",
"instance",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L136-L160 |
17,513 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.addSorting | protected function addSorting(QueryBuilder $queryBuilder, array $sorting = [])
{
foreach ($sorting as $field => $sortOrder) {
if (!$this->isFieldSortable($field)) {
// Skip: invalid field
continue;
}
if (!$this->isSortOrderValid($sortOrder)) {
// Skip: invalid sort order
continue;
}
$methodName = sprintf('add%sSorting', ucfirst($field));
if (method_exists($this, $methodName)) {
$this->$methodName($queryBuilder, $sortOrder);
continue;
}
$queryBuilder->addOrderBy($this->addEntityAlias($field), strtolower($sortOrder));
}
return $queryBuilder;
} | php | protected function addSorting(QueryBuilder $queryBuilder, array $sorting = [])
{
foreach ($sorting as $field => $sortOrder) {
if (!$this->isFieldSortable($field)) {
// Skip: invalid field
continue;
}
if (!$this->isSortOrderValid($sortOrder)) {
// Skip: invalid sort order
continue;
}
$methodName = sprintf('add%sSorting', ucfirst($field));
if (method_exists($this, $methodName)) {
$this->$methodName($queryBuilder, $sortOrder);
continue;
}
$queryBuilder->addOrderBy($this->addEntityAlias($field), strtolower($sortOrder));
}
return $queryBuilder;
} | [
"protected",
"function",
"addSorting",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"array",
"$",
"sorting",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"sorting",
"as",
"$",
"field",
"=>",
"$",
"sortOrder",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFieldSortable",
"(",
"$",
"field",
")",
")",
"{",
"// Skip: invalid field",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isSortOrderValid",
"(",
"$",
"sortOrder",
")",
")",
"{",
"// Skip: invalid sort order",
"continue",
";",
"}",
"$",
"methodName",
"=",
"sprintf",
"(",
"'add%sSorting'",
",",
"ucfirst",
"(",
"$",
"field",
")",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
")",
"{",
"$",
"this",
"->",
"$",
"methodName",
"(",
"$",
"queryBuilder",
",",
"$",
"sortOrder",
")",
";",
"continue",
";",
"}",
"$",
"queryBuilder",
"->",
"addOrderBy",
"(",
"$",
"this",
"->",
"addEntityAlias",
"(",
"$",
"field",
")",
",",
"strtolower",
"(",
"$",
"sortOrder",
")",
")",
";",
"}",
"return",
"$",
"queryBuilder",
";",
"}"
]
| Adds sorting to the specified query builder.
@param \Doctrine\ORM\QueryBuilder $queryBuilder
@param array $sorting
@return \Doctrine\ORM\QueryBuilder | [
"Adds",
"sorting",
"to",
"the",
"specified",
"query",
"builder",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L169-L191 |
17,514 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.addPagination | protected function addPagination(QueryBuilder $queryBuilder, $elementsPerPage, $page = 1)
{
$elementsPerPage = (int)$elementsPerPage;
$page = (int)$page;
return $queryBuilder
->setMaxResults($elementsPerPage)
->setFirstResult($elementsPerPage * ($page - 1));
} | php | protected function addPagination(QueryBuilder $queryBuilder, $elementsPerPage, $page = 1)
{
$elementsPerPage = (int)$elementsPerPage;
$page = (int)$page;
return $queryBuilder
->setMaxResults($elementsPerPage)
->setFirstResult($elementsPerPage * ($page - 1));
} | [
"protected",
"function",
"addPagination",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"$",
"elementsPerPage",
",",
"$",
"page",
"=",
"1",
")",
"{",
"$",
"elementsPerPage",
"=",
"(",
"int",
")",
"$",
"elementsPerPage",
";",
"$",
"page",
"=",
"(",
"int",
")",
"$",
"page",
";",
"return",
"$",
"queryBuilder",
"->",
"setMaxResults",
"(",
"$",
"elementsPerPage",
")",
"->",
"setFirstResult",
"(",
"$",
"elementsPerPage",
"*",
"(",
"$",
"page",
"-",
"1",
")",
")",
";",
"}"
]
| Adds pagination to the specified query builder.
@param \Doctrine\ORM\QueryBuilder $queryBuilder
@param integer $elementsPerPage
@param integer $page
@return \Doctrine\ORM\QueryBuilder | [
"Adds",
"pagination",
"to",
"the",
"specified",
"query",
"builder",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L201-L209 |
17,515 | gibilogic/crud-bundle | Entity/EntityRepository.php | EntityRepository.hasJoin | protected function hasJoin(QueryBuilder $queryBuilder, $joinString)
{
/* @var \Doctrine\ORM\Query\Expr\Join $joinExpression */
foreach ($queryBuilder->getDQLPart('join') as $joinsList) {
foreach ($joinsList as $joinExpression) {
if ($joinExpression->getJoin() == $joinString) {
return true;
}
}
}
return false;
} | php | protected function hasJoin(QueryBuilder $queryBuilder, $joinString)
{
/* @var \Doctrine\ORM\Query\Expr\Join $joinExpression */
foreach ($queryBuilder->getDQLPart('join') as $joinsList) {
foreach ($joinsList as $joinExpression) {
if ($joinExpression->getJoin() == $joinString) {
return true;
}
}
}
return false;
} | [
"protected",
"function",
"hasJoin",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"$",
"joinString",
")",
"{",
"/* @var \\Doctrine\\ORM\\Query\\Expr\\Join $joinExpression */",
"foreach",
"(",
"$",
"queryBuilder",
"->",
"getDQLPart",
"(",
"'join'",
")",
"as",
"$",
"joinsList",
")",
"{",
"foreach",
"(",
"$",
"joinsList",
"as",
"$",
"joinExpression",
")",
"{",
"if",
"(",
"$",
"joinExpression",
"->",
"getJoin",
"(",
")",
"==",
"$",
"joinString",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Returns TRUE if the join string is already present inside the query builder, FALSE otherwise.
@param \Doctrine\ORM\QueryBuilder $queryBuilder
@param string $joinString
@return boolean | [
"Returns",
"TRUE",
"if",
"the",
"join",
"string",
"is",
"already",
"present",
"inside",
"the",
"query",
"builder",
"FALSE",
"otherwise",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Entity/EntityRepository.php#L218-L230 |
17,516 | 2amigos/yiifoundation | widgets/JoyRide.php | JoyRide.renderStop | public function renderStop($stop)
{
$options = array();
$options['data-id'] = ArrayHelper::getValue($stop, 'id');
$options['data-text'] = ArrayHelper::getValue($stop, 'text');
$options['data-button'] = ArrayHelper::getValue($stop, 'button');
$options['data-class'] = ArrayHelper::getValue($stop, 'class');
$options['data-options'] = ArrayHelper::getValue($stop, 'options');
if ($options['data-options'] !== null) {
$config = array();
foreach ($options['data-options'] as $key => $option) {
$config[] = $key . ':' . $option;
}
$options['data-options'] = implode(';', $config);
}
$title = ArrayHelper::getValue($stop, 'title');
if (!empty($title)) {
$title = "<h4>{$title}</h4>";
}
$content = '<p>' . ArrayHelper::getValue($stop, 'body', '') . '</p>';
return \CHtml::tag('li', $options, $title . $content);
} | php | public function renderStop($stop)
{
$options = array();
$options['data-id'] = ArrayHelper::getValue($stop, 'id');
$options['data-text'] = ArrayHelper::getValue($stop, 'text');
$options['data-button'] = ArrayHelper::getValue($stop, 'button');
$options['data-class'] = ArrayHelper::getValue($stop, 'class');
$options['data-options'] = ArrayHelper::getValue($stop, 'options');
if ($options['data-options'] !== null) {
$config = array();
foreach ($options['data-options'] as $key => $option) {
$config[] = $key . ':' . $option;
}
$options['data-options'] = implode(';', $config);
}
$title = ArrayHelper::getValue($stop, 'title');
if (!empty($title)) {
$title = "<h4>{$title}</h4>";
}
$content = '<p>' . ArrayHelper::getValue($stop, 'body', '') . '</p>';
return \CHtml::tag('li', $options, $title . $content);
} | [
"public",
"function",
"renderStop",
"(",
"$",
"stop",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"$",
"options",
"[",
"'data-id'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"stop",
",",
"'id'",
")",
";",
"$",
"options",
"[",
"'data-text'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"stop",
",",
"'text'",
")",
";",
"$",
"options",
"[",
"'data-button'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"stop",
",",
"'button'",
")",
";",
"$",
"options",
"[",
"'data-class'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"stop",
",",
"'class'",
")",
";",
"$",
"options",
"[",
"'data-options'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"stop",
",",
"'options'",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'data-options'",
"]",
"!==",
"null",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"[",
"'data-options'",
"]",
"as",
"$",
"key",
"=>",
"$",
"option",
")",
"{",
"$",
"config",
"[",
"]",
"=",
"$",
"key",
".",
"':'",
".",
"$",
"option",
";",
"}",
"$",
"options",
"[",
"'data-options'",
"]",
"=",
"implode",
"(",
"';'",
",",
"$",
"config",
")",
";",
"}",
"$",
"title",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"stop",
",",
"'title'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"title",
")",
")",
"{",
"$",
"title",
"=",
"\"<h4>{$title}</h4>\"",
";",
"}",
"$",
"content",
"=",
"'<p>'",
".",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"stop",
",",
"'body'",
",",
"''",
")",
".",
"'</p>'",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"$",
"options",
",",
"$",
"title",
".",
"$",
"content",
")",
";",
"}"
]
| Renders a single stop
@param array $stop the stop configuration
@return string the resulting li tag | [
"Renders",
"a",
"single",
"stop"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/JoyRide.php#L124-L146 |
17,517 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Table/Cell.php | PHPWord_Section_Table_Cell.addText | public function addText($text, $styleFont = null, $styleParagraph = null) {
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $text;
return $text;
} | php | public function addText($text, $styleFont = null, $styleParagraph = null) {
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $text;
return $text;
} | [
"public",
"function",
"addText",
"(",
"$",
"text",
",",
"$",
"styleFont",
"=",
"null",
",",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"$",
"text",
"=",
"new",
"PHPWord_Section_Text",
"(",
"$",
"text",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
")",
";",
"$",
"this",
"->",
"_elementCollection",
"[",
"]",
"=",
"$",
"text",
";",
"return",
"$",
"text",
";",
"}"
]
| Add a Text Element
@param string $text
@param mixed $style
@return PHPWord_Section_Text | [
"Add",
"a",
"Text",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Table/Cell.php#L110-L114 |
17,518 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Table/Cell.php | PHPWord_Section_Table_Cell.addObject | public function addObject($src, $style = null) {
$object = new PHPWord_Section_Object($src, $style);
if(!is_null($object->getSource())) {
$inf = pathinfo($src);
$ext = $inf['extension'];
if(strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
$ext = substr($ext, 0, -1);
}
$iconSrc = PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/';
if(!file_exists($iconSrc.'_'.$ext.'.png')) {
$iconSrc = $iconSrc.'_default.png';
} else {
$iconSrc .= '_'.$ext.'.png';
}
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject');
$rID = $data[0];
$objectId = $data[1];
$object->setRelationId($rID);
$object->setObjectId($objectId);
$object->setImageRelationId($rIDimg);
$this->_elementCollection[] = $object;
return $object;
} else {
trigger_error('Source does not exist or unsupported object type.');
}
} | php | public function addObject($src, $style = null) {
$object = new PHPWord_Section_Object($src, $style);
if(!is_null($object->getSource())) {
$inf = pathinfo($src);
$ext = $inf['extension'];
if(strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
$ext = substr($ext, 0, -1);
}
$iconSrc = PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/';
if(!file_exists($iconSrc.'_'.$ext.'.png')) {
$iconSrc = $iconSrc.'_default.png';
} else {
$iconSrc .= '_'.$ext.'.png';
}
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject');
$rID = $data[0];
$objectId = $data[1];
$object->setRelationId($rID);
$object->setObjectId($objectId);
$object->setImageRelationId($rIDimg);
$this->_elementCollection[] = $object;
return $object;
} else {
trigger_error('Source does not exist or unsupported object type.');
}
} | [
"public",
"function",
"addObject",
"(",
"$",
"src",
",",
"$",
"style",
"=",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"PHPWord_Section_Object",
"(",
"$",
"src",
",",
"$",
"style",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"object",
"->",
"getSource",
"(",
")",
")",
")",
"{",
"$",
"inf",
"=",
"pathinfo",
"(",
"$",
"src",
")",
";",
"$",
"ext",
"=",
"$",
"inf",
"[",
"'extension'",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"ext",
")",
"==",
"4",
"&&",
"strtolower",
"(",
"substr",
"(",
"$",
"ext",
",",
"-",
"1",
")",
")",
"==",
"'x'",
")",
"{",
"$",
"ext",
"=",
"substr",
"(",
"$",
"ext",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"$",
"iconSrc",
"=",
"PHPWORD_BASE_PATH",
".",
"'PHPWord/_staticDocParts/'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"iconSrc",
".",
"'_'",
".",
"$",
"ext",
".",
"'.png'",
")",
")",
"{",
"$",
"iconSrc",
"=",
"$",
"iconSrc",
".",
"'_default.png'",
";",
"}",
"else",
"{",
"$",
"iconSrc",
".=",
"'_'",
".",
"$",
"ext",
".",
"'.png'",
";",
"}",
"$",
"rIDimg",
"=",
"PHPWord_Media",
"::",
"addSectionMediaElement",
"(",
"$",
"iconSrc",
",",
"'image'",
")",
";",
"$",
"data",
"=",
"PHPWord_Media",
"::",
"addSectionMediaElement",
"(",
"$",
"src",
",",
"'oleObject'",
")",
";",
"$",
"rID",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"objectId",
"=",
"$",
"data",
"[",
"1",
"]",
";",
"$",
"object",
"->",
"setRelationId",
"(",
"$",
"rID",
")",
";",
"$",
"object",
"->",
"setObjectId",
"(",
"$",
"objectId",
")",
";",
"$",
"object",
"->",
"setImageRelationId",
"(",
"$",
"rIDimg",
")",
";",
"$",
"this",
"->",
"_elementCollection",
"[",
"]",
"=",
"$",
"object",
";",
"return",
"$",
"object",
";",
"}",
"else",
"{",
"trigger_error",
"(",
"'Source does not exist or unsupported object type.'",
")",
";",
"}",
"}"
]
| Add a OLE-Object Element
@param string $src
@param mixed $style
@return PHPWord_Section_Object | [
"Add",
"a",
"OLE",
"-",
"Object",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Table/Cell.php#L223-L254 |
17,519 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Table/Cell.php | PHPWord_Section_Table_Cell.addPreserveText | public function addPreserveText($text, $styleFont = null, $styleParagraph = null) {
if($this->_insideOf == 'footer' || $this->_insideOf == 'header') {
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $ptext;
return $ptext;
} else {
trigger_error('addPreserveText only supported in footer/header.');
}
} | php | public function addPreserveText($text, $styleFont = null, $styleParagraph = null) {
if($this->_insideOf == 'footer' || $this->_insideOf == 'header') {
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $ptext;
return $ptext;
} else {
trigger_error('addPreserveText only supported in footer/header.');
}
} | [
"public",
"function",
"addPreserveText",
"(",
"$",
"text",
",",
"$",
"styleFont",
"=",
"null",
",",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_insideOf",
"==",
"'footer'",
"||",
"$",
"this",
"->",
"_insideOf",
"==",
"'header'",
")",
"{",
"$",
"ptext",
"=",
"new",
"PHPWord_Section_Footer_PreserveText",
"(",
"$",
"text",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
")",
";",
"$",
"this",
"->",
"_elementCollection",
"[",
"]",
"=",
"$",
"ptext",
";",
"return",
"$",
"ptext",
";",
"}",
"else",
"{",
"trigger_error",
"(",
"'addPreserveText only supported in footer/header.'",
")",
";",
"}",
"}"
]
| Add a PreserveText Element
@param string $text
@param mixed $styleFont
@param mixed $styleParagraph
@return PHPWord_Section_Footer_PreserveText | [
"Add",
"a",
"PreserveText",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Table/Cell.php#L264-L272 |
17,520 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Table/Cell.php | PHPWord_Section_Table_Cell.createTextRun | public function createTextRun($styleParagraph = null) {
$textRun = new PHPWord_Section_TextRun($styleParagraph);
$this->_elementCollection[] = $textRun;
return $textRun;
} | php | public function createTextRun($styleParagraph = null) {
$textRun = new PHPWord_Section_TextRun($styleParagraph);
$this->_elementCollection[] = $textRun;
return $textRun;
} | [
"public",
"function",
"createTextRun",
"(",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"$",
"textRun",
"=",
"new",
"PHPWord_Section_TextRun",
"(",
"$",
"styleParagraph",
")",
";",
"$",
"this",
"->",
"_elementCollection",
"[",
"]",
"=",
"$",
"textRun",
";",
"return",
"$",
"textRun",
";",
"}"
]
| Create a new TextRun
@return PHPWord_Section_TextRun | [
"Create",
"a",
"new",
"TextRun"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Table/Cell.php#L279-L283 |
17,521 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/TOC.php | PHPWord_TOC.addTitle | public static function addTitle($text, $depth = 0) {
$anchor = '_Toc'.++self::$_anchor;
$bookmarkId = self::$_bookmarkId++;
$title = array();
$title['text'] = $text;
$title['depth'] = $depth;
$title['anchor'] = $anchor;
$title['bookmarkId'] = $bookmarkId;
self::$_titles[] = $title;
return array($anchor, $bookmarkId);
} | php | public static function addTitle($text, $depth = 0) {
$anchor = '_Toc'.++self::$_anchor;
$bookmarkId = self::$_bookmarkId++;
$title = array();
$title['text'] = $text;
$title['depth'] = $depth;
$title['anchor'] = $anchor;
$title['bookmarkId'] = $bookmarkId;
self::$_titles[] = $title;
return array($anchor, $bookmarkId);
} | [
"public",
"static",
"function",
"addTitle",
"(",
"$",
"text",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"$",
"anchor",
"=",
"'_Toc'",
".",
"++",
"self",
"::",
"$",
"_anchor",
";",
"$",
"bookmarkId",
"=",
"self",
"::",
"$",
"_bookmarkId",
"++",
";",
"$",
"title",
"=",
"array",
"(",
")",
";",
"$",
"title",
"[",
"'text'",
"]",
"=",
"$",
"text",
";",
"$",
"title",
"[",
"'depth'",
"]",
"=",
"$",
"depth",
";",
"$",
"title",
"[",
"'anchor'",
"]",
"=",
"$",
"anchor",
";",
"$",
"title",
"[",
"'bookmarkId'",
"]",
"=",
"$",
"bookmarkId",
";",
"self",
"::",
"$",
"_titles",
"[",
"]",
"=",
"$",
"title",
";",
"return",
"array",
"(",
"$",
"anchor",
",",
"$",
"bookmarkId",
")",
";",
"}"
]
| Add a Title
@return array | [
"Add",
"a",
"Title"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/TOC.php#L113-L126 |
17,522 | webforge-labs/psc-cms | lib/Psc/Doctrine/Helper.php | Helper.reindex | public static function reindex($collection, $getIndex = 'getIdentifier') {
if (!Code::isTraversable($collection)) {
throw new \InvalidArgumentException('$collection muss Traversable sein. '.Code::varInfo($collection));
}
$getIndex = Code::castGetter($getIndex);
$ret = array();
foreach ($collection as $o) {
$ret[$getIndex($o)] = $o;
}
return $ret;
} | php | public static function reindex($collection, $getIndex = 'getIdentifier') {
if (!Code::isTraversable($collection)) {
throw new \InvalidArgumentException('$collection muss Traversable sein. '.Code::varInfo($collection));
}
$getIndex = Code::castGetter($getIndex);
$ret = array();
foreach ($collection as $o) {
$ret[$getIndex($o)] = $o;
}
return $ret;
} | [
"public",
"static",
"function",
"reindex",
"(",
"$",
"collection",
",",
"$",
"getIndex",
"=",
"'getIdentifier'",
")",
"{",
"if",
"(",
"!",
"Code",
"::",
"isTraversable",
"(",
"$",
"collection",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$collection muss Traversable sein. '",
".",
"Code",
"::",
"varInfo",
"(",
"$",
"collection",
")",
")",
";",
"}",
"$",
"getIndex",
"=",
"Code",
"::",
"castGetter",
"(",
"$",
"getIndex",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"o",
")",
"{",
"$",
"ret",
"[",
"$",
"getIndex",
"(",
"$",
"o",
")",
"]",
"=",
"$",
"o",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Organisiert die Collection mit einem neuen Index
macht eine Kopie der $collection, deshalb erstmal nur array erlaubt, bis ich weiß, was da die arraycollection macht
@param string|Closure $getIndex wenn ein Closure wird als erster Parameter das Objekt der Collection übergeben. wenn ein string ist dies der Name des Getters des indexes für das Objekt in $collection
@TODO was ist schneller:
1. $getIndex in ein Closure zu casten und dann einfach durchlaufe,
2. oder $getIndex als String zu benutzen und jedes mal in der Schleife abfragen ob $getIndex ein String oder ein Closure ist
@return array | [
"Organisiert",
"die",
"Collection",
"mit",
"einem",
"neuen",
"Index"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/Helper.php#L48-L60 |
17,523 | CakeCMS/Core | src/Utility/Toolbar.php | Toolbar.getInstance | public static function getInstance($name = self::DEFAULT_NAME)
{
if (empty(self::$_instances[$name])) {
self::$_instances[$name] = new Toolbar($name);
}
return self::$_instances[$name];
} | php | public static function getInstance($name = self::DEFAULT_NAME)
{
if (empty(self::$_instances[$name])) {
self::$_instances[$name] = new Toolbar($name);
}
return self::$_instances[$name];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"name",
"=",
"self",
"::",
"DEFAULT_NAME",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"self",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
"=",
"new",
"Toolbar",
"(",
"$",
"name",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
";",
"}"
]
| Get toolbar instance.
@param string $name
@return array|Toolbar | [
"Get",
"toolbar",
"instance",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Toolbar.php#L92-L99 |
17,524 | CakeCMS/Core | src/Utility/Toolbar.php | Toolbar.loadItemType | public function loadItemType($type)
{
$signature = md5($type);
if (isset($this->_buttons[$signature])) {
return $this->_buttons[$signature];
}
list($plugin, $name) = pluginSplit($type);
$alias = Slug::filter($name, '_');
$aliasClass = Inflector::classify($alias);
$className = $this->_getItemClassName($plugin, $aliasClass);
if (!$className) {
return false;
}
$this->_buttons[$signature] = new $className($this);
return $this->_buttons[$signature];
} | php | public function loadItemType($type)
{
$signature = md5($type);
if (isset($this->_buttons[$signature])) {
return $this->_buttons[$signature];
}
list($plugin, $name) = pluginSplit($type);
$alias = Slug::filter($name, '_');
$aliasClass = Inflector::classify($alias);
$className = $this->_getItemClassName($plugin, $aliasClass);
if (!$className) {
return false;
}
$this->_buttons[$signature] = new $className($this);
return $this->_buttons[$signature];
} | [
"public",
"function",
"loadItemType",
"(",
"$",
"type",
")",
"{",
"$",
"signature",
"=",
"md5",
"(",
"$",
"type",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_buttons",
"[",
"$",
"signature",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_buttons",
"[",
"$",
"signature",
"]",
";",
"}",
"list",
"(",
"$",
"plugin",
",",
"$",
"name",
")",
"=",
"pluginSplit",
"(",
"$",
"type",
")",
";",
"$",
"alias",
"=",
"Slug",
"::",
"filter",
"(",
"$",
"name",
",",
"'_'",
")",
";",
"$",
"aliasClass",
"=",
"Inflector",
"::",
"classify",
"(",
"$",
"alias",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"_getItemClassName",
"(",
"$",
"plugin",
",",
"$",
"aliasClass",
")",
";",
"if",
"(",
"!",
"$",
"className",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_buttons",
"[",
"$",
"signature",
"]",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
"->",
"_buttons",
"[",
"$",
"signature",
"]",
";",
"}"
]
| Load object of item type.
@param $type
@return ToolbarItem|bool | [
"Load",
"object",
"of",
"item",
"type",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Toolbar.php#L127-L146 |
17,525 | CakeCMS/Core | src/Utility/Toolbar.php | Toolbar.render | public function render()
{
$i = 0;
$output = [];
$count = count($this->_items);
foreach ($this->_items as $item) {
$i++;
$item['class'] = 'item-wrapper tb-item-' . $i;
if ($i == 1) {
$item['class'] .= ' first';
}
if ($i == $count) {
$item['class'] .= ' last';
}
$output[] = $this->renderItem($item);
}
return implode(PHP_EOL, $output);
} | php | public function render()
{
$i = 0;
$output = [];
$count = count($this->_items);
foreach ($this->_items as $item) {
$i++;
$item['class'] = 'item-wrapper tb-item-' . $i;
if ($i == 1) {
$item['class'] .= ' first';
}
if ($i == $count) {
$item['class'] .= ' last';
}
$output[] = $this->renderItem($item);
}
return implode(PHP_EOL, $output);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"_items",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_items",
"as",
"$",
"item",
")",
"{",
"$",
"i",
"++",
";",
"$",
"item",
"[",
"'class'",
"]",
"=",
"'item-wrapper tb-item-'",
".",
"$",
"i",
";",
"if",
"(",
"$",
"i",
"==",
"1",
")",
"{",
"$",
"item",
"[",
"'class'",
"]",
".=",
"' first'",
";",
"}",
"if",
"(",
"$",
"i",
"==",
"$",
"count",
")",
"{",
"$",
"item",
"[",
"'class'",
"]",
".=",
"' last'",
";",
"}",
"$",
"output",
"[",
"]",
"=",
"$",
"this",
"->",
"renderItem",
"(",
"$",
"item",
")",
";",
"}",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"output",
")",
";",
"}"
]
| Render toolbar items.
@return string
@SuppressWarnings(PHPMD.ShortVariable) | [
"Render",
"toolbar",
"items",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Toolbar.php#L167-L188 |
17,526 | CakeCMS/Core | src/Utility/Toolbar.php | Toolbar.renderItem | public function renderItem(&$node)
{
$type = $node[0];
$item = $this->loadItemType($type);
if ($item === false) {
return null;
}
return $item->render($node);
} | php | public function renderItem(&$node)
{
$type = $node[0];
$item = $this->loadItemType($type);
if ($item === false) {
return null;
}
return $item->render($node);
} | [
"public",
"function",
"renderItem",
"(",
"&",
"$",
"node",
")",
"{",
"$",
"type",
"=",
"$",
"node",
"[",
"0",
"]",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"loadItemType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"item",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"item",
"->",
"render",
"(",
"$",
"node",
")",
";",
"}"
]
| Render toolbar item html.
@param $node
@return null|string | [
"Render",
"toolbar",
"item",
"html",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Toolbar.php#L196-L206 |
17,527 | CakeCMS/Core | src/Utility/Toolbar.php | Toolbar._getItemClassName | protected function _getItemClassName($plugin, $aliasClass)
{
if ($plugin === null) {
$plugin = 'Core';
}
$buttonClass = $plugin . '.' . self::CLASS_NAME_PREFIX . $aliasClass;
$className = App::className($buttonClass, self::CLASS_TYPE);
if ($className === false) {
$buttonClass = self::CLASS_NAME_PREFIX . $aliasClass;
$className = App::className($buttonClass, self::CLASS_TYPE);
}
return $className;
} | php | protected function _getItemClassName($plugin, $aliasClass)
{
if ($plugin === null) {
$plugin = 'Core';
}
$buttonClass = $plugin . '.' . self::CLASS_NAME_PREFIX . $aliasClass;
$className = App::className($buttonClass, self::CLASS_TYPE);
if ($className === false) {
$buttonClass = self::CLASS_NAME_PREFIX . $aliasClass;
$className = App::className($buttonClass, self::CLASS_TYPE);
}
return $className;
} | [
"protected",
"function",
"_getItemClassName",
"(",
"$",
"plugin",
",",
"$",
"aliasClass",
")",
"{",
"if",
"(",
"$",
"plugin",
"===",
"null",
")",
"{",
"$",
"plugin",
"=",
"'Core'",
";",
"}",
"$",
"buttonClass",
"=",
"$",
"plugin",
".",
"'.'",
".",
"self",
"::",
"CLASS_NAME_PREFIX",
".",
"$",
"aliasClass",
";",
"$",
"className",
"=",
"App",
"::",
"className",
"(",
"$",
"buttonClass",
",",
"self",
"::",
"CLASS_TYPE",
")",
";",
"if",
"(",
"$",
"className",
"===",
"false",
")",
"{",
"$",
"buttonClass",
"=",
"self",
"::",
"CLASS_NAME_PREFIX",
".",
"$",
"aliasClass",
";",
"$",
"className",
"=",
"App",
"::",
"className",
"(",
"$",
"buttonClass",
",",
"self",
"::",
"CLASS_TYPE",
")",
";",
"}",
"return",
"$",
"className",
";",
"}"
]
| Get full class name.
@param string $plugin
@param string $aliasClass
@return bool|string | [
"Get",
"full",
"class",
"name",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Toolbar.php#L215-L230 |
17,528 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._createIcon | protected function _createIcon(HtmlHelper $html, $title, array $options = [])
{
list($options, $iconOptions) = $this->_createIconAttr($options);
if (Arr::key('createIcon', $iconOptions)) {
unset($iconOptions['createIcon']);
$title = $html->icon($options['icon'], $iconOptions) . PHP_EOL . $title;
unset($options['icon']);
}
if (Arr::key('iconInline', $options)) {
unset($options['iconInline']);
}
return [$title, $options];
} | php | protected function _createIcon(HtmlHelper $html, $title, array $options = [])
{
list($options, $iconOptions) = $this->_createIconAttr($options);
if (Arr::key('createIcon', $iconOptions)) {
unset($iconOptions['createIcon']);
$title = $html->icon($options['icon'], $iconOptions) . PHP_EOL . $title;
unset($options['icon']);
}
if (Arr::key('iconInline', $options)) {
unset($options['iconInline']);
}
return [$title, $options];
} | [
"protected",
"function",
"_createIcon",
"(",
"HtmlHelper",
"$",
"html",
",",
"$",
"title",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"list",
"(",
"$",
"options",
",",
"$",
"iconOptions",
")",
"=",
"$",
"this",
"->",
"_createIconAttr",
"(",
"$",
"options",
")",
";",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'createIcon'",
",",
"$",
"iconOptions",
")",
")",
"{",
"unset",
"(",
"$",
"iconOptions",
"[",
"'createIcon'",
"]",
")",
";",
"$",
"title",
"=",
"$",
"html",
"->",
"icon",
"(",
"$",
"options",
"[",
"'icon'",
"]",
",",
"$",
"iconOptions",
")",
".",
"PHP_EOL",
".",
"$",
"title",
";",
"unset",
"(",
"$",
"options",
"[",
"'icon'",
"]",
")",
";",
"}",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'iconInline'",
",",
"$",
"options",
")",
")",
"{",
"unset",
"(",
"$",
"options",
"[",
"'iconInline'",
"]",
")",
";",
"}",
"return",
"[",
"$",
"title",
",",
"$",
"options",
"]",
";",
"}"
]
| Create current icon.
@param HtmlHelper $html
@param string|int $title
@param array $options
@return array | [
"Create",
"current",
"icon",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L69-L84 |
17,529 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._createIconAttr | protected function _createIconAttr(array $options = [])
{
$iconOptions = ['class' => ''];
if (Arr::key('icon', $options)) {
if (Arr::key('iconClass', $options)) {
$iconOptions = $this->_addClass($iconOptions, $options['iconClass']);
unset($options['iconClass']);
}
list ($options, $iconOptions) = $this->_setIconOptions($options, $iconOptions);
}
return [$options, $iconOptions];
} | php | protected function _createIconAttr(array $options = [])
{
$iconOptions = ['class' => ''];
if (Arr::key('icon', $options)) {
if (Arr::key('iconClass', $options)) {
$iconOptions = $this->_addClass($iconOptions, $options['iconClass']);
unset($options['iconClass']);
}
list ($options, $iconOptions) = $this->_setIconOptions($options, $iconOptions);
}
return [$options, $iconOptions];
} | [
"protected",
"function",
"_createIconAttr",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"iconOptions",
"=",
"[",
"'class'",
"=>",
"''",
"]",
";",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'icon'",
",",
"$",
"options",
")",
")",
"{",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'iconClass'",
",",
"$",
"options",
")",
")",
"{",
"$",
"iconOptions",
"=",
"$",
"this",
"->",
"_addClass",
"(",
"$",
"iconOptions",
",",
"$",
"options",
"[",
"'iconClass'",
"]",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'iconClass'",
"]",
")",
";",
"}",
"list",
"(",
"$",
"options",
",",
"$",
"iconOptions",
")",
"=",
"$",
"this",
"->",
"_setIconOptions",
"(",
"$",
"options",
",",
"$",
"iconOptions",
")",
";",
"}",
"return",
"[",
"$",
"options",
",",
"$",
"iconOptions",
"]",
";",
"}"
]
| Create icon attributes.
@param array $options
@return array | [
"Create",
"icon",
"attributes",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L92-L106 |
17,530 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._getBtnClass | protected function _getBtnClass(array $options = [])
{
if (Arr::key('button', $options)) {
$button = $options['button'];
unset($options['button']);
if (is_callable($this->getConfig('prepareBtnClass'))) {
return (array) call_user_func($this->getConfig('prepareBtnClass'), $this, $options, $button);
}
$options = $this->_setBtnClass($button, $options);
}
return $options;
} | php | protected function _getBtnClass(array $options = [])
{
if (Arr::key('button', $options)) {
$button = $options['button'];
unset($options['button']);
if (is_callable($this->getConfig('prepareBtnClass'))) {
return (array) call_user_func($this->getConfig('prepareBtnClass'), $this, $options, $button);
}
$options = $this->_setBtnClass($button, $options);
}
return $options;
} | [
"protected",
"function",
"_getBtnClass",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'button'",
",",
"$",
"options",
")",
")",
"{",
"$",
"button",
"=",
"$",
"options",
"[",
"'button'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'button'",
"]",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'prepareBtnClass'",
")",
")",
")",
"{",
"return",
"(",
"array",
")",
"call_user_func",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'prepareBtnClass'",
")",
",",
"$",
"this",
",",
"$",
"options",
",",
"$",
"button",
")",
";",
"}",
"$",
"options",
"=",
"$",
"this",
"->",
"_setBtnClass",
"(",
"$",
"button",
",",
"$",
"options",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
]
| Create and get button classes.
@param array $options
@return array | [
"Create",
"and",
"get",
"button",
"classes",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L114-L128 |
17,531 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._getToolTipAttr | protected function _getToolTipAttr(array $options = [], $toggle = 'tooltip')
{
if (Arr::key('tooltip', $options)) {
$tooltip = $options['tooltip'];
unset($options['tooltip']);
if (is_callable($this->getConfig('prepareTooltip'))) {
return (array) call_user_func($this->getConfig('prepareTooltip'), $this, $options, $tooltip);
}
$_options = [
'data-toggle' => $toggle,
'data-placement' => 'top',
];
if (Arr::key('tooltipPos', $options)) {
$_options['data-placement'] = (string) $options['tooltipPos'];
unset($options['tooltipPos']);
}
$options = $this->_setTooltipTitle($tooltip, $options);
return Hash::merge($_options, $options);
}
return $options;
} | php | protected function _getToolTipAttr(array $options = [], $toggle = 'tooltip')
{
if (Arr::key('tooltip', $options)) {
$tooltip = $options['tooltip'];
unset($options['tooltip']);
if (is_callable($this->getConfig('prepareTooltip'))) {
return (array) call_user_func($this->getConfig('prepareTooltip'), $this, $options, $tooltip);
}
$_options = [
'data-toggle' => $toggle,
'data-placement' => 'top',
];
if (Arr::key('tooltipPos', $options)) {
$_options['data-placement'] = (string) $options['tooltipPos'];
unset($options['tooltipPos']);
}
$options = $this->_setTooltipTitle($tooltip, $options);
return Hash::merge($_options, $options);
}
return $options;
} | [
"protected",
"function",
"_getToolTipAttr",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"toggle",
"=",
"'tooltip'",
")",
"{",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'tooltip'",
",",
"$",
"options",
")",
")",
"{",
"$",
"tooltip",
"=",
"$",
"options",
"[",
"'tooltip'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'tooltip'",
"]",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'prepareTooltip'",
")",
")",
")",
"{",
"return",
"(",
"array",
")",
"call_user_func",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'prepareTooltip'",
")",
",",
"$",
"this",
",",
"$",
"options",
",",
"$",
"tooltip",
")",
";",
"}",
"$",
"_options",
"=",
"[",
"'data-toggle'",
"=>",
"$",
"toggle",
",",
"'data-placement'",
"=>",
"'top'",
",",
"]",
";",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'tooltipPos'",
",",
"$",
"options",
")",
")",
"{",
"$",
"_options",
"[",
"'data-placement'",
"]",
"=",
"(",
"string",
")",
"$",
"options",
"[",
"'tooltipPos'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'tooltipPos'",
"]",
")",
";",
"}",
"$",
"options",
"=",
"$",
"this",
"->",
"_setTooltipTitle",
"(",
"$",
"tooltip",
",",
"$",
"options",
")",
";",
"return",
"Hash",
"::",
"merge",
"(",
"$",
"_options",
",",
"$",
"options",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
]
| Create and get tooltip attributes.
@param array $options
@param string $toggle
@return array | [
"Create",
"and",
"get",
"tooltip",
"attributes",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L137-L163 |
17,532 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._prepareBeforeAfterContainer | protected function _prepareBeforeAfterContainer($type, $value)
{
$output = null;
$iconClass = ($type === 'before') ? 'prefix' : 'postfix';
if ($value !== null) {
$output = $value;
if (is_string($output)) {
$hasIcon = preg_match('/icon:[a-zA-Z]/', $output);
if ($hasIcon > 0) {
list (, $icon) = explode(':', $output, 2);
$icon = Str::low($icon);
$output = $this->Html->icon($icon, ['class' => $iconClass]);
}
}
}
return $output;
} | php | protected function _prepareBeforeAfterContainer($type, $value)
{
$output = null;
$iconClass = ($type === 'before') ? 'prefix' : 'postfix';
if ($value !== null) {
$output = $value;
if (is_string($output)) {
$hasIcon = preg_match('/icon:[a-zA-Z]/', $output);
if ($hasIcon > 0) {
list (, $icon) = explode(':', $output, 2);
$icon = Str::low($icon);
$output = $this->Html->icon($icon, ['class' => $iconClass]);
}
}
}
return $output;
} | [
"protected",
"function",
"_prepareBeforeAfterContainer",
"(",
"$",
"type",
",",
"$",
"value",
")",
"{",
"$",
"output",
"=",
"null",
";",
"$",
"iconClass",
"=",
"(",
"$",
"type",
"===",
"'before'",
")",
"?",
"'prefix'",
":",
"'postfix'",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"output",
"=",
"$",
"value",
";",
"if",
"(",
"is_string",
"(",
"$",
"output",
")",
")",
"{",
"$",
"hasIcon",
"=",
"preg_match",
"(",
"'/icon:[a-zA-Z]/'",
",",
"$",
"output",
")",
";",
"if",
"(",
"$",
"hasIcon",
">",
"0",
")",
"{",
"list",
"(",
",",
"$",
"icon",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"output",
",",
"2",
")",
";",
"$",
"icon",
"=",
"Str",
"::",
"low",
"(",
"$",
"icon",
")",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"Html",
"->",
"icon",
"(",
"$",
"icon",
",",
"[",
"'class'",
"=>",
"$",
"iconClass",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"output",
";",
"}"
]
| Prepare before after content for input container.
@param string|int $type Set before or after flag.
@param string|int $value
@return null|string | [
"Prepare",
"before",
"after",
"content",
"for",
"input",
"container",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L172-L190 |
17,533 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._setBtnClass | protected function _setBtnClass($button, array $options = [])
{
if ($button !== true) {
$classes = [$this->_configRead('btnPref')];
foreach ((array) $button as $button) {
$classes[] = $this->_configRead('btnPref') . '-' . $button;
}
$options = $this->_addClass($options, implode(' ', $classes));
}
return $options;
} | php | protected function _setBtnClass($button, array $options = [])
{
if ($button !== true) {
$classes = [$this->_configRead('btnPref')];
foreach ((array) $button as $button) {
$classes[] = $this->_configRead('btnPref') . '-' . $button;
}
$options = $this->_addClass($options, implode(' ', $classes));
}
return $options;
} | [
"protected",
"function",
"_setBtnClass",
"(",
"$",
"button",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"button",
"!==",
"true",
")",
"{",
"$",
"classes",
"=",
"[",
"$",
"this",
"->",
"_configRead",
"(",
"'btnPref'",
")",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"button",
"as",
"$",
"button",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"$",
"this",
"->",
"_configRead",
"(",
"'btnPref'",
")",
".",
"'-'",
".",
"$",
"button",
";",
"}",
"$",
"options",
"=",
"$",
"this",
"->",
"_addClass",
"(",
"$",
"options",
",",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
]
| Setup button classes by options.
@param string $button
@param array $options
@return array | [
"Setup",
"button",
"classes",
"by",
"options",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L199-L210 |
17,534 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._setIconOptions | protected function _setIconOptions(array $options = [], array $iconOptions = [])
{
$icon = $options['icon'];
if (Arr::key('iconInline', $options)) {
$iconPrefix = $this->_configRead('iconPref');
$options = $this->_addClass($options, implode(' ', [
$this->_class('icon'),
$iconPrefix,
$iconPrefix . '-' . $icon
]));
unset($options['icon']);
} else {
$options['escape'] = false;
$iconOptions['createIcon'] = true;
}
return [$options, $iconOptions];
} | php | protected function _setIconOptions(array $options = [], array $iconOptions = [])
{
$icon = $options['icon'];
if (Arr::key('iconInline', $options)) {
$iconPrefix = $this->_configRead('iconPref');
$options = $this->_addClass($options, implode(' ', [
$this->_class('icon'),
$iconPrefix,
$iconPrefix . '-' . $icon
]));
unset($options['icon']);
} else {
$options['escape'] = false;
$iconOptions['createIcon'] = true;
}
return [$options, $iconOptions];
} | [
"protected",
"function",
"_setIconOptions",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"array",
"$",
"iconOptions",
"=",
"[",
"]",
")",
"{",
"$",
"icon",
"=",
"$",
"options",
"[",
"'icon'",
"]",
";",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'iconInline'",
",",
"$",
"options",
")",
")",
"{",
"$",
"iconPrefix",
"=",
"$",
"this",
"->",
"_configRead",
"(",
"'iconPref'",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"_addClass",
"(",
"$",
"options",
",",
"implode",
"(",
"' '",
",",
"[",
"$",
"this",
"->",
"_class",
"(",
"'icon'",
")",
",",
"$",
"iconPrefix",
",",
"$",
"iconPrefix",
".",
"'-'",
".",
"$",
"icon",
"]",
")",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'icon'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"options",
"[",
"'escape'",
"]",
"=",
"false",
";",
"$",
"iconOptions",
"[",
"'createIcon'",
"]",
"=",
"true",
";",
"}",
"return",
"[",
"$",
"options",
",",
"$",
"iconOptions",
"]",
";",
"}"
]
| Setup icon options.
@param array $options
@param array $iconOptions
@return array | [
"Setup",
"icon",
"options",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L219-L237 |
17,535 | CakeCMS/Core | src/View/Helper/Traits/HelperTrait.php | HelperTrait._setTooltipTitle | protected function _setTooltipTitle($tooltip, array $options = [])
{
if ($tooltip === true && !Arr::key('title', $options)) {
$options['title'] = strip_tags($options['label']);
}
if (is_string($tooltip)) {
$options['title'] = $tooltip;
}
return $options;
} | php | protected function _setTooltipTitle($tooltip, array $options = [])
{
if ($tooltip === true && !Arr::key('title', $options)) {
$options['title'] = strip_tags($options['label']);
}
if (is_string($tooltip)) {
$options['title'] = $tooltip;
}
return $options;
} | [
"protected",
"function",
"_setTooltipTitle",
"(",
"$",
"tooltip",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"tooltip",
"===",
"true",
"&&",
"!",
"Arr",
"::",
"key",
"(",
"'title'",
",",
"$",
"options",
")",
")",
"{",
"$",
"options",
"[",
"'title'",
"]",
"=",
"strip_tags",
"(",
"$",
"options",
"[",
"'label'",
"]",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"tooltip",
")",
")",
"{",
"$",
"options",
"[",
"'title'",
"]",
"=",
"$",
"tooltip",
";",
"}",
"return",
"$",
"options",
";",
"}"
]
| Setup tooltip title by options.
@param string $tooltip
@param array $options
@return array | [
"Setup",
"tooltip",
"title",
"by",
"options",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/HelperTrait.php#L246-L257 |
17,536 | aryelgois/yasql-php | src/Utils.php | Utils.arrayAppendLast | public static function arrayAppendLast(
array $array,
string $last,
string $others = null
) {
$count = count($array);
foreach ($array as $key => $value) {
$array[$key] = $value . (--$count > 0 ? $others : $last);
}
return $array;
} | php | public static function arrayAppendLast(
array $array,
string $last,
string $others = null
) {
$count = count($array);
foreach ($array as $key => $value) {
$array[$key] = $value . (--$count > 0 ? $others : $last);
}
return $array;
} | [
"public",
"static",
"function",
"arrayAppendLast",
"(",
"array",
"$",
"array",
",",
"string",
"$",
"last",
",",
"string",
"$",
"others",
"=",
"null",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"array",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
".",
"(",
"--",
"$",
"count",
">",
"0",
"?",
"$",
"others",
":",
"$",
"last",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
]
| Appends a string to the last item in an array
Optionally, appends a string to the other items
@param string[] $array Array to receive data
@param string $last Appended to the last item
@param string $others Appended to the other items | [
"Appends",
"a",
"string",
"to",
"the",
"last",
"item",
"in",
"an",
"array"
]
| f428b180d35bfc1ddf1f9b3323f9b085fbc09ac7 | https://github.com/aryelgois/yasql-php/blob/f428b180d35bfc1ddf1f9b3323f9b085fbc09ac7/src/Utils.php#L28-L38 |
17,537 | barebone-php/barebone-core | lib/Request.php | Request.getContentType | public function getContentType()
{
$contentType = null;
$_contentType = $this->getHeader('Content-Type');
if (!empty($_contentType)) {
$_contentType = explode(';', $_contentType[0]);
$contentType = $_contentType[0];
}
return $contentType;
} | php | public function getContentType()
{
$contentType = null;
$_contentType = $this->getHeader('Content-Type');
if (!empty($_contentType)) {
$_contentType = explode(';', $_contentType[0]);
$contentType = $_contentType[0];
}
return $contentType;
} | [
"public",
"function",
"getContentType",
"(",
")",
"{",
"$",
"contentType",
"=",
"null",
";",
"$",
"_contentType",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"'Content-Type'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"_contentType",
")",
")",
"{",
"$",
"_contentType",
"=",
"explode",
"(",
"';'",
",",
"$",
"_contentType",
"[",
"0",
"]",
")",
";",
"$",
"contentType",
"=",
"$",
"_contentType",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"contentType",
";",
"}"
]
| Get primary content-type header without encoding info
@return string|null | [
"Get",
"primary",
"content",
"-",
"type",
"header",
"without",
"encoding",
"info"
]
| 7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Request.php#L132-L142 |
17,538 | flextype-components/http | Http.php | Http.setResponseStatus | public static function setResponseStatus(int $status) : void
{
if (array_key_exists($status, Http::$http_status_messages)) {
header('HTTP/1.1 ' . $status . ' ' . Http::$http_status_messages[$status]);
}
} | php | public static function setResponseStatus(int $status) : void
{
if (array_key_exists($status, Http::$http_status_messages)) {
header('HTTP/1.1 ' . $status . ' ' . Http::$http_status_messages[$status]);
}
} | [
"public",
"static",
"function",
"setResponseStatus",
"(",
"int",
"$",
"status",
")",
":",
"void",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"status",
",",
"Http",
"::",
"$",
"http_status_messages",
")",
")",
"{",
"header",
"(",
"'HTTP/1.1 '",
".",
"$",
"status",
".",
"' '",
".",
"Http",
"::",
"$",
"http_status_messages",
"[",
"$",
"status",
"]",
")",
";",
"}",
"}"
]
| Set response header status
Http::setResponseStatus(404);
@param integer $status Status code
@return void | [
"Set",
"response",
"header",
"status"
]
| 97c352f79b216355ba655a1cefcdbe69c134dee5 | https://github.com/flextype-components/http/blob/97c352f79b216355ba655a1cefcdbe69c134dee5/Http.php#L95-L100 |
17,539 | flextype-components/http | Http.php | Http.getBaseUrl | public static function getBaseUrl() : string
{
$https = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://';
return $https . rtrim(rtrim($_SERVER['HTTP_HOST'], '\\/') . dirname($_SERVER['PHP_SELF']), '\\/');
} | php | public static function getBaseUrl() : string
{
$https = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://';
return $https . rtrim(rtrim($_SERVER['HTTP_HOST'], '\\/') . dirname($_SERVER['PHP_SELF']), '\\/');
} | [
"public",
"static",
"function",
"getBaseUrl",
"(",
")",
":",
"string",
"{",
"$",
"https",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"==",
"'on'",
")",
"?",
"'https://'",
":",
"'http://'",
";",
"return",
"$",
"https",
".",
"rtrim",
"(",
"rtrim",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
",",
"'\\\\/'",
")",
".",
"dirname",
"(",
"$",
"_SERVER",
"[",
"'PHP_SELF'",
"]",
")",
",",
"'\\\\/'",
")",
";",
"}"
]
| Gets the base URL
echo Http::getBaseUrl();
@return string | [
"Gets",
"the",
"base",
"URL"
]
| 97c352f79b216355ba655a1cefcdbe69c134dee5 | https://github.com/flextype-components/http/blob/97c352f79b216355ba655a1cefcdbe69c134dee5/Http.php#L189-L194 |
17,540 | flextype-components/http | Http.php | Http.getUriString | public static function getUriString() : string
{
// Get request url and script url
$url = '';
$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
$script_url = (isset($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : '';
// Get our url path and trim the / of the left and the right
if ($request_url != $script_url) {
$url = trim(preg_replace('/'. str_replace('/', '\/', str_replace('index.php', '', $script_url)) .'/', '', $request_url, 1), '/');
}
$url = preg_replace('/\?.*/', '', $url); // Strip query string
return $url;
} | php | public static function getUriString() : string
{
// Get request url and script url
$url = '';
$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
$script_url = (isset($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : '';
// Get our url path and trim the / of the left and the right
if ($request_url != $script_url) {
$url = trim(preg_replace('/'. str_replace('/', '\/', str_replace('index.php', '', $script_url)) .'/', '', $request_url, 1), '/');
}
$url = preg_replace('/\?.*/', '', $url); // Strip query string
return $url;
} | [
"public",
"static",
"function",
"getUriString",
"(",
")",
":",
"string",
"{",
"// Get request url and script url",
"$",
"url",
"=",
"''",
";",
"$",
"request_url",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
")",
"?",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
":",
"''",
";",
"$",
"script_url",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'PHP_SELF'",
"]",
")",
")",
"?",
"$",
"_SERVER",
"[",
"'PHP_SELF'",
"]",
":",
"''",
";",
"// Get our url path and trim the / of the left and the right",
"if",
"(",
"$",
"request_url",
"!=",
"$",
"script_url",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/'",
".",
"str_replace",
"(",
"'/'",
",",
"'\\/'",
",",
"str_replace",
"(",
"'index.php'",
",",
"''",
",",
"$",
"script_url",
")",
")",
".",
"'/'",
",",
"''",
",",
"$",
"request_url",
",",
"1",
")",
",",
"'/'",
")",
";",
"}",
"$",
"url",
"=",
"preg_replace",
"(",
"'/\\?.*/'",
",",
"''",
",",
"$",
"url",
")",
";",
"// Strip query string",
"return",
"$",
"url",
";",
"}"
]
| Get Uri String
$uri_string = Http::getUriString();
@access public
@return string | [
"Get",
"Uri",
"String"
]
| 97c352f79b216355ba655a1cefcdbe69c134dee5 | https://github.com/flextype-components/http/blob/97c352f79b216355ba655a1cefcdbe69c134dee5/Http.php#L216-L231 |
17,541 | flextype-components/http | Http.php | Http.getUriSegment | public static function getUriSegment(int $segment)
{
$segments = self::getUriSegments();
return isset($segments[$segment]) ? $segments[$segment] : null;
} | php | public static function getUriSegment(int $segment)
{
$segments = self::getUriSegments();
return isset($segments[$segment]) ? $segments[$segment] : null;
} | [
"public",
"static",
"function",
"getUriSegment",
"(",
"int",
"$",
"segment",
")",
"{",
"$",
"segments",
"=",
"self",
"::",
"getUriSegments",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"segments",
"[",
"$",
"segment",
"]",
")",
"?",
"$",
"segments",
"[",
"$",
"segment",
"]",
":",
"null",
";",
"}"
]
| Get Uri Segment
$uri_segment = Http::getUriSegment(1);
@access public
@param int $segment segment
@return string | [
"Get",
"Uri",
"Segment"
]
| 97c352f79b216355ba655a1cefcdbe69c134dee5 | https://github.com/flextype-components/http/blob/97c352f79b216355ba655a1cefcdbe69c134dee5/Http.php#L255-L259 |
17,542 | npbtrac/yii2-enpii-cms | libs/override/web/NpUrlManager.php | NpUrlManager.matchCode | protected function matchCode($code)
{
$language = $code;
$country = null;
$parts = explode('-', $code);
if (count($parts)===2) {
$language = $parts[0];
$country = strtoupper($parts[1]);
}
if (in_array($code, $this->languages)) {
return [$language, $country];
} elseif (
$country && in_array("$language-$country", $this->languages) ||
in_array("$language-*", $this->languages)
) {
return [$language, $country];
} elseif (in_array($language, $this->languages)) {
return [$language, null];
} else {
return [null, null];
}
} | php | protected function matchCode($code)
{
$language = $code;
$country = null;
$parts = explode('-', $code);
if (count($parts)===2) {
$language = $parts[0];
$country = strtoupper($parts[1]);
}
if (in_array($code, $this->languages)) {
return [$language, $country];
} elseif (
$country && in_array("$language-$country", $this->languages) ||
in_array("$language-*", $this->languages)
) {
return [$language, $country];
} elseif (in_array($language, $this->languages)) {
return [$language, null];
} else {
return [null, null];
}
} | [
"protected",
"function",
"matchCode",
"(",
"$",
"code",
")",
"{",
"$",
"language",
"=",
"$",
"code",
";",
"$",
"country",
"=",
"null",
";",
"$",
"parts",
"=",
"explode",
"(",
"'-'",
",",
"$",
"code",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"2",
")",
"{",
"$",
"language",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"country",
"=",
"strtoupper",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"languages",
")",
")",
"{",
"return",
"[",
"$",
"language",
",",
"$",
"country",
"]",
";",
"}",
"elseif",
"(",
"$",
"country",
"&&",
"in_array",
"(",
"\"$language-$country\"",
",",
"$",
"this",
"->",
"languages",
")",
"||",
"in_array",
"(",
"\"$language-*\"",
",",
"$",
"this",
"->",
"languages",
")",
")",
"{",
"return",
"[",
"$",
"language",
",",
"$",
"country",
"]",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"language",
",",
"$",
"this",
"->",
"languages",
")",
")",
"{",
"return",
"[",
"$",
"language",
",",
"null",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"null",
",",
"null",
"]",
";",
"}",
"}"
]
| Tests whether the given code matches any of the configured languages.
If the code is a single language code, and matches either
- an exact language as configured (ll)
- a language with a country wildcard (ll-*)
this language code is returned.
If the code also contains a country code, and matches either
- an exact language/country code as configured (ll-CC)
- a language with a country wildcard (ll-*)
the code with uppercase country is returned. If only the language part matches
a configured language, that language is returned.
@param string $code the code to match
@return array of [language, country], [language, null] or [null, null] if no match | [
"Tests",
"whether",
"the",
"given",
"code",
"matches",
"any",
"of",
"the",
"configured",
"languages",
"."
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/web/NpUrlManager.php#L363-L384 |
17,543 | slashworks/control-bundle | src/Slashworks/AppBundle/Controller/AboutController.php | AboutController.aboutAction | public function aboutAction()
{
$oLicense = LicenseQuery::create()->findOne();
// include symfony requirements class
require_once dirname(__FILE__) . '/../../../../app/SymfonyRequirements.php';
$symfonyRequirements = new \SymfonyRequirements();
// add additional requirement for mcrypt
$symfonyRequirements->addRequirement(extension_loaded('mcrypt'), "Check if mcrypt ist loaded for RSA encryption", "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>");
// fetch all data
$aRequirements = $symfonyRequirements->getRequirements();
$aRecommendations = $symfonyRequirements->getRecommendations();
$aFailedRequirements = $symfonyRequirements->getFailedRequirements();
$aFailedRecommendations = $symfonyRequirements->getFailedRecommendations();
$iniPath = $symfonyRequirements->getPhpIniConfigPath();
$sVersion = file_get_contents(dirname(__FILE__) . '/../../../../version.txt');
return $this->render('SlashworksAppBundle:About:about.html.twig', array(
"license" => $oLicense,"version" => $sVersion, "iniPath" => $iniPath, "requirements" => $aRequirements, "recommendations" => $aRecommendations, "failedrequirements" => $aFailedRequirements, "failedrecommendations" => $aFailedRecommendations
));
} | php | public function aboutAction()
{
$oLicense = LicenseQuery::create()->findOne();
// include symfony requirements class
require_once dirname(__FILE__) . '/../../../../app/SymfonyRequirements.php';
$symfonyRequirements = new \SymfonyRequirements();
// add additional requirement for mcrypt
$symfonyRequirements->addRequirement(extension_loaded('mcrypt'), "Check if mcrypt ist loaded for RSA encryption", "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>");
// fetch all data
$aRequirements = $symfonyRequirements->getRequirements();
$aRecommendations = $symfonyRequirements->getRecommendations();
$aFailedRequirements = $symfonyRequirements->getFailedRequirements();
$aFailedRecommendations = $symfonyRequirements->getFailedRecommendations();
$iniPath = $symfonyRequirements->getPhpIniConfigPath();
$sVersion = file_get_contents(dirname(__FILE__) . '/../../../../version.txt');
return $this->render('SlashworksAppBundle:About:about.html.twig', array(
"license" => $oLicense,"version" => $sVersion, "iniPath" => $iniPath, "requirements" => $aRequirements, "recommendations" => $aRecommendations, "failedrequirements" => $aFailedRequirements, "failedrecommendations" => $aFailedRecommendations
));
} | [
"public",
"function",
"aboutAction",
"(",
")",
"{",
"$",
"oLicense",
"=",
"LicenseQuery",
"::",
"create",
"(",
")",
"->",
"findOne",
"(",
")",
";",
"// include symfony requirements class",
"require_once",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../../../app/SymfonyRequirements.php'",
";",
"$",
"symfonyRequirements",
"=",
"new",
"\\",
"SymfonyRequirements",
"(",
")",
";",
"// add additional requirement for mcrypt",
"$",
"symfonyRequirements",
"->",
"addRequirement",
"(",
"extension_loaded",
"(",
"'mcrypt'",
")",
",",
"\"Check if mcrypt ist loaded for RSA encryption\"",
",",
"\"Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>\"",
")",
";",
"// fetch all data",
"$",
"aRequirements",
"=",
"$",
"symfonyRequirements",
"->",
"getRequirements",
"(",
")",
";",
"$",
"aRecommendations",
"=",
"$",
"symfonyRequirements",
"->",
"getRecommendations",
"(",
")",
";",
"$",
"aFailedRequirements",
"=",
"$",
"symfonyRequirements",
"->",
"getFailedRequirements",
"(",
")",
";",
"$",
"aFailedRecommendations",
"=",
"$",
"symfonyRequirements",
"->",
"getFailedRecommendations",
"(",
")",
";",
"$",
"iniPath",
"=",
"$",
"symfonyRequirements",
"->",
"getPhpIniConfigPath",
"(",
")",
";",
"$",
"sVersion",
"=",
"file_get_contents",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../../../version.txt'",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:About:about.html.twig'",
",",
"array",
"(",
"\"license\"",
"=>",
"$",
"oLicense",
",",
"\"version\"",
"=>",
"$",
"sVersion",
",",
"\"iniPath\"",
"=>",
"$",
"iniPath",
",",
"\"requirements\"",
"=>",
"$",
"aRequirements",
",",
"\"recommendations\"",
"=>",
"$",
"aRecommendations",
",",
"\"failedrequirements\"",
"=>",
"$",
"aFailedRequirements",
",",
"\"failedrecommendations\"",
"=>",
"$",
"aFailedRecommendations",
")",
")",
";",
"}"
]
| Display form for license activation
@return \Symfony\Component\HttpFoundation\Response | [
"Display",
"form",
"for",
"license",
"activation"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/AboutController.php#L44-L72 |
17,544 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper.initialize | public function initialize(array $config)
{
$isMaterializeCss = $this->getConfig('materializeCss', false);
if ($isMaterializeCss === true) {
$this->_configWrite('prepareBtnClass', function (Helper $form, $options, $button) {
return $this->_prepareBtn($form, $options, $button);
});
$this->_configWrite('prepareTooltip', function (Helper $html, $options, $tooltip) {
return $this->_prepareTooltip($html, $options, $tooltip);
});
}
parent::initialize($config);
} | php | public function initialize(array $config)
{
$isMaterializeCss = $this->getConfig('materializeCss', false);
if ($isMaterializeCss === true) {
$this->_configWrite('prepareBtnClass', function (Helper $form, $options, $button) {
return $this->_prepareBtn($form, $options, $button);
});
$this->_configWrite('prepareTooltip', function (Helper $html, $options, $tooltip) {
return $this->_prepareTooltip($html, $options, $tooltip);
});
}
parent::initialize($config);
} | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"isMaterializeCss",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'materializeCss'",
",",
"false",
")",
";",
"if",
"(",
"$",
"isMaterializeCss",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"_configWrite",
"(",
"'prepareBtnClass'",
",",
"function",
"(",
"Helper",
"$",
"form",
",",
"$",
"options",
",",
"$",
"button",
")",
"{",
"return",
"$",
"this",
"->",
"_prepareBtn",
"(",
"$",
"form",
",",
"$",
"options",
",",
"$",
"button",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"_configWrite",
"(",
"'prepareTooltip'",
",",
"function",
"(",
"Helper",
"$",
"html",
",",
"$",
"options",
",",
"$",
"tooltip",
")",
"{",
"return",
"$",
"this",
"->",
"_prepareTooltip",
"(",
"$",
"html",
",",
"$",
"options",
",",
"$",
"tooltip",
")",
";",
"}",
")",
";",
"}",
"parent",
"::",
"initialize",
"(",
"$",
"config",
")",
";",
"}"
]
| Constructor hook method. Implement this method to avoid having to overwrite the constructor and call parent.
@param array $config The configuration settings provided to this helper.
@return void | [
"Constructor",
"hook",
"method",
".",
"Implement",
"this",
"method",
"to",
"avoid",
"having",
"to",
"overwrite",
"the",
"constructor",
"and",
"call",
"parent",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L90-L105 |
17,545 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper.getAssets | public function getAssets($key)
{
$value = Hash::get($this->_assets, $key);
if (is_string($value)) {
return $value;
}
return Hash::sort((array) $value, '{n}.weight', 'asc');
} | php | public function getAssets($key)
{
$value = Hash::get($this->_assets, $key);
if (is_string($value)) {
return $value;
}
return Hash::sort((array) $value, '{n}.weight', 'asc');
} | [
"public",
"function",
"getAssets",
"(",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"Hash",
"::",
"get",
"(",
"$",
"this",
"->",
"_assets",
",",
"$",
"key",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"Hash",
"::",
"sort",
"(",
"(",
"array",
")",
"$",
"value",
",",
"'{n}.weight'",
",",
"'asc'",
")",
";",
"}"
]
| Get sort assets included list.
@param string $key
@return array|null|string | [
"Get",
"sort",
"assets",
"included",
"list",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L126-L134 |
17,546 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper.icon | public function icon($icon = 'home', array $options = [])
{
$iconPref = $this->_configRead('iconPref');
$_classes = [
$this->_class(__FUNCTION__),
$iconPref,
$iconPref . '-' . $icon,
];
$options = $this->_addClass($options, implode(' ', $_classes));
$classes = $options['class'];
unset($options['class']);
$templater = $this->templater();
return $templater->format(__FUNCTION__, [
'class' => $classes,
'attrs' => $templater->formatAttributes($options),
]);
} | php | public function icon($icon = 'home', array $options = [])
{
$iconPref = $this->_configRead('iconPref');
$_classes = [
$this->_class(__FUNCTION__),
$iconPref,
$iconPref . '-' . $icon,
];
$options = $this->_addClass($options, implode(' ', $_classes));
$classes = $options['class'];
unset($options['class']);
$templater = $this->templater();
return $templater->format(__FUNCTION__, [
'class' => $classes,
'attrs' => $templater->formatAttributes($options),
]);
} | [
"public",
"function",
"icon",
"(",
"$",
"icon",
"=",
"'home'",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"iconPref",
"=",
"$",
"this",
"->",
"_configRead",
"(",
"'iconPref'",
")",
";",
"$",
"_classes",
"=",
"[",
"$",
"this",
"->",
"_class",
"(",
"__FUNCTION__",
")",
",",
"$",
"iconPref",
",",
"$",
"iconPref",
".",
"'-'",
".",
"$",
"icon",
",",
"]",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"_addClass",
"(",
"$",
"options",
",",
"implode",
"(",
"' '",
",",
"$",
"_classes",
")",
")",
";",
"$",
"classes",
"=",
"$",
"options",
"[",
"'class'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'class'",
"]",
")",
";",
"$",
"templater",
"=",
"$",
"this",
"->",
"templater",
"(",
")",
";",
"return",
"$",
"templater",
"->",
"format",
"(",
"__FUNCTION__",
",",
"[",
"'class'",
"=>",
"$",
"classes",
",",
"'attrs'",
"=>",
"$",
"templater",
"->",
"formatAttributes",
"(",
"$",
"options",
")",
",",
"]",
")",
";",
"}"
]
| Create icon element.
@param string $icon
@param array $options
@return null|string | [
"Create",
"icon",
"element",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L143-L161 |
17,547 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper.less | public function less($path, array $options = [])
{
$cssPath = [];
if (!Arr::key('force', $options)) {
$options['force'] = false;
}
if (is_array($path)) {
foreach ($path as $i) {
if ($result = $this->Less->process($i, $options['force'])) {
$cssPath[] = $result;
}
}
}
if (is_string($path) && $result = $this->Less->process($path, $options['force'])) {
$cssPath[] = $result;
}
return $this->css($cssPath, $options);
} | php | public function less($path, array $options = [])
{
$cssPath = [];
if (!Arr::key('force', $options)) {
$options['force'] = false;
}
if (is_array($path)) {
foreach ($path as $i) {
if ($result = $this->Less->process($i, $options['force'])) {
$cssPath[] = $result;
}
}
}
if (is_string($path) && $result = $this->Less->process($path, $options['force'])) {
$cssPath[] = $result;
}
return $this->css($cssPath, $options);
} | [
"public",
"function",
"less",
"(",
"$",
"path",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"cssPath",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"Arr",
"::",
"key",
"(",
"'force'",
",",
"$",
"options",
")",
")",
"{",
"$",
"options",
"[",
"'force'",
"]",
"=",
"false",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"foreach",
"(",
"$",
"path",
"as",
"$",
"i",
")",
"{",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"Less",
"->",
"process",
"(",
"$",
"i",
",",
"$",
"options",
"[",
"'force'",
"]",
")",
")",
"{",
"$",
"cssPath",
"[",
"]",
"=",
"$",
"result",
";",
"}",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"path",
")",
"&&",
"$",
"result",
"=",
"$",
"this",
"->",
"Less",
"->",
"process",
"(",
"$",
"path",
",",
"$",
"options",
"[",
"'force'",
"]",
")",
")",
"{",
"$",
"cssPath",
"[",
"]",
"=",
"$",
"result",
";",
"}",
"return",
"$",
"this",
"->",
"css",
"(",
"$",
"cssPath",
",",
"$",
"options",
")",
";",
"}"
]
| Creates a CSS stylesheets from less.
@param string|array $path
@param array $options
@return null|string
@throws \JBZoo\Less\Exception | [
"Creates",
"a",
"CSS",
"stylesheets",
"from",
"less",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L172-L193 |
17,548 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper.link | public function link($title, $url = null, array $options = [])
{
$options = $this->addClass($options, $this->_class(__FUNCTION__));
$options = Hash::merge([
'escapeTitle' => false,
'clear' => false,
'label' => $title,
], $options);
$isClear = (bool) $options['clear'];
unset($options['clear']);
$options = $this->_setTitleAttr($title, $options);
// Set title in html tag.
if ($this->_isEscapeTitle($title, $isClear, $options)) {
$title = $this->tag('span', $title, ['class' => $this->_class(__FUNCTION__) . '-title']);
}
$options = $this->_getBtnClass($options);
$options = $this->_getToolTipAttr($options);
list($title, $options) = $this->_createIcon($this, $title, $options);
unset($options['label']);
return parent::link($title, $url, $options);
} | php | public function link($title, $url = null, array $options = [])
{
$options = $this->addClass($options, $this->_class(__FUNCTION__));
$options = Hash::merge([
'escapeTitle' => false,
'clear' => false,
'label' => $title,
], $options);
$isClear = (bool) $options['clear'];
unset($options['clear']);
$options = $this->_setTitleAttr($title, $options);
// Set title in html tag.
if ($this->_isEscapeTitle($title, $isClear, $options)) {
$title = $this->tag('span', $title, ['class' => $this->_class(__FUNCTION__) . '-title']);
}
$options = $this->_getBtnClass($options);
$options = $this->_getToolTipAttr($options);
list($title, $options) = $this->_createIcon($this, $title, $options);
unset($options['label']);
return parent::link($title, $url, $options);
} | [
"public",
"function",
"link",
"(",
"$",
"title",
",",
"$",
"url",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"addClass",
"(",
"$",
"options",
",",
"$",
"this",
"->",
"_class",
"(",
"__FUNCTION__",
")",
")",
";",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'escapeTitle'",
"=>",
"false",
",",
"'clear'",
"=>",
"false",
",",
"'label'",
"=>",
"$",
"title",
",",
"]",
",",
"$",
"options",
")",
";",
"$",
"isClear",
"=",
"(",
"bool",
")",
"$",
"options",
"[",
"'clear'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'clear'",
"]",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"_setTitleAttr",
"(",
"$",
"title",
",",
"$",
"options",
")",
";",
"// Set title in html tag.",
"if",
"(",
"$",
"this",
"->",
"_isEscapeTitle",
"(",
"$",
"title",
",",
"$",
"isClear",
",",
"$",
"options",
")",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"tag",
"(",
"'span'",
",",
"$",
"title",
",",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"_class",
"(",
"__FUNCTION__",
")",
".",
"'-title'",
"]",
")",
";",
"}",
"$",
"options",
"=",
"$",
"this",
"->",
"_getBtnClass",
"(",
"$",
"options",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"_getToolTipAttr",
"(",
"$",
"options",
")",
";",
"list",
"(",
"$",
"title",
",",
"$",
"options",
")",
"=",
"$",
"this",
"->",
"_createIcon",
"(",
"$",
"this",
",",
"$",
"title",
",",
"$",
"options",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'label'",
"]",
")",
";",
"return",
"parent",
"::",
"link",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"}"
]
| Create an html link.
@param string $title
@param null|string|array $url
@param array $options
@return string | [
"Create",
"an",
"html",
"link",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L203-L229 |
17,549 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper.status | public function status($status = 0, array $url = [], $icon = 'circle')
{
$class = (int) $status === 1 ? 'ck-green' : 'ck-red';
if (count($url) === 0) {
return $this->icon($icon, ['class' => $class]);
}
return $this->link(null, 'javascript:void(0);', [
'icon' => $icon,
'class' => $class,
'data-url' => $this->Url->build($url)
]);
} | php | public function status($status = 0, array $url = [], $icon = 'circle')
{
$class = (int) $status === 1 ? 'ck-green' : 'ck-red';
if (count($url) === 0) {
return $this->icon($icon, ['class' => $class]);
}
return $this->link(null, 'javascript:void(0);', [
'icon' => $icon,
'class' => $class,
'data-url' => $this->Url->build($url)
]);
} | [
"public",
"function",
"status",
"(",
"$",
"status",
"=",
"0",
",",
"array",
"$",
"url",
"=",
"[",
"]",
",",
"$",
"icon",
"=",
"'circle'",
")",
"{",
"$",
"class",
"=",
"(",
"int",
")",
"$",
"status",
"===",
"1",
"?",
"'ck-green'",
":",
"'ck-red'",
";",
"if",
"(",
"count",
"(",
"$",
"url",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"icon",
"(",
"$",
"icon",
",",
"[",
"'class'",
"=>",
"$",
"class",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"link",
"(",
"null",
",",
"'javascript:void(0);'",
",",
"[",
"'icon'",
"=>",
"$",
"icon",
",",
"'class'",
"=>",
"$",
"class",
",",
"'data-url'",
"=>",
"$",
"this",
"->",
"Url",
"->",
"build",
"(",
"$",
"url",
")",
"]",
")",
";",
"}"
]
| Create status icon or link.
@param int $status
@param array $url
@param string $icon
@return null|string | [
"Create",
"status",
"icon",
"or",
"link",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L251-L263 |
17,550 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper.toggle | public function toggle(Entity $entity, array $url = [], array $data = [])
{
if (count($url) === 0) {
$url = [
'action' => 'toggle',
'prefix' => $this->request->getParam('prefix'),
'plugin' => $this->request->getParam('plugin'),
'controller' => $this->request->getParam('controller'),
(int) $entity->get('id'),
(int) $entity->get('status')
];
}
$data = Hash::merge([
'url' => $url,
'entity' => $entity,
], $data);
return $this->_View->element('Core.' . __FUNCTION__, $data);
} | php | public function toggle(Entity $entity, array $url = [], array $data = [])
{
if (count($url) === 0) {
$url = [
'action' => 'toggle',
'prefix' => $this->request->getParam('prefix'),
'plugin' => $this->request->getParam('plugin'),
'controller' => $this->request->getParam('controller'),
(int) $entity->get('id'),
(int) $entity->get('status')
];
}
$data = Hash::merge([
'url' => $url,
'entity' => $entity,
], $data);
return $this->_View->element('Core.' . __FUNCTION__, $data);
} | [
"public",
"function",
"toggle",
"(",
"Entity",
"$",
"entity",
",",
"array",
"$",
"url",
"=",
"[",
"]",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"url",
")",
"===",
"0",
")",
"{",
"$",
"url",
"=",
"[",
"'action'",
"=>",
"'toggle'",
",",
"'prefix'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
",",
"'plugin'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'plugin'",
")",
",",
"'controller'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'controller'",
")",
",",
"(",
"int",
")",
"$",
"entity",
"->",
"get",
"(",
"'id'",
")",
",",
"(",
"int",
")",
"$",
"entity",
"->",
"get",
"(",
"'status'",
")",
"]",
";",
"}",
"$",
"data",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'entity'",
"=>",
"$",
"entity",
",",
"]",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"_View",
"->",
"element",
"(",
"'Core.'",
".",
"__FUNCTION__",
",",
"$",
"data",
")",
";",
"}"
]
| Create and render ajax toggle element.
@param Entity $entity
@param array $url
@param array $data
@return string | [
"Create",
"and",
"render",
"ajax",
"toggle",
"element",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L273-L292 |
17,551 | CakeCMS/Core | src/View/Helper/HtmlHelper.php | HtmlHelper._setTitleAttr | protected function _setTitleAttr($title, array $options = [])
{
if (!Arr::key('title', $options)) {
$options['title'] = strip_tags($title);
}
return $options;
} | php | protected function _setTitleAttr($title, array $options = [])
{
if (!Arr::key('title', $options)) {
$options['title'] = strip_tags($title);
}
return $options;
} | [
"protected",
"function",
"_setTitleAttr",
"(",
"$",
"title",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"key",
"(",
"'title'",
",",
"$",
"options",
")",
")",
"{",
"$",
"options",
"[",
"'title'",
"]",
"=",
"strip_tags",
"(",
"$",
"title",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
]
| Setup default title attr.
@param string $title
@param array $options
@return array | [
"Setup",
"default",
"title",
"attr",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/HtmlHelper.php#L314-L321 |
17,552 | joomlatools/joomlatools-platform-legacy | code/utilities/xmlelement.php | JXMLElement.asFormattedXml | public function asFormattedXml($compressed = false, $indent = "\t", $level = 0)
{
JLog::add('JXMLElement::asFormattedXml() is deprecated, use SimpleXMLElement::asXml() instead.', JLog::WARNING, 'deprecated');
$out = '';
// Start a new line, indent by the number indicated in $level
$out .= ($compressed) ? '' : "\n" . str_repeat($indent, $level);
// Add a <, and add the name of the tag
$out .= '<' . $this->getName();
// For each attribute, add attr="value"
foreach ($this->attributes() as $attr)
{
$out .= ' ' . $attr->getName() . '="' . htmlspecialchars((string) $attr, ENT_COMPAT, 'UTF-8') . '"';
}
// If there are no children and it contains no data, end it off with a />
if (!count($this->children()) && !(string) $this)
{
$out .= " />";
}
else
{
// If there are children
if (count($this->children()))
{
// Close off the start tag
$out .= '>';
$level++;
// For each child, call the asFormattedXML function (this will ensure that all children are added recursively)
foreach ($this->children() as $child)
{
$out .= $child->asFormattedXml($compressed, $indent, $level);
}
$level--;
// Add the newline and indentation to go along with the close tag
$out .= ($compressed) ? '' : "\n" . str_repeat($indent, $level);
}
elseif ((string) $this)
{
// If there is data, close off the start tag and add the data
$out .= '>' . htmlspecialchars((string) $this, ENT_COMPAT, 'UTF-8');
}
// Add the end tag
$out .= '</' . $this->getName() . '>';
}
return $out;
} | php | public function asFormattedXml($compressed = false, $indent = "\t", $level = 0)
{
JLog::add('JXMLElement::asFormattedXml() is deprecated, use SimpleXMLElement::asXml() instead.', JLog::WARNING, 'deprecated');
$out = '';
// Start a new line, indent by the number indicated in $level
$out .= ($compressed) ? '' : "\n" . str_repeat($indent, $level);
// Add a <, and add the name of the tag
$out .= '<' . $this->getName();
// For each attribute, add attr="value"
foreach ($this->attributes() as $attr)
{
$out .= ' ' . $attr->getName() . '="' . htmlspecialchars((string) $attr, ENT_COMPAT, 'UTF-8') . '"';
}
// If there are no children and it contains no data, end it off with a />
if (!count($this->children()) && !(string) $this)
{
$out .= " />";
}
else
{
// If there are children
if (count($this->children()))
{
// Close off the start tag
$out .= '>';
$level++;
// For each child, call the asFormattedXML function (this will ensure that all children are added recursively)
foreach ($this->children() as $child)
{
$out .= $child->asFormattedXml($compressed, $indent, $level);
}
$level--;
// Add the newline and indentation to go along with the close tag
$out .= ($compressed) ? '' : "\n" . str_repeat($indent, $level);
}
elseif ((string) $this)
{
// If there is data, close off the start tag and add the data
$out .= '>' . htmlspecialchars((string) $this, ENT_COMPAT, 'UTF-8');
}
// Add the end tag
$out .= '</' . $this->getName() . '>';
}
return $out;
} | [
"public",
"function",
"asFormattedXml",
"(",
"$",
"compressed",
"=",
"false",
",",
"$",
"indent",
"=",
"\"\\t\"",
",",
"$",
"level",
"=",
"0",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JXMLElement::asFormattedXml() is deprecated, use SimpleXMLElement::asXml() instead.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"$",
"out",
"=",
"''",
";",
"// Start a new line, indent by the number indicated in $level",
"$",
"out",
".=",
"(",
"$",
"compressed",
")",
"?",
"''",
":",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"indent",
",",
"$",
"level",
")",
";",
"// Add a <, and add the name of the tag",
"$",
"out",
".=",
"'<'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"// For each attribute, add attr=\"value\"",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"(",
")",
"as",
"$",
"attr",
")",
"{",
"$",
"out",
".=",
"' '",
".",
"$",
"attr",
"->",
"getName",
"(",
")",
".",
"'=\"'",
".",
"htmlspecialchars",
"(",
"(",
"string",
")",
"$",
"attr",
",",
"ENT_COMPAT",
",",
"'UTF-8'",
")",
".",
"'\"'",
";",
"}",
"// If there are no children and it contains no data, end it off with a />",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"children",
"(",
")",
")",
"&&",
"!",
"(",
"string",
")",
"$",
"this",
")",
"{",
"$",
"out",
".=",
"\" />\"",
";",
"}",
"else",
"{",
"// If there are children",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"children",
"(",
")",
")",
")",
"{",
"// Close off the start tag",
"$",
"out",
".=",
"'>'",
";",
"$",
"level",
"++",
";",
"// For each child, call the asFormattedXML function (this will ensure that all children are added recursively)",
"foreach",
"(",
"$",
"this",
"->",
"children",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"out",
".=",
"$",
"child",
"->",
"asFormattedXml",
"(",
"$",
"compressed",
",",
"$",
"indent",
",",
"$",
"level",
")",
";",
"}",
"$",
"level",
"--",
";",
"// Add the newline and indentation to go along with the close tag",
"$",
"out",
".=",
"(",
"$",
"compressed",
")",
"?",
"''",
":",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"indent",
",",
"$",
"level",
")",
";",
"}",
"elseif",
"(",
"(",
"string",
")",
"$",
"this",
")",
"{",
"// If there is data, close off the start tag and add the data",
"$",
"out",
".=",
"'>'",
".",
"htmlspecialchars",
"(",
"(",
"string",
")",
"$",
"this",
",",
"ENT_COMPAT",
",",
"'UTF-8'",
")",
";",
"}",
"// Add the end tag",
"$",
"out",
".=",
"'</'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'>'",
";",
"}",
"return",
"$",
"out",
";",
"}"
]
| Return a well-formed XML string based on SimpleXML element
@param boolean $compressed Should we use indentation and newlines ?
@param string $indent Indention character.
@param integer $level The level within the document which informs the indentation.
@return string
@since 11.1
@deprecated 13.3 Use SimpleXMLElement::asXml() instead. | [
"Return",
"a",
"well",
"-",
"formed",
"XML",
"string",
"based",
"on",
"SimpleXML",
"element"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/utilities/xmlelement.php#L49-L103 |
17,553 | steeffeen/FancyManiaLinks | FML/Script/Features/ValuePickerFeature.php | ValuePickerFeature.setLabel | public function setLabel(Label $label)
{
$label->checkId();
$label->setScriptEvents(true);
$this->label = $label;
return $this;
} | php | public function setLabel(Label $label)
{
$label->checkId();
$label->setScriptEvents(true);
$this->label = $label;
return $this;
} | [
"public",
"function",
"setLabel",
"(",
"Label",
"$",
"label",
")",
"{",
"$",
"label",
"->",
"checkId",
"(",
")",
";",
"$",
"label",
"->",
"setScriptEvents",
"(",
"true",
")",
";",
"$",
"this",
"->",
"label",
"=",
"$",
"label",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the Label
@api
@param Label $label Label
@return static | [
"Set",
"the",
"Label"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ValuePickerFeature.php#L93-L99 |
17,554 | steeffeen/FancyManiaLinks | FML/Script/Features/ValuePickerFeature.php | ValuePickerFeature.setValues | public function setValues(array $values)
{
$this->values = array();
foreach ($values as $value) {
$this->addValue($value);
}
return $this;
} | php | public function setValues(array $values)
{
$this->values = array();
foreach ($values as $value) {
$this->addValue($value);
}
return $this;
} | [
"public",
"function",
"setValues",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the possible values
@api
@param string[] $values Possible values
@return static | [
"Set",
"the",
"possible",
"values"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ValuePickerFeature.php#L157-L164 |
17,555 | steeffeen/FancyManiaLinks | FML/Script/Features/ValuePickerFeature.php | ValuePickerFeature.getDefault | public function getDefault()
{
if ($this->default) {
return $this->default;
}
if (!empty($this->values)) {
return reset($this->values);
}
return null;
} | php | public function getDefault()
{
if ($this->default) {
return $this->default;
}
if (!empty($this->values)) {
return reset($this->values);
}
return null;
} | [
"public",
"function",
"getDefault",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"default",
")",
"{",
"return",
"$",
"this",
"->",
"default",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"values",
")",
")",
"{",
"return",
"reset",
"(",
"$",
"this",
"->",
"values",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Get the default value
@api
@return string | [
"Get",
"the",
"default",
"value"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ValuePickerFeature.php#L172-L181 |
17,556 | alphayax/phpdoc_md | src/models/NamespaceMd.php | NamespaceMd.generateTree | public function generateTree( $pad = '', $relativePath = '') {
$generatedMd = '';
/// SubPages
if( ! empty( $this->subPages)){
foreach( $this->subPages as $subPageName => $subPage){
$subPageFile = './' . $relativePath . $subPageName . DIRECTORY_SEPARATOR . $subPage->getPageBfe();
$generatedMd .= "$pad- [$subPageName]($subPageFile)". PHP_EOL;
$generatedMd .= $subPage->generateTree( $pad . ' ', $relativePath . $subPageName . DIRECTORY_SEPARATOR);
}
}
/// Chapters
if( ! empty( $this->classMds)){
foreach($this->classMds as $chapter){
$chapterName = $chapter->getReflexion()->getShortName();
$chapterFile = $relativePath . $this->getPageBfe();
$chapterAnchor = $chapterFile .'#'. $chapter->getReflexion()->getShortName();
$generatedMd .= "$pad- [$chapterName]($chapterAnchor)" . PHP_EOL;
}
}
return $generatedMd;
} | php | public function generateTree( $pad = '', $relativePath = '') {
$generatedMd = '';
/// SubPages
if( ! empty( $this->subPages)){
foreach( $this->subPages as $subPageName => $subPage){
$subPageFile = './' . $relativePath . $subPageName . DIRECTORY_SEPARATOR . $subPage->getPageBfe();
$generatedMd .= "$pad- [$subPageName]($subPageFile)". PHP_EOL;
$generatedMd .= $subPage->generateTree( $pad . ' ', $relativePath . $subPageName . DIRECTORY_SEPARATOR);
}
}
/// Chapters
if( ! empty( $this->classMds)){
foreach($this->classMds as $chapter){
$chapterName = $chapter->getReflexion()->getShortName();
$chapterFile = $relativePath . $this->getPageBfe();
$chapterAnchor = $chapterFile .'#'. $chapter->getReflexion()->getShortName();
$generatedMd .= "$pad- [$chapterName]($chapterAnchor)" . PHP_EOL;
}
}
return $generatedMd;
} | [
"public",
"function",
"generateTree",
"(",
"$",
"pad",
"=",
"''",
",",
"$",
"relativePath",
"=",
"''",
")",
"{",
"$",
"generatedMd",
"=",
"''",
";",
"/// SubPages",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"subPages",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"subPages",
"as",
"$",
"subPageName",
"=>",
"$",
"subPage",
")",
"{",
"$",
"subPageFile",
"=",
"'./'",
".",
"$",
"relativePath",
".",
"$",
"subPageName",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"subPage",
"->",
"getPageBfe",
"(",
")",
";",
"$",
"generatedMd",
".=",
"\"$pad- [$subPageName]($subPageFile)\"",
".",
"PHP_EOL",
";",
"$",
"generatedMd",
".=",
"$",
"subPage",
"->",
"generateTree",
"(",
"$",
"pad",
".",
"' '",
",",
"$",
"relativePath",
".",
"$",
"subPageName",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"}",
"}",
"/// Chapters",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"classMds",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"classMds",
"as",
"$",
"chapter",
")",
"{",
"$",
"chapterName",
"=",
"$",
"chapter",
"->",
"getReflexion",
"(",
")",
"->",
"getShortName",
"(",
")",
";",
"$",
"chapterFile",
"=",
"$",
"relativePath",
".",
"$",
"this",
"->",
"getPageBfe",
"(",
")",
";",
"$",
"chapterAnchor",
"=",
"$",
"chapterFile",
".",
"'#'",
".",
"$",
"chapter",
"->",
"getReflexion",
"(",
")",
"->",
"getShortName",
"(",
")",
";",
"$",
"generatedMd",
".=",
"\"$pad- [$chapterName]($chapterAnchor)\"",
".",
"PHP_EOL",
";",
"}",
"}",
"return",
"$",
"generatedMd",
";",
"}"
]
| Generate overview markdown tree
@param string $pad
@param string $relativePath
@return string | [
"Generate",
"overview",
"markdown",
"tree"
]
| 326da10b837161591a32ab4f36f9b2f4feabbe65 | https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/models/NamespaceMd.php#L73-L96 |
17,557 | alphayax/phpdoc_md | src/models/NamespaceMd.php | NamespaceMd.write | public function write(){
$m = new \Mustache_Engine([
'loader' => new \Mustache_Loader_FilesystemLoader( __DIR__.'/../views')
]);
$template = $m->loadTemplate('Page');
$generatedMd = $template->render( $this);
$this->writeSubPages();
/// Write page
@mkdir( $this->page_rd, 0777, true);
file_put_contents( $this->page_rd . DIRECTORY_SEPARATOR . $this->page_bfe, $generatedMd);
} | php | public function write(){
$m = new \Mustache_Engine([
'loader' => new \Mustache_Loader_FilesystemLoader( __DIR__.'/../views')
]);
$template = $m->loadTemplate('Page');
$generatedMd = $template->render( $this);
$this->writeSubPages();
/// Write page
@mkdir( $this->page_rd, 0777, true);
file_put_contents( $this->page_rd . DIRECTORY_SEPARATOR . $this->page_bfe, $generatedMd);
} | [
"public",
"function",
"write",
"(",
")",
"{",
"$",
"m",
"=",
"new",
"\\",
"Mustache_Engine",
"(",
"[",
"'loader'",
"=>",
"new",
"\\",
"Mustache_Loader_FilesystemLoader",
"(",
"__DIR__",
".",
"'/../views'",
")",
"]",
")",
";",
"$",
"template",
"=",
"$",
"m",
"->",
"loadTemplate",
"(",
"'Page'",
")",
";",
"$",
"generatedMd",
"=",
"$",
"template",
"->",
"render",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"writeSubPages",
"(",
")",
";",
"/// Write page",
"@",
"mkdir",
"(",
"$",
"this",
"->",
"page_rd",
",",
"0777",
",",
"true",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"page_rd",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"page_bfe",
",",
"$",
"generatedMd",
")",
";",
"}"
]
| Write markdown file | [
"Write",
"markdown",
"file"
]
| 326da10b837161591a32ab4f36f9b2f4feabbe65 | https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/models/NamespaceMd.php#L101-L115 |
17,558 | alphayax/phpdoc_md | src/models/NamespaceMd.php | NamespaceMd.writeSubPages | public function writeSubPages() {
foreach( $this->subPages as $subPageName => $subPage) {
$subPageDirectory = $this->page_rd . DIRECTORY_SEPARATOR . $subPageName;
$subPage->setDirectory( $subPageDirectory);
$subPage->write();
}
} | php | public function writeSubPages() {
foreach( $this->subPages as $subPageName => $subPage) {
$subPageDirectory = $this->page_rd . DIRECTORY_SEPARATOR . $subPageName;
$subPage->setDirectory( $subPageDirectory);
$subPage->write();
}
} | [
"public",
"function",
"writeSubPages",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"subPages",
"as",
"$",
"subPageName",
"=>",
"$",
"subPage",
")",
"{",
"$",
"subPageDirectory",
"=",
"$",
"this",
"->",
"page_rd",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"subPageName",
";",
"$",
"subPage",
"->",
"setDirectory",
"(",
"$",
"subPageDirectory",
")",
";",
"$",
"subPage",
"->",
"write",
"(",
")",
";",
"}",
"}"
]
| Write sub pages of this page | [
"Write",
"sub",
"pages",
"of",
"this",
"page"
]
| 326da10b837161591a32ab4f36f9b2f4feabbe65 | https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/models/NamespaceMd.php#L120-L126 |
17,559 | userfriendly/SocialUserBundle | Model/UserIdentity.php | UserIdentity.getReadableType | static public function getReadableType( $type )
{
switch ( $type )
{
case self::TYPE_GOOGLE: return 'google';
case self::TYPE_FACEBOOK: return 'facebook';
case self::TYPE_YAHOO: return 'yahoo';
case self::TYPE_TWITTER: return 'twitter';
}
} | php | static public function getReadableType( $type )
{
switch ( $type )
{
case self::TYPE_GOOGLE: return 'google';
case self::TYPE_FACEBOOK: return 'facebook';
case self::TYPE_YAHOO: return 'yahoo';
case self::TYPE_TWITTER: return 'twitter';
}
} | [
"static",
"public",
"function",
"getReadableType",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"TYPE_GOOGLE",
":",
"return",
"'google'",
";",
"case",
"self",
"::",
"TYPE_FACEBOOK",
":",
"return",
"'facebook'",
";",
"case",
"self",
"::",
"TYPE_YAHOO",
":",
"return",
"'yahoo'",
";",
"case",
"self",
"::",
"TYPE_TWITTER",
":",
"return",
"'twitter'",
";",
"}",
"}"
]
| Convert type to human-readable form
@param integer $type
@return string | [
"Convert",
"type",
"to",
"human",
"-",
"readable",
"form"
]
| 1dfcf76af2bc639901c471e6f28b04d73fb65452 | https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/Model/UserIdentity.php#L112-L121 |
17,560 | userfriendly/SocialUserBundle | Model/UserIdentity.php | UserIdentity.getStorableType | static public function getStorableType( $type )
{
switch ( $type )
{
case 'google': return self::TYPE_GOOGLE;
case 'facebook': return self::TYPE_FACEBOOK;
case 'yahoo': return self::TYPE_YAHOO;
case 'twitter': return self::TYPE_TWITTER;
}
} | php | static public function getStorableType( $type )
{
switch ( $type )
{
case 'google': return self::TYPE_GOOGLE;
case 'facebook': return self::TYPE_FACEBOOK;
case 'yahoo': return self::TYPE_YAHOO;
case 'twitter': return self::TYPE_TWITTER;
}
} | [
"static",
"public",
"function",
"getStorableType",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'google'",
":",
"return",
"self",
"::",
"TYPE_GOOGLE",
";",
"case",
"'facebook'",
":",
"return",
"self",
"::",
"TYPE_FACEBOOK",
";",
"case",
"'yahoo'",
":",
"return",
"self",
"::",
"TYPE_YAHOO",
";",
"case",
"'twitter'",
":",
"return",
"self",
"::",
"TYPE_TWITTER",
";",
"}",
"}"
]
| Convert human-readable type to integer
@param string $type
@return integer | [
"Convert",
"human",
"-",
"readable",
"type",
"to",
"integer"
]
| 1dfcf76af2bc639901c471e6f28b04d73fb65452 | https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/Model/UserIdentity.php#L129-L138 |
17,561 | aedart/laravel-helpers | src/Traits/Logging/PsrLogTrait.php | PsrLogTrait.getPsrLog | public function getPsrLog(): ?LoggerInterface
{
if (!$this->hasPsrLog()) {
$this->setPsrLog($this->getDefaultPsrLog());
}
return $this->psrLog;
} | php | public function getPsrLog(): ?LoggerInterface
{
if (!$this->hasPsrLog()) {
$this->setPsrLog($this->getDefaultPsrLog());
}
return $this->psrLog;
} | [
"public",
"function",
"getPsrLog",
"(",
")",
":",
"?",
"LoggerInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPsrLog",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setPsrLog",
"(",
"$",
"this",
"->",
"getDefaultPsrLog",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"psrLog",
";",
"}"
]
| Get psr log
If no psr log has been set, this method will
set and return a default psr log, if any such
value is available
@see getDefaultPsrLog()
@return LoggerInterface|null psr log or null if none psr log has been set | [
"Get",
"psr",
"log"
]
| 8b81a2d6658f3f8cb62b6be2c34773aaa2df219a | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Logging/PsrLogTrait.php#L53-L59 |
17,562 | benmanu/silverstripe-knowledgebase | code/forms/KnowledgeBaseSearchForm.php | KnowledgeBaseSearchForm.doSearchKnowledgeBase | public function doSearchKnowledgeBase($data, $form)
{
if (!$this->kbPageId) {
return $this->controller->redirectBack();
}
$page = KnowledgebasePage::get()->byID($this->kbPageId);
// just in case the page doesn't actually exist anymore
if (!$page) {
return $this->controller->redirectBack();
}
// should either go to the results page or the landing page depending on if there is a query
$link = (!empty($data['Query']))
? sprintf('%s?q=%s', $page->AbsoluteLink(), strip_tags($data['Query']))
: $page->AbsoluteLink();
$this->extend('UpdateLink', $link, $data);
return $this->controller->redirect($link);
} | php | public function doSearchKnowledgeBase($data, $form)
{
if (!$this->kbPageId) {
return $this->controller->redirectBack();
}
$page = KnowledgebasePage::get()->byID($this->kbPageId);
// just in case the page doesn't actually exist anymore
if (!$page) {
return $this->controller->redirectBack();
}
// should either go to the results page or the landing page depending on if there is a query
$link = (!empty($data['Query']))
? sprintf('%s?q=%s', $page->AbsoluteLink(), strip_tags($data['Query']))
: $page->AbsoluteLink();
$this->extend('UpdateLink', $link, $data);
return $this->controller->redirect($link);
} | [
"public",
"function",
"doSearchKnowledgeBase",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"kbPageId",
")",
"{",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirectBack",
"(",
")",
";",
"}",
"$",
"page",
"=",
"KnowledgebasePage",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"kbPageId",
")",
";",
"// just in case the page doesn't actually exist anymore",
"if",
"(",
"!",
"$",
"page",
")",
"{",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirectBack",
"(",
")",
";",
"}",
"// should either go to the results page or the landing page depending on if there is a query",
"$",
"link",
"=",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'Query'",
"]",
")",
")",
"?",
"sprintf",
"(",
"'%s?q=%s'",
",",
"$",
"page",
"->",
"AbsoluteLink",
"(",
")",
",",
"strip_tags",
"(",
"$",
"data",
"[",
"'Query'",
"]",
")",
")",
":",
"$",
"page",
"->",
"AbsoluteLink",
"(",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"'UpdateLink'",
",",
"$",
"link",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirect",
"(",
"$",
"link",
")",
";",
"}"
]
| Handler for the form submission.
@param array $data
@param Form $form
@return SS_HTTPResponse | [
"Handler",
"for",
"the",
"form",
"submission",
"."
]
| db19bfd4836f43da17ab52e8b53e72a11be64210 | https://github.com/benmanu/silverstripe-knowledgebase/blob/db19bfd4836f43da17ab52e8b53e72a11be64210/code/forms/KnowledgeBaseSearchForm.php#L62-L83 |
17,563 | 2amigos/yiifoundation | helpers/Button.php | Button.group | public static function group($buttons, $htmlOptions = array())
{
ArrayHelper::addValue('class', 'button-group', $htmlOptions);
ob_start();
echo \CHtml::openTag('ul', $htmlOptions);
foreach ($buttons as $button) {
echo $button;
}
echo \CHtml::closeTag('ul');
return ob_get_clean();
} | php | public static function group($buttons, $htmlOptions = array())
{
ArrayHelper::addValue('class', 'button-group', $htmlOptions);
ob_start();
echo \CHtml::openTag('ul', $htmlOptions);
foreach ($buttons as $button) {
echo $button;
}
echo \CHtml::closeTag('ul');
return ob_get_clean();
} | [
"public",
"static",
"function",
"group",
"(",
"$",
"buttons",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"'button-group'",
",",
"$",
"htmlOptions",
")",
";",
"ob_start",
"(",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'ul'",
",",
"$",
"htmlOptions",
")",
";",
"foreach",
"(",
"$",
"buttons",
"as",
"$",
"button",
")",
"{",
"echo",
"$",
"button",
";",
"}",
"echo",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'ul'",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
]
| Generates a group of link buttons
@param array $buttons the link buttons to render in a group
@param array $htmlOptions
@return string
@see http://foundation.zurb.com/docs/components/button-groups.html | [
"Generates",
"a",
"group",
"of",
"link",
"buttons"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Button.php#L54-L66 |
17,564 | 2amigos/yiifoundation | helpers/Button.php | Button.bar | public static function bar($groups, $htmlOptions = array())
{
ArrayHelper::addValue('class', 'button-bar', $htmlOptions);
ob_start();
echo \CHtml::openTag('div', $htmlOptions);
foreach ($groups as $group) {
echo $group;
}
echo \CHtml::closeTag('div');
return ob_get_clean();
} | php | public static function bar($groups, $htmlOptions = array())
{
ArrayHelper::addValue('class', 'button-bar', $htmlOptions);
ob_start();
echo \CHtml::openTag('div', $htmlOptions);
foreach ($groups as $group) {
echo $group;
}
echo \CHtml::closeTag('div');
return ob_get_clean();
} | [
"public",
"static",
"function",
"bar",
"(",
"$",
"groups",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"'button-bar'",
",",
"$",
"htmlOptions",
")",
";",
"ob_start",
"(",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'div'",
",",
"$",
"htmlOptions",
")",
";",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"echo",
"$",
"group",
";",
"}",
"echo",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'div'",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
]
| Generates a button bar by wrapping multiple button groups into a button-bar
@param array $groups the button group to wrap
@param array $htmlOptions
@return string | [
"Generates",
"a",
"button",
"bar",
"by",
"wrapping",
"multiple",
"button",
"groups",
"into",
"a",
"button",
"-",
"bar"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Button.php#L74-L86 |
17,565 | alanpich/slender | src/App.php | App.loadConfigDefaults | protected function loadConfigDefaults($userSettings)
{
$parser = $this['config-parser'];
$defaults = $parser->parseFile(__DIR__ . '/slender.yml');
$userSettings = array_merge_recursive($defaults, $userSettings);
$this['settings']->setArray($userSettings);
} | php | protected function loadConfigDefaults($userSettings)
{
$parser = $this['config-parser'];
$defaults = $parser->parseFile(__DIR__ . '/slender.yml');
$userSettings = array_merge_recursive($defaults, $userSettings);
$this['settings']->setArray($userSettings);
} | [
"protected",
"function",
"loadConfigDefaults",
"(",
"$",
"userSettings",
")",
"{",
"$",
"parser",
"=",
"$",
"this",
"[",
"'config-parser'",
"]",
";",
"$",
"defaults",
"=",
"$",
"parser",
"->",
"parseFile",
"(",
"__DIR__",
".",
"'/slender.yml'",
")",
";",
"$",
"userSettings",
"=",
"array_merge_recursive",
"(",
"$",
"defaults",
",",
"$",
"userSettings",
")",
";",
"$",
"this",
"[",
"'settings'",
"]",
"->",
"setArray",
"(",
"$",
"userSettings",
")",
";",
"}"
]
| Load up config defaults
This is a hardcoded config file within Slender core that sets
up sane default values for config
@var ConfigFileParserInterface $parser | [
"Load",
"up",
"config",
"defaults"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/App.php#L91-L97 |
17,566 | alanpich/slender | src/App.php | App.loadApplicationConfigFiles | protected function loadApplicationConfigFiles($userSettings)
{
$parser = $this['config-parser'];
$loader = $this['config-finder'];
$userSettings = array();
foreach ($loader->findFiles() as $path) {
if (is_readable($path)) {
$parsedFile = $parser->parseFile($path);
if ($parsedFile !== false) {
$this->addConfig($parsedFile);
}
} else {
echo "Invalid path $path\n";
}
}
} | php | protected function loadApplicationConfigFiles($userSettings)
{
$parser = $this['config-parser'];
$loader = $this['config-finder'];
$userSettings = array();
foreach ($loader->findFiles() as $path) {
if (is_readable($path)) {
$parsedFile = $parser->parseFile($path);
if ($parsedFile !== false) {
$this->addConfig($parsedFile);
}
} else {
echo "Invalid path $path\n";
}
}
} | [
"protected",
"function",
"loadApplicationConfigFiles",
"(",
"$",
"userSettings",
")",
"{",
"$",
"parser",
"=",
"$",
"this",
"[",
"'config-parser'",
"]",
";",
"$",
"loader",
"=",
"$",
"this",
"[",
"'config-finder'",
"]",
";",
"$",
"userSettings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"loader",
"->",
"findFiles",
"(",
")",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"$",
"parsedFile",
"=",
"$",
"parser",
"->",
"parseFile",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"parsedFile",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"addConfig",
"(",
"$",
"parsedFile",
")",
";",
"}",
"}",
"else",
"{",
"echo",
"\"Invalid path $path\\n\"",
";",
"}",
"}",
"}"
]
| Load any application config files
@var ConfigFileFinderInterface $loader | [
"Load",
"any",
"application",
"config",
"files"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/App.php#L104-L119 |
17,567 | alanpich/slender | src/App.php | App.registerService | public function registerService($service, $class)
{
$this[$service] = function ($app) use ($class) {
$inst = new $class;
if ($inst instanceof FactoryInterface) {
return $inst->create($app);
} else {
return $inst;
}
};
} | php | public function registerService($service, $class)
{
$this[$service] = function ($app) use ($class) {
$inst = new $class;
if ($inst instanceof FactoryInterface) {
return $inst->create($app);
} else {
return $inst;
}
};
} | [
"public",
"function",
"registerService",
"(",
"$",
"service",
",",
"$",
"class",
")",
"{",
"$",
"this",
"[",
"$",
"service",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"use",
"(",
"$",
"class",
")",
"{",
"$",
"inst",
"=",
"new",
"$",
"class",
";",
"if",
"(",
"$",
"inst",
"instanceof",
"FactoryInterface",
")",
"{",
"return",
"$",
"inst",
"->",
"create",
"(",
"$",
"app",
")",
";",
"}",
"else",
"{",
"return",
"$",
"inst",
";",
"}",
"}",
";",
"}"
]
| Register a Service to the DI container.
Services are singletons, and the same instance
is returned every time the identifier is requested
@param string $service identifier
@param string $class Class to create | [
"Register",
"a",
"Service",
"to",
"the",
"DI",
"container",
".",
"Services",
"are",
"singletons",
"and",
"the",
"same",
"instance",
"is",
"returned",
"every",
"time",
"the",
"identifier",
"is",
"requested"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/App.php#L129-L139 |
17,568 | alanpich/slender | src/App.php | App.registerFactory | public function registerFactory($factory, $class)
{
$this[$factory] = $this->factory(function ($app) use ($class) {
$obj = new $class;
if ($obj instanceof FactoryInterface) {
return $obj->create($app);
} else {
return $obj;
}
});
} | php | public function registerFactory($factory, $class)
{
$this[$factory] = $this->factory(function ($app) use ($class) {
$obj = new $class;
if ($obj instanceof FactoryInterface) {
return $obj->create($app);
} else {
return $obj;
}
});
} | [
"public",
"function",
"registerFactory",
"(",
"$",
"factory",
",",
"$",
"class",
")",
"{",
"$",
"this",
"[",
"$",
"factory",
"]",
"=",
"$",
"this",
"->",
"factory",
"(",
"function",
"(",
"$",
"app",
")",
"use",
"(",
"$",
"class",
")",
"{",
"$",
"obj",
"=",
"new",
"$",
"class",
";",
"if",
"(",
"$",
"obj",
"instanceof",
"FactoryInterface",
")",
"{",
"return",
"$",
"obj",
"->",
"create",
"(",
"$",
"app",
")",
";",
"}",
"else",
"{",
"return",
"$",
"obj",
";",
"}",
"}",
")",
";",
"}"
]
| Register a Factory to the DI container.
Factories return a new instance of a class each
time they are called
@param string $factory identifier
@param string $class Class to create | [
"Register",
"a",
"Factory",
"to",
"the",
"DI",
"container",
".",
"Factories",
"return",
"a",
"new",
"instance",
"of",
"a",
"class",
"each",
"time",
"they",
"are",
"called"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/App.php#L149-L159 |
17,569 | alanpich/slender | src/App.php | App.registerCoreServices | protected function registerCoreServices()
{
$this['util'] = function ($app) {
return new \Slender\Core\Util\Util();
};
$this->registerService('dependency-injector','Slender\Core\DependencyInjector\Factory');
$this->registerService('autoloader', 'Slender\Core\Autoloader\AutoloaderFactory');
$this->registerService('autoloader.psr4', 'Slender\Core\Autoloader\PSR4Factory');
/**
* The configParser is used to translate various file
* formats into PHP arrays
*
* @var ConfigFileParserInterface
* @return \Slender\Core\ConfigParser\Stack
*/
$this['config-parser'] = function () {
return new ConfigParser\Stack(array(
'yml' => new ConfigParser\YAML,
'php' => new ConfigParser\PHP,
'json' => new ConfigParser\JSON,
));
};
/**
* ConfigFinder is responsible for finding, loading and merging
* configuration files
*
* @var ConfigFileFinderInterface
* @return ConfigFileFinderInterface
*/
$this['config-finder'] = function ($app) {
$configLoader = new \Slender\Core\ConfigFinder\ConfigFinder(
$this['settings']['config']['autoload'],
$this['settings']['config']['files']
);
return $configLoader;
};
/**
* ModuleResolver is used for tracking down a module's path
* from it's name
*
* @var ModuleResolverInterface
* @return \Slender\Core\ModuleResolver\ResolverStack
*/
$this['module-resolver'] = function ($app) {
$stack = new ResolverStack(new NamespaceResolver);
$stack->setConfigParser($app['config-parser']);
foreach ($this['settings']['modulePaths'] as $path) {
if (is_readable($path)) {
$stack->prependResolver(new DirectoryResolver($path));
}
}
return $stack;
};
/**
* ModuleLoader is used to load modules & their dependencies,
* registering services & routes etc along the way
*
* @var ModuleLoaderInterface
* @param \Slender\App $app
* @return ModuleLoaderInterface
*/
$this->registerService('module-loader', 'Slender\Core\ModuleLoader\Factory');
} | php | protected function registerCoreServices()
{
$this['util'] = function ($app) {
return new \Slender\Core\Util\Util();
};
$this->registerService('dependency-injector','Slender\Core\DependencyInjector\Factory');
$this->registerService('autoloader', 'Slender\Core\Autoloader\AutoloaderFactory');
$this->registerService('autoloader.psr4', 'Slender\Core\Autoloader\PSR4Factory');
/**
* The configParser is used to translate various file
* formats into PHP arrays
*
* @var ConfigFileParserInterface
* @return \Slender\Core\ConfigParser\Stack
*/
$this['config-parser'] = function () {
return new ConfigParser\Stack(array(
'yml' => new ConfigParser\YAML,
'php' => new ConfigParser\PHP,
'json' => new ConfigParser\JSON,
));
};
/**
* ConfigFinder is responsible for finding, loading and merging
* configuration files
*
* @var ConfigFileFinderInterface
* @return ConfigFileFinderInterface
*/
$this['config-finder'] = function ($app) {
$configLoader = new \Slender\Core\ConfigFinder\ConfigFinder(
$this['settings']['config']['autoload'],
$this['settings']['config']['files']
);
return $configLoader;
};
/**
* ModuleResolver is used for tracking down a module's path
* from it's name
*
* @var ModuleResolverInterface
* @return \Slender\Core\ModuleResolver\ResolverStack
*/
$this['module-resolver'] = function ($app) {
$stack = new ResolverStack(new NamespaceResolver);
$stack->setConfigParser($app['config-parser']);
foreach ($this['settings']['modulePaths'] as $path) {
if (is_readable($path)) {
$stack->prependResolver(new DirectoryResolver($path));
}
}
return $stack;
};
/**
* ModuleLoader is used to load modules & their dependencies,
* registering services & routes etc along the way
*
* @var ModuleLoaderInterface
* @param \Slender\App $app
* @return ModuleLoaderInterface
*/
$this->registerService('module-loader', 'Slender\Core\ModuleLoader\Factory');
} | [
"protected",
"function",
"registerCoreServices",
"(",
")",
"{",
"$",
"this",
"[",
"'util'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"\\",
"Slender",
"\\",
"Core",
"\\",
"Util",
"\\",
"Util",
"(",
")",
";",
"}",
";",
"$",
"this",
"->",
"registerService",
"(",
"'dependency-injector'",
",",
"'Slender\\Core\\DependencyInjector\\Factory'",
")",
";",
"$",
"this",
"->",
"registerService",
"(",
"'autoloader'",
",",
"'Slender\\Core\\Autoloader\\AutoloaderFactory'",
")",
";",
"$",
"this",
"->",
"registerService",
"(",
"'autoloader.psr4'",
",",
"'Slender\\Core\\Autoloader\\PSR4Factory'",
")",
";",
"/**\n * The configParser is used to translate various file\n * formats into PHP arrays\n *\n * @var ConfigFileParserInterface\n * @return \\Slender\\Core\\ConfigParser\\Stack\n */",
"$",
"this",
"[",
"'config-parser'",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"new",
"ConfigParser",
"\\",
"Stack",
"(",
"array",
"(",
"'yml'",
"=>",
"new",
"ConfigParser",
"\\",
"YAML",
",",
"'php'",
"=>",
"new",
"ConfigParser",
"\\",
"PHP",
",",
"'json'",
"=>",
"new",
"ConfigParser",
"\\",
"JSON",
",",
")",
")",
";",
"}",
";",
"/**\n * ConfigFinder is responsible for finding, loading and merging\n * configuration files\n *\n * @var ConfigFileFinderInterface\n * @return ConfigFileFinderInterface\n */",
"$",
"this",
"[",
"'config-finder'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"configLoader",
"=",
"new",
"\\",
"Slender",
"\\",
"Core",
"\\",
"ConfigFinder",
"\\",
"ConfigFinder",
"(",
"$",
"this",
"[",
"'settings'",
"]",
"[",
"'config'",
"]",
"[",
"'autoload'",
"]",
",",
"$",
"this",
"[",
"'settings'",
"]",
"[",
"'config'",
"]",
"[",
"'files'",
"]",
")",
";",
"return",
"$",
"configLoader",
";",
"}",
";",
"/**\n * ModuleResolver is used for tracking down a module's path\n * from it's name\n *\n * @var ModuleResolverInterface\n * @return \\Slender\\Core\\ModuleResolver\\ResolverStack\n */",
"$",
"this",
"[",
"'module-resolver'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"stack",
"=",
"new",
"ResolverStack",
"(",
"new",
"NamespaceResolver",
")",
";",
"$",
"stack",
"->",
"setConfigParser",
"(",
"$",
"app",
"[",
"'config-parser'",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"[",
"'settings'",
"]",
"[",
"'modulePaths'",
"]",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"$",
"stack",
"->",
"prependResolver",
"(",
"new",
"DirectoryResolver",
"(",
"$",
"path",
")",
")",
";",
"}",
"}",
"return",
"$",
"stack",
";",
"}",
";",
"/**\n * ModuleLoader is used to load modules & their dependencies,\n * registering services & routes etc along the way\n *\n * @var ModuleLoaderInterface\n * @param \\Slender\\App $app\n * @return ModuleLoaderInterface\n */",
"$",
"this",
"->",
"registerService",
"(",
"'module-loader'",
",",
"'Slender\\Core\\ModuleLoader\\Factory'",
")",
";",
"}"
]
| Registers core services to the IoC Container | [
"Registers",
"core",
"services",
"to",
"the",
"IoC",
"Container"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/App.php#L236-L311 |
17,570 | gries/rcon | src/Connection.php | Connection.sendMessage | public function sendMessage(Message $message)
{
$this->currentId++;
$messageData = $message->convertToRconData($this->currentId);
$this->client->write($messageData);
return $this->getResponseMessage();
} | php | public function sendMessage(Message $message)
{
$this->currentId++;
$messageData = $message->convertToRconData($this->currentId);
$this->client->write($messageData);
return $this->getResponseMessage();
} | [
"public",
"function",
"sendMessage",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"currentId",
"++",
";",
"$",
"messageData",
"=",
"$",
"message",
"->",
"convertToRconData",
"(",
"$",
"this",
"->",
"currentId",
")",
";",
"$",
"this",
"->",
"client",
"->",
"write",
"(",
"$",
"messageData",
")",
";",
"return",
"$",
"this",
"->",
"getResponseMessage",
"(",
")",
";",
"}"
]
| Send a RCON message.
@param Message $message
@return Message | [
"Send",
"a",
"RCON",
"message",
"."
]
| 7fada05b329d89542692af00ab80db02ad59d45d | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Connection.php#L55-L62 |
17,571 | gries/rcon | src/Connection.php | Connection.getResponseMessage | protected function getResponseMessage()
{
// read the first 4 bytes which include the length of the response
$lengthEncoded = $this->client->read(4);
if (strlen($lengthEncoded) < 4) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$lengthInBytes = unpack('V1size', $lengthEncoded)['size'];
if ($lengthInBytes <= 0) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseData = $this->client->read($lengthInBytes);
// return an empty message if the server did not send any response
if (null === $responseData) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseMessage = new Message();
$responseMessage->initializeFromRconData($responseData);
if ($lengthInBytes >= 4000) {
$this->handleFragmentedResponse($responseMessage);
}
return $responseMessage;
} | php | protected function getResponseMessage()
{
// read the first 4 bytes which include the length of the response
$lengthEncoded = $this->client->read(4);
if (strlen($lengthEncoded) < 4) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$lengthInBytes = unpack('V1size', $lengthEncoded)['size'];
if ($lengthInBytes <= 0) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseData = $this->client->read($lengthInBytes);
// return an empty message if the server did not send any response
if (null === $responseData) {
return new Message('', Message::TYPE_RESPONSE_VALUE);
}
$responseMessage = new Message();
$responseMessage->initializeFromRconData($responseData);
if ($lengthInBytes >= 4000) {
$this->handleFragmentedResponse($responseMessage);
}
return $responseMessage;
} | [
"protected",
"function",
"getResponseMessage",
"(",
")",
"{",
"// read the first 4 bytes which include the length of the response",
"$",
"lengthEncoded",
"=",
"$",
"this",
"->",
"client",
"->",
"read",
"(",
"4",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"lengthEncoded",
")",
"<",
"4",
")",
"{",
"return",
"new",
"Message",
"(",
"''",
",",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
";",
"}",
"$",
"lengthInBytes",
"=",
"unpack",
"(",
"'V1size'",
",",
"$",
"lengthEncoded",
")",
"[",
"'size'",
"]",
";",
"if",
"(",
"$",
"lengthInBytes",
"<=",
"0",
")",
"{",
"return",
"new",
"Message",
"(",
"''",
",",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
";",
"}",
"$",
"responseData",
"=",
"$",
"this",
"->",
"client",
"->",
"read",
"(",
"$",
"lengthInBytes",
")",
";",
"// return an empty message if the server did not send any response",
"if",
"(",
"null",
"===",
"$",
"responseData",
")",
"{",
"return",
"new",
"Message",
"(",
"''",
",",
"Message",
"::",
"TYPE_RESPONSE_VALUE",
")",
";",
"}",
"$",
"responseMessage",
"=",
"new",
"Message",
"(",
")",
";",
"$",
"responseMessage",
"->",
"initializeFromRconData",
"(",
"$",
"responseData",
")",
";",
"if",
"(",
"$",
"lengthInBytes",
">=",
"4000",
")",
"{",
"$",
"this",
"->",
"handleFragmentedResponse",
"(",
"$",
"responseMessage",
")",
";",
"}",
"return",
"$",
"responseMessage",
";",
"}"
]
| Get the response value of the server.
@return string | [
"Get",
"the",
"response",
"value",
"of",
"the",
"server",
"."
]
| 7fada05b329d89542692af00ab80db02ad59d45d | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Connection.php#L69-L100 |
17,572 | gries/rcon | src/Connection.php | Connection.authenticate | protected function authenticate($password)
{
$message = new Message($password, Message::TYPE_AUTH);
$response = $this->sendMessage($message);
if ($response->getType() === Message::TYPE_AUTH_FAILURE) {
throw new AuthenticationFailedException('Could not authenticate to the server.');
}
} | php | protected function authenticate($password)
{
$message = new Message($password, Message::TYPE_AUTH);
$response = $this->sendMessage($message);
if ($response->getType() === Message::TYPE_AUTH_FAILURE) {
throw new AuthenticationFailedException('Could not authenticate to the server.');
}
} | [
"protected",
"function",
"authenticate",
"(",
"$",
"password",
")",
"{",
"$",
"message",
"=",
"new",
"Message",
"(",
"$",
"password",
",",
"Message",
"::",
"TYPE_AUTH",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"sendMessage",
"(",
"$",
"message",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getType",
"(",
")",
"===",
"Message",
"::",
"TYPE_AUTH_FAILURE",
")",
"{",
"throw",
"new",
"AuthenticationFailedException",
"(",
"'Could not authenticate to the server.'",
")",
";",
"}",
"}"
]
| Authenticate with the server.
@param $password
@throws Exception\AuthenticationFailedException | [
"Authenticate",
"with",
"the",
"server",
"."
]
| 7fada05b329d89542692af00ab80db02ad59d45d | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Connection.php#L109-L117 |
17,573 | vufind-org/vufinddate | src/Converter.php | Converter.getDateExceptionMessage | protected function getDateExceptionMessage($details)
{
$errors = "Date/time problem: Details: ";
if (is_array($details['errors']) && $details['error_count'] > 0) {
foreach ($details['errors'] as $error) {
$errors .= $error . " ";
}
} elseif (is_array($details['warnings'])) {
foreach ($details['warnings'] as $warning) {
$errors .= $warning . " ";
}
}
return $errors;
} | php | protected function getDateExceptionMessage($details)
{
$errors = "Date/time problem: Details: ";
if (is_array($details['errors']) && $details['error_count'] > 0) {
foreach ($details['errors'] as $error) {
$errors .= $error . " ";
}
} elseif (is_array($details['warnings'])) {
foreach ($details['warnings'] as $warning) {
$errors .= $warning . " ";
}
}
return $errors;
} | [
"protected",
"function",
"getDateExceptionMessage",
"(",
"$",
"details",
")",
"{",
"$",
"errors",
"=",
"\"Date/time problem: Details: \"",
";",
"if",
"(",
"is_array",
"(",
"$",
"details",
"[",
"'errors'",
"]",
")",
"&&",
"$",
"details",
"[",
"'error_count'",
"]",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"details",
"[",
"'errors'",
"]",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
".=",
"$",
"error",
".",
"\" \"",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"details",
"[",
"'warnings'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"details",
"[",
"'warnings'",
"]",
"as",
"$",
"warning",
")",
"{",
"$",
"errors",
".=",
"$",
"warning",
".",
"\" \"",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
]
| Build an exception message from a detailed error array.
@param array $details Error details
@return string | [
"Build",
"an",
"exception",
"message",
"from",
"a",
"detailed",
"error",
"array",
"."
]
| 1bec5458b48d96fa8ff87123584042780f4c3c24 | https://github.com/vufind-org/vufinddate/blob/1bec5458b48d96fa8ff87123584042780f4c3c24/src/Converter.php#L147-L160 |
17,574 | vufind-org/vufinddate | src/Converter.php | Converter.convertToDisplayDateAndTime | public function convertToDisplayDateAndTime($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayDate($createFormat, $timeString)
. $separator . $this->convertToDisplayTime($createFormat, $timeString);
} | php | public function convertToDisplayDateAndTime($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayDate($createFormat, $timeString)
. $separator . $this->convertToDisplayTime($createFormat, $timeString);
} | [
"public",
"function",
"convertToDisplayDateAndTime",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
",",
"$",
"separator",
"=",
"' '",
")",
"{",
"return",
"$",
"this",
"->",
"convertToDisplayDate",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
".",
"$",
"separator",
".",
"$",
"this",
"->",
"convertToDisplayTime",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
";",
"}"
]
| Public method for getting a date prepended to a time.
@param string $createFormat The format of the time string to be changed
@param string $timeString The time string
@param string $separator String between time/date
@throws DateException
@return string A re-formatted time string | [
"Public",
"method",
"for",
"getting",
"a",
"date",
"prepended",
"to",
"a",
"time",
"."
]
| 1bec5458b48d96fa8ff87123584042780f4c3c24 | https://github.com/vufind-org/vufinddate/blob/1bec5458b48d96fa8ff87123584042780f4c3c24/src/Converter.php#L218-L223 |
17,575 | vufind-org/vufinddate | src/Converter.php | Converter.convertToDisplayTimeAndDate | public function convertToDisplayTimeAndDate($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayTime($createFormat, $timeString)
. $separator . $this->convertToDisplayDate($createFormat, $timeString);
} | php | public function convertToDisplayTimeAndDate($createFormat, $timeString,
$separator = ' '
) {
return $this->convertToDisplayTime($createFormat, $timeString)
. $separator . $this->convertToDisplayDate($createFormat, $timeString);
} | [
"public",
"function",
"convertToDisplayTimeAndDate",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
",",
"$",
"separator",
"=",
"' '",
")",
"{",
"return",
"$",
"this",
"->",
"convertToDisplayTime",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
".",
"$",
"separator",
".",
"$",
"this",
"->",
"convertToDisplayDate",
"(",
"$",
"createFormat",
",",
"$",
"timeString",
")",
";",
"}"
]
| Public method for getting a time prepended to a date.
@param string $createFormat The format of the time string to be changed
@param string $timeString The time string
@param string $separator String between time/date
@throws DateException
@return string A re-formatted time string | [
"Public",
"method",
"for",
"getting",
"a",
"time",
"prepended",
"to",
"a",
"date",
"."
]
| 1bec5458b48d96fa8ff87123584042780f4c3c24 | https://github.com/vufind-org/vufinddate/blob/1bec5458b48d96fa8ff87123584042780f4c3c24/src/Converter.php#L235-L240 |
17,576 | flextype-components/form | Form.php | Form.open | public static function open($action = '', array $attributes = null) : string
{
// Add the form action to the attributes
$attributes['action'] = $action;
if ( ! isset($attributes['method'])) {
// Use POST method
$attributes['method'] = 'post';
}
return '<form'.Html::attributes($attributes).'>';
} | php | public static function open($action = '', array $attributes = null) : string
{
// Add the form action to the attributes
$attributes['action'] = $action;
if ( ! isset($attributes['method'])) {
// Use POST method
$attributes['method'] = 'post';
}
return '<form'.Html::attributes($attributes).'>';
} | [
"public",
"static",
"function",
"open",
"(",
"$",
"action",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Add the form action to the attributes",
"$",
"attributes",
"[",
"'action'",
"]",
"=",
"$",
"action",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'method'",
"]",
")",
")",
"{",
"// Use POST method",
"$",
"attributes",
"[",
"'method'",
"]",
"=",
"'post'",
";",
"}",
"return",
"'<form'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
";",
"}"
]
| Create an opening HTML form tag.
// Form will submit back to the current page using POST
echo Form::open();
// Form will submit to 'search' using GET
echo Form::open('search', array('method' => 'get'));
// When "file" inputs are present, you must include the "enctype"
echo Form::open(null, array('enctype' => 'multipart/form-data'));
@param string $action Form action, defaults to the current request URI.
@param array $attributes HTML attributes.
@return string | [
"Create",
"an",
"opening",
"HTML",
"form",
"tag",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L72-L84 |
17,577 | flextype-components/form | Form.php | Form.input | public static function input(string $name, string $value = '', array $attributes = null) : string
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id'])) ? $attributes['id'] : $name;
// Set the input value
$attributes['value'] = $value;
if ( ! isset($attributes['type'])) {
// Default type is text
$attributes['type'] = 'text';
}
return '<input'.Html::attributes($attributes).'>';
} | php | public static function input(string $name, string $value = '', array $attributes = null) : string
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id'])) ? $attributes['id'] : $name;
// Set the input value
$attributes['value'] = $value;
if ( ! isset($attributes['type'])) {
// Default type is text
$attributes['type'] = 'text';
}
return '<input'.Html::attributes($attributes).'>';
} | [
"public",
"static",
"function",
"input",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"// Set the input id",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"?",
"$",
"attributes",
"[",
"'id'",
"]",
":",
"$",
"name",
";",
"// Set the input value",
"$",
"attributes",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'type'",
"]",
")",
")",
"{",
"// Default type is text",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'text'",
";",
"}",
"return",
"'<input'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
";",
"}"
]
| Create a form input.
Text is default input type.
echo Form::input('username', $username);
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@return string | [
"Create",
"a",
"form",
"input",
".",
"Text",
"is",
"default",
"input",
"type",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L97-L115 |
17,578 | flextype-components/form | Form.php | Form.hidden | public static function hidden(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'hidden';
return Form::input($name, $value, $attributes);
} | php | public static function hidden(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'hidden';
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"hidden",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'hidden'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Create a hidden form input.
echo Form::hidden('user_id', $user_id);
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@return string | [
"Create",
"a",
"hidden",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L127-L133 |
17,579 | flextype-components/form | Form.php | Form.password | public static function password(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'password';
return Form::input($name, $value, $attributes);
} | php | public static function password(string $name, string $value = '', array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'password';
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"password",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'password'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a password form input.
echo Form::password('password');
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@return string | [
"Creates",
"a",
"password",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L145-L151 |
17,580 | flextype-components/form | Form.php | Form.file | public static function file(string $name, array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'file';
return Form::input($name, '', $attributes);
} | php | public static function file(string $name, array $attributes = null) : string
{
// Set the input type
$attributes['type'] = 'file';
return Form::input($name, '', $attributes);
} | [
"public",
"static",
"function",
"file",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'file'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"''",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a file upload form input.
echo Form::file('image');
@param string $name Input name
@param array $attributes HTML attributes
@return string | [
"Creates",
"a",
"file",
"upload",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L162-L168 |
17,581 | flextype-components/form | Form.php | Form.checkbox | public static function checkbox($name, $value = '', $checked = false, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'checkbox';
if ($checked === true) {
// Make the checkbox active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | php | public static function checkbox($name, $value = '', $checked = false, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'checkbox';
if ($checked === true) {
// Make the checkbox active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"checkbox",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"''",
",",
"$",
"checked",
"=",
"false",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'checkbox'",
";",
"if",
"(",
"$",
"checked",
"===",
"true",
")",
"{",
"// Make the checkbox active",
"$",
"attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a checkbox form input.
echo Form::checkbox('i_am_not_a_robot');
@param string $name Input name
@param string $input Input value
@param boolean $checked Checked status
@param array $attributes HTML attributes
@uses Form::input
@return string | [
"Creates",
"a",
"checkbox",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L182-L193 |
17,582 | flextype-components/form | Form.php | Form.radio | public static function radio($name, $value = '', $checked = null, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'radio';
if ($checked === true) {
// Make the radio active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | php | public static function radio($name, $value = '', $checked = null, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'radio';
if ($checked === true) {
// Make the radio active
$attributes['checked'] = 'checked';
}
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"radio",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"''",
",",
"$",
"checked",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'radio'",
";",
"if",
"(",
"$",
"checked",
"===",
"true",
")",
"{",
"// Make the radio active",
"$",
"attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a radio form input.
echo Form::radio('i_am_not_a_robot');
@param string $name Input name
@param string $value Input value
@param boolean $checked Checked status
@param array $attributes HTML attributes
@uses Form::input
@return string | [
"Creates",
"a",
"radio",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L207-L218 |
17,583 | flextype-components/form | Form.php | Form.textarea | public static function textarea($name, $body = '', array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
return '<textarea'.Html::attributes($attributes).'>'.$body.'</textarea>';
} | php | public static function textarea($name, $body = '', array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
return '<textarea'.Html::attributes($attributes).'>'.$body.'</textarea>';
} | [
"public",
"static",
"function",
"textarea",
"(",
"$",
"name",
",",
"$",
"body",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"// Set the input id",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"?",
"$",
"attributes",
"[",
"'id'",
"]",
":",
"$",
"name",
";",
"return",
"'<textarea'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"body",
".",
"'</textarea>'",
";",
"}"
]
| Creates a textarea form input.
echo Form::textarea('text', $text);
@param string $name Name
@param string $body Body
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"textarea",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L231-L240 |
17,584 | flextype-components/form | Form.php | Form.select | public static function select($name, array $options = null, $selected = null, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
$options_output = '';
foreach ($options as $value => $name) {
if ($selected == $value) $current = ' selected '; else $current = '';
$options_output .= '<option value="'.$value.'" '.$current.'>'.$name.'</option>';
}
return '<select'.Html::attributes($attributes).'>'.$options_output.'</select>';
} | php | public static function select($name, array $options = null, $selected = null, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
// Set the input id
$attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name;
$options_output = '';
foreach ($options as $value => $name) {
if ($selected == $value) $current = ' selected '; else $current = '';
$options_output .= '<option value="'.$value.'" '.$current.'>'.$name.'</option>';
}
return '<select'.Html::attributes($attributes).'>'.$options_output.'</select>';
} | [
"public",
"static",
"function",
"select",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"null",
",",
"$",
"selected",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"// Set the input id",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"?",
"$",
"attributes",
"[",
"'id'",
"]",
":",
"$",
"name",
";",
"$",
"options_output",
"=",
"''",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"selected",
"==",
"$",
"value",
")",
"$",
"current",
"=",
"' selected '",
";",
"else",
"$",
"current",
"=",
"''",
";",
"$",
"options_output",
".=",
"'<option value=\"'",
".",
"$",
"value",
".",
"'\" '",
".",
"$",
"current",
".",
"'>'",
".",
"$",
"name",
".",
"'</option>'",
";",
"}",
"return",
"'<select'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"options_output",
".",
"'</select>'",
";",
"}"
]
| Creates a select form input.
<code>
echo Form::select('themes', array('default', 'classic', 'modern'));
</code>
@param string $name Name
@param array $options Options array
@param string $selected Selected option
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"select",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L256-L272 |
17,585 | flextype-components/form | Form.php | Form.submit | public static function submit($name, $value, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'submit';
return Form::input($name, $value, $attributes);
} | php | public static function submit($name, $value, array $attributes = null)
{
// Set the input type
$attributes['type'] = 'submit';
return Form::input($name, $value, $attributes);
} | [
"public",
"static",
"function",
"submit",
"(",
"$",
"name",
",",
"$",
"value",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input type",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'submit'",
";",
"return",
"Form",
"::",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"}"
]
| Creates a submit form input.
<code>
echo Form::submit('save', 'Save');
</code>
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@uses Form::input
@return string | [
"Creates",
"a",
"submit",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L287-L293 |
17,586 | flextype-components/form | Form.php | Form.button | public static function button($name, $body, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
return '<button'.Html::attributes($attributes).'>'.$body.'</button>';
} | php | public static function button($name, $body, array $attributes = null)
{
// Set the input name
$attributes['name'] = $name;
return '<button'.Html::attributes($attributes).'>'.$body.'</button>';
} | [
"public",
"static",
"function",
"button",
"(",
"$",
"name",
",",
"$",
"body",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the input name",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"return",
"'<button'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"body",
".",
"'</button>'",
";",
"}"
]
| Creates a button form input.
echo Form::button('save', 'Save Profile', array('type' => 'submit'));
@param string $name Input name
@param string $value Input value
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"button",
"form",
"input",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L306-L312 |
17,587 | flextype-components/form | Form.php | Form.label | public static function label($input, $text, array $attributes = null)
{
// Set the label target
$attributes['for'] = $input;
return '<label'.Html::attributes($attributes).'>'.$text.'</label>';
} | php | public static function label($input, $text, array $attributes = null)
{
// Set the label target
$attributes['for'] = $input;
return '<label'.Html::attributes($attributes).'>'.$text.'</label>';
} | [
"public",
"static",
"function",
"label",
"(",
"$",
"input",
",",
"$",
"text",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"// Set the label target",
"$",
"attributes",
"[",
"'for'",
"]",
"=",
"$",
"input",
";",
"return",
"'<label'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"text",
".",
"'</label>'",
";",
"}"
]
| Creates a form label.
echo Form::label('username', 'Username');
@param string $input Target input
@param string $text Label text
@param array $attributes HTML attributes
@uses Html::attributes
@return string | [
"Creates",
"a",
"form",
"label",
"."
]
| b3fea245c996dc19d7a0081db6e48dac39fac5e5 | https://github.com/flextype-components/form/blob/b3fea245c996dc19d7a0081db6e48dac39fac5e5/Form.php#L325-L331 |
17,588 | 4devs/ElfinderPhpConnector | Connector.php | Connector.run | public function run($cmd, array $args)
{
if (!isset($this->commands[$cmd])) {
$this->error(sprintf('command %s not exists', $cmd));
}
$response = new Response();
$driverId = isset($args['target']) ? $this->getDriverId($args['target']) : '';
$driverId = !$driverId && isset($args['targets']) ? $this->getDriverId(current($args['targets'])) : $driverId;
$interface = $this->getInterfaceByCmd($cmd);
/*
* @var string $name
* @var DriverInterface $driver
*/
$data = null;
foreach ($this->driverList as $name => $driver) {
if (!$driverId || $driverId == $name) {
if ($driver instanceof $interface) {
if ($driver->mount()) {
$data = $this->runCmd($driver, $cmd, $args, $response);
}
$driver->unmount();
} else {
$this->error(sprintf('command "%s" not supported, please use interface "%s"', $cmd, $interface));
}
$this->addDisabledCommand($driver);
$response->setOptions($driver->getOptions());
}
$response->addFile($driver->getRootFileInfo());
}
if (!empty($args['init'])) {
$response->setApi(DriverInterface::VERSION);
}
return $data ?: $response;
} | php | public function run($cmd, array $args)
{
if (!isset($this->commands[$cmd])) {
$this->error(sprintf('command %s not exists', $cmd));
}
$response = new Response();
$driverId = isset($args['target']) ? $this->getDriverId($args['target']) : '';
$driverId = !$driverId && isset($args['targets']) ? $this->getDriverId(current($args['targets'])) : $driverId;
$interface = $this->getInterfaceByCmd($cmd);
/*
* @var string $name
* @var DriverInterface $driver
*/
$data = null;
foreach ($this->driverList as $name => $driver) {
if (!$driverId || $driverId == $name) {
if ($driver instanceof $interface) {
if ($driver->mount()) {
$data = $this->runCmd($driver, $cmd, $args, $response);
}
$driver->unmount();
} else {
$this->error(sprintf('command "%s" not supported, please use interface "%s"', $cmd, $interface));
}
$this->addDisabledCommand($driver);
$response->setOptions($driver->getOptions());
}
$response->addFile($driver->getRootFileInfo());
}
if (!empty($args['init'])) {
$response->setApi(DriverInterface::VERSION);
}
return $data ?: $response;
} | [
"public",
"function",
"run",
"(",
"$",
"cmd",
",",
"array",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"commands",
"[",
"$",
"cmd",
"]",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'command %s not exists'",
",",
"$",
"cmd",
")",
")",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"driverId",
"=",
"isset",
"(",
"$",
"args",
"[",
"'target'",
"]",
")",
"?",
"$",
"this",
"->",
"getDriverId",
"(",
"$",
"args",
"[",
"'target'",
"]",
")",
":",
"''",
";",
"$",
"driverId",
"=",
"!",
"$",
"driverId",
"&&",
"isset",
"(",
"$",
"args",
"[",
"'targets'",
"]",
")",
"?",
"$",
"this",
"->",
"getDriverId",
"(",
"current",
"(",
"$",
"args",
"[",
"'targets'",
"]",
")",
")",
":",
"$",
"driverId",
";",
"$",
"interface",
"=",
"$",
"this",
"->",
"getInterfaceByCmd",
"(",
"$",
"cmd",
")",
";",
"/*\n * @var string $name\n * @var DriverInterface $driver\n */",
"$",
"data",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"driverList",
"as",
"$",
"name",
"=>",
"$",
"driver",
")",
"{",
"if",
"(",
"!",
"$",
"driverId",
"||",
"$",
"driverId",
"==",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"driver",
"instanceof",
"$",
"interface",
")",
"{",
"if",
"(",
"$",
"driver",
"->",
"mount",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"runCmd",
"(",
"$",
"driver",
",",
"$",
"cmd",
",",
"$",
"args",
",",
"$",
"response",
")",
";",
"}",
"$",
"driver",
"->",
"unmount",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'command \"%s\" not supported, please use interface \"%s\"'",
",",
"$",
"cmd",
",",
"$",
"interface",
")",
")",
";",
"}",
"$",
"this",
"->",
"addDisabledCommand",
"(",
"$",
"driver",
")",
";",
"$",
"response",
"->",
"setOptions",
"(",
"$",
"driver",
"->",
"getOptions",
"(",
")",
")",
";",
"}",
"$",
"response",
"->",
"addFile",
"(",
"$",
"driver",
"->",
"getRootFileInfo",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"'init'",
"]",
")",
")",
"{",
"$",
"response",
"->",
"setApi",
"(",
"DriverInterface",
"::",
"VERSION",
")",
";",
"}",
"return",
"$",
"data",
"?",
":",
"$",
"response",
";",
"}"
]
| run command.
@param string $cmd
@param array $args
@return Response|HttpResponse | [
"run",
"command",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L105-L140 |
17,589 | 4devs/ElfinderPhpConnector | Connector.php | Connector.addDriver | public function addDriver(DriverInterface $driver)
{
$driver->setConnector($this);
$this->driverList[$driver->getDriverId()] = $driver;
return $this;
} | php | public function addDriver(DriverInterface $driver)
{
$driver->setConnector($this);
$this->driverList[$driver->getDriverId()] = $driver;
return $this;
} | [
"public",
"function",
"addDriver",
"(",
"DriverInterface",
"$",
"driver",
")",
"{",
"$",
"driver",
"->",
"setConnector",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"driverList",
"[",
"$",
"driver",
"->",
"getDriverId",
"(",
")",
"]",
"=",
"$",
"driver",
";",
"return",
"$",
"this",
";",
"}"
]
| add Driver.
@param DriverInterface $driver
@return $this | [
"add",
"Driver",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L176-L182 |
17,590 | 4devs/ElfinderPhpConnector | Connector.php | Connector.setDrivers | public function setDrivers(array $drivers)
{
$this->driverList = array();
foreach ($drivers as $driver) {
$this->addDriver($driver);
}
return $this;
} | php | public function setDrivers(array $drivers)
{
$this->driverList = array();
foreach ($drivers as $driver) {
$this->addDriver($driver);
}
return $this;
} | [
"public",
"function",
"setDrivers",
"(",
"array",
"$",
"drivers",
")",
"{",
"$",
"this",
"->",
"driverList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"drivers",
"as",
"$",
"driver",
")",
"{",
"$",
"this",
"->",
"addDriver",
"(",
"$",
"driver",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| set All Drivers.
@param array $drivers
@return $this | [
"set",
"All",
"Drivers",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L191-L199 |
17,591 | 4devs/ElfinderPhpConnector | Connector.php | Connector.error | public function error($message)
{
if ($this->logger) {
$this->logger->error($message);
}
if (!$this->debug) {
throw new \RuntimeException($message);
}
} | php | public function error($message)
{
if ($this->logger) {
$this->logger->error($message);
}
if (!$this->debug) {
throw new \RuntimeException($message);
}
} | [
"public",
"function",
"error",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"message",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"debug",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"message",
")",
";",
"}",
"}"
]
| error Handling.
@param string $message
@throws \RuntimeException | [
"error",
"Handling",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L208-L216 |
17,592 | 4devs/ElfinderPhpConnector | Connector.php | Connector.getDriverId | public function getDriverId($targetHash)
{
if (is_array($targetHash)) {
$targetHash = current($targetHash);
}
return substr($targetHash, 0, strpos($targetHash, '_'));
} | php | public function getDriverId($targetHash)
{
if (is_array($targetHash)) {
$targetHash = current($targetHash);
}
return substr($targetHash, 0, strpos($targetHash, '_'));
} | [
"public",
"function",
"getDriverId",
"(",
"$",
"targetHash",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"targetHash",
")",
")",
"{",
"$",
"targetHash",
"=",
"current",
"(",
"$",
"targetHash",
")",
";",
"}",
"return",
"substr",
"(",
"$",
"targetHash",
",",
"0",
",",
"strpos",
"(",
"$",
"targetHash",
",",
"'_'",
")",
")",
";",
"}"
]
| get Driver Id from hash target.
@param string $targetHash
@return string | [
"get",
"Driver",
"Id",
"from",
"hash",
"target",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L239-L246 |
17,593 | 4devs/ElfinderPhpConnector | Connector.php | Connector.runCmd | private function runCmd(DriverInterface $driver, $cmd, array $args, Response $response)
{
$data = null;
try {
if ($driver->isAllowedCommand($cmd)) {
$data = call_user_func_array(
array($driver, $cmd),
$this->getArgs($args, $cmd, $response, $driver->getDriverId())
);
} else {
$this->error(sprintf('command "%s" not allowed', $cmd));
}
} catch (Exception $e) {
$this->error($e->getMessage());
}
return $data instanceof HttpResponse ? $data : $response;
} | php | private function runCmd(DriverInterface $driver, $cmd, array $args, Response $response)
{
$data = null;
try {
if ($driver->isAllowedCommand($cmd)) {
$data = call_user_func_array(
array($driver, $cmd),
$this->getArgs($args, $cmd, $response, $driver->getDriverId())
);
} else {
$this->error(sprintf('command "%s" not allowed', $cmd));
}
} catch (Exception $e) {
$this->error($e->getMessage());
}
return $data instanceof HttpResponse ? $data : $response;
} | [
"private",
"function",
"runCmd",
"(",
"DriverInterface",
"$",
"driver",
",",
"$",
"cmd",
",",
"array",
"$",
"args",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"data",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"$",
"driver",
"->",
"isAllowedCommand",
"(",
"$",
"cmd",
")",
")",
"{",
"$",
"data",
"=",
"call_user_func_array",
"(",
"array",
"(",
"$",
"driver",
",",
"$",
"cmd",
")",
",",
"$",
"this",
"->",
"getArgs",
"(",
"$",
"args",
",",
"$",
"cmd",
",",
"$",
"response",
",",
"$",
"driver",
"->",
"getDriverId",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'command \"%s\" not allowed'",
",",
"$",
"cmd",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"data",
"instanceof",
"HttpResponse",
"?",
"$",
"data",
":",
"$",
"response",
";",
"}"
]
| run cmd.
@param DriverInterface $driver
@param string $cmd
@param array $args
@param Response $response
@return Response | [
"run",
"cmd",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L258-L275 |
17,594 | 4devs/ElfinderPhpConnector | Connector.php | Connector.addDisabledCommand | private function addDisabledCommand(AbstractDriver $driver)
{
foreach ($this->commands as $name => $command) {
$interface = $this->getInterfaceByCmd($name);
if (!$driver instanceof $interface) {
$driver->addDisabledCmd($name);
}
}
return $this;
} | php | private function addDisabledCommand(AbstractDriver $driver)
{
foreach ($this->commands as $name => $command) {
$interface = $this->getInterfaceByCmd($name);
if (!$driver instanceof $interface) {
$driver->addDisabledCmd($name);
}
}
return $this;
} | [
"private",
"function",
"addDisabledCommand",
"(",
"AbstractDriver",
"$",
"driver",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"name",
"=>",
"$",
"command",
")",
"{",
"$",
"interface",
"=",
"$",
"this",
"->",
"getInterfaceByCmd",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"driver",
"instanceof",
"$",
"interface",
")",
"{",
"$",
"driver",
"->",
"addDisabledCmd",
"(",
"$",
"name",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| add Disabled Command.
@param AbstractDriver $driver
@return $this | [
"add",
"Disabled",
"Command",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L296-L306 |
17,595 | 4devs/ElfinderPhpConnector | Connector.php | Connector.getArgs | private function getArgs(array $args, $cmd, $response, $driverId)
{
$response = array($response);
$allowedArgs = $this->commands[$cmd];
unset($allowedArgs['interface']);
foreach ($allowedArgs as $key => $value) {
if (isset($args[$key])) {
$response[$key] = $args[$key];
if (isset($this->filenameInRequest[$key])) {
$response[$key] = self::getNameByTarget($args[$key], $driverId);
} elseif ($key == 'targets') {
$response[$key] = array_map(
function ($val) use ($driverId) {
return self::getNameByTarget($val, $driverId);
},
$args[$key]
);
}
} elseif (isset($this->defaultValues[$key])) {
$response[$key] = $this->defaultValues[$key];
} elseif ($value) {
$this->error(sprintf('parameter "%s" in cmd "%s" required', $key, $cmd));
}
}
return $response;
} | php | private function getArgs(array $args, $cmd, $response, $driverId)
{
$response = array($response);
$allowedArgs = $this->commands[$cmd];
unset($allowedArgs['interface']);
foreach ($allowedArgs as $key => $value) {
if (isset($args[$key])) {
$response[$key] = $args[$key];
if (isset($this->filenameInRequest[$key])) {
$response[$key] = self::getNameByTarget($args[$key], $driverId);
} elseif ($key == 'targets') {
$response[$key] = array_map(
function ($val) use ($driverId) {
return self::getNameByTarget($val, $driverId);
},
$args[$key]
);
}
} elseif (isset($this->defaultValues[$key])) {
$response[$key] = $this->defaultValues[$key];
} elseif ($value) {
$this->error(sprintf('parameter "%s" in cmd "%s" required', $key, $cmd));
}
}
return $response;
} | [
"private",
"function",
"getArgs",
"(",
"array",
"$",
"args",
",",
"$",
"cmd",
",",
"$",
"response",
",",
"$",
"driverId",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"$",
"response",
")",
";",
"$",
"allowedArgs",
"=",
"$",
"this",
"->",
"commands",
"[",
"$",
"cmd",
"]",
";",
"unset",
"(",
"$",
"allowedArgs",
"[",
"'interface'",
"]",
")",
";",
"foreach",
"(",
"$",
"allowedArgs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"$",
"args",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filenameInRequest",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"getNameByTarget",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
",",
"$",
"driverId",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'targets'",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"array_map",
"(",
"function",
"(",
"$",
"val",
")",
"use",
"(",
"$",
"driverId",
")",
"{",
"return",
"self",
"::",
"getNameByTarget",
"(",
"$",
"val",
",",
"$",
"driverId",
")",
";",
"}",
",",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"defaultValues",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"response",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"defaultValues",
"[",
"$",
"key",
"]",
";",
"}",
"elseif",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"sprintf",
"(",
"'parameter \"%s\" in cmd \"%s\" required'",
",",
"$",
"key",
",",
"$",
"cmd",
")",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
]
| get Allowed Arguments.
@param array $args
@param string $cmd
@param Response $response
@param string $driverId
@return array | [
"get",
"Allowed",
"Arguments",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Connector.php#L318-L344 |
17,596 | jfusion/org.jfusion.framework | src/Plugin/Auth.php | Auth.checkPassword | function checkPassword(Userinfo $userinfo) {
return $this->comparePassword($userinfo->password, $this->generateEncryptedPassword($userinfo));
} | php | function checkPassword(Userinfo $userinfo) {
return $this->comparePassword($userinfo->password, $this->generateEncryptedPassword($userinfo));
} | [
"function",
"checkPassword",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"return",
"$",
"this",
"->",
"comparePassword",
"(",
"$",
"userinfo",
"->",
"password",
",",
"$",
"this",
"->",
"generateEncryptedPassword",
"(",
"$",
"userinfo",
")",
")",
";",
"}"
]
| used by framework to ensure a password test
@param Userinfo $userinfo userdata object containing the userdata
@return boolean | [
"used",
"by",
"framework",
"to",
"ensure",
"a",
"password",
"test"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Auth.php#L61-L63 |
17,597 | zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeOctet | public function writeOctet($n)
{
if ($n < 0 || $n > 255) {
throw new \InvalidArgumentException('Octet out of range 0..255');
}
$this->flushBits();
$this->out .= chr($n);
return $this;
} | php | public function writeOctet($n)
{
if ($n < 0 || $n > 255) {
throw new \InvalidArgumentException('Octet out of range 0..255');
}
$this->flushBits();
$this->out .= chr($n);
return $this;
} | [
"public",
"function",
"writeOctet",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"<",
"0",
"||",
"$",
"n",
">",
"255",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Octet out of range 0..255'",
")",
";",
"}",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"out",
".=",
"chr",
"(",
"$",
"n",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write an integer as an unsigned 8-bit value.
@param $n
@return Writer
@throws \InvalidArgumentException | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"8",
"-",
"bit",
"value",
"."
]
| b96777b372f556797db4fd0ba02edb18d4bf4a1e | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L138-L147 |
17,598 | zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeShort | public function writeShort($n)
{
if ($n < 0 || $n > 65535) {
throw new \InvalidArgumentException('Octet out of range 0..65535');
}
$this->flushBits();
$this->out .= pack('n', $n);
return $this;
} | php | public function writeShort($n)
{
if ($n < 0 || $n > 65535) {
throw new \InvalidArgumentException('Octet out of range 0..65535');
}
$this->flushBits();
$this->out .= pack('n', $n);
return $this;
} | [
"public",
"function",
"writeShort",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"<",
"0",
"||",
"$",
"n",
">",
"65535",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Octet out of range 0..65535'",
")",
";",
"}",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"out",
".=",
"pack",
"(",
"'n'",
",",
"$",
"n",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write an integer as an unsigned 16-bit value.
@param $n
@return Writer
@throws \InvalidArgumentException | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"16",
"-",
"bit",
"value",
"."
]
| b96777b372f556797db4fd0ba02edb18d4bf4a1e | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L157-L166 |
17,599 | zircote/AMQP | library/AMQP/Wire/Writer.php | Writer.writeLong | public function writeLong($n)
{
$this->flushBits();
$this->out .= implode('', Writer::chrByteSplit($n, 4));
return $this;
} | php | public function writeLong($n)
{
$this->flushBits();
$this->out .= implode('', Writer::chrByteSplit($n, 4));
return $this;
} | [
"public",
"function",
"writeLong",
"(",
"$",
"n",
")",
"{",
"$",
"this",
"->",
"flushBits",
"(",
")",
";",
"$",
"this",
"->",
"out",
".=",
"implode",
"(",
"''",
",",
"Writer",
"::",
"chrByteSplit",
"(",
"$",
"n",
",",
"4",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Write an integer as an unsigned 32-bit value.
@param $n
@return Writer | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"32",
"-",
"bit",
"value",
"."
]
| b96777b372f556797db4fd0ba02edb18d4bf4a1e | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/Writer.php#L175-L180 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.