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
|
---|---|---|---|---|---|---|---|---|---|---|
maestroprog/saw-php | src/Connector/WebControllerConnector.php | WebControllerConnector.connect | public function connect()
{
try {
if (!$this->controllerStarter->isExistsPidFile()) {
throw new ConnectionException('Pid file is not exists.');
}
$this->client->connect($this->connectAddress);
} catch (ConnectionException $e) {
$this->controllerStarter->start();
}
// $this->client->block();
} | php | public function connect()
{
try {
if (!$this->controllerStarter->isExistsPidFile()) {
throw new ConnectionException('Pid file is not exists.');
}
$this->client->connect($this->connectAddress);
} catch (ConnectionException $e) {
$this->controllerStarter->start();
}
// $this->client->block();
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"controllerStarter",
"->",
"isExistsPidFile",
"(",
")",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"'Pid file is not exists.'",
")",
";",
"}",
"$",
"this",
"->",
"client",
"->",
"connect",
"(",
"$",
"this",
"->",
"connectAddress",
")",
";",
"}",
"catch",
"(",
"ConnectionException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"controllerStarter",
"->",
"start",
"(",
")",
";",
"}",
"// $this->client->block();",
"}"
] | Выполняет подключение к контроллеру.
Если контроллер не работает, выполняется запуск контроллера.
@throws \RuntimeException Если не удалось запустить контроллер | [
"Выполняет",
"подключение",
"к",
"контроллеру",
".",
"Если",
"контроллер",
"не",
"работает",
"выполняется",
"запуск",
"контроллера",
"."
] | train | https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Connector/WebControllerConnector.php#L45-L56 |
simbiosis-group/yii2-helper | actions/AjaxDeleteAction.php | AjaxDeleteAction.run | public function run()
{
$model = $this->model;
if ($model->delete()) {
Yii::$app->getSession()->setFlash('success', $this->successMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'success' => true,
];
}
Yii::$app->getSession()->setFlash('error', $this->errorMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'success' => false,
'error' => print_r($model->getErrors()),
];
} | php | public function run()
{
$model = $this->model;
if ($model->delete()) {
Yii::$app->getSession()->setFlash('success', $this->successMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'success' => true,
];
}
Yii::$app->getSession()->setFlash('error', $this->errorMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'success' => false,
'error' => print_r($model->getErrors()),
];
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"if",
"(",
"$",
"model",
"->",
"delete",
"(",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'success'",
",",
"$",
"this",
"->",
"successMsg",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"[",
"'success'",
"=>",
"true",
",",
"]",
";",
"}",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'error'",
",",
"$",
"this",
"->",
"errorMsg",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"[",
"'success'",
"=>",
"false",
",",
"'error'",
"=>",
"print_r",
"(",
"$",
"model",
"->",
"getErrors",
"(",
")",
")",
",",
"]",
";",
"}"
] | Runs the action
@return string Return the result | [
"Runs",
"the",
"action"
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/actions/AjaxDeleteAction.php#L51-L72 |
dlundgren/php-css-splitter | src/Splitter.php | Splitter.countSelectors | public function countSelectors($css = null)
{
$count = 0;
if ($css !== null && $this->css !== $css) {
$this->css = $css;
$this->parsedCss = $this->splitIntoBlocks($this->css);
}
foreach ($this->parsedCss as $rules) {
$count += $rules['count'];
}
return $count;
} | php | public function countSelectors($css = null)
{
$count = 0;
if ($css !== null && $this->css !== $css) {
$this->css = $css;
$this->parsedCss = $this->splitIntoBlocks($this->css);
}
foreach ($this->parsedCss as $rules) {
$count += $rules['count'];
}
return $count;
} | [
"public",
"function",
"countSelectors",
"(",
"$",
"css",
"=",
"null",
")",
"{",
"$",
"count",
"=",
"0",
";",
"if",
"(",
"$",
"css",
"!==",
"null",
"&&",
"$",
"this",
"->",
"css",
"!==",
"$",
"css",
")",
"{",
"$",
"this",
"->",
"css",
"=",
"$",
"css",
";",
"$",
"this",
"->",
"parsedCss",
"=",
"$",
"this",
"->",
"splitIntoBlocks",
"(",
"$",
"this",
"->",
"css",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"parsedCss",
"as",
"$",
"rules",
")",
"{",
"$",
"count",
"+=",
"$",
"rules",
"[",
"'count'",
"]",
";",
"}",
"return",
"$",
"count",
";",
"}"
] | Counts the selectors in the given css
@param string $css
@return int The count of selectors in the CSS | [
"Counts",
"the",
"selectors",
"in",
"the",
"given",
"css"
] | train | https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L57-L69 |
dlundgren/php-css-splitter | src/Splitter.php | Splitter.split | public function split($css = null, $part = 1, $maxSelectors = self::MAX_SELECTORS_DEFAULT)
{
if (empty($css) && empty($this->css)) {
return null;
}
if (!empty($css) && $this->css !== $css) {
$this->css = $css;
}
$charset = $this->extractCharset($this->css);
isset($charset) && $this->css = str_replace($charset, '', $this->css);
if (empty($this->css)) {
return null;
}
$this->parsedCss = $this->splitIntoBlocks($this->css);
if (empty($this->parsedCss)) {
return null;
}
$output = $charset ? : '';
$count = 0;
$partCount = 1;
foreach ($this->parsedCss as $block) {
$appliedMedia = false;
foreach ($block['rules'] as $rule) {
$tmpCount = $rule['count'];
// we have a new part so let's reset and increase
if (($count + $tmpCount) > $maxSelectors) {
$partCount++;
$count = 0;
}
$count += $tmpCount;
if ($partCount < $part) {
continue;
}
if ($partCount > $part) {
break;
}
if (!$appliedMedia && isset($block['at-rule'])) {
$output .= $block['at-rule'] . ' {';
$appliedMedia = true;
}
$output .= $rule['rule'];
}
$appliedMedia && $output .= '}';
}
return $output;
} | php | public function split($css = null, $part = 1, $maxSelectors = self::MAX_SELECTORS_DEFAULT)
{
if (empty($css) && empty($this->css)) {
return null;
}
if (!empty($css) && $this->css !== $css) {
$this->css = $css;
}
$charset = $this->extractCharset($this->css);
isset($charset) && $this->css = str_replace($charset, '', $this->css);
if (empty($this->css)) {
return null;
}
$this->parsedCss = $this->splitIntoBlocks($this->css);
if (empty($this->parsedCss)) {
return null;
}
$output = $charset ? : '';
$count = 0;
$partCount = 1;
foreach ($this->parsedCss as $block) {
$appliedMedia = false;
foreach ($block['rules'] as $rule) {
$tmpCount = $rule['count'];
// we have a new part so let's reset and increase
if (($count + $tmpCount) > $maxSelectors) {
$partCount++;
$count = 0;
}
$count += $tmpCount;
if ($partCount < $part) {
continue;
}
if ($partCount > $part) {
break;
}
if (!$appliedMedia && isset($block['at-rule'])) {
$output .= $block['at-rule'] . ' {';
$appliedMedia = true;
}
$output .= $rule['rule'];
}
$appliedMedia && $output .= '}';
}
return $output;
} | [
"public",
"function",
"split",
"(",
"$",
"css",
"=",
"null",
",",
"$",
"part",
"=",
"1",
",",
"$",
"maxSelectors",
"=",
"self",
"::",
"MAX_SELECTORS_DEFAULT",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"css",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"css",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"css",
")",
"&&",
"$",
"this",
"->",
"css",
"!==",
"$",
"css",
")",
"{",
"$",
"this",
"->",
"css",
"=",
"$",
"css",
";",
"}",
"$",
"charset",
"=",
"$",
"this",
"->",
"extractCharset",
"(",
"$",
"this",
"->",
"css",
")",
";",
"isset",
"(",
"$",
"charset",
")",
"&&",
"$",
"this",
"->",
"css",
"=",
"str_replace",
"(",
"$",
"charset",
",",
"''",
",",
"$",
"this",
"->",
"css",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"css",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"parsedCss",
"=",
"$",
"this",
"->",
"splitIntoBlocks",
"(",
"$",
"this",
"->",
"css",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"parsedCss",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"output",
"=",
"$",
"charset",
"?",
":",
"''",
";",
"$",
"count",
"=",
"0",
";",
"$",
"partCount",
"=",
"1",
";",
"foreach",
"(",
"$",
"this",
"->",
"parsedCss",
"as",
"$",
"block",
")",
"{",
"$",
"appliedMedia",
"=",
"false",
";",
"foreach",
"(",
"$",
"block",
"[",
"'rules'",
"]",
"as",
"$",
"rule",
")",
"{",
"$",
"tmpCount",
"=",
"$",
"rule",
"[",
"'count'",
"]",
";",
"// we have a new part so let's reset and increase",
"if",
"(",
"(",
"$",
"count",
"+",
"$",
"tmpCount",
")",
">",
"$",
"maxSelectors",
")",
"{",
"$",
"partCount",
"++",
";",
"$",
"count",
"=",
"0",
";",
"}",
"$",
"count",
"+=",
"$",
"tmpCount",
";",
"if",
"(",
"$",
"partCount",
"<",
"$",
"part",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"partCount",
">",
"$",
"part",
")",
"{",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"appliedMedia",
"&&",
"isset",
"(",
"$",
"block",
"[",
"'at-rule'",
"]",
")",
")",
"{",
"$",
"output",
".=",
"$",
"block",
"[",
"'at-rule'",
"]",
".",
"' {'",
";",
"$",
"appliedMedia",
"=",
"true",
";",
"}",
"$",
"output",
".=",
"$",
"rule",
"[",
"'rule'",
"]",
";",
"}",
"$",
"appliedMedia",
"&&",
"$",
"output",
".=",
"'}'",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Returns the requested part of the split css
@param string $css
@param int $part
@param int $maxSelectors
@return null|string | [
"Returns",
"the",
"requested",
"part",
"of",
"the",
"split",
"css"
] | train | https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L79-L132 |
dlundgren/php-css-splitter | src/Splitter.php | Splitter.summarizeBlock | private function summarizeBlock($block)
{
$block = array(
'rules' => is_array($block) ? $block : $this->splitIntoRules(trim($block)),
'count' => 0
);
foreach ($block['rules'] as $key => $rule) {
$block['rules'][$key] = array(
'rule' => $rule,
'count' => $this->countSelectorsInRule($rule),
);
$block['count'] += $block['rules'][$key]['count'];
}
return $block;
} | php | private function summarizeBlock($block)
{
$block = array(
'rules' => is_array($block) ? $block : $this->splitIntoRules(trim($block)),
'count' => 0
);
foreach ($block['rules'] as $key => $rule) {
$block['rules'][$key] = array(
'rule' => $rule,
'count' => $this->countSelectorsInRule($rule),
);
$block['count'] += $block['rules'][$key]['count'];
}
return $block;
} | [
"private",
"function",
"summarizeBlock",
"(",
"$",
"block",
")",
"{",
"$",
"block",
"=",
"array",
"(",
"'rules'",
"=>",
"is_array",
"(",
"$",
"block",
")",
"?",
"$",
"block",
":",
"$",
"this",
"->",
"splitIntoRules",
"(",
"trim",
"(",
"$",
"block",
")",
")",
",",
"'count'",
"=>",
"0",
")",
";",
"foreach",
"(",
"$",
"block",
"[",
"'rules'",
"]",
"as",
"$",
"key",
"=>",
"$",
"rule",
")",
"{",
"$",
"block",
"[",
"'rules'",
"]",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
"'rule'",
"=>",
"$",
"rule",
",",
"'count'",
"=>",
"$",
"this",
"->",
"countSelectorsInRule",
"(",
"$",
"rule",
")",
",",
")",
";",
"$",
"block",
"[",
"'count'",
"]",
"+=",
"$",
"block",
"[",
"'rules'",
"]",
"[",
"$",
"key",
"]",
"[",
"'count'",
"]",
";",
"}",
"return",
"$",
"block",
";",
"}"
] | Summarizes the block of CSS
This splits the block into it's css rules and then counts the selectors in the rule
@param $block
@return array Array(rules,count) | [
"Summarizes",
"the",
"block",
"of",
"CSS"
] | train | https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L142-L157 |
dlundgren/php-css-splitter | src/Splitter.php | Splitter.splitIntoBlocks | private function splitIntoBlocks($css)
{
if (is_array($css)) {
return $css;
}
$blocks = array();
$css = $this->stripComments($css);
$offset = 0;
// catch all @feature {...} blocks
if (preg_match_all('/(@[^{]+){([^{}]*{[^}]*})*\s*}/ism', $css, $matches, PREG_OFFSET_CAPTURE) > 0) {
foreach ($matches[0] as $key => $match) {
$atRule = trim($matches[1][$key][0]);
list($rules, $start) = $match;
if ($start > $offset) {
// make previous selectors into their own block
$block = trim(substr($css, $offset, $start - $offset));
if (!empty($block)) {
$blocks[] = $this->summarizeBlock($block);
}
}
$offset = $start + strlen($rules);
// currently only @media rules need to be parsed and counted for IE9 selectors
if (strpos($atRule, '@media') === 0) {
$block = $this->summarizeBlock(substr($rules, strpos($rules, '{') + 1, -1));
}
else {
$block = array(
'count' => 1,
'rules' => array(
array(
'rule' => substr($rules, strpos($rules, '{') + 1, -1),
'count' => 1,
)
),
);
}
$block['at-rule'] = $atRule;
$blocks[] = $block;
}
// catch any remaining as it's own block
$block = trim(substr($css, $offset));
if (!empty($block)) {
$blocks[] = $this->summarizeBlock($block);
}
}
else {
$blocks[] = $this->summarizeBlock($css);
}
return $blocks;
} | php | private function splitIntoBlocks($css)
{
if (is_array($css)) {
return $css;
}
$blocks = array();
$css = $this->stripComments($css);
$offset = 0;
// catch all @feature {...} blocks
if (preg_match_all('/(@[^{]+){([^{}]*{[^}]*})*\s*}/ism', $css, $matches, PREG_OFFSET_CAPTURE) > 0) {
foreach ($matches[0] as $key => $match) {
$atRule = trim($matches[1][$key][0]);
list($rules, $start) = $match;
if ($start > $offset) {
// make previous selectors into their own block
$block = trim(substr($css, $offset, $start - $offset));
if (!empty($block)) {
$blocks[] = $this->summarizeBlock($block);
}
}
$offset = $start + strlen($rules);
// currently only @media rules need to be parsed and counted for IE9 selectors
if (strpos($atRule, '@media') === 0) {
$block = $this->summarizeBlock(substr($rules, strpos($rules, '{') + 1, -1));
}
else {
$block = array(
'count' => 1,
'rules' => array(
array(
'rule' => substr($rules, strpos($rules, '{') + 1, -1),
'count' => 1,
)
),
);
}
$block['at-rule'] = $atRule;
$blocks[] = $block;
}
// catch any remaining as it's own block
$block = trim(substr($css, $offset));
if (!empty($block)) {
$blocks[] = $this->summarizeBlock($block);
}
}
else {
$blocks[] = $this->summarizeBlock($css);
}
return $blocks;
} | [
"private",
"function",
"splitIntoBlocks",
"(",
"$",
"css",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"css",
")",
")",
"{",
"return",
"$",
"css",
";",
"}",
"$",
"blocks",
"=",
"array",
"(",
")",
";",
"$",
"css",
"=",
"$",
"this",
"->",
"stripComments",
"(",
"$",
"css",
")",
";",
"$",
"offset",
"=",
"0",
";",
"// catch all @feature {...} blocks",
"if",
"(",
"preg_match_all",
"(",
"'/(@[^{]+){([^{}]*{[^}]*})*\\s*}/ism'",
",",
"$",
"css",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"matches",
"[",
"0",
"]",
"as",
"$",
"key",
"=>",
"$",
"match",
")",
"{",
"$",
"atRule",
"=",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
")",
";",
"list",
"(",
"$",
"rules",
",",
"$",
"start",
")",
"=",
"$",
"match",
";",
"if",
"(",
"$",
"start",
">",
"$",
"offset",
")",
"{",
"// make previous selectors into their own block",
"$",
"block",
"=",
"trim",
"(",
"substr",
"(",
"$",
"css",
",",
"$",
"offset",
",",
"$",
"start",
"-",
"$",
"offset",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"blocks",
"[",
"]",
"=",
"$",
"this",
"->",
"summarizeBlock",
"(",
"$",
"block",
")",
";",
"}",
"}",
"$",
"offset",
"=",
"$",
"start",
"+",
"strlen",
"(",
"$",
"rules",
")",
";",
"// currently only @media rules need to be parsed and counted for IE9 selectors",
"if",
"(",
"strpos",
"(",
"$",
"atRule",
",",
"'@media'",
")",
"===",
"0",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"summarizeBlock",
"(",
"substr",
"(",
"$",
"rules",
",",
"strpos",
"(",
"$",
"rules",
",",
"'{'",
")",
"+",
"1",
",",
"-",
"1",
")",
")",
";",
"}",
"else",
"{",
"$",
"block",
"=",
"array",
"(",
"'count'",
"=>",
"1",
",",
"'rules'",
"=>",
"array",
"(",
"array",
"(",
"'rule'",
"=>",
"substr",
"(",
"$",
"rules",
",",
"strpos",
"(",
"$",
"rules",
",",
"'{'",
")",
"+",
"1",
",",
"-",
"1",
")",
",",
"'count'",
"=>",
"1",
",",
")",
")",
",",
")",
";",
"}",
"$",
"block",
"[",
"'at-rule'",
"]",
"=",
"$",
"atRule",
";",
"$",
"blocks",
"[",
"]",
"=",
"$",
"block",
";",
"}",
"// catch any remaining as it's own block",
"$",
"block",
"=",
"trim",
"(",
"substr",
"(",
"$",
"css",
",",
"$",
"offset",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"blocks",
"[",
"]",
"=",
"$",
"this",
"->",
"summarizeBlock",
"(",
"$",
"block",
")",
";",
"}",
"}",
"else",
"{",
"$",
"blocks",
"[",
"]",
"=",
"$",
"this",
"->",
"summarizeBlock",
"(",
"$",
"css",
")",
";",
"}",
"return",
"$",
"blocks",
";",
"}"
] | Splits the css into blocks maintaining the order of the rules and media queries
This makes it easier to split the CSS into files when a media query might be split
@param $css
@return array | [
"Splits",
"the",
"css",
"into",
"blocks",
"maintaining",
"the",
"order",
"of",
"the",
"rules",
"and",
"media",
"queries"
] | train | https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L167-L224 |
dlundgren/php-css-splitter | src/Splitter.php | Splitter.splitIntoRules | private function splitIntoRules($css)
{
$rules = preg_split('/}/', trim($this->stripComments($css)));
// complete any rules by append } to them
array_walk($rules,
function (&$s) {
!empty($s) && $s = trim("$s}");
});
// clears out any empty rules
return array_filter($rules);
} | php | private function splitIntoRules($css)
{
$rules = preg_split('/}/', trim($this->stripComments($css)));
// complete any rules by append } to them
array_walk($rules,
function (&$s) {
!empty($s) && $s = trim("$s}");
});
// clears out any empty rules
return array_filter($rules);
} | [
"private",
"function",
"splitIntoRules",
"(",
"$",
"css",
")",
"{",
"$",
"rules",
"=",
"preg_split",
"(",
"'/}/'",
",",
"trim",
"(",
"$",
"this",
"->",
"stripComments",
"(",
"$",
"css",
")",
")",
")",
";",
"// complete any rules by append } to them",
"array_walk",
"(",
"$",
"rules",
",",
"function",
"(",
"&",
"$",
"s",
")",
"{",
"!",
"empty",
"(",
"$",
"s",
")",
"&&",
"$",
"s",
"=",
"trim",
"(",
"\"$s}\"",
")",
";",
"}",
")",
";",
"// clears out any empty rules",
"return",
"array_filter",
"(",
"$",
"rules",
")",
";",
"}"
] | Splits the css into it's rules
@param $css
@return array | [
"Splits",
"the",
"css",
"into",
"it",
"s",
"rules"
] | train | https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L232-L244 |
wenbinye/PhalconX | src/Db/Schema/Table.php | Table.describeTable | public static function describeTable(AdapterInterface $db, $table, $schema = null)
{
$columns = $db->describeColumns($table, $schema);
$indexes = $db->describeIndexes($table, $schema);
$references = $db->describeReferences($table, $schema);
$options = $db->tableOptions($table, $schema);
return new self([
'name' => $table,
'schema' => $schema,
'columns' => array_map([Column::class, 'fromColumn'], $columns),
'indexes' => array_map([Index::class, 'fromIndex'], $indexes),
'references' => array_map([Reference::class, 'fromReference'], $references),
'options' => $options,
]);
} | php | public static function describeTable(AdapterInterface $db, $table, $schema = null)
{
$columns = $db->describeColumns($table, $schema);
$indexes = $db->describeIndexes($table, $schema);
$references = $db->describeReferences($table, $schema);
$options = $db->tableOptions($table, $schema);
return new self([
'name' => $table,
'schema' => $schema,
'columns' => array_map([Column::class, 'fromColumn'], $columns),
'indexes' => array_map([Index::class, 'fromIndex'], $indexes),
'references' => array_map([Reference::class, 'fromReference'], $references),
'options' => $options,
]);
} | [
"public",
"static",
"function",
"describeTable",
"(",
"AdapterInterface",
"$",
"db",
",",
"$",
"table",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"columns",
"=",
"$",
"db",
"->",
"describeColumns",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"$",
"indexes",
"=",
"$",
"db",
"->",
"describeIndexes",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"$",
"references",
"=",
"$",
"db",
"->",
"describeReferences",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"$",
"options",
"=",
"$",
"db",
"->",
"tableOptions",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"return",
"new",
"self",
"(",
"[",
"'name'",
"=>",
"$",
"table",
",",
"'schema'",
"=>",
"$",
"schema",
",",
"'columns'",
"=>",
"array_map",
"(",
"[",
"Column",
"::",
"class",
",",
"'fromColumn'",
"]",
",",
"$",
"columns",
")",
",",
"'indexes'",
"=>",
"array_map",
"(",
"[",
"Index",
"::",
"class",
",",
"'fromIndex'",
"]",
",",
"$",
"indexes",
")",
",",
"'references'",
"=>",
"array_map",
"(",
"[",
"Reference",
"::",
"class",
",",
"'fromReference'",
"]",
",",
"$",
"references",
")",
",",
"'options'",
"=>",
"$",
"options",
",",
"]",
")",
";",
"}"
] | Gets table description
@return Table | [
"Gets",
"table",
"description"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Schema/Table.php#L40-L55 |
php-lug/lug | src/Component/Grid/Filter/Type/FilterType.php | FilterType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setRequired(['builder', 'filter', 'grid'])
->setAllowedTypes('builder', DataSourceBuilderInterface::class)
->setAllowedTypes('filter', FilterInterface::class)
->setAllowedTypes('grid', GridInterface::class);
} | php | public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setRequired(['builder', 'filter', 'grid'])
->setAllowedTypes('builder', DataSourceBuilderInterface::class)
->setAllowedTypes('filter', FilterInterface::class)
->setAllowedTypes('grid', GridInterface::class);
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setRequired",
"(",
"[",
"'builder'",
",",
"'filter'",
",",
"'grid'",
"]",
")",
"->",
"setAllowedTypes",
"(",
"'builder'",
",",
"DataSourceBuilderInterface",
"::",
"class",
")",
"->",
"setAllowedTypes",
"(",
"'filter'",
",",
"FilterInterface",
"::",
"class",
")",
"->",
"setAllowedTypes",
"(",
"'grid'",
",",
"GridInterface",
"::",
"class",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Filter/Type/FilterType.php#L40-L47 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php | ezcDbSchemaComparator.compareSchemas | public static final function compareSchemas( ezcDbSchema $fromSchema, ezcDbSchema $toSchema )
{
$diff = new ezcDbSchemaDiff();
$fromSchema = $fromSchema->getSchema();
$toSchema = $toSchema->getSchema();
foreach ( $toSchema as $tableName => $tableDefinition )
{
if ( !isset( $fromSchema[$tableName] ) )
{
$diff->newTables[$tableName] = $tableDefinition;
}
else
{
$tableDifferences = ezcDbSchemaComparator::diffTable( $fromSchema[$tableName], $tableDefinition );
if ( $tableDifferences !== false )
{
$diff->changedTables[$tableName] = $tableDifferences;
}
}
}
/* Check if there are tables removed */
foreach ( $fromSchema as $tableName => $tableDefinition )
{
if ( !isset( $toSchema[$tableName] ) )
{
$diff->removedTables[$tableName] = true;
}
}
return $diff;
} | php | public static final function compareSchemas( ezcDbSchema $fromSchema, ezcDbSchema $toSchema )
{
$diff = new ezcDbSchemaDiff();
$fromSchema = $fromSchema->getSchema();
$toSchema = $toSchema->getSchema();
foreach ( $toSchema as $tableName => $tableDefinition )
{
if ( !isset( $fromSchema[$tableName] ) )
{
$diff->newTables[$tableName] = $tableDefinition;
}
else
{
$tableDifferences = ezcDbSchemaComparator::diffTable( $fromSchema[$tableName], $tableDefinition );
if ( $tableDifferences !== false )
{
$diff->changedTables[$tableName] = $tableDifferences;
}
}
}
/* Check if there are tables removed */
foreach ( $fromSchema as $tableName => $tableDefinition )
{
if ( !isset( $toSchema[$tableName] ) )
{
$diff->removedTables[$tableName] = true;
}
}
return $diff;
} | [
"public",
"static",
"final",
"function",
"compareSchemas",
"(",
"ezcDbSchema",
"$",
"fromSchema",
",",
"ezcDbSchema",
"$",
"toSchema",
")",
"{",
"$",
"diff",
"=",
"new",
"ezcDbSchemaDiff",
"(",
")",
";",
"$",
"fromSchema",
"=",
"$",
"fromSchema",
"->",
"getSchema",
"(",
")",
";",
"$",
"toSchema",
"=",
"$",
"toSchema",
"->",
"getSchema",
"(",
")",
";",
"foreach",
"(",
"$",
"toSchema",
"as",
"$",
"tableName",
"=>",
"$",
"tableDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"fromSchema",
"[",
"$",
"tableName",
"]",
")",
")",
"{",
"$",
"diff",
"->",
"newTables",
"[",
"$",
"tableName",
"]",
"=",
"$",
"tableDefinition",
";",
"}",
"else",
"{",
"$",
"tableDifferences",
"=",
"ezcDbSchemaComparator",
"::",
"diffTable",
"(",
"$",
"fromSchema",
"[",
"$",
"tableName",
"]",
",",
"$",
"tableDefinition",
")",
";",
"if",
"(",
"$",
"tableDifferences",
"!==",
"false",
")",
"{",
"$",
"diff",
"->",
"changedTables",
"[",
"$",
"tableName",
"]",
"=",
"$",
"tableDifferences",
";",
"}",
"}",
"}",
"/* Check if there are tables removed */",
"foreach",
"(",
"$",
"fromSchema",
"as",
"$",
"tableName",
"=>",
"$",
"tableDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"toSchema",
"[",
"$",
"tableName",
"]",
")",
")",
"{",
"$",
"diff",
"->",
"removedTables",
"[",
"$",
"tableName",
"]",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"diff",
";",
"}"
] | Returns a ezcDbSchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
The returned diferences are returned in such a way that they contain the
operations to change the schema stored in $fromSchema to the schema that is
stored in $toSchema.
@param ezcDbSchema $fromSchema
@param ezcDbSchema $toSchema
@return ezcDbSchemaDiff | [
"Returns",
"a",
"ezcDbSchemaDiff",
"object",
"containing",
"the",
"differences",
"between",
"the",
"schemas",
"$fromSchema",
"and",
"$toSchema",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php#L41-L73 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php | ezcDbSchemaComparator.diffTable | private static final function diffTable( ezcDbSchemaTable $table1, ezcDbSchemaTable $table2 )
{
$changes = 0;
$tableDifferences = new ezcDbSchemaTableDiff();
/* See if all the fields in table 1 exist in table 2 */
foreach ( $table2->fields as $fieldName => $fieldDefinition )
{
if ( !isset( $table1->fields[$fieldName] ) )
{
$tableDifferences->addedFields[$fieldName] = $fieldDefinition;
$changes++;
}
}
/* See if there are any removed fields in table 2 */
foreach ( $table1->fields as $fieldName => $fieldDefinition )
{
if ( !isset( $table2->fields[$fieldName] ) )
{
$tableDifferences->removedFields[$fieldName] = true;
$changes++;
}
}
/* See if there are any changed fieldDefinitioninitions */
foreach ( $table1->fields as $fieldName => $fieldDefinition )
{
if ( isset( $table2->fields[$fieldName] ) )
{
$fieldDifferences = ezcDbSchemaComparator::diffField( $fieldDefinition, $table2->fields[$fieldName] );
if ( $fieldDifferences )
{
$tableDifferences->changedFields[$fieldName] = $fieldDifferences;
$changes++;
}
}
}
$table1Indexes = $table1->indexes;
$table2Indexes = $table2->indexes;
/* See if all the indexes in table 1 exist in table 2 */
foreach ( $table2Indexes as $indexName => $indexDefinition )
{
if ( !isset( $table1Indexes[$indexName] ) )
{
$tableDifferences->addedIndexes[$indexName] = $indexDefinition;
$changes++;
}
}
/* See if there are any removed indexes in table 2 */
foreach ( $table1Indexes as $indexName => $indexDefinition )
{
if ( !isset( $table2Indexes[$indexName] ) )
{
$tableDifferences->removedIndexes[$indexName] = true;
$changes++;
}
}
/* See if there are any changed indexDefinitions */
foreach ( $table1Indexes as $indexName => $indexDefinition )
{
if ( isset( $table2Indexes[$indexName] ) )
{
$indexDifferences = ezcDbSchemaComparator::diffIndex( $indexDefinition, $table2Indexes[$indexName] );
if ( $indexDifferences )
{
$tableDifferences->changedIndexes[$indexName] = $indexDifferences;
$changes++;
}
}
}
return $changes ? $tableDifferences : false;
} | php | private static final function diffTable( ezcDbSchemaTable $table1, ezcDbSchemaTable $table2 )
{
$changes = 0;
$tableDifferences = new ezcDbSchemaTableDiff();
/* See if all the fields in table 1 exist in table 2 */
foreach ( $table2->fields as $fieldName => $fieldDefinition )
{
if ( !isset( $table1->fields[$fieldName] ) )
{
$tableDifferences->addedFields[$fieldName] = $fieldDefinition;
$changes++;
}
}
/* See if there are any removed fields in table 2 */
foreach ( $table1->fields as $fieldName => $fieldDefinition )
{
if ( !isset( $table2->fields[$fieldName] ) )
{
$tableDifferences->removedFields[$fieldName] = true;
$changes++;
}
}
/* See if there are any changed fieldDefinitioninitions */
foreach ( $table1->fields as $fieldName => $fieldDefinition )
{
if ( isset( $table2->fields[$fieldName] ) )
{
$fieldDifferences = ezcDbSchemaComparator::diffField( $fieldDefinition, $table2->fields[$fieldName] );
if ( $fieldDifferences )
{
$tableDifferences->changedFields[$fieldName] = $fieldDifferences;
$changes++;
}
}
}
$table1Indexes = $table1->indexes;
$table2Indexes = $table2->indexes;
/* See if all the indexes in table 1 exist in table 2 */
foreach ( $table2Indexes as $indexName => $indexDefinition )
{
if ( !isset( $table1Indexes[$indexName] ) )
{
$tableDifferences->addedIndexes[$indexName] = $indexDefinition;
$changes++;
}
}
/* See if there are any removed indexes in table 2 */
foreach ( $table1Indexes as $indexName => $indexDefinition )
{
if ( !isset( $table2Indexes[$indexName] ) )
{
$tableDifferences->removedIndexes[$indexName] = true;
$changes++;
}
}
/* See if there are any changed indexDefinitions */
foreach ( $table1Indexes as $indexName => $indexDefinition )
{
if ( isset( $table2Indexes[$indexName] ) )
{
$indexDifferences = ezcDbSchemaComparator::diffIndex( $indexDefinition, $table2Indexes[$indexName] );
if ( $indexDifferences )
{
$tableDifferences->changedIndexes[$indexName] = $indexDifferences;
$changes++;
}
}
}
return $changes ? $tableDifferences : false;
} | [
"private",
"static",
"final",
"function",
"diffTable",
"(",
"ezcDbSchemaTable",
"$",
"table1",
",",
"ezcDbSchemaTable",
"$",
"table2",
")",
"{",
"$",
"changes",
"=",
"0",
";",
"$",
"tableDifferences",
"=",
"new",
"ezcDbSchemaTableDiff",
"(",
")",
";",
"/* See if all the fields in table 1 exist in table 2 */",
"foreach",
"(",
"$",
"table2",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"table1",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"$",
"tableDifferences",
"->",
"addedFields",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"fieldDefinition",
";",
"$",
"changes",
"++",
";",
"}",
"}",
"/* See if there are any removed fields in table 2 */",
"foreach",
"(",
"$",
"table1",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"table2",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"$",
"tableDifferences",
"->",
"removedFields",
"[",
"$",
"fieldName",
"]",
"=",
"true",
";",
"$",
"changes",
"++",
";",
"}",
"}",
"/* See if there are any changed fieldDefinitioninitions */",
"foreach",
"(",
"$",
"table1",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldDefinition",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"table2",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"$",
"fieldDifferences",
"=",
"ezcDbSchemaComparator",
"::",
"diffField",
"(",
"$",
"fieldDefinition",
",",
"$",
"table2",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
")",
";",
"if",
"(",
"$",
"fieldDifferences",
")",
"{",
"$",
"tableDifferences",
"->",
"changedFields",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"fieldDifferences",
";",
"$",
"changes",
"++",
";",
"}",
"}",
"}",
"$",
"table1Indexes",
"=",
"$",
"table1",
"->",
"indexes",
";",
"$",
"table2Indexes",
"=",
"$",
"table2",
"->",
"indexes",
";",
"/* See if all the indexes in table 1 exist in table 2 */",
"foreach",
"(",
"$",
"table2Indexes",
"as",
"$",
"indexName",
"=>",
"$",
"indexDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"table1Indexes",
"[",
"$",
"indexName",
"]",
")",
")",
"{",
"$",
"tableDifferences",
"->",
"addedIndexes",
"[",
"$",
"indexName",
"]",
"=",
"$",
"indexDefinition",
";",
"$",
"changes",
"++",
";",
"}",
"}",
"/* See if there are any removed indexes in table 2 */",
"foreach",
"(",
"$",
"table1Indexes",
"as",
"$",
"indexName",
"=>",
"$",
"indexDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"table2Indexes",
"[",
"$",
"indexName",
"]",
")",
")",
"{",
"$",
"tableDifferences",
"->",
"removedIndexes",
"[",
"$",
"indexName",
"]",
"=",
"true",
";",
"$",
"changes",
"++",
";",
"}",
"}",
"/* See if there are any changed indexDefinitions */",
"foreach",
"(",
"$",
"table1Indexes",
"as",
"$",
"indexName",
"=>",
"$",
"indexDefinition",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"table2Indexes",
"[",
"$",
"indexName",
"]",
")",
")",
"{",
"$",
"indexDifferences",
"=",
"ezcDbSchemaComparator",
"::",
"diffIndex",
"(",
"$",
"indexDefinition",
",",
"$",
"table2Indexes",
"[",
"$",
"indexName",
"]",
")",
";",
"if",
"(",
"$",
"indexDifferences",
")",
"{",
"$",
"tableDifferences",
"->",
"changedIndexes",
"[",
"$",
"indexName",
"]",
"=",
"$",
"indexDifferences",
";",
"$",
"changes",
"++",
";",
"}",
"}",
"}",
"return",
"$",
"changes",
"?",
"$",
"tableDifferences",
":",
"false",
";",
"}"
] | Returns the difference between the tables $table1 and $table2.
If there are no differences this method returns the boolean false.
@param ezcDbSchemaTable $table1
@param ezcDbSchemaTable $table2
@return bool|ezcDbSchemaTableDiff | [
"Returns",
"the",
"difference",
"between",
"the",
"tables",
"$table1",
"and",
"$table2",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php#L85-L158 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php | ezcDbSchemaComparator.diffField | private static final function diffField( ezcDbSchemaField $field1, ezcDbSchemaField $field2 )
{
/* Type is always available */
if ( $field1->type != $field2->type )
{
return $field2;
}
$testFields = array( 'type', 'length', 'notNull', 'default', 'autoIncrement' );
foreach ( $testFields as $property )
{
if ( $field1->$property !== $field2->$property )
{
return $field2;
}
}
return false;
} | php | private static final function diffField( ezcDbSchemaField $field1, ezcDbSchemaField $field2 )
{
/* Type is always available */
if ( $field1->type != $field2->type )
{
return $field2;
}
$testFields = array( 'type', 'length', 'notNull', 'default', 'autoIncrement' );
foreach ( $testFields as $property )
{
if ( $field1->$property !== $field2->$property )
{
return $field2;
}
}
return false;
} | [
"private",
"static",
"final",
"function",
"diffField",
"(",
"ezcDbSchemaField",
"$",
"field1",
",",
"ezcDbSchemaField",
"$",
"field2",
")",
"{",
"/* Type is always available */",
"if",
"(",
"$",
"field1",
"->",
"type",
"!=",
"$",
"field2",
"->",
"type",
")",
"{",
"return",
"$",
"field2",
";",
"}",
"$",
"testFields",
"=",
"array",
"(",
"'type'",
",",
"'length'",
",",
"'notNull'",
",",
"'default'",
",",
"'autoIncrement'",
")",
";",
"foreach",
"(",
"$",
"testFields",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"field1",
"->",
"$",
"property",
"!==",
"$",
"field2",
"->",
"$",
"property",
")",
"{",
"return",
"$",
"field2",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns the difference between the fields $field1 and $field2.
If there are differences this method returns $field2, otherwise the
boolean false.
@param ezcDbSchemaField $field1
@param ezcDbSchemaField $field2
@return bool|ezcDbSchemaField | [
"Returns",
"the",
"difference",
"between",
"the",
"fields",
"$field1",
"and",
"$field2",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php#L171-L189 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php | ezcDbSchemaComparator.diffIndex | private static final function diffIndex( ezcDbSchemaIndex $index1, ezcDbSchemaIndex $index2 )
{
$testFields = array( 'primary', 'unique' );
foreach ( $testFields as $property )
{
if ( $index1->$property !== $index2->$property )
{
return $index2;
}
}
// Check for removed index fields in $index2
foreach ( $index1->indexFields as $indexFieldName => $indexFieldDefinition )
{
if ( !isset( $index2->indexFields[$indexFieldName] ) )
{
return $index2;
}
}
// Check for new index fields in $index2
foreach ( $index2->indexFields as $indexFieldName => $indexFieldDefinition )
{
if ( !isset( $index1->indexFields[$indexFieldName] ) )
{
return $index2;
}
}
$testFields = array( 'sorting' );
foreach ( $index1->indexFields as $indexFieldName => $indexFieldDefinition )
{
foreach ( $testFields as $testField )
{
if ( $indexFieldDefinition->$testField != $index2->indexFields[$indexFieldName]->$testField )
{
return $index2;
}
}
}
return false;
} | php | private static final function diffIndex( ezcDbSchemaIndex $index1, ezcDbSchemaIndex $index2 )
{
$testFields = array( 'primary', 'unique' );
foreach ( $testFields as $property )
{
if ( $index1->$property !== $index2->$property )
{
return $index2;
}
}
// Check for removed index fields in $index2
foreach ( $index1->indexFields as $indexFieldName => $indexFieldDefinition )
{
if ( !isset( $index2->indexFields[$indexFieldName] ) )
{
return $index2;
}
}
// Check for new index fields in $index2
foreach ( $index2->indexFields as $indexFieldName => $indexFieldDefinition )
{
if ( !isset( $index1->indexFields[$indexFieldName] ) )
{
return $index2;
}
}
$testFields = array( 'sorting' );
foreach ( $index1->indexFields as $indexFieldName => $indexFieldDefinition )
{
foreach ( $testFields as $testField )
{
if ( $indexFieldDefinition->$testField != $index2->indexFields[$indexFieldName]->$testField )
{
return $index2;
}
}
}
return false;
} | [
"private",
"static",
"final",
"function",
"diffIndex",
"(",
"ezcDbSchemaIndex",
"$",
"index1",
",",
"ezcDbSchemaIndex",
"$",
"index2",
")",
"{",
"$",
"testFields",
"=",
"array",
"(",
"'primary'",
",",
"'unique'",
")",
";",
"foreach",
"(",
"$",
"testFields",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"index1",
"->",
"$",
"property",
"!==",
"$",
"index2",
"->",
"$",
"property",
")",
"{",
"return",
"$",
"index2",
";",
"}",
"}",
"// Check for removed index fields in $index2",
"foreach",
"(",
"$",
"index1",
"->",
"indexFields",
"as",
"$",
"indexFieldName",
"=>",
"$",
"indexFieldDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"index2",
"->",
"indexFields",
"[",
"$",
"indexFieldName",
"]",
")",
")",
"{",
"return",
"$",
"index2",
";",
"}",
"}",
"// Check for new index fields in $index2",
"foreach",
"(",
"$",
"index2",
"->",
"indexFields",
"as",
"$",
"indexFieldName",
"=>",
"$",
"indexFieldDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"index1",
"->",
"indexFields",
"[",
"$",
"indexFieldName",
"]",
")",
")",
"{",
"return",
"$",
"index2",
";",
"}",
"}",
"$",
"testFields",
"=",
"array",
"(",
"'sorting'",
")",
";",
"foreach",
"(",
"$",
"index1",
"->",
"indexFields",
"as",
"$",
"indexFieldName",
"=>",
"$",
"indexFieldDefinition",
")",
"{",
"foreach",
"(",
"$",
"testFields",
"as",
"$",
"testField",
")",
"{",
"if",
"(",
"$",
"indexFieldDefinition",
"->",
"$",
"testField",
"!=",
"$",
"index2",
"->",
"indexFields",
"[",
"$",
"indexFieldName",
"]",
"->",
"$",
"testField",
")",
"{",
"return",
"$",
"index2",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Finds the difference between the indexes $index1 and $index2.
Compares $index1 with $index2 and returns $index2 if there are any
differences or false in case there are no differences.
@param ezcDbSchemaIndex $index1
@param ezcDbSchemaIndex $index2
@return bool|ezcDbSchemaIndex | [
"Finds",
"the",
"difference",
"between",
"the",
"indexes",
"$index1",
"and",
"$index2",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/comparator.php#L201-L242 |
getuisdk/getui-php-sdk | src/PBBool.php | PBBool.parseFromArray | public function parseFromArray()
{
$this->value = $this->reader->next();
$this->value = ($this->value !== 0) ? 1 : 0;
} | php | public function parseFromArray()
{
$this->value = $this->reader->next();
$this->value = ($this->value !== 0) ? 1 : 0;
} | [
"public",
"function",
"parseFromArray",
"(",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"this",
"->",
"reader",
"->",
"next",
"(",
")",
";",
"$",
"this",
"->",
"value",
"=",
"(",
"$",
"this",
"->",
"value",
"!==",
"0",
")",
"?",
"1",
":",
"0",
";",
"}"
] | Parses the message for this type
@param array | [
"Parses",
"the",
"message",
"for",
"this",
"type"
] | train | https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBBool.php#L25-L29 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/index_fields.php | ezcDbSchemaIndexFieldsValidator.validate | static public function validate( ezcDbSchema $schema )
{
$errors = array();
/* For each table we first retrieve all the field names, and then check
* per index whether the fields it references exist */
foreach ( $schema->getSchema() as $tableName => $table )
{
$fields = array_keys( $table->fields );
foreach ( $table->indexes as $indexName => $index )
{
foreach ( $index->indexFields as $indexFieldName => $dummy )
{
if ( !in_array( $indexFieldName, $fields ) )
{
$errors[] = "Index '$tableName:$indexName' references unknown field name '$tableName:$indexFieldName'.";
}
}
}
}
return $errors;
} | php | static public function validate( ezcDbSchema $schema )
{
$errors = array();
/* For each table we first retrieve all the field names, and then check
* per index whether the fields it references exist */
foreach ( $schema->getSchema() as $tableName => $table )
{
$fields = array_keys( $table->fields );
foreach ( $table->indexes as $indexName => $index )
{
foreach ( $index->indexFields as $indexFieldName => $dummy )
{
if ( !in_array( $indexFieldName, $fields ) )
{
$errors[] = "Index '$tableName:$indexName' references unknown field name '$tableName:$indexFieldName'.";
}
}
}
}
return $errors;
} | [
"static",
"public",
"function",
"validate",
"(",
"ezcDbSchema",
"$",
"schema",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"/* For each table we first retrieve all the field names, and then check\n * per index whether the fields it references exist */",
"foreach",
"(",
"$",
"schema",
"->",
"getSchema",
"(",
")",
"as",
"$",
"tableName",
"=>",
"$",
"table",
")",
"{",
"$",
"fields",
"=",
"array_keys",
"(",
"$",
"table",
"->",
"fields",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"indexes",
"as",
"$",
"indexName",
"=>",
"$",
"index",
")",
"{",
"foreach",
"(",
"$",
"index",
"->",
"indexFields",
"as",
"$",
"indexFieldName",
"=>",
"$",
"dummy",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"indexFieldName",
",",
"$",
"fields",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Index '$tableName:$indexName' references unknown field name '$tableName:$indexFieldName'.\"",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] | Validates if all the fields used in all indexes exist.
This method loops over all the fields in the indexes of each table and
checks whether the fields that is used in an index is also defined in
the table definition. It will return an array containing error strings
for each non-supported type that it finds.
@param ezcDbSchema $schema
@return array(string) | [
"Validates",
"if",
"all",
"the",
"fields",
"used",
"in",
"all",
"indexes",
"exist",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/index_fields.php#L31-L54 |
j-d/draggy | src/Draggy/Log.php | Log.prepend | public function prepend($message)
{
$this->log = [$message] + $this->log;
$this->extendedLog = [$message] + $this->extendedLog;
} | php | public function prepend($message)
{
$this->log = [$message] + $this->log;
$this->extendedLog = [$message] + $this->extendedLog;
} | [
"public",
"function",
"prepend",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"log",
"=",
"[",
"$",
"message",
"]",
"+",
"$",
"this",
"->",
"log",
";",
"$",
"this",
"->",
"extendedLog",
"=",
"[",
"$",
"message",
"]",
"+",
"$",
"this",
"->",
"extendedLog",
";",
"}"
] | Prepend a message to the log
@param $message | [
"Prepend",
"a",
"message",
"to",
"the",
"log"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Log.php#L43-L47 |
primipilus/fileinfo | src/MimeType.php | MimeType.getExtensions | public static function getExtensions(string $mime) : array
{
$extensions = [];
foreach (static::$_types as $extension => $mimeType) {
if ($mimeType === $mime) {
$extensions[] = $extension;
}
}
return $extensions;
} | php | public static function getExtensions(string $mime) : array
{
$extensions = [];
foreach (static::$_types as $extension => $mimeType) {
if ($mimeType === $mime) {
$extensions[] = $extension;
}
}
return $extensions;
} | [
"public",
"static",
"function",
"getExtensions",
"(",
"string",
"$",
"mime",
")",
":",
"array",
"{",
"$",
"extensions",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"$",
"_types",
"as",
"$",
"extension",
"=>",
"$",
"mimeType",
")",
"{",
"if",
"(",
"$",
"mimeType",
"===",
"$",
"mime",
")",
"{",
"$",
"extensions",
"[",
"]",
"=",
"$",
"extension",
";",
"}",
"}",
"return",
"$",
"extensions",
";",
"}"
] | Get extensions for one mime
@param string $mime
@return array | [
"Get",
"extensions",
"for",
"one",
"mime"
] | train | https://github.com/primipilus/fileinfo/blob/734fd25b3dfd3b0706f9ef07499663578c0fa56e/src/MimeType.php#L1023-L1034 |
philiplb/Valdi | src/Valdi/Validator/AbstractComparator.php | AbstractComparator.isValid | public function isValid($value, array $parameters) {
$this->validateParameterCount($this->type, $this->amountOfParameters, $parameters);
return in_array($value, ['', null], true) ||
$this->isValidComparison($value, $parameters);
} | php | public function isValid($value, array $parameters) {
$this->validateParameterCount($this->type, $this->amountOfParameters, $parameters);
return in_array($value, ['', null], true) ||
$this->isValidComparison($value, $parameters);
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
",",
"array",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"validateParameterCount",
"(",
"$",
"this",
"->",
"type",
",",
"$",
"this",
"->",
"amountOfParameters",
",",
"$",
"parameters",
")",
";",
"return",
"in_array",
"(",
"$",
"value",
",",
"[",
"''",
",",
"null",
"]",
",",
"true",
")",
"||",
"$",
"this",
"->",
"isValidComparison",
"(",
"$",
"value",
",",
"$",
"parameters",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/AbstractComparator.php#L60-L66 |
php-lug/lug | src/Bundle/RegistryBundle/DependencyInjection/Compiler/RegisterRegistryPass.php | RegisterRegistryPass.process | public function process(ContainerBuilder $container)
{
$registry = $container->getDefinition($this->registry);
foreach ($container->findTaggedServiceIds($this->tag) as $service => $attributes) {
foreach ($attributes as $attribute) {
if (!isset($attribute[$this->attribute])) {
throw new TagAttributeNotFoundException(sprintf(
'The attribute "%s" could not be found for the tag "%s" on the "%s" service.',
$this->attribute,
$this->tag,
$service
));
}
$registry->addMethodCall('offsetSet', [$attribute[$this->attribute], new Reference($service)]);
}
}
} | php | public function process(ContainerBuilder $container)
{
$registry = $container->getDefinition($this->registry);
foreach ($container->findTaggedServiceIds($this->tag) as $service => $attributes) {
foreach ($attributes as $attribute) {
if (!isset($attribute[$this->attribute])) {
throw new TagAttributeNotFoundException(sprintf(
'The attribute "%s" could not be found for the tag "%s" on the "%s" service.',
$this->attribute,
$this->tag,
$service
));
}
$registry->addMethodCall('offsetSet', [$attribute[$this->attribute], new Reference($service)]);
}
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"registry",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"$",
"this",
"->",
"registry",
")",
";",
"foreach",
"(",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"$",
"this",
"->",
"tag",
")",
"as",
"$",
"service",
"=>",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"attribute",
"[",
"$",
"this",
"->",
"attribute",
"]",
")",
")",
"{",
"throw",
"new",
"TagAttributeNotFoundException",
"(",
"sprintf",
"(",
"'The attribute \"%s\" could not be found for the tag \"%s\" on the \"%s\" service.'",
",",
"$",
"this",
"->",
"attribute",
",",
"$",
"this",
"->",
"tag",
",",
"$",
"service",
")",
")",
";",
"}",
"$",
"registry",
"->",
"addMethodCall",
"(",
"'offsetSet'",
",",
"[",
"$",
"attribute",
"[",
"$",
"this",
"->",
"attribute",
"]",
",",
"new",
"Reference",
"(",
"$",
"service",
")",
"]",
")",
";",
"}",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/RegistryBundle/DependencyInjection/Compiler/RegisterRegistryPass.php#L54-L72 |
ronaldborla/chikka | src/Borla/Chikka/Models/Notification.php | Notification.onSetAttribute | protected function onSetAttribute($name, $value) {
// Listen to these attributes
$listen = [
'message_type'=> 'type',
'message_id' => 'id',
'credits_cost'=> 'credits',
'rb_cost' => 'cost',
];
// If set
if (isset($listen[$name])) {
// If not yet set
if ( ! isset($this->{$listen[$name]})) {
// Set corresponding attribute
$this->{$listen[$name]} = $value;
}
}
} | php | protected function onSetAttribute($name, $value) {
// Listen to these attributes
$listen = [
'message_type'=> 'type',
'message_id' => 'id',
'credits_cost'=> 'credits',
'rb_cost' => 'cost',
];
// If set
if (isset($listen[$name])) {
// If not yet set
if ( ! isset($this->{$listen[$name]})) {
// Set corresponding attribute
$this->{$listen[$name]} = $value;
}
}
} | [
"protected",
"function",
"onSetAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"// Listen to these attributes",
"$",
"listen",
"=",
"[",
"'message_type'",
"=>",
"'type'",
",",
"'message_id'",
"=>",
"'id'",
",",
"'credits_cost'",
"=>",
"'credits'",
",",
"'rb_cost'",
"=>",
"'cost'",
",",
"]",
";",
"// If set",
"if",
"(",
"isset",
"(",
"$",
"listen",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// If not yet set",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"{",
"$",
"listen",
"[",
"$",
"name",
"]",
"}",
")",
")",
"{",
"// Set corresponding attribute",
"$",
"this",
"->",
"{",
"$",
"listen",
"[",
"$",
"name",
"]",
"}",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] | When an attribute is set | [
"When",
"an",
"attribute",
"is",
"set"
] | train | https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Notification.php#L56-L72 |
ronaldborla/chikka | src/Borla/Chikka/Models/Notification.php | Notification.setStatusAttribute | protected function setStatusAttribute($value) {
// If null
if ($value === null) {
// Return null
return null;
}
// If numeric
if (is_int($value) || is_numeric($value)) {
// If not valid
if (isset(static::statuses()[$value])) {
// Return int value
return (int) $value;
}
}
// Else
else {
// Find
if (($status = array_search(strtolower($value), static::statuses())) !== false) {
// Return status
return $status;
}
}
// Throw error
throw new InvalidAttribute('Invalid status value: ' . $value);
} | php | protected function setStatusAttribute($value) {
// If null
if ($value === null) {
// Return null
return null;
}
// If numeric
if (is_int($value) || is_numeric($value)) {
// If not valid
if (isset(static::statuses()[$value])) {
// Return int value
return (int) $value;
}
}
// Else
else {
// Find
if (($status = array_search(strtolower($value), static::statuses())) !== false) {
// Return status
return $status;
}
}
// Throw error
throw new InvalidAttribute('Invalid status value: ' . $value);
} | [
"protected",
"function",
"setStatusAttribute",
"(",
"$",
"value",
")",
"{",
"// If null",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"// Return null",
"return",
"null",
";",
"}",
"// If numeric",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
"||",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"// If not valid",
"if",
"(",
"isset",
"(",
"static",
"::",
"statuses",
"(",
")",
"[",
"$",
"value",
"]",
")",
")",
"{",
"// Return int value",
"return",
"(",
"int",
")",
"$",
"value",
";",
"}",
"}",
"// Else",
"else",
"{",
"// Find ",
"if",
"(",
"(",
"$",
"status",
"=",
"array_search",
"(",
"strtolower",
"(",
"$",
"value",
")",
",",
"static",
"::",
"statuses",
"(",
")",
")",
")",
"!==",
"false",
")",
"{",
"// Return status",
"return",
"$",
"status",
";",
"}",
"}",
"// Throw error",
"throw",
"new",
"InvalidAttribute",
"(",
"'Invalid status value: '",
".",
"$",
"value",
")",
";",
"}"
] | Set status | [
"Set",
"status"
] | train | https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Notification.php#L130-L154 |
nabab/bbn | src/bbn/api/virtualmin.php | virtualmin.delete_cache | public function delete_cache($command_name = '', $arguments= false){
$uid = $this->hostname;
if ( !empty($arguments) ){
$uid .= md5(json_encode($arguments));
}
if ( !empty($this->cache_delete($uid, $command_name)) ){
\bbn\x::log([$uid, $command_name], 'cache_delete');
return true;
}
return false;
} | php | public function delete_cache($command_name = '', $arguments= false){
$uid = $this->hostname;
if ( !empty($arguments) ){
$uid .= md5(json_encode($arguments));
}
if ( !empty($this->cache_delete($uid, $command_name)) ){
\bbn\x::log([$uid, $command_name], 'cache_delete');
return true;
}
return false;
} | [
"public",
"function",
"delete_cache",
"(",
"$",
"command_name",
"=",
"''",
",",
"$",
"arguments",
"=",
"false",
")",
"{",
"$",
"uid",
"=",
"$",
"this",
"->",
"hostname",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"arguments",
")",
")",
"{",
"$",
"uid",
".=",
"md5",
"(",
"json_encode",
"(",
"$",
"arguments",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"cache_delete",
"(",
"$",
"uid",
",",
"$",
"command_name",
")",
")",
")",
"{",
"\\",
"bbn",
"\\",
"x",
"::",
"log",
"(",
"[",
"$",
"uid",
",",
"$",
"command_name",
"]",
",",
"'cache_delete'",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | This function allows the cancellation of the cache of the used commands
@param $uid file cache
@param $method name
@return bool | [
"This",
"function",
"allows",
"the",
"cancellation",
"of",
"the",
"cache",
"of",
"the",
"used",
"commands"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/virtualmin.php#L186-L196 |
nabab/bbn | src/bbn/api/virtualmin.php | virtualmin.get_header_url | private function get_header_url(){
return "wget -O - --quiet --http-user=" . $this->user . " --http-passwd=" . escapeshellarg($this->pass) . " --no-check-certificate 'https://" . $this->hostname . ":10000/".(
$this->mode === 'cloudmin' ? 'server-manager' : 'virtual-server'
)."/remote.cgi?json=1&multiline=&program=";
} | php | private function get_header_url(){
return "wget -O - --quiet --http-user=" . $this->user . " --http-passwd=" . escapeshellarg($this->pass) . " --no-check-certificate 'https://" . $this->hostname . ":10000/".(
$this->mode === 'cloudmin' ? 'server-manager' : 'virtual-server'
)."/remote.cgi?json=1&multiline=&program=";
} | [
"private",
"function",
"get_header_url",
"(",
")",
"{",
"return",
"\"wget -O - --quiet --http-user=\"",
".",
"$",
"this",
"->",
"user",
".",
"\" --http-passwd=\"",
".",
"escapeshellarg",
"(",
"$",
"this",
"->",
"pass",
")",
".",
"\" --no-check-certificate 'https://\"",
".",
"$",
"this",
"->",
"hostname",
".",
"\":10000/\"",
".",
"(",
"$",
"this",
"->",
"mode",
"===",
"'cloudmin'",
"?",
"'server-manager'",
":",
"'virtual-server'",
")",
".",
"\"/remote.cgi?json=1&multiline=&program=\"",
";",
"}"
] | This function is used to get the header url part to be executed
@return string The the header url part to be executed | [
"This",
"function",
"is",
"used",
"to",
"get",
"the",
"header",
"url",
"part",
"to",
"be",
"executed"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/virtualmin.php#L260-L264 |
nabab/bbn | src/bbn/api/virtualmin.php | virtualmin.list_commands | public function list_commands($param = []){
//Prepping, processing and validating the create user parameters
$param = $this->process_parameters($param);
//Setting the last action performed
$this->last_action = "list-commands";
//Defining the $url_part and the command to be executed
$url_part = "list-commands";
if (isset($param['short'])){//short parameter is set
$url_part .= "&short";
}
if (isset($param['nameonly'])){//nameonly parameter is set
$url_part .= "&nameonly";
}
//Concatenating the closing single quote
$url_part .="'";
//Concatenating the header url and $url_part to create the full url to be executed
$url_part = $this->get_header_url() . $url_part;
//test
$uid = $this->hostname;
if ( !empty($param) ){
$uid .= md5(json_encode($param));
}
if ( $this->cache_has($uid, 'list_commands') ){
$result_call = $this->cache_get($uid, 'list_commands');
}
else {
$result_call = $this->call_shell_exec($url_part);
$this->cache_set($uid, 'list_commands', $result_call);
}
return $result_call;
} | php | public function list_commands($param = []){
//Prepping, processing and validating the create user parameters
$param = $this->process_parameters($param);
//Setting the last action performed
$this->last_action = "list-commands";
//Defining the $url_part and the command to be executed
$url_part = "list-commands";
if (isset($param['short'])){//short parameter is set
$url_part .= "&short";
}
if (isset($param['nameonly'])){//nameonly parameter is set
$url_part .= "&nameonly";
}
//Concatenating the closing single quote
$url_part .="'";
//Concatenating the header url and $url_part to create the full url to be executed
$url_part = $this->get_header_url() . $url_part;
//test
$uid = $this->hostname;
if ( !empty($param) ){
$uid .= md5(json_encode($param));
}
if ( $this->cache_has($uid, 'list_commands') ){
$result_call = $this->cache_get($uid, 'list_commands');
}
else {
$result_call = $this->call_shell_exec($url_part);
$this->cache_set($uid, 'list_commands', $result_call);
}
return $result_call;
} | [
"public",
"function",
"list_commands",
"(",
"$",
"param",
"=",
"[",
"]",
")",
"{",
"//Prepping, processing and validating the create user parameters",
"$",
"param",
"=",
"$",
"this",
"->",
"process_parameters",
"(",
"$",
"param",
")",
";",
"//Setting the last action performed",
"$",
"this",
"->",
"last_action",
"=",
"\"list-commands\"",
";",
"//Defining the $url_part and the command to be executed",
"$",
"url_part",
"=",
"\"list-commands\"",
";",
"if",
"(",
"isset",
"(",
"$",
"param",
"[",
"'short'",
"]",
")",
")",
"{",
"//short parameter is set",
"$",
"url_part",
".=",
"\"&short\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"param",
"[",
"'nameonly'",
"]",
")",
")",
"{",
"//nameonly parameter is set",
"$",
"url_part",
".=",
"\"&nameonly\"",
";",
"}",
"//Concatenating the closing single quote",
"$",
"url_part",
".=",
"\"'\"",
";",
"//Concatenating the header url and $url_part to create the full url to be executed",
"$",
"url_part",
"=",
"$",
"this",
"->",
"get_header_url",
"(",
")",
".",
"$",
"url_part",
";",
"//test",
"$",
"uid",
"=",
"$",
"this",
"->",
"hostname",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"param",
")",
")",
"{",
"$",
"uid",
".=",
"md5",
"(",
"json_encode",
"(",
"$",
"param",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"cache_has",
"(",
"$",
"uid",
",",
"'list_commands'",
")",
")",
"{",
"$",
"result_call",
"=",
"$",
"this",
"->",
"cache_get",
"(",
"$",
"uid",
",",
"'list_commands'",
")",
";",
"}",
"else",
"{",
"$",
"result_call",
"=",
"$",
"this",
"->",
"call_shell_exec",
"(",
"$",
"url_part",
")",
";",
"$",
"this",
"->",
"cache_set",
"(",
"$",
"uid",
",",
"'list_commands'",
",",
"$",
"result_call",
")",
";",
"}",
"return",
"$",
"result_call",
";",
"}"
] | Gets all the commands directly from the API
@param array $param
@return array | [
"Gets",
"all",
"the",
"commands",
"directly",
"from",
"the",
"API"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/virtualmin.php#L343-L377 |
glynnforrest/blockade | src/Blockade/Resolver/RedirectResolver.php | RedirectResolver.createUrl | protected function createUrl(BlockadeException $exception, Request $request)
{
//decide where to redirect. login_url for unauthenticated or
//bad credentials, deny_url for unauthorized or anything else
if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) {
return $this->login_url.'/to'.$request->getPathInfo();
}
return $this->deny_url;
} | php | protected function createUrl(BlockadeException $exception, Request $request)
{
//decide where to redirect. login_url for unauthenticated or
//bad credentials, deny_url for unauthorized or anything else
if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) {
return $this->login_url.'/to'.$request->getPathInfo();
}
return $this->deny_url;
} | [
"protected",
"function",
"createUrl",
"(",
"BlockadeException",
"$",
"exception",
",",
"Request",
"$",
"request",
")",
"{",
"//decide where to redirect. login_url for unauthenticated or",
"//bad credentials, deny_url for unauthorized or anything else",
"if",
"(",
"$",
"exception",
"instanceof",
"AuthenticationException",
"||",
"$",
"exception",
"instanceof",
"CredentialsException",
")",
"{",
"return",
"$",
"this",
"->",
"login_url",
".",
"'/to'",
".",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"deny_url",
";",
"}"
] | Create the url to redirect to.
@param BlockadeException $exception The exception
@param Request $request The request that caused the exception | [
"Create",
"the",
"url",
"to",
"redirect",
"to",
"."
] | train | https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Resolver/RedirectResolver.php#L41-L50 |
glynnforrest/blockade | src/Blockade/Resolver/RedirectResolver.php | RedirectResolver.createXmlHttpResponse | protected function createXmlHttpResponse(BlockadeException $exception, Request $request)
{
if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) {
return new Response('Authentication required', Response::HTTP_UNAUTHORIZED);
}
return new Response('Access denied', Response::HTTP_FORBIDDEN);
} | php | protected function createXmlHttpResponse(BlockadeException $exception, Request $request)
{
if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) {
return new Response('Authentication required', Response::HTTP_UNAUTHORIZED);
}
return new Response('Access denied', Response::HTTP_FORBIDDEN);
} | [
"protected",
"function",
"createXmlHttpResponse",
"(",
"BlockadeException",
"$",
"exception",
",",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"AuthenticationException",
"||",
"$",
"exception",
"instanceof",
"CredentialsException",
")",
"{",
"return",
"new",
"Response",
"(",
"'Authentication required'",
",",
"Response",
"::",
"HTTP_UNAUTHORIZED",
")",
";",
"}",
"return",
"new",
"Response",
"(",
"'Access denied'",
",",
"Response",
"::",
"HTTP_FORBIDDEN",
")",
";",
"}"
] | Create a response for XmlHttpRequests.
@param BlockadeException $exception The exception
@param Request $request The request that caused the exception | [
"Create",
"a",
"response",
"for",
"XmlHttpRequests",
"."
] | train | https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Resolver/RedirectResolver.php#L58-L65 |
codeburnerframework/container | src/Container.php | Container.call | public function call($function, array $parameters = [])
{
$inspector = new ReflectionFunction($function);
$dependencies = $inspector->getParameters();
$dependencies = $this->process('', $parameters, $dependencies);
return call_user_func_array($function, $dependencies);
} | php | public function call($function, array $parameters = [])
{
$inspector = new ReflectionFunction($function);
$dependencies = $inspector->getParameters();
$dependencies = $this->process('', $parameters, $dependencies);
return call_user_func_array($function, $dependencies);
} | [
"public",
"function",
"call",
"(",
"$",
"function",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"inspector",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"function",
")",
";",
"$",
"dependencies",
"=",
"$",
"inspector",
"->",
"getParameters",
"(",
")",
";",
"$",
"dependencies",
"=",
"$",
"this",
"->",
"process",
"(",
"''",
",",
"$",
"parameters",
",",
"$",
"dependencies",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"function",
",",
"$",
"dependencies",
")",
";",
"}"
] | Call a user function injecting the dependencies.
@param string|Closure $function The function or the user function name.
@param array $parameters The predefined dependencies.
@return mixed | [
"Call",
"a",
"user",
"function",
"injecting",
"the",
"dependencies",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L75-L83 |
codeburnerframework/container | src/Container.php | Container.make | public function make(string $abstract, array $parameters = [])
{
try {
if (! isset($this->resolving[$abstract])) {
$this->resolving[$abstract] = $this->construct($abstract);
}
return $this->resolving[$abstract]($abstract, $parameters);
} catch (ReflectionException $e) {
throw new ContainerException("Fail while attempt to make '$abstract'", 0, $e);
}
} | php | public function make(string $abstract, array $parameters = [])
{
try {
if (! isset($this->resolving[$abstract])) {
$this->resolving[$abstract] = $this->construct($abstract);
}
return $this->resolving[$abstract]($abstract, $parameters);
} catch (ReflectionException $e) {
throw new ContainerException("Fail while attempt to make '$abstract'", 0, $e);
}
} | [
"public",
"function",
"make",
"(",
"string",
"$",
"abstract",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resolving",
"[",
"$",
"abstract",
"]",
")",
")",
"{",
"$",
"this",
"->",
"resolving",
"[",
"$",
"abstract",
"]",
"=",
"$",
"this",
"->",
"construct",
"(",
"$",
"abstract",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolving",
"[",
"$",
"abstract",
"]",
"(",
"$",
"abstract",
",",
"$",
"parameters",
")",
";",
"}",
"catch",
"(",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"ContainerException",
"(",
"\"Fail while attempt to make '$abstract'\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Makes an element or class injecting automatically all the dependencies.
@param string $abstract The class name or container element name to make.
@param array $parameters Specific parameters definition.
@throws ContainerException
@return object|null | [
"Makes",
"an",
"element",
"or",
"class",
"injecting",
"automatically",
"all",
"the",
"dependencies",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L95-L106 |
codeburnerframework/container | src/Container.php | Container.construct | protected function construct(string $abstract) : Closure
{
$inspector = new ReflectionClass($abstract);
if (($constructor = $inspector->getConstructor()) && ($dependencies = $constructor->getParameters())) {
// if, and only if, a class has a constructor with parameters, we try to solve then
// creating a resolving callback that in every call will recalculate all dependencies
// for the given class, and offcourse, using a cached resolving callback if exists.
return function (string $abstract, array $parameters) use ($inspector, $dependencies) {
return $inspector->newInstanceArgs(
$this->process($abstract, $parameters, $dependencies)
);
};
}
return function (string $abstract) {
return new $abstract;
};
} | php | protected function construct(string $abstract) : Closure
{
$inspector = new ReflectionClass($abstract);
if (($constructor = $inspector->getConstructor()) && ($dependencies = $constructor->getParameters())) {
// if, and only if, a class has a constructor with parameters, we try to solve then
// creating a resolving callback that in every call will recalculate all dependencies
// for the given class, and offcourse, using a cached resolving callback if exists.
return function (string $abstract, array $parameters) use ($inspector, $dependencies) {
return $inspector->newInstanceArgs(
$this->process($abstract, $parameters, $dependencies)
);
};
}
return function (string $abstract) {
return new $abstract;
};
} | [
"protected",
"function",
"construct",
"(",
"string",
"$",
"abstract",
")",
":",
"Closure",
"{",
"$",
"inspector",
"=",
"new",
"ReflectionClass",
"(",
"$",
"abstract",
")",
";",
"if",
"(",
"(",
"$",
"constructor",
"=",
"$",
"inspector",
"->",
"getConstructor",
"(",
")",
")",
"&&",
"(",
"$",
"dependencies",
"=",
"$",
"constructor",
"->",
"getParameters",
"(",
")",
")",
")",
"{",
"// if, and only if, a class has a constructor with parameters, we try to solve then",
"// creating a resolving callback that in every call will recalculate all dependencies",
"// for the given class, and offcourse, using a cached resolving callback if exists.",
"return",
"function",
"(",
"string",
"$",
"abstract",
",",
"array",
"$",
"parameters",
")",
"use",
"(",
"$",
"inspector",
",",
"$",
"dependencies",
")",
"{",
"return",
"$",
"inspector",
"->",
"newInstanceArgs",
"(",
"$",
"this",
"->",
"process",
"(",
"$",
"abstract",
",",
"$",
"parameters",
",",
"$",
"dependencies",
")",
")",
";",
"}",
";",
"}",
"return",
"function",
"(",
"string",
"$",
"abstract",
")",
"{",
"return",
"new",
"$",
"abstract",
";",
"}",
";",
"}"
] | Construct a class and all the dependencies using the reflection library of PHP.
@param string $abstract The class name or container element name to make.
@throws ReflectionException
@return Closure | [
"Construct",
"a",
"class",
"and",
"all",
"the",
"dependencies",
"using",
"the",
"reflection",
"library",
"of",
"PHP",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L117-L137 |
codeburnerframework/container | src/Container.php | Container.process | protected function process(string $abstract, array $parameters, array $dependencies) : array
{
foreach ($dependencies as &$dependency) {
if (isset($parameters[$dependency->name])) {
$dependency = $parameters[$dependency->name];
} else $dependency = $this->resolve($abstract, $dependency);
}
return $dependencies;
} | php | protected function process(string $abstract, array $parameters, array $dependencies) : array
{
foreach ($dependencies as &$dependency) {
if (isset($parameters[$dependency->name])) {
$dependency = $parameters[$dependency->name];
} else $dependency = $this->resolve($abstract, $dependency);
}
return $dependencies;
} | [
"protected",
"function",
"process",
"(",
"string",
"$",
"abstract",
",",
"array",
"$",
"parameters",
",",
"array",
"$",
"dependencies",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"dependencies",
"as",
"&",
"$",
"dependency",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"$",
"dependency",
"->",
"name",
"]",
")",
")",
"{",
"$",
"dependency",
"=",
"$",
"parameters",
"[",
"$",
"dependency",
"->",
"name",
"]",
";",
"}",
"else",
"$",
"dependency",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"abstract",
",",
"$",
"dependency",
")",
";",
"}",
"return",
"$",
"dependencies",
";",
"}"
] | Process all dependencies
@param string $abstract The class name or container element name to make
@param array $parameters User defined parameters that must be used instead of resolved ones
@param array $dependencies Array of ReflectionParameter
@throws ContainerException When a dependency cannot be solved.
@return array | [
"Process",
"all",
"dependencies"
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L150-L159 |
codeburnerframework/container | src/Container.php | Container.resolve | protected function resolve(string $abstract, ReflectionParameter $dependency)
{
$key = $abstract.$dependency->name;
if (! isset($this->resolved[$key])) {
$this->resolved[$key] = $this->generate($abstract, $dependency);
}
return $this->resolved[$key]($this);
} | php | protected function resolve(string $abstract, ReflectionParameter $dependency)
{
$key = $abstract.$dependency->name;
if (! isset($this->resolved[$key])) {
$this->resolved[$key] = $this->generate($abstract, $dependency);
}
return $this->resolved[$key]($this);
} | [
"protected",
"function",
"resolve",
"(",
"string",
"$",
"abstract",
",",
"ReflectionParameter",
"$",
"dependency",
")",
"{",
"$",
"key",
"=",
"$",
"abstract",
".",
"$",
"dependency",
"->",
"name",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resolved",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"resolved",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"generate",
"(",
"$",
"abstract",
",",
"$",
"dependency",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolved",
"[",
"$",
"key",
"]",
"(",
"$",
"this",
")",
";",
"}"
] | Resolve all the given class reflected dependencies.
@param string $abstract The class name or container element name to resolve dependencies.
@param ReflectionParameter $dependency The class dependency to be resolved.
@throws ContainerException When a dependency cannot be solved.
@return Object | [
"Resolve",
"all",
"the",
"given",
"class",
"reflected",
"dependencies",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L171-L180 |
codeburnerframework/container | src/Container.php | Container.generate | protected function generate(string $abstract, ReflectionParameter $dependency) : Closure
{
if ($class = $dependency->getClass()) {
return $this->build($class->name, "{$abstract}{$class->name}");
}
try {
$value = $dependency->getDefaultValue();
return function () use ($value) {
return $value;
};
} catch (ReflectionException $e) {
throw new ContainerException("Cannot resolve '$dependency->name' of '$abstract'", 0, $e);
}
} | php | protected function generate(string $abstract, ReflectionParameter $dependency) : Closure
{
if ($class = $dependency->getClass()) {
return $this->build($class->name, "{$abstract}{$class->name}");
}
try {
$value = $dependency->getDefaultValue();
return function () use ($value) {
return $value;
};
} catch (ReflectionException $e) {
throw new ContainerException("Cannot resolve '$dependency->name' of '$abstract'", 0, $e);
}
} | [
"protected",
"function",
"generate",
"(",
"string",
"$",
"abstract",
",",
"ReflectionParameter",
"$",
"dependency",
")",
":",
"Closure",
"{",
"if",
"(",
"$",
"class",
"=",
"$",
"dependency",
"->",
"getClass",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"build",
"(",
"$",
"class",
"->",
"name",
",",
"\"{$abstract}{$class->name}\"",
")",
";",
"}",
"try",
"{",
"$",
"value",
"=",
"$",
"dependency",
"->",
"getDefaultValue",
"(",
")",
";",
"return",
"function",
"(",
")",
"use",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"value",
";",
"}",
";",
"}",
"catch",
"(",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"ContainerException",
"(",
"\"Cannot resolve '$dependency->name' of '$abstract'\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Generate the dependencies callbacks to jump some conditions in every dependency creation.
@param string $abstract The class name or container element name to resolve dependencies.
@param ReflectionParameter $dependency The class dependency to be resolved.
@throws ContainerException When a dependency cannot be solved.
@return Closure | [
"Generate",
"the",
"dependencies",
"callbacks",
"to",
"jump",
"some",
"conditions",
"in",
"every",
"dependency",
"creation",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L192-L207 |
codeburnerframework/container | src/Container.php | Container.build | protected function build(string $classname, string $entry) : Closure
{
if (isset($this->dependencies[$entry])) {
return $this->dependencies[$entry];
}
return function () use ($classname) {
return $this->make($classname);
};
} | php | protected function build(string $classname, string $entry) : Closure
{
if (isset($this->dependencies[$entry])) {
return $this->dependencies[$entry];
}
return function () use ($classname) {
return $this->make($classname);
};
} | [
"protected",
"function",
"build",
"(",
"string",
"$",
"classname",
",",
"string",
"$",
"entry",
")",
":",
"Closure",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"entry",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"entry",
"]",
";",
"}",
"return",
"function",
"(",
")",
"use",
"(",
"$",
"classname",
")",
"{",
"return",
"$",
"this",
"->",
"make",
"(",
"$",
"classname",
")",
";",
"}",
";",
"}"
] | Create a build closure for a given class
@param string $classname The class that need to be build
@param string $entry Cache entry to search
@return Closure | [
"Create",
"a",
"build",
"closure",
"for",
"a",
"given",
"class"
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L218-L227 |
codeburnerframework/container | src/Container.php | Container.flush | public function flush() : ContainerInterface
{
$this->collection = [];
$this->dependencies = [];
$this->resolving = [];
$this->resolved = [];
return $this;
} | php | public function flush() : ContainerInterface
{
$this->collection = [];
$this->dependencies = [];
$this->resolving = [];
$this->resolved = [];
return $this;
} | [
"public",
"function",
"flush",
"(",
")",
":",
"ContainerInterface",
"{",
"$",
"this",
"->",
"collection",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"dependencies",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"resolving",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"resolved",
"=",
"[",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Reset the container, removing all the elements, cache and options.
@return ContainerInterface | [
"Reset",
"the",
"container",
"removing",
"all",
"the",
"elements",
"cache",
"and",
"options",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L235-L243 |
codeburnerframework/container | src/Container.php | Container.get | public function get($abstract)
{
if (! isset($this->collection[$abstract])) {
throw new NotFoundException("Element '$abstract' not found");
}
if ($this->collection[$abstract] instanceof Closure) {
try {
return $this->collection[$abstract]($this);
} catch (Exception $e) {
throw new ContainerException("An exception was thrown while attempt to make $abstract", 0, $e);
}
}
return $this->collection[$abstract];
} | php | public function get($abstract)
{
if (! isset($this->collection[$abstract])) {
throw new NotFoundException("Element '$abstract' not found");
}
if ($this->collection[$abstract] instanceof Closure) {
try {
return $this->collection[$abstract]($this);
} catch (Exception $e) {
throw new ContainerException("An exception was thrown while attempt to make $abstract", 0, $e);
}
}
return $this->collection[$abstract];
} | [
"public",
"function",
"get",
"(",
"$",
"abstract",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"\"Element '$abstract' not found\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"instanceof",
"Closure",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"(",
"$",
"this",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"ContainerException",
"(",
"\"An exception was thrown while attempt to make $abstract\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
";",
"}"
] | Finds an entry of the container by its identifier and returns it.
@param string $abstract Identifier of the entry to look for.
@throws NotFoundException No entry was found for this identifier.
@throws ContainerException Error while retrieving the entry.
@return mixed Entry. | [
"Finds",
"an",
"entry",
"of",
"the",
"container",
"by",
"its",
"identifier",
"and",
"returns",
"it",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L255-L270 |
codeburnerframework/container | src/Container.php | Container.isSingleton | public function isSingleton(string $abstract) : bool
{
if (! $this->has($abstract)) {
throw new NotFoundException("Element '$abstract' not found");
}
return $this->collection[$abstract] instanceof Closure === false;
} | php | public function isSingleton(string $abstract) : bool
{
if (! $this->has($abstract)) {
throw new NotFoundException("Element '$abstract' not found");
}
return $this->collection[$abstract] instanceof Closure === false;
} | [
"public",
"function",
"isSingleton",
"(",
"string",
"$",
"abstract",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"abstract",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"\"Element '$abstract' not found\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"instanceof",
"Closure",
"===",
"false",
";",
"}"
] | Verify if an element has a singleton instance.
@param string The class name or container element name to resolve dependencies.
@throws NotFoundException When $abstract does not exists
@return bool | [
"Verify",
"if",
"an",
"element",
"has",
"a",
"singleton",
"instance",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L298-L305 |
codeburnerframework/container | src/Container.php | Container.set | public function set(string $abstract, $concrete, bool $shared = false) : ContainerInterface
{
if (is_object($concrete)) {
return $this->instance($abstract, $concrete);
}
if ($concrete instanceof Closure === false) {
$concrete = function (Container $container) use ($concrete) {
return $container->make($concrete);
};
}
if ($shared === true) {
$this->collection[$abstract] = $concrete($this);
} else $this->collection[$abstract] = $concrete;
return $this;
} | php | public function set(string $abstract, $concrete, bool $shared = false) : ContainerInterface
{
if (is_object($concrete)) {
return $this->instance($abstract, $concrete);
}
if ($concrete instanceof Closure === false) {
$concrete = function (Container $container) use ($concrete) {
return $container->make($concrete);
};
}
if ($shared === true) {
$this->collection[$abstract] = $concrete($this);
} else $this->collection[$abstract] = $concrete;
return $this;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"abstract",
",",
"$",
"concrete",
",",
"bool",
"$",
"shared",
"=",
"false",
")",
":",
"ContainerInterface",
"{",
"if",
"(",
"is_object",
"(",
"$",
"concrete",
")",
")",
"{",
"return",
"$",
"this",
"->",
"instance",
"(",
"$",
"abstract",
",",
"$",
"concrete",
")",
";",
"}",
"if",
"(",
"$",
"concrete",
"instanceof",
"Closure",
"===",
"false",
")",
"{",
"$",
"concrete",
"=",
"function",
"(",
"Container",
"$",
"container",
")",
"use",
"(",
"$",
"concrete",
")",
"{",
"return",
"$",
"container",
"->",
"make",
"(",
"$",
"concrete",
")",
";",
"}",
";",
"}",
"if",
"(",
"$",
"shared",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"=",
"$",
"concrete",
"(",
"$",
"this",
")",
";",
"}",
"else",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"=",
"$",
"concrete",
";",
"return",
"$",
"this",
";",
"}"
] | Bind a new element to the container.
@param string $abstract The alias name that will be used to call the element.
@param string|closure|object $concrete The element class name, or an closure that makes the element, or the object itself.
@param bool $shared Define if the element will be a singleton instance.
@return ContainerInterface | [
"Bind",
"a",
"new",
"element",
"to",
"the",
"container",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L335-L352 |
codeburnerframework/container | src/Container.php | Container.setIf | public function setIf(string $abstract, $concrete, bool $shared = false) : ContainerInterface
{
if (! $this->has($abstract)) {
$this->set($abstract, $concrete, $shared);
}
return $this;
} | php | public function setIf(string $abstract, $concrete, bool $shared = false) : ContainerInterface
{
if (! $this->has($abstract)) {
$this->set($abstract, $concrete, $shared);
}
return $this;
} | [
"public",
"function",
"setIf",
"(",
"string",
"$",
"abstract",
",",
"$",
"concrete",
",",
"bool",
"$",
"shared",
"=",
"false",
")",
":",
"ContainerInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"abstract",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"abstract",
",",
"$",
"concrete",
",",
"$",
"shared",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Bind a new element to the container IF the element name not exists in the container.
@param string $abstract The alias name that will be used to call the element.
@param string|closure $concrete The element class name, or an closure that makes the element.
@param bool $shared Define if the element will be a singleton instance.
@return ContainerInterface | [
"Bind",
"a",
"new",
"element",
"to",
"the",
"container",
"IF",
"the",
"element",
"name",
"not",
"exists",
"in",
"the",
"container",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L364-L371 |
codeburnerframework/container | src/Container.php | Container.setTo | public function setTo(string $class, string $dependencyName, $dependency) : ContainerInterface
{
$key = "$class$dependencyName";
if ($dependency instanceof Closure === false) {
// let's use temporarily the set method to resolve
// the $dependency if it is not a closure ready to use.
$this->set($key, $dependency);
$resolved = $this->collection[$key];
// now we already have a resolved version of $dependency
// we just need to ensure the dependencies type, a closure.
$dependency = function () use ($resolved) {
return $resolved;
};
// we have used the set method to resolve the $dependency
// now that we have done all the process let's clear the memory.
unset($resolved, $this->collection[$key]);
}
$this->dependencies[$key] = $dependency;
return $this;
} | php | public function setTo(string $class, string $dependencyName, $dependency) : ContainerInterface
{
$key = "$class$dependencyName";
if ($dependency instanceof Closure === false) {
// let's use temporarily the set method to resolve
// the $dependency if it is not a closure ready to use.
$this->set($key, $dependency);
$resolved = $this->collection[$key];
// now we already have a resolved version of $dependency
// we just need to ensure the dependencies type, a closure.
$dependency = function () use ($resolved) {
return $resolved;
};
// we have used the set method to resolve the $dependency
// now that we have done all the process let's clear the memory.
unset($resolved, $this->collection[$key]);
}
$this->dependencies[$key] = $dependency;
return $this;
} | [
"public",
"function",
"setTo",
"(",
"string",
"$",
"class",
",",
"string",
"$",
"dependencyName",
",",
"$",
"dependency",
")",
":",
"ContainerInterface",
"{",
"$",
"key",
"=",
"\"$class$dependencyName\"",
";",
"if",
"(",
"$",
"dependency",
"instanceof",
"Closure",
"===",
"false",
")",
"{",
"// let's use temporarily the set method to resolve",
"// the $dependency if it is not a closure ready to use.",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"dependency",
")",
";",
"$",
"resolved",
"=",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
";",
"// now we already have a resolved version of $dependency",
"// we just need to ensure the dependencies type, a closure.",
"$",
"dependency",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"resolved",
")",
"{",
"return",
"$",
"resolved",
";",
"}",
";",
"// we have used the set method to resolve the $dependency",
"// now that we have done all the process let's clear the memory.",
"unset",
"(",
"$",
"resolved",
",",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"key",
"]",
"=",
"$",
"dependency",
";",
"return",
"$",
"this",
";",
"}"
] | Bind an specific instance to a class dependency.
@param string $class The class full name.
@param string $dependencyName The dependency full name.
@param string|closure $dependency The specific object class name or a classure that makes the element.
@return ContainerInterface | [
"Bind",
"an",
"specific",
"instance",
"to",
"a",
"class",
"dependency",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L383-L411 |
codeburnerframework/container | src/Container.php | Container.instance | public function instance(string $abstract, $instance) : ContainerInterface
{
if (! is_object($instance)) {
throw new ContainerException('Trying to store ' . gettype($instance) . ' as object.');
}
$this->collection[$abstract] = $instance;
return $this;
} | php | public function instance(string $abstract, $instance) : ContainerInterface
{
if (! is_object($instance)) {
throw new ContainerException('Trying to store ' . gettype($instance) . ' as object.');
}
$this->collection[$abstract] = $instance;
return $this;
} | [
"public",
"function",
"instance",
"(",
"string",
"$",
"abstract",
",",
"$",
"instance",
")",
":",
"ContainerInterface",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"instance",
")",
")",
"{",
"throw",
"new",
"ContainerException",
"(",
"'Trying to store '",
".",
"gettype",
"(",
"$",
"instance",
")",
".",
"' as object.'",
")",
";",
"}",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"=",
"$",
"instance",
";",
"return",
"$",
"this",
";",
"}"
] | Bind an object to the container.
@param string $abstract The alias name that will be used to call the object.
@param object $instance The object that will be inserted.
@throws ContainerException When $instance is not an object.
@return ContainerInterface | [
"Bind",
"an",
"object",
"to",
"the",
"container",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L440-L449 |
codeburnerframework/container | src/Container.php | Container.extend | public function extend(string $abstract, closure $extension) : ContainerInterface
{
$object = $this->get($abstract);
$this->collection[$abstract] = $extension($object, $this);
return $this;
} | php | public function extend(string $abstract, closure $extension) : ContainerInterface
{
$object = $this->get($abstract);
$this->collection[$abstract] = $extension($object, $this);
return $this;
} | [
"public",
"function",
"extend",
"(",
"string",
"$",
"abstract",
",",
"closure",
"$",
"extension",
")",
":",
"ContainerInterface",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"abstract",
")",
";",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"=",
"$",
"extension",
"(",
"$",
"object",
",",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Modify an element with a given function that receive the old element as argument.
@param string $abstract The alias name that will be used to call the element.
@param closure $extension The function that receives the old element and return a new or modified one.
@throws NotFoundException When no element was found with $abstract key.
@return ContainerInterface | [
"Modify",
"an",
"element",
"with",
"a",
"given",
"function",
"that",
"receive",
"the",
"old",
"element",
"as",
"argument",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L461-L468 |
codeburnerframework/container | src/Container.php | Container.share | public function share(string $abstract) : ContainerInterface
{
$object = $this->get($abstract);
$this->collection[$abstract] = $object;
return $this;
} | php | public function share(string $abstract) : ContainerInterface
{
$object = $this->get($abstract);
$this->collection[$abstract] = $object;
return $this;
} | [
"public",
"function",
"share",
"(",
"string",
"$",
"abstract",
")",
":",
"ContainerInterface",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"abstract",
")",
";",
"$",
"this",
"->",
"collection",
"[",
"$",
"abstract",
"]",
"=",
"$",
"object",
";",
"return",
"$",
"this",
";",
"}"
] | Makes an resolvable element an singleton.
@param string $abstract The alias name that will be used to call the element.
@throws NotFoundException When no element was found with $abstract key.
@throws ContainerException When the element on $abstract key is not resolvable.
@return ContainerInterface | [
"Makes",
"an",
"resolvable",
"element",
"an",
"singleton",
"."
] | train | https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L481-L488 |
Eresus/EresusCMS | src/core/HTTP/Parameters.php | Eresus_HTTP_Parameters.get | public function get($name, $default = null)
{
return $this->has($name) ? (@$this->data[$name] ?: $this->data["wyswyg_$name"]) : $default;
} | php | public function get($name, $default = null)
{
return $this->has($name) ? (@$this->data[$name] ?: $this->data["wyswyg_$name"]) : $default;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
"?",
"(",
"@",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"?",
":",
"$",
"this",
"->",
"data",
"[",
"\"wyswyg_$name\"",
"]",
")",
":",
"$",
"default",
";",
"}"
] | Возвращает значение параметра
@param string $name имя параметра
@param mixed $default значение по умолчанию, если параметр отсутствует
@return mixed
@since 3.01 | [
"Возвращает",
"значение",
"параметра"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Parameters.php#L107-L110 |
Eresus/EresusCMS | src/core/HTTP/Parameters.php | Eresus_HTTP_Parameters.filter | public function filter($name, $default = null, $filter = FILTER_DEFAULT, $options = null)
{
$value = $this->get($name, $default);
if (FILTER_REGEXP == $filter)
{
return preg_replace($options, '', $value);
}
if (FILTER_CALLBACK == $filter && is_callable($options))
{
$options = array('options' => $options);
}
return filter_var($value, $filter, $options);
} | php | public function filter($name, $default = null, $filter = FILTER_DEFAULT, $options = null)
{
$value = $this->get($name, $default);
if (FILTER_REGEXP == $filter)
{
return preg_replace($options, '', $value);
}
if (FILTER_CALLBACK == $filter && is_callable($options))
{
$options = array('options' => $options);
}
return filter_var($value, $filter, $options);
} | [
"public",
"function",
"filter",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
",",
"$",
"filter",
"=",
"FILTER_DEFAULT",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
",",
"$",
"default",
")",
";",
"if",
"(",
"FILTER_REGEXP",
"==",
"$",
"filter",
")",
"{",
"return",
"preg_replace",
"(",
"$",
"options",
",",
"''",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"FILTER_CALLBACK",
"==",
"$",
"filter",
"&&",
"is_callable",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'options'",
"=>",
"$",
"options",
")",
";",
"}",
"return",
"filter_var",
"(",
"$",
"value",
",",
"$",
"filter",
",",
"$",
"options",
")",
";",
"}"
] | Возвращает профильтрованное значение параметра $name
@param string $name имя параметра
@param mixed $default значение по умолчанию, если параметр отсутствует
@param int $filter фильтр (константа FILTER_*)
@param mixed $options опции фильтра
@return mixed
@since 3.01 | [
"Возвращает",
"профильтрованное",
"значение",
"параметра",
"$name"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Parameters.php#L123-L135 |
Eresus/EresusCMS | src/core/HTTP/Parameters.php | Eresus_HTTP_Parameters.getInt | public function getInt($name, $default = null)
{
$value = $this->get($name, $default);
return null === $value ? null : intval($value);
} | php | public function getInt($name, $default = null)
{
$value = $this->get($name, $default);
return null === $value ? null : intval($value);
} | [
"public",
"function",
"getInt",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
",",
"$",
"default",
")",
";",
"return",
"null",
"===",
"$",
"value",
"?",
"null",
":",
"intval",
"(",
"$",
"value",
")",
";",
"}"
] | @param string $name
@param int $default
@return int|null
@since 3.01 | [
"@param",
"string",
"$name",
"@param",
"int",
"$default"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/HTTP/Parameters.php#L144-L148 |
nabab/bbn | src/bbn/util/timer.php | timer.start | public function start($key='default')
{
if ( !isset($this->measures[$key]) ){
$this->measures[$key] = [
'num' => 0,
'sum' => 0,
'start' => microtime(1)
];
}
else{
$this->measures[$key]['start'] = microtime(1);
}
} | php | public function start($key='default')
{
if ( !isset($this->measures[$key]) ){
$this->measures[$key] = [
'num' => 0,
'sum' => 0,
'start' => microtime(1)
];
}
else{
$this->measures[$key]['start'] = microtime(1);
}
} | [
"public",
"function",
"start",
"(",
"$",
"key",
"=",
"'default'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"=",
"[",
"'num'",
"=>",
"0",
",",
"'sum'",
"=>",
"0",
",",
"'start'",
"=>",
"microtime",
"(",
"1",
")",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'start'",
"]",
"=",
"microtime",
"(",
"1",
")",
";",
"}",
"}"
] | Starts a timer for a given key
@return void | [
"Starts",
"a",
"timer",
"for",
"a",
"given",
"key"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/timer.php#L34-L46 |
nabab/bbn | src/bbn/util/timer.php | timer.has_started | public function has_started($key)
{
if ( isset($this->measures[$key]) ){
return $this->measures[$key]['start'] > 0;
}
return false;
} | php | public function has_started($key)
{
if ( isset($this->measures[$key]) ){
return $this->measures[$key]['start'] > 0;
}
return false;
} | [
"public",
"function",
"has_started",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'start'",
"]",
">",
"0",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true is the timer has started for the given key
@return bool | [
"Returns",
"true",
"is",
"the",
"timer",
"has",
"started",
"for",
"the",
"given",
"key"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/timer.php#L53-L59 |
nabab/bbn | src/bbn/util/timer.php | timer.stop | public function stop($key='default')
{
if ( isset($this->measures[$key], $this->measures[$key]['start']) ){
$this->measures[$key]['num']++;
$time = $this->measure($key);
$this->measures[$key]['sum'] += $time;
unset($this->measures[$key]['start']);
return $time;
}
else{
die("Missing a start declaration for timer $key");
}
} | php | public function stop($key='default')
{
if ( isset($this->measures[$key], $this->measures[$key]['start']) ){
$this->measures[$key]['num']++;
$time = $this->measure($key);
$this->measures[$key]['sum'] += $time;
unset($this->measures[$key]['start']);
return $time;
}
else{
die("Missing a start declaration for timer $key");
}
} | [
"public",
"function",
"stop",
"(",
"$",
"key",
"=",
"'default'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
",",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'start'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'num'",
"]",
"++",
";",
"$",
"time",
"=",
"$",
"this",
"->",
"measure",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'sum'",
"]",
"+=",
"$",
"time",
";",
"unset",
"(",
"$",
"this",
"->",
"measures",
"[",
"$",
"key",
"]",
"[",
"'start'",
"]",
")",
";",
"return",
"$",
"time",
";",
"}",
"else",
"{",
"die",
"(",
"\"Missing a start declaration for timer $key\"",
")",
";",
"}",
"}"
] | Stops a timer for a given key
@return int | [
"Stops",
"a",
"timer",
"for",
"a",
"given",
"key"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/timer.php#L67-L79 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setNamespace | public function setNamespace($namespace)
{
if (!is_string($namespace)) {
throw new \InvalidArgumentException('The attribute namespace on the class Entity has to be string (' . gettype($namespace) . ('object' === gettype($namespace) ? ' ' . get_class($namespace) : '') . ' given).');
}
if (strlen($namespace) < 1) {
throw new \InvalidArgumentException('On the attribute namespace, the length of the string ' . $namespace . ' is ' . strlen($namespace) . ' which is shorter than the minimum allowed (1).');
}
$this->namespace = $namespace;
return $this;
} | php | public function setNamespace($namespace)
{
if (!is_string($namespace)) {
throw new \InvalidArgumentException('The attribute namespace on the class Entity has to be string (' . gettype($namespace) . ('object' === gettype($namespace) ? ' ' . get_class($namespace) : '') . ' given).');
}
if (strlen($namespace) < 1) {
throw new \InvalidArgumentException('On the attribute namespace, the length of the string ' . $namespace . ' is ' . strlen($namespace) . ' which is shorter than the minimum allowed (1).');
}
$this->namespace = $namespace;
return $this;
} | [
"public",
"function",
"setNamespace",
"(",
"$",
"namespace",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"namespace",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute namespace on the class Entity has to be string ('",
".",
"gettype",
"(",
"$",
"namespace",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"namespace",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"namespace",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"namespace",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'On the attribute namespace, the length of the string '",
".",
"$",
"namespace",
".",
"' is '",
".",
"strlen",
"(",
"$",
"namespace",
")",
".",
"' which is shorter than the minimum allowed (1).'",
")",
";",
"}",
"$",
"this",
"->",
"namespace",
"=",
"$",
"namespace",
";",
"return",
"$",
"this",
";",
"}"
] | Set namespace
@param string $namespace
@return Entity
@throws \InvalidArgumentException | [
"Set",
"namespace"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L148-L161 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setModule | public function setModule($module)
{
if (!is_string($module)) {
throw new \InvalidArgumentException('The attribute module on the class Entity has to be string (' . gettype($module) . ('object' === gettype($module) ? ' ' . get_class($module) : '') . ' given).');
}
$this->module = $module;
return $this;
} | php | public function setModule($module)
{
if (!is_string($module)) {
throw new \InvalidArgumentException('The attribute module on the class Entity has to be string (' . gettype($module) . ('object' === gettype($module) ? ' ' . get_class($module) : '') . ' given).');
}
$this->module = $module;
return $this;
} | [
"public",
"function",
"setModule",
"(",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"module",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute module on the class Entity has to be string ('",
".",
"gettype",
"(",
"$",
"module",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"module",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"module",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"module",
"=",
"$",
"module",
";",
"return",
"$",
"this",
";",
"}"
] | Set module
@param string $module
@return Entity
@throws \InvalidArgumentException | [
"Set",
"module"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L184-L193 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setType | public function setType($type)
{
if (!is_string($type)) {
throw new \InvalidArgumentException('The attribute type on the class Entity has to be string (' . gettype($type) . ('object' === gettype($type) ? ' ' . get_class($type) : '') . ' given).');
}
$this->type = $type;
return $this;
} | php | public function setType($type)
{
if (!is_string($type)) {
throw new \InvalidArgumentException('The attribute type on the class Entity has to be string (' . gettype($type) . ('object' === gettype($type) ? ' ' . get_class($type) : '') . ' given).');
}
$this->type = $type;
return $this;
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute type on the class Entity has to be string ('",
".",
"gettype",
"(",
"$",
"type",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"type",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"type",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}"
] | Set type
@param string $type
@return Entity
@throws \InvalidArgumentException | [
"Set",
"type"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L244-L253 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setDescription | public function setDescription($description)
{
if (!is_string($description)) {
throw new \InvalidArgumentException('The attribute description on the class Entity has to be string (' . gettype($description) . ('object' === gettype($description) ? ' ' . get_class($description) : '') . ' given).');
}
$this->description = $description;
return $this;
} | php | public function setDescription($description)
{
if (!is_string($description)) {
throw new \InvalidArgumentException('The attribute description on the class Entity has to be string (' . gettype($description) . ('object' === gettype($description) ? ' ' . get_class($description) : '') . ' given).');
}
$this->description = $description;
return $this;
} | [
"public",
"function",
"setDescription",
"(",
"$",
"description",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"description",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute description on the class Entity has to be string ('",
".",
"gettype",
"(",
"$",
"description",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"description",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"description",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"description",
"=",
"$",
"description",
";",
"return",
"$",
"this",
";",
"}"
] | Set description
@param string $description
@return Entity
@throws \InvalidArgumentException | [
"Set",
"description"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L274-L283 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.containsAttributes | public function containsAttributes(array $attributes)
{
foreach ($attributes as $attribute) {
if (!$this->attributes->contains($attribute)) {
return false;
}
}
return true;
} | php | public function containsAttributes(array $attributes)
{
foreach ($attributes as $attribute) {
if (!$this->attributes->contains($attribute)) {
return false;
}
}
return true;
} | [
"public",
"function",
"containsAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"attributes",
"->",
"contains",
"(",
"$",
"attribute",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Contains attributes
@param Attribute[] $attributes
@return bool | [
"Contains",
"attributes"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L358-L367 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.removeAttribute | public function removeAttribute(Attribute $attribute)
{
foreach ($this->attributes as $key => $attributeElement) {
if ($attributeElement === $attribute) {
unset($this->attributes[$key]);
break;
}
}
return $this;
} | php | public function removeAttribute(Attribute $attribute)
{
foreach ($this->attributes as $key => $attributeElement) {
if ($attributeElement === $attribute) {
unset($this->attributes[$key]);
break;
}
}
return $this;
} | [
"public",
"function",
"removeAttribute",
"(",
"Attribute",
"$",
"attribute",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"attributeElement",
")",
"{",
"if",
"(",
"$",
"attributeElement",
"===",
"$",
"attribute",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove attribute
@param Attribute $attribute
@return Entity | [
"Remove",
"attribute"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L376-L386 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.containsAttributeNames | public function containsAttributeNames(array $attributeNames)
{
foreach ($attributeNames as $attributeName) {
if (!$this->attributeNames->contains($attributeName)) {
return false;
}
}
return true;
} | php | public function containsAttributeNames(array $attributeNames)
{
foreach ($attributeNames as $attributeName) {
if (!$this->attributeNames->contains($attributeName)) {
return false;
}
}
return true;
} | [
"public",
"function",
"containsAttributeNames",
"(",
"array",
"$",
"attributeNames",
")",
"{",
"foreach",
"(",
"$",
"attributeNames",
"as",
"$",
"attributeName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"attributeNames",
"->",
"contains",
"(",
"$",
"attributeName",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Contains attributeNames
@param string[] $attributeNames
@return bool | [
"Contains",
"attributeNames"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L477-L486 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.removeAttributeName | public function removeAttributeName($attributeName)
{
foreach ($this->attributeNames as $key => $attributeNameElement) {
if ($attributeNameElement === $attributeName) {
unset($this->attributeNames[$key]);
break;
}
}
return $this;
} | php | public function removeAttributeName($attributeName)
{
foreach ($this->attributeNames as $key => $attributeNameElement) {
if ($attributeNameElement === $attributeName) {
unset($this->attributeNames[$key]);
break;
}
}
return $this;
} | [
"public",
"function",
"removeAttributeName",
"(",
"$",
"attributeName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"attributeNames",
"as",
"$",
"key",
"=>",
"$",
"attributeNameElement",
")",
"{",
"if",
"(",
"$",
"attributeNameElement",
"===",
"$",
"attributeName",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"attributeNames",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove attributeName
@param string $attributeName
@return Entity | [
"Remove",
"attributeName"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L495-L505 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.containsPrimaryAttributes | public function containsPrimaryAttributes(array $primaryAttributes)
{
foreach ($primaryAttributes as $primaryAttribute) {
if (!$this->primaryAttributes->contains($primaryAttribute)) {
return false;
}
}
return true;
} | php | public function containsPrimaryAttributes(array $primaryAttributes)
{
foreach ($primaryAttributes as $primaryAttribute) {
if (!$this->primaryAttributes->contains($primaryAttribute)) {
return false;
}
}
return true;
} | [
"public",
"function",
"containsPrimaryAttributes",
"(",
"array",
"$",
"primaryAttributes",
")",
"{",
"foreach",
"(",
"$",
"primaryAttributes",
"as",
"$",
"primaryAttribute",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"primaryAttributes",
"->",
"contains",
"(",
"$",
"primaryAttribute",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Contains primaryAttributes
@param Attribute[] $primaryAttributes
@return bool | [
"Contains",
"primaryAttributes"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L596-L605 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.removePrimaryAttribute | public function removePrimaryAttribute(Attribute $primaryAttribute)
{
foreach ($this->primaryAttributes as $key => $primaryAttributeElement) {
if ($primaryAttributeElement === $primaryAttribute) {
unset($this->primaryAttributes[$key]);
break;
}
}
return $this;
} | php | public function removePrimaryAttribute(Attribute $primaryAttribute)
{
foreach ($this->primaryAttributes as $key => $primaryAttributeElement) {
if ($primaryAttributeElement === $primaryAttribute) {
unset($this->primaryAttributes[$key]);
break;
}
}
return $this;
} | [
"public",
"function",
"removePrimaryAttribute",
"(",
"Attribute",
"$",
"primaryAttribute",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"primaryAttributes",
"as",
"$",
"key",
"=>",
"$",
"primaryAttributeElement",
")",
"{",
"if",
"(",
"$",
"primaryAttributeElement",
"===",
"$",
"primaryAttribute",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"primaryAttributes",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove primaryAttribute
@param Attribute $primaryAttribute
@return Entity | [
"Remove",
"primaryAttribute"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L614-L624 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setRenderizable | public function setRenderizable($renderizable)
{
if (!is_bool($renderizable)) {
throw new \InvalidArgumentException('The attribute renderizable on the class Entity has to be boolean (' . gettype($renderizable) . ('object' === gettype($renderizable) ? ' ' . get_class($renderizable) : '') . ' given).');
}
$this->renderizable = $renderizable;
return $this;
} | php | public function setRenderizable($renderizable)
{
if (!is_bool($renderizable)) {
throw new \InvalidArgumentException('The attribute renderizable on the class Entity has to be boolean (' . gettype($renderizable) . ('object' === gettype($renderizable) ? ' ' . get_class($renderizable) : '') . ' given).');
}
$this->renderizable = $renderizable;
return $this;
} | [
"public",
"function",
"setRenderizable",
"(",
"$",
"renderizable",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"renderizable",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute renderizable on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"renderizable",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"renderizable",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"renderizable",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"renderizable",
"=",
"$",
"renderizable",
";",
"return",
"$",
"this",
";",
"}"
] | Set renderizable
@param boolean $renderizable
@return Entity
@throws \InvalidArgumentException | [
"Set",
"renderizable"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L661-L670 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setToString | public function setToString($toString)
{
if (!is_string($toString) && null !== $toString) {
throw new \InvalidArgumentException('The attribute toString on the class Entity has to be string or null (' . gettype($toString) . ('object' === gettype($toString) ? ' ' . get_class($toString) : '') . ' given).');
}
$this->toString = $toString;
return $this;
} | php | public function setToString($toString)
{
if (!is_string($toString) && null !== $toString) {
throw new \InvalidArgumentException('The attribute toString on the class Entity has to be string or null (' . gettype($toString) . ('object' === gettype($toString) ? ' ' . get_class($toString) : '') . ' given).');
}
$this->toString = $toString;
return $this;
} | [
"public",
"function",
"setToString",
"(",
"$",
"toString",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"toString",
")",
"&&",
"null",
"!==",
"$",
"toString",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute toString on the class Entity has to be string or null ('",
".",
"gettype",
"(",
"$",
"toString",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"toString",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"toString",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"toString",
"=",
"$",
"toString",
";",
"return",
"$",
"this",
";",
"}"
] | Set toString
@param string|null $toString
@return Entity
@throws \InvalidArgumentException | [
"Set",
"toString"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L691-L700 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setParentEntity | public function setParentEntity($parentEntity)
{
if (!$parentEntity instanceof Entity && null !== $parentEntity) {
throw new \InvalidArgumentException('The attribute parentEntity on the class Entity has to be Entity or null (' . gettype($parentEntity) . ('object' === gettype($parentEntity) ? ' ' . get_class($parentEntity) : '') . ' given).');
}
$this->parentEntity = $parentEntity;
return $this;
} | php | public function setParentEntity($parentEntity)
{
if (!$parentEntity instanceof Entity && null !== $parentEntity) {
throw new \InvalidArgumentException('The attribute parentEntity on the class Entity has to be Entity or null (' . gettype($parentEntity) . ('object' === gettype($parentEntity) ? ' ' . get_class($parentEntity) : '') . ' given).');
}
$this->parentEntity = $parentEntity;
return $this;
} | [
"public",
"function",
"setParentEntity",
"(",
"$",
"parentEntity",
")",
"{",
"if",
"(",
"!",
"$",
"parentEntity",
"instanceof",
"Entity",
"&&",
"null",
"!==",
"$",
"parentEntity",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute parentEntity on the class Entity has to be Entity or null ('",
".",
"gettype",
"(",
"$",
"parentEntity",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"parentEntity",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"parentEntity",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"parentEntity",
"=",
"$",
"parentEntity",
";",
"return",
"$",
"this",
";",
"}"
] | Set parentEntity
@param Entity|null $parentEntity
@return Entity
@throws \InvalidArgumentException | [
"Set",
"parentEntity"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L721-L730 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.containsChildrenEntities | public function containsChildrenEntities(array $childrenEntities)
{
foreach ($childrenEntities as $childrenEntity) {
if (!$this->childrenEntities->contains($childrenEntity)) {
return false;
}
}
return true;
} | php | public function containsChildrenEntities(array $childrenEntities)
{
foreach ($childrenEntities as $childrenEntity) {
if (!$this->childrenEntities->contains($childrenEntity)) {
return false;
}
}
return true;
} | [
"public",
"function",
"containsChildrenEntities",
"(",
"array",
"$",
"childrenEntities",
")",
"{",
"foreach",
"(",
"$",
"childrenEntities",
"as",
"$",
"childrenEntity",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"childrenEntities",
"->",
"contains",
"(",
"$",
"childrenEntity",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Contains childrenEntities
@param Entity[] $childrenEntities
@return bool | [
"Contains",
"childrenEntities"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L805-L814 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.removeChildrenEntity | public function removeChildrenEntity(Entity $childrenEntity)
{
foreach ($this->childrenEntities as $key => $childrenEntityElement) {
if ($childrenEntityElement === $childrenEntity) {
unset($this->childrenEntities[$key]);
break;
}
}
return $this;
} | php | public function removeChildrenEntity(Entity $childrenEntity)
{
foreach ($this->childrenEntities as $key => $childrenEntityElement) {
if ($childrenEntityElement === $childrenEntity) {
unset($this->childrenEntities[$key]);
break;
}
}
return $this;
} | [
"public",
"function",
"removeChildrenEntity",
"(",
"Entity",
"$",
"childrenEntity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"childrenEntities",
"as",
"$",
"key",
"=>",
"$",
"childrenEntityElement",
")",
"{",
"if",
"(",
"$",
"childrenEntityElement",
"===",
"$",
"childrenEntity",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"childrenEntities",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove childrenEntity
@param Entity $childrenEntity
@return Entity | [
"Remove",
"childrenEntity"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L823-L833 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setHasRepository | public function setHasRepository($hasRepository)
{
if (!is_bool($hasRepository)) {
throw new \InvalidArgumentException('The attribute hasRepository on the class Entity has to be boolean (' . gettype($hasRepository) . ('object' === gettype($hasRepository) ? ' ' . get_class($hasRepository) : '') . ' given).');
}
$this->hasRepository = $hasRepository;
return $this;
} | php | public function setHasRepository($hasRepository)
{
if (!is_bool($hasRepository)) {
throw new \InvalidArgumentException('The attribute hasRepository on the class Entity has to be boolean (' . gettype($hasRepository) . ('object' === gettype($hasRepository) ? ' ' . get_class($hasRepository) : '') . ' given).');
}
$this->hasRepository = $hasRepository;
return $this;
} | [
"public",
"function",
"setHasRepository",
"(",
"$",
"hasRepository",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"hasRepository",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute hasRepository on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"hasRepository",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"hasRepository",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"hasRepository",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"hasRepository",
"=",
"$",
"hasRepository",
";",
"return",
"$",
"this",
";",
"}"
] | Set hasRepository
@param boolean $hasRepository
@return Entity
@throws \InvalidArgumentException | [
"Set",
"hasRepository"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L870-L879 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setHasForm | public function setHasForm($hasForm)
{
if (!is_bool($hasForm)) {
throw new \InvalidArgumentException('The attribute hasForm on the class Entity has to be boolean (' . gettype($hasForm) . ('object' === gettype($hasForm) ? ' ' . get_class($hasForm) : '') . ' given).');
}
$this->hasForm = $hasForm;
return $this;
} | php | public function setHasForm($hasForm)
{
if (!is_bool($hasForm)) {
throw new \InvalidArgumentException('The attribute hasForm on the class Entity has to be boolean (' . gettype($hasForm) . ('object' === gettype($hasForm) ? ' ' . get_class($hasForm) : '') . ' given).');
}
$this->hasForm = $hasForm;
return $this;
} | [
"public",
"function",
"setHasForm",
"(",
"$",
"hasForm",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"hasForm",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute hasForm on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"hasForm",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"hasForm",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"hasForm",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"hasForm",
"=",
"$",
"hasForm",
";",
"return",
"$",
"this",
";",
"}"
] | Set hasForm
@param boolean $hasForm
@return Entity
@throws \InvalidArgumentException | [
"Set",
"hasForm"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L900-L909 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setHasController | public function setHasController($hasController)
{
if (!is_bool($hasController)) {
throw new \InvalidArgumentException('The attribute hasController on the class Entity has to be boolean (' . gettype($hasController) . ('object' === gettype($hasController) ? ' ' . get_class($hasController) : '') . ' given).');
}
$this->hasController = $hasController;
return $this;
} | php | public function setHasController($hasController)
{
if (!is_bool($hasController)) {
throw new \InvalidArgumentException('The attribute hasController on the class Entity has to be boolean (' . gettype($hasController) . ('object' === gettype($hasController) ? ' ' . get_class($hasController) : '') . ' given).');
}
$this->hasController = $hasController;
return $this;
} | [
"public",
"function",
"setHasController",
"(",
"$",
"hasController",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"hasController",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute hasController on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"hasController",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"hasController",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"hasController",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"hasController",
"=",
"$",
"hasController",
";",
"return",
"$",
"this",
";",
"}"
] | Set hasController
@param boolean $hasController
@return Entity
@throws \InvalidArgumentException | [
"Set",
"hasController"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L930-L939 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setHasFixtures | public function setHasFixtures($hasFixtures)
{
if (!is_bool($hasFixtures)) {
throw new \InvalidArgumentException('The attribute hasFixtures on the class Entity has to be boolean (' . gettype($hasFixtures) . ('object' === gettype($hasFixtures) ? ' ' . get_class($hasFixtures) : '') . ' given).');
}
$this->hasFixtures = $hasFixtures;
return $this;
} | php | public function setHasFixtures($hasFixtures)
{
if (!is_bool($hasFixtures)) {
throw new \InvalidArgumentException('The attribute hasFixtures on the class Entity has to be boolean (' . gettype($hasFixtures) . ('object' === gettype($hasFixtures) ? ' ' . get_class($hasFixtures) : '') . ' given).');
}
$this->hasFixtures = $hasFixtures;
return $this;
} | [
"public",
"function",
"setHasFixtures",
"(",
"$",
"hasFixtures",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"hasFixtures",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute hasFixtures on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"hasFixtures",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"hasFixtures",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"hasFixtures",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"hasFixtures",
"=",
"$",
"hasFixtures",
";",
"return",
"$",
"this",
";",
"}"
] | Set hasFixtures
@param boolean $hasFixtures
@return Entity
@throws \InvalidArgumentException | [
"Set",
"hasFixtures"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L960-L969 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setCrud | public function setCrud($crud)
{
if (!is_string($crud)) {
throw new \InvalidArgumentException('The attribute crud on the class Entity has to be string (' . gettype($crud) . ('object' === gettype($crud) ? ' ' . get_class($crud) : '') . ' given).');
}
$this->crud = $crud;
return $this;
} | php | public function setCrud($crud)
{
if (!is_string($crud)) {
throw new \InvalidArgumentException('The attribute crud on the class Entity has to be string (' . gettype($crud) . ('object' === gettype($crud) ? ' ' . get_class($crud) : '') . ' given).');
}
$this->crud = $crud;
return $this;
} | [
"public",
"function",
"setCrud",
"(",
"$",
"crud",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"crud",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute crud on the class Entity has to be string ('",
".",
"gettype",
"(",
"$",
"crud",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"crud",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"crud",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"crud",
"=",
"$",
"crud",
";",
"return",
"$",
"this",
";",
"}"
] | Set crud
@param string $crud
@return Entity
@throws \InvalidArgumentException | [
"Set",
"crud"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L990-L999 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setHasRoutes | public function setHasRoutes($hasRoutes)
{
if (!is_bool($hasRoutes)) {
throw new \InvalidArgumentException('The attribute hasRoutes on the class Entity has to be boolean (' . gettype($hasRoutes) . ('object' === gettype($hasRoutes) ? ' ' . get_class($hasRoutes) : '') . ' given).');
}
$this->hasRoutes = $hasRoutes;
return $this;
} | php | public function setHasRoutes($hasRoutes)
{
if (!is_bool($hasRoutes)) {
throw new \InvalidArgumentException('The attribute hasRoutes on the class Entity has to be boolean (' . gettype($hasRoutes) . ('object' === gettype($hasRoutes) ? ' ' . get_class($hasRoutes) : '') . ' given).');
}
$this->hasRoutes = $hasRoutes;
return $this;
} | [
"public",
"function",
"setHasRoutes",
"(",
"$",
"hasRoutes",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"hasRoutes",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute hasRoutes on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"hasRoutes",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"hasRoutes",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"hasRoutes",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"hasRoutes",
"=",
"$",
"hasRoutes",
";",
"return",
"$",
"this",
";",
"}"
] | Set hasRoutes
@param boolean $hasRoutes
@return Entity
@throws \InvalidArgumentException | [
"Set",
"hasRoutes"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L1020-L1029 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setHasConstructor | public function setHasConstructor($hasConstructor)
{
if (!is_bool($hasConstructor)) {
throw new \InvalidArgumentException('The attribute hasConstructor on the class Entity has to be boolean (' . gettype($hasConstructor) . ('object' === gettype($hasConstructor) ? ' ' . get_class($hasConstructor) : '') . ' given).');
}
$this->hasConstructor = $hasConstructor;
return $this;
} | php | public function setHasConstructor($hasConstructor)
{
if (!is_bool($hasConstructor)) {
throw new \InvalidArgumentException('The attribute hasConstructor on the class Entity has to be boolean (' . gettype($hasConstructor) . ('object' === gettype($hasConstructor) ? ' ' . get_class($hasConstructor) : '') . ' given).');
}
$this->hasConstructor = $hasConstructor;
return $this;
} | [
"public",
"function",
"setHasConstructor",
"(",
"$",
"hasConstructor",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"hasConstructor",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute hasConstructor on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"hasConstructor",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"hasConstructor",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"hasConstructor",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"hasConstructor",
"=",
"$",
"hasConstructor",
";",
"return",
"$",
"this",
";",
"}"
] | Set hasConstructor
@param boolean $hasConstructor
@return Entity
@throws \InvalidArgumentException | [
"Set",
"hasConstructor"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L1074-L1083 |
j-d/draggy | src/Draggy/Autocode/Base/EntityBase.php | EntityBase.setArrayAccess | public function setArrayAccess($arrayAccess)
{
if (!is_bool($arrayAccess)) {
throw new \InvalidArgumentException('The attribute arrayAccess on the class Entity has to be boolean (' . gettype($arrayAccess) . ('object' === gettype($arrayAccess) ? ' ' . get_class($arrayAccess) : '') . ' given).');
}
$this->arrayAccess = $arrayAccess;
return $this;
} | php | public function setArrayAccess($arrayAccess)
{
if (!is_bool($arrayAccess)) {
throw new \InvalidArgumentException('The attribute arrayAccess on the class Entity has to be boolean (' . gettype($arrayAccess) . ('object' === gettype($arrayAccess) ? ' ' . get_class($arrayAccess) : '') . ' given).');
}
$this->arrayAccess = $arrayAccess;
return $this;
} | [
"public",
"function",
"setArrayAccess",
"(",
"$",
"arrayAccess",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"arrayAccess",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute arrayAccess on the class Entity has to be boolean ('",
".",
"gettype",
"(",
"$",
"arrayAccess",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"arrayAccess",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"arrayAccess",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"arrayAccess",
"=",
"$",
"arrayAccess",
";",
"return",
"$",
"this",
";",
"}"
] | Set arrayAccess
@param boolean $arrayAccess
@return Entity
@throws \InvalidArgumentException | [
"Set",
"arrayAccess"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/EntityBase.php#L1104-L1113 |
inhere/php-librarys | src/Web/ViewRenderer.php | ViewRenderer.fetch | public function fetch($view, array $data = [])
{
$file = $this->getViewFile($view);
if (!is_file($file)) {
throw new \RuntimeException("cannot render '$view' because the view file does not exist. File: $file");
}
/*
foreach ($data as $k=>$val) {
if (in_array($k, array_keys($this->attributes))) {
throw new \InvalidArgumentException("Duplicate key found in data and renderer attributes. " . $k);
}
}
*/
$data = array_merge($this->attributes, $data);
try {
ob_start();
$this->protectedIncludeScope($file, $data);
$output = ob_get_clean();
} catch (\Throwable $e) { // PHP 7+
ob_end_clean();
throw $e;
}
return $output;
} | php | public function fetch($view, array $data = [])
{
$file = $this->getViewFile($view);
if (!is_file($file)) {
throw new \RuntimeException("cannot render '$view' because the view file does not exist. File: $file");
}
/*
foreach ($data as $k=>$val) {
if (in_array($k, array_keys($this->attributes))) {
throw new \InvalidArgumentException("Duplicate key found in data and renderer attributes. " . $k);
}
}
*/
$data = array_merge($this->attributes, $data);
try {
ob_start();
$this->protectedIncludeScope($file, $data);
$output = ob_get_clean();
} catch (\Throwable $e) { // PHP 7+
ob_end_clean();
throw $e;
}
return $output;
} | [
"public",
"function",
"fetch",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getViewFile",
"(",
"$",
"view",
")",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"cannot render '$view' because the view file does not exist. File: $file\"",
")",
";",
"}",
"/*\n foreach ($data as $k=>$val) {\n if (in_array($k, array_keys($this->attributes))) {\n throw new \\InvalidArgumentException(\"Duplicate key found in data and renderer attributes. \" . $k);\n }\n }\n */",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"data",
")",
";",
"try",
"{",
"ob_start",
"(",
")",
";",
"$",
"this",
"->",
"protectedIncludeScope",
"(",
"$",
"file",
",",
"$",
"data",
")",
";",
"$",
"output",
"=",
"ob_get_clean",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"// PHP 7+",
"ob_end_clean",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Renders a view and returns the result as a string
throws RuntimeException if $viewsPath . $view does not exist
@param string $view
@param array $data
@return mixed
@throws \Throwable | [
"Renders",
"a",
"view",
"and",
"returns",
"the",
"result",
"as",
"a",
"string",
"throws",
"RuntimeException",
"if",
"$viewsPath",
".",
"$view",
"does",
"not",
"exist"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Web/ViewRenderer.php#L153-L180 |
interactivesolutions/honeycomb-core | src/models/traits/CustomAppends.php | CustomAppends.getArrayAbleAppends | protected function getArrayAbleAppends()
{
if (property_exists($this, 'customAppends')) {
// you can set custom appends array
if (is_array(self::$customAppends) && count(self::$customAppends))
return self::$customAppends;
// or if you want to disable custom appends just write false i.e. Model::$customAppends = false;
elseif (is_bool(self::$customAppends) && !self::$customAppends)
return [];
}
return parent::getArrayAbleAppends();
} | php | protected function getArrayAbleAppends()
{
if (property_exists($this, 'customAppends')) {
// you can set custom appends array
if (is_array(self::$customAppends) && count(self::$customAppends))
return self::$customAppends;
// or if you want to disable custom appends just write false i.e. Model::$customAppends = false;
elseif (is_bool(self::$customAppends) && !self::$customAppends)
return [];
}
return parent::getArrayAbleAppends();
} | [
"protected",
"function",
"getArrayAbleAppends",
"(",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'customAppends'",
")",
")",
"{",
"// you can set custom appends array",
"if",
"(",
"is_array",
"(",
"self",
"::",
"$",
"customAppends",
")",
"&&",
"count",
"(",
"self",
"::",
"$",
"customAppends",
")",
")",
"return",
"self",
"::",
"$",
"customAppends",
";",
"// or if you want to disable custom appends just write false i.e. Model::$customAppends = false;",
"elseif",
"(",
"is_bool",
"(",
"self",
"::",
"$",
"customAppends",
")",
"&&",
"!",
"self",
"::",
"$",
"customAppends",
")",
"return",
"[",
"]",
";",
"}",
"return",
"parent",
"::",
"getArrayAbleAppends",
"(",
")",
";",
"}"
] | Append attribute ignore
@return array | [
"Append",
"attribute",
"ignore"
] | train | https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/models/traits/CustomAppends.php#L19-L33 |
nabab/bbn | src/bbn/appui/masks.php | masks.get | public function get(string $id): ?array
{
$mask = $this->db->rselect('bbn_notes_masks', [], ['id_note' => $id]);
if ( $data = $this->notes->get($mask['id_note']) ){
$data['default'] = $mask['def'];
$data['id_type'] = $mask['id_type'];
$data['type'] = $this->o->text($mask['id_type']);
$data['name'] = $mask['name'];
return $data;
}
return null;
} | php | public function get(string $id): ?array
{
$mask = $this->db->rselect('bbn_notes_masks', [], ['id_note' => $id]);
if ( $data = $this->notes->get($mask['id_note']) ){
$data['default'] = $mask['def'];
$data['id_type'] = $mask['id_type'];
$data['type'] = $this->o->text($mask['id_type']);
$data['name'] = $mask['name'];
return $data;
}
return null;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"id",
")",
":",
"?",
"array",
"{",
"$",
"mask",
"=",
"$",
"this",
"->",
"db",
"->",
"rselect",
"(",
"'bbn_notes_masks'",
",",
"[",
"]",
",",
"[",
"'id_note'",
"=>",
"$",
"id",
"]",
")",
";",
"if",
"(",
"$",
"data",
"=",
"$",
"this",
"->",
"notes",
"->",
"get",
"(",
"$",
"mask",
"[",
"'id_note'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'default'",
"]",
"=",
"$",
"mask",
"[",
"'def'",
"]",
";",
"$",
"data",
"[",
"'id_type'",
"]",
"=",
"$",
"mask",
"[",
"'id_type'",
"]",
";",
"$",
"data",
"[",
"'type'",
"]",
"=",
"$",
"this",
"->",
"o",
"->",
"text",
"(",
"$",
"mask",
"[",
"'id_type'",
"]",
")",
";",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"mask",
"[",
"'name'",
"]",
";",
"return",
"$",
"data",
";",
"}",
"return",
"null",
";",
"}"
] | Gets the content of a mask based on the provided ID
@param string $id
@return array|null | [
"Gets",
"the",
"content",
"of",
"a",
"mask",
"based",
"on",
"the",
"provided",
"ID"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/masks.php#L42-L53 |
Laralum/Events | src/Controllers/EventController.php | EventController.getDatetime | private function getDatetime($datein, $timein)
{
$date = explode('-', $datein);
$time = explode(':', $timein);
$datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $datetime;
} | php | private function getDatetime($datein, $timein)
{
$date = explode('-', $datein);
$time = explode(':', $timein);
$datetime = Carbon::create($date[0], $date[1], $date[2], $time[0], $time[1]);
return $datetime;
} | [
"private",
"function",
"getDatetime",
"(",
"$",
"datein",
",",
"$",
"timein",
")",
"{",
"$",
"date",
"=",
"explode",
"(",
"'-'",
",",
"$",
"datein",
")",
";",
"$",
"time",
"=",
"explode",
"(",
"':'",
",",
"$",
"timein",
")",
";",
"$",
"datetime",
"=",
"Carbon",
"::",
"create",
"(",
"$",
"date",
"[",
"0",
"]",
",",
"$",
"date",
"[",
"1",
"]",
",",
"$",
"date",
"[",
"2",
"]",
",",
"$",
"time",
"[",
"0",
"]",
",",
"$",
"time",
"[",
"1",
"]",
")",
";",
"return",
"$",
"datetime",
";",
"}"
] | Get Carbon start datetime and end datemime.
@param mixed $object
@return array | [
"Get",
"Carbon",
"start",
"datetime",
"and",
"end",
"datemime",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L48-L55 |
Laralum/Events | src/Controllers/EventController.php | EventController.update | public function update(Request $request, Event $event)
{
$this->authorize('update', $event);
// Check dates
$validator = Validator::make($request->all(), [
'start_date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_date' => 'required|date',
'end_time' => 'required|date_format:H:i',
'title' => 'required|max:191',
'description' => 'required|max:2500',
'color' => 'max:191',
'place' => 'max:191',
'price' => 'required|numeric|max:999999999.99',
]);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
$start_datetime = self::getDatetime($request->start_date, $request->start_time);
$end_datetime = self::getDatetime($request->end_date, $request->end_time);
if ($end_datetime->lte($start_datetime)) {
$validator->errors()->add('end_date', __('laralum_events::general.end_date_after_start_date'));
return redirect()->back()->withErrors($validator)->withInput();
}
$user = User::findOrFail(Auth::id());
if (Settings::first()->text_editor == 'markdown') {
$desc = Markdown::convertToHtml($request->description);
} else {
$desc = htmlentities($request->description);
}
$event->update([
'title' => $request->title,
'start_date' => $request->start_date,
'start_time' => $request->start_time,
'end_date' => $request->end_date,
'end_time' => $request->end_time,
'description' => $desc,
'color' => $request->color,
'place' => $request->place,
'price' => $request->price,
'public' => $user->can('publish', Event::class) ? $request->has('public') : false,
]);
$event->touch();
return redirect()->route('laralum::events.index')->with('success', __('laralum_events::general.event_updated', ['id' => $event->id]));
} | php | public function update(Request $request, Event $event)
{
$this->authorize('update', $event);
// Check dates
$validator = Validator::make($request->all(), [
'start_date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_date' => 'required|date',
'end_time' => 'required|date_format:H:i',
'title' => 'required|max:191',
'description' => 'required|max:2500',
'color' => 'max:191',
'place' => 'max:191',
'price' => 'required|numeric|max:999999999.99',
]);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
$start_datetime = self::getDatetime($request->start_date, $request->start_time);
$end_datetime = self::getDatetime($request->end_date, $request->end_time);
if ($end_datetime->lte($start_datetime)) {
$validator->errors()->add('end_date', __('laralum_events::general.end_date_after_start_date'));
return redirect()->back()->withErrors($validator)->withInput();
}
$user = User::findOrFail(Auth::id());
if (Settings::first()->text_editor == 'markdown') {
$desc = Markdown::convertToHtml($request->description);
} else {
$desc = htmlentities($request->description);
}
$event->update([
'title' => $request->title,
'start_date' => $request->start_date,
'start_time' => $request->start_time,
'end_date' => $request->end_date,
'end_time' => $request->end_time,
'description' => $desc,
'color' => $request->color,
'place' => $request->place,
'price' => $request->price,
'public' => $user->can('publish', Event::class) ? $request->has('public') : false,
]);
$event->touch();
return redirect()->route('laralum::events.index')->with('success', __('laralum_events::general.event_updated', ['id' => $event->id]));
} | [
"public",
"function",
"update",
"(",
"Request",
"$",
"request",
",",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"event",
")",
";",
"// Check dates",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"request",
"->",
"all",
"(",
")",
",",
"[",
"'start_date'",
"=>",
"'required|date'",
",",
"'start_time'",
"=>",
"'required|date_format:H:i'",
",",
"'end_date'",
"=>",
"'required|date'",
",",
"'end_time'",
"=>",
"'required|date_format:H:i'",
",",
"'title'",
"=>",
"'required|max:191'",
",",
"'description'",
"=>",
"'required|max:2500'",
",",
"'color'",
"=>",
"'max:191'",
",",
"'place'",
"=>",
"'max:191'",
",",
"'price'",
"=>",
"'required|numeric|max:999999999.99'",
",",
"]",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"withErrors",
"(",
"$",
"validator",
")",
"->",
"withInput",
"(",
")",
";",
"}",
"$",
"start_datetime",
"=",
"self",
"::",
"getDatetime",
"(",
"$",
"request",
"->",
"start_date",
",",
"$",
"request",
"->",
"start_time",
")",
";",
"$",
"end_datetime",
"=",
"self",
"::",
"getDatetime",
"(",
"$",
"request",
"->",
"end_date",
",",
"$",
"request",
"->",
"end_time",
")",
";",
"if",
"(",
"$",
"end_datetime",
"->",
"lte",
"(",
"$",
"start_datetime",
")",
")",
"{",
"$",
"validator",
"->",
"errors",
"(",
")",
"->",
"add",
"(",
"'end_date'",
",",
"__",
"(",
"'laralum_events::general.end_date_after_start_date'",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"withErrors",
"(",
"$",
"validator",
")",
"->",
"withInput",
"(",
")",
";",
"}",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"Auth",
"::",
"id",
"(",
")",
")",
";",
"if",
"(",
"Settings",
"::",
"first",
"(",
")",
"->",
"text_editor",
"==",
"'markdown'",
")",
"{",
"$",
"desc",
"=",
"Markdown",
"::",
"convertToHtml",
"(",
"$",
"request",
"->",
"description",
")",
";",
"}",
"else",
"{",
"$",
"desc",
"=",
"htmlentities",
"(",
"$",
"request",
"->",
"description",
")",
";",
"}",
"$",
"event",
"->",
"update",
"(",
"[",
"'title'",
"=>",
"$",
"request",
"->",
"title",
",",
"'start_date'",
"=>",
"$",
"request",
"->",
"start_date",
",",
"'start_time'",
"=>",
"$",
"request",
"->",
"start_time",
",",
"'end_date'",
"=>",
"$",
"request",
"->",
"end_date",
",",
"'end_time'",
"=>",
"$",
"request",
"->",
"end_time",
",",
"'description'",
"=>",
"$",
"desc",
",",
"'color'",
"=>",
"$",
"request",
"->",
"color",
",",
"'place'",
"=>",
"$",
"request",
"->",
"place",
",",
"'price'",
"=>",
"$",
"request",
"->",
"price",
",",
"'public'",
"=>",
"$",
"user",
"->",
"can",
"(",
"'publish'",
",",
"Event",
"::",
"class",
")",
"?",
"$",
"request",
"->",
"has",
"(",
"'public'",
")",
":",
"false",
",",
"]",
")",
";",
"$",
"event",
"->",
"touch",
"(",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.index'",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.event_updated'",
",",
"[",
"'id'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
")",
";",
"}"
] | Update the specified resource in storage.
@param \Illuminate\Http\Request $request
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response | [
"Update",
"the",
"specified",
"resource",
"in",
"storage",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L158-L212 |
Laralum/Events | src/Controllers/EventController.php | EventController.confirmDestroy | public function confirmDestroy(Request $request, Event $event)
{
$this->authorize('delete', $event);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'message' => __('laralum_events::general.sure_del_event', ['event' => $event->title]),
'action' => route('laralum::events.destroy', ['event' => $event->id]),
]);
} | php | public function confirmDestroy(Request $request, Event $event)
{
$this->authorize('delete', $event);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'message' => __('laralum_events::general.sure_del_event', ['event' => $event->title]),
'action' => route('laralum::events.destroy', ['event' => $event->id]),
]);
} | [
"public",
"function",
"confirmDestroy",
"(",
"Request",
"$",
"request",
",",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"$",
"event",
")",
";",
"return",
"view",
"(",
"'laralum::pages.confirmation'",
",",
"[",
"'method'",
"=>",
"'DELETE'",
",",
"'message'",
"=>",
"__",
"(",
"'laralum_events::general.sure_del_event'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"title",
"]",
")",
",",
"'action'",
"=>",
"route",
"(",
"'laralum::events.destroy'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
",",
"]",
")",
";",
"}"
] | confirm destroy of the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response | [
"confirm",
"destroy",
"of",
"the",
"specified",
"resource",
"from",
"storage",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L221-L230 |
Laralum/Events | src/Controllers/EventController.php | EventController.destroy | public function destroy(Event $event)
{
$this->authorize('delete', $event);
$event->deleteUsers($event->users);
$event->delete();
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.event_deleted', ['id' => $event->id]));
} | php | public function destroy(Event $event)
{
$this->authorize('delete', $event);
$event->deleteUsers($event->users);
$event->delete();
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.event_deleted', ['id' => $event->id]));
} | [
"public",
"function",
"destroy",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"$",
"event",
")",
";",
"$",
"event",
"->",
"deleteUsers",
"(",
"$",
"event",
"->",
"users",
")",
";",
"$",
"event",
"->",
"delete",
"(",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.index'",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.event_deleted'",
",",
"[",
"'id'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
")",
";",
"}"
] | Remove the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response | [
"Remove",
"the",
"specified",
"resource",
"from",
"storage",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L239-L247 |
Laralum/Events | src/Controllers/EventController.php | EventController.join | public function join(Event $event)
{
$this->authorize('join', Event::class);
$event->addUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.joined_event', ['id' => $event->id]));
} | php | public function join(Event $event)
{
$this->authorize('join', Event::class);
$event->addUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.joined_event', ['id' => $event->id]));
} | [
"public",
"function",
"join",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'join'",
",",
"Event",
"::",
"class",
")",
";",
"$",
"event",
"->",
"addUser",
"(",
"User",
"::",
"findOrfail",
"(",
"Auth",
"::",
"id",
"(",
")",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.index'",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.joined_event'",
",",
"[",
"'id'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
")",
";",
"}"
] | Join to the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response | [
"Join",
"to",
"the",
"specified",
"resource",
"from",
"storage",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L256-L263 |
Laralum/Events | src/Controllers/EventController.php | EventController.leave | public function leave(Event $event)
{
$this->authorize('join', Event::class);
$event->deleteUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.left_event', ['id' => $event->id]));
} | php | public function leave(Event $event)
{
$this->authorize('join', Event::class);
$event->deleteUser(User::findOrfail(Auth::id()));
return redirect()->route('laralum::events.index')
->with('success', __('laralum_events::general.left_event', ['id' => $event->id]));
} | [
"public",
"function",
"leave",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'join'",
",",
"Event",
"::",
"class",
")",
";",
"$",
"event",
"->",
"deleteUser",
"(",
"User",
"::",
"findOrfail",
"(",
"Auth",
"::",
"id",
"(",
")",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.index'",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.left_event'",
",",
"[",
"'id'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
")",
";",
"}"
] | Leave from the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@return \Illuminate\Http\Response | [
"Leave",
"from",
"the",
"specified",
"resource",
"from",
"storage",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L272-L279 |
Laralum/Events | src/Controllers/EventController.php | EventController.makeResponsible | public function makeResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->addResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_added', ['event_id' => $event->id, 'user_id' => $user->id]));
} | php | public function makeResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->addResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_added', ['event_id' => $event->id, 'user_id' => $user->id]));
} | [
"public",
"function",
"makeResponsible",
"(",
"Event",
"$",
"event",
",",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"event",
")",
";",
"$",
"event",
"->",
"addResponsible",
"(",
"$",
"user",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.show'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.responsible_added'",
",",
"[",
"'event_id'",
"=>",
"$",
"event",
"->",
"id",
",",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
")",
";",
"}"
] | Make author of to the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@param \Laralum\Users\Models\User $user
@return \Illuminate\Http\Response | [
"Make",
"author",
"of",
"to",
"the",
"specified",
"resource",
"from",
"storage",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L289-L296 |
Laralum/Events | src/Controllers/EventController.php | EventController.undoResponsible | public function undoResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->deleteResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_deleted', ['event_id' => $event->id, 'user_id' => $user->id]));
} | php | public function undoResponsible(Event $event, User $user)
{
$this->authorize('update', $event);
$event->deleteResponsible($user);
return redirect()->route('laralum::events.show', ['event' => $event->id])
->with('success', __('laralum_events::general.responsible_deleted', ['event_id' => $event->id, 'user_id' => $user->id]));
} | [
"public",
"function",
"undoResponsible",
"(",
"Event",
"$",
"event",
",",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"event",
")",
";",
"$",
"event",
"->",
"deleteResponsible",
"(",
"$",
"user",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::events.show'",
",",
"[",
"'event'",
"=>",
"$",
"event",
"->",
"id",
"]",
")",
"->",
"with",
"(",
"'success'",
",",
"__",
"(",
"'laralum_events::general.responsible_deleted'",
",",
"[",
"'event_id'",
"=>",
"$",
"event",
"->",
"id",
",",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
"]",
")",
")",
";",
"}"
] | Undo author from the specified resource from storage.
@param \Laralum\Events\Models\Event $event
@param \Laralum\Users\Models\User $user
@return \Illuminate\Http\Response | [
"Undo",
"author",
"from",
"the",
"specified",
"resource",
"from",
"storage",
"."
] | train | https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Controllers/EventController.php#L306-L313 |
Eresus/EresusCMS | src/core/pages.php | TPages.insert | function insert()
{
$item = array();
$item['owner'] = arg('owner', 'int');
$item['name'] = arg('name', '/[^a-z0-9_]/i');
$item['title'] = arg('title', 'dbsafe');
$item['caption'] = arg('caption', 'dbsafe');
$item['description'] = arg('description', 'dbsafe');
$item['hint'] = arg('hint', 'dbsafe');
$item['keywords'] = arg('keywords', 'dbsafe');
$item['template'] = arg('template', 'dbsafe');
$item['type'] = arg('type', 'dbsafe');
$item['active'] = arg('active', 'int');
$item['visible'] = arg('visible', 'int');
$item['access'] = arg('access', 'int');
$item['position'] = arg('position', 'int');
$item['options'] = arg('options');
$item['created'] = $item['updated'] = gettime('Y-m-d H:i:s');
$temp = Eresus_CMS::getLegacyKernel()->sections->get("(`name`='" . $item['name'] .
"') AND (`owner`='" . $item['owner'] . "')");
if (count($temp) == 0)
{
Eresus_CMS::getLegacyKernel()->sections->add($item);
dbReorderItems('pages', "`owner`='".arg('owner', 'int')."'");
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
}
else
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf(errItemWithSameName, $item['name']));
saveRequest();
HTTP::redirect(Eresus_CMS::getLegacyKernel()->request['referer']);
}
} | php | function insert()
{
$item = array();
$item['owner'] = arg('owner', 'int');
$item['name'] = arg('name', '/[^a-z0-9_]/i');
$item['title'] = arg('title', 'dbsafe');
$item['caption'] = arg('caption', 'dbsafe');
$item['description'] = arg('description', 'dbsafe');
$item['hint'] = arg('hint', 'dbsafe');
$item['keywords'] = arg('keywords', 'dbsafe');
$item['template'] = arg('template', 'dbsafe');
$item['type'] = arg('type', 'dbsafe');
$item['active'] = arg('active', 'int');
$item['visible'] = arg('visible', 'int');
$item['access'] = arg('access', 'int');
$item['position'] = arg('position', 'int');
$item['options'] = arg('options');
$item['created'] = $item['updated'] = gettime('Y-m-d H:i:s');
$temp = Eresus_CMS::getLegacyKernel()->sections->get("(`name`='" . $item['name'] .
"') AND (`owner`='" . $item['owner'] . "')");
if (count($temp) == 0)
{
Eresus_CMS::getLegacyKernel()->sections->add($item);
dbReorderItems('pages', "`owner`='".arg('owner', 'int')."'");
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
}
else
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf(errItemWithSameName, $item['name']));
saveRequest();
HTTP::redirect(Eresus_CMS::getLegacyKernel()->request['referer']);
}
} | [
"function",
"insert",
"(",
")",
"{",
"$",
"item",
"=",
"array",
"(",
")",
";",
"$",
"item",
"[",
"'owner'",
"]",
"=",
"arg",
"(",
"'owner'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'name'",
"]",
"=",
"arg",
"(",
"'name'",
",",
"'/[^a-z0-9_]/i'",
")",
";",
"$",
"item",
"[",
"'title'",
"]",
"=",
"arg",
"(",
"'title'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'caption'",
"]",
"=",
"arg",
"(",
"'caption'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'description'",
"]",
"=",
"arg",
"(",
"'description'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'hint'",
"]",
"=",
"arg",
"(",
"'hint'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'keywords'",
"]",
"=",
"arg",
"(",
"'keywords'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'template'",
"]",
"=",
"arg",
"(",
"'template'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'type'",
"]",
"=",
"arg",
"(",
"'type'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'active'",
"]",
"=",
"arg",
"(",
"'active'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'visible'",
"]",
"=",
"arg",
"(",
"'visible'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'access'",
"]",
"=",
"arg",
"(",
"'access'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'position'",
"]",
"=",
"arg",
"(",
"'position'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'options'",
"]",
"=",
"arg",
"(",
"'options'",
")",
";",
"$",
"item",
"[",
"'created'",
"]",
"=",
"$",
"item",
"[",
"'updated'",
"]",
"=",
"gettime",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"temp",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"\"(`name`='\"",
".",
"$",
"item",
"[",
"'name'",
"]",
".",
"\"') AND (`owner`='\"",
".",
"$",
"item",
"[",
"'owner'",
"]",
".",
"\"')\"",
")",
";",
"if",
"(",
"count",
"(",
"$",
"temp",
")",
"==",
"0",
")",
"{",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"add",
"(",
"$",
"item",
")",
";",
"dbReorderItems",
"(",
"'pages'",
",",
"\"`owner`='\"",
".",
"arg",
"(",
"'owner'",
",",
"'int'",
")",
".",
"\"'\"",
")",
";",
"HTTP",
"::",
"redirect",
"(",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"url",
"(",
"array",
"(",
"'id'",
"=>",
"''",
")",
")",
")",
";",
"}",
"else",
"{",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"addErrorMessage",
"(",
"sprintf",
"(",
"errItemWithSameName",
",",
"$",
"item",
"[",
"'name'",
"]",
")",
")",
";",
"saveRequest",
"(",
")",
";",
"HTTP",
"::",
"redirect",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'referer'",
"]",
")",
";",
"}",
"}"
] | Запись новой страницы в БД
@return void | [
"Запись",
"новой",
"страницы",
"в",
"БД"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L54-L88 |
Eresus/EresusCMS | src/core/pages.php | TPages.update | function update()
{
$old = Eresus_CMS::getLegacyKernel()->sections->get(arg('update', 'int'));
$item = $old;
$newName = arg('name', '/[^a-z0-9_]/i');
if ($newName)
{
$item['name'] = $newName;
}
$item['title'] = arg('title', 'dbsafe');
$item['caption'] = arg('caption', 'dbsafe');
$item['description'] = arg('description', 'dbsafe');
$item['hint'] = arg('hint', 'dbsafe');
$item['keywords'] = arg('keywords', 'dbsafe');
$item['template'] = arg('template', 'dbsafe');
$item['type'] = arg('type', 'dbsafe');
$item['active'] = arg('active', 'int');
$item['visible'] = arg('visible', 'int');
$item['access'] = arg('access', 'int');
$item['position'] = arg('position', 'int');
$item['options'] = text2array(arg('options'), true);
$temp = Eresus_CMS::getLegacyKernel()->sections->get("(`name`='" . $item['name'] .
"') AND (`owner`='" . $item['owner'] . "' AND `id` <> " . $item['id'] . ")");
if (count($temp) > 0)
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf(errItemWithSameName, $item['name']));
saveRequest();
HTTP::redirect(Eresus_CMS::getLegacyKernel()->request['referer']);
}
if (arg('created'))
{
$item['created'] = arg('created', 'dbsafe');
}
$item['updated'] = arg('updated', 'dbsafe');
if (arg('updatedAuto'))
{
$item['updated'] = gettime('Y-m-d H:i:s');
}
Eresus_CMS::getLegacyKernel()->sections->update($item);
HTTP::redirect(arg('submitURL'));
} | php | function update()
{
$old = Eresus_CMS::getLegacyKernel()->sections->get(arg('update', 'int'));
$item = $old;
$newName = arg('name', '/[^a-z0-9_]/i');
if ($newName)
{
$item['name'] = $newName;
}
$item['title'] = arg('title', 'dbsafe');
$item['caption'] = arg('caption', 'dbsafe');
$item['description'] = arg('description', 'dbsafe');
$item['hint'] = arg('hint', 'dbsafe');
$item['keywords'] = arg('keywords', 'dbsafe');
$item['template'] = arg('template', 'dbsafe');
$item['type'] = arg('type', 'dbsafe');
$item['active'] = arg('active', 'int');
$item['visible'] = arg('visible', 'int');
$item['access'] = arg('access', 'int');
$item['position'] = arg('position', 'int');
$item['options'] = text2array(arg('options'), true);
$temp = Eresus_CMS::getLegacyKernel()->sections->get("(`name`='" . $item['name'] .
"') AND (`owner`='" . $item['owner'] . "' AND `id` <> " . $item['id'] . ")");
if (count($temp) > 0)
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf(errItemWithSameName, $item['name']));
saveRequest();
HTTP::redirect(Eresus_CMS::getLegacyKernel()->request['referer']);
}
if (arg('created'))
{
$item['created'] = arg('created', 'dbsafe');
}
$item['updated'] = arg('updated', 'dbsafe');
if (arg('updatedAuto'))
{
$item['updated'] = gettime('Y-m-d H:i:s');
}
Eresus_CMS::getLegacyKernel()->sections->update($item);
HTTP::redirect(arg('submitURL'));
} | [
"function",
"update",
"(",
")",
"{",
"$",
"old",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"arg",
"(",
"'update'",
",",
"'int'",
")",
")",
";",
"$",
"item",
"=",
"$",
"old",
";",
"$",
"newName",
"=",
"arg",
"(",
"'name'",
",",
"'/[^a-z0-9_]/i'",
")",
";",
"if",
"(",
"$",
"newName",
")",
"{",
"$",
"item",
"[",
"'name'",
"]",
"=",
"$",
"newName",
";",
"}",
"$",
"item",
"[",
"'title'",
"]",
"=",
"arg",
"(",
"'title'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'caption'",
"]",
"=",
"arg",
"(",
"'caption'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'description'",
"]",
"=",
"arg",
"(",
"'description'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'hint'",
"]",
"=",
"arg",
"(",
"'hint'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'keywords'",
"]",
"=",
"arg",
"(",
"'keywords'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'template'",
"]",
"=",
"arg",
"(",
"'template'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'type'",
"]",
"=",
"arg",
"(",
"'type'",
",",
"'dbsafe'",
")",
";",
"$",
"item",
"[",
"'active'",
"]",
"=",
"arg",
"(",
"'active'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'visible'",
"]",
"=",
"arg",
"(",
"'visible'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'access'",
"]",
"=",
"arg",
"(",
"'access'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'position'",
"]",
"=",
"arg",
"(",
"'position'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'options'",
"]",
"=",
"text2array",
"(",
"arg",
"(",
"'options'",
")",
",",
"true",
")",
";",
"$",
"temp",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"\"(`name`='\"",
".",
"$",
"item",
"[",
"'name'",
"]",
".",
"\"') AND (`owner`='\"",
".",
"$",
"item",
"[",
"'owner'",
"]",
".",
"\"' AND `id` <> \"",
".",
"$",
"item",
"[",
"'id'",
"]",
".",
"\")\"",
")",
";",
"if",
"(",
"count",
"(",
"$",
"temp",
")",
">",
"0",
")",
"{",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"addErrorMessage",
"(",
"sprintf",
"(",
"errItemWithSameName",
",",
"$",
"item",
"[",
"'name'",
"]",
")",
")",
";",
"saveRequest",
"(",
")",
";",
"HTTP",
"::",
"redirect",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'referer'",
"]",
")",
";",
"}",
"if",
"(",
"arg",
"(",
"'created'",
")",
")",
"{",
"$",
"item",
"[",
"'created'",
"]",
"=",
"arg",
"(",
"'created'",
",",
"'dbsafe'",
")",
";",
"}",
"$",
"item",
"[",
"'updated'",
"]",
"=",
"arg",
"(",
"'updated'",
",",
"'dbsafe'",
")",
";",
"if",
"(",
"arg",
"(",
"'updatedAuto'",
")",
")",
"{",
"$",
"item",
"[",
"'updated'",
"]",
"=",
"gettime",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"update",
"(",
"$",
"item",
")",
";",
"HTTP",
"::",
"redirect",
"(",
"arg",
"(",
"'submitURL'",
")",
")",
";",
"}"
] | ???
@return void | [
"???"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L95-L141 |
Eresus/EresusCMS | src/core/pages.php | TPages.selectList | private function selectList($skip=0, $owner = 0, $level = 0)
{
$items = Eresus_CMS::getLegacyKernel()->sections->
children($owner, Eresus_CMS::getLegacyKernel()->user['access']);
$result = array(array(), array());
foreach ($items as $item)
{
if ($item['id'] != $skip)
{
$item['caption'] = trim($item['caption']);
if (empty($item['caption']))
{
$item['caption'] = ADM_NA;
}
$result[0][] = $item['id'];
$result[1][] = str_repeat(' ', $level*2).$item['caption'];
$children = $this->selectList($skip, $item['id'], $level+1);
$result[0] = array_merge($result[0], $children[0]);
$result[1] = array_merge($result[1], $children[1]);
}
}
return $result;
} | php | private function selectList($skip=0, $owner = 0, $level = 0)
{
$items = Eresus_CMS::getLegacyKernel()->sections->
children($owner, Eresus_CMS::getLegacyKernel()->user['access']);
$result = array(array(), array());
foreach ($items as $item)
{
if ($item['id'] != $skip)
{
$item['caption'] = trim($item['caption']);
if (empty($item['caption']))
{
$item['caption'] = ADM_NA;
}
$result[0][] = $item['id'];
$result[1][] = str_repeat(' ', $level*2).$item['caption'];
$children = $this->selectList($skip, $item['id'], $level+1);
$result[0] = array_merge($result[0], $children[0]);
$result[1] = array_merge($result[1], $children[1]);
}
}
return $result;
} | [
"private",
"function",
"selectList",
"(",
"$",
"skip",
"=",
"0",
",",
"$",
"owner",
"=",
"0",
",",
"$",
"level",
"=",
"0",
")",
"{",
"$",
"items",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"children",
"(",
"$",
"owner",
",",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"user",
"[",
"'access'",
"]",
")",
";",
"$",
"result",
"=",
"array",
"(",
"array",
"(",
")",
",",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'id'",
"]",
"!=",
"$",
"skip",
")",
"{",
"$",
"item",
"[",
"'caption'",
"]",
"=",
"trim",
"(",
"$",
"item",
"[",
"'caption'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"item",
"[",
"'caption'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'caption'",
"]",
"=",
"ADM_NA",
";",
"}",
"$",
"result",
"[",
"0",
"]",
"[",
"]",
"=",
"$",
"item",
"[",
"'id'",
"]",
";",
"$",
"result",
"[",
"1",
"]",
"[",
"]",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"level",
"*",
"2",
")",
".",
"$",
"item",
"[",
"'caption'",
"]",
";",
"$",
"children",
"=",
"$",
"this",
"->",
"selectList",
"(",
"$",
"skip",
",",
"$",
"item",
"[",
"'id'",
"]",
",",
"$",
"level",
"+",
"1",
")",
";",
"$",
"result",
"[",
"0",
"]",
"=",
"array_merge",
"(",
"$",
"result",
"[",
"0",
"]",
",",
"$",
"children",
"[",
"0",
"]",
")",
";",
"$",
"result",
"[",
"1",
"]",
"=",
"array_merge",
"(",
"$",
"result",
"[",
"1",
"]",
",",
"$",
"children",
"[",
"1",
"]",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | ???
@param $skip
@param $owner
@param $level
@return string | [
"???"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L151-L173 |
Eresus/EresusCMS | src/core/pages.php | TPages.moveUp | private function moveUp()
{
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
dbReorderItems('pages', "`owner`='".$item['owner']."'");
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
if ($item['position'] > 0)
{
$temp = Eresus_CMS::getLegacyKernel()->sections->get("(`owner`='".$item['owner'].
"') AND (`position`='".
($item['position']-1)."')");
if (count($temp))
{
$temp = $temp[0];
$item['position']--;
$temp['position']++;
Eresus_CMS::getLegacyKernel()->sections->update($item);
Eresus_CMS::getLegacyKernel()->sections->update($temp);
}
}
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
} | php | private function moveUp()
{
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
dbReorderItems('pages', "`owner`='".$item['owner']."'");
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
if ($item['position'] > 0)
{
$temp = Eresus_CMS::getLegacyKernel()->sections->get("(`owner`='".$item['owner'].
"') AND (`position`='".
($item['position']-1)."')");
if (count($temp))
{
$temp = $temp[0];
$item['position']--;
$temp['position']++;
Eresus_CMS::getLegacyKernel()->sections->update($item);
Eresus_CMS::getLegacyKernel()->sections->update($temp);
}
}
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
} | [
"private",
"function",
"moveUp",
"(",
")",
"{",
"$",
"item",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"arg",
"(",
"'id'",
",",
"'int'",
")",
")",
";",
"dbReorderItems",
"(",
"'pages'",
",",
"\"`owner`='\"",
".",
"$",
"item",
"[",
"'owner'",
"]",
".",
"\"'\"",
")",
";",
"$",
"item",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"arg",
"(",
"'id'",
",",
"'int'",
")",
")",
";",
"if",
"(",
"$",
"item",
"[",
"'position'",
"]",
">",
"0",
")",
"{",
"$",
"temp",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"\"(`owner`='\"",
".",
"$",
"item",
"[",
"'owner'",
"]",
".",
"\"') AND (`position`='\"",
".",
"(",
"$",
"item",
"[",
"'position'",
"]",
"-",
"1",
")",
".",
"\"')\"",
")",
";",
"if",
"(",
"count",
"(",
"$",
"temp",
")",
")",
"{",
"$",
"temp",
"=",
"$",
"temp",
"[",
"0",
"]",
";",
"$",
"item",
"[",
"'position'",
"]",
"--",
";",
"$",
"temp",
"[",
"'position'",
"]",
"++",
";",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"update",
"(",
"$",
"item",
")",
";",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"update",
"(",
"$",
"temp",
")",
";",
"}",
"}",
"HTTP",
"::",
"redirect",
"(",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"url",
"(",
"array",
"(",
"'id'",
"=>",
"''",
")",
")",
")",
";",
"}"
] | Функция перемещает страницу вверх в списке
@return void | [
"Функция",
"перемещает",
"страницу",
"вверх",
"в",
"списке"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L179-L199 |
Eresus/EresusCMS | src/core/pages.php | TPages.move | private function move()
{
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
if (!is_null(arg('to')))
{
$item['owner'] = arg('to', 'int');
$item['position'] = count(Eresus_CMS::getLegacyKernel()->sections->children($item['owner']));
/* Проверяем, нет ли в разделе назначения раздела с таким же именем */
$q = Eresus_DB::getHandler()->createSelectQuery();
$e = $q->expr;
$q->select($q->alias($e->count('id'), 'count'));
$q->from('pages');
$q->where($e->lAnd(
$e->eq('owner', $q->bindValue($item['owner'], null, PDO::PARAM_INT)),
$e->eq('name', $q->bindValue($item['name']))
));
$count = $q->fetch();
if ($count['count'])
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
'В разделе назначения уже есть раздел с таким же именем!');
HTTP::goback();
}
Eresus_CMS::getLegacyKernel()->sections->update($item);
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
}
else
{
$select = $this->selectList($item['id']);
array_unshift($select[0], 0);
array_unshift($select[1], admPagesRoot);
$form = array(
'name' => 'MoveForm',
'caption' => admPagesMove,
'fields' => array(
array('type'=>'hidden', 'name'=>'mod', 'value' => 'pages'),
array('type'=>'hidden', 'name'=>'action', 'value' => 'move'),
array('type'=>'hidden', 'name'=>'id', 'value' => $item['id']),
array('type'=>'select', 'label'=>strMove.' "<b>'.$item['caption'].'</b>" в',
'name'=>'to', 'items'=>$select[1], 'values'=>$select[0], 'value' => $item['owner']),
),
'buttons' => array('ok', 'cancel'),
);
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = $page->renderForm($form);
return $result;
}
return '';
} | php | private function move()
{
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
if (!is_null(arg('to')))
{
$item['owner'] = arg('to', 'int');
$item['position'] = count(Eresus_CMS::getLegacyKernel()->sections->children($item['owner']));
/* Проверяем, нет ли в разделе назначения раздела с таким же именем */
$q = Eresus_DB::getHandler()->createSelectQuery();
$e = $q->expr;
$q->select($q->alias($e->count('id'), 'count'));
$q->from('pages');
$q->where($e->lAnd(
$e->eq('owner', $q->bindValue($item['owner'], null, PDO::PARAM_INT)),
$e->eq('name', $q->bindValue($item['name']))
));
$count = $q->fetch();
if ($count['count'])
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
'В разделе назначения уже есть раздел с таким же именем!');
HTTP::goback();
}
Eresus_CMS::getLegacyKernel()->sections->update($item);
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
}
else
{
$select = $this->selectList($item['id']);
array_unshift($select[0], 0);
array_unshift($select[1], admPagesRoot);
$form = array(
'name' => 'MoveForm',
'caption' => admPagesMove,
'fields' => array(
array('type'=>'hidden', 'name'=>'mod', 'value' => 'pages'),
array('type'=>'hidden', 'name'=>'action', 'value' => 'move'),
array('type'=>'hidden', 'name'=>'id', 'value' => $item['id']),
array('type'=>'select', 'label'=>strMove.' "<b>'.$item['caption'].'</b>" в',
'name'=>'to', 'items'=>$select[1], 'values'=>$select[0], 'value' => $item['owner']),
),
'buttons' => array('ok', 'cancel'),
);
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = $page->renderForm($form);
return $result;
}
return '';
} | [
"private",
"function",
"move",
"(",
")",
"{",
"$",
"item",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"arg",
"(",
"'id'",
",",
"'int'",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"arg",
"(",
"'to'",
")",
")",
")",
"{",
"$",
"item",
"[",
"'owner'",
"]",
"=",
"arg",
"(",
"'to'",
",",
"'int'",
")",
";",
"$",
"item",
"[",
"'position'",
"]",
"=",
"count",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"children",
"(",
"$",
"item",
"[",
"'owner'",
"]",
")",
")",
";",
"/* Проверяем, нет ли в разделе назначения раздела с таким же именем */",
"$",
"q",
"=",
"Eresus_DB",
"::",
"getHandler",
"(",
")",
"->",
"createSelectQuery",
"(",
")",
";",
"$",
"e",
"=",
"$",
"q",
"->",
"expr",
";",
"$",
"q",
"->",
"select",
"(",
"$",
"q",
"->",
"alias",
"(",
"$",
"e",
"->",
"count",
"(",
"'id'",
")",
",",
"'count'",
")",
")",
";",
"$",
"q",
"->",
"from",
"(",
"'pages'",
")",
";",
"$",
"q",
"->",
"where",
"(",
"$",
"e",
"->",
"lAnd",
"(",
"$",
"e",
"->",
"eq",
"(",
"'owner'",
",",
"$",
"q",
"->",
"bindValue",
"(",
"$",
"item",
"[",
"'owner'",
"]",
",",
"null",
",",
"PDO",
"::",
"PARAM_INT",
")",
")",
",",
"$",
"e",
"->",
"eq",
"(",
"'name'",
",",
"$",
"q",
"->",
"bindValue",
"(",
"$",
"item",
"[",
"'name'",
"]",
")",
")",
")",
")",
";",
"$",
"count",
"=",
"$",
"q",
"->",
"fetch",
"(",
")",
";",
"if",
"(",
"$",
"count",
"[",
"'count'",
"]",
")",
"{",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"addErrorMessage",
"(",
"'В разделе назначения уже есть раздел с таким же именем!');",
"",
"",
"HTTP",
"::",
"goback",
"(",
")",
";",
"}",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"update",
"(",
"$",
"item",
")",
";",
"HTTP",
"::",
"redirect",
"(",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"url",
"(",
"array",
"(",
"'id'",
"=>",
"''",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"selectList",
"(",
"$",
"item",
"[",
"'id'",
"]",
")",
";",
"array_unshift",
"(",
"$",
"select",
"[",
"0",
"]",
",",
"0",
")",
";",
"array_unshift",
"(",
"$",
"select",
"[",
"1",
"]",
",",
"admPagesRoot",
")",
";",
"$",
"form",
"=",
"array",
"(",
"'name'",
"=>",
"'MoveForm'",
",",
"'caption'",
"=>",
"admPagesMove",
",",
"'fields'",
"=>",
"array",
"(",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'mod'",
",",
"'value'",
"=>",
"'pages'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'action'",
",",
"'value'",
"=>",
"'move'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'id'",
",",
"'value'",
"=>",
"$",
"item",
"[",
"'id'",
"]",
")",
",",
"array",
"(",
"'type'",
"=>",
"'select'",
",",
"'label'",
"=>",
"strMove",
".",
"' \"<b>'",
".",
"$",
"item",
"[",
"'caption'",
"]",
".",
"'</b>\" в',",
"",
"'name'",
"=>",
"'to'",
",",
"'items'",
"=>",
"$",
"select",
"[",
"1",
"]",
",",
"'values'",
"=>",
"$",
"select",
"[",
"0",
"]",
",",
"'value'",
"=>",
"$",
"item",
"[",
"'owner'",
"]",
")",
",",
")",
",",
"'buttons'",
"=>",
"array",
"(",
"'ok'",
",",
"'cancel'",
")",
",",
")",
";",
"/** @var TAdminUI $page */",
"$",
"page",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"result",
"=",
"$",
"page",
"->",
"renderForm",
"(",
"$",
"form",
")",
";",
"return",
"$",
"result",
";",
"}",
"return",
"''",
";",
"}"
] | Перемещает страницу из одной ветки в другую
@return string | [
"Перемещает",
"страницу",
"из",
"одной",
"ветки",
"в",
"другую"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L233-L284 |
Eresus/EresusCMS | src/core/pages.php | TPages.delete | private function delete()
{
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
Eresus_CMS::getLegacyKernel()->sections->delete(arg('id', 'int'));
dbReorderItems('pages', "`owner`='".$item['owner']."'");
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
} | php | private function delete()
{
$item = Eresus_CMS::getLegacyKernel()->sections->get(arg('id', 'int'));
Eresus_CMS::getLegacyKernel()->sections->delete(arg('id', 'int'));
dbReorderItems('pages', "`owner`='".$item['owner']."'");
HTTP::redirect(Eresus_Kernel::app()->getPage()->url(array('id'=>'')));
} | [
"private",
"function",
"delete",
"(",
")",
"{",
"$",
"item",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"arg",
"(",
"'id'",
",",
"'int'",
")",
")",
";",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"delete",
"(",
"arg",
"(",
"'id'",
",",
"'int'",
")",
")",
";",
"dbReorderItems",
"(",
"'pages'",
",",
"\"`owner`='\"",
".",
"$",
"item",
"[",
"'owner'",
"]",
".",
"\"'\"",
")",
";",
"HTTP",
"::",
"redirect",
"(",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"url",
"(",
"array",
"(",
"'id'",
"=>",
"''",
")",
")",
")",
";",
"}"
] | Удаляет страницу
@return void | [
"Удаляет",
"страницу"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L290-L296 |
Eresus/EresusCMS | src/core/pages.php | TPages.loadContentTypes | private function loadContentTypes()
{
$result[0] = array();
$result[1] = array();
/*
* Стандартные типы контента
*/
$result[0] []= admPagesContentDefault;
$result[1] []= 'default';
$result[0] []= admPagesContentList;
$result[1] []= 'list';
$result[0] []= admPagesContentURL;
$result[1] []= 'url';
/*
* Типы контентов из плагинов
*/
$plugins = Eresus_Plugin_Registry::getInstance();
foreach ($plugins->getEnabled() as $plugin)
{
if (
$plugin instanceof ContentPlugin ||
$plugin instanceof TContentPlugin
)
{
$result[0][] = $plugin->title;
$result[1][] = $plugin->name;
}
}
return $result;
} | php | private function loadContentTypes()
{
$result[0] = array();
$result[1] = array();
/*
* Стандартные типы контента
*/
$result[0] []= admPagesContentDefault;
$result[1] []= 'default';
$result[0] []= admPagesContentList;
$result[1] []= 'list';
$result[0] []= admPagesContentURL;
$result[1] []= 'url';
/*
* Типы контентов из плагинов
*/
$plugins = Eresus_Plugin_Registry::getInstance();
foreach ($plugins->getEnabled() as $plugin)
{
if (
$plugin instanceof ContentPlugin ||
$plugin instanceof TContentPlugin
)
{
$result[0][] = $plugin->title;
$result[1][] = $plugin->name;
}
}
return $result;
} | [
"private",
"function",
"loadContentTypes",
"(",
")",
"{",
"$",
"result",
"[",
"0",
"]",
"=",
"array",
"(",
")",
";",
"$",
"result",
"[",
"1",
"]",
"=",
"array",
"(",
")",
";",
"/*\n * Стандартные типы контента\n */",
"$",
"result",
"[",
"0",
"]",
"[",
"]",
"=",
"admPagesContentDefault",
";",
"$",
"result",
"[",
"1",
"]",
"[",
"]",
"=",
"'default'",
";",
"$",
"result",
"[",
"0",
"]",
"[",
"]",
"=",
"admPagesContentList",
";",
"$",
"result",
"[",
"1",
"]",
"[",
"]",
"=",
"'list'",
";",
"$",
"result",
"[",
"0",
"]",
"[",
"]",
"=",
"admPagesContentURL",
";",
"$",
"result",
"[",
"1",
"]",
"[",
"]",
"=",
"'url'",
";",
"/*\n * Типы контентов из плагинов\n */",
"$",
"plugins",
"=",
"Eresus_Plugin_Registry",
"::",
"getInstance",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"->",
"getEnabled",
"(",
")",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"instanceof",
"ContentPlugin",
"||",
"$",
"plugin",
"instanceof",
"TContentPlugin",
")",
"{",
"$",
"result",
"[",
"0",
"]",
"[",
"]",
"=",
"$",
"plugin",
"->",
"title",
";",
"$",
"result",
"[",
"1",
"]",
"[",
"]",
"=",
"$",
"plugin",
"->",
"name",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Возвращает список типов контента в виде, пригодном для построения выпадающего списка
@return array | [
"Возвращает",
"список",
"типов",
"контента",
"в",
"виде",
"пригодном",
"для",
"построения",
"выпадающего",
"списка"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L303-L337 |
Eresus/EresusCMS | src/core/pages.php | TPages.loadTemplates | function loadTemplates()
{
$result[0] = array();
$result[1] = array();
$templates = Templates::getInstance();
$list = $templates->enum();
$result[0]= array_values($list);
$result[1]= array_keys($list);
return $result;
} | php | function loadTemplates()
{
$result[0] = array();
$result[1] = array();
$templates = Templates::getInstance();
$list = $templates->enum();
$result[0]= array_values($list);
$result[1]= array_keys($list);
return $result;
} | [
"function",
"loadTemplates",
"(",
")",
"{",
"$",
"result",
"[",
"0",
"]",
"=",
"array",
"(",
")",
";",
"$",
"result",
"[",
"1",
"]",
"=",
"array",
"(",
")",
";",
"$",
"templates",
"=",
"Templates",
"::",
"getInstance",
"(",
")",
";",
"$",
"list",
"=",
"$",
"templates",
"->",
"enum",
"(",
")",
";",
"$",
"result",
"[",
"0",
"]",
"=",
"array_values",
"(",
"$",
"list",
")",
";",
"$",
"result",
"[",
"1",
"]",
"=",
"array_keys",
"(",
"$",
"list",
")",
";",
"return",
"$",
"result",
";",
"}"
] | ???
@return array | [
"???"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L343-L352 |
Eresus/EresusCMS | src/core/pages.php | TPages.create | function create()
{
$content = $this->loadContentTypes();
$templates = $this->loadTemplates();
restoreRequest();
$form = array (
'name' => 'createPage',
'caption' => strAdd,
'width' => '600px',
'fields' => array (
array ('type' => 'hidden','name'=>'owner','value'=>arg('owner', 'int')),
array ('type' => 'hidden','name'=>'action', 'value'=>'insert'),
array ('type' => 'edit','name' => 'name','label' => admPagesName,'width' => '150px',
'maxlength' => '32', 'pattern'=>'/^[a-z0-9_]+$/i', 'errormsg'=>admPagesNameInvalid),
array ('type' => 'edit','name' => 'title','label' => admPagesTitle,'width' => '100%',
'pattern'=>'/.+/', 'errormsg'=>admPagesTitleInvalid),
array ('type' => 'edit','name' => 'caption','label' => admPagesCaption,'width' => '100%',
'maxlength' => '64', 'pattern'=>'/.+/', 'errormsg'=>admPagesCaptionInvalid),
array ('type' => 'edit','name' => 'hint','label' => admPagesHint,'width' => '100%'),
array ('type' => 'edit','name' => 'description','label' => admPagesDescription,
'width' => '100%'),
array ('type' => 'edit','name' => 'keywords','label' => admPagesKeywords,'width' => '100%'),
array ('type' => 'select','name' => 'template','label' => admPagesTemplate,
'items' => $templates[0], 'values' => $templates[1], 'default'=>pageTemplateDefault),
array ('type' => 'select','name' => 'type','label' => admPagesContentType,
'items' => $content[0], 'values' => $content[1], 'default'=>contentTypeDefault),
array ('type' => 'checkbox','name' => 'active','label' => admPagesActive, 'default'=>true),
array ('type' => 'checkbox','name' => 'visible','label' => admPagesVisible,
'default'=>true),
array ('type' => 'select','name' => 'access','label' => admAccessLevel,'access' => ADMIN,
'values'=>array(ADMIN,EDITOR,USER,GUEST),
'items' => array (ACCESSLEVEL2,ACCESSLEVEL3,ACCESSLEVEL4,ACCESSLEVEL5),
'default' => GUEST),
array ('type' => 'edit','name' => 'position','label' => admPosition,'access' => ADMIN,
'width' => '4em','maxlength' => '5'),
array ('type' => 'memo','name' => 'options','label' => admPagesOptions,'height' => '5')
),
'buttons' => array('ok', 'cancel'),
);
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = $page->renderForm($form, Eresus_CMS::getLegacyKernel()->request['arg']);
return $result;
} | php | function create()
{
$content = $this->loadContentTypes();
$templates = $this->loadTemplates();
restoreRequest();
$form = array (
'name' => 'createPage',
'caption' => strAdd,
'width' => '600px',
'fields' => array (
array ('type' => 'hidden','name'=>'owner','value'=>arg('owner', 'int')),
array ('type' => 'hidden','name'=>'action', 'value'=>'insert'),
array ('type' => 'edit','name' => 'name','label' => admPagesName,'width' => '150px',
'maxlength' => '32', 'pattern'=>'/^[a-z0-9_]+$/i', 'errormsg'=>admPagesNameInvalid),
array ('type' => 'edit','name' => 'title','label' => admPagesTitle,'width' => '100%',
'pattern'=>'/.+/', 'errormsg'=>admPagesTitleInvalid),
array ('type' => 'edit','name' => 'caption','label' => admPagesCaption,'width' => '100%',
'maxlength' => '64', 'pattern'=>'/.+/', 'errormsg'=>admPagesCaptionInvalid),
array ('type' => 'edit','name' => 'hint','label' => admPagesHint,'width' => '100%'),
array ('type' => 'edit','name' => 'description','label' => admPagesDescription,
'width' => '100%'),
array ('type' => 'edit','name' => 'keywords','label' => admPagesKeywords,'width' => '100%'),
array ('type' => 'select','name' => 'template','label' => admPagesTemplate,
'items' => $templates[0], 'values' => $templates[1], 'default'=>pageTemplateDefault),
array ('type' => 'select','name' => 'type','label' => admPagesContentType,
'items' => $content[0], 'values' => $content[1], 'default'=>contentTypeDefault),
array ('type' => 'checkbox','name' => 'active','label' => admPagesActive, 'default'=>true),
array ('type' => 'checkbox','name' => 'visible','label' => admPagesVisible,
'default'=>true),
array ('type' => 'select','name' => 'access','label' => admAccessLevel,'access' => ADMIN,
'values'=>array(ADMIN,EDITOR,USER,GUEST),
'items' => array (ACCESSLEVEL2,ACCESSLEVEL3,ACCESSLEVEL4,ACCESSLEVEL5),
'default' => GUEST),
array ('type' => 'edit','name' => 'position','label' => admPosition,'access' => ADMIN,
'width' => '4em','maxlength' => '5'),
array ('type' => 'memo','name' => 'options','label' => admPagesOptions,'height' => '5')
),
'buttons' => array('ok', 'cancel'),
);
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = $page->renderForm($form, Eresus_CMS::getLegacyKernel()->request['arg']);
return $result;
} | [
"function",
"create",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"loadContentTypes",
"(",
")",
";",
"$",
"templates",
"=",
"$",
"this",
"->",
"loadTemplates",
"(",
")",
";",
"restoreRequest",
"(",
")",
";",
"$",
"form",
"=",
"array",
"(",
"'name'",
"=>",
"'createPage'",
",",
"'caption'",
"=>",
"strAdd",
",",
"'width'",
"=>",
"'600px'",
",",
"'fields'",
"=>",
"array",
"(",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'owner'",
",",
"'value'",
"=>",
"arg",
"(",
"'owner'",
",",
"'int'",
")",
")",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'action'",
",",
"'value'",
"=>",
"'insert'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'name'",
",",
"'label'",
"=>",
"admPagesName",
",",
"'width'",
"=>",
"'150px'",
",",
"'maxlength'",
"=>",
"'32'",
",",
"'pattern'",
"=>",
"'/^[a-z0-9_]+$/i'",
",",
"'errormsg'",
"=>",
"admPagesNameInvalid",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'title'",
",",
"'label'",
"=>",
"admPagesTitle",
",",
"'width'",
"=>",
"'100%'",
",",
"'pattern'",
"=>",
"'/.+/'",
",",
"'errormsg'",
"=>",
"admPagesTitleInvalid",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'caption'",
",",
"'label'",
"=>",
"admPagesCaption",
",",
"'width'",
"=>",
"'100%'",
",",
"'maxlength'",
"=>",
"'64'",
",",
"'pattern'",
"=>",
"'/.+/'",
",",
"'errormsg'",
"=>",
"admPagesCaptionInvalid",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'hint'",
",",
"'label'",
"=>",
"admPagesHint",
",",
"'width'",
"=>",
"'100%'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'description'",
",",
"'label'",
"=>",
"admPagesDescription",
",",
"'width'",
"=>",
"'100%'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'keywords'",
",",
"'label'",
"=>",
"admPagesKeywords",
",",
"'width'",
"=>",
"'100%'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'select'",
",",
"'name'",
"=>",
"'template'",
",",
"'label'",
"=>",
"admPagesTemplate",
",",
"'items'",
"=>",
"$",
"templates",
"[",
"0",
"]",
",",
"'values'",
"=>",
"$",
"templates",
"[",
"1",
"]",
",",
"'default'",
"=>",
"pageTemplateDefault",
")",
",",
"array",
"(",
"'type'",
"=>",
"'select'",
",",
"'name'",
"=>",
"'type'",
",",
"'label'",
"=>",
"admPagesContentType",
",",
"'items'",
"=>",
"$",
"content",
"[",
"0",
"]",
",",
"'values'",
"=>",
"$",
"content",
"[",
"1",
"]",
",",
"'default'",
"=>",
"contentTypeDefault",
")",
",",
"array",
"(",
"'type'",
"=>",
"'checkbox'",
",",
"'name'",
"=>",
"'active'",
",",
"'label'",
"=>",
"admPagesActive",
",",
"'default'",
"=>",
"true",
")",
",",
"array",
"(",
"'type'",
"=>",
"'checkbox'",
",",
"'name'",
"=>",
"'visible'",
",",
"'label'",
"=>",
"admPagesVisible",
",",
"'default'",
"=>",
"true",
")",
",",
"array",
"(",
"'type'",
"=>",
"'select'",
",",
"'name'",
"=>",
"'access'",
",",
"'label'",
"=>",
"admAccessLevel",
",",
"'access'",
"=>",
"ADMIN",
",",
"'values'",
"=>",
"array",
"(",
"ADMIN",
",",
"EDITOR",
",",
"USER",
",",
"GUEST",
")",
",",
"'items'",
"=>",
"array",
"(",
"ACCESSLEVEL2",
",",
"ACCESSLEVEL3",
",",
"ACCESSLEVEL4",
",",
"ACCESSLEVEL5",
")",
",",
"'default'",
"=>",
"GUEST",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'position'",
",",
"'label'",
"=>",
"admPosition",
",",
"'access'",
"=>",
"ADMIN",
",",
"'width'",
"=>",
"'4em'",
",",
"'maxlength'",
"=>",
"'5'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'memo'",
",",
"'name'",
"=>",
"'options'",
",",
"'label'",
"=>",
"admPagesOptions",
",",
"'height'",
"=>",
"'5'",
")",
")",
",",
"'buttons'",
"=>",
"array",
"(",
"'ok'",
",",
"'cancel'",
")",
",",
")",
";",
"/** @var TAdminUI $page */",
"$",
"page",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"result",
"=",
"$",
"page",
"->",
"renderForm",
"(",
"$",
"form",
",",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'arg'",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Функция выводит форму для добавления новой страницы
@return string | [
"Функция",
"выводит",
"форму",
"для",
"добавления",
"новой",
"страницы"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L358-L402 |
Eresus/EresusCMS | src/core/pages.php | TPages.edit | private function edit($id)
{
$item = Eresus_CMS::getLegacyKernel()->sections->get($id);
$content = $this->loadContentTypes();
$templates = $this->loadTemplates();
$item['options'] = array2text($item['options'], true);
$form['caption'] = $item['caption'];
# Вычисляем адрес страницы
$urlAbs = Eresus_Kernel::app()->getPage()->clientURL($item['id']);
$isMainPage = $item['name'] == 'main' && $item['owner'] == 0;
$form = array(
'name' => 'PageForm',
'caption' => $item['caption'].' ('.$item['name'].')',
'width' => '700px',
'fields' => array (
array ('type' => 'hidden','name' => 'update', 'value'=>$item['id']),
array ('type' => 'edit','name' => 'name','label' => admPagesName,'width' => '150px',
'maxlength' => '32', 'pattern'=>'/^[a-z0-9_]+$/i', 'errormsg'=>admPagesNameInvalid,
'disabled' => $isMainPage),
array ('type' => 'edit','name' => 'title','label' => admPagesTitle,'width' => '100%',
'pattern'=>'/.+/', 'errormsg'=>admPagesTitleInvalid),
array ('type' => 'edit','name' => 'caption','label' => admPagesCaption,
'width' => '100%','maxlength' => '64', 'pattern'=>'/.+/',
'errormsg'=>admPagesCaptionInvalid),
array ('type' => 'edit','name' => 'hint','label' => admPagesHint,'width' => '100%'),
array ('type' => 'edit','name' => 'description','label' => admPagesDescription,
'width' => '100%'),
array ('type' => 'edit','name' => 'keywords','label' => admPagesKeywords,'width' => '100%'),
array ('type' => 'select','name' => 'template','label' => admPagesTemplate,
'items' => $templates[0], 'values' => $templates[1]),
array ('type' => 'select','name' => 'type','label' => admPagesContentType,
'items' => $content[0], 'values' => $content[1]),
array ('type' => 'checkbox','name' => 'active','label' => admPagesActive),
array ('type' => 'checkbox','name' => 'visible','label' => admPagesVisible),
array ('type' => 'select','name' => 'access','label' => admAccessLevel,'access' => ADMIN,
'values'=>array(ADMIN,EDITOR,USER,GUEST),
'items' => array (ACCESSLEVEL2,ACCESSLEVEL3,ACCESSLEVEL4,ACCESSLEVEL5)),
array ('type' => 'edit','name' => 'position','label' => admPosition,'access' => ADMIN,
'width' => '4em','maxlength' => '5'),
array ('type' => 'memo','name' => 'options','label' => admPagesOptions,'height' => '5'),
array ('type' => 'edit','name' => 'created','label' => admPagesCreated,'access' => ADMIN,
'width' => '10em','maxlength' => '19'),
array ('type' => 'edit','name' => 'updated','label' => admPagesUpdated,'access' => ADMIN,
'width' => '10em','maxlength' => '19'),
array ('type' => 'checkbox','name' => 'updatedAuto','label' => admPagesUpdatedAuto,
'default' => true),
array ('type' => 'text',
'value'=>admPagesThisURL.': <a href="'.$urlAbs.'">'.$urlAbs.'</a>'),
),
'buttons' => array('ok', 'apply', 'cancel'),
);
if ($isMainPage)
{
array_unshift($form['fields'],
array('type' => 'hidden', 'name' => 'name', 'value' => 'main'));
}
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = $page->renderForm($form, $item);
return $result;
} | php | private function edit($id)
{
$item = Eresus_CMS::getLegacyKernel()->sections->get($id);
$content = $this->loadContentTypes();
$templates = $this->loadTemplates();
$item['options'] = array2text($item['options'], true);
$form['caption'] = $item['caption'];
# Вычисляем адрес страницы
$urlAbs = Eresus_Kernel::app()->getPage()->clientURL($item['id']);
$isMainPage = $item['name'] == 'main' && $item['owner'] == 0;
$form = array(
'name' => 'PageForm',
'caption' => $item['caption'].' ('.$item['name'].')',
'width' => '700px',
'fields' => array (
array ('type' => 'hidden','name' => 'update', 'value'=>$item['id']),
array ('type' => 'edit','name' => 'name','label' => admPagesName,'width' => '150px',
'maxlength' => '32', 'pattern'=>'/^[a-z0-9_]+$/i', 'errormsg'=>admPagesNameInvalid,
'disabled' => $isMainPage),
array ('type' => 'edit','name' => 'title','label' => admPagesTitle,'width' => '100%',
'pattern'=>'/.+/', 'errormsg'=>admPagesTitleInvalid),
array ('type' => 'edit','name' => 'caption','label' => admPagesCaption,
'width' => '100%','maxlength' => '64', 'pattern'=>'/.+/',
'errormsg'=>admPagesCaptionInvalid),
array ('type' => 'edit','name' => 'hint','label' => admPagesHint,'width' => '100%'),
array ('type' => 'edit','name' => 'description','label' => admPagesDescription,
'width' => '100%'),
array ('type' => 'edit','name' => 'keywords','label' => admPagesKeywords,'width' => '100%'),
array ('type' => 'select','name' => 'template','label' => admPagesTemplate,
'items' => $templates[0], 'values' => $templates[1]),
array ('type' => 'select','name' => 'type','label' => admPagesContentType,
'items' => $content[0], 'values' => $content[1]),
array ('type' => 'checkbox','name' => 'active','label' => admPagesActive),
array ('type' => 'checkbox','name' => 'visible','label' => admPagesVisible),
array ('type' => 'select','name' => 'access','label' => admAccessLevel,'access' => ADMIN,
'values'=>array(ADMIN,EDITOR,USER,GUEST),
'items' => array (ACCESSLEVEL2,ACCESSLEVEL3,ACCESSLEVEL4,ACCESSLEVEL5)),
array ('type' => 'edit','name' => 'position','label' => admPosition,'access' => ADMIN,
'width' => '4em','maxlength' => '5'),
array ('type' => 'memo','name' => 'options','label' => admPagesOptions,'height' => '5'),
array ('type' => 'edit','name' => 'created','label' => admPagesCreated,'access' => ADMIN,
'width' => '10em','maxlength' => '19'),
array ('type' => 'edit','name' => 'updated','label' => admPagesUpdated,'access' => ADMIN,
'width' => '10em','maxlength' => '19'),
array ('type' => 'checkbox','name' => 'updatedAuto','label' => admPagesUpdatedAuto,
'default' => true),
array ('type' => 'text',
'value'=>admPagesThisURL.': <a href="'.$urlAbs.'">'.$urlAbs.'</a>'),
),
'buttons' => array('ok', 'apply', 'cancel'),
);
if ($isMainPage)
{
array_unshift($form['fields'],
array('type' => 'hidden', 'name' => 'name', 'value' => 'main'));
}
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = $page->renderForm($form, $item);
return $result;
} | [
"private",
"function",
"edit",
"(",
"$",
"id",
")",
"{",
"$",
"item",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"$",
"id",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"loadContentTypes",
"(",
")",
";",
"$",
"templates",
"=",
"$",
"this",
"->",
"loadTemplates",
"(",
")",
";",
"$",
"item",
"[",
"'options'",
"]",
"=",
"array2text",
"(",
"$",
"item",
"[",
"'options'",
"]",
",",
"true",
")",
";",
"$",
"form",
"[",
"'caption'",
"]",
"=",
"$",
"item",
"[",
"'caption'",
"]",
";",
"# Вычисляем адрес страницы",
"$",
"urlAbs",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"clientURL",
"(",
"$",
"item",
"[",
"'id'",
"]",
")",
";",
"$",
"isMainPage",
"=",
"$",
"item",
"[",
"'name'",
"]",
"==",
"'main'",
"&&",
"$",
"item",
"[",
"'owner'",
"]",
"==",
"0",
";",
"$",
"form",
"=",
"array",
"(",
"'name'",
"=>",
"'PageForm'",
",",
"'caption'",
"=>",
"$",
"item",
"[",
"'caption'",
"]",
".",
"' ('",
".",
"$",
"item",
"[",
"'name'",
"]",
".",
"')'",
",",
"'width'",
"=>",
"'700px'",
",",
"'fields'",
"=>",
"array",
"(",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'update'",
",",
"'value'",
"=>",
"$",
"item",
"[",
"'id'",
"]",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'name'",
",",
"'label'",
"=>",
"admPagesName",
",",
"'width'",
"=>",
"'150px'",
",",
"'maxlength'",
"=>",
"'32'",
",",
"'pattern'",
"=>",
"'/^[a-z0-9_]+$/i'",
",",
"'errormsg'",
"=>",
"admPagesNameInvalid",
",",
"'disabled'",
"=>",
"$",
"isMainPage",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'title'",
",",
"'label'",
"=>",
"admPagesTitle",
",",
"'width'",
"=>",
"'100%'",
",",
"'pattern'",
"=>",
"'/.+/'",
",",
"'errormsg'",
"=>",
"admPagesTitleInvalid",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'caption'",
",",
"'label'",
"=>",
"admPagesCaption",
",",
"'width'",
"=>",
"'100%'",
",",
"'maxlength'",
"=>",
"'64'",
",",
"'pattern'",
"=>",
"'/.+/'",
",",
"'errormsg'",
"=>",
"admPagesCaptionInvalid",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'hint'",
",",
"'label'",
"=>",
"admPagesHint",
",",
"'width'",
"=>",
"'100%'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'description'",
",",
"'label'",
"=>",
"admPagesDescription",
",",
"'width'",
"=>",
"'100%'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'keywords'",
",",
"'label'",
"=>",
"admPagesKeywords",
",",
"'width'",
"=>",
"'100%'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'select'",
",",
"'name'",
"=>",
"'template'",
",",
"'label'",
"=>",
"admPagesTemplate",
",",
"'items'",
"=>",
"$",
"templates",
"[",
"0",
"]",
",",
"'values'",
"=>",
"$",
"templates",
"[",
"1",
"]",
")",
",",
"array",
"(",
"'type'",
"=>",
"'select'",
",",
"'name'",
"=>",
"'type'",
",",
"'label'",
"=>",
"admPagesContentType",
",",
"'items'",
"=>",
"$",
"content",
"[",
"0",
"]",
",",
"'values'",
"=>",
"$",
"content",
"[",
"1",
"]",
")",
",",
"array",
"(",
"'type'",
"=>",
"'checkbox'",
",",
"'name'",
"=>",
"'active'",
",",
"'label'",
"=>",
"admPagesActive",
")",
",",
"array",
"(",
"'type'",
"=>",
"'checkbox'",
",",
"'name'",
"=>",
"'visible'",
",",
"'label'",
"=>",
"admPagesVisible",
")",
",",
"array",
"(",
"'type'",
"=>",
"'select'",
",",
"'name'",
"=>",
"'access'",
",",
"'label'",
"=>",
"admAccessLevel",
",",
"'access'",
"=>",
"ADMIN",
",",
"'values'",
"=>",
"array",
"(",
"ADMIN",
",",
"EDITOR",
",",
"USER",
",",
"GUEST",
")",
",",
"'items'",
"=>",
"array",
"(",
"ACCESSLEVEL2",
",",
"ACCESSLEVEL3",
",",
"ACCESSLEVEL4",
",",
"ACCESSLEVEL5",
")",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'position'",
",",
"'label'",
"=>",
"admPosition",
",",
"'access'",
"=>",
"ADMIN",
",",
"'width'",
"=>",
"'4em'",
",",
"'maxlength'",
"=>",
"'5'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'memo'",
",",
"'name'",
"=>",
"'options'",
",",
"'label'",
"=>",
"admPagesOptions",
",",
"'height'",
"=>",
"'5'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'created'",
",",
"'label'",
"=>",
"admPagesCreated",
",",
"'access'",
"=>",
"ADMIN",
",",
"'width'",
"=>",
"'10em'",
",",
"'maxlength'",
"=>",
"'19'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'edit'",
",",
"'name'",
"=>",
"'updated'",
",",
"'label'",
"=>",
"admPagesUpdated",
",",
"'access'",
"=>",
"ADMIN",
",",
"'width'",
"=>",
"'10em'",
",",
"'maxlength'",
"=>",
"'19'",
")",
",",
"array",
"(",
"'type'",
"=>",
"'checkbox'",
",",
"'name'",
"=>",
"'updatedAuto'",
",",
"'label'",
"=>",
"admPagesUpdatedAuto",
",",
"'default'",
"=>",
"true",
")",
",",
"array",
"(",
"'type'",
"=>",
"'text'",
",",
"'value'",
"=>",
"admPagesThisURL",
".",
"': <a href=\"'",
".",
"$",
"urlAbs",
".",
"'\">'",
".",
"$",
"urlAbs",
".",
"'</a>'",
")",
",",
")",
",",
"'buttons'",
"=>",
"array",
"(",
"'ok'",
",",
"'apply'",
",",
"'cancel'",
")",
",",
")",
";",
"if",
"(",
"$",
"isMainPage",
")",
"{",
"array_unshift",
"(",
"$",
"form",
"[",
"'fields'",
"]",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'name'",
",",
"'value'",
"=>",
"'main'",
")",
")",
";",
"}",
"/** @var TAdminUI $page */",
"$",
"page",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"result",
"=",
"$",
"page",
"->",
"renderForm",
"(",
"$",
"form",
",",
"$",
"item",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Возвращает диалог изменения свойств раздела
@param int $id
@return string HTML | [
"Возвращает",
"диалог",
"изменения",
"свойств",
"раздела"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L410-L474 |
Eresus/EresusCMS | src/core/pages.php | TPages.sectionIndexBranch | function sectionIndexBranch($owner=0, $level=0)
{
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = array();
$items = Eresus_CMS::getLegacyKernel()->sections->children($owner,
Eresus_CMS::getLegacyKernel()->user['auth'] ?
Eresus_CMS::getLegacyKernel()->user['access'] : GUEST);
for ($i=0; $i<count($items); $i++)
{
$content_type = isset($this->cache['content_types'][$items[$i]['type']]) ?
$this->cache['content_types'][$items[$i]['type']] :
'<span class="admError">'.sprintf(errContentType, $items[$i]['type']).'</span>';
$row = array();
$row[] = array('text' => $items[$i]['caption'], 'style'=>"padding-left: {$level}em;",
'href'=>Eresus_CMS::getLegacyKernel()->root.'admin.php?mod=content&section='.
$items[$i]['id']);
$row[] = $items[$i]['name'];
$row[] = array('text' => $content_type, 'align' => 'center');
$row[] = array('text' => constant('ACCESSLEVEL'.$items[$i]['access']), 'align' => 'center');
if ($items[$i]['name'] == 'main' && $items[$i]['owner'] == 0)
{
$root = Eresus_CMS::getLegacyKernel()->root.'admin.php?mod=pages&';
$controls =
$page->control('setup', $root.'id=%d').' '.
$page->control('position',
array($root.'action=up&id=%d', $root.'action=down&id=%d')).' '.
$page->control('add', $root.'action=create&owner=%d');
}
else
{
$controls = $this->cache['index_controls'];
}
$row[] = sprintf($controls, $items[$i]['id'], $items[$i]['id'], $items[$i]['id'],
$items[$i]['id'], $items[$i]['id'], $items[$i]['id']);
$result[] = $row;
$children = $this->sectionIndexBranch($items[$i]['id'], $level+1);
if (count($children))
{
$result = array_merge($result, $children);
}
}
return $result;
} | php | function sectionIndexBranch($owner=0, $level=0)
{
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = array();
$items = Eresus_CMS::getLegacyKernel()->sections->children($owner,
Eresus_CMS::getLegacyKernel()->user['auth'] ?
Eresus_CMS::getLegacyKernel()->user['access'] : GUEST);
for ($i=0; $i<count($items); $i++)
{
$content_type = isset($this->cache['content_types'][$items[$i]['type']]) ?
$this->cache['content_types'][$items[$i]['type']] :
'<span class="admError">'.sprintf(errContentType, $items[$i]['type']).'</span>';
$row = array();
$row[] = array('text' => $items[$i]['caption'], 'style'=>"padding-left: {$level}em;",
'href'=>Eresus_CMS::getLegacyKernel()->root.'admin.php?mod=content&section='.
$items[$i]['id']);
$row[] = $items[$i]['name'];
$row[] = array('text' => $content_type, 'align' => 'center');
$row[] = array('text' => constant('ACCESSLEVEL'.$items[$i]['access']), 'align' => 'center');
if ($items[$i]['name'] == 'main' && $items[$i]['owner'] == 0)
{
$root = Eresus_CMS::getLegacyKernel()->root.'admin.php?mod=pages&';
$controls =
$page->control('setup', $root.'id=%d').' '.
$page->control('position',
array($root.'action=up&id=%d', $root.'action=down&id=%d')).' '.
$page->control('add', $root.'action=create&owner=%d');
}
else
{
$controls = $this->cache['index_controls'];
}
$row[] = sprintf($controls, $items[$i]['id'], $items[$i]['id'], $items[$i]['id'],
$items[$i]['id'], $items[$i]['id'], $items[$i]['id']);
$result[] = $row;
$children = $this->sectionIndexBranch($items[$i]['id'], $level+1);
if (count($children))
{
$result = array_merge($result, $children);
}
}
return $result;
} | [
"function",
"sectionIndexBranch",
"(",
"$",
"owner",
"=",
"0",
",",
"$",
"level",
"=",
"0",
")",
"{",
"/** @var TAdminUI $page */",
"$",
"page",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"items",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"children",
"(",
"$",
"owner",
",",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"user",
"[",
"'auth'",
"]",
"?",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"user",
"[",
"'access'",
"]",
":",
"GUEST",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"items",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"content_type",
"=",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"'content_types'",
"]",
"[",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'type'",
"]",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"'content_types'",
"]",
"[",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'type'",
"]",
"]",
":",
"'<span class=\"admError\">'",
".",
"sprintf",
"(",
"errContentType",
",",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'type'",
"]",
")",
".",
"'</span>'",
";",
"$",
"row",
"=",
"array",
"(",
")",
";",
"$",
"row",
"[",
"]",
"=",
"array",
"(",
"'text'",
"=>",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'caption'",
"]",
",",
"'style'",
"=>",
"\"padding-left: {$level}em;\"",
",",
"'href'",
"=>",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin.php?mod=content&section='",
".",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
")",
";",
"$",
"row",
"[",
"]",
"=",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'name'",
"]",
";",
"$",
"row",
"[",
"]",
"=",
"array",
"(",
"'text'",
"=>",
"$",
"content_type",
",",
"'align'",
"=>",
"'center'",
")",
";",
"$",
"row",
"[",
"]",
"=",
"array",
"(",
"'text'",
"=>",
"constant",
"(",
"'ACCESSLEVEL'",
".",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'access'",
"]",
")",
",",
"'align'",
"=>",
"'center'",
")",
";",
"if",
"(",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'name'",
"]",
"==",
"'main'",
"&&",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'owner'",
"]",
"==",
"0",
")",
"{",
"$",
"root",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin.php?mod=pages&'",
";",
"$",
"controls",
"=",
"$",
"page",
"->",
"control",
"(",
"'setup'",
",",
"$",
"root",
".",
"'id=%d'",
")",
".",
"' '",
".",
"$",
"page",
"->",
"control",
"(",
"'position'",
",",
"array",
"(",
"$",
"root",
".",
"'action=up&id=%d'",
",",
"$",
"root",
".",
"'action=down&id=%d'",
")",
")",
".",
"' '",
".",
"$",
"page",
"->",
"control",
"(",
"'add'",
",",
"$",
"root",
".",
"'action=create&owner=%d'",
")",
";",
"}",
"else",
"{",
"$",
"controls",
"=",
"$",
"this",
"->",
"cache",
"[",
"'index_controls'",
"]",
";",
"}",
"$",
"row",
"[",
"]",
"=",
"sprintf",
"(",
"$",
"controls",
",",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
",",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
",",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
",",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
",",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
",",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
")",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"row",
";",
"$",
"children",
"=",
"$",
"this",
"->",
"sectionIndexBranch",
"(",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
",",
"$",
"level",
"+",
"1",
")",
";",
"if",
"(",
"count",
"(",
"$",
"children",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"children",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Отрисовывает подраздел индекса
@param int $owner Родительский раздел
@param int $level Уровень вложенности
@return string Отрисованная часть таблицы | [
"Отрисовывает",
"подраздел",
"индекса"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L484-L527 |
Eresus/EresusCMS | src/core/pages.php | TPages.sectionIndex | function sectionIndex()
{
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$root = Eresus_CMS::getLegacyKernel()->root.'admin.php?mod=pages&';
$this->cache['index_controls'] =
$page->control('setup', $root.'id=%d') . ' ' .
$page->control('position',
array($root.'action=up&id=%d',$root.'action=down&id=%d')) . ' ' .
$page->control('add', $root.'action=create&owner=%d') . ' ' .
$page->control('move', $root.'action=move&id=%d') . ' ' .
$page->control('delete', $root.'action=delete&id=%d');
$types = $this->loadContentTypes();
for ($i=0; $i<count($types[0]); $i++)
{
$this->cache['content_types'][$types[1][$i]] = $types[0][$i];
}
$table = new AdminList;
$table->setHead(array('text'=>'Раздел', 'align'=>'left'), 'Имя', 'Тип', 'Доступ', '');
$table->addRow(array(admPagesRoot, '', '', '',
array($page->control('add', $root.'action=create&owner=0'), 'align' => 'center')));
$table->addRows($this->sectionIndexBranch(0, 1));
$result = $table->render();
return $result;
} | php | function sectionIndex()
{
/** @var TAdminUI $page */
$page = Eresus_Kernel::app()->getPage();
$root = Eresus_CMS::getLegacyKernel()->root.'admin.php?mod=pages&';
$this->cache['index_controls'] =
$page->control('setup', $root.'id=%d') . ' ' .
$page->control('position',
array($root.'action=up&id=%d',$root.'action=down&id=%d')) . ' ' .
$page->control('add', $root.'action=create&owner=%d') . ' ' .
$page->control('move', $root.'action=move&id=%d') . ' ' .
$page->control('delete', $root.'action=delete&id=%d');
$types = $this->loadContentTypes();
for ($i=0; $i<count($types[0]); $i++)
{
$this->cache['content_types'][$types[1][$i]] = $types[0][$i];
}
$table = new AdminList;
$table->setHead(array('text'=>'Раздел', 'align'=>'left'), 'Имя', 'Тип', 'Доступ', '');
$table->addRow(array(admPagesRoot, '', '', '',
array($page->control('add', $root.'action=create&owner=0'), 'align' => 'center')));
$table->addRows($this->sectionIndexBranch(0, 1));
$result = $table->render();
return $result;
} | [
"function",
"sectionIndex",
"(",
")",
"{",
"/** @var TAdminUI $page */",
"$",
"page",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"root",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
".",
"'admin.php?mod=pages&'",
";",
"$",
"this",
"->",
"cache",
"[",
"'index_controls'",
"]",
"=",
"$",
"page",
"->",
"control",
"(",
"'setup'",
",",
"$",
"root",
".",
"'id=%d'",
")",
".",
"' '",
".",
"$",
"page",
"->",
"control",
"(",
"'position'",
",",
"array",
"(",
"$",
"root",
".",
"'action=up&id=%d'",
",",
"$",
"root",
".",
"'action=down&id=%d'",
")",
")",
".",
"' '",
".",
"$",
"page",
"->",
"control",
"(",
"'add'",
",",
"$",
"root",
".",
"'action=create&owner=%d'",
")",
".",
"' '",
".",
"$",
"page",
"->",
"control",
"(",
"'move'",
",",
"$",
"root",
".",
"'action=move&id=%d'",
")",
".",
"' '",
".",
"$",
"page",
"->",
"control",
"(",
"'delete'",
",",
"$",
"root",
".",
"'action=delete&id=%d'",
")",
";",
"$",
"types",
"=",
"$",
"this",
"->",
"loadContentTypes",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"types",
"[",
"0",
"]",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"'content_types'",
"]",
"[",
"$",
"types",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
"]",
"=",
"$",
"types",
"[",
"0",
"]",
"[",
"$",
"i",
"]",
";",
"}",
"$",
"table",
"=",
"new",
"AdminList",
";",
"$",
"table",
"->",
"setHead",
"(",
"array",
"(",
"'text'",
"=>",
"'Раздел', 'ali",
"g",
"'=>'lef",
"t'",
"), 'Им",
"я",
"'",
" 'Тип', ",
"'",
"оступ', ",
"'",
");",
"",
"",
"",
"",
"$",
"table",
"->",
"addRow",
"(",
"array",
"(",
"admPagesRoot",
",",
"''",
",",
"''",
",",
"''",
",",
"array",
"(",
"$",
"page",
"->",
"control",
"(",
"'add'",
",",
"$",
"root",
".",
"'action=create&owner=0'",
")",
",",
"'align'",
"=>",
"'center'",
")",
")",
")",
";",
"$",
"table",
"->",
"addRows",
"(",
"$",
"this",
"->",
"sectionIndexBranch",
"(",
"0",
",",
"1",
")",
")",
";",
"$",
"result",
"=",
"$",
"table",
"->",
"render",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | ???
@return string | [
"???"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L534-L558 |
Eresus/EresusCMS | src/core/pages.php | TPages.adminRender | function adminRender()
{
if (UserRights($this->access))
{
$result = '';
if (arg('update'))
{
$this->update();
}
elseif (arg('action'))
{
switch (arg('action'))
{
case 'up':
$this->moveUp();
break;
case 'down':
$this->moveDown();
break;
case 'create':
$result = $this->create();
break;
case 'insert':
$this->insert();
break;
case 'move':
$result = $this->move();
break;
case 'delete':
$this->delete();
break;
}
}
elseif (isset(Eresus_CMS::getLegacyKernel()->request['arg']['id']))
{
$result = $this->edit(arg('id', 'int'));
}
else
{
$result = $this->sectionIndex();
}
return $result;
}
else
{
return '';
}
} | php | function adminRender()
{
if (UserRights($this->access))
{
$result = '';
if (arg('update'))
{
$this->update();
}
elseif (arg('action'))
{
switch (arg('action'))
{
case 'up':
$this->moveUp();
break;
case 'down':
$this->moveDown();
break;
case 'create':
$result = $this->create();
break;
case 'insert':
$this->insert();
break;
case 'move':
$result = $this->move();
break;
case 'delete':
$this->delete();
break;
}
}
elseif (isset(Eresus_CMS::getLegacyKernel()->request['arg']['id']))
{
$result = $this->edit(arg('id', 'int'));
}
else
{
$result = $this->sectionIndex();
}
return $result;
}
else
{
return '';
}
} | [
"function",
"adminRender",
"(",
")",
"{",
"if",
"(",
"UserRights",
"(",
"$",
"this",
"->",
"access",
")",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"arg",
"(",
"'update'",
")",
")",
"{",
"$",
"this",
"->",
"update",
"(",
")",
";",
"}",
"elseif",
"(",
"arg",
"(",
"'action'",
")",
")",
"{",
"switch",
"(",
"arg",
"(",
"'action'",
")",
")",
"{",
"case",
"'up'",
":",
"$",
"this",
"->",
"moveUp",
"(",
")",
";",
"break",
";",
"case",
"'down'",
":",
"$",
"this",
"->",
"moveDown",
"(",
")",
";",
"break",
";",
"case",
"'create'",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"create",
"(",
")",
";",
"break",
";",
"case",
"'insert'",
":",
"$",
"this",
"->",
"insert",
"(",
")",
";",
"break",
";",
"case",
"'move'",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"move",
"(",
")",
";",
"break",
";",
"case",
"'delete'",
":",
"$",
"this",
"->",
"delete",
"(",
")",
";",
"break",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'arg'",
"]",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"edit",
"(",
"arg",
"(",
"'id'",
",",
"'int'",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sectionIndex",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | ???
@return string | [
"???"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/pages.php#L564-L611 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php | ezcDbSchemaXmlReader.parseField | private function parseField( SimpleXMLElement $field )
{
return ezcDbSchema::createNewField(
(string) $field->type,
isset( $field->length ) ? (string) $field->length : false,
isset( $field->notnull ) ? ((string) $field->notnull == 'true' || (string) $field->notnull == '1' ? true : false ) : false,
isset( $field->default ) ? (string) $field->default : null,
isset( $field->autoincrement ) ? ((string) $field->autoincrement == 'true' || (string) $field->autoincrement == '1' ? true : false ) : false,
isset( $field->unsigned ) ? ((string) $field->unsigned == 'true' || (string) $field->unsigned == '1' ? true : false ) : false
);
} | php | private function parseField( SimpleXMLElement $field )
{
return ezcDbSchema::createNewField(
(string) $field->type,
isset( $field->length ) ? (string) $field->length : false,
isset( $field->notnull ) ? ((string) $field->notnull == 'true' || (string) $field->notnull == '1' ? true : false ) : false,
isset( $field->default ) ? (string) $field->default : null,
isset( $field->autoincrement ) ? ((string) $field->autoincrement == 'true' || (string) $field->autoincrement == '1' ? true : false ) : false,
isset( $field->unsigned ) ? ((string) $field->unsigned == 'true' || (string) $field->unsigned == '1' ? true : false ) : false
);
} | [
"private",
"function",
"parseField",
"(",
"SimpleXMLElement",
"$",
"field",
")",
"{",
"return",
"ezcDbSchema",
"::",
"createNewField",
"(",
"(",
"string",
")",
"$",
"field",
"->",
"type",
",",
"isset",
"(",
"$",
"field",
"->",
"length",
")",
"?",
"(",
"string",
")",
"$",
"field",
"->",
"length",
":",
"false",
",",
"isset",
"(",
"$",
"field",
"->",
"notnull",
")",
"?",
"(",
"(",
"string",
")",
"$",
"field",
"->",
"notnull",
"==",
"'true'",
"||",
"(",
"string",
")",
"$",
"field",
"->",
"notnull",
"==",
"'1'",
"?",
"true",
":",
"false",
")",
":",
"false",
",",
"isset",
"(",
"$",
"field",
"->",
"default",
")",
"?",
"(",
"string",
")",
"$",
"field",
"->",
"default",
":",
"null",
",",
"isset",
"(",
"$",
"field",
"->",
"autoincrement",
")",
"?",
"(",
"(",
"string",
")",
"$",
"field",
"->",
"autoincrement",
"==",
"'true'",
"||",
"(",
"string",
")",
"$",
"field",
"->",
"autoincrement",
"==",
"'1'",
"?",
"true",
":",
"false",
")",
":",
"false",
",",
"isset",
"(",
"$",
"field",
"->",
"unsigned",
")",
"?",
"(",
"(",
"string",
")",
"$",
"field",
"->",
"unsigned",
"==",
"'true'",
"||",
"(",
"string",
")",
"$",
"field",
"->",
"unsigned",
"==",
"'1'",
"?",
"true",
":",
"false",
")",
":",
"false",
")",
";",
"}"
] | Extracts information about a table field from the XML element $field
@param SimpleXMLElement $field
@return ezcDbSchemaField or an inherited class | [
"Extracts",
"information",
"about",
"a",
"table",
"field",
"from",
"the",
"XML",
"element",
"$field"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php#L50-L60 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php | ezcDbSchemaXmlReader.parseIndex | private function parseIndex( SimpleXMLElement $index )
{
$indexFields = array();
foreach ( $index->field as $indexField )
{
$indexFieldName = (string) $indexField->name;
$indexFields[$indexFieldName] = ezcDbSchema::createNewIndexField(
isset( $indexField->sorting ) ? (string) $indexField->sorting : null
);
}
return ezcDbSchema::createNewIndex(
$indexFields,
isset( $index->primary ) ? (string) $index->primary : false,
isset( $index->unique ) ? (string) $index->unique : false
);
} | php | private function parseIndex( SimpleXMLElement $index )
{
$indexFields = array();
foreach ( $index->field as $indexField )
{
$indexFieldName = (string) $indexField->name;
$indexFields[$indexFieldName] = ezcDbSchema::createNewIndexField(
isset( $indexField->sorting ) ? (string) $indexField->sorting : null
);
}
return ezcDbSchema::createNewIndex(
$indexFields,
isset( $index->primary ) ? (string) $index->primary : false,
isset( $index->unique ) ? (string) $index->unique : false
);
} | [
"private",
"function",
"parseIndex",
"(",
"SimpleXMLElement",
"$",
"index",
")",
"{",
"$",
"indexFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"index",
"->",
"field",
"as",
"$",
"indexField",
")",
"{",
"$",
"indexFieldName",
"=",
"(",
"string",
")",
"$",
"indexField",
"->",
"name",
";",
"$",
"indexFields",
"[",
"$",
"indexFieldName",
"]",
"=",
"ezcDbSchema",
"::",
"createNewIndexField",
"(",
"isset",
"(",
"$",
"indexField",
"->",
"sorting",
")",
"?",
"(",
"string",
")",
"$",
"indexField",
"->",
"sorting",
":",
"null",
")",
";",
"}",
"return",
"ezcDbSchema",
"::",
"createNewIndex",
"(",
"$",
"indexFields",
",",
"isset",
"(",
"$",
"index",
"->",
"primary",
")",
"?",
"(",
"string",
")",
"$",
"index",
"->",
"primary",
":",
"false",
",",
"isset",
"(",
"$",
"index",
"->",
"unique",
")",
"?",
"(",
"string",
")",
"$",
"index",
"->",
"unique",
":",
"false",
")",
";",
"}"
] | Extracts information about an index from the XML element $index
@param SimpleXMLElement $index
@return ezcDbSchemaIndex or an inherited class | [
"Extracts",
"information",
"about",
"an",
"index",
"from",
"the",
"XML",
"element",
"$index"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php#L69-L87 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php | ezcDbSchemaXmlReader.parseTable | private function parseTable( SimpleXMLElement $table )
{
$fields = array();
$indexes = array();
foreach ( $table->declaration->field as $field )
{
$fieldName = (string) $field->name;
$fields[$fieldName] = $this->parseField( $field );
}
foreach ( $table->declaration->index as $index )
{
$indexName = (string) $index->name;
$indexes[$indexName] = $this->parseIndex( $index );
}
return ezcDbSchema::createNewTable( $fields, $indexes );
} | php | private function parseTable( SimpleXMLElement $table )
{
$fields = array();
$indexes = array();
foreach ( $table->declaration->field as $field )
{
$fieldName = (string) $field->name;
$fields[$fieldName] = $this->parseField( $field );
}
foreach ( $table->declaration->index as $index )
{
$indexName = (string) $index->name;
$indexes[$indexName] = $this->parseIndex( $index );
}
return ezcDbSchema::createNewTable( $fields, $indexes );
} | [
"private",
"function",
"parseTable",
"(",
"SimpleXMLElement",
"$",
"table",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"$",
"indexes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"declaration",
"->",
"field",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"(",
"string",
")",
"$",
"field",
"->",
"name",
";",
"$",
"fields",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"parseField",
"(",
"$",
"field",
")",
";",
"}",
"foreach",
"(",
"$",
"table",
"->",
"declaration",
"->",
"index",
"as",
"$",
"index",
")",
"{",
"$",
"indexName",
"=",
"(",
"string",
")",
"$",
"index",
"->",
"name",
";",
"$",
"indexes",
"[",
"$",
"indexName",
"]",
"=",
"$",
"this",
"->",
"parseIndex",
"(",
"$",
"index",
")",
";",
"}",
"return",
"ezcDbSchema",
"::",
"createNewTable",
"(",
"$",
"fields",
",",
"$",
"indexes",
")",
";",
"}"
] | Extracts information about a table from the XML element $table
@param SimpleXMLElement $table
@return ezcDbSchemaTable or an inherited class | [
"Extracts",
"information",
"about",
"a",
"table",
"from",
"the",
"XML",
"element",
"$table"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php#L96-L114 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php | ezcDbSchemaXmlReader.parseChangedTable | private function parseChangedTable( SimpleXMLElement $table )
{
$addedFields = array();
foreach ( $table->{'added-fields'}->field as $field )
{
$fieldName = (string) $field->name;
$addedFields[$fieldName] = $this->parseField( $field );
}
$changedFields = array();
foreach ( $table->{'changed-fields'}->field as $field )
{
$fieldName = (string) $field->name;
$changedFields[$fieldName] = $this->parseField( $field );
}
$removedFields = array();
foreach ( $table->{'removed-fields'}->field as $field )
{
$fieldName = (string) $field->name;
if ( (string) $field->removed == 'true' )
{
$removedFields[$fieldName] = true;
}
}
$addedIndexes = array();
foreach ( $table->{'added-indexes'}->index as $index )
{
$indexName = (string) $index->name;
$addedIndexes[$indexName] = $this->parseIndex( $index );
}
$changedIndexes = array();
foreach ( $table->{'changed-indexes'}->index as $index )
{
$indexName = (string) $index->name;
$changedIndexes[$indexName] = $this->parseIndex( $index );
}
$removedIndexes = array();
foreach ( $table->{'removed-indexes'}->index as $index )
{
$indexName = (string) $index->name;
if ( (string) $index->removed == 'true' )
{
$removedIndexes[$indexName] = true;
}
}
return new ezcDbSchemaTableDiff(
$addedFields, $changedFields, $removedFields, $addedIndexes,
$changedIndexes, $removedIndexes
);
} | php | private function parseChangedTable( SimpleXMLElement $table )
{
$addedFields = array();
foreach ( $table->{'added-fields'}->field as $field )
{
$fieldName = (string) $field->name;
$addedFields[$fieldName] = $this->parseField( $field );
}
$changedFields = array();
foreach ( $table->{'changed-fields'}->field as $field )
{
$fieldName = (string) $field->name;
$changedFields[$fieldName] = $this->parseField( $field );
}
$removedFields = array();
foreach ( $table->{'removed-fields'}->field as $field )
{
$fieldName = (string) $field->name;
if ( (string) $field->removed == 'true' )
{
$removedFields[$fieldName] = true;
}
}
$addedIndexes = array();
foreach ( $table->{'added-indexes'}->index as $index )
{
$indexName = (string) $index->name;
$addedIndexes[$indexName] = $this->parseIndex( $index );
}
$changedIndexes = array();
foreach ( $table->{'changed-indexes'}->index as $index )
{
$indexName = (string) $index->name;
$changedIndexes[$indexName] = $this->parseIndex( $index );
}
$removedIndexes = array();
foreach ( $table->{'removed-indexes'}->index as $index )
{
$indexName = (string) $index->name;
if ( (string) $index->removed == 'true' )
{
$removedIndexes[$indexName] = true;
}
}
return new ezcDbSchemaTableDiff(
$addedFields, $changedFields, $removedFields, $addedIndexes,
$changedIndexes, $removedIndexes
);
} | [
"private",
"function",
"parseChangedTable",
"(",
"SimpleXMLElement",
"$",
"table",
")",
"{",
"$",
"addedFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"{",
"'added-fields'",
"}",
"->",
"field",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"(",
"string",
")",
"$",
"field",
"->",
"name",
";",
"$",
"addedFields",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"parseField",
"(",
"$",
"field",
")",
";",
"}",
"$",
"changedFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"{",
"'changed-fields'",
"}",
"->",
"field",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"(",
"string",
")",
"$",
"field",
"->",
"name",
";",
"$",
"changedFields",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"parseField",
"(",
"$",
"field",
")",
";",
"}",
"$",
"removedFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"{",
"'removed-fields'",
"}",
"->",
"field",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"(",
"string",
")",
"$",
"field",
"->",
"name",
";",
"if",
"(",
"(",
"string",
")",
"$",
"field",
"->",
"removed",
"==",
"'true'",
")",
"{",
"$",
"removedFields",
"[",
"$",
"fieldName",
"]",
"=",
"true",
";",
"}",
"}",
"$",
"addedIndexes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"{",
"'added-indexes'",
"}",
"->",
"index",
"as",
"$",
"index",
")",
"{",
"$",
"indexName",
"=",
"(",
"string",
")",
"$",
"index",
"->",
"name",
";",
"$",
"addedIndexes",
"[",
"$",
"indexName",
"]",
"=",
"$",
"this",
"->",
"parseIndex",
"(",
"$",
"index",
")",
";",
"}",
"$",
"changedIndexes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"{",
"'changed-indexes'",
"}",
"->",
"index",
"as",
"$",
"index",
")",
"{",
"$",
"indexName",
"=",
"(",
"string",
")",
"$",
"index",
"->",
"name",
";",
"$",
"changedIndexes",
"[",
"$",
"indexName",
"]",
"=",
"$",
"this",
"->",
"parseIndex",
"(",
"$",
"index",
")",
";",
"}",
"$",
"removedIndexes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"{",
"'removed-indexes'",
"}",
"->",
"index",
"as",
"$",
"index",
")",
"{",
"$",
"indexName",
"=",
"(",
"string",
")",
"$",
"index",
"->",
"name",
";",
"if",
"(",
"(",
"string",
")",
"$",
"index",
"->",
"removed",
"==",
"'true'",
")",
"{",
"$",
"removedIndexes",
"[",
"$",
"indexName",
"]",
"=",
"true",
";",
"}",
"}",
"return",
"new",
"ezcDbSchemaTableDiff",
"(",
"$",
"addedFields",
",",
"$",
"changedFields",
",",
"$",
"removedFields",
",",
"$",
"addedIndexes",
",",
"$",
"changedIndexes",
",",
"$",
"removedIndexes",
")",
";",
"}"
] | Extracts information about changes to a table from the XML element $table
@param SimpleXMLElement $table
@return ezcDbSchemaTableDiff | [
"Extracts",
"information",
"about",
"changes",
"to",
"a",
"table",
"from",
"the",
"XML",
"element",
"$table"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php#L123-L177 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php | ezcDbSchemaXmlReader.parseXml | private function parseXml( SimpleXMLElement $xml )
{
$schema = array();
foreach ( $xml->table as $table )
{
$tableName = (string) $table->name;
$schema[$tableName] = $this->parseTable( $table );
}
return new ezcDbSchema( $schema );
} | php | private function parseXml( SimpleXMLElement $xml )
{
$schema = array();
foreach ( $xml->table as $table )
{
$tableName = (string) $table->name;
$schema[$tableName] = $this->parseTable( $table );
}
return new ezcDbSchema( $schema );
} | [
"private",
"function",
"parseXml",
"(",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"$",
"schema",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"xml",
"->",
"table",
"as",
"$",
"table",
")",
"{",
"$",
"tableName",
"=",
"(",
"string",
")",
"$",
"table",
"->",
"name",
";",
"$",
"schema",
"[",
"$",
"tableName",
"]",
"=",
"$",
"this",
"->",
"parseTable",
"(",
"$",
"table",
")",
";",
"}",
"return",
"new",
"ezcDbSchema",
"(",
"$",
"schema",
")",
";",
"}"
] | Returns the schema definition in $xml as an ezcDbSchema
@param SimpleXMLElement $xml
@return ezcDbSchema | [
"Returns",
"the",
"schema",
"definition",
"in",
"$xml",
"as",
"an",
"ezcDbSchema"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/xml/reader.php#L186-L197 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.