repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
nabab/bbn | src/bbn/user/preferences.php | preferences.move_bit | public function move_bit(string $id, string $id_parent = null): ?bool
{
if (
\bbn\str::is_uid($id) &&
(
(\bbn\str::is_uid($id_parent) && $this->get_bit($id_parent)) ||
\is_null($id_parent)
) &&
($bit = $this->get_bit($id)) &&
($cf = $this->get_class_cfg()) &&
($cfg = $cf['arch']['user_options_bits'])
){
$upd = [
$cfg['id_parent'] => $id_parent,
$cfg['num'] => $this->get_max_bit_num($bit[$cfg['id_user_option']], $id_parent, true)
];
return !!$this->db->update($cf['tables']['user_options_bits'], $upd, [$cfg['id'] => $id]);
}
return null;
} | php | public function move_bit(string $id, string $id_parent = null): ?bool
{
if (
\bbn\str::is_uid($id) &&
(
(\bbn\str::is_uid($id_parent) && $this->get_bit($id_parent)) ||
\is_null($id_parent)
) &&
($bit = $this->get_bit($id)) &&
($cf = $this->get_class_cfg()) &&
($cfg = $cf['arch']['user_options_bits'])
){
$upd = [
$cfg['id_parent'] => $id_parent,
$cfg['num'] => $this->get_max_bit_num($bit[$cfg['id_user_option']], $id_parent, true)
];
return !!$this->db->update($cf['tables']['user_options_bits'], $upd, [$cfg['id'] => $id]);
}
return null;
} | [
"public",
"function",
"move_bit",
"(",
"string",
"$",
"id",
",",
"string",
"$",
"id_parent",
"=",
"null",
")",
":",
"?",
"bool",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
"&&",
"(",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_parent",
")",
"&&",
"$",
"this",
"->",
"get_bit",
"(",
"$",
"id_parent",
")",
")",
"||",
"\\",
"is_null",
"(",
"$",
"id_parent",
")",
")",
"&&",
"(",
"$",
"bit",
"=",
"$",
"this",
"->",
"get_bit",
"(",
"$",
"id",
")",
")",
"&&",
"(",
"$",
"cf",
"=",
"$",
"this",
"->",
"get_class_cfg",
"(",
")",
")",
"&&",
"(",
"$",
"cfg",
"=",
"$",
"cf",
"[",
"'arch'",
"]",
"[",
"'user_options_bits'",
"]",
")",
")",
"{",
"$",
"upd",
"=",
"[",
"$",
"cfg",
"[",
"'id_parent'",
"]",
"=>",
"$",
"id_parent",
",",
"$",
"cfg",
"[",
"'num'",
"]",
"=>",
"$",
"this",
"->",
"get_max_bit_num",
"(",
"$",
"bit",
"[",
"$",
"cfg",
"[",
"'id_user_option'",
"]",
"]",
",",
"$",
"id_parent",
",",
"true",
")",
"]",
";",
"return",
"!",
"!",
"$",
"this",
"->",
"db",
"->",
"update",
"(",
"$",
"cf",
"[",
"'tables'",
"]",
"[",
"'user_options_bits'",
"]",
",",
"$",
"upd",
",",
"[",
"$",
"cfg",
"[",
"'id'",
"]",
"=>",
"$",
"id",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Moves a bit.
@param string $id The bit's ID
@param string|null The new parent's ID
@return bool|null | [
"Moves",
"a",
"bit",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1289-L1308 |
nabab/bbn | src/bbn/user/preferences.php | preferences.get_max_bit_num | public function get_max_bit_num(string $id_user_option, string $id_parent = null, bool $incr = false): int
{
if (
\bbn\str::is_uid($id_user_option) &&
(\bbn\str::is_uid($id_parent) || is_null($id_parent)) &&
($cf = $this->get_class_cfg()) &&
($cfg = $cf['arch']['user_options_bits'])
){
if ( $max = $this->db->select_one([
'table' => $cf['tables']['user_options_bits'],
'fields' => ["MAX($cfg[num])"],
'where' => [
'conditions' => [[
'field' => $cfg['id_user_option'],
'value' => $id_user_option
], [
'field' => $cfg['id_parent'],
empty($id_parent) ? 'operator' : 'value' => $id_parent ?: 'isnull'
]]
]
]) ){
$max = (int)$max;
return $incr ? $max+1 : $max;
}
return 0;
}
} | php | public function get_max_bit_num(string $id_user_option, string $id_parent = null, bool $incr = false): int
{
if (
\bbn\str::is_uid($id_user_option) &&
(\bbn\str::is_uid($id_parent) || is_null($id_parent)) &&
($cf = $this->get_class_cfg()) &&
($cfg = $cf['arch']['user_options_bits'])
){
if ( $max = $this->db->select_one([
'table' => $cf['tables']['user_options_bits'],
'fields' => ["MAX($cfg[num])"],
'where' => [
'conditions' => [[
'field' => $cfg['id_user_option'],
'value' => $id_user_option
], [
'field' => $cfg['id_parent'],
empty($id_parent) ? 'operator' : 'value' => $id_parent ?: 'isnull'
]]
]
]) ){
$max = (int)$max;
return $incr ? $max+1 : $max;
}
return 0;
}
} | [
"public",
"function",
"get_max_bit_num",
"(",
"string",
"$",
"id_user_option",
",",
"string",
"$",
"id_parent",
"=",
"null",
",",
"bool",
"$",
"incr",
"=",
"false",
")",
":",
"int",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_user_option",
")",
"&&",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_parent",
")",
"||",
"is_null",
"(",
"$",
"id_parent",
")",
")",
"&&",
"(",
"$",
"cf",
"=",
"$",
"this",
"->",
"get_class_cfg",
"(",
")",
")",
"&&",
"(",
"$",
"cfg",
"=",
"$",
"cf",
"[",
"'arch'",
"]",
"[",
"'user_options_bits'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"max",
"=",
"$",
"this",
"->",
"db",
"->",
"select_one",
"(",
"[",
"'table'",
"=>",
"$",
"cf",
"[",
"'tables'",
"]",
"[",
"'user_options_bits'",
"]",
",",
"'fields'",
"=>",
"[",
"\"MAX($cfg[num])\"",
"]",
",",
"'where'",
"=>",
"[",
"'conditions'",
"=>",
"[",
"[",
"'field'",
"=>",
"$",
"cfg",
"[",
"'id_user_option'",
"]",
",",
"'value'",
"=>",
"$",
"id_user_option",
"]",
",",
"[",
"'field'",
"=>",
"$",
"cfg",
"[",
"'id_parent'",
"]",
",",
"empty",
"(",
"$",
"id_parent",
")",
"?",
"'operator'",
":",
"'value'",
"=>",
"$",
"id_parent",
"?",
":",
"'isnull'",
"]",
"]",
"]",
"]",
")",
")",
"{",
"$",
"max",
"=",
"(",
"int",
")",
"$",
"max",
";",
"return",
"$",
"incr",
"?",
"$",
"max",
"+",
"1",
":",
"$",
"max",
";",
"}",
"return",
"0",
";",
"}",
"}"
] | Gets the maximum num value of the user option's bits.
@param string $id_user_option The user option's ID
@param string|null $id_parent The parent's ID
@param bool $incr Set it to true if you want the result increased by 1
@return int | [
"Gets",
"the",
"maximum",
"num",
"value",
"of",
"the",
"user",
"option",
"s",
"bits",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1318-L1344 |
nabab/bbn | src/bbn/user/preferences.php | preferences.get_by_bit | public function get_by_bit(string $id): ?array
{
$t =& $this;
if ( \bbn\str::is_uid($id) ){
return $this->db->rselect([
'table' => $this->class_cfg['table'],
'fields' => array_map(function($v) use($t){
return $this->class_cfg['table'].'.'.$v;
}, array_values($this->class_cfg['arch']['user_options'])),
'join' => [[
'table' => $this->class_cfg['tables']['user_options_bits'],
'on' => [
'conditions' => [[
'field' => $this->class_cfg['arch']['user_options_bits']['id_user_option'],
'exp' => $this->class_cfg['table'].'.'.$this->fields['id']
]]
]
]],
'where' => [
$this->class_cfg['tables']['user_options_bits'].'.'.$this->class_cfg['arch']['user_options_bits']['id'] => $id
]
]);
}
} | php | public function get_by_bit(string $id): ?array
{
$t =& $this;
if ( \bbn\str::is_uid($id) ){
return $this->db->rselect([
'table' => $this->class_cfg['table'],
'fields' => array_map(function($v) use($t){
return $this->class_cfg['table'].'.'.$v;
}, array_values($this->class_cfg['arch']['user_options'])),
'join' => [[
'table' => $this->class_cfg['tables']['user_options_bits'],
'on' => [
'conditions' => [[
'field' => $this->class_cfg['arch']['user_options_bits']['id_user_option'],
'exp' => $this->class_cfg['table'].'.'.$this->fields['id']
]]
]
]],
'where' => [
$this->class_cfg['tables']['user_options_bits'].'.'.$this->class_cfg['arch']['user_options_bits']['id'] => $id
]
]);
}
} | [
"public",
"function",
"get_by_bit",
"(",
"string",
"$",
"id",
")",
":",
"?",
"array",
"{",
"$",
"t",
"=",
"&",
"$",
"this",
";",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"rselect",
"(",
"[",
"'table'",
"=>",
"$",
"this",
"->",
"class_cfg",
"[",
"'table'",
"]",
",",
"'fields'",
"=>",
"array_map",
"(",
"function",
"(",
"$",
"v",
")",
"use",
"(",
"$",
"t",
")",
"{",
"return",
"$",
"this",
"->",
"class_cfg",
"[",
"'table'",
"]",
".",
"'.'",
".",
"$",
"v",
";",
"}",
",",
"array_values",
"(",
"$",
"this",
"->",
"class_cfg",
"[",
"'arch'",
"]",
"[",
"'user_options'",
"]",
")",
")",
",",
"'join'",
"=>",
"[",
"[",
"'table'",
"=>",
"$",
"this",
"->",
"class_cfg",
"[",
"'tables'",
"]",
"[",
"'user_options_bits'",
"]",
",",
"'on'",
"=>",
"[",
"'conditions'",
"=>",
"[",
"[",
"'field'",
"=>",
"$",
"this",
"->",
"class_cfg",
"[",
"'arch'",
"]",
"[",
"'user_options_bits'",
"]",
"[",
"'id_user_option'",
"]",
",",
"'exp'",
"=>",
"$",
"this",
"->",
"class_cfg",
"[",
"'table'",
"]",
".",
"'.'",
".",
"$",
"this",
"->",
"fields",
"[",
"'id'",
"]",
"]",
"]",
"]",
"]",
"]",
",",
"'where'",
"=>",
"[",
"$",
"this",
"->",
"class_cfg",
"[",
"'tables'",
"]",
"[",
"'user_options_bits'",
"]",
".",
"'.'",
".",
"$",
"this",
"->",
"class_cfg",
"[",
"'arch'",
"]",
"[",
"'user_options_bits'",
"]",
"[",
"'id'",
"]",
"=>",
"$",
"id",
"]",
"]",
")",
";",
"}",
"}"
] | Gets a preference row from a bit ID
@param string $id The bit's ID
@return array | [
"Gets",
"a",
"preference",
"row",
"from",
"a",
"bit",
"ID"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1355-L1378 |
nabab/bbn | src/bbn/user/preferences.php | preferences.get_id_by_bit | public function get_id_by_bit(string $id): ?string
{
if ( \bbn\str::is_uid($id) && ($p = $this->get_by_bit($id)) ){
return $p[$this->fields['id']];
}
return null;
} | php | public function get_id_by_bit(string $id): ?string
{
if ( \bbn\str::is_uid($id) && ($p = $this->get_by_bit($id)) ){
return $p[$this->fields['id']];
}
return null;
} | [
"public",
"function",
"get_id_by_bit",
"(",
"string",
"$",
"id",
")",
":",
"?",
"string",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
"&&",
"(",
"$",
"p",
"=",
"$",
"this",
"->",
"get_by_bit",
"(",
"$",
"id",
")",
")",
")",
"{",
"return",
"$",
"p",
"[",
"$",
"this",
"->",
"fields",
"[",
"'id'",
"]",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Gets the preference's ID from a bit ID
@param string $id The bit's ID
@return string | [
"Gets",
"the",
"preference",
"s",
"ID",
"from",
"a",
"bit",
"ID"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1386-L1392 |
mothership-ec/composer | src/Composer/Repository/Pear/ChannelReader.php | ChannelReader.selectRestVersion | private function selectRestVersion($channelXml, $supportedVersions)
{
$channelXml->registerXPathNamespace('ns', self::CHANNEL_NS);
foreach ($supportedVersions as $version) {
$xpathTest = "ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']";
$testResult = $channelXml->xpath($xpathTest);
if (count($testResult) > 0) {
return array('version' => $version, 'baseUrl' => (string) $testResult[0]);
}
}
return null;
} | php | private function selectRestVersion($channelXml, $supportedVersions)
{
$channelXml->registerXPathNamespace('ns', self::CHANNEL_NS);
foreach ($supportedVersions as $version) {
$xpathTest = "ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']";
$testResult = $channelXml->xpath($xpathTest);
if (count($testResult) > 0) {
return array('version' => $version, 'baseUrl' => (string) $testResult[0]);
}
}
return null;
} | [
"private",
"function",
"selectRestVersion",
"(",
"$",
"channelXml",
",",
"$",
"supportedVersions",
")",
"{",
"$",
"channelXml",
"->",
"registerXPathNamespace",
"(",
"'ns'",
",",
"self",
"::",
"CHANNEL_NS",
")",
";",
"foreach",
"(",
"$",
"supportedVersions",
"as",
"$",
"version",
")",
"{",
"$",
"xpathTest",
"=",
"\"ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']\"",
";",
"$",
"testResult",
"=",
"$",
"channelXml",
"->",
"xpath",
"(",
"$",
"xpathTest",
")",
";",
"if",
"(",
"count",
"(",
"$",
"testResult",
")",
">",
"0",
")",
"{",
"return",
"array",
"(",
"'version'",
"=>",
"$",
"version",
",",
"'baseUrl'",
"=>",
"(",
"string",
")",
"$",
"testResult",
"[",
"0",
"]",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Reads channel supported REST interfaces and selects one of them
@param $channelXml \SimpleXMLElement
@param $supportedVersions string[] supported PEAR REST protocols
@return array|null hash with selected version and baseUrl | [
"Reads",
"channel",
"supported",
"REST",
"interfaces",
"and",
"selects",
"one",
"of",
"them"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Pear/ChannelReader.php#L78-L91 |
vaibhavpandeyvpz/sandesh | src/CookieFactory.php | CookieFactory.createCookie | public function createCookie($header)
{
$parts = preg_split('~\\s*[;]\\s*~', $header);
list($name, $value) = explode('=', array_shift($parts), 2);
$cookie = new Cookie($name);
if (is_string($value)) {
$cookie = $cookie->withValue(urldecode($value));
}
while ($nvp = array_shift($parts)) {
$nvp = explode('=', $nvp, 2);
$value = count($nvp) === 2 ? $nvp[1] : null;
switch (strtolower($nvp[0])) {
case 'domain':
$cookie = $cookie->withDomain($value);
break;
case 'expires':
$cookie = $cookie->withExpiry($value);
break;
case 'httponly':
$cookie = $cookie->withHttpOnly(true);
break;
case 'max-age':
$cookie = $cookie->withMaxAge($value);
break;
case 'path':
$cookie = $cookie->withPath($value);
break;
case 'secure':
$cookie = $cookie->withSecure(true);
break;
}
}
return $cookie;
} | php | public function createCookie($header)
{
$parts = preg_split('~\\s*[;]\\s*~', $header);
list($name, $value) = explode('=', array_shift($parts), 2);
$cookie = new Cookie($name);
if (is_string($value)) {
$cookie = $cookie->withValue(urldecode($value));
}
while ($nvp = array_shift($parts)) {
$nvp = explode('=', $nvp, 2);
$value = count($nvp) === 2 ? $nvp[1] : null;
switch (strtolower($nvp[0])) {
case 'domain':
$cookie = $cookie->withDomain($value);
break;
case 'expires':
$cookie = $cookie->withExpiry($value);
break;
case 'httponly':
$cookie = $cookie->withHttpOnly(true);
break;
case 'max-age':
$cookie = $cookie->withMaxAge($value);
break;
case 'path':
$cookie = $cookie->withPath($value);
break;
case 'secure':
$cookie = $cookie->withSecure(true);
break;
}
}
return $cookie;
} | [
"public",
"function",
"createCookie",
"(",
"$",
"header",
")",
"{",
"$",
"parts",
"=",
"preg_split",
"(",
"'~\\\\s*[;]\\\\s*~'",
",",
"$",
"header",
")",
";",
"list",
"(",
"$",
"name",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"'='",
",",
"array_shift",
"(",
"$",
"parts",
")",
",",
"2",
")",
";",
"$",
"cookie",
"=",
"new",
"Cookie",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"cookie",
"=",
"$",
"cookie",
"->",
"withValue",
"(",
"urldecode",
"(",
"$",
"value",
")",
")",
";",
"}",
"while",
"(",
"$",
"nvp",
"=",
"array_shift",
"(",
"$",
"parts",
")",
")",
"{",
"$",
"nvp",
"=",
"explode",
"(",
"'='",
",",
"$",
"nvp",
",",
"2",
")",
";",
"$",
"value",
"=",
"count",
"(",
"$",
"nvp",
")",
"===",
"2",
"?",
"$",
"nvp",
"[",
"1",
"]",
":",
"null",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"nvp",
"[",
"0",
"]",
")",
")",
"{",
"case",
"'domain'",
":",
"$",
"cookie",
"=",
"$",
"cookie",
"->",
"withDomain",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'expires'",
":",
"$",
"cookie",
"=",
"$",
"cookie",
"->",
"withExpiry",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'httponly'",
":",
"$",
"cookie",
"=",
"$",
"cookie",
"->",
"withHttpOnly",
"(",
"true",
")",
";",
"break",
";",
"case",
"'max-age'",
":",
"$",
"cookie",
"=",
"$",
"cookie",
"->",
"withMaxAge",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'path'",
":",
"$",
"cookie",
"=",
"$",
"cookie",
"->",
"withPath",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'secure'",
":",
"$",
"cookie",
"=",
"$",
"cookie",
"->",
"withSecure",
"(",
"true",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"cookie",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/CookieFactory.php#L23-L56 |
brick/di | src/DependencyInjectionException.php | DependencyInjectionException.keyNotRegistered | public static function keyNotRegistered(string $key) : DependencyInjectionException
{
if (class_exists($key)) {
$message = 'The class "' . $key . '" is not marked as injected, and not registered with the container.';
} else {
$message = 'The key "' . $key . '" is not registered with the container.';
}
return new self($message);
} | php | public static function keyNotRegistered(string $key) : DependencyInjectionException
{
if (class_exists($key)) {
$message = 'The class "' . $key . '" is not marked as injected, and not registered with the container.';
} else {
$message = 'The key "' . $key . '" is not registered with the container.';
}
return new self($message);
} | [
"public",
"static",
"function",
"keyNotRegistered",
"(",
"string",
"$",
"key",
")",
":",
"DependencyInjectionException",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"key",
")",
")",
"{",
"$",
"message",
"=",
"'The class \"'",
".",
"$",
"key",
".",
"'\" is not marked as injected, and not registered with the container.'",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"'The key \"'",
".",
"$",
"key",
".",
"'\" is not registered with the container.'",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"message",
")",
";",
"}"
] | @param string $key
@return DependencyInjectionException | [
"@param",
"string",
"$key"
] | train | https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/DependencyInjectionException.php#L17-L26 |
odiaseo/pagebuilder | src/PageBuilder/Controller/TemplateSectionController.php | TemplateSectionController.get | public function get($id)
{
return $this->_sendPayload(
$this->_getService($this->_pageServiceKey)->getActiveTemplateSections($id)
);
} | php | public function get($id)
{
return $this->_sendPayload(
$this->_getService($this->_pageServiceKey)->getActiveTemplateSections($id)
);
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"_sendPayload",
"(",
"$",
"this",
"->",
"_getService",
"(",
"$",
"this",
"->",
"_pageServiceKey",
")",
"->",
"getActiveTemplateSections",
"(",
"$",
"id",
")",
")",
";",
"}"
] | Get template sections
@param mixed $id
@return mixed|\Zend\View\Model\ModelInterface | [
"Get",
"template",
"sections"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Controller/TemplateSectionController.php#L18-L23 |
odiaseo/pagebuilder | src/PageBuilder/Controller/TemplateSectionController.php | TemplateSectionController.update | public function update($id, $data)
{
$sections = empty($data['sections']) ? [] : $data['sections'];
return $this->_sendPayload(
$this->_getService($this->_pageServiceKey)->updateTemplateSections($id, $sections)
);
} | php | public function update($id, $data)
{
$sections = empty($data['sections']) ? [] : $data['sections'];
return $this->_sendPayload(
$this->_getService($this->_pageServiceKey)->updateTemplateSections($id, $sections)
);
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"$",
"sections",
"=",
"empty",
"(",
"$",
"data",
"[",
"'sections'",
"]",
")",
"?",
"[",
"]",
":",
"$",
"data",
"[",
"'sections'",
"]",
";",
"return",
"$",
"this",
"->",
"_sendPayload",
"(",
"$",
"this",
"->",
"_getService",
"(",
"$",
"this",
"->",
"_pageServiceKey",
")",
"->",
"updateTemplateSections",
"(",
"$",
"id",
",",
"$",
"sections",
")",
")",
";",
"}"
] | Update section details
@param mixed $id
@param mixed $data
@return mixed|\Zend\View\Model\ModelInterface | [
"Update",
"section",
"details"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Controller/TemplateSectionController.php#L33-L40 |
Eresus/EresusCMS | src/core/admin.php | AdminUITheme.getTemplate | public function getTemplate($name)
{
$filename = $this->getResource($name);
$template = new Eresus_Template($filename);
return $template;
} | php | public function getTemplate($name)
{
$filename = $this->getResource($name);
$template = new Eresus_Template($filename);
return $template;
} | [
"public",
"function",
"getTemplate",
"(",
"$",
"name",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getResource",
"(",
"$",
"name",
")",
";",
"$",
"template",
"=",
"new",
"Eresus_Template",
"(",
"$",
"filename",
")",
";",
"return",
"$",
"template",
";",
"}"
] | Возвращает шаблон
@param string $name
@return Eresus_Template | [
"Возвращает",
"шаблон"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L138-L143 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.replaceMacros | public function replaceMacros($text)
{
$result = str_replace(
array(
'$(httpHost)',
'$(httpPath)',
'$(httpRoot)',
'$(styleRoot)',
'$(dataRoot)',
'$(siteName)',
'$(siteTitle)',
'$(siteKeywords)',
'$(siteDescription)',
),
array(
httpHost,
httpPath,
Eresus_CMS::getLegacyKernel()->root,
styleRoot,
dataRoot,
siteName,
siteTitle,
siteKeywords,
siteDescription,
),
$text
);
$result = preg_replace_callback('/\$\(const:(.*?)\)/i', '__macroConst', $result);
$result = preg_replace_callback('/\$\(var:(([\w]*)(\[.*?\]){0,1})\)/i', '__macroVar', $result);
$result = preg_replace('/\$\(\w+(:.*?)*?\)/', '', $result);
return $result;
} | php | public function replaceMacros($text)
{
$result = str_replace(
array(
'$(httpHost)',
'$(httpPath)',
'$(httpRoot)',
'$(styleRoot)',
'$(dataRoot)',
'$(siteName)',
'$(siteTitle)',
'$(siteKeywords)',
'$(siteDescription)',
),
array(
httpHost,
httpPath,
Eresus_CMS::getLegacyKernel()->root,
styleRoot,
dataRoot,
siteName,
siteTitle,
siteKeywords,
siteDescription,
),
$text
);
$result = preg_replace_callback('/\$\(const:(.*?)\)/i', '__macroConst', $result);
$result = preg_replace_callback('/\$\(var:(([\w]*)(\[.*?\]){0,1})\)/i', '__macroVar', $result);
$result = preg_replace('/\$\(\w+(:.*?)*?\)/', '', $result);
return $result;
} | [
"public",
"function",
"replaceMacros",
"(",
"$",
"text",
")",
"{",
"$",
"result",
"=",
"str_replace",
"(",
"array",
"(",
"'$(httpHost)'",
",",
"'$(httpPath)'",
",",
"'$(httpRoot)'",
",",
"'$(styleRoot)'",
",",
"'$(dataRoot)'",
",",
"'$(siteName)'",
",",
"'$(siteTitle)'",
",",
"'$(siteKeywords)'",
",",
"'$(siteDescription)'",
",",
")",
",",
"array",
"(",
"httpHost",
",",
"httpPath",
",",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
",",
"styleRoot",
",",
"dataRoot",
",",
"siteName",
",",
"siteTitle",
",",
"siteKeywords",
",",
"siteDescription",
",",
")",
",",
"$",
"text",
")",
";",
"$",
"result",
"=",
"preg_replace_callback",
"(",
"'/\\$\\(const:(.*?)\\)/i'",
",",
"'__macroConst'",
",",
"$",
"result",
")",
";",
"$",
"result",
"=",
"preg_replace_callback",
"(",
"'/\\$\\(var:(([\\w]*)(\\[.*?\\]){0,1})\\)/i'",
",",
"'__macroVar'",
",",
"$",
"result",
")",
";",
"$",
"result",
"=",
"preg_replace",
"(",
"'/\\$\\(\\w+(:.*?)*?\\)/'",
",",
"''",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Подставляет значения макросов
@param string $text
@return string | [
"Подставляет",
"значения",
"макросов"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L286-L319 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.url | public function url($args = null, $clear = false)
{
$basics = array('mod','section','id','sort','desc','pg');
$result = '';
$arg = array();
if (count(Eresus_CMS::getLegacyKernel()->request['arg']))
{
foreach (Eresus_CMS::getLegacyKernel()->request['arg'] as $key => $value)
{
if (in_array($key,$basics)|| strpos($key, 'sub_')===0)
{
$arg[$key] = $value;
}
}
}
if (count($args))
{
foreach ($args as $key => $value)
{
$arg[$key] = $value;
}
}
if (count($arg))
{
foreach ($arg as $key => $value)
{
if (!empty($value))
{
$result .= '&'.$key.'='.$value;
}
}
}
if (!empty($result))
{
$result[0] = '?';
}
// См. баг http://bugs.eresus.ru/view.php?id=365
//$result = str_replace('&', '&', $result);
$result = Eresus_CMS::getLegacyKernel()->root . 'admin.php' . $result;
return $result;
} | php | public function url($args = null, $clear = false)
{
$basics = array('mod','section','id','sort','desc','pg');
$result = '';
$arg = array();
if (count(Eresus_CMS::getLegacyKernel()->request['arg']))
{
foreach (Eresus_CMS::getLegacyKernel()->request['arg'] as $key => $value)
{
if (in_array($key,$basics)|| strpos($key, 'sub_')===0)
{
$arg[$key] = $value;
}
}
}
if (count($args))
{
foreach ($args as $key => $value)
{
$arg[$key] = $value;
}
}
if (count($arg))
{
foreach ($arg as $key => $value)
{
if (!empty($value))
{
$result .= '&'.$key.'='.$value;
}
}
}
if (!empty($result))
{
$result[0] = '?';
}
// См. баг http://bugs.eresus.ru/view.php?id=365
//$result = str_replace('&', '&', $result);
$result = Eresus_CMS::getLegacyKernel()->root . 'admin.php' . $result;
return $result;
} | [
"public",
"function",
"url",
"(",
"$",
"args",
"=",
"null",
",",
"$",
"clear",
"=",
"false",
")",
"{",
"$",
"basics",
"=",
"array",
"(",
"'mod'",
",",
"'section'",
",",
"'id'",
",",
"'sort'",
",",
"'desc'",
",",
"'pg'",
")",
";",
"$",
"result",
"=",
"''",
";",
"$",
"arg",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'arg'",
"]",
")",
")",
"{",
"foreach",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'arg'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"basics",
")",
"||",
"strpos",
"(",
"$",
"key",
",",
"'sub_'",
")",
"===",
"0",
")",
"{",
"$",
"arg",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"arg",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"arg",
")",
")",
"{",
"foreach",
"(",
"$",
"arg",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
".=",
"'&'",
".",
"$",
"key",
".",
"'='",
".",
"$",
"value",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"[",
"0",
"]",
"=",
"'?'",
";",
"}",
"// См. баг http://bugs.eresus.ru/view.php?id=365",
"//$result = str_replace('&', '&', $result);",
"$",
"result",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin.php'",
".",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}"
] | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L322-L362 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.addMenuItem | public function addMenuItem($section, $item)
{
$item['link'] = 'ext-'.$item['link'];
$ptr = null;
for ($i=0; $i<count($this->extmenu); $i++)
{
if ($this->extmenu[$i]['caption'] == $section)
{
$ptr = &$this->extmenu[$i];
break;
}
}
if (is_null($ptr))
{
$this->extmenu[] = array(
'access' => $item['access'],
'caption' => $section,
'items' => array()
);
$ptr = &$this->extmenu[count($this->extmenu)-1];
}
$ptr['items'][] = encodeHTML($item);
if ($ptr['access'] < $item['access'])
{
$ptr['access'] = $item['access'];
}
} | php | public function addMenuItem($section, $item)
{
$item['link'] = 'ext-'.$item['link'];
$ptr = null;
for ($i=0; $i<count($this->extmenu); $i++)
{
if ($this->extmenu[$i]['caption'] == $section)
{
$ptr = &$this->extmenu[$i];
break;
}
}
if (is_null($ptr))
{
$this->extmenu[] = array(
'access' => $item['access'],
'caption' => $section,
'items' => array()
);
$ptr = &$this->extmenu[count($this->extmenu)-1];
}
$ptr['items'][] = encodeHTML($item);
if ($ptr['access'] < $item['access'])
{
$ptr['access'] = $item['access'];
}
} | [
"public",
"function",
"addMenuItem",
"(",
"$",
"section",
",",
"$",
"item",
")",
"{",
"$",
"item",
"[",
"'link'",
"]",
"=",
"'ext-'",
".",
"$",
"item",
"[",
"'link'",
"]",
";",
"$",
"ptr",
"=",
"null",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"extmenu",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"extmenu",
"[",
"$",
"i",
"]",
"[",
"'caption'",
"]",
"==",
"$",
"section",
")",
"{",
"$",
"ptr",
"=",
"&",
"$",
"this",
"->",
"extmenu",
"[",
"$",
"i",
"]",
";",
"break",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"ptr",
")",
")",
"{",
"$",
"this",
"->",
"extmenu",
"[",
"]",
"=",
"array",
"(",
"'access'",
"=>",
"$",
"item",
"[",
"'access'",
"]",
",",
"'caption'",
"=>",
"$",
"section",
",",
"'items'",
"=>",
"array",
"(",
")",
")",
";",
"$",
"ptr",
"=",
"&",
"$",
"this",
"->",
"extmenu",
"[",
"count",
"(",
"$",
"this",
"->",
"extmenu",
")",
"-",
"1",
"]",
";",
"}",
"$",
"ptr",
"[",
"'items'",
"]",
"[",
"]",
"=",
"encodeHTML",
"(",
"$",
"item",
")",
";",
"if",
"(",
"$",
"ptr",
"[",
"'access'",
"]",
"<",
"$",
"item",
"[",
"'access'",
"]",
")",
"{",
"$",
"ptr",
"[",
"'access'",
"]",
"=",
"$",
"item",
"[",
"'access'",
"]",
";",
"}",
"}"
] | Добавляет пункт в меню "Расширения"
Добавляет пункт в меню «Расширения», создавая, при необходимости, новое меню. Аргумент
$section должен содержать заголовок меню к которому надо добавить пункт. Чтобы добавить пункт
стандартному меню «Расширения», можно использовать константу admExtensions.
В плагинах рекомендуется вызывать этот метод из обработчика события adminOnMenuRender.
При выборе пользователем пункта такого меню, будет вызван метод adminRender соответствующего
плагина. Если вы в одном плагине устанавливаете несколько пунктов меню, то в adminRender вам
надо указывать значение «link» в виде «$this→name . "&доп_аргумент=значение"»
(см. примеры ниже).
Стандартный способ. Пункт будет добавлен в меню "Расширения". Название пункта будет
совпадать с названием плагина. Пункт будет доступен всем.
<code>
$page->addMenuItem(admExtensions, array('access' => EDITOR, 'link' => $this->name,
'caption' => $this->title, 'hint' => $this->description));
</code>
Создаёт меню "Справочники" и добавляет в него пункты "Организации" и "Типы товаров". Пункты
будут доступны только администраторам.
<code>
$page->addMenuItem('Справочники', array('access' => ADMIN,
'link' => $this->name . '&ref=orgs', 'caption' => 'Организации'));
$page->addMenuItem('Справочники', array('access' => ADMIN,
'link' => $this->name . '&ref=types', 'caption' => 'Организации'));
</code>
@param string $section Заголовок меню
@param array $item Описание добавляемого пункта. Ассоциативный массив:
- 'access' - Минимальный уровень доступа, необходимый чтобы видеть
этот пункт
- 'link' - "адрес", соответствующий этому пункту. В URL будет
подставлен в виде "mod=ext-{link}" (без фигурных скобок)
- 'caption' - Название пункта меню
- 'hint' - Всплывающая подсказка к пункту меню
- 'disabled' - Если true - пункт будет видимым, но недоступным
@return void | [
"Добавляет",
"пункт",
"в",
"меню",
"Расширения"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L407-L434 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.box | function box($text, $class, $caption='')
{
$result = "<div".(empty($class)?'':' class="'.$class.'"').">\n".(empty($caption)?'':
'<span class="'.$class.'Caption">'.$caption.'</span><br />').$text."</div>\n";
return $result;
} | php | function box($text, $class, $caption='')
{
$result = "<div".(empty($class)?'':' class="'.$class.'"').">\n".(empty($caption)?'':
'<span class="'.$class.'Caption">'.$caption.'</span><br />').$text."</div>\n";
return $result;
} | [
"function",
"box",
"(",
"$",
"text",
",",
"$",
"class",
",",
"$",
"caption",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"\"<div\"",
".",
"(",
"empty",
"(",
"$",
"class",
")",
"?",
"''",
":",
"' class=\"'",
".",
"$",
"class",
".",
"'\"'",
")",
".",
"\">\\n\"",
".",
"(",
"empty",
"(",
"$",
"caption",
")",
"?",
"''",
":",
"'<span class=\"'",
".",
"$",
"class",
".",
"'Caption\">'",
".",
"$",
"caption",
".",
"'</span><br />'",
")",
".",
"$",
"text",
".",
"\"</div>\\n\"",
";",
"return",
"$",
"result",
";",
"}"
] | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L438-L443 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.window | function window($wnd)
{
$result =
"<table border=\"0\" class=\"admWindow\"".(empty($wnd['width'])?'':' style="width: '.
$wnd['width'].';"').">\n".
(empty($wnd['caption'])?'':"<tr><th>".$wnd['caption']."</th></tr>\n").
"<tr><td".(empty($wnd['style'])?'':' style="'.$wnd['style'].'"').">".$wnd['body'].
"</td></tr>\n</table>\n";
return $result;
} | php | function window($wnd)
{
$result =
"<table border=\"0\" class=\"admWindow\"".(empty($wnd['width'])?'':' style="width: '.
$wnd['width'].';"').">\n".
(empty($wnd['caption'])?'':"<tr><th>".$wnd['caption']."</th></tr>\n").
"<tr><td".(empty($wnd['style'])?'':' style="'.$wnd['style'].'"').">".$wnd['body'].
"</td></tr>\n</table>\n";
return $result;
} | [
"function",
"window",
"(",
"$",
"wnd",
")",
"{",
"$",
"result",
"=",
"\"<table border=\\\"0\\\" class=\\\"admWindow\\\"\"",
".",
"(",
"empty",
"(",
"$",
"wnd",
"[",
"'width'",
"]",
")",
"?",
"''",
":",
"' style=\"width: '",
".",
"$",
"wnd",
"[",
"'width'",
"]",
".",
"';\"'",
")",
".",
"\">\\n\"",
".",
"(",
"empty",
"(",
"$",
"wnd",
"[",
"'caption'",
"]",
")",
"?",
"''",
":",
"\"<tr><th>\"",
".",
"$",
"wnd",
"[",
"'caption'",
"]",
".",
"\"</th></tr>\\n\"",
")",
".",
"\"<tr><td\"",
".",
"(",
"empty",
"(",
"$",
"wnd",
"[",
"'style'",
"]",
")",
"?",
"''",
":",
"' style=\"'",
".",
"$",
"wnd",
"[",
"'style'",
"]",
".",
"'\"'",
")",
".",
"\">\"",
".",
"$",
"wnd",
"[",
"'body'",
"]",
".",
"\"</td></tr>\\n</table>\\n\"",
";",
"return",
"$",
"result",
";",
"}"
] | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L446-L455 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.control | public function control($type, $href, $custom = array())
{
$s = '';
switch ($type)
{
case 'add':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-add.png',
'title' => strAdd,
'alt' => '+',
);
break;
case 'edit':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-edit.png',
'title' => strEdit,
'alt' => '±',
);
break;
case 'delete':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-delete.png',
'title' => strDelete,
'alt' => 'X',
'onclick' => 'return askdel(this)',
);
break;
case 'setup':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-config.png',
'title' => strProperties,
'alt' => '*',
);
break;
case 'move':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-move.png',
'title' => strMove,
'alt' => '->',
);
break;
case 'position':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/move-up.png',
'title' => ADM_UP,
'alt' => '↑',
);
$s = array_pop($href);
$href = $href[0];
break;
case 'position_down':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/move-down.png',
'title' => ADM_DOWN,
'alt' => '↓',
);
break;
default:
$control = array(
'image' => '',
'title' => '',
'alt' => '',
);
break;
}
foreach ($custom as $key => $value)
{
$control[$key] = $value;
}
$result = '<a href="'.$href.'"'.(isset($control['onclick'])?' onclick="'.
$control['onclick'].'"':'').'><img src="'.$control['image'].'" alt="'.$control['alt'].
'" title="'.$control['title'].'" /></a>';
if ($type == 'position')
{
$result .= ' '.$this->control('position_down', $s, $custom);
}
return $result;
} | php | public function control($type, $href, $custom = array())
{
$s = '';
switch ($type)
{
case 'add':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-add.png',
'title' => strAdd,
'alt' => '+',
);
break;
case 'edit':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-edit.png',
'title' => strEdit,
'alt' => '±',
);
break;
case 'delete':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-delete.png',
'title' => strDelete,
'alt' => 'X',
'onclick' => 'return askdel(this)',
);
break;
case 'setup':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-config.png',
'title' => strProperties,
'alt' => '*',
);
break;
case 'move':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/item-move.png',
'title' => strMove,
'alt' => '->',
);
break;
case 'position':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/move-up.png',
'title' => ADM_UP,
'alt' => '↑',
);
$s = array_pop($href);
$href = $href[0];
break;
case 'position_down':
$control = array(
'image' => Eresus_CMS::getLegacyKernel()->root .
'admin/themes/default/img/medium/move-down.png',
'title' => ADM_DOWN,
'alt' => '↓',
);
break;
default:
$control = array(
'image' => '',
'title' => '',
'alt' => '',
);
break;
}
foreach ($custom as $key => $value)
{
$control[$key] = $value;
}
$result = '<a href="'.$href.'"'.(isset($control['onclick'])?' onclick="'.
$control['onclick'].'"':'').'><img src="'.$control['image'].'" alt="'.$control['alt'].
'" title="'.$control['title'].'" /></a>';
if ($type == 'position')
{
$result .= ' '.$this->control('position_down', $s, $custom);
}
return $result;
} | [
"public",
"function",
"control",
"(",
"$",
"type",
",",
"$",
"href",
",",
"$",
"custom",
"=",
"array",
"(",
")",
")",
"{",
"$",
"s",
"=",
"''",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'add'",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin/themes/default/img/medium/item-add.png'",
",",
"'title'",
"=>",
"strAdd",
",",
"'alt'",
"=>",
"'+'",
",",
")",
";",
"break",
";",
"case",
"'edit'",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin/themes/default/img/medium/item-edit.png'",
",",
"'title'",
"=>",
"strEdit",
",",
"'alt'",
"=>",
"'±'",
",",
")",
";",
"break",
";",
"case",
"'delete'",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin/themes/default/img/medium/item-delete.png'",
",",
"'title'",
"=>",
"strDelete",
",",
"'alt'",
"=>",
"'X'",
",",
"'onclick'",
"=>",
"'return askdel(this)'",
",",
")",
";",
"break",
";",
"case",
"'setup'",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin/themes/default/img/medium/item-config.png'",
",",
"'title'",
"=>",
"strProperties",
",",
"'alt'",
"=>",
"'*'",
",",
")",
";",
"break",
";",
"case",
"'move'",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin/themes/default/img/medium/item-move.png'",
",",
"'title'",
"=>",
"strMove",
",",
"'alt'",
"=>",
"'->'",
",",
")",
";",
"break",
";",
"case",
"'position'",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin/themes/default/img/medium/move-up.png'",
",",
"'title'",
"=>",
"ADM_UP",
",",
"'alt'",
"=>",
"'↑'",
",",
")",
";",
"$",
"s",
"=",
"array_pop",
"(",
"$",
"href",
")",
";",
"$",
"href",
"=",
"$",
"href",
"[",
"0",
"]",
";",
"break",
";",
"case",
"'position_down'",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin/themes/default/img/medium/move-down.png'",
",",
"'title'",
"=>",
"ADM_DOWN",
",",
"'alt'",
"=>",
"'↓'",
",",
")",
";",
"break",
";",
"default",
":",
"$",
"control",
"=",
"array",
"(",
"'image'",
"=>",
"''",
",",
"'title'",
"=>",
"''",
",",
"'alt'",
"=>",
"''",
",",
")",
";",
"break",
";",
"}",
"foreach",
"(",
"$",
"custom",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"control",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"result",
"=",
"'<a href=\"'",
".",
"$",
"href",
".",
"'\"'",
".",
"(",
"isset",
"(",
"$",
"control",
"[",
"'onclick'",
"]",
")",
"?",
"' onclick=\"'",
".",
"$",
"control",
"[",
"'onclick'",
"]",
".",
"'\"'",
":",
"''",
")",
".",
"'><img src=\"'",
".",
"$",
"control",
"[",
"'image'",
"]",
".",
"'\" alt=\"'",
".",
"$",
"control",
"[",
"'alt'",
"]",
".",
"'\" title=\"'",
".",
"$",
"control",
"[",
"'title'",
"]",
".",
"'\" /></a>'",
";",
"if",
"(",
"$",
"type",
"==",
"'position'",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"this",
"->",
"control",
"(",
"'position_down'",
",",
"$",
"s",
",",
"$",
"custom",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Отрисовывает элемент управления
@param string $type Тип ЭУ (delete,toggle,move,custom...)
@param string $href Ссылка
@param string $custom Индивидуальные настройки
@return string HTML | [
"Отрисовывает",
"элемент",
"управления"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L467-L551 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderTabs | function renderTabs($tabs)
{
$result = '';
if (count($tabs))
{
$result = '<div class="legacy-tabs ui-helper-clearfix">';
$width = empty($tabs['width']) ?
'' :
' style="width: ' . $tabs['width'] . '"';
if (
isset($tabs['items']) &&
count($tabs['items'])
)
{
foreach ($tabs['items'] as $item)
{
if (isset($item['url']))
{
$url = $item['url'];
}
else
{
$url = Eresus_CMS::getLegacyKernel()->request['url'];
if (isset($item['name']))
{
if (($p = strpos($url, $item['name'].'=')) !== false)
{
$url = substr($url, 0, $p-1);
}
$url .= (strpos($url, '?') !== false ? '&' : '?') . $item['name'].'='.$item['value'];
}
else
{
$url = Eresus_Kernel::app()->getPage()->url();
}
}
$url = preg_replace('/&(?!amp;)/', '&', $url);
$result .= '<a'.$width.(isset($item['class'])?' class="'.$item['class'].'"':'').
' href="'.$url.'">'.$item['caption'].'</a>';
}
}
$result .= "</div>\n";
}
return $result;
} | php | function renderTabs($tabs)
{
$result = '';
if (count($tabs))
{
$result = '<div class="legacy-tabs ui-helper-clearfix">';
$width = empty($tabs['width']) ?
'' :
' style="width: ' . $tabs['width'] . '"';
if (
isset($tabs['items']) &&
count($tabs['items'])
)
{
foreach ($tabs['items'] as $item)
{
if (isset($item['url']))
{
$url = $item['url'];
}
else
{
$url = Eresus_CMS::getLegacyKernel()->request['url'];
if (isset($item['name']))
{
if (($p = strpos($url, $item['name'].'=')) !== false)
{
$url = substr($url, 0, $p-1);
}
$url .= (strpos($url, '?') !== false ? '&' : '?') . $item['name'].'='.$item['value'];
}
else
{
$url = Eresus_Kernel::app()->getPage()->url();
}
}
$url = preg_replace('/&(?!amp;)/', '&', $url);
$result .= '<a'.$width.(isset($item['class'])?' class="'.$item['class'].'"':'').
' href="'.$url.'">'.$item['caption'].'</a>';
}
}
$result .= "</div>\n";
}
return $result;
} | [
"function",
"renderTabs",
"(",
"$",
"tabs",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"count",
"(",
"$",
"tabs",
")",
")",
"{",
"$",
"result",
"=",
"'<div class=\"legacy-tabs ui-helper-clearfix\">'",
";",
"$",
"width",
"=",
"empty",
"(",
"$",
"tabs",
"[",
"'width'",
"]",
")",
"?",
"''",
":",
"' style=\"width: '",
".",
"$",
"tabs",
"[",
"'width'",
"]",
".",
"'\"'",
";",
"if",
"(",
"isset",
"(",
"$",
"tabs",
"[",
"'items'",
"]",
")",
"&&",
"count",
"(",
"$",
"tabs",
"[",
"'items'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"tabs",
"[",
"'items'",
"]",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"url",
"=",
"$",
"item",
"[",
"'url'",
"]",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'url'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'name'",
"]",
")",
")",
"{",
"if",
"(",
"(",
"$",
"p",
"=",
"strpos",
"(",
"$",
"url",
",",
"$",
"item",
"[",
"'name'",
"]",
".",
"'='",
")",
")",
"!==",
"false",
")",
"{",
"$",
"url",
"=",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"$",
"p",
"-",
"1",
")",
";",
"}",
"$",
"url",
".=",
"(",
"strpos",
"(",
"$",
"url",
",",
"'?'",
")",
"!==",
"false",
"?",
"'&'",
":",
"'?'",
")",
".",
"$",
"item",
"[",
"'name'",
"]",
".",
"'='",
".",
"$",
"item",
"[",
"'value'",
"]",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"url",
"(",
")",
";",
"}",
"}",
"$",
"url",
"=",
"preg_replace",
"(",
"'/&(?!amp;)/'",
",",
"'&'",
",",
"$",
"url",
")",
";",
"$",
"result",
".=",
"'<a'",
".",
"$",
"width",
".",
"(",
"isset",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
"?",
"' class=\"'",
".",
"$",
"item",
"[",
"'class'",
"]",
".",
"'\"'",
":",
"''",
")",
".",
"' href=\"'",
".",
"$",
"url",
".",
"'\">'",
".",
"$",
"item",
"[",
"'caption'",
"]",
".",
"'</a>'",
";",
"}",
"}",
"$",
"result",
".=",
"\"</div>\\n\"",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Отрисовывает кнопки-"вкладки"
Отрисовывает вкладки-переключатели на основе параметров, заданных аргументом tabs. Вкладки
представляют собой HTML-таблицу с классом admTabs, каждый таб выполнен в виде ячейки (td).
Алгоритм построения URL вкладки:
1. Если для вкладки задан параметр url, то используется его значение.
2. Если не задан параметр name, то используется результат выполнения функции url.
3. Если в текущем URL присутствует аргумент name, то из URL удаляется он и всё после него.
4. К URL прибавляется «name=value» (с соответствующим префиксом & или ?)
Ассоциативный массив $tabs описывает вкладки. В нём допустимы следующие ключи:
- width (string) — Ширина вкладки в единицах CSS. Если параметр не задан, ширина будет
вычисляться браузером на основе содержимого таба.
- items (array) Массив вкладок. Каждая вкладка описывается ассоциативным массивом (см. ниже)
Формат описания вкладки:
- name (string) — Имя вкладки. Используется для построения URL, если не указан параметр url.
- value (string) — Значение. Используется для построения URL, если не указан параметр url.
- url (string) — Задаёт адрес по которому будет перенаправлен ПА при нажатии на вкладку.
- caption (string) — Текст вкладки. Обязательный параметр.
- class (string) CSS-класс вкладки.
Пример:
<code>
$tabs = array(
'width' => '7em',
'items' => array(
array('caption' => admAdd, 'name' => 'action', 'value' => 'add'),
),
);
$result .= $page->renderTabs($tabs);
</code>
@param array $tabs ассоциативный массив, описывающий вкладки
@return string HTML | [
"Отрисовывает",
"кнопки",
"-",
"вкладки"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L597-L641 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderPages | function renderPages($itemsCount, $itemsPerPage, $pageCount, $Descending = false, $sub_prefix='')
{
$prefix = empty($sub_prefix)?str_repeat('sub_', $this->sub):$sub_prefix;
if ($itemsCount > $itemsPerPage)
{
$result = '<div class="admListPages">'.strPages;
if ($Descending)
{
$forFrom = $pageCount;
$forTo = 0;
$forDelta = -1;
}
else
{
$forFrom = 1;
$forTo = $pageCount+1;
$forDelta = 1;
}
$pageIndex = arg($prefix.'pg') ? arg($prefix.'pg', 'int') : $forFrom;
for ($i = $forFrom; $i != $forTo; $i += $forDelta)
{
if ($i == $pageIndex)
{
$result .= '<span class="selected"> '.$i.' </span>';
}
else
{
$result .= '<a href="'.$this->url(array($prefix.'pg' => $i)).'"> '.$i.' </a>';
}
}
$result .= "</div>\n";
return $result;
}
else
{
return '';
}
} | php | function renderPages($itemsCount, $itemsPerPage, $pageCount, $Descending = false, $sub_prefix='')
{
$prefix = empty($sub_prefix)?str_repeat('sub_', $this->sub):$sub_prefix;
if ($itemsCount > $itemsPerPage)
{
$result = '<div class="admListPages">'.strPages;
if ($Descending)
{
$forFrom = $pageCount;
$forTo = 0;
$forDelta = -1;
}
else
{
$forFrom = 1;
$forTo = $pageCount+1;
$forDelta = 1;
}
$pageIndex = arg($prefix.'pg') ? arg($prefix.'pg', 'int') : $forFrom;
for ($i = $forFrom; $i != $forTo; $i += $forDelta)
{
if ($i == $pageIndex)
{
$result .= '<span class="selected"> '.$i.' </span>';
}
else
{
$result .= '<a href="'.$this->url(array($prefix.'pg' => $i)).'"> '.$i.' </a>';
}
}
$result .= "</div>\n";
return $result;
}
else
{
return '';
}
} | [
"function",
"renderPages",
"(",
"$",
"itemsCount",
",",
"$",
"itemsPerPage",
",",
"$",
"pageCount",
",",
"$",
"Descending",
"=",
"false",
",",
"$",
"sub_prefix",
"=",
"''",
")",
"{",
"$",
"prefix",
"=",
"empty",
"(",
"$",
"sub_prefix",
")",
"?",
"str_repeat",
"(",
"'sub_'",
",",
"$",
"this",
"->",
"sub",
")",
":",
"$",
"sub_prefix",
";",
"if",
"(",
"$",
"itemsCount",
">",
"$",
"itemsPerPage",
")",
"{",
"$",
"result",
"=",
"'<div class=\"admListPages\">'",
".",
"strPages",
";",
"if",
"(",
"$",
"Descending",
")",
"{",
"$",
"forFrom",
"=",
"$",
"pageCount",
";",
"$",
"forTo",
"=",
"0",
";",
"$",
"forDelta",
"=",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"forFrom",
"=",
"1",
";",
"$",
"forTo",
"=",
"$",
"pageCount",
"+",
"1",
";",
"$",
"forDelta",
"=",
"1",
";",
"}",
"$",
"pageIndex",
"=",
"arg",
"(",
"$",
"prefix",
".",
"'pg'",
")",
"?",
"arg",
"(",
"$",
"prefix",
".",
"'pg'",
",",
"'int'",
")",
":",
"$",
"forFrom",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"forFrom",
";",
"$",
"i",
"!=",
"$",
"forTo",
";",
"$",
"i",
"+=",
"$",
"forDelta",
")",
"{",
"if",
"(",
"$",
"i",
"==",
"$",
"pageIndex",
")",
"{",
"$",
"result",
".=",
"'<span class=\"selected\"> '",
".",
"$",
"i",
".",
"' </span>'",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"'<a href=\"'",
".",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"'pg'",
"=>",
"$",
"i",
")",
")",
".",
"'\"> '",
".",
"$",
"i",
".",
"' </a>'",
";",
"}",
"}",
"$",
"result",
".=",
"\"</div>\\n\"",
";",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L644-L681 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderTable | function renderTable($table, $values=null, $sub_prefix='')
{
$result = '';
$prefix = empty($sub_prefix) ? str_repeat('sub_', $this->sub) : $sub_prefix;
$itemsPerPage = isset($table['itemsPerPage']) ?
$table['itemsPerPage'] :
(isset($this->module->settings['itemsPerPage']) ?
$this->module->settings['itemsPerPage'] :
0);
$pagesDesc = isset($table['sortDesc']) ? $table['sortDesc'] : false;
if (isset($table['tabs']) && count($table['tabs']))
{
$result .= $this->renderTabs($table['tabs']);
}
if (isset($table['hint']))
{
$result .= '<div class="admListHint">'.$table['hint']."</div>\n";
}
$sortMode = arg($prefix.'sort') ?
arg($prefix.'sort', 'word') :
(isset($table['sortMode'])?$table['sortMode']:'');
$sortDesc = arg($prefix.'desc') ?
arg($prefix.'desc', 'int') :
(arg($prefix.'sort')?'':(isset($table['sortDesc'])?$table['sortDesc']:false));
if (is_null($values))
{
$count = Eresus_CMS::getLegacyKernel()->db->count($table['name'],
isset($table['condition'])?$table['condition']:'');
if ($itemsPerPage)
{
$pageCount = ((integer) ($count / $itemsPerPage)+(($count % $itemsPerPage) > 0));
if ($count > $itemsPerPage)
{
$pages = $this->renderPages($count, $itemsPerPage, $pageCount, $pagesDesc, $sub_prefix);
}
else
{
$pages = '';
}
$page = arg($prefix.'pg') ? arg($prefix.'pg', 'int') : ($pagesDesc ? $pageCount : 1);
}
else
{
$pageCount = $count;
$pages = '';
$page = 1;
}
$items = Eresus_CMS::getLegacyKernel()->db->select(
$table['name'],
isset($table['condition'])?$table['condition']:'',
($sortDesc ? '-' : '').$sortMode,
'',
$itemsPerPage,
($pagesDesc?($pageCount-$page)*$itemsPerPage:($page-1)*$itemsPerPage)
);
}
else
{
$items = $values;
}
if (isset($pages))
{
$result .= $pages;
}
$result .= "<table class=\"admList\">\n".
'<tr><th style="width: 100px;">'.admControls.
(isset($table['controls']['position'])?' <a href="'.
$this->url(array($prefix.'sort' => 'position', $prefix.'desc' => '0')).'" title="'.
ADM_SORT_POS.'">'.
img('admin/themes/default/img/ard.gif', ADM_SORT_POS, ADM_SORT_POS).'</a>':'').
"</th>";
if (count($table['columns']))
{
foreach ($table['columns'] as $column)
{
$result .= '<th '.(isset($column['width'])?' style="width: '.$column['width'].'"':'').'>'.
(arg($prefix.'sort') == $column['name'] ? '<span class="admSortBy">'.
(isset($column['caption'])?$column['caption']:' ').
'</span>':(isset($column['caption'])?$column['caption']:' ')).
(isset($table['name'])?
' <a href="'.$this->url(array($prefix.'sort' => $column['name'], $prefix.'desc' => '')).
'" title="'.ADM_SORT_ASC.'">'.
img('admin/themes/default/img/ard.gif', ADM_SORT_ASC, ADM_SORT_ASC).'</a> '.
'<a href="'.$this->url(array($prefix.'sort' => $column['name'], $prefix.'desc' => '1')).
'" title="'.ADM_SORT_DESC.'">'.
img('admin/themes/default/img/aru.gif', ADM_SORT_DESC, ADM_SORT_DESC).
'</a></th>':'');
}
}
$result .= "</tr>\n";
$url_delete = $this->url(array($prefix.'delete'=>"%s"));
$url_edit = $this->url(array($prefix.'id'=>"%s"));
$url_position = $this->url(array($prefix."%s"=>"%s"));
$url_toggle = $this->url(array($prefix.'toggle'=>"%s"));
if (count($items))
{
foreach ($items as $item)
{
$result .= '<tr><td class="ctrl">';
/* Удаление */
if (
isset($table['controls']['delete']) &&
(
empty($table['controls']['delete']) ||
$this->module->$table['controls']['delete']($item)
)
)
{
$result .= ' <a href="' . sprintf($url_delete, $item[$table['key']]) . '" title="' .
ADM_DELETE . '" onclick="return askdel(this)">' .
img('admin/themes/default/img/medium/item-delete.png', ADM_DELETE, ADM_DELETE, 16, 16).
'</a>';
}
/* Изменение */
if (
isset($table['controls']['edit']) &&
(
empty($table['controls']['edit']) ||
$this->module->$table['controls']['edit']($item)
)
)
{
$result .= ' <a href="' . sprintf($url_edit, $item[$table['key']]) . '" title="' .
ADM_EDIT . '">' .
img('admin/themes/default/img/medium/item-edit.png', ADM_EDIT, ADM_EDIT, 16, 16).'</a>';
}
/* Вверх/вниз */
if (
isset($table['controls']['position']) &&
(
empty($table['controls']['position']) ||
$this->module->$table['controls']['position']($item)
) &&
$sortMode == 'position'
)
{
$result .= ' <a href="' . sprintf($url_position, 'up', $item[$table['key']]) .
'" title="' . ADM_UP . '">' .
img('admin/themes/default/img/medium/move-up.png', ADM_UP, ADM_UP).'</a>';
$result .= ' <a href="' . sprintf($url_position, 'down', $item[$table['key']]) .
'" title="' . ADM_DOWN . '">' .
img('admin/themes/default/img/medium/move-down.png', ADM_DOWN, ADM_DOWN).'</a>';
}
/* Активность */
if (
isset($table['controls']['toggle']) &&
(
empty($table['controls']['toggle']) ||
$this->module->$table['controls']['toggle']($item)
)
)
{
$result .= ' <a href="' . sprintf($url_toggle, $item[$table['key']]) . '" title="' .
($item['active'] ? ADM_DEACTIVATE : ADM_ACTIVATE) . '">' .
img('admin/themes/default/img/medium/item-' . ($item['active'] ? 'active':'inactive').
'.png', $item['active']?ADM_DEACTIVATE:ADM_ACTIVATE,
$item['active']?ADM_DEACTIVATE:ADM_ACTIVATE).'</a>';
}
$result .= '</td>';
# Обрабатываем ячейки данных
if (count($table['columns']))
{
foreach ($table['columns'] as $column)
{
$value = isset($column['value']) ?
$column['value'] :
(isset($item[$column['name']])?$item[$column['name']]:'');
if (isset($column['replace']) && count($column['replace']))
{
$value = array_key_exists($value, $column['replace']) ?
$column['replace'][$value] :
$value;
}
if (isset($column['macros']))
{
preg_match_all('/\$\((.+)\)/U', $value, $matches);
if (count($matches[1]))
{
foreach ($matches[1] as $macros)
{
if (isset($item[$macros]))
{
$value = str_replace('$('.$macros.')', encodeHTML($item[$macros]), $value);
}
}
}
}
$value = $this->replaceMacros($value);
if (isset($column['striptags']))
{
$value = strip_tags($value);
}
if (isset($column['function']))
{
switch ($column['function'])
{
case 'isEmpty':
$value = empty($value)?strYes:strNo;
break;
case 'isNotEmpty':
$value = empty($value)?strNo:strYes;
break;
case 'isNull':
$value = is_null($value)?strYes:strNo;
break;
case 'isNotNull':
$value = is_null($value)?strNo:strYes;
break;
case 'length':
$value = mb_strlen($value);
break;
}
}
if (isset($column['maxlength']) && (mb_strlen($value) > $column['maxlength']))
{
$value = mb_substr($value, 0, $column['maxlength']).'...';
}
$style = '';
if (isset($column['align']))
{
$style .= 'text-align: '.$column['align'].';';
}
if (isset($column['wrap']) && !$column['wrap'])
{
$style .= 'white-space: nowrap;';
}
if (!empty($style))
{
$style = " style=\"$style\"";
}
$result .= '<td'.$style.'>'.$value.'</td>';
}
}
$result .= "</tr>\n";
}
}
$result .= "</table>\n";
if (isset($pages))
{
$result .= $pages;
}
return $result;
} | php | function renderTable($table, $values=null, $sub_prefix='')
{
$result = '';
$prefix = empty($sub_prefix) ? str_repeat('sub_', $this->sub) : $sub_prefix;
$itemsPerPage = isset($table['itemsPerPage']) ?
$table['itemsPerPage'] :
(isset($this->module->settings['itemsPerPage']) ?
$this->module->settings['itemsPerPage'] :
0);
$pagesDesc = isset($table['sortDesc']) ? $table['sortDesc'] : false;
if (isset($table['tabs']) && count($table['tabs']))
{
$result .= $this->renderTabs($table['tabs']);
}
if (isset($table['hint']))
{
$result .= '<div class="admListHint">'.$table['hint']."</div>\n";
}
$sortMode = arg($prefix.'sort') ?
arg($prefix.'sort', 'word') :
(isset($table['sortMode'])?$table['sortMode']:'');
$sortDesc = arg($prefix.'desc') ?
arg($prefix.'desc', 'int') :
(arg($prefix.'sort')?'':(isset($table['sortDesc'])?$table['sortDesc']:false));
if (is_null($values))
{
$count = Eresus_CMS::getLegacyKernel()->db->count($table['name'],
isset($table['condition'])?$table['condition']:'');
if ($itemsPerPage)
{
$pageCount = ((integer) ($count / $itemsPerPage)+(($count % $itemsPerPage) > 0));
if ($count > $itemsPerPage)
{
$pages = $this->renderPages($count, $itemsPerPage, $pageCount, $pagesDesc, $sub_prefix);
}
else
{
$pages = '';
}
$page = arg($prefix.'pg') ? arg($prefix.'pg', 'int') : ($pagesDesc ? $pageCount : 1);
}
else
{
$pageCount = $count;
$pages = '';
$page = 1;
}
$items = Eresus_CMS::getLegacyKernel()->db->select(
$table['name'],
isset($table['condition'])?$table['condition']:'',
($sortDesc ? '-' : '').$sortMode,
'',
$itemsPerPage,
($pagesDesc?($pageCount-$page)*$itemsPerPage:($page-1)*$itemsPerPage)
);
}
else
{
$items = $values;
}
if (isset($pages))
{
$result .= $pages;
}
$result .= "<table class=\"admList\">\n".
'<tr><th style="width: 100px;">'.admControls.
(isset($table['controls']['position'])?' <a href="'.
$this->url(array($prefix.'sort' => 'position', $prefix.'desc' => '0')).'" title="'.
ADM_SORT_POS.'">'.
img('admin/themes/default/img/ard.gif', ADM_SORT_POS, ADM_SORT_POS).'</a>':'').
"</th>";
if (count($table['columns']))
{
foreach ($table['columns'] as $column)
{
$result .= '<th '.(isset($column['width'])?' style="width: '.$column['width'].'"':'').'>'.
(arg($prefix.'sort') == $column['name'] ? '<span class="admSortBy">'.
(isset($column['caption'])?$column['caption']:' ').
'</span>':(isset($column['caption'])?$column['caption']:' ')).
(isset($table['name'])?
' <a href="'.$this->url(array($prefix.'sort' => $column['name'], $prefix.'desc' => '')).
'" title="'.ADM_SORT_ASC.'">'.
img('admin/themes/default/img/ard.gif', ADM_SORT_ASC, ADM_SORT_ASC).'</a> '.
'<a href="'.$this->url(array($prefix.'sort' => $column['name'], $prefix.'desc' => '1')).
'" title="'.ADM_SORT_DESC.'">'.
img('admin/themes/default/img/aru.gif', ADM_SORT_DESC, ADM_SORT_DESC).
'</a></th>':'');
}
}
$result .= "</tr>\n";
$url_delete = $this->url(array($prefix.'delete'=>"%s"));
$url_edit = $this->url(array($prefix.'id'=>"%s"));
$url_position = $this->url(array($prefix."%s"=>"%s"));
$url_toggle = $this->url(array($prefix.'toggle'=>"%s"));
if (count($items))
{
foreach ($items as $item)
{
$result .= '<tr><td class="ctrl">';
/* Удаление */
if (
isset($table['controls']['delete']) &&
(
empty($table['controls']['delete']) ||
$this->module->$table['controls']['delete']($item)
)
)
{
$result .= ' <a href="' . sprintf($url_delete, $item[$table['key']]) . '" title="' .
ADM_DELETE . '" onclick="return askdel(this)">' .
img('admin/themes/default/img/medium/item-delete.png', ADM_DELETE, ADM_DELETE, 16, 16).
'</a>';
}
/* Изменение */
if (
isset($table['controls']['edit']) &&
(
empty($table['controls']['edit']) ||
$this->module->$table['controls']['edit']($item)
)
)
{
$result .= ' <a href="' . sprintf($url_edit, $item[$table['key']]) . '" title="' .
ADM_EDIT . '">' .
img('admin/themes/default/img/medium/item-edit.png', ADM_EDIT, ADM_EDIT, 16, 16).'</a>';
}
/* Вверх/вниз */
if (
isset($table['controls']['position']) &&
(
empty($table['controls']['position']) ||
$this->module->$table['controls']['position']($item)
) &&
$sortMode == 'position'
)
{
$result .= ' <a href="' . sprintf($url_position, 'up', $item[$table['key']]) .
'" title="' . ADM_UP . '">' .
img('admin/themes/default/img/medium/move-up.png', ADM_UP, ADM_UP).'</a>';
$result .= ' <a href="' . sprintf($url_position, 'down', $item[$table['key']]) .
'" title="' . ADM_DOWN . '">' .
img('admin/themes/default/img/medium/move-down.png', ADM_DOWN, ADM_DOWN).'</a>';
}
/* Активность */
if (
isset($table['controls']['toggle']) &&
(
empty($table['controls']['toggle']) ||
$this->module->$table['controls']['toggle']($item)
)
)
{
$result .= ' <a href="' . sprintf($url_toggle, $item[$table['key']]) . '" title="' .
($item['active'] ? ADM_DEACTIVATE : ADM_ACTIVATE) . '">' .
img('admin/themes/default/img/medium/item-' . ($item['active'] ? 'active':'inactive').
'.png', $item['active']?ADM_DEACTIVATE:ADM_ACTIVATE,
$item['active']?ADM_DEACTIVATE:ADM_ACTIVATE).'</a>';
}
$result .= '</td>';
# Обрабатываем ячейки данных
if (count($table['columns']))
{
foreach ($table['columns'] as $column)
{
$value = isset($column['value']) ?
$column['value'] :
(isset($item[$column['name']])?$item[$column['name']]:'');
if (isset($column['replace']) && count($column['replace']))
{
$value = array_key_exists($value, $column['replace']) ?
$column['replace'][$value] :
$value;
}
if (isset($column['macros']))
{
preg_match_all('/\$\((.+)\)/U', $value, $matches);
if (count($matches[1]))
{
foreach ($matches[1] as $macros)
{
if (isset($item[$macros]))
{
$value = str_replace('$('.$macros.')', encodeHTML($item[$macros]), $value);
}
}
}
}
$value = $this->replaceMacros($value);
if (isset($column['striptags']))
{
$value = strip_tags($value);
}
if (isset($column['function']))
{
switch ($column['function'])
{
case 'isEmpty':
$value = empty($value)?strYes:strNo;
break;
case 'isNotEmpty':
$value = empty($value)?strNo:strYes;
break;
case 'isNull':
$value = is_null($value)?strYes:strNo;
break;
case 'isNotNull':
$value = is_null($value)?strNo:strYes;
break;
case 'length':
$value = mb_strlen($value);
break;
}
}
if (isset($column['maxlength']) && (mb_strlen($value) > $column['maxlength']))
{
$value = mb_substr($value, 0, $column['maxlength']).'...';
}
$style = '';
if (isset($column['align']))
{
$style .= 'text-align: '.$column['align'].';';
}
if (isset($column['wrap']) && !$column['wrap'])
{
$style .= 'white-space: nowrap;';
}
if (!empty($style))
{
$style = " style=\"$style\"";
}
$result .= '<td'.$style.'>'.$value.'</td>';
}
}
$result .= "</tr>\n";
}
}
$result .= "</table>\n";
if (isset($pages))
{
$result .= $pages;
}
return $result;
} | [
"function",
"renderTable",
"(",
"$",
"table",
",",
"$",
"values",
"=",
"null",
",",
"$",
"sub_prefix",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"prefix",
"=",
"empty",
"(",
"$",
"sub_prefix",
")",
"?",
"str_repeat",
"(",
"'sub_'",
",",
"$",
"this",
"->",
"sub",
")",
":",
"$",
"sub_prefix",
";",
"$",
"itemsPerPage",
"=",
"isset",
"(",
"$",
"table",
"[",
"'itemsPerPage'",
"]",
")",
"?",
"$",
"table",
"[",
"'itemsPerPage'",
"]",
":",
"(",
"isset",
"(",
"$",
"this",
"->",
"module",
"->",
"settings",
"[",
"'itemsPerPage'",
"]",
")",
"?",
"$",
"this",
"->",
"module",
"->",
"settings",
"[",
"'itemsPerPage'",
"]",
":",
"0",
")",
";",
"$",
"pagesDesc",
"=",
"isset",
"(",
"$",
"table",
"[",
"'sortDesc'",
"]",
")",
"?",
"$",
"table",
"[",
"'sortDesc'",
"]",
":",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"'tabs'",
"]",
")",
"&&",
"count",
"(",
"$",
"table",
"[",
"'tabs'",
"]",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"renderTabs",
"(",
"$",
"table",
"[",
"'tabs'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"'hint'",
"]",
")",
")",
"{",
"$",
"result",
".=",
"'<div class=\"admListHint\">'",
".",
"$",
"table",
"[",
"'hint'",
"]",
".",
"\"</div>\\n\"",
";",
"}",
"$",
"sortMode",
"=",
"arg",
"(",
"$",
"prefix",
".",
"'sort'",
")",
"?",
"arg",
"(",
"$",
"prefix",
".",
"'sort'",
",",
"'word'",
")",
":",
"(",
"isset",
"(",
"$",
"table",
"[",
"'sortMode'",
"]",
")",
"?",
"$",
"table",
"[",
"'sortMode'",
"]",
":",
"''",
")",
";",
"$",
"sortDesc",
"=",
"arg",
"(",
"$",
"prefix",
".",
"'desc'",
")",
"?",
"arg",
"(",
"$",
"prefix",
".",
"'desc'",
",",
"'int'",
")",
":",
"(",
"arg",
"(",
"$",
"prefix",
".",
"'sort'",
")",
"?",
"''",
":",
"(",
"isset",
"(",
"$",
"table",
"[",
"'sortDesc'",
"]",
")",
"?",
"$",
"table",
"[",
"'sortDesc'",
"]",
":",
"false",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"values",
")",
")",
"{",
"$",
"count",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"db",
"->",
"count",
"(",
"$",
"table",
"[",
"'name'",
"]",
",",
"isset",
"(",
"$",
"table",
"[",
"'condition'",
"]",
")",
"?",
"$",
"table",
"[",
"'condition'",
"]",
":",
"''",
")",
";",
"if",
"(",
"$",
"itemsPerPage",
")",
"{",
"$",
"pageCount",
"=",
"(",
"(",
"integer",
")",
"(",
"$",
"count",
"/",
"$",
"itemsPerPage",
")",
"+",
"(",
"(",
"$",
"count",
"%",
"$",
"itemsPerPage",
")",
">",
"0",
")",
")",
";",
"if",
"(",
"$",
"count",
">",
"$",
"itemsPerPage",
")",
"{",
"$",
"pages",
"=",
"$",
"this",
"->",
"renderPages",
"(",
"$",
"count",
",",
"$",
"itemsPerPage",
",",
"$",
"pageCount",
",",
"$",
"pagesDesc",
",",
"$",
"sub_prefix",
")",
";",
"}",
"else",
"{",
"$",
"pages",
"=",
"''",
";",
"}",
"$",
"page",
"=",
"arg",
"(",
"$",
"prefix",
".",
"'pg'",
")",
"?",
"arg",
"(",
"$",
"prefix",
".",
"'pg'",
",",
"'int'",
")",
":",
"(",
"$",
"pagesDesc",
"?",
"$",
"pageCount",
":",
"1",
")",
";",
"}",
"else",
"{",
"$",
"pageCount",
"=",
"$",
"count",
";",
"$",
"pages",
"=",
"''",
";",
"$",
"page",
"=",
"1",
";",
"}",
"$",
"items",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"db",
"->",
"select",
"(",
"$",
"table",
"[",
"'name'",
"]",
",",
"isset",
"(",
"$",
"table",
"[",
"'condition'",
"]",
")",
"?",
"$",
"table",
"[",
"'condition'",
"]",
":",
"''",
",",
"(",
"$",
"sortDesc",
"?",
"'-'",
":",
"''",
")",
".",
"$",
"sortMode",
",",
"''",
",",
"$",
"itemsPerPage",
",",
"(",
"$",
"pagesDesc",
"?",
"(",
"$",
"pageCount",
"-",
"$",
"page",
")",
"*",
"$",
"itemsPerPage",
":",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"itemsPerPage",
")",
")",
";",
"}",
"else",
"{",
"$",
"items",
"=",
"$",
"values",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"pages",
")",
")",
"{",
"$",
"result",
".=",
"$",
"pages",
";",
"}",
"$",
"result",
".=",
"\"<table class=\\\"admList\\\">\\n\"",
".",
"'<tr><th style=\"width: 100px;\">'",
".",
"admControls",
".",
"(",
"isset",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'position'",
"]",
")",
"?",
"' <a href=\"'",
".",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"'sort'",
"=>",
"'position'",
",",
"$",
"prefix",
".",
"'desc'",
"=>",
"'0'",
")",
")",
".",
"'\" title=\"'",
".",
"ADM_SORT_POS",
".",
"'\">'",
".",
"img",
"(",
"'admin/themes/default/img/ard.gif'",
",",
"ADM_SORT_POS",
",",
"ADM_SORT_POS",
")",
".",
"'</a>'",
":",
"''",
")",
".",
"\"</th>\"",
";",
"if",
"(",
"count",
"(",
"$",
"table",
"[",
"'columns'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"table",
"[",
"'columns'",
"]",
"as",
"$",
"column",
")",
"{",
"$",
"result",
".=",
"'<th '",
".",
"(",
"isset",
"(",
"$",
"column",
"[",
"'width'",
"]",
")",
"?",
"' style=\"width: '",
".",
"$",
"column",
"[",
"'width'",
"]",
".",
"'\"'",
":",
"''",
")",
".",
"'>'",
".",
"(",
"arg",
"(",
"$",
"prefix",
".",
"'sort'",
")",
"==",
"$",
"column",
"[",
"'name'",
"]",
"?",
"'<span class=\"admSortBy\">'",
".",
"(",
"isset",
"(",
"$",
"column",
"[",
"'caption'",
"]",
")",
"?",
"$",
"column",
"[",
"'caption'",
"]",
":",
"' '",
")",
".",
"'</span>'",
":",
"(",
"isset",
"(",
"$",
"column",
"[",
"'caption'",
"]",
")",
"?",
"$",
"column",
"[",
"'caption'",
"]",
":",
"' '",
")",
")",
".",
"(",
"isset",
"(",
"$",
"table",
"[",
"'name'",
"]",
")",
"?",
"' <a href=\"'",
".",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"'sort'",
"=>",
"$",
"column",
"[",
"'name'",
"]",
",",
"$",
"prefix",
".",
"'desc'",
"=>",
"''",
")",
")",
".",
"'\" title=\"'",
".",
"ADM_SORT_ASC",
".",
"'\">'",
".",
"img",
"(",
"'admin/themes/default/img/ard.gif'",
",",
"ADM_SORT_ASC",
",",
"ADM_SORT_ASC",
")",
".",
"'</a> '",
".",
"'<a href=\"'",
".",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"'sort'",
"=>",
"$",
"column",
"[",
"'name'",
"]",
",",
"$",
"prefix",
".",
"'desc'",
"=>",
"'1'",
")",
")",
".",
"'\" title=\"'",
".",
"ADM_SORT_DESC",
".",
"'\">'",
".",
"img",
"(",
"'admin/themes/default/img/aru.gif'",
",",
"ADM_SORT_DESC",
",",
"ADM_SORT_DESC",
")",
".",
"'</a></th>'",
":",
"''",
")",
";",
"}",
"}",
"$",
"result",
".=",
"\"</tr>\\n\"",
";",
"$",
"url_delete",
"=",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"'delete'",
"=>",
"\"%s\"",
")",
")",
";",
"$",
"url_edit",
"=",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"'id'",
"=>",
"\"%s\"",
")",
")",
";",
"$",
"url_position",
"=",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"\"%s\"",
"=>",
"\"%s\"",
")",
")",
";",
"$",
"url_toggle",
"=",
"$",
"this",
"->",
"url",
"(",
"array",
"(",
"$",
"prefix",
".",
"'toggle'",
"=>",
"\"%s\"",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"items",
")",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"result",
".=",
"'<tr><td class=\"ctrl\">'",
";",
"/* Удаление */",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'delete'",
"]",
")",
"&&",
"(",
"empty",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'delete'",
"]",
")",
"||",
"$",
"this",
"->",
"module",
"->",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'delete'",
"]",
"(",
"$",
"item",
")",
")",
")",
"{",
"$",
"result",
".=",
"' <a href=\"'",
".",
"sprintf",
"(",
"$",
"url_delete",
",",
"$",
"item",
"[",
"$",
"table",
"[",
"'key'",
"]",
"]",
")",
".",
"'\" title=\"'",
".",
"ADM_DELETE",
".",
"'\" onclick=\"return askdel(this)\">'",
".",
"img",
"(",
"'admin/themes/default/img/medium/item-delete.png'",
",",
"ADM_DELETE",
",",
"ADM_DELETE",
",",
"16",
",",
"16",
")",
".",
"'</a>'",
";",
"}",
"/* Изменение */",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'edit'",
"]",
")",
"&&",
"(",
"empty",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'edit'",
"]",
")",
"||",
"$",
"this",
"->",
"module",
"->",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'edit'",
"]",
"(",
"$",
"item",
")",
")",
")",
"{",
"$",
"result",
".=",
"' <a href=\"'",
".",
"sprintf",
"(",
"$",
"url_edit",
",",
"$",
"item",
"[",
"$",
"table",
"[",
"'key'",
"]",
"]",
")",
".",
"'\" title=\"'",
".",
"ADM_EDIT",
".",
"'\">'",
".",
"img",
"(",
"'admin/themes/default/img/medium/item-edit.png'",
",",
"ADM_EDIT",
",",
"ADM_EDIT",
",",
"16",
",",
"16",
")",
".",
"'</a>'",
";",
"}",
"/* Вверх/вниз */",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'position'",
"]",
")",
"&&",
"(",
"empty",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'position'",
"]",
")",
"||",
"$",
"this",
"->",
"module",
"->",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'position'",
"]",
"(",
"$",
"item",
")",
")",
"&&",
"$",
"sortMode",
"==",
"'position'",
")",
"{",
"$",
"result",
".=",
"' <a href=\"'",
".",
"sprintf",
"(",
"$",
"url_position",
",",
"'up'",
",",
"$",
"item",
"[",
"$",
"table",
"[",
"'key'",
"]",
"]",
")",
".",
"'\" title=\"'",
".",
"ADM_UP",
".",
"'\">'",
".",
"img",
"(",
"'admin/themes/default/img/medium/move-up.png'",
",",
"ADM_UP",
",",
"ADM_UP",
")",
".",
"'</a>'",
";",
"$",
"result",
".=",
"' <a href=\"'",
".",
"sprintf",
"(",
"$",
"url_position",
",",
"'down'",
",",
"$",
"item",
"[",
"$",
"table",
"[",
"'key'",
"]",
"]",
")",
".",
"'\" title=\"'",
".",
"ADM_DOWN",
".",
"'\">'",
".",
"img",
"(",
"'admin/themes/default/img/medium/move-down.png'",
",",
"ADM_DOWN",
",",
"ADM_DOWN",
")",
".",
"'</a>'",
";",
"}",
"/* Активность */",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'toggle'",
"]",
")",
"&&",
"(",
"empty",
"(",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'toggle'",
"]",
")",
"||",
"$",
"this",
"->",
"module",
"->",
"$",
"table",
"[",
"'controls'",
"]",
"[",
"'toggle'",
"]",
"(",
"$",
"item",
")",
")",
")",
"{",
"$",
"result",
".=",
"' <a href=\"'",
".",
"sprintf",
"(",
"$",
"url_toggle",
",",
"$",
"item",
"[",
"$",
"table",
"[",
"'key'",
"]",
"]",
")",
".",
"'\" title=\"'",
".",
"(",
"$",
"item",
"[",
"'active'",
"]",
"?",
"ADM_DEACTIVATE",
":",
"ADM_ACTIVATE",
")",
".",
"'\">'",
".",
"img",
"(",
"'admin/themes/default/img/medium/item-'",
".",
"(",
"$",
"item",
"[",
"'active'",
"]",
"?",
"'active'",
":",
"'inactive'",
")",
".",
"'.png'",
",",
"$",
"item",
"[",
"'active'",
"]",
"?",
"ADM_DEACTIVATE",
":",
"ADM_ACTIVATE",
",",
"$",
"item",
"[",
"'active'",
"]",
"?",
"ADM_DEACTIVATE",
":",
"ADM_ACTIVATE",
")",
".",
"'</a>'",
";",
"}",
"$",
"result",
".=",
"'</td>'",
";",
"# Обрабатываем ячейки данных",
"if",
"(",
"count",
"(",
"$",
"table",
"[",
"'columns'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"table",
"[",
"'columns'",
"]",
"as",
"$",
"column",
")",
"{",
"$",
"value",
"=",
"isset",
"(",
"$",
"column",
"[",
"'value'",
"]",
")",
"?",
"$",
"column",
"[",
"'value'",
"]",
":",
"(",
"isset",
"(",
"$",
"item",
"[",
"$",
"column",
"[",
"'name'",
"]",
"]",
")",
"?",
"$",
"item",
"[",
"$",
"column",
"[",
"'name'",
"]",
"]",
":",
"''",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'replace'",
"]",
")",
"&&",
"count",
"(",
"$",
"column",
"[",
"'replace'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"column",
"[",
"'replace'",
"]",
")",
"?",
"$",
"column",
"[",
"'replace'",
"]",
"[",
"$",
"value",
"]",
":",
"$",
"value",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'macros'",
"]",
")",
")",
"{",
"preg_match_all",
"(",
"'/\\$\\((.+)\\)/U'",
",",
"$",
"value",
",",
"$",
"matches",
")",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"macros",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"$",
"macros",
"]",
")",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"'$('",
".",
"$",
"macros",
".",
"')'",
",",
"encodeHTML",
"(",
"$",
"item",
"[",
"$",
"macros",
"]",
")",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"replaceMacros",
"(",
"$",
"value",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'striptags'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"strip_tags",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'function'",
"]",
")",
")",
"{",
"switch",
"(",
"$",
"column",
"[",
"'function'",
"]",
")",
"{",
"case",
"'isEmpty'",
":",
"$",
"value",
"=",
"empty",
"(",
"$",
"value",
")",
"?",
"strYes",
":",
"strNo",
";",
"break",
";",
"case",
"'isNotEmpty'",
":",
"$",
"value",
"=",
"empty",
"(",
"$",
"value",
")",
"?",
"strNo",
":",
"strYes",
";",
"break",
";",
"case",
"'isNull'",
":",
"$",
"value",
"=",
"is_null",
"(",
"$",
"value",
")",
"?",
"strYes",
":",
"strNo",
";",
"break",
";",
"case",
"'isNotNull'",
":",
"$",
"value",
"=",
"is_null",
"(",
"$",
"value",
")",
"?",
"strNo",
":",
"strYes",
";",
"break",
";",
"case",
"'length'",
":",
"$",
"value",
"=",
"mb_strlen",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'maxlength'",
"]",
")",
"&&",
"(",
"mb_strlen",
"(",
"$",
"value",
")",
">",
"$",
"column",
"[",
"'maxlength'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"mb_substr",
"(",
"$",
"value",
",",
"0",
",",
"$",
"column",
"[",
"'maxlength'",
"]",
")",
".",
"'...'",
";",
"}",
"$",
"style",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'align'",
"]",
")",
")",
"{",
"$",
"style",
".=",
"'text-align: '",
".",
"$",
"column",
"[",
"'align'",
"]",
".",
"';'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"column",
"[",
"'wrap'",
"]",
")",
"&&",
"!",
"$",
"column",
"[",
"'wrap'",
"]",
")",
"{",
"$",
"style",
".=",
"'white-space: nowrap;'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"style",
")",
")",
"{",
"$",
"style",
"=",
"\" style=\\\"$style\\\"\"",
";",
"}",
"$",
"result",
".=",
"'<td'",
".",
"$",
"style",
".",
"'>'",
".",
"$",
"value",
".",
"'</td>'",
";",
"}",
"}",
"$",
"result",
".=",
"\"</tr>\\n\"",
";",
"}",
"}",
"$",
"result",
".=",
"\"</table>\\n\"",
";",
"if",
"(",
"isset",
"(",
"$",
"pages",
")",
")",
"{",
"$",
"result",
".=",
"$",
"pages",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Отрисовывает таблицу-список на основе описания $table
Таблица заполняется данными из БД или из аргумента $values.
Описание таблицы. Может включать в себя следующие элементы:
- name (string) — Имя таблицы в БД, из которой следует брать данные.
- key (string) — Имя ключевого поля таблицы, хранящего идентификатор записи.
- sortMode (string) — Имя столбца, по которому надо сортировать записи.
- sortDesc (bool) — true для сортировки по убыванию.
- columns (array) — Список отображаемых столбцов в таблице. Каждый элемент в свою очередь
должен описываться массивом, могущим включать в себя элементы: name (string) — имя столбца в
БД; caption (string) — заголовок столбца; align (string) — выравнивание данных в ячейке,
возможные значения: left, right, center, justify; replace (array) — таблицы замены значений.
Массив, в котором ключи соответствуют возможным значениям соответствующей ячейки БД, а
значения – тексту, который должен быть подставлен вместо значений в БД.
- controls (array) — Элементы управления для каждой строки таблицы, может включать в себя
элементы: delete — ЭУ «Удалить»; edit — ЭУ «Изменить»; toggle — ЭУ «Активность».
Значение $sub_prefix будет добавлено к ссылкам из таблицы. Например без префикса, иконка
«Изменить» добавляет к URL »&id=NN», с $sub_prefix равным «sub_» будет добавлять »&sub_id=NN».
@param array $table
@param array $values
@param string $sub_prefix
@return string | [
"Отрисовывает",
"таблицу",
"-",
"список",
"на",
"основе",
"описания",
"$table"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L712-L960 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderForm | public function renderForm($form, $values=array())
{
$result = '';
if (isset($form['tabs']))
{
$result .= $this->renderTabs($form['tabs']);
}
$wnd['caption'] = $form['caption'];
$wnd['width'] = isset($form['width'])?$form['width']:'';
$wnd['style'] = 'padding: 0px;';
$form = new Form($form, $values);
$wnd['body'] = $form->render();
$result .= $this->window($wnd);
return $result;
} | php | public function renderForm($form, $values=array())
{
$result = '';
if (isset($form['tabs']))
{
$result .= $this->renderTabs($form['tabs']);
}
$wnd['caption'] = $form['caption'];
$wnd['width'] = isset($form['width'])?$form['width']:'';
$wnd['style'] = 'padding: 0px;';
$form = new Form($form, $values);
$wnd['body'] = $form->render();
$result .= $this->window($wnd);
return $result;
} | [
"public",
"function",
"renderForm",
"(",
"$",
"form",
",",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"form",
"[",
"'tabs'",
"]",
")",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"renderTabs",
"(",
"$",
"form",
"[",
"'tabs'",
"]",
")",
";",
"}",
"$",
"wnd",
"[",
"'caption'",
"]",
"=",
"$",
"form",
"[",
"'caption'",
"]",
";",
"$",
"wnd",
"[",
"'width'",
"]",
"=",
"isset",
"(",
"$",
"form",
"[",
"'width'",
"]",
")",
"?",
"$",
"form",
"[",
"'width'",
"]",
":",
"''",
";",
"$",
"wnd",
"[",
"'style'",
"]",
"=",
"'padding: 0px;'",
";",
"$",
"form",
"=",
"new",
"Form",
"(",
"$",
"form",
",",
"$",
"values",
")",
";",
"$",
"wnd",
"[",
"'body'",
"]",
"=",
"$",
"form",
"->",
"render",
"(",
")",
";",
"$",
"result",
".=",
"$",
"this",
"->",
"window",
"(",
"$",
"wnd",
")",
";",
"return",
"$",
"result",
";",
"}"
] | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L963-L978 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderContent | private function renderContent(Eresus_CMS_Request $request)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
$result = '';
if (arg('mod'))
{
$module = arg('mod', '/[^\w-]/');
if (substr($module, 0, 4) == 'ext-')
{
$name = substr($module, 4);
$plugin = Eresus_Plugin_Registry::getInstance()->load($name);
if (false === $plugin)
{
throw new Eresus_HTTP_Exception_NotFound();
}
$provider = new Eresus_Admin_ContentProvider_Plugin($plugin);
$this->module = $plugin;
}
else
{
$class = 't' . $module;
if (!class_exists($class))
{
throw new Eresus_HTTP_Exception_NotFound();
}
$module = new $class;
$provider = new Eresus_Admin_ContentProvider_Module($module);
$this->module = $module;
}
try
{
$result = $provider->adminRender($request);
}
catch (RuntimeException $e)
{
if ($e instanceof Eresus_CMS_Exception_NotFound)
{
$result = ErrorBox($e->getMessage() ?: 'Запрошенная страница не найдена.');
}
else
{
Eresus_Kernel::logException($e);
$result = ErrorBox($e->getMessage());
}
}
}
if (
isset(Eresus_CMS::getLegacyKernel()->session['msg']['information']) &&
count(Eresus_CMS::getLegacyKernel()->session['msg']['information'])
)
{
$messages = '';
foreach (Eresus_CMS::getLegacyKernel()->session['msg']['information'] as $message)
{
$messages .= InfoBox($message);
}
$result = $messages . $result;
Eresus_CMS::getLegacyKernel()->session['msg']['information'] = array();
}
if (
isset(Eresus_CMS::getLegacyKernel()->session['msg']['errors']) &&
count(Eresus_CMS::getLegacyKernel()->session['msg']['errors']))
{
$messages = '';
foreach (Eresus_CMS::getLegacyKernel()->session['msg']['errors'] as $message)
{
$messages .= ErrorBox($message);
}
$result = $messages . $result;
Eresus_CMS::getLegacyKernel()->session['msg']['errors'] = array();
}
return $result;
} | php | private function renderContent(Eresus_CMS_Request $request)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
$result = '';
if (arg('mod'))
{
$module = arg('mod', '/[^\w-]/');
if (substr($module, 0, 4) == 'ext-')
{
$name = substr($module, 4);
$plugin = Eresus_Plugin_Registry::getInstance()->load($name);
if (false === $plugin)
{
throw new Eresus_HTTP_Exception_NotFound();
}
$provider = new Eresus_Admin_ContentProvider_Plugin($plugin);
$this->module = $plugin;
}
else
{
$class = 't' . $module;
if (!class_exists($class))
{
throw new Eresus_HTTP_Exception_NotFound();
}
$module = new $class;
$provider = new Eresus_Admin_ContentProvider_Module($module);
$this->module = $module;
}
try
{
$result = $provider->adminRender($request);
}
catch (RuntimeException $e)
{
if ($e instanceof Eresus_CMS_Exception_NotFound)
{
$result = ErrorBox($e->getMessage() ?: 'Запрошенная страница не найдена.');
}
else
{
Eresus_Kernel::logException($e);
$result = ErrorBox($e->getMessage());
}
}
}
if (
isset(Eresus_CMS::getLegacyKernel()->session['msg']['information']) &&
count(Eresus_CMS::getLegacyKernel()->session['msg']['information'])
)
{
$messages = '';
foreach (Eresus_CMS::getLegacyKernel()->session['msg']['information'] as $message)
{
$messages .= InfoBox($message);
}
$result = $messages . $result;
Eresus_CMS::getLegacyKernel()->session['msg']['information'] = array();
}
if (
isset(Eresus_CMS::getLegacyKernel()->session['msg']['errors']) &&
count(Eresus_CMS::getLegacyKernel()->session['msg']['errors']))
{
$messages = '';
foreach (Eresus_CMS::getLegacyKernel()->session['msg']['errors'] as $message)
{
$messages .= ErrorBox($message);
}
$result = $messages . $result;
Eresus_CMS::getLegacyKernel()->session['msg']['errors'] = array();
}
return $result;
} | [
"private",
"function",
"renderContent",
"(",
"Eresus_CMS_Request",
"$",
"request",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'()'",
")",
";",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"arg",
"(",
"'mod'",
")",
")",
"{",
"$",
"module",
"=",
"arg",
"(",
"'mod'",
",",
"'/[^\\w-]/'",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"module",
",",
"0",
",",
"4",
")",
"==",
"'ext-'",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"module",
",",
"4",
")",
";",
"$",
"plugin",
"=",
"Eresus_Plugin_Registry",
"::",
"getInstance",
"(",
")",
"->",
"load",
"(",
"$",
"name",
")",
";",
"if",
"(",
"false",
"===",
"$",
"plugin",
")",
"{",
"throw",
"new",
"Eresus_HTTP_Exception_NotFound",
"(",
")",
";",
"}",
"$",
"provider",
"=",
"new",
"Eresus_Admin_ContentProvider_Plugin",
"(",
"$",
"plugin",
")",
";",
"$",
"this",
"->",
"module",
"=",
"$",
"plugin",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"'t'",
".",
"$",
"module",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"Eresus_HTTP_Exception_NotFound",
"(",
")",
";",
"}",
"$",
"module",
"=",
"new",
"$",
"class",
";",
"$",
"provider",
"=",
"new",
"Eresus_Admin_ContentProvider_Module",
"(",
"$",
"module",
")",
";",
"$",
"this",
"->",
"module",
"=",
"$",
"module",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"$",
"provider",
"->",
"adminRender",
"(",
"$",
"request",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"Eresus_CMS_Exception_NotFound",
")",
"{",
"$",
"result",
"=",
"ErrorBox",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
"?",
":",
"'Запрошенная страница не найдена.');",
"",
"",
"}",
"else",
"{",
"Eresus_Kernel",
"::",
"logException",
"(",
"$",
"e",
")",
";",
"$",
"result",
"=",
"ErrorBox",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'information'",
"]",
")",
"&&",
"count",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'information'",
"]",
")",
")",
"{",
"$",
"messages",
"=",
"''",
";",
"foreach",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'information'",
"]",
"as",
"$",
"message",
")",
"{",
"$",
"messages",
".=",
"InfoBox",
"(",
"$",
"message",
")",
";",
"}",
"$",
"result",
"=",
"$",
"messages",
".",
"$",
"result",
";",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'information'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'errors'",
"]",
")",
"&&",
"count",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'errors'",
"]",
")",
")",
"{",
"$",
"messages",
"=",
"''",
";",
"foreach",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'errors'",
"]",
"as",
"$",
"message",
")",
"{",
"$",
"messages",
".=",
"ErrorBox",
"(",
"$",
"message",
")",
";",
"}",
"$",
"result",
"=",
"$",
"messages",
".",
"$",
"result",
";",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"session",
"[",
"'msg'",
"]",
"[",
"'errors'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Отрисовывает область контента страницы
@param Eresus_CMS_Request $request
@throws Eresus_HTTP_Exception_NotFound
@return string | [
"Отрисовывает",
"область",
"контента",
"страницы"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L989-L1064 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderPagesMenu | private function renderPagesMenu(&$opened, $owner = 0, $level = 0)
{
$theme = $this->getUITheme();
$result = '';
$items = Eresus_CMS::getLegacyKernel()->
sections->children($owner, Eresus_CMS::getLegacyKernel()->user['access'], SECTIONS_ACTIVE);
if (count($items))
{
foreach ($items as $item)
{
if (empty($item['caption']))
{
$item['caption'] = ADM_NA;
}
if (
isset(Eresus_CMS::getLegacyKernel()->request['arg']['section']) &&
$item['id'] == arg('section')
)
{
$this->title = $item['caption']; # title - массив?
}
$sub = $this->renderPagesMenu($opened, $item['id'], $level+1);
$current = (arg('mod') == 'content') && (arg('section') == $item['id']);
if ($current)
{
$opened = $level;
}
// Альтернативный текст
$alt = '[ ]';
// Подсказка
$title = '';
// Классы пункта меню
$classes = array();
if ($opened == $level + 1)
{
$display = 'block';
$classes []= 'opened';
$opened--;
}
else
{
$display = 'none';
}
if ($sub)
{
$classes []= 'parrent';
$alt = '[+]';
$title = 'Развернуть';
}
if ($current)
{
$classes []= 'current';
}
if (!$item['visible'])
{
$classes []= 'invisible';
}
$classes = implode(' ', $classes);
$result .=
'<li' . ($classes ? ' class="' . $classes . '"' : '') . '>' .
'<img src="' . Eresus_CMS::getLegacyKernel()->root . $theme->getImage('dot.gif') . '" alt="' .
$alt . '" title="' . $title . '" /> ' .
'<a href="' . Eresus_CMS::getLegacyKernel()->root . 'admin.php?mod=content&section=' .
$item['id'] .
'" title="ID: '.$item['id'].' ('.$item['name'].')">'.$item['caption']."</a>\n";
if (!empty($sub))
{
$result .= '<ul style="display: '.$display.';">'.$sub.'</ul>';
}
}
}
return $result;
} | php | private function renderPagesMenu(&$opened, $owner = 0, $level = 0)
{
$theme = $this->getUITheme();
$result = '';
$items = Eresus_CMS::getLegacyKernel()->
sections->children($owner, Eresus_CMS::getLegacyKernel()->user['access'], SECTIONS_ACTIVE);
if (count($items))
{
foreach ($items as $item)
{
if (empty($item['caption']))
{
$item['caption'] = ADM_NA;
}
if (
isset(Eresus_CMS::getLegacyKernel()->request['arg']['section']) &&
$item['id'] == arg('section')
)
{
$this->title = $item['caption']; # title - массив?
}
$sub = $this->renderPagesMenu($opened, $item['id'], $level+1);
$current = (arg('mod') == 'content') && (arg('section') == $item['id']);
if ($current)
{
$opened = $level;
}
// Альтернативный текст
$alt = '[ ]';
// Подсказка
$title = '';
// Классы пункта меню
$classes = array();
if ($opened == $level + 1)
{
$display = 'block';
$classes []= 'opened';
$opened--;
}
else
{
$display = 'none';
}
if ($sub)
{
$classes []= 'parrent';
$alt = '[+]';
$title = 'Развернуть';
}
if ($current)
{
$classes []= 'current';
}
if (!$item['visible'])
{
$classes []= 'invisible';
}
$classes = implode(' ', $classes);
$result .=
'<li' . ($classes ? ' class="' . $classes . '"' : '') . '>' .
'<img src="' . Eresus_CMS::getLegacyKernel()->root . $theme->getImage('dot.gif') . '" alt="' .
$alt . '" title="' . $title . '" /> ' .
'<a href="' . Eresus_CMS::getLegacyKernel()->root . 'admin.php?mod=content&section=' .
$item['id'] .
'" title="ID: '.$item['id'].' ('.$item['name'].')">'.$item['caption']."</a>\n";
if (!empty($sub))
{
$result .= '<ul style="display: '.$display.';">'.$sub.'</ul>';
}
}
}
return $result;
} | [
"private",
"function",
"renderPagesMenu",
"(",
"&",
"$",
"opened",
",",
"$",
"owner",
"=",
"0",
",",
"$",
"level",
"=",
"0",
")",
"{",
"$",
"theme",
"=",
"$",
"this",
"->",
"getUITheme",
"(",
")",
";",
"$",
"result",
"=",
"''",
";",
"$",
"items",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"children",
"(",
"$",
"owner",
",",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"user",
"[",
"'access'",
"]",
",",
"SECTIONS_ACTIVE",
")",
";",
"if",
"(",
"count",
"(",
"$",
"items",
")",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"item",
"[",
"'caption'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'caption'",
"]",
"=",
"ADM_NA",
";",
"}",
"if",
"(",
"isset",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'arg'",
"]",
"[",
"'section'",
"]",
")",
"&&",
"$",
"item",
"[",
"'id'",
"]",
"==",
"arg",
"(",
"'section'",
")",
")",
"{",
"$",
"this",
"->",
"title",
"=",
"$",
"item",
"[",
"'caption'",
"]",
";",
"# title - массив?",
"}",
"$",
"sub",
"=",
"$",
"this",
"->",
"renderPagesMenu",
"(",
"$",
"opened",
",",
"$",
"item",
"[",
"'id'",
"]",
",",
"$",
"level",
"+",
"1",
")",
";",
"$",
"current",
"=",
"(",
"arg",
"(",
"'mod'",
")",
"==",
"'content'",
")",
"&&",
"(",
"arg",
"(",
"'section'",
")",
"==",
"$",
"item",
"[",
"'id'",
"]",
")",
";",
"if",
"(",
"$",
"current",
")",
"{",
"$",
"opened",
"=",
"$",
"level",
";",
"}",
"// Альтернативный текст",
"$",
"alt",
"=",
"'[ ]'",
";",
"// Подсказка",
"$",
"title",
"=",
"''",
";",
"// Классы пункта меню",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"opened",
"==",
"$",
"level",
"+",
"1",
")",
"{",
"$",
"display",
"=",
"'block'",
";",
"$",
"classes",
"[",
"]",
"=",
"'opened'",
";",
"$",
"opened",
"--",
";",
"}",
"else",
"{",
"$",
"display",
"=",
"'none'",
";",
"}",
"if",
"(",
"$",
"sub",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'parrent'",
";",
"$",
"alt",
"=",
"'[+]'",
";",
"$",
"title",
"=",
"'Развернуть';",
"",
"}",
"if",
"(",
"$",
"current",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'current'",
";",
"}",
"if",
"(",
"!",
"$",
"item",
"[",
"'visible'",
"]",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'invisible'",
";",
"}",
"$",
"classes",
"=",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"$",
"result",
".=",
"'<li'",
".",
"(",
"$",
"classes",
"?",
"' class=\"'",
".",
"$",
"classes",
".",
"'\"'",
":",
"''",
")",
".",
"'>'",
".",
"'<img src=\"'",
".",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"$",
"theme",
"->",
"getImage",
"(",
"'dot.gif'",
")",
".",
"'\" alt=\"'",
".",
"$",
"alt",
".",
"'\" title=\"'",
".",
"$",
"title",
".",
"'\" /> '",
".",
"'<a href=\"'",
".",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin.php?mod=content&section='",
".",
"$",
"item",
"[",
"'id'",
"]",
".",
"'\" title=\"ID: '",
".",
"$",
"item",
"[",
"'id'",
"]",
".",
"' ('",
".",
"$",
"item",
"[",
"'name'",
"]",
".",
"')\">'",
".",
"$",
"item",
"[",
"'caption'",
"]",
".",
"\"</a>\\n\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sub",
")",
")",
"{",
"$",
"result",
".=",
"'<ul style=\"display: '",
".",
"$",
"display",
".",
"';\">'",
".",
"$",
"sub",
".",
"'</ul>'",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Отрисовывает ветку меню
@param $opened
@param $owner
@param $level | [
"Отрисовывает",
"ветку",
"меню"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L1073-L1159 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderControlMenu | private function renderControlMenu()
{
$menu = '';
for ($section = 0; $section < count($this->extmenu); $section++)
{
if (UserRights($this->extmenu[$section]['access']))
{
$menu .= '<div class="header">' . $this->extmenu[$section]['caption'] .
'</div><div class="content">';
foreach ($this->extmenu[$section]['items'] as $item)
{
if (
UserRights(
isset($item['access']) ? $item['access'] : $this->extmenu[$section]['access']
) &&
(!(isset($item['disabled']) && $item['disabled']))
)
{
if ($item['link'] == arg('mod'))
{
$this->title = $item['caption'];
}
$menu .= '<div ' . ($item['link'] == arg('mod') ? 'class="selected"' : '') .
"><a href=\"" . Eresus_CMS::getLegacyKernel()->root . "admin.php?mod=" . $item['link'] .
"\" title=\"" . $item['hint'] . "\">" . $item['caption'] . "</a></div>\n";
}
}
$menu .= "</div>\n";
}
}
for ($section = 0; $section < count($this->menu); $section++)
{
if (UserRights($this->menu[$section]['access']))
{
$menu .= '<div class="header">' . $this->menu[$section]['caption'] .
'</div><div class="content">';
foreach ($this->menu[$section]['items'] as $item)
{
if (
UserRights(
isset($item['access']) ? $item['access'] : $this->menu[$section]['access']
) &&
(!(isset($item['disabled']) && $item['disabled']))
)
{
if ($item['link'] == arg('mod'))
{
$this->title = $item['caption'];
}
$menu .= '<div '.($item['link'] == arg('mod') ?'class="selected"':'') .
"><a href=\"" . Eresus_CMS::getLegacyKernel()->root . "admin.php?mod=" . $item['link'] .
"\" title=\"" . $item['hint'] . "\">" . $item['caption'] . "</a></div>\n";
}
}
$menu .= "</div>\n";
}
}
return $menu;
} | php | private function renderControlMenu()
{
$menu = '';
for ($section = 0; $section < count($this->extmenu); $section++)
{
if (UserRights($this->extmenu[$section]['access']))
{
$menu .= '<div class="header">' . $this->extmenu[$section]['caption'] .
'</div><div class="content">';
foreach ($this->extmenu[$section]['items'] as $item)
{
if (
UserRights(
isset($item['access']) ? $item['access'] : $this->extmenu[$section]['access']
) &&
(!(isset($item['disabled']) && $item['disabled']))
)
{
if ($item['link'] == arg('mod'))
{
$this->title = $item['caption'];
}
$menu .= '<div ' . ($item['link'] == arg('mod') ? 'class="selected"' : '') .
"><a href=\"" . Eresus_CMS::getLegacyKernel()->root . "admin.php?mod=" . $item['link'] .
"\" title=\"" . $item['hint'] . "\">" . $item['caption'] . "</a></div>\n";
}
}
$menu .= "</div>\n";
}
}
for ($section = 0; $section < count($this->menu); $section++)
{
if (UserRights($this->menu[$section]['access']))
{
$menu .= '<div class="header">' . $this->menu[$section]['caption'] .
'</div><div class="content">';
foreach ($this->menu[$section]['items'] as $item)
{
if (
UserRights(
isset($item['access']) ? $item['access'] : $this->menu[$section]['access']
) &&
(!(isset($item['disabled']) && $item['disabled']))
)
{
if ($item['link'] == arg('mod'))
{
$this->title = $item['caption'];
}
$menu .= '<div '.($item['link'] == arg('mod') ?'class="selected"':'') .
"><a href=\"" . Eresus_CMS::getLegacyKernel()->root . "admin.php?mod=" . $item['link'] .
"\" title=\"" . $item['hint'] . "\">" . $item['caption'] . "</a></div>\n";
}
}
$menu .= "</div>\n";
}
}
return $menu;
} | [
"private",
"function",
"renderControlMenu",
"(",
")",
"{",
"$",
"menu",
"=",
"''",
";",
"for",
"(",
"$",
"section",
"=",
"0",
";",
"$",
"section",
"<",
"count",
"(",
"$",
"this",
"->",
"extmenu",
")",
";",
"$",
"section",
"++",
")",
"{",
"if",
"(",
"UserRights",
"(",
"$",
"this",
"->",
"extmenu",
"[",
"$",
"section",
"]",
"[",
"'access'",
"]",
")",
")",
"{",
"$",
"menu",
".=",
"'<div class=\"header\">'",
".",
"$",
"this",
"->",
"extmenu",
"[",
"$",
"section",
"]",
"[",
"'caption'",
"]",
".",
"'</div><div class=\"content\">'",
";",
"foreach",
"(",
"$",
"this",
"->",
"extmenu",
"[",
"$",
"section",
"]",
"[",
"'items'",
"]",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"UserRights",
"(",
"isset",
"(",
"$",
"item",
"[",
"'access'",
"]",
")",
"?",
"$",
"item",
"[",
"'access'",
"]",
":",
"$",
"this",
"->",
"extmenu",
"[",
"$",
"section",
"]",
"[",
"'access'",
"]",
")",
"&&",
"(",
"!",
"(",
"isset",
"(",
"$",
"item",
"[",
"'disabled'",
"]",
")",
"&&",
"$",
"item",
"[",
"'disabled'",
"]",
")",
")",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'link'",
"]",
"==",
"arg",
"(",
"'mod'",
")",
")",
"{",
"$",
"this",
"->",
"title",
"=",
"$",
"item",
"[",
"'caption'",
"]",
";",
"}",
"$",
"menu",
".=",
"'<div '",
".",
"(",
"$",
"item",
"[",
"'link'",
"]",
"==",
"arg",
"(",
"'mod'",
")",
"?",
"'class=\"selected\"'",
":",
"''",
")",
".",
"\"><a href=\\\"\"",
".",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"\"admin.php?mod=\"",
".",
"$",
"item",
"[",
"'link'",
"]",
".",
"\"\\\" title=\\\"\"",
".",
"$",
"item",
"[",
"'hint'",
"]",
".",
"\"\\\">\"",
".",
"$",
"item",
"[",
"'caption'",
"]",
".",
"\"</a></div>\\n\"",
";",
"}",
"}",
"$",
"menu",
".=",
"\"</div>\\n\"",
";",
"}",
"}",
"for",
"(",
"$",
"section",
"=",
"0",
";",
"$",
"section",
"<",
"count",
"(",
"$",
"this",
"->",
"menu",
")",
";",
"$",
"section",
"++",
")",
"{",
"if",
"(",
"UserRights",
"(",
"$",
"this",
"->",
"menu",
"[",
"$",
"section",
"]",
"[",
"'access'",
"]",
")",
")",
"{",
"$",
"menu",
".=",
"'<div class=\"header\">'",
".",
"$",
"this",
"->",
"menu",
"[",
"$",
"section",
"]",
"[",
"'caption'",
"]",
".",
"'</div><div class=\"content\">'",
";",
"foreach",
"(",
"$",
"this",
"->",
"menu",
"[",
"$",
"section",
"]",
"[",
"'items'",
"]",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"UserRights",
"(",
"isset",
"(",
"$",
"item",
"[",
"'access'",
"]",
")",
"?",
"$",
"item",
"[",
"'access'",
"]",
":",
"$",
"this",
"->",
"menu",
"[",
"$",
"section",
"]",
"[",
"'access'",
"]",
")",
"&&",
"(",
"!",
"(",
"isset",
"(",
"$",
"item",
"[",
"'disabled'",
"]",
")",
"&&",
"$",
"item",
"[",
"'disabled'",
"]",
")",
")",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'link'",
"]",
"==",
"arg",
"(",
"'mod'",
")",
")",
"{",
"$",
"this",
"->",
"title",
"=",
"$",
"item",
"[",
"'caption'",
"]",
";",
"}",
"$",
"menu",
".=",
"'<div '",
".",
"(",
"$",
"item",
"[",
"'link'",
"]",
"==",
"arg",
"(",
"'mod'",
")",
"?",
"'class=\"selected\"'",
":",
"''",
")",
".",
"\"><a href=\\\"\"",
".",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"\"admin.php?mod=\"",
".",
"$",
"item",
"[",
"'link'",
"]",
".",
"\"\\\" title=\\\"\"",
".",
"$",
"item",
"[",
"'hint'",
"]",
".",
"\"\\\">\"",
".",
"$",
"item",
"[",
"'caption'",
"]",
".",
"\"</a></div>\\n\"",
";",
"}",
"}",
"$",
"menu",
".=",
"\"</div>\\n\"",
";",
"}",
"}",
"return",
"$",
"menu",
";",
"}"
] | Отрисовывает меню плагинов и управления
@return string HTML | [
"Отрисовывает",
"меню",
"плагинов",
"и",
"управления"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L1167-L1227 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.render | public function render(Eresus_CMS_Request $request)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
return $this->renderUI($request);
} | php | public function render(Eresus_CMS_Request $request)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
return $this->renderUI($request);
} | [
"public",
"function",
"render",
"(",
"Eresus_CMS_Request",
"$",
"request",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'()'",
")",
";",
"return",
"$",
"this",
"->",
"renderUI",
"(",
"$",
"request",
")",
";",
"}"
] | Отправляет созданную страницу пользователю
@param Eresus_CMS_Request $request
@return Eresus_HTTP_Response | [
"Отправляет",
"созданную",
"страницу",
"пользователю"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L1236-L1240 |
Eresus/EresusCMS | src/core/admin.php | TAdminUI.renderUI | private function renderUI(Eresus_CMS_Request $request)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
$response = $this->renderContent($request);
if (!($response instanceof Eresus_HTTP_Response))
{
$data = array();
$data['page'] = $this;
$data['content'] = $response;
$data['siteName'] = option('siteName');
$data['body'] = $this->renderBodySection();
$opened = -1;
$data['sectionMenu'] = $this->renderPagesMenu($opened);
$data['controlMenu'] = $this->renderControlMenu();
$data['user'] = Eresus_CMS::getLegacyKernel()->user;
$tmpl = new Eresus_Template('admin/themes/default/page.default.html');
$response = new Eresus_HTTP_Response($tmpl->compile($data), 200, $this->headers);
}
return $response;
} | php | private function renderUI(Eresus_CMS_Request $request)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
$response = $this->renderContent($request);
if (!($response instanceof Eresus_HTTP_Response))
{
$data = array();
$data['page'] = $this;
$data['content'] = $response;
$data['siteName'] = option('siteName');
$data['body'] = $this->renderBodySection();
$opened = -1;
$data['sectionMenu'] = $this->renderPagesMenu($opened);
$data['controlMenu'] = $this->renderControlMenu();
$data['user'] = Eresus_CMS::getLegacyKernel()->user;
$tmpl = new Eresus_Template('admin/themes/default/page.default.html');
$response = new Eresus_HTTP_Response($tmpl->compile($data), 200, $this->headers);
}
return $response;
} | [
"private",
"function",
"renderUI",
"(",
"Eresus_CMS_Request",
"$",
"request",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'()'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"renderContent",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"(",
"$",
"response",
"instanceof",
"Eresus_HTTP_Response",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'page'",
"]",
"=",
"$",
"this",
";",
"$",
"data",
"[",
"'content'",
"]",
"=",
"$",
"response",
";",
"$",
"data",
"[",
"'siteName'",
"]",
"=",
"option",
"(",
"'siteName'",
")",
";",
"$",
"data",
"[",
"'body'",
"]",
"=",
"$",
"this",
"->",
"renderBodySection",
"(",
")",
";",
"$",
"opened",
"=",
"-",
"1",
";",
"$",
"data",
"[",
"'sectionMenu'",
"]",
"=",
"$",
"this",
"->",
"renderPagesMenu",
"(",
"$",
"opened",
")",
";",
"$",
"data",
"[",
"'controlMenu'",
"]",
"=",
"$",
"this",
"->",
"renderControlMenu",
"(",
")",
";",
"$",
"data",
"[",
"'user'",
"]",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"user",
";",
"$",
"tmpl",
"=",
"new",
"Eresus_Template",
"(",
"'admin/themes/default/page.default.html'",
")",
";",
"$",
"response",
"=",
"new",
"Eresus_HTTP_Response",
"(",
"$",
"tmpl",
"->",
"compile",
"(",
"$",
"data",
")",
",",
"200",
",",
"$",
"this",
"->",
"headers",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Отрисовка интерфейса
@param Eresus_CMS_Request $request
@return Eresus_HTTP_Response | [
"Отрисовка",
"интерфейса"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/admin.php#L1249-L1271 |
vaibhavpandeyvpz/sandesh | src/Response.php | Response.withStatus | public function withStatus($code, $reasonPhrase = '')
{
MessageValidations::assertStatusCode($code);
$clone = clone $this;
$clone->statusCode = $code;
$clone->reasonPhrase = $reasonPhrase;
return $clone;
} | php | public function withStatus($code, $reasonPhrase = '')
{
MessageValidations::assertStatusCode($code);
$clone = clone $this;
$clone->statusCode = $code;
$clone->reasonPhrase = $reasonPhrase;
return $clone;
} | [
"public",
"function",
"withStatus",
"(",
"$",
"code",
",",
"$",
"reasonPhrase",
"=",
"''",
")",
"{",
"MessageValidations",
"::",
"assertStatusCode",
"(",
"$",
"code",
")",
";",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"statusCode",
"=",
"$",
"code",
";",
"$",
"clone",
"->",
"reasonPhrase",
"=",
"$",
"reasonPhrase",
";",
"return",
"$",
"clone",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/Response.php#L68-L75 |
php-lug/lug | src/Component/Grid/Sort/Type/ColumnType.php | ColumnType.sort | public function sort($data, array $options)
{
$builder = $options['builder'];
$builder->orderBy($builder->getProperty($options['field']), $data);
} | php | public function sort($data, array $options)
{
$builder = $options['builder'];
$builder->orderBy($builder->getProperty($options['field']), $data);
} | [
"public",
"function",
"sort",
"(",
"$",
"data",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"=",
"$",
"options",
"[",
"'builder'",
"]",
";",
"$",
"builder",
"->",
"orderBy",
"(",
"$",
"builder",
"->",
"getProperty",
"(",
"$",
"options",
"[",
"'field'",
"]",
")",
",",
"$",
"data",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Sort/Type/ColumnType.php#L22-L27 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Block/Widget/Grid.php | Aoe_Layout_Block_Widget_Grid.getRowUrl | public function getRowUrl($item)
{
if (!$item instanceof Varien_Object) {
return parent::getRowUrl($item);
}
$rowUrlRoute = trim($this->getRowUrlRoute());
if (empty($rowUrlRoute)) {
return parent::getRowUrl($item);
}
$params = [];
$rowUrlParams = $this->getRowUrlParams();
$rowUrlParams = (is_array($rowUrlParams) ? $rowUrlParams : explode(',', $rowUrlParams));
$rowUrlParams = array_filter(array_map('trim', $rowUrlParams));
foreach ($rowUrlParams as $key => $value) {
if (strpos($value, '{{') === 0 && strrpos($value, '}}') === (strlen($value) - 2)) {
$value = $item->getDataUsingMethod(substr($value, 2, -2));
}
$params[$key] = $value;
}
$rowUrlQueryParams = $this->getRowUrlQueryParams();
$rowUrlQueryParams = (is_array($rowUrlQueryParams) ? $rowUrlQueryParams : explode(',', $rowUrlQueryParams));
$rowUrlQueryParams = array_filter(array_map('trim', $rowUrlQueryParams));
foreach ($rowUrlQueryParams as $key => $value) {
if (strpos($value, '{{') === 0 && strrpos($value, '}}') === (strlen($value) - 2)) {
$value = $item->getDataUsingMethod(substr($value, 1, -1));
}
$params['_query'][$key] = $value;
}
return $this->getUrl($rowUrlRoute, $params);
} | php | public function getRowUrl($item)
{
if (!$item instanceof Varien_Object) {
return parent::getRowUrl($item);
}
$rowUrlRoute = trim($this->getRowUrlRoute());
if (empty($rowUrlRoute)) {
return parent::getRowUrl($item);
}
$params = [];
$rowUrlParams = $this->getRowUrlParams();
$rowUrlParams = (is_array($rowUrlParams) ? $rowUrlParams : explode(',', $rowUrlParams));
$rowUrlParams = array_filter(array_map('trim', $rowUrlParams));
foreach ($rowUrlParams as $key => $value) {
if (strpos($value, '{{') === 0 && strrpos($value, '}}') === (strlen($value) - 2)) {
$value = $item->getDataUsingMethod(substr($value, 2, -2));
}
$params[$key] = $value;
}
$rowUrlQueryParams = $this->getRowUrlQueryParams();
$rowUrlQueryParams = (is_array($rowUrlQueryParams) ? $rowUrlQueryParams : explode(',', $rowUrlQueryParams));
$rowUrlQueryParams = array_filter(array_map('trim', $rowUrlQueryParams));
foreach ($rowUrlQueryParams as $key => $value) {
if (strpos($value, '{{') === 0 && strrpos($value, '}}') === (strlen($value) - 2)) {
$value = $item->getDataUsingMethod(substr($value, 1, -1));
}
$params['_query'][$key] = $value;
}
return $this->getUrl($rowUrlRoute, $params);
} | [
"public",
"function",
"getRowUrl",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"item",
"instanceof",
"Varien_Object",
")",
"{",
"return",
"parent",
"::",
"getRowUrl",
"(",
"$",
"item",
")",
";",
"}",
"$",
"rowUrlRoute",
"=",
"trim",
"(",
"$",
"this",
"->",
"getRowUrlRoute",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"rowUrlRoute",
")",
")",
"{",
"return",
"parent",
"::",
"getRowUrl",
"(",
"$",
"item",
")",
";",
"}",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"rowUrlParams",
"=",
"$",
"this",
"->",
"getRowUrlParams",
"(",
")",
";",
"$",
"rowUrlParams",
"=",
"(",
"is_array",
"(",
"$",
"rowUrlParams",
")",
"?",
"$",
"rowUrlParams",
":",
"explode",
"(",
"','",
",",
"$",
"rowUrlParams",
")",
")",
";",
"$",
"rowUrlParams",
"=",
"array_filter",
"(",
"array_map",
"(",
"'trim'",
",",
"$",
"rowUrlParams",
")",
")",
";",
"foreach",
"(",
"$",
"rowUrlParams",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'{{'",
")",
"===",
"0",
"&&",
"strrpos",
"(",
"$",
"value",
",",
"'}}'",
")",
"===",
"(",
"strlen",
"(",
"$",
"value",
")",
"-",
"2",
")",
")",
"{",
"$",
"value",
"=",
"$",
"item",
"->",
"getDataUsingMethod",
"(",
"substr",
"(",
"$",
"value",
",",
"2",
",",
"-",
"2",
")",
")",
";",
"}",
"$",
"params",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"rowUrlQueryParams",
"=",
"$",
"this",
"->",
"getRowUrlQueryParams",
"(",
")",
";",
"$",
"rowUrlQueryParams",
"=",
"(",
"is_array",
"(",
"$",
"rowUrlQueryParams",
")",
"?",
"$",
"rowUrlQueryParams",
":",
"explode",
"(",
"','",
",",
"$",
"rowUrlQueryParams",
")",
")",
";",
"$",
"rowUrlQueryParams",
"=",
"array_filter",
"(",
"array_map",
"(",
"'trim'",
",",
"$",
"rowUrlQueryParams",
")",
")",
";",
"foreach",
"(",
"$",
"rowUrlQueryParams",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'{{'",
")",
"===",
"0",
"&&",
"strrpos",
"(",
"$",
"value",
",",
"'}}'",
")",
"===",
"(",
"strlen",
"(",
"$",
"value",
")",
"-",
"2",
")",
")",
"{",
"$",
"value",
"=",
"$",
"item",
"->",
"getDataUsingMethod",
"(",
"substr",
"(",
"$",
"value",
",",
"1",
",",
"-",
"1",
")",
")",
";",
"}",
"$",
"params",
"[",
"'_query'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"getUrl",
"(",
"$",
"rowUrlRoute",
",",
"$",
"params",
")",
";",
"}"
] | Return row url for js event handlers
@param Varien_Object
@return string | [
"Return",
"row",
"url",
"for",
"js",
"event",
"handlers"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Block/Widget/Grid.php#L49-L84 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Block/Widget/Grid.php | Aoe_Layout_Block_Widget_Grid.sortColumnsByOrder | public function sortColumnsByOrder()
{
$columns = $this->_columns;
foreach ($this->getColumnsOrder() as $columnId => $after) {
if ($after[0] === '-') {
$before = substr($after, 1);
$after = null;
} else {
$before = null;
}
if ($after !== null && isset($columns[$after])) {
$currentPosition = array_search($columnId, array_keys($columns));
$value = array_splice($columns, $currentPosition, 1);
$destPosition = array_search($after, array_keys($columns)) + 1;
$columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
} elseif ($before !== null && $columns[$before]) {
$currentPosition = array_search($columnId, array_keys($columns));
$value = array_splice($columns, $currentPosition, 1);
$destPosition = array_search($before, array_keys($columns));
$columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
}
}
$this->_columns = $columns;
end($this->_columns);
$this->_lastColumnId = key($this->_columns);
return $this;
} | php | public function sortColumnsByOrder()
{
$columns = $this->_columns;
foreach ($this->getColumnsOrder() as $columnId => $after) {
if ($after[0] === '-') {
$before = substr($after, 1);
$after = null;
} else {
$before = null;
}
if ($after !== null && isset($columns[$after])) {
$currentPosition = array_search($columnId, array_keys($columns));
$value = array_splice($columns, $currentPosition, 1);
$destPosition = array_search($after, array_keys($columns)) + 1;
$columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
} elseif ($before !== null && $columns[$before]) {
$currentPosition = array_search($columnId, array_keys($columns));
$value = array_splice($columns, $currentPosition, 1);
$destPosition = array_search($before, array_keys($columns));
$columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
}
}
$this->_columns = $columns;
end($this->_columns);
$this->_lastColumnId = key($this->_columns);
return $this;
} | [
"public",
"function",
"sortColumnsByOrder",
"(",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"_columns",
";",
"foreach",
"(",
"$",
"this",
"->",
"getColumnsOrder",
"(",
")",
"as",
"$",
"columnId",
"=>",
"$",
"after",
")",
"{",
"if",
"(",
"$",
"after",
"[",
"0",
"]",
"===",
"'-'",
")",
"{",
"$",
"before",
"=",
"substr",
"(",
"$",
"after",
",",
"1",
")",
";",
"$",
"after",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"before",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"after",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"columns",
"[",
"$",
"after",
"]",
")",
")",
"{",
"$",
"currentPosition",
"=",
"array_search",
"(",
"$",
"columnId",
",",
"array_keys",
"(",
"$",
"columns",
")",
")",
";",
"$",
"value",
"=",
"array_splice",
"(",
"$",
"columns",
",",
"$",
"currentPosition",
",",
"1",
")",
";",
"$",
"destPosition",
"=",
"array_search",
"(",
"$",
"after",
",",
"array_keys",
"(",
"$",
"columns",
")",
")",
"+",
"1",
";",
"$",
"columns",
"=",
"array_slice",
"(",
"$",
"columns",
",",
"0",
",",
"$",
"destPosition",
")",
"+",
"$",
"value",
"+",
"array_slice",
"(",
"$",
"columns",
",",
"$",
"destPosition",
")",
";",
"}",
"elseif",
"(",
"$",
"before",
"!==",
"null",
"&&",
"$",
"columns",
"[",
"$",
"before",
"]",
")",
"{",
"$",
"currentPosition",
"=",
"array_search",
"(",
"$",
"columnId",
",",
"array_keys",
"(",
"$",
"columns",
")",
")",
";",
"$",
"value",
"=",
"array_splice",
"(",
"$",
"columns",
",",
"$",
"currentPosition",
",",
"1",
")",
";",
"$",
"destPosition",
"=",
"array_search",
"(",
"$",
"before",
",",
"array_keys",
"(",
"$",
"columns",
")",
")",
";",
"$",
"columns",
"=",
"array_slice",
"(",
"$",
"columns",
",",
"0",
",",
"$",
"destPosition",
")",
"+",
"$",
"value",
"+",
"array_slice",
"(",
"$",
"columns",
",",
"$",
"destPosition",
")",
";",
"}",
"}",
"$",
"this",
"->",
"_columns",
"=",
"$",
"columns",
";",
"end",
"(",
"$",
"this",
"->",
"_columns",
")",
";",
"$",
"this",
"->",
"_lastColumnId",
"=",
"key",
"(",
"$",
"this",
"->",
"_columns",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sort columns by predefined order
@return Mage_Adminhtml_Block_Widget_Grid | [
"Sort",
"columns",
"by",
"predefined",
"order"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Block/Widget/Grid.php#L97-L127 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Block/Widget/Grid.php | Aoe_Layout_Block_Widget_Grid.updateColumn | public function updateColumn($columnId, $key, $value)
{
if (isset($this->_columns[$columnId]) && $this->_columns[$columnId] instanceof Varien_Object) {
$this->_columns[$columnId]->setData($key, $value);
}
return $this;
} | php | public function updateColumn($columnId, $key, $value)
{
if (isset($this->_columns[$columnId]) && $this->_columns[$columnId] instanceof Varien_Object) {
$this->_columns[$columnId]->setData($key, $value);
}
return $this;
} | [
"public",
"function",
"updateColumn",
"(",
"$",
"columnId",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_columns",
"[",
"$",
"columnId",
"]",
")",
"&&",
"$",
"this",
"->",
"_columns",
"[",
"$",
"columnId",
"]",
"instanceof",
"Varien_Object",
")",
"{",
"$",
"this",
"->",
"_columns",
"[",
"$",
"columnId",
"]",
"->",
"setData",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Modify grid column
@param $columnId
@param $key
@param $value
@return $this | [
"Modify",
"grid",
"column"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Block/Widget/Grid.php#L138-L145 |
nonzod/yii2-foundation | Button.php | Button.run | public function run() {
if($this->tagName == 'a') {
echo Html::a($this->encodeLabel ? Html::encode($this->label) : $this->label, $this->url, $this->options);
} else {
$this->options['tabindex'] = '0';
echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
}
} | php | public function run() {
if($this->tagName == 'a') {
echo Html::a($this->encodeLabel ? Html::encode($this->label) : $this->label, $this->url, $this->options);
} else {
$this->options['tabindex'] = '0';
echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tagName",
"==",
"'a'",
")",
"{",
"echo",
"Html",
"::",
"a",
"(",
"$",
"this",
"->",
"encodeLabel",
"?",
"Html",
"::",
"encode",
"(",
"$",
"this",
"->",
"label",
")",
":",
"$",
"this",
"->",
"label",
",",
"$",
"this",
"->",
"url",
",",
"$",
"this",
"->",
"options",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"options",
"[",
"'tabindex'",
"]",
"=",
"'0'",
";",
"echo",
"Html",
"::",
"tag",
"(",
"$",
"this",
"->",
"tagName",
",",
"$",
"this",
"->",
"encodeLabel",
"?",
"Html",
"::",
"encode",
"(",
"$",
"this",
"->",
"label",
")",
":",
"$",
"this",
"->",
"label",
",",
"$",
"this",
"->",
"options",
")",
";",
"}",
"}"
] | Renders the widget. | [
"Renders",
"the",
"widget",
"."
] | train | https://github.com/nonzod/yii2-foundation/blob/5df93b8a39a73a7fade2f3189693fdb6625205d2/Button.php#L61-L68 |
HedronDev/hedron | src/ProjectTypeDictionary.php | ProjectTypeDictionary.getCurrentProject | public function getCurrentProject() {
return $this->createInstance($this->environment->getProjectType(), $this->environment, $this->configuration, $this->fileSystem);
} | php | public function getCurrentProject() {
return $this->createInstance($this->environment->getProjectType(), $this->environment, $this->configuration, $this->fileSystem);
} | [
"public",
"function",
"getCurrentProject",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"createInstance",
"(",
"$",
"this",
"->",
"environment",
"->",
"getProjectType",
"(",
")",
",",
"$",
"this",
"->",
"environment",
",",
"$",
"this",
"->",
"configuration",
",",
"$",
"this",
"->",
"fileSystem",
")",
";",
"}"
] | Get a project plugin for the current environment settings.
@return \Hedron\ProjectTypeInterface | [
"Get",
"a",
"project",
"plugin",
"for",
"the",
"current",
"environment",
"settings",
"."
] | train | https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/ProjectTypeDictionary.php#L55-L57 |
zhouyl/mellivora | Mellivora/Config/NativeArray.php | NativeArray.set | public function set($key, $value = null)
{
$data = is_array($key) ? $key : [$key => $value];
foreach ($data as $key => $value) {
Arr::set($this->config, $key, is_array($value) ? new self($value) : $value);
}
return $this;
} | php | public function set($key, $value = null)
{
$data = is_array($key) ? $key : [$key => $value];
foreach ($data as $key => $value) {
Arr::set($this->config, $key, is_array($value) ? new self($value) : $value);
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"[",
"$",
"key",
"=>",
"$",
"value",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"Arr",
"::",
"set",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"key",
",",
"is_array",
"(",
"$",
"value",
")",
"?",
"new",
"self",
"(",
"$",
"value",
")",
":",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 设定配置数据
@param string $key
@param mixed $value
@return \Mellivora\Config\NativeArray | [
"设定配置数据"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Config/NativeArray.php#L43-L52 |
zhouyl/mellivora | Mellivora/Config/NativeArray.php | NativeArray.get | public function get($key, $default = null)
{
$data = Arr::get($this->config, $key);
if ($data === null) {
$data = is_array($default) ? new self($default) : $default;
}
return $data;
} | php | public function get($key, $default = null)
{
$data = Arr::get($this->config, $key);
if ($data === null) {
$data = is_array($default) ? new self($default) : $default;
}
return $data;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"key",
")",
";",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"$",
"data",
"=",
"is_array",
"(",
"$",
"default",
")",
"?",
"new",
"self",
"(",
"$",
"default",
")",
":",
"$",
"default",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | 获取配置数据
@param string $key
@param mixed $default
@return mixed | [
"获取配置数据"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Config/NativeArray.php#L62-L71 |
zhouyl/mellivora | Mellivora/Config/NativeArray.php | NativeArray.toArray | public function toArray()
{
$data = [];
foreach ($this->config as $key => $value) {
if ($value instanceof self) {
$value = $value->toArray();
}
$data[$key] = $value;
}
return $data;
} | php | public function toArray()
{
$data = [];
foreach ($this->config as $key => $value) {
if ($value instanceof self) {
$value = $value->toArray();
}
$data[$key] = $value;
}
return $data;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"self",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | 将配置数据转换为数组格式
@return array | [
"将配置数据转换为数组格式"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Config/NativeArray.php#L114-L127 |
inhere/php-librarys | src/Traits/TraitUseOption.php | TraitUseOption.getOption | public function getOption(string $name, $default = null, $strict = null)
{
if (array_key_exists($name, $this->options)) {
$value = $this->options[$name];
// use strict, check value is empty ?
if (true === $strict || (false !== $strict && $this->isStrict())) {
$value = $value ?: $default;
}
} else {
$value = $default;
}
if ($value && ($value instanceof \Closure)) {
$value = $value();
}
return $value;
} | php | public function getOption(string $name, $default = null, $strict = null)
{
if (array_key_exists($name, $this->options)) {
$value = $this->options[$name];
// use strict, check value is empty ?
if (true === $strict || (false !== $strict && $this->isStrict())) {
$value = $value ?: $default;
}
} else {
$value = $default;
}
if ($value && ($value instanceof \Closure)) {
$value = $value();
}
return $value;
} | [
"public",
"function",
"getOption",
"(",
"string",
"$",
"name",
",",
"$",
"default",
"=",
"null",
",",
"$",
"strict",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
";",
"// use strict, check value is empty ?",
"if",
"(",
"true",
"===",
"$",
"strict",
"||",
"(",
"false",
"!==",
"$",
"strict",
"&&",
"$",
"this",
"->",
"isStrict",
"(",
")",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"?",
":",
"$",
"default",
";",
"}",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"default",
";",
"}",
"if",
"(",
"$",
"value",
"&&",
"(",
"$",
"value",
"instanceof",
"\\",
"Closure",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"(",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Method to get property Options
@param string $name
@param mixed $default
@param null|bool $strict
@return mixed | [
"Method",
"to",
"get",
"property",
"Options"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/TraitUseOption.php#L56-L75 |
inhere/php-librarys | src/Traits/TraitUseOption.php | TraitUseOption.delOption | public function delOption($name)
{
$value = null;
if ($this->hasOption($name)) {
$value = $this->getOption($name);
unset($this->options[$name]);
}
return $value;
} | php | public function delOption($name)
{
$value = null;
if ($this->hasOption($name)) {
$value = $this->getOption($name);
unset($this->options[$name]);
}
return $value;
} | [
"public",
"function",
"delOption",
"(",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"name",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getOption",
"(",
"$",
"name",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | delete a option
@param $name
@return mixed|null | [
"delete",
"a",
"option"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/TraitUseOption.php#L95-L106 |
inhere/php-librarys | src/Traits/TraitUseOption.php | TraitUseOption.setOptions | public function setOptions(array $options, $merge = true)
{
$this->options = $merge ? ArrayHelper::merge($this->options, $options) : $options;
return $this;
} | php | public function setOptions(array $options, $merge = true)
{
$this->options = $merge ? ArrayHelper::merge($this->options, $options) : $options;
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
",",
"$",
"merge",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"merge",
"?",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
":",
"$",
"options",
";",
"return",
"$",
"this",
";",
"}"
] | Method to set property options
@param array $options
@param bool $merge
@return static Return self to support chaining. | [
"Method",
"to",
"set",
"property",
"options"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/TraitUseOption.php#L123-L128 |
vaibhavpandeyvpz/sandesh | src/Uri.php | Uri.getAuthority | public function getAuthority()
{
$authority = $this->host;
$info = $this->getUserInfo();
if ($info) {
$authority = "{$info}@{$authority}";
}
if ($this->port) {
$authority = "{$authority}:{$this->port}";
}
return $authority;
} | php | public function getAuthority()
{
$authority = $this->host;
$info = $this->getUserInfo();
if ($info) {
$authority = "{$info}@{$authority}";
}
if ($this->port) {
$authority = "{$authority}:{$this->port}";
}
return $authority;
} | [
"public",
"function",
"getAuthority",
"(",
")",
"{",
"$",
"authority",
"=",
"$",
"this",
"->",
"host",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"getUserInfo",
"(",
")",
";",
"if",
"(",
"$",
"info",
")",
"{",
"$",
"authority",
"=",
"\"{$info}@{$authority}\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"port",
")",
"{",
"$",
"authority",
"=",
"\"{$authority}:{$this->port}\"",
";",
"}",
"return",
"$",
"authority",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/Uri.php#L65-L76 |
vaibhavpandeyvpz/sandesh | src/Uri.php | Uri.getUserInfo | public function getUserInfo()
{
$info = $this->user;
if ($info && $this->password) {
$info .= (':' . $this->password);
}
return $info;
} | php | public function getUserInfo()
{
$info = $this->user;
if ($info && $this->password) {
$info .= (':' . $this->password);
}
return $info;
} | [
"public",
"function",
"getUserInfo",
"(",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"user",
";",
"if",
"(",
"$",
"info",
"&&",
"$",
"this",
"->",
"password",
")",
"{",
"$",
"info",
".=",
"(",
"':'",
".",
"$",
"this",
"->",
"password",
")",
";",
"}",
"return",
"$",
"info",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/Uri.php#L129-L136 |
vaibhavpandeyvpz/sandesh | src/Uri.php | Uri.withPath | public function withPath($path)
{
MessageValidations::assertPath($path);
$path = MessageValidations::normalizePath($path);
$clone = clone $this;
$clone->path = $path;
return $clone;
} | php | public function withPath($path)
{
MessageValidations::assertPath($path);
$path = MessageValidations::normalizePath($path);
$clone = clone $this;
$clone->path = $path;
return $clone;
} | [
"public",
"function",
"withPath",
"(",
"$",
"path",
")",
"{",
"MessageValidations",
"::",
"assertPath",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"MessageValidations",
"::",
"normalizePath",
"(",
"$",
"path",
")",
";",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"path",
"=",
"$",
"path",
";",
"return",
"$",
"clone",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/Uri.php#L163-L170 |
vaibhavpandeyvpz/sandesh | src/Uri.php | Uri.withPort | public function withPort($port)
{
if ($port !== null) {
MessageValidations::assertTcpUdpPort($port = (int)$port);
}
$clone = clone $this;
$clone->port = $port;
return $clone;
} | php | public function withPort($port)
{
if ($port !== null) {
MessageValidations::assertTcpUdpPort($port = (int)$port);
}
$clone = clone $this;
$clone->port = $port;
return $clone;
} | [
"public",
"function",
"withPort",
"(",
"$",
"port",
")",
"{",
"if",
"(",
"$",
"port",
"!==",
"null",
")",
"{",
"MessageValidations",
"::",
"assertTcpUdpPort",
"(",
"$",
"port",
"=",
"(",
"int",
")",
"$",
"port",
")",
";",
"}",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"port",
"=",
"$",
"port",
";",
"return",
"$",
"clone",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/Uri.php#L175-L183 |
vaibhavpandeyvpz/sandesh | src/Uri.php | Uri.withQuery | public function withQuery($query)
{
MessageValidations::assertQuery($query);
$query = MessageValidations::normalizeQuery($query);
$clone = clone $this;
$clone->query = $query;
return $clone;
} | php | public function withQuery($query)
{
MessageValidations::assertQuery($query);
$query = MessageValidations::normalizeQuery($query);
$clone = clone $this;
$clone->query = $query;
return $clone;
} | [
"public",
"function",
"withQuery",
"(",
"$",
"query",
")",
"{",
"MessageValidations",
"::",
"assertQuery",
"(",
"$",
"query",
")",
";",
"$",
"query",
"=",
"MessageValidations",
"::",
"normalizeQuery",
"(",
"$",
"query",
")",
";",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"query",
"=",
"$",
"query",
";",
"return",
"$",
"clone",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/Uri.php#L188-L195 |
ClementIV/yii-rest-rbac2.0 | controllers/UserController.php | UserController.actionIndex | public function actionIndex()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
$searchModel = new UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $dataProvider;
}catch(Exception $e)
{
throw new Exception($e);
}
} | php | public function actionIndex()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
$searchModel = new UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $dataProvider;
}catch(Exception $e)
{
throw new Exception($e);
}
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'index'",
"]",
")",
";",
"}",
"try",
"{",
"$",
"searchModel",
"=",
"new",
"UserSearch",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
")",
";",
"return",
"$",
"dataProvider",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Lists all User models.
@return mixed | [
"Lists",
"all",
"User",
"models",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/UserController.php#L84-L101 |
ClementIV/yii-rest-rbac2.0 | controllers/UserController.php | UserController.actionDelete | public function actionDelete($id)
{
try{
return $this->findModel($id)->delete();
}catch(Exception $e){
throw new Exception($e);
}
} | php | public function actionDelete($id)
{
try{
return $this->findModel($id)->delete();
}catch(Exception $e){
throw new Exception($e);
}
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
"->",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Deletes an existing User model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed | [
"Deletes",
"an",
"existing",
"User",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/UserController.php#L128-L136 |
ClementIV/yii-rest-rbac2.0 | controllers/UserController.php | UserController.actionSignup | public function actionSignup()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['signup']);
}
try{
$model = new SignupForm();
$model->setAttributes(Yii::$app->request->post());
$user = $model->signup();
if ($user !=null) {
return ["success"=>true,"message"=>"创建成功!"];
}else{
return ["success"=>false,"message"=>"参数错误!"];
}
}catch(Exception $e){
throw new Exception($e);
}
} | php | public function actionSignup()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['signup']);
}
try{
$model = new SignupForm();
$model->setAttributes(Yii::$app->request->post());
$user = $model->signup();
if ($user !=null) {
return ["success"=>true,"message"=>"创建成功!"];
}else{
return ["success"=>false,"message"=>"参数错误!"];
}
}catch(Exception $e){
throw new Exception($e);
}
} | [
"public",
"function",
"actionSignup",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'signup'",
"]",
")",
";",
"}",
"try",
"{",
"$",
"model",
"=",
"new",
"SignupForm",
"(",
")",
";",
"$",
"model",
"->",
"setAttributes",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
";",
"$",
"user",
"=",
"$",
"model",
"->",
"signup",
"(",
")",
";",
"if",
"(",
"$",
"user",
"!=",
"null",
")",
"{",
"return",
"[",
"\"success\"",
"=>",
"true",
",",
"\"message\"",
"=>",
"\"创建成功!\"];",
"",
"",
"}",
"else",
"{",
"return",
"[",
"\"success\"",
"=>",
"false",
",",
"\"message\"",
"=>",
"\"参数错误!\"];",
"",
"",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Signup new user
@return string | [
"Signup",
"new",
"user"
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/UserController.php#L147-L168 |
php-lug/lug | src/Bundle/GridBundle/Form/Type/GridType.php | GridType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('filters', GridFiltersType::class, ['grid' => $options['grid']])
->add('sorting', GridSortingType::class, ['grid' => $options['grid']])
->add('page', GridPageType::class)
->add('limit', GridLimitType::class, ['grid' => $options['grid']])
->add('submit', SubmitType::class, ['label' => 'lug.filter.submit'])
->add('reset', SubmitType::class, ['label' => 'lug.filter.reset'])
->addEventSubscriber($this->gridSubscriber);
if ($options['persistent']) {
$builder->addEventSubscriber(clone $this->persistentGridSubscriber);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('filters', GridFiltersType::class, ['grid' => $options['grid']])
->add('sorting', GridSortingType::class, ['grid' => $options['grid']])
->add('page', GridPageType::class)
->add('limit', GridLimitType::class, ['grid' => $options['grid']])
->add('submit', SubmitType::class, ['label' => 'lug.filter.submit'])
->add('reset', SubmitType::class, ['label' => 'lug.filter.reset'])
->addEventSubscriber($this->gridSubscriber);
if ($options['persistent']) {
$builder->addEventSubscriber(clone $this->persistentGridSubscriber);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"'filters'",
",",
"GridFiltersType",
"::",
"class",
",",
"[",
"'grid'",
"=>",
"$",
"options",
"[",
"'grid'",
"]",
"]",
")",
"->",
"add",
"(",
"'sorting'",
",",
"GridSortingType",
"::",
"class",
",",
"[",
"'grid'",
"=>",
"$",
"options",
"[",
"'grid'",
"]",
"]",
")",
"->",
"add",
"(",
"'page'",
",",
"GridPageType",
"::",
"class",
")",
"->",
"add",
"(",
"'limit'",
",",
"GridLimitType",
"::",
"class",
",",
"[",
"'grid'",
"=>",
"$",
"options",
"[",
"'grid'",
"]",
"]",
")",
"->",
"add",
"(",
"'submit'",
",",
"SubmitType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'lug.filter.submit'",
"]",
")",
"->",
"add",
"(",
"'reset'",
",",
"SubmitType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'lug.filter.reset'",
"]",
")",
"->",
"addEventSubscriber",
"(",
"$",
"this",
"->",
"gridSubscriber",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'persistent'",
"]",
")",
"{",
"$",
"builder",
"->",
"addEventSubscriber",
"(",
"clone",
"$",
"this",
"->",
"persistentGridSubscriber",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Form/Type/GridType.php#L51-L65 |
php-lug/lug | src/Bundle/GridBundle/Form/Type/GridType.php | GridType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'persistent' => function (Options $options) {
return $options['grid']->hasOption('persistent')
&& $options['grid']->getOption('persistent');
},
'xml_http_request' => function (Options $options) {
return $options['grid']->hasOption('xml_http_request')
&& $options['grid']->getOption('xml_http_request');
},
'method' => 'GET',
'csrf_protection' => false,
])
->setRequired('grid')
->setAllowedTypes('grid', GridInterface::class)
->setAllowedTypes('persistent', 'boolean');
} | php | public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'persistent' => function (Options $options) {
return $options['grid']->hasOption('persistent')
&& $options['grid']->getOption('persistent');
},
'xml_http_request' => function (Options $options) {
return $options['grid']->hasOption('xml_http_request')
&& $options['grid']->getOption('xml_http_request');
},
'method' => 'GET',
'csrf_protection' => false,
])
->setRequired('grid')
->setAllowedTypes('grid', GridInterface::class)
->setAllowedTypes('persistent', 'boolean');
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setDefaults",
"(",
"[",
"'persistent'",
"=>",
"function",
"(",
"Options",
"$",
"options",
")",
"{",
"return",
"$",
"options",
"[",
"'grid'",
"]",
"->",
"hasOption",
"(",
"'persistent'",
")",
"&&",
"$",
"options",
"[",
"'grid'",
"]",
"->",
"getOption",
"(",
"'persistent'",
")",
";",
"}",
",",
"'xml_http_request'",
"=>",
"function",
"(",
"Options",
"$",
"options",
")",
"{",
"return",
"$",
"options",
"[",
"'grid'",
"]",
"->",
"hasOption",
"(",
"'xml_http_request'",
")",
"&&",
"$",
"options",
"[",
"'grid'",
"]",
"->",
"getOption",
"(",
"'xml_http_request'",
")",
";",
"}",
",",
"'method'",
"=>",
"'GET'",
",",
"'csrf_protection'",
"=>",
"false",
",",
"]",
")",
"->",
"setRequired",
"(",
"'grid'",
")",
"->",
"setAllowedTypes",
"(",
"'grid'",
",",
"GridInterface",
"::",
"class",
")",
"->",
"setAllowedTypes",
"(",
"'persistent'",
",",
"'boolean'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Form/Type/GridType.php#L70-L88 |
nguyenanhung/security | src/Password.php | Password.passwordReHash | public static function passwordReHash($password = '', $hash = '')
{
if (self::verifyPassword($password, $hash)) {
if (password_needs_rehash($hash, self::ALGORITHM_DEFAULT)) {
return self::createPassword($password);
}
}
return NULL;
} | php | public static function passwordReHash($password = '', $hash = '')
{
if (self::verifyPassword($password, $hash)) {
if (password_needs_rehash($hash, self::ALGORITHM_DEFAULT)) {
return self::createPassword($password);
}
}
return NULL;
} | [
"public",
"static",
"function",
"passwordReHash",
"(",
"$",
"password",
"=",
"''",
",",
"$",
"hash",
"=",
"''",
")",
"{",
"if",
"(",
"self",
"::",
"verifyPassword",
"(",
"$",
"password",
",",
"$",
"hash",
")",
")",
"{",
"if",
"(",
"password_needs_rehash",
"(",
"$",
"hash",
",",
"self",
"::",
"ALGORITHM_DEFAULT",
")",
")",
"{",
"return",
"self",
"::",
"createPassword",
"(",
"$",
"password",
")",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
] | Function passwordReHash
@author: 713uk13m <[email protected]>
@time : 2018-12-03 16:09
@param string $password
@param string $hash
@return bool|false|string|null | [
"Function",
"passwordReHash"
] | train | https://github.com/nguyenanhung/security/blob/a2c9bac66d3c2dad6d668ba6c2bd82ed04bffbd6/src/Password.php#L106-L115 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Plugin.php | Dwoo_Plugin.paramsToAttributes | public static function paramsToAttributes(array $params, $delim = '\'')
{
if (isset($params['*'])) {
$params = array_merge($params, $params['*']);
unset($params['*']);
}
$out = '';
foreach ($params as $attr=>$val) {
$out .= ' '.$attr.'=';
if (trim($val, '"\'')=='' || $val=='null') {
$out .= str_replace($delim, '\\'.$delim, '""');
} elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) {
$out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"');
} else {
$out .= str_replace($delim, '\\'.$delim, '"') . $delim . '.'.$val.'.' . $delim . str_replace($delim, '\\'.$delim, '"');
}
}
return ltrim($out);
} | php | public static function paramsToAttributes(array $params, $delim = '\'')
{
if (isset($params['*'])) {
$params = array_merge($params, $params['*']);
unset($params['*']);
}
$out = '';
foreach ($params as $attr=>$val) {
$out .= ' '.$attr.'=';
if (trim($val, '"\'')=='' || $val=='null') {
$out .= str_replace($delim, '\\'.$delim, '""');
} elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) {
$out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"');
} else {
$out .= str_replace($delim, '\\'.$delim, '"') . $delim . '.'.$val.'.' . $delim . str_replace($delim, '\\'.$delim, '"');
}
}
return ltrim($out);
} | [
"public",
"static",
"function",
"paramsToAttributes",
"(",
"array",
"$",
"params",
",",
"$",
"delim",
"=",
"'\\''",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'*'",
"]",
")",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"params",
",",
"$",
"params",
"[",
"'*'",
"]",
")",
";",
"unset",
"(",
"$",
"params",
"[",
"'*'",
"]",
")",
";",
"}",
"$",
"out",
"=",
"''",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"attr",
"=>",
"$",
"val",
")",
"{",
"$",
"out",
".=",
"' '",
".",
"$",
"attr",
".",
"'='",
";",
"if",
"(",
"trim",
"(",
"$",
"val",
",",
"'\"\\''",
")",
"==",
"''",
"||",
"$",
"val",
"==",
"'null'",
")",
"{",
"$",
"out",
".=",
"str_replace",
"(",
"$",
"delim",
",",
"'\\\\'",
".",
"$",
"delim",
",",
"'\"\"'",
")",
";",
"}",
"elseif",
"(",
"substr",
"(",
"$",
"val",
",",
"0",
",",
"1",
")",
"===",
"$",
"delim",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
")",
"===",
"$",
"delim",
")",
"{",
"$",
"out",
".=",
"str_replace",
"(",
"$",
"delim",
",",
"'\\\\'",
".",
"$",
"delim",
",",
"'\"'",
".",
"substr",
"(",
"$",
"val",
",",
"1",
",",
"-",
"1",
")",
".",
"'\"'",
")",
";",
"}",
"else",
"{",
"$",
"out",
".=",
"str_replace",
"(",
"$",
"delim",
",",
"'\\\\'",
".",
"$",
"delim",
",",
"'\"'",
")",
".",
"$",
"delim",
".",
"'.'",
".",
"$",
"val",
".",
"'.'",
".",
"$",
"delim",
".",
"str_replace",
"(",
"$",
"delim",
",",
"'\\\\'",
".",
"$",
"delim",
",",
"'\"'",
")",
";",
"}",
"}",
"return",
"ltrim",
"(",
"$",
"out",
")",
";",
"}"
] | utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag attributes
this is to be used in preProcessing or postProcessing functions, example :
$p = $compiler->getCompiledParams($params);
// get only the rest array as attributes
$attributes = Dwoo_Plugin::paramsToAttributes($p['*']);
// get all the parameters as attributes (if there is a rest array, it will be included)
$attributes = Dwoo_Plugin::paramsToAttributes($p);
@param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string
@param string $delim the string delimiter you want to use (defaults to ')
@return string | [
"utility",
"function",
"that",
"converts",
"an",
"array",
"of",
"compiled",
"parameters",
"(",
"or",
"rest",
"array",
")",
"to",
"a",
"string",
"of",
"xml",
"/",
"html",
"tag",
"attributes"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Plugin.php#L64-L84 |
Erdiko/core | src/Response.php | Response.getKeyValue | public function getKeyValue($key)
{
return empty($this->_data[$key]) ? null: $this->_data[$key];
} | php | public function getKeyValue($key)
{
return empty($this->_data[$key]) ? null: $this->_data[$key];
} | [
"public",
"function",
"getKeyValue",
"(",
"$",
"key",
")",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
")",
"?",
"null",
":",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
";",
"}"
] | Get data value by key
@param mixed $key
@return mixed | [
"Get",
"data",
"value",
"by",
"key"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Response.php#L55-L58 |
Erdiko/core | src/Response.php | Response.addTypedKeyValue | public function addTypedKeyValue($type, $key, $value)
{
if(empty($this->_data[$type]))
$this->_data[$type] = array();
$this->_data[$type][$key] = $value;
} | php | public function addTypedKeyValue($type, $key, $value)
{
if(empty($this->_data[$type]))
$this->_data[$type] = array();
$this->_data[$type][$key] = $value;
} | [
"public",
"function",
"addTypedKeyValue",
"(",
"$",
"type",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"type",
"]",
")",
")",
"$",
"this",
"->",
"_data",
"[",
"$",
"type",
"]",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_data",
"[",
"$",
"type",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] | Add a pool of key/values segmented by type
This is useful for js/css includes and other grouped data | [
"Add",
"a",
"pool",
"of",
"key",
"/",
"values",
"segmented",
"by",
"type",
"This",
"is",
"useful",
"for",
"js",
"/",
"css",
"includes",
"and",
"other",
"grouped",
"data"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Response.php#L64-L69 |
Erdiko/core | src/Response.php | Response.getTheme | public function getTheme()
{
if($this->_theme === null)
$this->_theme = new \erdiko\core\Theme($this->getThemeName(), null, $this->getThemeTemplate());
return $this->_theme;
} | php | public function getTheme()
{
if($this->_theme === null)
$this->_theme = new \erdiko\core\Theme($this->getThemeName(), null, $this->getThemeTemplate());
return $this->_theme;
} | [
"public",
"function",
"getTheme",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_theme",
"===",
"null",
")",
"$",
"this",
"->",
"_theme",
"=",
"new",
"\\",
"erdiko",
"\\",
"core",
"\\",
"Theme",
"(",
"$",
"this",
"->",
"getThemeName",
"(",
")",
",",
"null",
",",
"$",
"this",
"->",
"getThemeTemplate",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"_theme",
";",
"}"
] | Get theme
@return Theme Object $theme | [
"Get",
"theme"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Response.php#L86-L92 |
Erdiko/core | src/Response.php | Response.getThemeName | public function getThemeName()
{
if(!empty($this->_themeName))
$name = $this->_themeName;
elseif(!empty($this->_theme))
$name = $this->_theme->getName();
else
$name = Helper::getConfig()['theme']['name'];
return $name;
} | php | public function getThemeName()
{
if(!empty($this->_themeName))
$name = $this->_themeName;
elseif(!empty($this->_theme))
$name = $this->_theme->getName();
else
$name = Helper::getConfig()['theme']['name'];
return $name;
} | [
"public",
"function",
"getThemeName",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_themeName",
")",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"_themeName",
";",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_theme",
")",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"_theme",
"->",
"getName",
"(",
")",
";",
"else",
"$",
"name",
"=",
"Helper",
"::",
"getConfig",
"(",
")",
"[",
"'theme'",
"]",
"[",
"'name'",
"]",
";",
"return",
"$",
"name",
";",
"}"
] | Get the theme name
Name pecking order: response, theme, config
@return string $name | [
"Get",
"the",
"theme",
"name",
"Name",
"pecking",
"order",
":",
"response",
"theme",
"config"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Response.php#L110-L120 |
Erdiko/core | src/Response.php | Response.setThemeTemplate | public function setThemeTemplate($template)
{
$this->_themeTemplate = $template;
if ($this->getTheme() != null) {
$this->getTheme()->setTemplate($this->_themeTemplate);
}
} | php | public function setThemeTemplate($template)
{
$this->_themeTemplate = $template;
if ($this->getTheme() != null) {
$this->getTheme()->setTemplate($this->_themeTemplate);
}
} | [
"public",
"function",
"setThemeTemplate",
"(",
"$",
"template",
")",
"{",
"$",
"this",
"->",
"_themeTemplate",
"=",
"$",
"template",
";",
"if",
"(",
"$",
"this",
"->",
"getTheme",
"(",
")",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"getTheme",
"(",
")",
"->",
"setTemplate",
"(",
"$",
"this",
"->",
"_themeTemplate",
")",
";",
"}",
"}"
] | Set Theme Template
@param string $tamplate | [
"Set",
"Theme",
"Template"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Response.php#L127-L133 |
Erdiko/core | src/Response.php | Response.render | public function render()
{
// Render all objects to html (string)
$html = (string) $this->_content;
if (!$this->_themeIgnore) {
$theme = $this->getTheme();
$theme->setContent($html); // rendered html (body content)
$html = (string) $theme;
}
return $html;
} | php | public function render()
{
// Render all objects to html (string)
$html = (string) $this->_content;
if (!$this->_themeIgnore) {
$theme = $this->getTheme();
$theme->setContent($html); // rendered html (body content)
$html = (string) $theme;
}
return $html;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// Render all objects to html (string)",
"$",
"html",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"_content",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_themeIgnore",
")",
"{",
"$",
"theme",
"=",
"$",
"this",
"->",
"getTheme",
"(",
")",
";",
"$",
"theme",
"->",
"setContent",
"(",
"$",
"html",
")",
";",
"// rendered html (body content)",
"$",
"html",
"=",
"(",
"string",
")",
"$",
"theme",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | Render
@return string | [
"Render"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Response.php#L181-L193 |
GrupaZero/api | src/Gzero/Api/UrlParamsProcessor.php | UrlParamsProcessor.getProcessedFields | public function getProcessedFields()
{
return [
'page' => $this->getPage(),
'perPage' => $this->getPerPage(),
'filter' => $this->filter,
'orderBy' => $this->orderBy,
'query' => $this->searchQuery
];
} | php | public function getProcessedFields()
{
return [
'page' => $this->getPage(),
'perPage' => $this->getPerPage(),
'filter' => $this->filter,
'orderBy' => $this->orderBy,
'query' => $this->searchQuery
];
} | [
"public",
"function",
"getProcessedFields",
"(",
")",
"{",
"return",
"[",
"'page'",
"=>",
"$",
"this",
"->",
"getPage",
"(",
")",
",",
"'perPage'",
"=>",
"$",
"this",
"->",
"getPerPage",
"(",
")",
",",
"'filter'",
"=>",
"$",
"this",
"->",
"filter",
",",
"'orderBy'",
"=>",
"$",
"this",
"->",
"orderBy",
",",
"'query'",
"=>",
"$",
"this",
"->",
"searchQuery",
"]",
";",
"}"
] | Returns array with all processed fields
@return array | [
"Returns",
"array",
"with",
"all",
"processed",
"fields"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/UrlParamsProcessor.php#L100-L109 |
GrupaZero/api | src/Gzero/Api/UrlParamsProcessor.php | UrlParamsProcessor.process | public function process(array $input)
{
if (!empty($input['q'])) {
$this->searchQuery = $input['q'];
}
if (!empty($input['sort'])) {
foreach (explode(',', $input['sort']) as $sort) {
$this->processOrderByParams($sort);
}
}
$input = $this->processPageParams($input);
foreach ($input as $key => $param) {
if (!in_array($key, ['sort', 'page', 'per_page', 'q'], true)) {
$this->processFilterParams($key, $param);
}
}
return $this;
} | php | public function process(array $input)
{
if (!empty($input['q'])) {
$this->searchQuery = $input['q'];
}
if (!empty($input['sort'])) {
foreach (explode(',', $input['sort']) as $sort) {
$this->processOrderByParams($sort);
}
}
$input = $this->processPageParams($input);
foreach ($input as $key => $param) {
if (!in_array($key, ['sort', 'page', 'per_page', 'q'], true)) {
$this->processFilterParams($key, $param);
}
}
return $this;
} | [
"public",
"function",
"process",
"(",
"array",
"$",
"input",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"input",
"[",
"'q'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"searchQuery",
"=",
"$",
"input",
"[",
"'q'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"input",
"[",
"'sort'",
"]",
")",
")",
"{",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"input",
"[",
"'sort'",
"]",
")",
"as",
"$",
"sort",
")",
"{",
"$",
"this",
"->",
"processOrderByParams",
"(",
"$",
"sort",
")",
";",
"}",
"}",
"$",
"input",
"=",
"$",
"this",
"->",
"processPageParams",
"(",
"$",
"input",
")",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"[",
"'sort'",
",",
"'page'",
",",
"'per_page'",
",",
"'q'",
"]",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"processFilterParams",
"(",
"$",
"key",
",",
"$",
"param",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Process params
@param array $input Array with parameters to process
@return $this | [
"Process",
"params"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/UrlParamsProcessor.php#L118-L135 |
GrupaZero/api | src/Gzero/Api/UrlParamsProcessor.php | UrlParamsProcessor.processOrderByParams | private function processOrderByParams($sort)
{
$direction = (substr($sort, 0, 1) == '-') ? 'DESC' : 'ASC';
$field = (substr($sort, 0, 1) == '-') ? substr($sort, 1) : $sort;
$this->orderBy[] = [
snake_case($field),
$direction
];
} | php | private function processOrderByParams($sort)
{
$direction = (substr($sort, 0, 1) == '-') ? 'DESC' : 'ASC';
$field = (substr($sort, 0, 1) == '-') ? substr($sort, 1) : $sort;
$this->orderBy[] = [
snake_case($field),
$direction
];
} | [
"private",
"function",
"processOrderByParams",
"(",
"$",
"sort",
")",
"{",
"$",
"direction",
"=",
"(",
"substr",
"(",
"$",
"sort",
",",
"0",
",",
"1",
")",
"==",
"'-'",
")",
"?",
"'DESC'",
":",
"'ASC'",
";",
"$",
"field",
"=",
"(",
"substr",
"(",
"$",
"sort",
",",
"0",
",",
"1",
")",
"==",
"'-'",
")",
"?",
"substr",
"(",
"$",
"sort",
",",
"1",
")",
":",
"$",
"sort",
";",
"$",
"this",
"->",
"orderBy",
"[",
"]",
"=",
"[",
"snake_case",
"(",
"$",
"field",
")",
",",
"$",
"direction",
"]",
";",
"}"
] | Process order by params
@param string $sort Sort parameter
@return void | [
"Process",
"order",
"by",
"params"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/UrlParamsProcessor.php#L144-L152 |
GrupaZero/api | src/Gzero/Api/UrlParamsProcessor.php | UrlParamsProcessor.processPageParams | private function processPageParams(array $input)
{
if (!empty($input['page']) && is_numeric($input['page'])) {
$this->page = $input['page'];
}
if (!empty($input['per_page']) && is_numeric($input['per_page'])) {
$this->perPage = $input['per_page'];
}
return $input;
} | php | private function processPageParams(array $input)
{
if (!empty($input['page']) && is_numeric($input['page'])) {
$this->page = $input['page'];
}
if (!empty($input['per_page']) && is_numeric($input['per_page'])) {
$this->perPage = $input['per_page'];
}
return $input;
} | [
"private",
"function",
"processPageParams",
"(",
"array",
"$",
"input",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"input",
"[",
"'page'",
"]",
")",
"&&",
"is_numeric",
"(",
"$",
"input",
"[",
"'page'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"page",
"=",
"$",
"input",
"[",
"'page'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"input",
"[",
"'per_page'",
"]",
")",
"&&",
"is_numeric",
"(",
"$",
"input",
"[",
"'per_page'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"perPage",
"=",
"$",
"input",
"[",
"'per_page'",
"]",
";",
"}",
"return",
"$",
"input",
";",
"}"
] | Process page params
@param array $input Array of parameters
@return mixed | [
"Process",
"page",
"params"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/UrlParamsProcessor.php#L161-L170 |
GrupaZero/api | src/Gzero/Api/UrlParamsProcessor.php | UrlParamsProcessor.processFilterParams | private function processFilterParams($key, $param)
{
$this->filter[] = [
$key,
'=',
(is_numeric($param)) ? (float) $param : $param
];
} | php | private function processFilterParams($key, $param)
{
$this->filter[] = [
$key,
'=',
(is_numeric($param)) ? (float) $param : $param
];
} | [
"private",
"function",
"processFilterParams",
"(",
"$",
"key",
",",
"$",
"param",
")",
"{",
"$",
"this",
"->",
"filter",
"[",
"]",
"=",
"[",
"$",
"key",
",",
"'='",
",",
"(",
"is_numeric",
"(",
"$",
"param",
")",
")",
"?",
"(",
"float",
")",
"$",
"param",
":",
"$",
"param",
"]",
";",
"}"
] | Process filter params
@param string $key Param name
@param string $param Param value
@return void | [
"Process",
"filter",
"params"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/UrlParamsProcessor.php#L180-L187 |
frdl/webfan | .ApplicationComposer/apps/frdl/webfan/ApplicationComposer/Command/html.php | html.item_accounts | protected function item_accounts(){
$html .= $this->item_login();
$html .= $this->item_icontem();
$html .= $this->item_webfan();
$html .= $this->item_api();
$this->result->js .= "
mod.Tabs.delTabs();
mod.Tabs.addTab('#window_main_frdl-webfan-login', 'Admin', 'window_main_frdl-webfan-login', true);
mod.Tabs.addTab('#window_main_frdl-webfan-icontem', 'Icontem', 'window_main_frdl-webfan-icontem', true);
mod.Tabs.addTab('#window_main_frdl-webfan-webfan', 'Webfan', 'window_main_frdl-webfan-webfan', true);
mod.Tabs.addTab('#window_main_frdl-webfan-api', 'Webfan API', 'window_main_frdl-webfan-api', true);
mod.Tabs.render();
mod.Tabs.openTab('window_main_frdl-webfan-api');
";
return $html;
} | php | protected function item_accounts(){
$html .= $this->item_login();
$html .= $this->item_icontem();
$html .= $this->item_webfan();
$html .= $this->item_api();
$this->result->js .= "
mod.Tabs.delTabs();
mod.Tabs.addTab('#window_main_frdl-webfan-login', 'Admin', 'window_main_frdl-webfan-login', true);
mod.Tabs.addTab('#window_main_frdl-webfan-icontem', 'Icontem', 'window_main_frdl-webfan-icontem', true);
mod.Tabs.addTab('#window_main_frdl-webfan-webfan', 'Webfan', 'window_main_frdl-webfan-webfan', true);
mod.Tabs.addTab('#window_main_frdl-webfan-api', 'Webfan API', 'window_main_frdl-webfan-api', true);
mod.Tabs.render();
mod.Tabs.openTab('window_main_frdl-webfan-api');
";
return $html;
} | [
"protected",
"function",
"item_accounts",
"(",
")",
"{",
"$",
"html",
".=",
"$",
"this",
"->",
"item_login",
"(",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"item_icontem",
"(",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"item_webfan",
"(",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"item_api",
"(",
")",
";",
"$",
"this",
"->",
"result",
"->",
"js",
".=",
"\" \n\n mod.Tabs.delTabs();\t \t \t \n mod.Tabs.addTab('#window_main_frdl-webfan-login', 'Admin', 'window_main_frdl-webfan-login', true);\t \t \t \n mod.Tabs.addTab('#window_main_frdl-webfan-icontem', 'Icontem', 'window_main_frdl-webfan-icontem', true);\n mod.Tabs.addTab('#window_main_frdl-webfan-webfan', 'Webfan', 'window_main_frdl-webfan-webfan', true);\n mod.Tabs.addTab('#window_main_frdl-webfan-api', 'Webfan API', 'window_main_frdl-webfan-api', true);\n mod.Tabs.render(); \n mod.Tabs.openTab('window_main_frdl-webfan-api');\n\n\n \"",
";",
"return",
"$",
"html",
";",
"}"
] | /*
protected function item_package(){
$tab = 'window_main_frdl-webfan-packages-package';
$html = '';
$this->_check_db();
if(true !== $this->check($html, $tab, true, true))return $html;
$p = new \frdl\ApplicationComposer\Package\Man(true);
$p -> run('package', $this->argtoks, $this->data['config'], $this);
$html.= '<div id="'.$tab.'" class="wd-tab">' ;
$html.= $p ->html();
$html.= '</div>';
$this->result->js.= $p ->js();
return $html;
} | [
"/",
"*",
"protected",
"function",
"item_package",
"()",
"{",
"$tab",
"=",
"window_main_frdl",
"-",
"webfan",
"-",
"packages",
"-",
"package",
";",
"$html",
"=",
";",
"$this",
"-",
">",
"_check_db",
"()",
";",
"if",
"(",
"true",
"!",
"==",
"$this",
"-",
">",
"check",
"(",
"$html",
"$tab",
"true",
"true",
"))",
"return",
"$html",
";"
] | train | https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/apps/frdl/webfan/ApplicationComposer/Command/html.php#L324-L342 |
surebert/surebert-framework | src/sb/String/Image.php | Image.draw | public function draw($text, $size=12, $x=0, $y=0)
{
imagettftext($this->image, $size, $this->rotation, $x, $y, $this->text_color, $this->font, $text);
return $this->image;
} | php | public function draw($text, $size=12, $x=0, $y=0)
{
imagettftext($this->image, $size, $this->rotation, $x, $y, $this->text_color, $this->font, $text);
return $this->image;
} | [
"public",
"function",
"draw",
"(",
"$",
"text",
",",
"$",
"size",
"=",
"12",
",",
"$",
"x",
"=",
"0",
",",
"$",
"y",
"=",
"0",
")",
"{",
"imagettftext",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"size",
",",
"$",
"this",
"->",
"rotation",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"this",
"->",
"text_color",
",",
"$",
"this",
"->",
"font",
",",
"$",
"text",
")",
";",
"return",
"$",
"this",
"->",
"image",
";",
"}"
] | Draws the text onto the image
@param string $text The text to write on the image
@param integer $size The font size to use
@param integer $x The x position to start draiwng on the image
@param integer $y The y position to start drawing on the image
@return resource A png image resource that can be used by imagepng, imagegif for output | [
"Draws",
"the",
"text",
"onto",
"the",
"image"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/String/Image.php#L84-L91 |
hametuha/wpametu | src/WPametu/Pattern/Singleton.php | Singleton.get_instance | final public static function get_instance( array $setting = [] ) {
$class_name = get_called_class();
if ( ! isset( self::$instances[ $class_name ] ) ) {
self::$instances[ $class_name ] = new $class_name( $setting );
}
return self::$instances[ $class_name ];
} | php | final public static function get_instance( array $setting = [] ) {
$class_name = get_called_class();
if ( ! isset( self::$instances[ $class_name ] ) ) {
self::$instances[ $class_name ] = new $class_name( $setting );
}
return self::$instances[ $class_name ];
} | [
"final",
"public",
"static",
"function",
"get_instance",
"(",
"array",
"$",
"setting",
"=",
"[",
"]",
")",
"{",
"$",
"class_name",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"class_name",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instances",
"[",
"$",
"class_name",
"]",
"=",
"new",
"$",
"class_name",
"(",
"$",
"setting",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instances",
"[",
"$",
"class_name",
"]",
";",
"}"
] | Singleton initialize method
@param array $setting
@return static | [
"Singleton",
"initialize",
"method"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Pattern/Singleton.php#L32-L39 |
gdbots/iam-php | src/RevokeRolesFromUserHandler.php | RevokeRolesFromUserHandler.createUserRolesRevoked | protected function createUserRolesRevoked(RevokeRolesFromUser $command, Pbjx $pbjx): UserRolesRevoked
{
/** @var UserRolesRevoked $event */
$event = UserRolesRevokedV1Mixin::findOne()->createMessage();
return $event;
} | php | protected function createUserRolesRevoked(RevokeRolesFromUser $command, Pbjx $pbjx): UserRolesRevoked
{
/** @var UserRolesRevoked $event */
$event = UserRolesRevokedV1Mixin::findOne()->createMessage();
return $event;
} | [
"protected",
"function",
"createUserRolesRevoked",
"(",
"RevokeRolesFromUser",
"$",
"command",
",",
"Pbjx",
"$",
"pbjx",
")",
":",
"UserRolesRevoked",
"{",
"/** @var UserRolesRevoked $event */",
"$",
"event",
"=",
"UserRolesRevokedV1Mixin",
"::",
"findOne",
"(",
")",
"->",
"createMessage",
"(",
")",
";",
"return",
"$",
"event",
";",
"}"
] | @param RevokeRolesFromUser $command
@param Pbjx $pbjx
@return UserRolesRevoked | [
"@param",
"RevokeRolesFromUser",
"$command",
"@param",
"Pbjx",
"$pbjx"
] | train | https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/RevokeRolesFromUserHandler.php#L75-L80 |
oroinc/OroLayoutComponent | ExpressionLanguage/ExpressionProcessor.php | ExpressionProcessor.checkStringValue | protected function checkStringValue($value)
{
if (is_string($value)) {
$pos = strpos($value, '=');
if ($pos === 0) {
// expression
return self::STRING_IS_EXPRESSION;
} elseif ($pos === 1 && $value[0] === '\\') {
// the backslash (\) at the begin of the array key should be removed
return self::STRING_IS_EXPRESSION_STARTED_WITH_BACKSLASH;
}
}
// regular string
return self::STRING_IS_REGULAR;
} | php | protected function checkStringValue($value)
{
if (is_string($value)) {
$pos = strpos($value, '=');
if ($pos === 0) {
// expression
return self::STRING_IS_EXPRESSION;
} elseif ($pos === 1 && $value[0] === '\\') {
// the backslash (\) at the begin of the array key should be removed
return self::STRING_IS_EXPRESSION_STARTED_WITH_BACKSLASH;
}
}
// regular string
return self::STRING_IS_REGULAR;
} | [
"protected",
"function",
"checkStringValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"value",
",",
"'='",
")",
";",
"if",
"(",
"$",
"pos",
"===",
"0",
")",
"{",
"// expression",
"return",
"self",
"::",
"STRING_IS_EXPRESSION",
";",
"}",
"elseif",
"(",
"$",
"pos",
"===",
"1",
"&&",
"$",
"value",
"[",
"0",
"]",
"===",
"'\\\\'",
")",
"{",
"// the backslash (\\) at the begin of the array key should be removed",
"return",
"self",
"::",
"STRING_IS_EXPRESSION_STARTED_WITH_BACKSLASH",
";",
"}",
"}",
"// regular string",
"return",
"self",
"::",
"STRING_IS_REGULAR",
";",
"}"
] | @param string $value
@return int the checking result
0 - the value is regular string
1 - the value is an expression
-1 - the value is string that starts with "\="
which should be replaces with "=" | [
"@param",
"string",
"$value"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ExpressionLanguage/ExpressionProcessor.php#L227-L242 |
ajant/SimpleArrayLibrary | src/Categories/Getters.php | Getters.getColumns | public static function getColumns(array $array, array $columns, $allRowsMustHaveAllColumns = false)
{
// validation
foreach ($array as $key => $row) {
if (!is_array($row)) {
throw new UnexpectedValueException('Array element "' . $key . '" is not an array');
}
}
foreach ($columns as $key => $column) {
if (!is_string($column) && !is_numeric($column)) {
throw new InvalidArgumentException('Invalid column type in columns array, index "' . $key . '"');
}
}
if (!is_bool($allRowsMustHaveAllColumns)) {
throw new InvalidArgumentException('allRowsMustHaveAllColumns flag must be boolean');
}
$return = array_fill_keys($columns, array());
foreach ($array as $key => $row) {
foreach ($columns as $column) {
if (isset($row[$column]) || array_key_exists($column, $row)) {
$return[$column][$key] = $row[$column];
} elseif ($allRowsMustHaveAllColumns) {
throw new UnexpectedValueException('Row "' . $key . '" is missing column: "' . $column . '"');
}
}
}
return $return;
} | php | public static function getColumns(array $array, array $columns, $allRowsMustHaveAllColumns = false)
{
// validation
foreach ($array as $key => $row) {
if (!is_array($row)) {
throw new UnexpectedValueException('Array element "' . $key . '" is not an array');
}
}
foreach ($columns as $key => $column) {
if (!is_string($column) && !is_numeric($column)) {
throw new InvalidArgumentException('Invalid column type in columns array, index "' . $key . '"');
}
}
if (!is_bool($allRowsMustHaveAllColumns)) {
throw new InvalidArgumentException('allRowsMustHaveAllColumns flag must be boolean');
}
$return = array_fill_keys($columns, array());
foreach ($array as $key => $row) {
foreach ($columns as $column) {
if (isset($row[$column]) || array_key_exists($column, $row)) {
$return[$column][$key] = $row[$column];
} elseif ($allRowsMustHaveAllColumns) {
throw new UnexpectedValueException('Row "' . $key . '" is missing column: "' . $column . '"');
}
}
}
return $return;
} | [
"public",
"static",
"function",
"getColumns",
"(",
"array",
"$",
"array",
",",
"array",
"$",
"columns",
",",
"$",
"allRowsMustHaveAllColumns",
"=",
"false",
")",
"{",
"// validation",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"row",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Array element \"'",
".",
"$",
"key",
".",
"'\" is not an array'",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"key",
"=>",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"column",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"column",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid column type in columns array, index \"'",
".",
"$",
"key",
".",
"'\"'",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"allRowsMustHaveAllColumns",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'allRowsMustHaveAllColumns flag must be boolean'",
")",
";",
"}",
"$",
"return",
"=",
"array_fill_keys",
"(",
"$",
"columns",
",",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"$",
"column",
"]",
")",
"||",
"array_key_exists",
"(",
"$",
"column",
",",
"$",
"row",
")",
")",
"{",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"row",
"[",
"$",
"column",
"]",
";",
"}",
"elseif",
"(",
"$",
"allRowsMustHaveAllColumns",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Row \"'",
".",
"$",
"key",
".",
"'\" is missing column: \"'",
".",
"$",
"column",
".",
"'\"'",
")",
";",
"}",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Extracts a column from an array
@param array $array
@param array $columns
@param bool $allRowsMustHaveAllColumns
@return array
@throws UnexpectedValueException | [
"Extracts",
"a",
"column",
"from",
"an",
"array"
] | train | https://github.com/ajant/SimpleArrayLibrary/blob/374877c0f20a22a914eb3680eb1cf39e424071be/src/Categories/Getters.php#L20-L49 |
ajant/SimpleArrayLibrary | src/Categories/Getters.php | Getters.getRectangularDimensions | public static function getRectangularDimensions(array $array)
{
$return = -1;
$allArrays = array_map('is_array', $array);
// all elements are arrays, iterate through them and call the static function recursively
if (self::allElementsEqual($allArrays, true)) {
$elementsPerArray = array();
foreach ($array as $row) {
$noElements = self::getRectangularDimensions($row);
if ($noElements == -1) {
return $noElements;
}
$elementsPerArray[] = $noElements;
}
if (!self::allElementsEqual($elementsPerArray)) {
return -1;
} else {
$return = reset($elementsPerArray);
$return[] = count($elementsPerArray);
}
} // none of the elements are arrays, return number of elements of the "bottom" array
elseif (self::allElementsEqual($allArrays, false)) {
$return = array(0 => count($array));
}
return $return;
} | php | public static function getRectangularDimensions(array $array)
{
$return = -1;
$allArrays = array_map('is_array', $array);
// all elements are arrays, iterate through them and call the static function recursively
if (self::allElementsEqual($allArrays, true)) {
$elementsPerArray = array();
foreach ($array as $row) {
$noElements = self::getRectangularDimensions($row);
if ($noElements == -1) {
return $noElements;
}
$elementsPerArray[] = $noElements;
}
if (!self::allElementsEqual($elementsPerArray)) {
return -1;
} else {
$return = reset($elementsPerArray);
$return[] = count($elementsPerArray);
}
} // none of the elements are arrays, return number of elements of the "bottom" array
elseif (self::allElementsEqual($allArrays, false)) {
$return = array(0 => count($array));
}
return $return;
} | [
"public",
"static",
"function",
"getRectangularDimensions",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"return",
"=",
"-",
"1",
";",
"$",
"allArrays",
"=",
"array_map",
"(",
"'is_array'",
",",
"$",
"array",
")",
";",
"// all elements are arrays, iterate through them and call the static function recursively",
"if",
"(",
"self",
"::",
"allElementsEqual",
"(",
"$",
"allArrays",
",",
"true",
")",
")",
"{",
"$",
"elementsPerArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"row",
")",
"{",
"$",
"noElements",
"=",
"self",
"::",
"getRectangularDimensions",
"(",
"$",
"row",
")",
";",
"if",
"(",
"$",
"noElements",
"==",
"-",
"1",
")",
"{",
"return",
"$",
"noElements",
";",
"}",
"$",
"elementsPerArray",
"[",
"]",
"=",
"$",
"noElements",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"allElementsEqual",
"(",
"$",
"elementsPerArray",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"reset",
"(",
"$",
"elementsPerArray",
")",
";",
"$",
"return",
"[",
"]",
"=",
"count",
"(",
"$",
"elementsPerArray",
")",
";",
"}",
"}",
"// none of the elements are arrays, return number of elements of the \"bottom\" array",
"elseif",
"(",
"self",
"::",
"allElementsEqual",
"(",
"$",
"allArrays",
",",
"false",
")",
")",
"{",
"$",
"return",
"=",
"array",
"(",
"0",
"=>",
"count",
"(",
"$",
"array",
")",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Checks if an array is rectangular array and returns dimensions or -1 if it's not rectangular
@param array $array
@return int|array | [
"Checks",
"if",
"an",
"array",
"is",
"rectangular",
"array",
"and",
"returns",
"dimensions",
"or",
"-",
"1",
"if",
"it",
"s",
"not",
"rectangular"
] | train | https://github.com/ajant/SimpleArrayLibrary/blob/374877c0f20a22a914eb3680eb1cf39e424071be/src/Categories/Getters.php#L58-L84 |
ajant/SimpleArrayLibrary | src/Categories/Getters.php | Getters.selectRandomArrayElements | public static function selectRandomArrayElements(array $array, $numberOfRequiredElements)
{
// validation, must be positive int or 0
if (!self::isLogicallyCastableToInt($numberOfRequiredElements)) {
throw new InvalidArgumentException('Number of requested elements parameter must be a positive integer');
}
if ($numberOfRequiredElements <= 0) {
throw new InvalidArgumentException('Number of requested elements parameter must be a positive integer');
}
$selected = $array;
if (count($array) > $numberOfRequiredElements) {
// select required number of random keys
$selectedKeys = array_rand($array, $numberOfRequiredElements);
$selectedKeys = $numberOfRequiredElements == 1 ? [$selectedKeys] : $selectedKeys;
// select only array members with selected random keys
$selected = array_intersect_key($array, array_fill_keys($selectedKeys, null));
}
return $selected;
} | php | public static function selectRandomArrayElements(array $array, $numberOfRequiredElements)
{
// validation, must be positive int or 0
if (!self::isLogicallyCastableToInt($numberOfRequiredElements)) {
throw new InvalidArgumentException('Number of requested elements parameter must be a positive integer');
}
if ($numberOfRequiredElements <= 0) {
throw new InvalidArgumentException('Number of requested elements parameter must be a positive integer');
}
$selected = $array;
if (count($array) > $numberOfRequiredElements) {
// select required number of random keys
$selectedKeys = array_rand($array, $numberOfRequiredElements);
$selectedKeys = $numberOfRequiredElements == 1 ? [$selectedKeys] : $selectedKeys;
// select only array members with selected random keys
$selected = array_intersect_key($array, array_fill_keys($selectedKeys, null));
}
return $selected;
} | [
"public",
"static",
"function",
"selectRandomArrayElements",
"(",
"array",
"$",
"array",
",",
"$",
"numberOfRequiredElements",
")",
"{",
"// validation, must be positive int or 0",
"if",
"(",
"!",
"self",
"::",
"isLogicallyCastableToInt",
"(",
"$",
"numberOfRequiredElements",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Number of requested elements parameter must be a positive integer'",
")",
";",
"}",
"if",
"(",
"$",
"numberOfRequiredElements",
"<=",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Number of requested elements parameter must be a positive integer'",
")",
";",
"}",
"$",
"selected",
"=",
"$",
"array",
";",
"if",
"(",
"count",
"(",
"$",
"array",
")",
">",
"$",
"numberOfRequiredElements",
")",
"{",
"// select required number of random keys",
"$",
"selectedKeys",
"=",
"array_rand",
"(",
"$",
"array",
",",
"$",
"numberOfRequiredElements",
")",
";",
"$",
"selectedKeys",
"=",
"$",
"numberOfRequiredElements",
"==",
"1",
"?",
"[",
"$",
"selectedKeys",
"]",
":",
"$",
"selectedKeys",
";",
"// select only array members with selected random keys",
"$",
"selected",
"=",
"array_intersect_key",
"(",
"$",
"array",
",",
"array_fill_keys",
"(",
"$",
"selectedKeys",
",",
"null",
")",
")",
";",
"}",
"return",
"$",
"selected",
";",
"}"
] | Selects random sub array
@param array $array
@param int $numberOfRequiredElements
@return array
@throws InvalidArgumentException | [
"Selects",
"random",
"sub",
"array"
] | train | https://github.com/ajant/SimpleArrayLibrary/blob/374877c0f20a22a914eb3680eb1cf39e424071be/src/Categories/Getters.php#L95-L115 |
mothership-ec/composer | src/Composer/Command/ValidateCommand.php | ValidateCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$file = $input->getArgument('file');
if (!file_exists($file)) {
$this->getIO()->writeError('<error>' . $file . ' not found.</error>');
return 1;
}
if (!is_readable($file)) {
$this->getIO()->writeError('<error>' . $file . ' is not readable.</error>');
return 1;
}
$validator = new ConfigValidator($this->getIO());
$checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
$checkPublish = !$input->getOption('no-check-publish');
list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
// output errors/warnings
if (!$errors && !$publishErrors && !$warnings) {
$this->getIO()->write('<info>' . $file . ' is valid</info>');
} elseif (!$errors && !$publishErrors) {
$this->getIO()->writeError('<info>' . $file . ' is valid, but with a few warnings</info>');
$this->getIO()->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
} elseif (!$errors) {
$this->getIO()->writeError('<info>' . $file . ' is valid for simple usage with composer but has</info>');
$this->getIO()->writeError('<info>strict errors that make it unable to be published as a package:</info>');
$this->getIO()->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
} else {
$this->getIO()->writeError('<error>' . $file . ' is invalid, the following errors/warnings were found:</error>');
}
$messages = array(
'error' => $errors,
'warning' => $warnings,
);
// If checking publish errors, display them errors, otherwise just show them as warnings
if ($checkPublish) {
$messages['error'] = array_merge($messages['error'], $publishErrors);
} else {
$messages['warning'] = array_merge($messages['warning'], $publishErrors);
}
foreach ($messages as $style => $msgs) {
foreach ($msgs as $msg) {
$this->getIO()->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
}
}
return $errors || ($publishErrors && $checkPublish) ? 1 : 0;
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$file = $input->getArgument('file');
if (!file_exists($file)) {
$this->getIO()->writeError('<error>' . $file . ' not found.</error>');
return 1;
}
if (!is_readable($file)) {
$this->getIO()->writeError('<error>' . $file . ' is not readable.</error>');
return 1;
}
$validator = new ConfigValidator($this->getIO());
$checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
$checkPublish = !$input->getOption('no-check-publish');
list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
// output errors/warnings
if (!$errors && !$publishErrors && !$warnings) {
$this->getIO()->write('<info>' . $file . ' is valid</info>');
} elseif (!$errors && !$publishErrors) {
$this->getIO()->writeError('<info>' . $file . ' is valid, but with a few warnings</info>');
$this->getIO()->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
} elseif (!$errors) {
$this->getIO()->writeError('<info>' . $file . ' is valid for simple usage with composer but has</info>');
$this->getIO()->writeError('<info>strict errors that make it unable to be published as a package:</info>');
$this->getIO()->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
} else {
$this->getIO()->writeError('<error>' . $file . ' is invalid, the following errors/warnings were found:</error>');
}
$messages = array(
'error' => $errors,
'warning' => $warnings,
);
// If checking publish errors, display them errors, otherwise just show them as warnings
if ($checkPublish) {
$messages['error'] = array_merge($messages['error'], $publishErrors);
} else {
$messages['warning'] = array_merge($messages['warning'], $publishErrors);
}
foreach ($messages as $style => $msgs) {
foreach ($msgs as $msg) {
$this->getIO()->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
}
}
return $errors || ($publishErrors && $checkPublish) ? 1 : 0;
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"file",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'file'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<error>'",
".",
"$",
"file",
".",
"' not found.</error>'",
")",
";",
"return",
"1",
";",
"}",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<error>'",
".",
"$",
"file",
".",
"' is not readable.</error>'",
")",
";",
"return",
"1",
";",
"}",
"$",
"validator",
"=",
"new",
"ConfigValidator",
"(",
"$",
"this",
"->",
"getIO",
"(",
")",
")",
";",
"$",
"checkAll",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'no-check-all'",
")",
"?",
"0",
":",
"ValidatingArrayLoader",
"::",
"CHECK_ALL",
";",
"$",
"checkPublish",
"=",
"!",
"$",
"input",
"->",
"getOption",
"(",
"'no-check-publish'",
")",
";",
"list",
"(",
"$",
"errors",
",",
"$",
"publishErrors",
",",
"$",
"warnings",
")",
"=",
"$",
"validator",
"->",
"validate",
"(",
"$",
"file",
",",
"$",
"checkAll",
")",
";",
"// output errors/warnings",
"if",
"(",
"!",
"$",
"errors",
"&&",
"!",
"$",
"publishErrors",
"&&",
"!",
"$",
"warnings",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"'<info>'",
".",
"$",
"file",
".",
"' is valid</info>'",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"errors",
"&&",
"!",
"$",
"publishErrors",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<info>'",
".",
"$",
"file",
".",
"' is valid, but with a few warnings</info>'",
")",
";",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>'",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"errors",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<info>'",
".",
"$",
"file",
".",
"' is valid for simple usage with composer but has</info>'",
")",
";",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<info>strict errors that make it unable to be published as a package:</info>'",
")",
";",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<error>'",
".",
"$",
"file",
".",
"' is invalid, the following errors/warnings were found:</error>'",
")",
";",
"}",
"$",
"messages",
"=",
"array",
"(",
"'error'",
"=>",
"$",
"errors",
",",
"'warning'",
"=>",
"$",
"warnings",
",",
")",
";",
"// If checking publish errors, display them errors, otherwise just show them as warnings",
"if",
"(",
"$",
"checkPublish",
")",
"{",
"$",
"messages",
"[",
"'error'",
"]",
"=",
"array_merge",
"(",
"$",
"messages",
"[",
"'error'",
"]",
",",
"$",
"publishErrors",
")",
";",
"}",
"else",
"{",
"$",
"messages",
"[",
"'warning'",
"]",
"=",
"array_merge",
"(",
"$",
"messages",
"[",
"'warning'",
"]",
",",
"$",
"publishErrors",
")",
";",
"}",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"style",
"=>",
"$",
"msgs",
")",
"{",
"foreach",
"(",
"$",
"msgs",
"as",
"$",
"msg",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<'",
".",
"$",
"style",
".",
"'>'",
".",
"$",
"msg",
".",
"'</'",
".",
"$",
"style",
".",
"'>'",
")",
";",
"}",
"}",
"return",
"$",
"errors",
"||",
"(",
"$",
"publishErrors",
"&&",
"$",
"checkPublish",
")",
"?",
"1",
":",
"0",
";",
"}"
] | @param InputInterface $input
@param OutputInterface $output
@return int | [
"@param",
"InputInterface",
"$input",
"@param",
"OutputInterface",
"$output"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/ValidateCommand.php#L56-L109 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Helper/Uri.php | Uri.parseUri | protected function parseUri($uriString = '')
{
$status = @preg_match("~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~", $uriString, $matches);
if($status === FALSE)
{
throw new Exception("URI scheme-specific decomposition failed");
}
if(!$status) return;
$this->path = (isset($matches[4])) ? $matches[4] : '';
$this->query = (isset($matches[6])) ? $matches[6] : '';
$this->fragment = (isset($matches[8])) ? $matches[8] : '';
$status = @preg_match("~^(([^:@]*)(:([^@]*))?@)?((?(?=[[])[[][^]]+[]]|[^:]+))(:(.*))?$~", (isset($matches[3])) ? $matches[3] : "", $matches);
if($status === FALSE)
{
throw new Exception("URI scheme-specific authority decomposition failed");
}
if(!$status) return;
$this->user = isset($matches[2]) ? $matches[2] : "";
$this->pass = isset($matches[4]) ? $matches[4] : "";
$this->host = isset($matches[5]) === TRUE ? preg_replace('~^\[([^]]+)\]$~', '\1', $matches[5]) : "";
$this->port = isset($matches[7]) ? $matches[7] : "";
} | php | protected function parseUri($uriString = '')
{
$status = @preg_match("~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~", $uriString, $matches);
if($status === FALSE)
{
throw new Exception("URI scheme-specific decomposition failed");
}
if(!$status) return;
$this->path = (isset($matches[4])) ? $matches[4] : '';
$this->query = (isset($matches[6])) ? $matches[6] : '';
$this->fragment = (isset($matches[8])) ? $matches[8] : '';
$status = @preg_match("~^(([^:@]*)(:([^@]*))?@)?((?(?=[[])[[][^]]+[]]|[^:]+))(:(.*))?$~", (isset($matches[3])) ? $matches[3] : "", $matches);
if($status === FALSE)
{
throw new Exception("URI scheme-specific authority decomposition failed");
}
if(!$status) return;
$this->user = isset($matches[2]) ? $matches[2] : "";
$this->pass = isset($matches[4]) ? $matches[4] : "";
$this->host = isset($matches[5]) === TRUE ? preg_replace('~^\[([^]]+)\]$~', '\1', $matches[5]) : "";
$this->port = isset($matches[7]) ? $matches[7] : "";
} | [
"protected",
"function",
"parseUri",
"(",
"$",
"uriString",
"=",
"''",
")",
"{",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"\"~^((//)([^/?#]*))([^?#]*)(\\?([^#]*))?(#(.*))?$~\"",
",",
"$",
"uriString",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"status",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"URI scheme-specific decomposition failed\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"status",
")",
"return",
";",
"$",
"this",
"->",
"path",
"=",
"(",
"isset",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
")",
"?",
"$",
"matches",
"[",
"4",
"]",
":",
"''",
";",
"$",
"this",
"->",
"query",
"=",
"(",
"isset",
"(",
"$",
"matches",
"[",
"6",
"]",
")",
")",
"?",
"$",
"matches",
"[",
"6",
"]",
":",
"''",
";",
"$",
"this",
"->",
"fragment",
"=",
"(",
"isset",
"(",
"$",
"matches",
"[",
"8",
"]",
")",
")",
"?",
"$",
"matches",
"[",
"8",
"]",
":",
"''",
";",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"\"~^(([^:@]*)(:([^@]*))?@)?((?(?=[[])[[][^]]+[]]|[^:]+))(:(.*))?$~\"",
",",
"(",
"isset",
"(",
"$",
"matches",
"[",
"3",
"]",
")",
")",
"?",
"$",
"matches",
"[",
"3",
"]",
":",
"\"\"",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"status",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"URI scheme-specific authority decomposition failed\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"status",
")",
"return",
";",
"$",
"this",
"->",
"user",
"=",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"$",
"matches",
"[",
"2",
"]",
":",
"\"\"",
";",
"$",
"this",
"->",
"pass",
"=",
"isset",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
"?",
"$",
"matches",
"[",
"4",
"]",
":",
"\"\"",
";",
"$",
"this",
"->",
"host",
"=",
"isset",
"(",
"$",
"matches",
"[",
"5",
"]",
")",
"===",
"TRUE",
"?",
"preg_replace",
"(",
"'~^\\[([^]]+)\\]$~'",
",",
"'\\1'",
",",
"$",
"matches",
"[",
"5",
"]",
")",
":",
"\"\"",
";",
"$",
"this",
"->",
"port",
"=",
"isset",
"(",
"$",
"matches",
"[",
"7",
"]",
")",
"?",
"$",
"matches",
"[",
"7",
"]",
":",
"\"\"",
";",
"}"
] | Parses the scheme-specific portion of the URI and place its parts into instance variables.
@throws Exception
@return void | [
"Parses",
"the",
"scheme",
"-",
"specific",
"portion",
"of",
"the",
"URI",
"and",
"place",
"its",
"parts",
"into",
"instance",
"variables",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Uri.php#L145-L173 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Helper/Uri.php | Uri.check | public static function check($uri)
{
try
{
$uri = new self(strval($uri));
}
catch(\Exception $e)
{
return FALSE;
}
return $uri->valid();
} | php | public static function check($uri)
{
try
{
$uri = new self(strval($uri));
}
catch(\Exception $e)
{
return FALSE;
}
return $uri->valid();
} | [
"public",
"static",
"function",
"check",
"(",
"$",
"uri",
")",
"{",
"try",
"{",
"$",
"uri",
"=",
"new",
"self",
"(",
"strval",
"(",
"$",
"uri",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"FALSE",
";",
"}",
"return",
"$",
"uri",
"->",
"valid",
"(",
")",
";",
"}"
] | Returns TRUE if a given URI is valid.
@param string $uri
@return boolean | [
"Returns",
"TRUE",
"if",
"a",
"given",
"URI",
"is",
"valid",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Uri.php#L191-L203 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Helper/Uri.php | Uri.checkPath | public function checkPath($path = null)
{
if($path === null)
{
$path = $this->path;
}
if(strlen($path) == 0)
{
return TRUE;
}
$pattern = "/^" . $this->regex["path"] . "$/";
$status = @preg_match($pattern, $path);
if($status === FALSE)
{
throw new Exception("URI path validation failed");
}
return ($status == 1);
} | php | public function checkPath($path = null)
{
if($path === null)
{
$path = $this->path;
}
if(strlen($path) == 0)
{
return TRUE;
}
$pattern = "/^" . $this->regex["path"] . "$/";
$status = @preg_match($pattern, $path);
if($status === FALSE)
{
throw new Exception("URI path validation failed");
}
return ($status == 1);
} | [
"public",
"function",
"checkPath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"path",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
"==",
"0",
")",
"{",
"return",
"TRUE",
";",
"}",
"$",
"pattern",
"=",
"\"/^\"",
".",
"$",
"this",
"->",
"regex",
"[",
"\"path\"",
"]",
".",
"\"$/\"",
";",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"status",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"URI path validation failed\"",
")",
";",
"}",
"return",
"(",
"$",
"status",
"==",
"1",
")",
";",
"}"
] | Returns TRUE if the path is valid.
@param string $path
@throws Exception
@return boolean | [
"Returns",
"TRUE",
"if",
"the",
"path",
"is",
"valid",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Uri.php#L414-L435 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Helper/Uri.php | Uri.getHostUri | public static function getHostUri()
{
$sheme = (self::getHostParam("HTTPS") == "on") ? "https" : "http";
$serverName = new Str(self::getHostParam("HTTP_HOST"));
$serverPort = self::getHostParam("SERVER_PORT");
$serverPort = ($serverPort != 80 && $serverPort != 443) ? ":" . $serverPort : "";
if($serverName->endsWith($serverPort))
{
$serverName = $serverName->replace($serverPort, "");
}
return new Str($sheme . "://" . $serverName . $serverPort);
} | php | public static function getHostUri()
{
$sheme = (self::getHostParam("HTTPS") == "on") ? "https" : "http";
$serverName = new Str(self::getHostParam("HTTP_HOST"));
$serverPort = self::getHostParam("SERVER_PORT");
$serverPort = ($serverPort != 80 && $serverPort != 443) ? ":" . $serverPort : "";
if($serverName->endsWith($serverPort))
{
$serverName = $serverName->replace($serverPort, "");
}
return new Str($sheme . "://" . $serverName . $serverPort);
} | [
"public",
"static",
"function",
"getHostUri",
"(",
")",
"{",
"$",
"sheme",
"=",
"(",
"self",
"::",
"getHostParam",
"(",
"\"HTTPS\"",
")",
"==",
"\"on\"",
")",
"?",
"\"https\"",
":",
"\"http\"",
";",
"$",
"serverName",
"=",
"new",
"Str",
"(",
"self",
"::",
"getHostParam",
"(",
"\"HTTP_HOST\"",
")",
")",
";",
"$",
"serverPort",
"=",
"self",
"::",
"getHostParam",
"(",
"\"SERVER_PORT\"",
")",
";",
"$",
"serverPort",
"=",
"(",
"$",
"serverPort",
"!=",
"80",
"&&",
"$",
"serverPort",
"!=",
"443",
")",
"?",
"\":\"",
".",
"$",
"serverPort",
":",
"\"\"",
";",
"if",
"(",
"$",
"serverName",
"->",
"endsWith",
"(",
"$",
"serverPort",
")",
")",
"{",
"$",
"serverName",
"=",
"$",
"serverName",
"->",
"replace",
"(",
"$",
"serverPort",
",",
"\"\"",
")",
";",
"}",
"return",
"new",
"Str",
"(",
"$",
"sheme",
".",
"\"://\"",
".",
"$",
"serverName",
".",
"$",
"serverPort",
")",
";",
"}"
] | Returns the applications host address.
@return Str | [
"Returns",
"the",
"applications",
"host",
"address",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Uri.php#L677-L691 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/text_parser.php | ezcMailTextParser.parseBody | public function parseBody( $line )
{
$line = rtrim( $line, "\r\n" );
if ( $this->text === null )
{
$this->text = $line;
}
else
{
$this->text .= "\n" . $line;
}
} | php | public function parseBody( $line )
{
$line = rtrim( $line, "\r\n" );
if ( $this->text === null )
{
$this->text = $line;
}
else
{
$this->text .= "\n" . $line;
}
} | [
"public",
"function",
"parseBody",
"(",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"rtrim",
"(",
"$",
"line",
",",
"\"\\r\\n\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"text",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"text",
"=",
"$",
"line",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"text",
".=",
"\"\\n\"",
".",
"$",
"line",
";",
"}",
"}"
] | Adds each line to the body of the text part.
@param string $line | [
"Adds",
"each",
"line",
"to",
"the",
"body",
"of",
"the",
"text",
"part",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/text_parser.php#L59-L70 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/text_parser.php | ezcMailTextParser.finish | public function finish()
{
$charset = "us-ascii"; // RFC 2822 default
if ( isset( $this->headers['Content-Type'] ) )
{
preg_match( '/\s*charset\s?=\s?"?([^;"\s]*);?/',
$this->headers['Content-Type'],
$parameters );
if ( count( $parameters ) > 0 )
{
$charset = strtolower( trim( $parameters[1], '"' ) );
}
}
$encoding = strtolower( $this->headers['Content-Transfer-Encoding'] );
if ( $encoding == ezcMail::QUOTED_PRINTABLE )
{
$this->text = quoted_printable_decode( $this->text );
}
else if ( $encoding == ezcMail::BASE64 )
{
$this->text = base64_decode( $this->text );
}
$this->text = ezcMailCharsetConverter::convertToUTF8( $this->text, $charset );
$part = new ezcMailText( $this->text, 'utf-8', ezcMail::EIGHT_BIT, $charset );
$part->subType = $this->subType;
$part->setHeaders( $this->headers->getCaseSensitiveArray() );
ezcMailPartParser::parsePartHeaders( $this->headers, $part );
$part->size = strlen( $this->text );
return $part;
} | php | public function finish()
{
$charset = "us-ascii"; // RFC 2822 default
if ( isset( $this->headers['Content-Type'] ) )
{
preg_match( '/\s*charset\s?=\s?"?([^;"\s]*);?/',
$this->headers['Content-Type'],
$parameters );
if ( count( $parameters ) > 0 )
{
$charset = strtolower( trim( $parameters[1], '"' ) );
}
}
$encoding = strtolower( $this->headers['Content-Transfer-Encoding'] );
if ( $encoding == ezcMail::QUOTED_PRINTABLE )
{
$this->text = quoted_printable_decode( $this->text );
}
else if ( $encoding == ezcMail::BASE64 )
{
$this->text = base64_decode( $this->text );
}
$this->text = ezcMailCharsetConverter::convertToUTF8( $this->text, $charset );
$part = new ezcMailText( $this->text, 'utf-8', ezcMail::EIGHT_BIT, $charset );
$part->subType = $this->subType;
$part->setHeaders( $this->headers->getCaseSensitiveArray() );
ezcMailPartParser::parsePartHeaders( $this->headers, $part );
$part->size = strlen( $this->text );
return $part;
} | [
"public",
"function",
"finish",
"(",
")",
"{",
"$",
"charset",
"=",
"\"us-ascii\"",
";",
"// RFC 2822 default",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"'Content-Type'",
"]",
")",
")",
"{",
"preg_match",
"(",
"'/\\s*charset\\s?=\\s?\"?([^;\"\\s]*);?/'",
",",
"$",
"this",
"->",
"headers",
"[",
"'Content-Type'",
"]",
",",
"$",
"parameters",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
">",
"0",
")",
"{",
"$",
"charset",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"parameters",
"[",
"1",
"]",
",",
"'\"'",
")",
")",
";",
"}",
"}",
"$",
"encoding",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"headers",
"[",
"'Content-Transfer-Encoding'",
"]",
")",
";",
"if",
"(",
"$",
"encoding",
"==",
"ezcMail",
"::",
"QUOTED_PRINTABLE",
")",
"{",
"$",
"this",
"->",
"text",
"=",
"quoted_printable_decode",
"(",
"$",
"this",
"->",
"text",
")",
";",
"}",
"else",
"if",
"(",
"$",
"encoding",
"==",
"ezcMail",
"::",
"BASE64",
")",
"{",
"$",
"this",
"->",
"text",
"=",
"base64_decode",
"(",
"$",
"this",
"->",
"text",
")",
";",
"}",
"$",
"this",
"->",
"text",
"=",
"ezcMailCharsetConverter",
"::",
"convertToUTF8",
"(",
"$",
"this",
"->",
"text",
",",
"$",
"charset",
")",
";",
"$",
"part",
"=",
"new",
"ezcMailText",
"(",
"$",
"this",
"->",
"text",
",",
"'utf-8'",
",",
"ezcMail",
"::",
"EIGHT_BIT",
",",
"$",
"charset",
")",
";",
"$",
"part",
"->",
"subType",
"=",
"$",
"this",
"->",
"subType",
";",
"$",
"part",
"->",
"setHeaders",
"(",
"$",
"this",
"->",
"headers",
"->",
"getCaseSensitiveArray",
"(",
")",
")",
";",
"ezcMailPartParser",
"::",
"parsePartHeaders",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"part",
")",
";",
"$",
"part",
"->",
"size",
"=",
"strlen",
"(",
"$",
"this",
"->",
"text",
")",
";",
"return",
"$",
"part",
";",
"}"
] | Returns the ezcMailText part corresponding to the parsed message.
@return ezcMailText | [
"Returns",
"the",
"ezcMailText",
"part",
"corresponding",
"to",
"the",
"parsed",
"message",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/text_parser.php#L77-L109 |
qlake/framework | src/Qlake/Support/Autoload.php | Autoload.load | public static function load($class)
{
$file = static::normalizePath($class);
if (file_exists($path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
foreach (static::$directories as $directory)
{
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
}
if (static::$aliases[$class])
{
class_alias(static::$aliases[$class], $class);
return true;
}
return false;
} | php | public static function load($class)
{
$file = static::normalizePath($class);
if (file_exists($path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
foreach (static::$directories as $directory)
{
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$file))
{
require $path;
return true;
}
}
if (static::$aliases[$class])
{
class_alias(static::$aliases[$class], $class);
return true;
}
return false;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"$",
"file",
"=",
"static",
"::",
"normalizePath",
"(",
"$",
"class",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
"=",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
")",
"{",
"require",
"$",
"path",
";",
"return",
"true",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"directories",
"as",
"$",
"directory",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
"=",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
")",
"{",
"require",
"$",
"path",
";",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"static",
"::",
"$",
"aliases",
"[",
"$",
"class",
"]",
")",
"{",
"class_alias",
"(",
"static",
"::",
"$",
"aliases",
"[",
"$",
"class",
"]",
",",
"$",
"class",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Search and Include a Class by class name like Qlake\Router\Route.
@param string $class Like Qlake\Router\Route
@return bool | [
"Search",
"and",
"Include",
"a",
"Class",
"by",
"class",
"name",
"like",
"Qlake",
"\\",
"Router",
"\\",
"Route",
"."
] | train | https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Support/Autoload.php#L41-L70 |
qlake/framework | src/Qlake/Support/Autoload.php | Autoload.removeDirectories | public static function removeDirectories($directories = null)
{
if (is_null($directories))
{
static::$directories = [];
}
else
{
$directories = (array) $directories;
static::$directories = array_filter(static::$directories, function($directory) use ($directories)
{
return ( ! in_array($directory, $directories));
});
}
} | php | public static function removeDirectories($directories = null)
{
if (is_null($directories))
{
static::$directories = [];
}
else
{
$directories = (array) $directories;
static::$directories = array_filter(static::$directories, function($directory) use ($directories)
{
return ( ! in_array($directory, $directories));
});
}
} | [
"public",
"static",
"function",
"removeDirectories",
"(",
"$",
"directories",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"directories",
")",
")",
"{",
"static",
"::",
"$",
"directories",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"directories",
"=",
"(",
"array",
")",
"$",
"directories",
";",
"static",
"::",
"$",
"directories",
"=",
"array_filter",
"(",
"static",
"::",
"$",
"directories",
",",
"function",
"(",
"$",
"directory",
")",
"use",
"(",
"$",
"directories",
")",
"{",
"return",
"(",
"!",
"in_array",
"(",
"$",
"directory",
",",
"$",
"directories",
")",
")",
";",
"}",
")",
";",
"}",
"}"
] | Remove directory from directory list. If $directories parameter be null,
all directories will be removed.
@param string|null $directories
@return void | [
"Remove",
"directory",
"from",
"directory",
"list",
".",
"If",
"$directories",
"parameter",
"be",
"null",
"all",
"directories",
"will",
"be",
"removed",
"."
] | train | https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Support/Autoload.php#L124-L139 |
surebert/surebert-framework | src/sb/Web/Captcha.php | Captcha.createWord | private function createWord()
{
$this->word ='';
for($x=0;$x<rand(5,7);$x++){
$this->word .=$this->allowed_characters[ rand(0, strlen($this->allowed_characters)-1)];
}
return $this->word;
} | php | private function createWord()
{
$this->word ='';
for($x=0;$x<rand(5,7);$x++){
$this->word .=$this->allowed_characters[ rand(0, strlen($this->allowed_characters)-1)];
}
return $this->word;
} | [
"private",
"function",
"createWord",
"(",
")",
"{",
"$",
"this",
"->",
"word",
"=",
"''",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"rand",
"(",
"5",
",",
"7",
")",
";",
"$",
"x",
"++",
")",
"{",
"$",
"this",
"->",
"word",
".=",
"$",
"this",
"->",
"allowed_characters",
"[",
"rand",
"(",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"allowed_characters",
")",
"-",
"1",
")",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"word",
";",
"}"
] | Creates the word from the allowed characters
@return string | [
"Creates",
"the",
"word",
"from",
"the",
"allowed",
"characters"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Captcha.php#L107-L116 |
surebert/surebert-framework | src/sb/Web/Captcha.php | Captcha.addInterference | public function addInterference()
{
for($i=0;$i<20;$i++){
$radius = rand(0,150);
imageellipse($this->image, rand(0,200), rand(0,200), $radius, $radius, $this->ink_color);
}
} | php | public function addInterference()
{
for($i=0;$i<20;$i++){
$radius = rand(0,150);
imageellipse($this->image, rand(0,200), rand(0,200), $radius, $radius, $this->ink_color);
}
} | [
"public",
"function",
"addInterference",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"20",
";",
"$",
"i",
"++",
")",
"{",
"$",
"radius",
"=",
"rand",
"(",
"0",
",",
"150",
")",
";",
"imageellipse",
"(",
"$",
"this",
"->",
"image",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"$",
"radius",
",",
"$",
"radius",
",",
"$",
"this",
"->",
"ink_color",
")",
";",
"}",
"}"
] | Adds interference as circles int he backgroun the make it more difficult to parse. This is optional | [
"Adds",
"interference",
"as",
"circles",
"int",
"he",
"backgroun",
"the",
"make",
"it",
"more",
"difficult",
"to",
"parse",
".",
"This",
"is",
"optional"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Captcha.php#L122-L129 |
surebert/surebert-framework | src/sb/Web/Captcha.php | Captcha.draw | public function draw($filters=Array())
{
$word = $this->createWord();
for($j=0;$j<5;$j++){
if(file_exists($this->font)){
imagettftext($this->image, rand(8,18), rand(0,30), rand(0,200), rand(0,200), $this->ink_color, $this->font, 'not the code');
} else {
imagestring($this->image, rand(1,3), rand(0,200), rand(0,200), 'not the word', $this->ink_color );
}
}
if(file_exists($this->font)){
imagettftext($this->image, 30, rand(-45,45), rand(10,80), rand(80,120), $this->ink_color, $this->font, $this->word);
} else {
imagestring($this->image, 5, rand(10,80), rand(80,120), $this->word, $this->ink_color );
}
foreach($filters as $filter){
imagefilter($this->image, $filter);
}
return $this->image;
} | php | public function draw($filters=Array())
{
$word = $this->createWord();
for($j=0;$j<5;$j++){
if(file_exists($this->font)){
imagettftext($this->image, rand(8,18), rand(0,30), rand(0,200), rand(0,200), $this->ink_color, $this->font, 'not the code');
} else {
imagestring($this->image, rand(1,3), rand(0,200), rand(0,200), 'not the word', $this->ink_color );
}
}
if(file_exists($this->font)){
imagettftext($this->image, 30, rand(-45,45), rand(10,80), rand(80,120), $this->ink_color, $this->font, $this->word);
} else {
imagestring($this->image, 5, rand(10,80), rand(80,120), $this->word, $this->ink_color );
}
foreach($filters as $filter){
imagefilter($this->image, $filter);
}
return $this->image;
} | [
"public",
"function",
"draw",
"(",
"$",
"filters",
"=",
"Array",
"(",
")",
")",
"{",
"$",
"word",
"=",
"$",
"this",
"->",
"createWord",
"(",
")",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"5",
";",
"$",
"j",
"++",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"font",
")",
")",
"{",
"imagettftext",
"(",
"$",
"this",
"->",
"image",
",",
"rand",
"(",
"8",
",",
"18",
")",
",",
"rand",
"(",
"0",
",",
"30",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"$",
"this",
"->",
"ink_color",
",",
"$",
"this",
"->",
"font",
",",
"'not the code'",
")",
";",
"}",
"else",
"{",
"imagestring",
"(",
"$",
"this",
"->",
"image",
",",
"rand",
"(",
"1",
",",
"3",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"rand",
"(",
"0",
",",
"200",
")",
",",
"'not the word'",
",",
"$",
"this",
"->",
"ink_color",
")",
";",
"}",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"font",
")",
")",
"{",
"imagettftext",
"(",
"$",
"this",
"->",
"image",
",",
"30",
",",
"rand",
"(",
"-",
"45",
",",
"45",
")",
",",
"rand",
"(",
"10",
",",
"80",
")",
",",
"rand",
"(",
"80",
",",
"120",
")",
",",
"$",
"this",
"->",
"ink_color",
",",
"$",
"this",
"->",
"font",
",",
"$",
"this",
"->",
"word",
")",
";",
"}",
"else",
"{",
"imagestring",
"(",
"$",
"this",
"->",
"image",
",",
"5",
",",
"rand",
"(",
"10",
",",
"80",
")",
",",
"rand",
"(",
"80",
",",
"120",
")",
",",
"$",
"this",
"->",
"word",
",",
"$",
"this",
"->",
"ink_color",
")",
";",
"}",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"imagefilter",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"filter",
")",
";",
"}",
"return",
"$",
"this",
"->",
"image",
";",
"}"
] | Draws the wor text on the image using the true type font specified. If no font is specified than
@param arary $filters AN array of GD filter constants to run on the image
@return resource THe image is returned and can be used with imagepng to display or export to file | [
"Draws",
"the",
"wor",
"text",
"on",
"the",
"image",
"using",
"the",
"true",
"type",
"font",
"specified",
".",
"If",
"no",
"font",
"is",
"specified",
"than"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Captcha.php#L137-L164 |
windwork/wf-logger | lib/LoggerAbstract.php | LoggerAbstract.checkLevel | protected function checkLevel($level)
{
switch ($this->logLevel) {
case self::LEVEL_EMERGENCY:
if ($level != 'emergency') {
return false;
}
break;
case self::LEVEL_ALTER:
if (false === stripos('emergency|alert', $level)) {
return false;
}
break;
case self::LEVEL_CRITICAL:
if (false === stripos('emergency|alert|critical', $level)) {
return false;
}
break;
case self::LEVEL_ERROR:
if (false === stripos('emergency|alert|critical|error', $level)) {
return false;
}
break;
case self::LEVEL_WARNING:
if (false === stripos('emergency|alert|critical|error|warning', $level)) {
return false;
}
break;
case self::LEVEL_NOTICE:
if (false === stripos('emergency|alert|critical|error|notice', $level)) {
return false;
}
break;
case self::LEVEL_INFO:
if (false === stripos('emergency|alert|critical|error|notice|info', $level)) {
return false;
}
break;
case self::LEVEL_DEBUG:
// logging all
break;
}
return true;
} | php | protected function checkLevel($level)
{
switch ($this->logLevel) {
case self::LEVEL_EMERGENCY:
if ($level != 'emergency') {
return false;
}
break;
case self::LEVEL_ALTER:
if (false === stripos('emergency|alert', $level)) {
return false;
}
break;
case self::LEVEL_CRITICAL:
if (false === stripos('emergency|alert|critical', $level)) {
return false;
}
break;
case self::LEVEL_ERROR:
if (false === stripos('emergency|alert|critical|error', $level)) {
return false;
}
break;
case self::LEVEL_WARNING:
if (false === stripos('emergency|alert|critical|error|warning', $level)) {
return false;
}
break;
case self::LEVEL_NOTICE:
if (false === stripos('emergency|alert|critical|error|notice', $level)) {
return false;
}
break;
case self::LEVEL_INFO:
if (false === stripos('emergency|alert|critical|error|notice|info', $level)) {
return false;
}
break;
case self::LEVEL_DEBUG:
// logging all
break;
}
return true;
} | [
"protected",
"function",
"checkLevel",
"(",
"$",
"level",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"logLevel",
")",
"{",
"case",
"self",
"::",
"LEVEL_EMERGENCY",
":",
"if",
"(",
"$",
"level",
"!=",
"'emergency'",
")",
"{",
"return",
"false",
";",
"}",
"break",
";",
"case",
"self",
"::",
"LEVEL_ALTER",
":",
"if",
"(",
"false",
"===",
"stripos",
"(",
"'emergency|alert'",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"break",
";",
"case",
"self",
"::",
"LEVEL_CRITICAL",
":",
"if",
"(",
"false",
"===",
"stripos",
"(",
"'emergency|alert|critical'",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"break",
";",
"case",
"self",
"::",
"LEVEL_ERROR",
":",
"if",
"(",
"false",
"===",
"stripos",
"(",
"'emergency|alert|critical|error'",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"break",
";",
"case",
"self",
"::",
"LEVEL_WARNING",
":",
"if",
"(",
"false",
"===",
"stripos",
"(",
"'emergency|alert|critical|error|warning'",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"break",
";",
"case",
"self",
"::",
"LEVEL_NOTICE",
":",
"if",
"(",
"false",
"===",
"stripos",
"(",
"'emergency|alert|critical|error|notice'",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"break",
";",
"case",
"self",
"::",
"LEVEL_INFO",
":",
"if",
"(",
"false",
"===",
"stripos",
"(",
"'emergency|alert|critical|error|notice|info'",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"break",
";",
"case",
"self",
"::",
"LEVEL_DEBUG",
":",
"// logging all",
"break",
";",
"}",
"return",
"true",
";",
"}"
] | 检查是否启用该级别日志
@param string $level
@return bool | [
"检查是否启用该级别日志"
] | train | https://github.com/windwork/wf-logger/blob/60cd331d4106296610ef0b827fce38f357231958/lib/LoggerAbstract.php#L91-L141 |
windwork/wf-logger | lib/LoggerAbstract.php | LoggerAbstract.setLogDir | public function setLogDir($dir)
{
$dir = str_replace("\\", "/", $dir);
$dir = rtrim($dir, '/');
$this->logDir = $dir;
} | php | public function setLogDir($dir)
{
$dir = str_replace("\\", "/", $dir);
$dir = rtrim($dir, '/');
$this->logDir = $dir;
} | [
"public",
"function",
"setLogDir",
"(",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
",",
"$",
"dir",
")",
";",
"$",
"dir",
"=",
"rtrim",
"(",
"$",
"dir",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"logDir",
"=",
"$",
"dir",
";",
"}"
] | 设置日志目录,支持wrapper
@param string $dir | [
"设置日志目录,支持wrapper"
] | train | https://github.com/windwork/wf-logger/blob/60cd331d4106296610ef0b827fce38f357231958/lib/LoggerAbstract.php#L154-L160 |
hametuha/wpametu | src/WPametu/API/Controller.php | Controller.nonce_field | public function nonce_field($key = '_wpnonce', $referrer = false, $echo = true){
return wp_nonce_field($this->action, $key, $referrer, $echo);
} | php | public function nonce_field($key = '_wpnonce', $referrer = false, $echo = true){
return wp_nonce_field($this->action, $key, $referrer, $echo);
} | [
"public",
"function",
"nonce_field",
"(",
"$",
"key",
"=",
"'_wpnonce'",
",",
"$",
"referrer",
"=",
"false",
",",
"$",
"echo",
"=",
"true",
")",
"{",
"return",
"wp_nonce_field",
"(",
"$",
"this",
"->",
"action",
",",
"$",
"key",
",",
"$",
"referrer",
",",
"$",
"echo",
")",
";",
"}"
] | Echo nonce field
@param string $key Default _wpnonce
@param bool $referrer Default false.
@param bool $echo Default true
@return string | [
"Echo",
"nonce",
"field"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Controller.php#L152-L154 |
hametuha/wpametu | src/WPametu/API/Controller.php | Controller.load_template | public function load_template($slug, $name = '', array $args = []){
$base_path = $slug.'.php';
$original_path = $slug.( !empty($name) ? '-'.$name : '' ).'.php';
$found_path = '';
foreach( [$original_path, $base_path] as $file ){
foreach( [get_stylesheet_directory(), get_template_directory()] as $dir ){
$path = $dir.'/'.ltrim($file, '\\');
if( file_exists($path) ){
$found_path = $path;
break 2;
}
}
}
if( $found_path ){
// Path found. Let's locate template.
global $post, $posts, $wp_query;
if( !empty($args) ){
extract($args);
}
include $found_path;
}
} | php | public function load_template($slug, $name = '', array $args = []){
$base_path = $slug.'.php';
$original_path = $slug.( !empty($name) ? '-'.$name : '' ).'.php';
$found_path = '';
foreach( [$original_path, $base_path] as $file ){
foreach( [get_stylesheet_directory(), get_template_directory()] as $dir ){
$path = $dir.'/'.ltrim($file, '\\');
if( file_exists($path) ){
$found_path = $path;
break 2;
}
}
}
if( $found_path ){
// Path found. Let's locate template.
global $post, $posts, $wp_query;
if( !empty($args) ){
extract($args);
}
include $found_path;
}
} | [
"public",
"function",
"load_template",
"(",
"$",
"slug",
",",
"$",
"name",
"=",
"''",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"base_path",
"=",
"$",
"slug",
".",
"'.php'",
";",
"$",
"original_path",
"=",
"$",
"slug",
".",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
"?",
"'-'",
".",
"$",
"name",
":",
"''",
")",
".",
"'.php'",
";",
"$",
"found_path",
"=",
"''",
";",
"foreach",
"(",
"[",
"$",
"original_path",
",",
"$",
"base_path",
"]",
"as",
"$",
"file",
")",
"{",
"foreach",
"(",
"[",
"get_stylesheet_directory",
"(",
")",
",",
"get_template_directory",
"(",
")",
"]",
"as",
"$",
"dir",
")",
"{",
"$",
"path",
"=",
"$",
"dir",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"file",
",",
"'\\\\'",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"found_path",
"=",
"$",
"path",
";",
"break",
"2",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"found_path",
")",
"{",
"// Path found. Let's locate template.",
"global",
"$",
"post",
",",
"$",
"posts",
",",
"$",
"wp_query",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"extract",
"(",
"$",
"args",
")",
";",
"}",
"include",
"$",
"found_path",
";",
"}",
"}"
] | Load template
@param string $slug
@param string $name
@param array $args This array will be extract | [
"Load",
"template"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Controller.php#L163-L184 |
hametuha/wpametu | src/WPametu/API/Controller.php | Controller.view | public static function view($slug, $name = '', array $args = []){
$class_name = get_called_class();
/** @var Controller $instance */
$instance = $class_name::get_instance();
$instance->lazy_scripts();
$instance->load_template($slug, $name, $args);
} | php | public static function view($slug, $name = '', array $args = []){
$class_name = get_called_class();
/** @var Controller $instance */
$instance = $class_name::get_instance();
$instance->lazy_scripts();
$instance->load_template($slug, $name, $args);
} | [
"public",
"static",
"function",
"view",
"(",
"$",
"slug",
",",
"$",
"name",
"=",
"''",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"class_name",
"=",
"get_called_class",
"(",
")",
";",
"/** @var Controller $instance */",
"$",
"instance",
"=",
"$",
"class_name",
"::",
"get_instance",
"(",
")",
";",
"$",
"instance",
"->",
"lazy_scripts",
"(",
")",
";",
"$",
"instance",
"->",
"load_template",
"(",
"$",
"slug",
",",
"$",
"name",
",",
"$",
"args",
")",
";",
"}"
] | Load view template with arguments
@param string $slug
@param string $name
@param array $args | [
"Load",
"view",
"template",
"with",
"arguments"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Controller.php#L193-L199 |
ekuiter/feature-php | FeaturePhp/Generator/ExtendGenerator.php | ExtendGenerator.getExtendableFile | private function getExtendableFile($specification) {
$target = $specification->getTarget();
if (!array_key_exists($target, $this->extendableFiles)) {
if (!$specification->mayCreate())
return null;
$this->extendableFiles[$target] = $this->getExtendableFileFromSpecification($specification);
$this->logFile->log(null, "added file \"{$specification->getTarget()}\"");
}
return $this->extendableFiles[$target];
} | php | private function getExtendableFile($specification) {
$target = $specification->getTarget();
if (!array_key_exists($target, $this->extendableFiles)) {
if (!$specification->mayCreate())
return null;
$this->extendableFiles[$target] = $this->getExtendableFileFromSpecification($specification);
$this->logFile->log(null, "added file \"{$specification->getTarget()}\"");
}
return $this->extendableFiles[$target];
} | [
"private",
"function",
"getExtendableFile",
"(",
"$",
"specification",
")",
"{",
"$",
"target",
"=",
"$",
"specification",
"->",
"getTarget",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"target",
",",
"$",
"this",
"->",
"extendableFiles",
")",
")",
"{",
"if",
"(",
"!",
"$",
"specification",
"->",
"mayCreate",
"(",
")",
")",
"return",
"null",
";",
"$",
"this",
"->",
"extendableFiles",
"[",
"$",
"target",
"]",
"=",
"$",
"this",
"->",
"getExtendableFileFromSpecification",
"(",
"$",
"specification",
")",
";",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"null",
",",
"\"added file \\\"{$specification->getTarget()}\\\"\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"extendableFiles",
"[",
"$",
"target",
"]",
";",
"}"
] | Creates an extendable file from a specification.
If the extendable file was already created, returns the cached extendable file.
If the extendable file does not yet exist, create it if it may be created from
this specification.
@param \FeaturePhp\Specification\Specification $specification
@return \FeaturePhp\File\ExtendableFile | [
"Creates",
"an",
"extendable",
"file",
"from",
"a",
"specification",
".",
"If",
"the",
"extendable",
"file",
"was",
"already",
"created",
"returns",
"the",
"cached",
"extendable",
"file",
".",
"If",
"the",
"extendable",
"file",
"does",
"not",
"yet",
"exist",
"create",
"it",
"if",
"it",
"may",
"be",
"created",
"from",
"this",
"specification",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ExtendGenerator.php#L41-L50 |
ekuiter/feature-php | FeaturePhp/Generator/ExtendGenerator.php | ExtendGenerator.generateFilesForArtifacts | private function generateFilesForArtifacts($artifacts, $fileSettingsGetter, $extend) {
foreach ($artifacts as $artifact) {
$settings = $artifact->getGeneratorSettings(static::getKey());
foreach (call_user_func(array($this, $fileSettingsGetter), $settings) as $file) {
$specification = $this->getSpecification($file, $settings, $artifact);
$extendableFile = $this->getExtendableFile($specification);
if ($extendableFile && $extend) {
$places = $extendableFile->extend($specification);
foreach ($places as $placePair) {
if (!is_array($placePair))
$placePair = array(new \FeaturePhp\Artifact\SettingsPlace($artifact), $placePair);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
static::getKey() === "template" ? "rule" : "chunk", $artifact, $placePair[0], $placePair[1]);
}
$this->logFile->log($artifact, "extended file \"{$specification->getTarget()}\"");
}
}
}
} | php | private function generateFilesForArtifacts($artifacts, $fileSettingsGetter, $extend) {
foreach ($artifacts as $artifact) {
$settings = $artifact->getGeneratorSettings(static::getKey());
foreach (call_user_func(array($this, $fileSettingsGetter), $settings) as $file) {
$specification = $this->getSpecification($file, $settings, $artifact);
$extendableFile = $this->getExtendableFile($specification);
if ($extendableFile && $extend) {
$places = $extendableFile->extend($specification);
foreach ($places as $placePair) {
if (!is_array($placePair))
$placePair = array(new \FeaturePhp\Artifact\SettingsPlace($artifact), $placePair);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
static::getKey() === "template" ? "rule" : "chunk", $artifact, $placePair[0], $placePair[1]);
}
$this->logFile->log($artifact, "extended file \"{$specification->getTarget()}\"");
}
}
}
} | [
"private",
"function",
"generateFilesForArtifacts",
"(",
"$",
"artifacts",
",",
"$",
"fileSettingsGetter",
",",
"$",
"extend",
")",
"{",
"foreach",
"(",
"$",
"artifacts",
"as",
"$",
"artifact",
")",
"{",
"$",
"settings",
"=",
"$",
"artifact",
"->",
"getGeneratorSettings",
"(",
"static",
"::",
"getKey",
"(",
")",
")",
";",
"foreach",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"fileSettingsGetter",
")",
",",
"$",
"settings",
")",
"as",
"$",
"file",
")",
"{",
"$",
"specification",
"=",
"$",
"this",
"->",
"getSpecification",
"(",
"$",
"file",
",",
"$",
"settings",
",",
"$",
"artifact",
")",
";",
"$",
"extendableFile",
"=",
"$",
"this",
"->",
"getExtendableFile",
"(",
"$",
"specification",
")",
";",
"if",
"(",
"$",
"extendableFile",
"&&",
"$",
"extend",
")",
"{",
"$",
"places",
"=",
"$",
"extendableFile",
"->",
"extend",
"(",
"$",
"specification",
")",
";",
"foreach",
"(",
"$",
"places",
"as",
"$",
"placePair",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"placePair",
")",
")",
"$",
"placePair",
"=",
"array",
"(",
"new",
"\\",
"FeaturePhp",
"\\",
"Artifact",
"\\",
"SettingsPlace",
"(",
"$",
"artifact",
")",
",",
"$",
"placePair",
")",
";",
"$",
"this",
"->",
"tracingLinks",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLink",
"(",
"static",
"::",
"getKey",
"(",
")",
"===",
"\"template\"",
"?",
"\"rule\"",
":",
"\"chunk\"",
",",
"$",
"artifact",
",",
"$",
"placePair",
"[",
"0",
"]",
",",
"$",
"placePair",
"[",
"1",
"]",
")",
";",
"}",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"$",
"artifact",
",",
"\"extended file \\\"{$specification->getTarget()}\\\"\"",
")",
";",
"}",
"}",
"}",
"}"
] | Generates the extendable files for a set of artifacts and file settings.
@param \FeaturePhp\Artifact\Artifact[] $artifacts
@param callable $fileSettingsGetter
@param bool $extend | [
"Generates",
"the",
"extendable",
"files",
"for",
"a",
"set",
"of",
"artifacts",
"and",
"file",
"settings",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ExtendGenerator.php#L58-L77 |
ekuiter/feature-php | FeaturePhp/Generator/ExtendGenerator.php | ExtendGenerator._generateFiles | protected function _generateFiles() {
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", false);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", false);
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", true);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", true);
foreach ($this->extendableFiles as $extendableFile)
$this->files[] = $extendableFile;
} | php | protected function _generateFiles() {
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", false);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", false);
$this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", true);
$this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", true);
foreach ($this->extendableFiles as $extendableFile)
$this->files[] = $extendableFile;
} | [
"protected",
"function",
"_generateFiles",
"(",
")",
"{",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"selectedArtifacts",
",",
"\"getFileSettingsForSelected\"",
",",
"false",
")",
";",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"deselectedArtifacts",
",",
"\"getFileSettingsForDeselected\"",
",",
"false",
")",
";",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"selectedArtifacts",
",",
"\"getFileSettingsForSelected\"",
",",
"true",
")",
";",
"$",
"this",
"->",
"generateFilesForArtifacts",
"(",
"$",
"this",
"->",
"deselectedArtifacts",
",",
"\"getFileSettingsForDeselected\"",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"extendableFiles",
"as",
"$",
"extendableFile",
")",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"$",
"extendableFile",
";",
"}"
] | Generates the extendable files. | [
"Generates",
"the",
"extendable",
"files",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ExtendGenerator.php#L82-L91 |
zicht/z | src/Zicht/Tool/Packager/Node/Stub.php | Stub.compile | final public function compile(Buffer $buffer)
{
$buffer
->writeln("Phar::mapPhar('z.phar');")
->writeln("define('ZPREFIX', 'phar://z.phar/');")
->writeln("require_once 'phar://z.phar/vendor/autoload.php';")
;
$this->compileInitialization($buffer);
$buffer
->writeln('$app->run();')
->writeln('__HALT_COMPILER();')
;
} | php | final public function compile(Buffer $buffer)
{
$buffer
->writeln("Phar::mapPhar('z.phar');")
->writeln("define('ZPREFIX', 'phar://z.phar/');")
->writeln("require_once 'phar://z.phar/vendor/autoload.php';")
;
$this->compileInitialization($buffer);
$buffer
->writeln('$app->run();')
->writeln('__HALT_COMPILER();')
;
} | [
"final",
"public",
"function",
"compile",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"buffer",
"->",
"writeln",
"(",
"\"Phar::mapPhar('z.phar');\"",
")",
"->",
"writeln",
"(",
"\"define('ZPREFIX', 'phar://z.phar/');\"",
")",
"->",
"writeln",
"(",
"\"require_once 'phar://z.phar/vendor/autoload.php';\"",
")",
";",
"$",
"this",
"->",
"compileInitialization",
"(",
"$",
"buffer",
")",
";",
"$",
"buffer",
"->",
"writeln",
"(",
"'$app->run();'",
")",
"->",
"writeln",
"(",
"'__HALT_COMPILER();'",
")",
";",
"}"
] | Compiles into the specified buffer.
@param \Zicht\Tool\Script\Buffer $buffer
@return void | [
"Compiles",
"into",
"the",
"specified",
"buffer",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Packager/Node/Stub.php#L43-L56 |
gdbots/iam-php | src/GetAllAppsRequestHandler.php | GetAllAppsRequestHandler.handle | protected function handle(GetAllAppsRequest $request, Pbjx $pbjx): GetAllAppsResponse
{
$apps = [];
/** @var Schema $schema */
foreach (AppV1Mixin::findAll() as $schema) {
$this->ncr->pipeNodes($schema->getQName(), function (Node $node) use (&$apps) {
$apps[] = $node;
}, $this->createNcrContext($request));
}
return $this->createGetAllAppsResponse($request, $pbjx)->addToList('nodes', $apps);
} | php | protected function handle(GetAllAppsRequest $request, Pbjx $pbjx): GetAllAppsResponse
{
$apps = [];
/** @var Schema $schema */
foreach (AppV1Mixin::findAll() as $schema) {
$this->ncr->pipeNodes($schema->getQName(), function (Node $node) use (&$apps) {
$apps[] = $node;
}, $this->createNcrContext($request));
}
return $this->createGetAllAppsResponse($request, $pbjx)->addToList('nodes', $apps);
} | [
"protected",
"function",
"handle",
"(",
"GetAllAppsRequest",
"$",
"request",
",",
"Pbjx",
"$",
"pbjx",
")",
":",
"GetAllAppsResponse",
"{",
"$",
"apps",
"=",
"[",
"]",
";",
"/** @var Schema $schema */",
"foreach",
"(",
"AppV1Mixin",
"::",
"findAll",
"(",
")",
"as",
"$",
"schema",
")",
"{",
"$",
"this",
"->",
"ncr",
"->",
"pipeNodes",
"(",
"$",
"schema",
"->",
"getQName",
"(",
")",
",",
"function",
"(",
"Node",
"$",
"node",
")",
"use",
"(",
"&",
"$",
"apps",
")",
"{",
"$",
"apps",
"[",
"]",
"=",
"$",
"node",
";",
"}",
",",
"$",
"this",
"->",
"createNcrContext",
"(",
"$",
"request",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createGetAllAppsResponse",
"(",
"$",
"request",
",",
"$",
"pbjx",
")",
"->",
"addToList",
"(",
"'nodes'",
",",
"$",
"apps",
")",
";",
"}"
] | @param GetAllAppsRequest $request
@param Pbjx $pbjx
@return GetAllAppsResponse | [
"@param",
"GetAllAppsRequest",
"$request",
"@param",
"Pbjx",
"$pbjx"
] | train | https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/GetAllAppsRequestHandler.php#L35-L46 |
gdbots/iam-php | src/GetAllAppsRequestHandler.php | GetAllAppsRequestHandler.createGetAllAppsResponse | protected function createGetAllAppsResponse(GetAllAppsRequest $request, Pbjx $pbjx): GetAllAppsResponse
{
/** @var GetAllAppsResponse $response */
$response = $this->createResponseFromRequest($request, $pbjx);
return $response;
} | php | protected function createGetAllAppsResponse(GetAllAppsRequest $request, Pbjx $pbjx): GetAllAppsResponse
{
/** @var GetAllAppsResponse $response */
$response = $this->createResponseFromRequest($request, $pbjx);
return $response;
} | [
"protected",
"function",
"createGetAllAppsResponse",
"(",
"GetAllAppsRequest",
"$",
"request",
",",
"Pbjx",
"$",
"pbjx",
")",
":",
"GetAllAppsResponse",
"{",
"/** @var GetAllAppsResponse $response */",
"$",
"response",
"=",
"$",
"this",
"->",
"createResponseFromRequest",
"(",
"$",
"request",
",",
"$",
"pbjx",
")",
";",
"return",
"$",
"response",
";",
"}"
] | @param GetAllAppsRequest $request
@param Pbjx $pbjx
@return GetAllAppsResponse | [
"@param",
"GetAllAppsRequest",
"$request",
"@param",
"Pbjx",
"$pbjx"
] | train | https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/GetAllAppsRequestHandler.php#L54-L59 |
ahmetertem/query_builder | src/qb.php | qb.set | public function set($field, $value, $type = 0)
{
$this->_write_fields[] = $field;
$this->_write_values[] = $value;
$this->_write_field_types[] = $type;
return $this;
} | php | public function set($field, $value, $type = 0)
{
$this->_write_fields[] = $field;
$this->_write_values[] = $value;
$this->_write_field_types[] = $type;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"type",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"_write_fields",
"[",
"]",
"=",
"$",
"field",
";",
"$",
"this",
"->",
"_write_values",
"[",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"_write_field_types",
"[",
"]",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}"
] | $type :
- 0 = string
- 1 = integer
- 2 = raw. | [
"$type",
":",
"-",
"0",
"=",
"string",
"-",
"1",
"=",
"integer",
"-",
"2",
"=",
"raw",
"."
] | train | https://github.com/ahmetertem/query_builder/blob/aefd8c9ce1d872f7de82f51d3d9507d492a89c3b/src/qb.php#L77-L84 |
surebert/surebert-framework | src/sb/RSS/Feed.php | Feed.display | public function display()
{
//add feed properties
$this->channelPropertiesToDOM();
//add items
foreach($this->items as $item){
$this->appendItem($item);
}
return $this->saveXML();
} | php | public function display()
{
//add feed properties
$this->channelPropertiesToDOM();
//add items
foreach($this->items as $item){
$this->appendItem($item);
}
return $this->saveXML();
} | [
"public",
"function",
"display",
"(",
")",
"{",
"//add feed properties",
"$",
"this",
"->",
"channelPropertiesToDOM",
"(",
")",
";",
"//add items",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"appendItem",
"(",
"$",
"item",
")",
";",
"}",
"return",
"$",
"this",
"->",
"saveXML",
"(",
")",
";",
"}"
] | Converts the \sb\RSSFeed instance into XML for display
<code>
echo $myFeed->display();
</code>
@return string | [
"Converts",
"the",
"\\",
"sb",
"\\",
"RSSFeed",
"instance",
"into",
"XML",
"for",
"display",
"<code",
">",
"echo",
"$myFeed",
"-",
">",
"display",
"()",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/RSS/Feed.php#L260-L273 |
surebert/surebert-framework | src/sb/RSS/Feed.php | Feed.createNode | private function createNode($nodeName, $nodeValue, $cdata = false)
{
$node = $this->createElement($nodeName);
if($cdata){
$text = $this->createCDATASection($nodeValue);
} else {
$text = $this->createTextNode($nodeValue);
}
$node->appendChild($text);
return $node;
} | php | private function createNode($nodeName, $nodeValue, $cdata = false)
{
$node = $this->createElement($nodeName);
if($cdata){
$text = $this->createCDATASection($nodeValue);
} else {
$text = $this->createTextNode($nodeValue);
}
$node->appendChild($text);
return $node;
} | [
"private",
"function",
"createNode",
"(",
"$",
"nodeName",
",",
"$",
"nodeValue",
",",
"$",
"cdata",
"=",
"false",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"nodeName",
")",
";",
"if",
"(",
"$",
"cdata",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"createCDATASection",
"(",
"$",
"nodeValue",
")",
";",
"}",
"else",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"createTextNode",
"(",
"$",
"nodeValue",
")",
";",
"}",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"text",
")",
";",
"return",
"$",
"node",
";",
"}"
] | Creates and returns a new node with textNode, ready for appending
@param string $nodeName
@param string $nodeValue
@return object DOM node | [
"Creates",
"and",
"returns",
"a",
"new",
"node",
"with",
"textNode",
"ready",
"for",
"appending"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/RSS/Feed.php#L282-L294 |
surebert/surebert-framework | src/sb/RSS/Feed.php | Feed.appendItem | private function appendItem(\sb\RSS\Item $item)
{
$new_item = $this->createElement("item");
foreach(get_object_vars($item) as $key=>$val){
if($item->{$key} instanceof \sb\RSS\ItemEnclosure){
$enclosure = $this->createElement('enclosure');
foreach($item->{$key} as $n=>$v){
$enclosure->setAttribute($n, $v);
}
$new_item->appendChild($enclosure);
}
if($key == 'categories'){
foreach($item->{$key} as $category){
$new_item->appendChild($this->createNode('category', $category));
}
}
if(is_string($val) && !empty($val)){
$new_item->appendChild($this->createNode($key, $val, $key == 'description'));
}
}
if(empty($item->guid)){
$new_item->appendChild($this->createNode('guid', $item->link));
}
$this->channel->appendChild($new_item);
} | php | private function appendItem(\sb\RSS\Item $item)
{
$new_item = $this->createElement("item");
foreach(get_object_vars($item) as $key=>$val){
if($item->{$key} instanceof \sb\RSS\ItemEnclosure){
$enclosure = $this->createElement('enclosure');
foreach($item->{$key} as $n=>$v){
$enclosure->setAttribute($n, $v);
}
$new_item->appendChild($enclosure);
}
if($key == 'categories'){
foreach($item->{$key} as $category){
$new_item->appendChild($this->createNode('category', $category));
}
}
if(is_string($val) && !empty($val)){
$new_item->appendChild($this->createNode($key, $val, $key == 'description'));
}
}
if(empty($item->guid)){
$new_item->appendChild($this->createNode('guid', $item->link));
}
$this->channel->appendChild($new_item);
} | [
"private",
"function",
"appendItem",
"(",
"\\",
"sb",
"\\",
"RSS",
"\\",
"Item",
"$",
"item",
")",
"{",
"$",
"new_item",
"=",
"$",
"this",
"->",
"createElement",
"(",
"\"item\"",
")",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"item",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"{",
"$",
"key",
"}",
"instanceof",
"\\",
"sb",
"\\",
"RSS",
"\\",
"ItemEnclosure",
")",
"{",
"$",
"enclosure",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'enclosure'",
")",
";",
"foreach",
"(",
"$",
"item",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"n",
"=>",
"$",
"v",
")",
"{",
"$",
"enclosure",
"->",
"setAttribute",
"(",
"$",
"n",
",",
"$",
"v",
")",
";",
"}",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"enclosure",
")",
";",
"}",
"if",
"(",
"$",
"key",
"==",
"'categories'",
")",
"{",
"foreach",
"(",
"$",
"item",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"category",
")",
"{",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'category'",
",",
"$",
"category",
")",
")",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"val",
")",
"&&",
"!",
"empty",
"(",
"$",
"val",
")",
")",
"{",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"key",
",",
"$",
"val",
",",
"$",
"key",
"==",
"'description'",
")",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"item",
"->",
"guid",
")",
")",
"{",
"$",
"new_item",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'guid'",
",",
"$",
"item",
"->",
"link",
")",
")",
";",
"}",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"new_item",
")",
";",
"}"
] | Takes an \sb\RSS\Item and converts it into a DOMM node followed by inserting it into the feed DOM
@param \sb\RSS\Item $item | [
"Takes",
"an",
"\\",
"sb",
"\\",
"RSS",
"\\",
"Item",
"and",
"converts",
"it",
"into",
"a",
"DOMM",
"node",
"followed",
"by",
"inserting",
"it",
"into",
"the",
"feed",
"DOM"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/RSS/Feed.php#L301-L334 |
surebert/surebert-framework | src/sb/RSS/Feed.php | Feed.channelPropertiesToDOM | private function channelPropertiesToDOM()
{
foreach(get_object_vars($this) as $key=>$val){
//parse string based key value pairs
if (is_string($val) && !empty($val)){
$this->channel->appendChild($this->createNode($key, $val, $key == 'description'));
//parse image
} elseif ($this->{$key} instanceof \sb\RSS\Image){
$image = $this->createElement('image');
foreach($this->{$key} as $n=>$v){
$image->appendChild($this->createNode($n, $v));
}
$image->appendChild($this->createNode('link', $this->link));
$this->channel->appendChild($image);
//parse cloud
} elseif ($this->{$key} instanceof \sb\RSS_Cloud){
$cloud = $this->createElement('cloud');
foreach($this->{$key} as $n=>$v){
$cloud->setAttribute($n, $v);
}
$this->channel->appendChild($cloud);
} elseif($key == 'categories'){
foreach($this->{$key} as $category){
$this->channel->appendChild($this->createNode('category', $category));
}
//parse skipHours and skipDays
} elseif($key == 'skipHours' || $key == 'skipDays'){
$node = $this->createElement($key);
$nodeName = ($key =='skipHours') ? 'hour' : 'day';
foreach($this->{$key} as $value){
//force caps on day name as it is required to validate
$node->appendChild($this->createNode($nodeName, ucwords($value)));
}
$this->channel->appendChild($node);
}
}
} | php | private function channelPropertiesToDOM()
{
foreach(get_object_vars($this) as $key=>$val){
//parse string based key value pairs
if (is_string($val) && !empty($val)){
$this->channel->appendChild($this->createNode($key, $val, $key == 'description'));
//parse image
} elseif ($this->{$key} instanceof \sb\RSS\Image){
$image = $this->createElement('image');
foreach($this->{$key} as $n=>$v){
$image->appendChild($this->createNode($n, $v));
}
$image->appendChild($this->createNode('link', $this->link));
$this->channel->appendChild($image);
//parse cloud
} elseif ($this->{$key} instanceof \sb\RSS_Cloud){
$cloud = $this->createElement('cloud');
foreach($this->{$key} as $n=>$v){
$cloud->setAttribute($n, $v);
}
$this->channel->appendChild($cloud);
} elseif($key == 'categories'){
foreach($this->{$key} as $category){
$this->channel->appendChild($this->createNode('category', $category));
}
//parse skipHours and skipDays
} elseif($key == 'skipHours' || $key == 'skipDays'){
$node = $this->createElement($key);
$nodeName = ($key =='skipHours') ? 'hour' : 'day';
foreach($this->{$key} as $value){
//force caps on day name as it is required to validate
$node->appendChild($this->createNode($nodeName, ucwords($value)));
}
$this->channel->appendChild($node);
}
}
} | [
"private",
"function",
"channelPropertiesToDOM",
"(",
")",
"{",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"//parse string based key value pairs",
"if",
"(",
"is_string",
"(",
"$",
"val",
")",
"&&",
"!",
"empty",
"(",
"$",
"val",
")",
")",
"{",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"key",
",",
"$",
"val",
",",
"$",
"key",
"==",
"'description'",
")",
")",
";",
"//parse image",
"}",
"elseif",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"instanceof",
"\\",
"sb",
"\\",
"RSS",
"\\",
"Image",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'image'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"n",
"=>",
"$",
"v",
")",
"{",
"$",
"image",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"n",
",",
"$",
"v",
")",
")",
";",
"}",
"$",
"image",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'link'",
",",
"$",
"this",
"->",
"link",
")",
")",
";",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"image",
")",
";",
"//parse cloud",
"}",
"elseif",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"instanceof",
"\\",
"sb",
"\\",
"RSS_Cloud",
")",
"{",
"$",
"cloud",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'cloud'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"n",
"=>",
"$",
"v",
")",
"{",
"$",
"cloud",
"->",
"setAttribute",
"(",
"$",
"n",
",",
"$",
"v",
")",
";",
"}",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"cloud",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'categories'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"category",
")",
"{",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"'category'",
",",
"$",
"category",
")",
")",
";",
"}",
"//parse skipHours and skipDays",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'skipHours'",
"||",
"$",
"key",
"==",
"'skipDays'",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"key",
")",
";",
"$",
"nodeName",
"=",
"(",
"$",
"key",
"==",
"'skipHours'",
")",
"?",
"'hour'",
":",
"'day'",
";",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"value",
")",
"{",
"//force caps on day name as it is required to validate",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createNode",
"(",
"$",
"nodeName",
",",
"ucwords",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"channel",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"}",
"}"
] | Converts all the feed object properties into RSS DOM nodes and adds them to the channel node | [
"Converts",
"all",
"the",
"feed",
"object",
"properties",
"into",
"RSS",
"DOM",
"nodes",
"and",
"adds",
"them",
"to",
"the",
"channel",
"node"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/RSS/Feed.php#L340-L393 |
rikby/crypter | src/Crypter.php | Crypter.encrypt | public function encrypt($text, $key = null)
{
if (null === $key) {
$key = $this->getEncryptKey();
}
$ivSize = $this->getMsCryptIvSize();
$iv = mcrypt_create_iv($ivSize, MCRYPT_DEV_RANDOM);
$cipherText = mcrypt_encrypt(
$this->getMcryptCipher(),
$key,
$text,
$this->getMcryptMode(),
$iv
);
$cipherText = $iv.$cipherText;
return base64_encode($cipherText);
} | php | public function encrypt($text, $key = null)
{
if (null === $key) {
$key = $this->getEncryptKey();
}
$ivSize = $this->getMsCryptIvSize();
$iv = mcrypt_create_iv($ivSize, MCRYPT_DEV_RANDOM);
$cipherText = mcrypt_encrypt(
$this->getMcryptCipher(),
$key,
$text,
$this->getMcryptMode(),
$iv
);
$cipherText = $iv.$cipherText;
return base64_encode($cipherText);
} | [
"public",
"function",
"encrypt",
"(",
"$",
"text",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getEncryptKey",
"(",
")",
";",
"}",
"$",
"ivSize",
"=",
"$",
"this",
"->",
"getMsCryptIvSize",
"(",
")",
";",
"$",
"iv",
"=",
"mcrypt_create_iv",
"(",
"$",
"ivSize",
",",
"MCRYPT_DEV_RANDOM",
")",
";",
"$",
"cipherText",
"=",
"mcrypt_encrypt",
"(",
"$",
"this",
"->",
"getMcryptCipher",
"(",
")",
",",
"$",
"key",
",",
"$",
"text",
",",
"$",
"this",
"->",
"getMcryptMode",
"(",
")",
",",
"$",
"iv",
")",
";",
"$",
"cipherText",
"=",
"$",
"iv",
".",
"$",
"cipherText",
";",
"return",
"base64_encode",
"(",
"$",
"cipherText",
")",
";",
"}"
] | Encrypt password
@param string $text Text to encrypt
@param null|string $key Encrypt key
@return string
@link http://php.net/manual/ru/function.mcrypt-encrypt.php#refsect1-function.mcrypt-encrypt-examples | [
"Encrypt",
"password"
] | train | https://github.com/rikby/crypter/blob/a34f05f37189a181633c8c848906c80c85a7894b/src/Crypter.php#L31-L51 |
rikby/crypter | src/Crypter.php | Crypter.decrypt | public function decrypt($string, $key = null)
{
if (null === $key) {
$key = $this->getEncryptKey();
}
$cipherText = base64_decode($string);
$ivSize = $this->getMsCryptIvSize();
$ivDec = substr($cipherText, 0, $ivSize);
$cipherText = substr($cipherText, $ivSize);
return mcrypt_decrypt(
$this->getMcryptCipher(),
$key,
$cipherText,
$this->getMcryptMode(),
$ivDec
);
} | php | public function decrypt($string, $key = null)
{
if (null === $key) {
$key = $this->getEncryptKey();
}
$cipherText = base64_decode($string);
$ivSize = $this->getMsCryptIvSize();
$ivDec = substr($cipherText, 0, $ivSize);
$cipherText = substr($cipherText, $ivSize);
return mcrypt_decrypt(
$this->getMcryptCipher(),
$key,
$cipherText,
$this->getMcryptMode(),
$ivDec
);
} | [
"public",
"function",
"decrypt",
"(",
"$",
"string",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getEncryptKey",
"(",
")",
";",
"}",
"$",
"cipherText",
"=",
"base64_decode",
"(",
"$",
"string",
")",
";",
"$",
"ivSize",
"=",
"$",
"this",
"->",
"getMsCryptIvSize",
"(",
")",
";",
"$",
"ivDec",
"=",
"substr",
"(",
"$",
"cipherText",
",",
"0",
",",
"$",
"ivSize",
")",
";",
"$",
"cipherText",
"=",
"substr",
"(",
"$",
"cipherText",
",",
"$",
"ivSize",
")",
";",
"return",
"mcrypt_decrypt",
"(",
"$",
"this",
"->",
"getMcryptCipher",
"(",
")",
",",
"$",
"key",
",",
"$",
"cipherText",
",",
"$",
"this",
"->",
"getMcryptMode",
"(",
")",
",",
"$",
"ivDec",
")",
";",
"}"
] | Decrypt string
@param string $string String to decrypt
@param null|string $key Encrypt key
@return string | [
"Decrypt",
"string"
] | train | https://github.com/rikby/crypter/blob/a34f05f37189a181633c8c848906c80c85a7894b/src/Crypter.php#L60-L80 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/tarball.php | ezcBaseMetaDataTarballReader.isComponentInstalled | public function isComponentInstalled( $componentName )
{
$root = $this->xml->deps->packages->package;
foreach ( $root as $package )
{
if ( (string) $package['name'] == $componentName )
{
return true;
}
}
return false;
} | php | public function isComponentInstalled( $componentName )
{
$root = $this->xml->deps->packages->package;
foreach ( $root as $package )
{
if ( (string) $package['name'] == $componentName )
{
return true;
}
}
return false;
} | [
"public",
"function",
"isComponentInstalled",
"(",
"$",
"componentName",
")",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"xml",
"->",
"deps",
"->",
"packages",
"->",
"package",
";",
"foreach",
"(",
"$",
"root",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"(",
"string",
")",
"$",
"package",
"[",
"'name'",
"]",
"==",
"$",
"componentName",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns whether $componentName is installed
Returns true for every component that exists (because all of them are
then available).
@return bool | [
"Returns",
"whether",
"$componentName",
"is",
"installed"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/tarball.php#L66-L78 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.