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
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
titon/db | src/Titon/Db/Behavior/HierarchyBehavior.php | HierarchyBehavior.preDelete | public function preDelete(Event $event, Query $query, $id) {
if (!$this->getConfig('onDelete')) {
return true;
}
if ($node = $this->getNode($id)) {
$count = $this->getRepository()->select()
->where($this->getConfig('parentField'), $id)
->count();
if ($count) {
return false;
}
$this->_deleteIndex = $node[$this->getConfig('leftField')];
}
return true;
} | php | public function preDelete(Event $event, Query $query, $id) {
if (!$this->getConfig('onDelete')) {
return true;
}
if ($node = $this->getNode($id)) {
$count = $this->getRepository()->select()
->where($this->getConfig('parentField'), $id)
->count();
if ($count) {
return false;
}
$this->_deleteIndex = $node[$this->getConfig('leftField')];
}
return true;
} | [
"public",
"function",
"preDelete",
"(",
"Event",
"$",
"event",
",",
"Query",
"$",
"query",
",",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getConfig",
"(",
"'onDelete'",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"id",
")",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"select",
"(",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'parentField'",
")",
",",
"$",
"id",
")",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"count",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_deleteIndex",
"=",
"$",
"node",
"[",
"$",
"this",
"->",
"getConfig",
"(",
"'leftField'",
")",
"]",
";",
"}",
"return",
"true",
";",
"}"
]
| Before a delete, fetch the node and save its left index.
If a node has children, the delete will fail.
@param \Titon\Event\Event $event
@param \Titon\Db\Query $query
@param int|int[] $id
@return bool | [
"Before",
"a",
"delete",
"fetch",
"the",
"node",
"and",
"save",
"its",
"left",
"index",
".",
"If",
"a",
"node",
"has",
"children",
"the",
"delete",
"will",
"fail",
"."
]
| train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L444-L462 |
titon/db | src/Titon/Db/Behavior/HierarchyBehavior.php | HierarchyBehavior.postDelete | public function postDelete(Event $event, $id, $count) {
if (!$this->getConfig('onDelete') || !$this->_deleteIndex) {
return;
}
$this->_removeNode($id, $this->_deleteIndex);
$this->_deleteIndex = null;
} | php | public function postDelete(Event $event, $id, $count) {
if (!$this->getConfig('onDelete') || !$this->_deleteIndex) {
return;
}
$this->_removeNode($id, $this->_deleteIndex);
$this->_deleteIndex = null;
} | [
"public",
"function",
"postDelete",
"(",
"Event",
"$",
"event",
",",
"$",
"id",
",",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getConfig",
"(",
"'onDelete'",
")",
"||",
"!",
"$",
"this",
"->",
"_deleteIndex",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_removeNode",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"_deleteIndex",
")",
";",
"$",
"this",
"->",
"_deleteIndex",
"=",
"null",
";",
"}"
]
| After a delete, shift all nodes up using the base index.
@param \Titon\Event\Event $event
@param int|int[] $id
@param int $count | [
"After",
"a",
"delete",
"shift",
"all",
"nodes",
"up",
"using",
"the",
"base",
"index",
"."
]
| train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L471-L478 |
titon/db | src/Titon/Db/Behavior/HierarchyBehavior.php | HierarchyBehavior.preSave | public function preSave(Event $event, Query $query, $id, array &$data) {
if (!$this->getConfig('onSave')) {
return true;
}
$parent = $this->getConfig('parentField');
$left = $this->getConfig('leftField');
$right = $this->getConfig('rightField');
// Append left and right during create
if ($query->getType() === Query::INSERT) {
$indexes = [];
// Is a child
if (isset($data[$parent])) {
if ($node = $this->getNode($data[$parent])) {
$parentRight = $node[$right];
// Save index for moving postSave
$this->_saveIndex = $parentRight;
$indexes = [
$left => $parentRight,
$right => $parentRight + 1
];
}
}
// Fallback to root
if (empty($indexes)) {
$node = $this->getLastNode();
$rootRight = $node[$right];
$indexes = [
$left => $rootRight + 1,
$right => $rootRight + 2
];
}
$data = $indexes + $data;
}
return true;
} | php | public function preSave(Event $event, Query $query, $id, array &$data) {
if (!$this->getConfig('onSave')) {
return true;
}
$parent = $this->getConfig('parentField');
$left = $this->getConfig('leftField');
$right = $this->getConfig('rightField');
// Append left and right during create
if ($query->getType() === Query::INSERT) {
$indexes = [];
// Is a child
if (isset($data[$parent])) {
if ($node = $this->getNode($data[$parent])) {
$parentRight = $node[$right];
// Save index for moving postSave
$this->_saveIndex = $parentRight;
$indexes = [
$left => $parentRight,
$right => $parentRight + 1
];
}
}
// Fallback to root
if (empty($indexes)) {
$node = $this->getLastNode();
$rootRight = $node[$right];
$indexes = [
$left => $rootRight + 1,
$right => $rootRight + 2
];
}
$data = $indexes + $data;
}
return true;
} | [
"public",
"function",
"preSave",
"(",
"Event",
"$",
"event",
",",
"Query",
"$",
"query",
",",
"$",
"id",
",",
"array",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getConfig",
"(",
"'onSave'",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'parentField'",
")",
";",
"$",
"left",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'leftField'",
")",
";",
"$",
"right",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'rightField'",
")",
";",
"// Append left and right during create",
"if",
"(",
"$",
"query",
"->",
"getType",
"(",
")",
"===",
"Query",
"::",
"INSERT",
")",
"{",
"$",
"indexes",
"=",
"[",
"]",
";",
"// Is a child",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"parent",
"]",
")",
")",
"{",
"if",
"(",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"data",
"[",
"$",
"parent",
"]",
")",
")",
"{",
"$",
"parentRight",
"=",
"$",
"node",
"[",
"$",
"right",
"]",
";",
"// Save index for moving postSave",
"$",
"this",
"->",
"_saveIndex",
"=",
"$",
"parentRight",
";",
"$",
"indexes",
"=",
"[",
"$",
"left",
"=>",
"$",
"parentRight",
",",
"$",
"right",
"=>",
"$",
"parentRight",
"+",
"1",
"]",
";",
"}",
"}",
"// Fallback to root",
"if",
"(",
"empty",
"(",
"$",
"indexes",
")",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getLastNode",
"(",
")",
";",
"$",
"rootRight",
"=",
"$",
"node",
"[",
"$",
"right",
"]",
";",
"$",
"indexes",
"=",
"[",
"$",
"left",
"=>",
"$",
"rootRight",
"+",
"1",
",",
"$",
"right",
"=>",
"$",
"rootRight",
"+",
"2",
"]",
";",
"}",
"$",
"data",
"=",
"$",
"indexes",
"+",
"$",
"data",
";",
"}",
"return",
"true",
";",
"}"
]
| Before an insert, determine the correct left and right using the parent or root node as a base.
Do not shift the nodes until postSave() just in case the insert fails.
Before an update, remove the left and right fields so that the tree cannot be modified.
Use moveUp(), moveDown(), moveTo() or reOrder() to update existing nodes.
@param \Titon\Event\Event $event
@param \Titon\Db\Query $query
@param int|int[] $id
@param array $data
@return bool | [
"Before",
"an",
"insert",
"determine",
"the",
"correct",
"left",
"and",
"right",
"using",
"the",
"parent",
"or",
"root",
"node",
"as",
"a",
"base",
".",
"Do",
"not",
"shift",
"the",
"nodes",
"until",
"postSave",
"()",
"just",
"in",
"case",
"the",
"insert",
"fails",
"."
]
| train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L493-L536 |
titon/db | src/Titon/Db/Behavior/HierarchyBehavior.php | HierarchyBehavior.postSave | public function postSave(Event $event, $id, $count) {
if (!$this->getConfig('onSave') || !$this->_saveIndex) {
return;
}
$this->_insertNode($id, $this->_saveIndex);
$this->_saveIndex = null;
} | php | public function postSave(Event $event, $id, $count) {
if (!$this->getConfig('onSave') || !$this->_saveIndex) {
return;
}
$this->_insertNode($id, $this->_saveIndex);
$this->_saveIndex = null;
} | [
"public",
"function",
"postSave",
"(",
"Event",
"$",
"event",
",",
"$",
"id",
",",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getConfig",
"(",
"'onSave'",
")",
"||",
"!",
"$",
"this",
"->",
"_saveIndex",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_insertNode",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"_saveIndex",
")",
";",
"$",
"this",
"->",
"_saveIndex",
"=",
"null",
";",
"}"
]
| After an insert, shift all nodes down using the base index.
@param \Titon\Event\Event $event
@param int|int[] $id
@Param int $count | [
"After",
"an",
"insert",
"shift",
"all",
"nodes",
"down",
"using",
"the",
"base",
"index",
"."
]
| train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L545-L552 |
titon/db | src/Titon/Db/Behavior/HierarchyBehavior.php | HierarchyBehavior._moveNode | protected function _moveNode(Closure $callback, array $data) {
return $this->getRepository()->updateMany($data, $callback, [
'before' => false,
'after' => false
]);
} | php | protected function _moveNode(Closure $callback, array $data) {
return $this->getRepository()->updateMany($data, $callback, [
'before' => false,
'after' => false
]);
} | [
"protected",
"function",
"_moveNode",
"(",
"Closure",
"$",
"callback",
",",
"array",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"updateMany",
"(",
"$",
"data",
",",
"$",
"callback",
",",
"[",
"'before'",
"=>",
"false",
",",
"'after'",
"=>",
"false",
"]",
")",
";",
"}"
]
| Move a node, or nodes, by applying a where clause to an update query and saving data.
Disable before and after callbacks to recursive events don't trigger.
@param callable $callback
@param array $data
@return int | [
"Move",
"a",
"node",
"or",
"nodes",
"by",
"applying",
"a",
"where",
"clause",
"to",
"an",
"update",
"query",
"and",
"saving",
"data",
".",
"Disable",
"before",
"and",
"after",
"callbacks",
"to",
"recursive",
"events",
"don",
"t",
"trigger",
"."
]
| train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L608-L613 |
titon/db | src/Titon/Db/Behavior/HierarchyBehavior.php | HierarchyBehavior._removeNode | protected function _removeNode($id, $index) {
$pk = $this->getRepository()->getPrimaryKey();
foreach ([$this->getConfig('leftField'), $this->getConfig('rightField')] as $field) {
$this->_moveNode(function(Query $query) use ($field, $index, $id, $pk) {
$query->where($field, '>=', $index);
if ($id) {
$query->where($pk, '!=', $id);
}
}, [
$field => Query::expr($field, '-', 2)
]);
}
} | php | protected function _removeNode($id, $index) {
$pk = $this->getRepository()->getPrimaryKey();
foreach ([$this->getConfig('leftField'), $this->getConfig('rightField')] as $field) {
$this->_moveNode(function(Query $query) use ($field, $index, $id, $pk) {
$query->where($field, '>=', $index);
if ($id) {
$query->where($pk, '!=', $id);
}
}, [
$field => Query::expr($field, '-', 2)
]);
}
} | [
"protected",
"function",
"_removeNode",
"(",
"$",
"id",
",",
"$",
"index",
")",
"{",
"$",
"pk",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"foreach",
"(",
"[",
"$",
"this",
"->",
"getConfig",
"(",
"'leftField'",
")",
",",
"$",
"this",
"->",
"getConfig",
"(",
"'rightField'",
")",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"_moveNode",
"(",
"function",
"(",
"Query",
"$",
"query",
")",
"use",
"(",
"$",
"field",
",",
"$",
"index",
",",
"$",
"id",
",",
"$",
"pk",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'>='",
",",
"$",
"index",
")",
";",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"pk",
",",
"'!='",
",",
"$",
"id",
")",
";",
"}",
"}",
",",
"[",
"$",
"field",
"=>",
"Query",
"::",
"expr",
"(",
"$",
"field",
",",
"'-'",
",",
"2",
")",
"]",
")",
";",
"}",
"}"
]
| Prepares a node for removal by moving all following nodes up.
@param int $id
@param int $index | [
"Prepares",
"a",
"node",
"for",
"removal",
"by",
"moving",
"all",
"following",
"nodes",
"up",
"."
]
| train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L621-L635 |
titon/db | src/Titon/Db/Behavior/HierarchyBehavior.php | HierarchyBehavior._reOrder | protected function _reOrder($parent_id, $left, array $order = []) {
$parent = $this->getConfig('parentField');
$repo = $this->getRepository();
$pk = $repo->getPrimaryKey();
$right = $left + 1;
// Get children and sort
$children = $repo->select()
->where($parent, $parent_id)
->orderBy($order)
->all();
foreach ($children as $child) {
$right = $this->_reOrder($child[$pk], $right, $order);
}
// Update parent node
if ($parent_id) {
$this->_moveNode(function(Query $query) use ($pk, $parent_id) {
$query->where($pk, $parent_id);
}, [
$this->getConfig('leftField') => $left,
$this->getConfig('rightField') => $right
]);
}
return $right + 1;
} | php | protected function _reOrder($parent_id, $left, array $order = []) {
$parent = $this->getConfig('parentField');
$repo = $this->getRepository();
$pk = $repo->getPrimaryKey();
$right = $left + 1;
// Get children and sort
$children = $repo->select()
->where($parent, $parent_id)
->orderBy($order)
->all();
foreach ($children as $child) {
$right = $this->_reOrder($child[$pk], $right, $order);
}
// Update parent node
if ($parent_id) {
$this->_moveNode(function(Query $query) use ($pk, $parent_id) {
$query->where($pk, $parent_id);
}, [
$this->getConfig('leftField') => $left,
$this->getConfig('rightField') => $right
]);
}
return $right + 1;
} | [
"protected",
"function",
"_reOrder",
"(",
"$",
"parent_id",
",",
"$",
"left",
",",
"array",
"$",
"order",
"=",
"[",
"]",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'parentField'",
")",
";",
"$",
"repo",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"$",
"pk",
"=",
"$",
"repo",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"right",
"=",
"$",
"left",
"+",
"1",
";",
"// Get children and sort",
"$",
"children",
"=",
"$",
"repo",
"->",
"select",
"(",
")",
"->",
"where",
"(",
"$",
"parent",
",",
"$",
"parent_id",
")",
"->",
"orderBy",
"(",
"$",
"order",
")",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"right",
"=",
"$",
"this",
"->",
"_reOrder",
"(",
"$",
"child",
"[",
"$",
"pk",
"]",
",",
"$",
"right",
",",
"$",
"order",
")",
";",
"}",
"// Update parent node",
"if",
"(",
"$",
"parent_id",
")",
"{",
"$",
"this",
"->",
"_moveNode",
"(",
"function",
"(",
"Query",
"$",
"query",
")",
"use",
"(",
"$",
"pk",
",",
"$",
"parent_id",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"pk",
",",
"$",
"parent_id",
")",
";",
"}",
",",
"[",
"$",
"this",
"->",
"getConfig",
"(",
"'leftField'",
")",
"=>",
"$",
"left",
",",
"$",
"this",
"->",
"getConfig",
"(",
"'rightField'",
")",
"=>",
"$",
"right",
"]",
")",
";",
"}",
"return",
"$",
"right",
"+",
"1",
";",
"}"
]
| Re-order the tree by recursively looping through all parents and children,
ordering the results, and generating the correct left and right indexes.
@param int $parent_id
@param int $left
@param array $order
@return int | [
"Re",
"-",
"order",
"the",
"tree",
"by",
"recursively",
"looping",
"through",
"all",
"parents",
"and",
"children",
"ordering",
"the",
"results",
"and",
"generating",
"the",
"correct",
"left",
"and",
"right",
"indexes",
"."
]
| train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L646-L673 |
seeruo/framework | src/Service/BuildService.php | BuildService.init | public function init()
{
$config = store('config');
// 配置文件处理
$config['themes_dir'] = ROOT.DIRECTORY_SEPARATOR.'Themes/'.$config['themes'];
$config['plugin_dir'] = ROOT.DIRECTORY_SEPARATOR.'Plugins';
$config['logs_dir'] = ROOT.DIRECTORY_SEPARATOR.'Logs';
$config['public_dir'] = ROOT.DIRECTORY_SEPARATOR.$config['public'];
$config['source_dir'] = ROOT.DIRECTORY_SEPARATOR.$config['source'];
$this->config = $config;
$this->page_limit = $config['page_limit'];
$this->themes_dir = $config['themes_dir'];
$this->public_dir = $config['public_dir'];
$this->source_dir = $config['source_dir'];
} | php | public function init()
{
$config = store('config');
// 配置文件处理
$config['themes_dir'] = ROOT.DIRECTORY_SEPARATOR.'Themes/'.$config['themes'];
$config['plugin_dir'] = ROOT.DIRECTORY_SEPARATOR.'Plugins';
$config['logs_dir'] = ROOT.DIRECTORY_SEPARATOR.'Logs';
$config['public_dir'] = ROOT.DIRECTORY_SEPARATOR.$config['public'];
$config['source_dir'] = ROOT.DIRECTORY_SEPARATOR.$config['source'];
$this->config = $config;
$this->page_limit = $config['page_limit'];
$this->themes_dir = $config['themes_dir'];
$this->public_dir = $config['public_dir'];
$this->source_dir = $config['source_dir'];
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"config",
"=",
"store",
"(",
"'config'",
")",
";",
"// 配置文件处理",
"$",
"config",
"[",
"'themes_dir'",
"]",
"=",
"ROOT",
".",
"DIRECTORY_SEPARATOR",
".",
"'Themes/'",
".",
"$",
"config",
"[",
"'themes'",
"]",
";",
"$",
"config",
"[",
"'plugin_dir'",
"]",
"=",
"ROOT",
".",
"DIRECTORY_SEPARATOR",
".",
"'Plugins'",
";",
"$",
"config",
"[",
"'logs_dir'",
"]",
"=",
"ROOT",
".",
"DIRECTORY_SEPARATOR",
".",
"'Logs'",
";",
"$",
"config",
"[",
"'public_dir'",
"]",
"=",
"ROOT",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"config",
"[",
"'public'",
"]",
";",
"$",
"config",
"[",
"'source_dir'",
"]",
"=",
"ROOT",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"config",
"[",
"'source'",
"]",
";",
"$",
"this",
"->",
"config",
"=",
"$",
"config",
";",
"$",
"this",
"->",
"page_limit",
"=",
"$",
"config",
"[",
"'page_limit'",
"]",
";",
"$",
"this",
"->",
"themes_dir",
"=",
"$",
"config",
"[",
"'themes_dir'",
"]",
";",
"$",
"this",
"->",
"public_dir",
"=",
"$",
"config",
"[",
"'public_dir'",
"]",
";",
"$",
"this",
"->",
"source_dir",
"=",
"$",
"config",
"[",
"'source_dir'",
"]",
";",
"}"
]
| 初始化构建对象
@DateTime 2019-01-02
@return [type] [description] | [
"初始化构建对象"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L84-L99 |
seeruo/framework | src/Service/BuildService.php | BuildService.run | public function run()
{
// @检查单页
$this->checkSinglePages();
// @解析文件设置
$this->resolveFiles();
// @静态文件构建
$this->createStatic();
// @生成查询json
$this->createSearchData();
// @生成文章信息
$this->createHome();
// @生成文章页面
$this->createArticles();
// @生成主题页面
$this->createSinglePage();
// @生成归档页面
$this->createTimer();
// @生成分类页面
$this->createCategory();
} | php | public function run()
{
// @检查单页
$this->checkSinglePages();
// @解析文件设置
$this->resolveFiles();
// @静态文件构建
$this->createStatic();
// @生成查询json
$this->createSearchData();
// @生成文章信息
$this->createHome();
// @生成文章页面
$this->createArticles();
// @生成主题页面
$this->createSinglePage();
// @生成归档页面
$this->createTimer();
// @生成分类页面
$this->createCategory();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"// @检查单页",
"$",
"this",
"->",
"checkSinglePages",
"(",
")",
";",
"// @解析文件设置",
"$",
"this",
"->",
"resolveFiles",
"(",
")",
";",
"// @静态文件构建",
"$",
"this",
"->",
"createStatic",
"(",
")",
";",
"// @生成查询json",
"$",
"this",
"->",
"createSearchData",
"(",
")",
";",
"// @生成文章信息",
"$",
"this",
"->",
"createHome",
"(",
")",
";",
"// @生成文章页面",
"$",
"this",
"->",
"createArticles",
"(",
")",
";",
"// @生成主题页面",
"$",
"this",
"->",
"createSinglePage",
"(",
")",
";",
"// @生成归档页面",
"$",
"this",
"->",
"createTimer",
"(",
")",
";",
"// @生成分类页面",
"$",
"this",
"->",
"createCategory",
"(",
")",
";",
"}"
]
| 构建静态网站所需文件 | [
"构建静态网站所需文件"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L104-L124 |
seeruo/framework | src/Service/BuildService.php | BuildService.createStatic | private function createStatic()
{
// 主题里面的静态文件
$files = $this->fileSys->getFiles($this->themes_dir . DIRECTORY_SEPARATOR . 'static');
// 文件拷贝
array_walk($files, function ($file)
{
$search_str = $this->themes_dir . DIRECTORY_SEPARATOR . 'static';
$replace_str = $this->public_dir . DIRECTORY_SEPARATOR . 'static';
$to_path = str_replace($search_str, $replace_str, $file['file_path']);
$this->fileSys->copy($file['file_path'], $to_path);
});
} | php | private function createStatic()
{
// 主题里面的静态文件
$files = $this->fileSys->getFiles($this->themes_dir . DIRECTORY_SEPARATOR . 'static');
// 文件拷贝
array_walk($files, function ($file)
{
$search_str = $this->themes_dir . DIRECTORY_SEPARATOR . 'static';
$replace_str = $this->public_dir . DIRECTORY_SEPARATOR . 'static';
$to_path = str_replace($search_str, $replace_str, $file['file_path']);
$this->fileSys->copy($file['file_path'], $to_path);
});
} | [
"private",
"function",
"createStatic",
"(",
")",
"{",
"// 主题里面的静态文件",
"$",
"files",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getFiles",
"(",
"$",
"this",
"->",
"themes_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'static'",
")",
";",
"// 文件拷贝",
"array_walk",
"(",
"$",
"files",
",",
"function",
"(",
"$",
"file",
")",
"{",
"$",
"search_str",
"=",
"$",
"this",
"->",
"themes_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'static'",
";",
"$",
"replace_str",
"=",
"$",
"this",
"->",
"public_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'static'",
";",
"$",
"to_path",
"=",
"str_replace",
"(",
"$",
"search_str",
",",
"$",
"replace_str",
",",
"$",
"file",
"[",
"'file_path'",
"]",
")",
";",
"$",
"this",
"->",
"fileSys",
"->",
"copy",
"(",
"$",
"file",
"[",
"'file_path'",
"]",
",",
"$",
"to_path",
")",
";",
"}",
")",
";",
"}"
]
| [createStatic 静态资源文件转移]
@Author danier [email protected]
@DateTime 2018-08-12
@return [type] | [
"[",
"createStatic",
"静态资源文件转移",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L132-L144 |
seeruo/framework | src/Service/BuildService.php | BuildService.createSinglePage | private function createSinglePage()
{
if (isset($this->config['single_pages'])) {
$themes = $this->config['single_pages'];
foreach ($themes as $key => $v) {
$theme_page = $this->source_dir.DIRECTORY_SEPARATOR . $v;
if ( file_exists($theme_page) ) {
$file_path = $this->public_dir . DIRECTORY_SEPARATOR . $key . '/index.html';
$html = $this->renderArticle($theme_page, true);
$this->fileSys->create($file_path, $html);
}
}
}
} | php | private function createSinglePage()
{
if (isset($this->config['single_pages'])) {
$themes = $this->config['single_pages'];
foreach ($themes as $key => $v) {
$theme_page = $this->source_dir.DIRECTORY_SEPARATOR . $v;
if ( file_exists($theme_page) ) {
$file_path = $this->public_dir . DIRECTORY_SEPARATOR . $key . '/index.html';
$html = $this->renderArticle($theme_page, true);
$this->fileSys->create($file_path, $html);
}
}
}
} | [
"private",
"function",
"createSinglePage",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'single_pages'",
"]",
")",
")",
"{",
"$",
"themes",
"=",
"$",
"this",
"->",
"config",
"[",
"'single_pages'",
"]",
";",
"foreach",
"(",
"$",
"themes",
"as",
"$",
"key",
"=>",
"$",
"v",
")",
"{",
"$",
"theme_page",
"=",
"$",
"this",
"->",
"source_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"v",
";",
"if",
"(",
"file_exists",
"(",
"$",
"theme_page",
")",
")",
"{",
"$",
"file_path",
"=",
"$",
"this",
"->",
"public_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"key",
".",
"'/index.html'",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"renderArticle",
"(",
"$",
"theme_page",
",",
"true",
")",
";",
"$",
"this",
"->",
"fileSys",
"->",
"create",
"(",
"$",
"file_path",
",",
"$",
"html",
")",
";",
"}",
"}",
"}",
"}"
]
| [createSinglePage 构建单页页面]
@Author danier [email protected]
@DateTime 2018-09-19
@return [type] [description] | [
"[",
"createSinglePage",
"构建单页页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L152-L165 |
seeruo/framework | src/Service/BuildService.php | BuildService.createSearchData | private function createSearchData()
{
$search_data = [];
$files = $this->files;
// 单页文件不解析
foreach ($files as $key => $file) {
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
$full_content = $this->fileSys->getContent($file['file_path'])['content'];
// $desc_content = mb_substr($full_content, 0, 1000, 'utf-8');
// $file['description'] = $this->markd2html->makeHtml( $desc_content );
$search_data[] = [
'title' => $file['title'],
'href' => $file['href'],
'date' => $file['date'],
'tags' => implode(',', $file['tags']),
'type' => implode(',', $file['type']),
// 'desc' => $file['description'],
];
}
$file_path = $this->public_dir . DIRECTORY_SEPARATOR . 'articles/data.json';
$html = json_encode($search_data, JSON_UNESCAPED_UNICODE);
$this->fileSys->create($file_path, $html);
} | php | private function createSearchData()
{
$search_data = [];
$files = $this->files;
// 单页文件不解析
foreach ($files as $key => $file) {
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
$full_content = $this->fileSys->getContent($file['file_path'])['content'];
// $desc_content = mb_substr($full_content, 0, 1000, 'utf-8');
// $file['description'] = $this->markd2html->makeHtml( $desc_content );
$search_data[] = [
'title' => $file['title'],
'href' => $file['href'],
'date' => $file['date'],
'tags' => implode(',', $file['tags']),
'type' => implode(',', $file['type']),
// 'desc' => $file['description'],
];
}
$file_path = $this->public_dir . DIRECTORY_SEPARATOR . 'articles/data.json';
$html = json_encode($search_data, JSON_UNESCAPED_UNICODE);
$this->fileSys->create($file_path, $html);
} | [
"private",
"function",
"createSearchData",
"(",
")",
"{",
"$",
"search_data",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
";",
"// 单页文件不解析",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"$",
"this",
"->",
"single_pages",
")",
")",
"{",
"unset",
"(",
"$",
"files",
"[",
"$",
"key",
"]",
")",
";",
"continue",
";",
"}",
"$",
"full_content",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getContent",
"(",
"$",
"file",
"[",
"'file_path'",
"]",
")",
"[",
"'content'",
"]",
";",
"// $desc_content = mb_substr($full_content, 0, 1000, 'utf-8');",
"// $file['description'] = $this->markd2html->makeHtml( $desc_content );",
"$",
"search_data",
"[",
"]",
"=",
"[",
"'title'",
"=>",
"$",
"file",
"[",
"'title'",
"]",
",",
"'href'",
"=>",
"$",
"file",
"[",
"'href'",
"]",
",",
"'date'",
"=>",
"$",
"file",
"[",
"'date'",
"]",
",",
"'tags'",
"=>",
"implode",
"(",
"','",
",",
"$",
"file",
"[",
"'tags'",
"]",
")",
",",
"'type'",
"=>",
"implode",
"(",
"','",
",",
"$",
"file",
"[",
"'type'",
"]",
")",
",",
"// 'desc' => $file['description'],",
"]",
";",
"}",
"$",
"file_path",
"=",
"$",
"this",
"->",
"public_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'articles/data.json'",
";",
"$",
"html",
"=",
"json_encode",
"(",
"$",
"search_data",
",",
"JSON_UNESCAPED_UNICODE",
")",
";",
"$",
"this",
"->",
"fileSys",
"->",
"create",
"(",
"$",
"file_path",
",",
"$",
"html",
")",
";",
"}"
]
| [createSinglePage 构建查询json]
@Author danier [email protected]
@DateTime 2018-09-19
@return [type] [description] | [
"[",
"createSinglePage",
"构建查询json",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L173-L198 |
seeruo/framework | src/Service/BuildService.php | BuildService.createHome | public function createHome()
{
// 检查是否设置了主页
$home_page = @$this->config['home_page'] ?: '';
if ( !empty($home_page) && file_exists($this->source_dir.DIRECTORY_SEPARATOR . $home_page) ) {
// 渲染html
$home_page = $this->source_dir.DIRECTORY_SEPARATOR . $home_page;
$html = $this->renderArticle($home_page, true);
// 创建文件
$file_path = $this->public_dir . '/index.html';
$this->fileSys->create($file_path, $html);
}else{
$files = $this->files;
// 单页文件不解析
foreach ($files as $key => $file) {
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
}
// 根据分页渲染
$limit = $this->page_limit;
$pages = ceil(count($files) / $limit);
for ($i=1; $i <= $pages; $i++) {
$repo = [];
$path_key = '';
if ($i == 1) {
$repo = array_slice($files, 0, $limit);
$path_key = '';
}else{
$start = $limit * ($i-1);
$repo = array_slice($files, $start, $limit);
$path_key = 'page'.'-'.$i;
}
$html = $this->renderHome($repo, $pages, $i);
// 处理路由
$path_key = array_filter(explode('-', $path_key));
$path = empty($path_key)? '' : implode('/', $path_key) . '/';
$file_path = $this->public_dir .DIRECTORY_SEPARATOR. $path .'index.html';
$this->fileSys->create($file_path, $html);
}
}
} | php | public function createHome()
{
// 检查是否设置了主页
$home_page = @$this->config['home_page'] ?: '';
if ( !empty($home_page) && file_exists($this->source_dir.DIRECTORY_SEPARATOR . $home_page) ) {
// 渲染html
$home_page = $this->source_dir.DIRECTORY_SEPARATOR . $home_page;
$html = $this->renderArticle($home_page, true);
// 创建文件
$file_path = $this->public_dir . '/index.html';
$this->fileSys->create($file_path, $html);
}else{
$files = $this->files;
// 单页文件不解析
foreach ($files as $key => $file) {
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
}
// 根据分页渲染
$limit = $this->page_limit;
$pages = ceil(count($files) / $limit);
for ($i=1; $i <= $pages; $i++) {
$repo = [];
$path_key = '';
if ($i == 1) {
$repo = array_slice($files, 0, $limit);
$path_key = '';
}else{
$start = $limit * ($i-1);
$repo = array_slice($files, $start, $limit);
$path_key = 'page'.'-'.$i;
}
$html = $this->renderHome($repo, $pages, $i);
// 处理路由
$path_key = array_filter(explode('-', $path_key));
$path = empty($path_key)? '' : implode('/', $path_key) . '/';
$file_path = $this->public_dir .DIRECTORY_SEPARATOR. $path .'index.html';
$this->fileSys->create($file_path, $html);
}
}
} | [
"public",
"function",
"createHome",
"(",
")",
"{",
"// 检查是否设置了主页",
"$",
"home_page",
"=",
"@",
"$",
"this",
"->",
"config",
"[",
"'home_page'",
"]",
"?",
":",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"home_page",
")",
"&&",
"file_exists",
"(",
"$",
"this",
"->",
"source_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"home_page",
")",
")",
"{",
"// 渲染html",
"$",
"home_page",
"=",
"$",
"this",
"->",
"source_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"home_page",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"renderArticle",
"(",
"$",
"home_page",
",",
"true",
")",
";",
"// 创建文件",
"$",
"file_path",
"=",
"$",
"this",
"->",
"public_dir",
".",
"'/index.html'",
";",
"$",
"this",
"->",
"fileSys",
"->",
"create",
"(",
"$",
"file_path",
",",
"$",
"html",
")",
";",
"}",
"else",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
";",
"// 单页文件不解析",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"$",
"this",
"->",
"single_pages",
")",
")",
"{",
"unset",
"(",
"$",
"files",
"[",
"$",
"key",
"]",
")",
";",
"continue",
";",
"}",
"}",
"// 根据分页渲染",
"$",
"limit",
"=",
"$",
"this",
"->",
"page_limit",
";",
"$",
"pages",
"=",
"ceil",
"(",
"count",
"(",
"$",
"files",
")",
"/",
"$",
"limit",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"pages",
";",
"$",
"i",
"++",
")",
"{",
"$",
"repo",
"=",
"[",
"]",
";",
"$",
"path_key",
"=",
"''",
";",
"if",
"(",
"$",
"i",
"==",
"1",
")",
"{",
"$",
"repo",
"=",
"array_slice",
"(",
"$",
"files",
",",
"0",
",",
"$",
"limit",
")",
";",
"$",
"path_key",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"start",
"=",
"$",
"limit",
"*",
"(",
"$",
"i",
"-",
"1",
")",
";",
"$",
"repo",
"=",
"array_slice",
"(",
"$",
"files",
",",
"$",
"start",
",",
"$",
"limit",
")",
";",
"$",
"path_key",
"=",
"'page'",
".",
"'-'",
".",
"$",
"i",
";",
"}",
"$",
"html",
"=",
"$",
"this",
"->",
"renderHome",
"(",
"$",
"repo",
",",
"$",
"pages",
",",
"$",
"i",
")",
";",
"// 处理路由",
"$",
"path_key",
"=",
"array_filter",
"(",
"explode",
"(",
"'-'",
",",
"$",
"path_key",
")",
")",
";",
"$",
"path",
"=",
"empty",
"(",
"$",
"path_key",
")",
"?",
"''",
":",
"implode",
"(",
"'/'",
",",
"$",
"path_key",
")",
".",
"'/'",
";",
"$",
"file_path",
"=",
"$",
"this",
"->",
"public_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"path",
".",
"'index.html'",
";",
"$",
"this",
"->",
"fileSys",
"->",
"create",
"(",
"$",
"file_path",
",",
"$",
"html",
")",
";",
"}",
"}",
"}"
]
| [createHome 构建主页静态文件]
@Author danier [email protected]
@DateTime 2018-08-12
@return [type] | [
"[",
"createHome",
"构建主页静态文件",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L206-L249 |
seeruo/framework | src/Service/BuildService.php | BuildService.renderHome | public function renderHome($rep=[], $pages, $curr_page)
{
// 如果分页太多,就创建一个分页导航
$pages_html = '';
if ($pages>1) {
$pages_html .= '<div class="pages">';
for ($i=1; $i <= $pages; $i++) {
if ($i === $curr_page) {
$pages_html .= '<span class="current-page">'.$i.'</span>';
}else{
if ($i === 1) {
$pages_html .= '<a href="/">'.$i.'</a>';
}else{
$pages_html .= '<a href="/page/'.$i.'">'.$i.'</a>';
}
}
}
$pages_html .= '</div>';
}
// 获取部分文件内容,用作缩略展示
foreach ($rep as &$file) {
$full_content = $this->fileSys->getContent($file['file_path'])['content'];
$full_con_arr = explode("\n", trim($full_content));
// 获取20行作为摘要
$desc_content = [];
$length = (count($full_con_arr)>20) ? 20 : count($full_con_arr);
for ($i=0; $i < $length; $i++) {
$desc_content[] = $full_con_arr[$i];
}
$desc_content = implode("\n", $desc_content);
$file['description'] = $this->markd2html->makeHtml( $desc_content );
}
unset($file);
$file = [];
$file['articles_file_index'] = $this->file_index;
$file['articles_type_index'] = $this->type_index;
$file['articles_list'] = $rep;
$file['articles_pages'] = $pages_html; // 分页导航
$file['web_title'] = $this->config['title']; // 网站标题
$html = $this->render('index.html', $file);
return $html;
} | php | public function renderHome($rep=[], $pages, $curr_page)
{
// 如果分页太多,就创建一个分页导航
$pages_html = '';
if ($pages>1) {
$pages_html .= '<div class="pages">';
for ($i=1; $i <= $pages; $i++) {
if ($i === $curr_page) {
$pages_html .= '<span class="current-page">'.$i.'</span>';
}else{
if ($i === 1) {
$pages_html .= '<a href="/">'.$i.'</a>';
}else{
$pages_html .= '<a href="/page/'.$i.'">'.$i.'</a>';
}
}
}
$pages_html .= '</div>';
}
// 获取部分文件内容,用作缩略展示
foreach ($rep as &$file) {
$full_content = $this->fileSys->getContent($file['file_path'])['content'];
$full_con_arr = explode("\n", trim($full_content));
// 获取20行作为摘要
$desc_content = [];
$length = (count($full_con_arr)>20) ? 20 : count($full_con_arr);
for ($i=0; $i < $length; $i++) {
$desc_content[] = $full_con_arr[$i];
}
$desc_content = implode("\n", $desc_content);
$file['description'] = $this->markd2html->makeHtml( $desc_content );
}
unset($file);
$file = [];
$file['articles_file_index'] = $this->file_index;
$file['articles_type_index'] = $this->type_index;
$file['articles_list'] = $rep;
$file['articles_pages'] = $pages_html; // 分页导航
$file['web_title'] = $this->config['title']; // 网站标题
$html = $this->render('index.html', $file);
return $html;
} | [
"public",
"function",
"renderHome",
"(",
"$",
"rep",
"=",
"[",
"]",
",",
"$",
"pages",
",",
"$",
"curr_page",
")",
"{",
"// 如果分页太多,就创建一个分页导航",
"$",
"pages_html",
"=",
"''",
";",
"if",
"(",
"$",
"pages",
">",
"1",
")",
"{",
"$",
"pages_html",
".=",
"'<div class=\"pages\">'",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"pages",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"===",
"$",
"curr_page",
")",
"{",
"$",
"pages_html",
".=",
"'<span class=\"current-page\">'",
".",
"$",
"i",
".",
"'</span>'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"i",
"===",
"1",
")",
"{",
"$",
"pages_html",
".=",
"'<a href=\"/\">'",
".",
"$",
"i",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"pages_html",
".=",
"'<a href=\"/page/'",
".",
"$",
"i",
".",
"'\">'",
".",
"$",
"i",
".",
"'</a>'",
";",
"}",
"}",
"}",
"$",
"pages_html",
".=",
"'</div>'",
";",
"}",
"// 获取部分文件内容,用作缩略展示",
"foreach",
"(",
"$",
"rep",
"as",
"&",
"$",
"file",
")",
"{",
"$",
"full_content",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getContent",
"(",
"$",
"file",
"[",
"'file_path'",
"]",
")",
"[",
"'content'",
"]",
";",
"$",
"full_con_arr",
"=",
"explode",
"(",
"\"\\n\"",
",",
"trim",
"(",
"$",
"full_content",
")",
")",
";",
"// 获取20行作为摘要",
"$",
"desc_content",
"=",
"[",
"]",
";",
"$",
"length",
"=",
"(",
"count",
"(",
"$",
"full_con_arr",
")",
">",
"20",
")",
"?",
"20",
":",
"count",
"(",
"$",
"full_con_arr",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"desc_content",
"[",
"]",
"=",
"$",
"full_con_arr",
"[",
"$",
"i",
"]",
";",
"}",
"$",
"desc_content",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"desc_content",
")",
";",
"$",
"file",
"[",
"'description'",
"]",
"=",
"$",
"this",
"->",
"markd2html",
"->",
"makeHtml",
"(",
"$",
"desc_content",
")",
";",
"}",
"unset",
"(",
"$",
"file",
")",
";",
"$",
"file",
"=",
"[",
"]",
";",
"$",
"file",
"[",
"'articles_file_index'",
"]",
"=",
"$",
"this",
"->",
"file_index",
";",
"$",
"file",
"[",
"'articles_type_index'",
"]",
"=",
"$",
"this",
"->",
"type_index",
";",
"$",
"file",
"[",
"'articles_list'",
"]",
"=",
"$",
"rep",
";",
"$",
"file",
"[",
"'articles_pages'",
"]",
"=",
"$",
"pages_html",
";",
"// 分页导航",
"$",
"file",
"[",
"'web_title'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'title'",
"]",
";",
"// 网站标题",
"$",
"html",
"=",
"$",
"this",
"->",
"render",
"(",
"'index.html'",
",",
"$",
"file",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| [renderHome 解析主页静态页面]
@Author danier [email protected]
@DateTime 2018-09-19
@param array $rep [文件数组]
@param [type] $pages [总页码]
@param [type] $curr_page [当前页码]
@param [type] $path_key [路径关键字]
@return [type] [description] | [
"[",
"renderHome",
"解析主页静态页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L261-L304 |
seeruo/framework | src/Service/BuildService.php | BuildService.createArticles | private function createArticles()
{
// 解析文件索引
$site_title = $this->config['title'];
foreach ($this->files as $key => $file) {
// 单页文件不解析
if (in_array($file['page_uuid'], $this->single_pages)) {
continue;
}
$html = $this->renderArticle($file['file_path']);
$this->fileSys->create($file['public_dir'], $html);
}
} | php | private function createArticles()
{
// 解析文件索引
$site_title = $this->config['title'];
foreach ($this->files as $key => $file) {
// 单页文件不解析
if (in_array($file['page_uuid'], $this->single_pages)) {
continue;
}
$html = $this->renderArticle($file['file_path']);
$this->fileSys->create($file['public_dir'], $html);
}
} | [
"private",
"function",
"createArticles",
"(",
")",
"{",
"// 解析文件索引",
"$",
"site_title",
"=",
"$",
"this",
"->",
"config",
"[",
"'title'",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"// 单页文件不解析",
"if",
"(",
"in_array",
"(",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"$",
"this",
"->",
"single_pages",
")",
")",
"{",
"continue",
";",
"}",
"$",
"html",
"=",
"$",
"this",
"->",
"renderArticle",
"(",
"$",
"file",
"[",
"'file_path'",
"]",
")",
";",
"$",
"this",
"->",
"fileSys",
"->",
"create",
"(",
"$",
"file",
"[",
"'public_dir'",
"]",
",",
"$",
"html",
")",
";",
"}",
"}"
]
| [createArticles 构建文章静态页面]
@Author danier [email protected]
@DateTime 2018-08-12
@return [type] | [
"[",
"createArticles",
"构建文章静态页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L312-L324 |
seeruo/framework | src/Service/BuildService.php | BuildService.renderArticle | public function renderArticle($file_path, $single_page=false)
{
$file_path = str_replace("\\","/", $file_path);
$page_uuid = md5($file_path);
$file = $this->files[$page_uuid];
$file_data = $this->fileSys->getContent($file['file_path']);
$file['content'] = $this->markd2html->makeHtml( $file_data['content'] );
$file['articles_file_index'] = $this->file_index;
$file['articles_type_index'] = $this->type_index;
$file['author'] = @$file['author'] ?: $this->config['author'];
$file['linker'] = @$file['linker'] ?: ($this->config['url'] . $file['href']);
$file['license'] = @$file['license'] ?: $this->config['license'];
$file['href'] = $this->config['url'].$file['href'];
$file['single_page'] = $single_page;
// 类型分类需要字段
$file['page_uuid_type_now'] = getpy($this->getLastItem($file['type']));
$file['page_uuid_type'] = $file['type'];
array_walk($file['page_uuid_type'], function(&$d){
$d = getpy(trim($d));
});
$html = $this->render('article.html', $file);
return $html;
} | php | public function renderArticle($file_path, $single_page=false)
{
$file_path = str_replace("\\","/", $file_path);
$page_uuid = md5($file_path);
$file = $this->files[$page_uuid];
$file_data = $this->fileSys->getContent($file['file_path']);
$file['content'] = $this->markd2html->makeHtml( $file_data['content'] );
$file['articles_file_index'] = $this->file_index;
$file['articles_type_index'] = $this->type_index;
$file['author'] = @$file['author'] ?: $this->config['author'];
$file['linker'] = @$file['linker'] ?: ($this->config['url'] . $file['href']);
$file['license'] = @$file['license'] ?: $this->config['license'];
$file['href'] = $this->config['url'].$file['href'];
$file['single_page'] = $single_page;
// 类型分类需要字段
$file['page_uuid_type_now'] = getpy($this->getLastItem($file['type']));
$file['page_uuid_type'] = $file['type'];
array_walk($file['page_uuid_type'], function(&$d){
$d = getpy(trim($d));
});
$html = $this->render('article.html', $file);
return $html;
} | [
"public",
"function",
"renderArticle",
"(",
"$",
"file_path",
",",
"$",
"single_page",
"=",
"false",
")",
"{",
"$",
"file_path",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
",",
"$",
"file_path",
")",
";",
"$",
"page_uuid",
"=",
"md5",
"(",
"$",
"file_path",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"files",
"[",
"$",
"page_uuid",
"]",
";",
"$",
"file_data",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getContent",
"(",
"$",
"file",
"[",
"'file_path'",
"]",
")",
";",
"$",
"file",
"[",
"'content'",
"]",
"=",
"$",
"this",
"->",
"markd2html",
"->",
"makeHtml",
"(",
"$",
"file_data",
"[",
"'content'",
"]",
")",
";",
"$",
"file",
"[",
"'articles_file_index'",
"]",
"=",
"$",
"this",
"->",
"file_index",
";",
"$",
"file",
"[",
"'articles_type_index'",
"]",
"=",
"$",
"this",
"->",
"type_index",
";",
"$",
"file",
"[",
"'author'",
"]",
"=",
"@",
"$",
"file",
"[",
"'author'",
"]",
"?",
":",
"$",
"this",
"->",
"config",
"[",
"'author'",
"]",
";",
"$",
"file",
"[",
"'linker'",
"]",
"=",
"@",
"$",
"file",
"[",
"'linker'",
"]",
"?",
":",
"(",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
".",
"$",
"file",
"[",
"'href'",
"]",
")",
";",
"$",
"file",
"[",
"'license'",
"]",
"=",
"@",
"$",
"file",
"[",
"'license'",
"]",
"?",
":",
"$",
"this",
"->",
"config",
"[",
"'license'",
"]",
";",
"$",
"file",
"[",
"'href'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
".",
"$",
"file",
"[",
"'href'",
"]",
";",
"$",
"file",
"[",
"'single_page'",
"]",
"=",
"$",
"single_page",
";",
"// 类型分类需要字段",
"$",
"file",
"[",
"'page_uuid_type_now'",
"]",
"=",
"getpy",
"(",
"$",
"this",
"->",
"getLastItem",
"(",
"$",
"file",
"[",
"'type'",
"]",
")",
")",
";",
"$",
"file",
"[",
"'page_uuid_type'",
"]",
"=",
"$",
"file",
"[",
"'type'",
"]",
";",
"array_walk",
"(",
"$",
"file",
"[",
"'page_uuid_type'",
"]",
",",
"function",
"(",
"&",
"$",
"d",
")",
"{",
"$",
"d",
"=",
"getpy",
"(",
"trim",
"(",
"$",
"d",
")",
")",
";",
"}",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"render",
"(",
"'article.html'",
",",
"$",
"file",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| [renderArticle 解析文章静态页面]
@DateTime 2018-10-12
@param [type] $file_path [文件路径]
@param boolean $single_page [是否单页,用于通知全段]
@return [type] [description] | [
"[",
"renderArticle",
"解析文章静态页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L333-L357 |
seeruo/framework | src/Service/BuildService.php | BuildService.createTimer | public function createTimer()
{
$archives = [];
$files = $this->files;
foreach ($files as $key => $file) {
// 单页文件不解析
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
// 解析其他文件
$date = empty($file['date']) ? date('Y-m-d') : date('Y-m-d', strtotime($file['date']));
$date_arr = explode('-', $date);
$archives[$date_arr[0]][] = $file;
$archives[$date_arr[0].'-'.$date_arr[1]][] = $file;
$archives[$date_arr[0].'-'.$date_arr[1].'-'.$date_arr[2]][] = $file;
}
$archives['all'] = $files;
// 构建分页
$limit = $this->page_limit;
foreach ($archives as $k => $v) {
$pages = ceil(count($v) / $limit);
for ($i=1; $i <= $pages; $i++) {
$repo = [];
$path_key = '';
if ($i == 1) {
$repo = array_slice($v, 0, $limit);
$path_key = $k;
}else{
$start = $limit * ($i-1);
$repo = array_slice($v, $start, $limit);
$path_key = $k.'-'.'page'.'-'.$i;
}
$html = $this->renderTimer($repo, $pages, $i, $k);
// 处理路由
$path_key = array_filter(explode('-', $path_key), function($s){
return $s !== 'all';
});
$path = empty($path_key)? '' : implode('/', $path_key) . '/';
$file_path = $this->public_dir .'/archives/'. $path .'index.html';
$this->fileSys->create($file_path, $html);
}
}
} | php | public function createTimer()
{
$archives = [];
$files = $this->files;
foreach ($files as $key => $file) {
// 单页文件不解析
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
// 解析其他文件
$date = empty($file['date']) ? date('Y-m-d') : date('Y-m-d', strtotime($file['date']));
$date_arr = explode('-', $date);
$archives[$date_arr[0]][] = $file;
$archives[$date_arr[0].'-'.$date_arr[1]][] = $file;
$archives[$date_arr[0].'-'.$date_arr[1].'-'.$date_arr[2]][] = $file;
}
$archives['all'] = $files;
// 构建分页
$limit = $this->page_limit;
foreach ($archives as $k => $v) {
$pages = ceil(count($v) / $limit);
for ($i=1; $i <= $pages; $i++) {
$repo = [];
$path_key = '';
if ($i == 1) {
$repo = array_slice($v, 0, $limit);
$path_key = $k;
}else{
$start = $limit * ($i-1);
$repo = array_slice($v, $start, $limit);
$path_key = $k.'-'.'page'.'-'.$i;
}
$html = $this->renderTimer($repo, $pages, $i, $k);
// 处理路由
$path_key = array_filter(explode('-', $path_key), function($s){
return $s !== 'all';
});
$path = empty($path_key)? '' : implode('/', $path_key) . '/';
$file_path = $this->public_dir .'/archives/'. $path .'index.html';
$this->fileSys->create($file_path, $html);
}
}
} | [
"public",
"function",
"createTimer",
"(",
")",
"{",
"$",
"archives",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"// 单页文件不解析",
"if",
"(",
"in_array",
"(",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"$",
"this",
"->",
"single_pages",
")",
")",
"{",
"unset",
"(",
"$",
"files",
"[",
"$",
"key",
"]",
")",
";",
"continue",
";",
"}",
"// 解析其他文件",
"$",
"date",
"=",
"empty",
"(",
"$",
"file",
"[",
"'date'",
"]",
")",
"?",
"date",
"(",
"'Y-m-d'",
")",
":",
"date",
"(",
"'Y-m-d'",
",",
"strtotime",
"(",
"$",
"file",
"[",
"'date'",
"]",
")",
")",
";",
"$",
"date_arr",
"=",
"explode",
"(",
"'-'",
",",
"$",
"date",
")",
";",
"$",
"archives",
"[",
"$",
"date_arr",
"[",
"0",
"]",
"]",
"[",
"]",
"=",
"$",
"file",
";",
"$",
"archives",
"[",
"$",
"date_arr",
"[",
"0",
"]",
".",
"'-'",
".",
"$",
"date_arr",
"[",
"1",
"]",
"]",
"[",
"]",
"=",
"$",
"file",
";",
"$",
"archives",
"[",
"$",
"date_arr",
"[",
"0",
"]",
".",
"'-'",
".",
"$",
"date_arr",
"[",
"1",
"]",
".",
"'-'",
".",
"$",
"date_arr",
"[",
"2",
"]",
"]",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"$",
"archives",
"[",
"'all'",
"]",
"=",
"$",
"files",
";",
"// 构建分页",
"$",
"limit",
"=",
"$",
"this",
"->",
"page_limit",
";",
"foreach",
"(",
"$",
"archives",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"pages",
"=",
"ceil",
"(",
"count",
"(",
"$",
"v",
")",
"/",
"$",
"limit",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"pages",
";",
"$",
"i",
"++",
")",
"{",
"$",
"repo",
"=",
"[",
"]",
";",
"$",
"path_key",
"=",
"''",
";",
"if",
"(",
"$",
"i",
"==",
"1",
")",
"{",
"$",
"repo",
"=",
"array_slice",
"(",
"$",
"v",
",",
"0",
",",
"$",
"limit",
")",
";",
"$",
"path_key",
"=",
"$",
"k",
";",
"}",
"else",
"{",
"$",
"start",
"=",
"$",
"limit",
"*",
"(",
"$",
"i",
"-",
"1",
")",
";",
"$",
"repo",
"=",
"array_slice",
"(",
"$",
"v",
",",
"$",
"start",
",",
"$",
"limit",
")",
";",
"$",
"path_key",
"=",
"$",
"k",
".",
"'-'",
".",
"'page'",
".",
"'-'",
".",
"$",
"i",
";",
"}",
"$",
"html",
"=",
"$",
"this",
"->",
"renderTimer",
"(",
"$",
"repo",
",",
"$",
"pages",
",",
"$",
"i",
",",
"$",
"k",
")",
";",
"// 处理路由",
"$",
"path_key",
"=",
"array_filter",
"(",
"explode",
"(",
"'-'",
",",
"$",
"path_key",
")",
",",
"function",
"(",
"$",
"s",
")",
"{",
"return",
"$",
"s",
"!==",
"'all'",
";",
"}",
")",
";",
"$",
"path",
"=",
"empty",
"(",
"$",
"path_key",
")",
"?",
"''",
":",
"implode",
"(",
"'/'",
",",
"$",
"path_key",
")",
".",
"'/'",
";",
"$",
"file_path",
"=",
"$",
"this",
"->",
"public_dir",
".",
"'/archives/'",
".",
"$",
"path",
".",
"'index.html'",
";",
"$",
"this",
"->",
"fileSys",
"->",
"create",
"(",
"$",
"file_path",
",",
"$",
"html",
")",
";",
"}",
"}",
"}"
]
| [createTimer 创建时间归档页面]
@Author danier [email protected]
@DateTime 2018-09-18
@return [type] [description] | [
"[",
"createTimer",
"创建时间归档页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L366-L412 |
seeruo/framework | src/Service/BuildService.php | BuildService.renderTimer | public function renderTimer($rep=[], $pages, $curr_page, $path_key)
{
// 基础路径解析
$path_key_arr = array_filter(explode('-', $path_key), function($s){
return $s !== 'all';
});
$path = empty($path_key_arr)? '' : implode('/', $path_key_arr) . '/';
$path = '/archives/'. $path;
// 如果分页太多,就创建一个分页导航
$pages_html = '';
if ($pages>1) {
$pages_html .= '<div class="pages">';
for ($i=1; $i <= $pages; $i++) {
if ($i === $curr_page) {
$pages_html .= '<span class="current-page">'.$i.'</span>';
}else{
if ($i === 1) {
$pages_html .= '<a href="'.$path.'">'.$i.'</a>';
}else{
$pages_html .= '<a href="'.$path.'page/'.$i.'">'.$i.'</a>';
}
}
}
$pages_html .= '</div>';
}
$file = [];
$file['articles_file_index'] = $this->file_index;
$file['articles_list'] = $rep;
$file['articles_pages'] = $pages_html;
$file['web_title'] = $this->config['title']; // 网站标题
$file['title'] = '归档'; // 网站标题
$html = $this->render('archives.html', $file);
return $html;
} | php | public function renderTimer($rep=[], $pages, $curr_page, $path_key)
{
// 基础路径解析
$path_key_arr = array_filter(explode('-', $path_key), function($s){
return $s !== 'all';
});
$path = empty($path_key_arr)? '' : implode('/', $path_key_arr) . '/';
$path = '/archives/'. $path;
// 如果分页太多,就创建一个分页导航
$pages_html = '';
if ($pages>1) {
$pages_html .= '<div class="pages">';
for ($i=1; $i <= $pages; $i++) {
if ($i === $curr_page) {
$pages_html .= '<span class="current-page">'.$i.'</span>';
}else{
if ($i === 1) {
$pages_html .= '<a href="'.$path.'">'.$i.'</a>';
}else{
$pages_html .= '<a href="'.$path.'page/'.$i.'">'.$i.'</a>';
}
}
}
$pages_html .= '</div>';
}
$file = [];
$file['articles_file_index'] = $this->file_index;
$file['articles_list'] = $rep;
$file['articles_pages'] = $pages_html;
$file['web_title'] = $this->config['title']; // 网站标题
$file['title'] = '归档'; // 网站标题
$html = $this->render('archives.html', $file);
return $html;
} | [
"public",
"function",
"renderTimer",
"(",
"$",
"rep",
"=",
"[",
"]",
",",
"$",
"pages",
",",
"$",
"curr_page",
",",
"$",
"path_key",
")",
"{",
"// 基础路径解析",
"$",
"path_key_arr",
"=",
"array_filter",
"(",
"explode",
"(",
"'-'",
",",
"$",
"path_key",
")",
",",
"function",
"(",
"$",
"s",
")",
"{",
"return",
"$",
"s",
"!==",
"'all'",
";",
"}",
")",
";",
"$",
"path",
"=",
"empty",
"(",
"$",
"path_key_arr",
")",
"?",
"''",
":",
"implode",
"(",
"'/'",
",",
"$",
"path_key_arr",
")",
".",
"'/'",
";",
"$",
"path",
"=",
"'/archives/'",
".",
"$",
"path",
";",
"// 如果分页太多,就创建一个分页导航",
"$",
"pages_html",
"=",
"''",
";",
"if",
"(",
"$",
"pages",
">",
"1",
")",
"{",
"$",
"pages_html",
".=",
"'<div class=\"pages\">'",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"pages",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"===",
"$",
"curr_page",
")",
"{",
"$",
"pages_html",
".=",
"'<span class=\"current-page\">'",
".",
"$",
"i",
".",
"'</span>'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"i",
"===",
"1",
")",
"{",
"$",
"pages_html",
".=",
"'<a href=\"'",
".",
"$",
"path",
".",
"'\">'",
".",
"$",
"i",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"pages_html",
".=",
"'<a href=\"'",
".",
"$",
"path",
".",
"'page/'",
".",
"$",
"i",
".",
"'\">'",
".",
"$",
"i",
".",
"'</a>'",
";",
"}",
"}",
"}",
"$",
"pages_html",
".=",
"'</div>'",
";",
"}",
"$",
"file",
"=",
"[",
"]",
";",
"$",
"file",
"[",
"'articles_file_index'",
"]",
"=",
"$",
"this",
"->",
"file_index",
";",
"$",
"file",
"[",
"'articles_list'",
"]",
"=",
"$",
"rep",
";",
"$",
"file",
"[",
"'articles_pages'",
"]",
"=",
"$",
"pages_html",
";",
"$",
"file",
"[",
"'web_title'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'title'",
"]",
";",
"// 网站标题",
"$",
"file",
"[",
"'title'",
"]",
"=",
"'归档'; /",
"/",
"站标题",
"$",
"html",
"=",
"$",
"this",
"->",
"render",
"(",
"'archives.html'",
",",
"$",
"file",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| [renderTimer 解析时间归档页面]
@Author danier [email protected]
@DateTime 2018-09-19
@param array $rep [文件数组]
@param [type] $pages [总页码]
@param [type] $curr_page [当前页码]
@param [type] $path_key [路径关键字]
@return [type] [description] | [
"[",
"renderTimer",
"解析时间归档页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L424-L459 |
seeruo/framework | src/Service/BuildService.php | BuildService.createCategory | private function createCategory($value='')
{
$files = $this->files;
// 构建文件分类
$archives = [];
foreach ($files as $key => $file) {
// 单页文件不解析
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
// 文件类型处理
$len = count($file['type']);
$str = '';
for ($i=0; $i < $len; $i++) {
$str.= '__' . $file['type'][$i];
$str = trim($str, '__');
$str_py = getpy($str);
$archives[ $str_py ][] = $file;
}
}
$archives['all'] = $files;
// 构建分页 分类导航索引
$limit = $this->page_limit;
foreach ($archives as $k => $v) {
// $k = getpy($k); // 中文转拼音
$pages = ceil(count($v) / $limit);
for ($i=1; $i <= $pages; $i++) {
$repo = [];
$path_key = '';
if ($i == 1) {
$repo = array_slice($v, 0, $limit);
$path_key = $k;
}else{
$start = $limit * ($i-1);
$repo = array_slice($v, $start, $limit);
$path_key = $k.'__'.'page'.'__'.$i;
}
$html = $this->renderCategory($repo, $pages, $i, $k);
// 处理路由
$path_key = array_filter(explode('__', $path_key), function($s){
return $s !== 'all';
});
$path = empty($path_key)? '' : implode('/', $path_key) . '/';
$file_path = $this->public_dir .'/category/'. $path .'index.html';
$this->fileSys->create($file_path, $html);
}
}
} | php | private function createCategory($value='')
{
$files = $this->files;
// 构建文件分类
$archives = [];
foreach ($files as $key => $file) {
// 单页文件不解析
if (in_array($file['page_uuid'], $this->single_pages)) {
unset($files[$key]);
continue;
}
// 文件类型处理
$len = count($file['type']);
$str = '';
for ($i=0; $i < $len; $i++) {
$str.= '__' . $file['type'][$i];
$str = trim($str, '__');
$str_py = getpy($str);
$archives[ $str_py ][] = $file;
}
}
$archives['all'] = $files;
// 构建分页 分类导航索引
$limit = $this->page_limit;
foreach ($archives as $k => $v) {
// $k = getpy($k); // 中文转拼音
$pages = ceil(count($v) / $limit);
for ($i=1; $i <= $pages; $i++) {
$repo = [];
$path_key = '';
if ($i == 1) {
$repo = array_slice($v, 0, $limit);
$path_key = $k;
}else{
$start = $limit * ($i-1);
$repo = array_slice($v, $start, $limit);
$path_key = $k.'__'.'page'.'__'.$i;
}
$html = $this->renderCategory($repo, $pages, $i, $k);
// 处理路由
$path_key = array_filter(explode('__', $path_key), function($s){
return $s !== 'all';
});
$path = empty($path_key)? '' : implode('/', $path_key) . '/';
$file_path = $this->public_dir .'/category/'. $path .'index.html';
$this->fileSys->create($file_path, $html);
}
}
} | [
"private",
"function",
"createCategory",
"(",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
";",
"// 构建文件分类",
"$",
"archives",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"// 单页文件不解析",
"if",
"(",
"in_array",
"(",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"$",
"this",
"->",
"single_pages",
")",
")",
"{",
"unset",
"(",
"$",
"files",
"[",
"$",
"key",
"]",
")",
";",
"continue",
";",
"}",
"// 文件类型处理",
"$",
"len",
"=",
"count",
"(",
"$",
"file",
"[",
"'type'",
"]",
")",
";",
"$",
"str",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"str",
".=",
"'__'",
".",
"$",
"file",
"[",
"'type'",
"]",
"[",
"$",
"i",
"]",
";",
"$",
"str",
"=",
"trim",
"(",
"$",
"str",
",",
"'__'",
")",
";",
"$",
"str_py",
"=",
"getpy",
"(",
"$",
"str",
")",
";",
"$",
"archives",
"[",
"$",
"str_py",
"]",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"}",
"$",
"archives",
"[",
"'all'",
"]",
"=",
"$",
"files",
";",
"// 构建分页 分类导航索引",
"$",
"limit",
"=",
"$",
"this",
"->",
"page_limit",
";",
"foreach",
"(",
"$",
"archives",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// $k = getpy($k); // 中文转拼音",
"$",
"pages",
"=",
"ceil",
"(",
"count",
"(",
"$",
"v",
")",
"/",
"$",
"limit",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"pages",
";",
"$",
"i",
"++",
")",
"{",
"$",
"repo",
"=",
"[",
"]",
";",
"$",
"path_key",
"=",
"''",
";",
"if",
"(",
"$",
"i",
"==",
"1",
")",
"{",
"$",
"repo",
"=",
"array_slice",
"(",
"$",
"v",
",",
"0",
",",
"$",
"limit",
")",
";",
"$",
"path_key",
"=",
"$",
"k",
";",
"}",
"else",
"{",
"$",
"start",
"=",
"$",
"limit",
"*",
"(",
"$",
"i",
"-",
"1",
")",
";",
"$",
"repo",
"=",
"array_slice",
"(",
"$",
"v",
",",
"$",
"start",
",",
"$",
"limit",
")",
";",
"$",
"path_key",
"=",
"$",
"k",
".",
"'__'",
".",
"'page'",
".",
"'__'",
".",
"$",
"i",
";",
"}",
"$",
"html",
"=",
"$",
"this",
"->",
"renderCategory",
"(",
"$",
"repo",
",",
"$",
"pages",
",",
"$",
"i",
",",
"$",
"k",
")",
";",
"// 处理路由",
"$",
"path_key",
"=",
"array_filter",
"(",
"explode",
"(",
"'__'",
",",
"$",
"path_key",
")",
",",
"function",
"(",
"$",
"s",
")",
"{",
"return",
"$",
"s",
"!==",
"'all'",
";",
"}",
")",
";",
"$",
"path",
"=",
"empty",
"(",
"$",
"path_key",
")",
"?",
"''",
":",
"implode",
"(",
"'/'",
",",
"$",
"path_key",
")",
".",
"'/'",
";",
"$",
"file_path",
"=",
"$",
"this",
"->",
"public_dir",
".",
"'/category/'",
".",
"$",
"path",
".",
"'index.html'",
";",
"$",
"this",
"->",
"fileSys",
"->",
"create",
"(",
"$",
"file_path",
",",
"$",
"html",
")",
";",
"}",
"}",
"}"
]
| [createCategory 创建分类归档页面]
@DateTime 2018-10-08
@param string $value [description]
@return [type] [description] | [
"[",
"createCategory",
"创建分类归档页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L468-L520 |
seeruo/framework | src/Service/BuildService.php | BuildService.renderCategory | public function renderCategory($rep=[], $pages, $curr_page, $path_key)
{
// 基础路径解析
$path_key_arr = array_filter(explode('__', $path_key), function($s){
return $s !== 'all';
});
$path_key_arr = array_values($path_key_arr);
$path = empty($path_key_arr)? '' : implode('/', $path_key_arr) . '/';
$path = '/category/'. $path;
// 如果分页太多,就创建一个分页导航
$pages_html = '';
if ($pages>1) {
$pages_html .= '<div class="pages">';
for ($i=1; $i <= $pages; $i++) {
if ($i === $curr_page) {
$pages_html .= '<span class="current-page">'.$i.'</span>';
}else{
if ($i === 1) {
$pages_html .= '<a href="'.$path.'">'.$i.'</a>';
}else{
$pages_html .= '<a href="'.$path.'page/'.$i.'">'.$i.'</a>';
}
}
}
$pages_html .= '</div>';
}
$file = [];
// 文件索引
$file['articles_file_index'] = $this->file_index;
// 类型索引相关
$file['articles_type_index'] = $this->type_index;
$file['page_uuid'] = @$this->getLastItem($path_key_arr);
$file['page_uuid_type'] = $path_key_arr;
// 文章相关
$file['articles_list'] = $rep; // 归档列表
$file['articles_pages'] = $pages_html;
$file['web_title'] = $this->config['title']; // 网站标题
$file['title'] = '归档'; // 网站标题
$html = $this->render('archives.html', $file);
return $html;
} | php | public function renderCategory($rep=[], $pages, $curr_page, $path_key)
{
// 基础路径解析
$path_key_arr = array_filter(explode('__', $path_key), function($s){
return $s !== 'all';
});
$path_key_arr = array_values($path_key_arr);
$path = empty($path_key_arr)? '' : implode('/', $path_key_arr) . '/';
$path = '/category/'. $path;
// 如果分页太多,就创建一个分页导航
$pages_html = '';
if ($pages>1) {
$pages_html .= '<div class="pages">';
for ($i=1; $i <= $pages; $i++) {
if ($i === $curr_page) {
$pages_html .= '<span class="current-page">'.$i.'</span>';
}else{
if ($i === 1) {
$pages_html .= '<a href="'.$path.'">'.$i.'</a>';
}else{
$pages_html .= '<a href="'.$path.'page/'.$i.'">'.$i.'</a>';
}
}
}
$pages_html .= '</div>';
}
$file = [];
// 文件索引
$file['articles_file_index'] = $this->file_index;
// 类型索引相关
$file['articles_type_index'] = $this->type_index;
$file['page_uuid'] = @$this->getLastItem($path_key_arr);
$file['page_uuid_type'] = $path_key_arr;
// 文章相关
$file['articles_list'] = $rep; // 归档列表
$file['articles_pages'] = $pages_html;
$file['web_title'] = $this->config['title']; // 网站标题
$file['title'] = '归档'; // 网站标题
$html = $this->render('archives.html', $file);
return $html;
} | [
"public",
"function",
"renderCategory",
"(",
"$",
"rep",
"=",
"[",
"]",
",",
"$",
"pages",
",",
"$",
"curr_page",
",",
"$",
"path_key",
")",
"{",
"// 基础路径解析",
"$",
"path_key_arr",
"=",
"array_filter",
"(",
"explode",
"(",
"'__'",
",",
"$",
"path_key",
")",
",",
"function",
"(",
"$",
"s",
")",
"{",
"return",
"$",
"s",
"!==",
"'all'",
";",
"}",
")",
";",
"$",
"path_key_arr",
"=",
"array_values",
"(",
"$",
"path_key_arr",
")",
";",
"$",
"path",
"=",
"empty",
"(",
"$",
"path_key_arr",
")",
"?",
"''",
":",
"implode",
"(",
"'/'",
",",
"$",
"path_key_arr",
")",
".",
"'/'",
";",
"$",
"path",
"=",
"'/category/'",
".",
"$",
"path",
";",
"// 如果分页太多,就创建一个分页导航",
"$",
"pages_html",
"=",
"''",
";",
"if",
"(",
"$",
"pages",
">",
"1",
")",
"{",
"$",
"pages_html",
".=",
"'<div class=\"pages\">'",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"pages",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"===",
"$",
"curr_page",
")",
"{",
"$",
"pages_html",
".=",
"'<span class=\"current-page\">'",
".",
"$",
"i",
".",
"'</span>'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"i",
"===",
"1",
")",
"{",
"$",
"pages_html",
".=",
"'<a href=\"'",
".",
"$",
"path",
".",
"'\">'",
".",
"$",
"i",
".",
"'</a>'",
";",
"}",
"else",
"{",
"$",
"pages_html",
".=",
"'<a href=\"'",
".",
"$",
"path",
".",
"'page/'",
".",
"$",
"i",
".",
"'\">'",
".",
"$",
"i",
".",
"'</a>'",
";",
"}",
"}",
"}",
"$",
"pages_html",
".=",
"'</div>'",
";",
"}",
"$",
"file",
"=",
"[",
"]",
";",
"// 文件索引",
"$",
"file",
"[",
"'articles_file_index'",
"]",
"=",
"$",
"this",
"->",
"file_index",
";",
"// 类型索引相关",
"$",
"file",
"[",
"'articles_type_index'",
"]",
"=",
"$",
"this",
"->",
"type_index",
";",
"$",
"file",
"[",
"'page_uuid'",
"]",
"=",
"@",
"$",
"this",
"->",
"getLastItem",
"(",
"$",
"path_key_arr",
")",
";",
"$",
"file",
"[",
"'page_uuid_type'",
"]",
"=",
"$",
"path_key_arr",
";",
"// 文章相关",
"$",
"file",
"[",
"'articles_list'",
"]",
"=",
"$",
"rep",
";",
"// 归档列表",
"$",
"file",
"[",
"'articles_pages'",
"]",
"=",
"$",
"pages_html",
";",
"$",
"file",
"[",
"'web_title'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'title'",
"]",
";",
"// 网站标题",
"$",
"file",
"[",
"'title'",
"]",
"=",
"'归档'; /",
"/",
"站标题",
"$",
"html",
"=",
"$",
"this",
"->",
"render",
"(",
"'archives.html'",
",",
"$",
"file",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| [renderCategory 解析分类归档页面]
@Author danier [email protected]
@DateTime 2018-09-19
@param array $rep [文件数组]
@param [type] $pages [总页码]
@param [type] $curr_page [当前页码]
@param [type] $path_key [路径关键字]
@return [type] [description] | [
"[",
"renderCategory",
"解析分类归档页面",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L532-L574 |
seeruo/framework | src/Service/BuildService.php | BuildService.resolveFiles | public function resolveFiles()
{
// 获取文件列表
$files = $this->fileSys->getFiles($this->source_dir);
// 对文件按时间重新排序
$this->resortByTime($files);
// 文章归集
// $lvl_index = []; // 解析文章索引
$new_files = []; // 新的文件数组
foreach ($files as $key => $file) {
// 解析文件名
$file_name = $file['file_name'];
$file_type = substr(strrchr($file_name, '.'), 1);
$file_name = basename($file_name, '.'.$file_type);
// 解析时间并设置归档路径和链接地址
$date = empty($file['date']) ? date('Y-m-d') : date('Y-m-d', strtotime($file['date']));
$date_arr = explode('-', $date);
$file['date'] = $date;
$file['href'] = '/articles/'.$date_arr[0].'/'.$date_arr[1].'/'.$date_arr[2].'/'.$file_name;
$file['public_dir'] = $this->public_dir . $file['href'] . '/index.html'; // 文件生成路径
$file['web_title'] = $this->config['title']; // 网站标题
$file_path = str_replace('\\', '/', $file['file_path']);
$file['page_uuid'] = md5($file_path);
$file['page_uuid_type'] = getpy($file['type'][0]);
$file['page_uuid_type_now'] = getpy($this->getLastItem($file['type']));
// 处理文章分类
if ( empty($file['type']) ) {
$source_dir = str_replace('\\', '/', $this->source_di);
$file_type = str_replace('\\', '/', $file['file_dire']);
$file_type = str_replace($source_dir, '', $file_type);
$file_type = explode('/', trim($file_type));
}else{
$file_type = explode(',', trim($file['type']));
}
// 去除空格
foreach ($file_type as &$t) {
$t = trim($t);
}
$file['type'] = array_values(array_filter($file_type));
$new_files[$file['page_uuid']] = $file;
// dd($this->single_pages);
}
unset($key, $file);
$this->files = $new_files;
// 单文件索引创建:包含标题索引
$this->resolveFileMenu();
// 类型归档索引创建
$this->resolveTypeIndex();
} | php | public function resolveFiles()
{
// 获取文件列表
$files = $this->fileSys->getFiles($this->source_dir);
// 对文件按时间重新排序
$this->resortByTime($files);
// 文章归集
// $lvl_index = []; // 解析文章索引
$new_files = []; // 新的文件数组
foreach ($files as $key => $file) {
// 解析文件名
$file_name = $file['file_name'];
$file_type = substr(strrchr($file_name, '.'), 1);
$file_name = basename($file_name, '.'.$file_type);
// 解析时间并设置归档路径和链接地址
$date = empty($file['date']) ? date('Y-m-d') : date('Y-m-d', strtotime($file['date']));
$date_arr = explode('-', $date);
$file['date'] = $date;
$file['href'] = '/articles/'.$date_arr[0].'/'.$date_arr[1].'/'.$date_arr[2].'/'.$file_name;
$file['public_dir'] = $this->public_dir . $file['href'] . '/index.html'; // 文件生成路径
$file['web_title'] = $this->config['title']; // 网站标题
$file_path = str_replace('\\', '/', $file['file_path']);
$file['page_uuid'] = md5($file_path);
$file['page_uuid_type'] = getpy($file['type'][0]);
$file['page_uuid_type_now'] = getpy($this->getLastItem($file['type']));
// 处理文章分类
if ( empty($file['type']) ) {
$source_dir = str_replace('\\', '/', $this->source_di);
$file_type = str_replace('\\', '/', $file['file_dire']);
$file_type = str_replace($source_dir, '', $file_type);
$file_type = explode('/', trim($file_type));
}else{
$file_type = explode(',', trim($file['type']));
}
// 去除空格
foreach ($file_type as &$t) {
$t = trim($t);
}
$file['type'] = array_values(array_filter($file_type));
$new_files[$file['page_uuid']] = $file;
// dd($this->single_pages);
}
unset($key, $file);
$this->files = $new_files;
// 单文件索引创建:包含标题索引
$this->resolveFileMenu();
// 类型归档索引创建
$this->resolveTypeIndex();
} | [
"public",
"function",
"resolveFiles",
"(",
")",
"{",
"// 获取文件列表",
"$",
"files",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getFiles",
"(",
"$",
"this",
"->",
"source_dir",
")",
";",
"// 对文件按时间重新排序",
"$",
"this",
"->",
"resortByTime",
"(",
"$",
"files",
")",
";",
"// 文章归集",
"// $lvl_index = []; // 解析文章索引",
"$",
"new_files",
"=",
"[",
"]",
";",
"// 新的文件数组",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"// 解析文件名",
"$",
"file_name",
"=",
"$",
"file",
"[",
"'file_name'",
"]",
";",
"$",
"file_type",
"=",
"substr",
"(",
"strrchr",
"(",
"$",
"file_name",
",",
"'.'",
")",
",",
"1",
")",
";",
"$",
"file_name",
"=",
"basename",
"(",
"$",
"file_name",
",",
"'.'",
".",
"$",
"file_type",
")",
";",
"// 解析时间并设置归档路径和链接地址",
"$",
"date",
"=",
"empty",
"(",
"$",
"file",
"[",
"'date'",
"]",
")",
"?",
"date",
"(",
"'Y-m-d'",
")",
":",
"date",
"(",
"'Y-m-d'",
",",
"strtotime",
"(",
"$",
"file",
"[",
"'date'",
"]",
")",
")",
";",
"$",
"date_arr",
"=",
"explode",
"(",
"'-'",
",",
"$",
"date",
")",
";",
"$",
"file",
"[",
"'date'",
"]",
"=",
"$",
"date",
";",
"$",
"file",
"[",
"'href'",
"]",
"=",
"'/articles/'",
".",
"$",
"date_arr",
"[",
"0",
"]",
".",
"'/'",
".",
"$",
"date_arr",
"[",
"1",
"]",
".",
"'/'",
".",
"$",
"date_arr",
"[",
"2",
"]",
".",
"'/'",
".",
"$",
"file_name",
";",
"$",
"file",
"[",
"'public_dir'",
"]",
"=",
"$",
"this",
"->",
"public_dir",
".",
"$",
"file",
"[",
"'href'",
"]",
".",
"'/index.html'",
";",
"// 文件生成路径",
"$",
"file",
"[",
"'web_title'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'title'",
"]",
";",
"// 网站标题",
"$",
"file_path",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"file",
"[",
"'file_path'",
"]",
")",
";",
"$",
"file",
"[",
"'page_uuid'",
"]",
"=",
"md5",
"(",
"$",
"file_path",
")",
";",
"$",
"file",
"[",
"'page_uuid_type'",
"]",
"=",
"getpy",
"(",
"$",
"file",
"[",
"'type'",
"]",
"[",
"0",
"]",
")",
";",
"$",
"file",
"[",
"'page_uuid_type_now'",
"]",
"=",
"getpy",
"(",
"$",
"this",
"->",
"getLastItem",
"(",
"$",
"file",
"[",
"'type'",
"]",
")",
")",
";",
"// 处理文章分类",
"if",
"(",
"empty",
"(",
"$",
"file",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"source_dir",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"this",
"->",
"source_di",
")",
";",
"$",
"file_type",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"file",
"[",
"'file_dire'",
"]",
")",
";",
"$",
"file_type",
"=",
"str_replace",
"(",
"$",
"source_dir",
",",
"''",
",",
"$",
"file_type",
")",
";",
"$",
"file_type",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"file_type",
")",
")",
";",
"}",
"else",
"{",
"$",
"file_type",
"=",
"explode",
"(",
"','",
",",
"trim",
"(",
"$",
"file",
"[",
"'type'",
"]",
")",
")",
";",
"}",
"// 去除空格",
"foreach",
"(",
"$",
"file_type",
"as",
"&",
"$",
"t",
")",
"{",
"$",
"t",
"=",
"trim",
"(",
"$",
"t",
")",
";",
"}",
"$",
"file",
"[",
"'type'",
"]",
"=",
"array_values",
"(",
"array_filter",
"(",
"$",
"file_type",
")",
")",
";",
"$",
"new_files",
"[",
"$",
"file",
"[",
"'page_uuid'",
"]",
"]",
"=",
"$",
"file",
";",
"// dd($this->single_pages);",
"}",
"unset",
"(",
"$",
"key",
",",
"$",
"file",
")",
";",
"$",
"this",
"->",
"files",
"=",
"$",
"new_files",
";",
"// 单文件索引创建:包含标题索引",
"$",
"this",
"->",
"resolveFileMenu",
"(",
")",
";",
"// 类型归档索引创建",
"$",
"this",
"->",
"resolveTypeIndex",
"(",
")",
";",
"}"
]
| [resolveFiles 解析文件]
@Author danier [email protected]
@DateTime 2018-09-18
@return [type] [description] | [
"[",
"resolveFiles",
"解析文件",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L582-L637 |
seeruo/framework | src/Service/BuildService.php | BuildService.resolveFileMenu | public function resolveFileMenu()
{
$file_index = [];
$files = $this->files;
foreach ($files as $key => $file) {
// 单页文件不做索引
if (in_array($file['page_uuid'], $this->single_pages)) {
continue;
}
// 标题索引处理
$content = $this->fileSys->getContent($file['file_path']);
$token = array_filter(explode("\n", $content['content']), function ($d){
if (empty($d)) {
return false;
}
if (strpos($d, "\n#") === false && strpos($d, '#') !== 0 ) {
return false;
}
return true;
});
if (count($token)>0) {
foreach ($token as &$value) {
$value = preg_replace_callback("|(#{1,6} )|", function($m){
return '';
}, $value);
$value = [
'title' => $value,
'href' => '#'.$value,
];
}
}
$index = [
'title' => $file['title'],
'href' => $file['href'],
'uuid' => $file['page_uuid'],
'child' => $token
];
$file_index[$file['page_uuid']] = $index;
}
$this->file_index = $file_index;
// dd($file_index);
} | php | public function resolveFileMenu()
{
$file_index = [];
$files = $this->files;
foreach ($files as $key => $file) {
// 单页文件不做索引
if (in_array($file['page_uuid'], $this->single_pages)) {
continue;
}
// 标题索引处理
$content = $this->fileSys->getContent($file['file_path']);
$token = array_filter(explode("\n", $content['content']), function ($d){
if (empty($d)) {
return false;
}
if (strpos($d, "\n#") === false && strpos($d, '#') !== 0 ) {
return false;
}
return true;
});
if (count($token)>0) {
foreach ($token as &$value) {
$value = preg_replace_callback("|(#{1,6} )|", function($m){
return '';
}, $value);
$value = [
'title' => $value,
'href' => '#'.$value,
];
}
}
$index = [
'title' => $file['title'],
'href' => $file['href'],
'uuid' => $file['page_uuid'],
'child' => $token
];
$file_index[$file['page_uuid']] = $index;
}
$this->file_index = $file_index;
// dd($file_index);
} | [
"public",
"function",
"resolveFileMenu",
"(",
")",
"{",
"$",
"file_index",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"// 单页文件不做索引",
"if",
"(",
"in_array",
"(",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"$",
"this",
"->",
"single_pages",
")",
")",
"{",
"continue",
";",
"}",
"// 标题索引处理",
"$",
"content",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getContent",
"(",
"$",
"file",
"[",
"'file_path'",
"]",
")",
";",
"$",
"token",
"=",
"array_filter",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"content",
"[",
"'content'",
"]",
")",
",",
"function",
"(",
"$",
"d",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"d",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"d",
",",
"\"\\n#\"",
")",
"===",
"false",
"&&",
"strpos",
"(",
"$",
"d",
",",
"'#'",
")",
"!==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"if",
"(",
"count",
"(",
"$",
"token",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"token",
"as",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"preg_replace_callback",
"(",
"\"|(#{1,6} )|\"",
",",
"function",
"(",
"$",
"m",
")",
"{",
"return",
"''",
";",
"}",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"[",
"'title'",
"=>",
"$",
"value",
",",
"'href'",
"=>",
"'#'",
".",
"$",
"value",
",",
"]",
";",
"}",
"}",
"$",
"index",
"=",
"[",
"'title'",
"=>",
"$",
"file",
"[",
"'title'",
"]",
",",
"'href'",
"=>",
"$",
"file",
"[",
"'href'",
"]",
",",
"'uuid'",
"=>",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"'child'",
"=>",
"$",
"token",
"]",
";",
"$",
"file_index",
"[",
"$",
"file",
"[",
"'page_uuid'",
"]",
"]",
"=",
"$",
"index",
";",
"}",
"$",
"this",
"->",
"file_index",
"=",
"$",
"file_index",
";",
"// dd($file_index);",
"}"
]
| [FunctionName 单文件子菜单索引]
@DateTime 2018-10-10
@param string $value [description] | [
"[",
"FunctionName",
"单文件子菜单索引",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L644-L685 |
seeruo/framework | src/Service/BuildService.php | BuildService.resolveTypeIndex | private function resolveTypeIndex()
{
// 构建文件分类
$archives = [];
$files = $this->files;
foreach ($files as $key => $file) {
// 单页文件不做索引
if (in_array($file['page_uuid'], $this->single_pages)) {
continue;
}
// 文件类型处理
$len = count($file['type']);
$str = '';
for ($i=0; $i < $len; $i++) {
$str.= '__' . $file['type'][$i];
$str = trim($str, '__');
$archives[] = $str;
}
}
unset($file);
$archives = array_unique($archives);
$keys = $archives;
foreach ($archives as $k1 => $v1) {
foreach ($keys as $v2) {
if (strpos($v2, $v1) !== false && ($v1 !== $v2)) {
unset($archives[$k1]);
break;
}
}
}
unset($v1,$k1,$v2);
$type_index = [];
foreach ($archives as $key => $t) {
$type = explode('__', $t);
$length = count($type);
$url = '/category';
$type_index = $this->my_merge($type_index, $this->getArray(0, $length, $type, $url));
}
// dd($type_index);
$this->type_index = $type_index;
} | php | private function resolveTypeIndex()
{
// 构建文件分类
$archives = [];
$files = $this->files;
foreach ($files as $key => $file) {
// 单页文件不做索引
if (in_array($file['page_uuid'], $this->single_pages)) {
continue;
}
// 文件类型处理
$len = count($file['type']);
$str = '';
for ($i=0; $i < $len; $i++) {
$str.= '__' . $file['type'][$i];
$str = trim($str, '__');
$archives[] = $str;
}
}
unset($file);
$archives = array_unique($archives);
$keys = $archives;
foreach ($archives as $k1 => $v1) {
foreach ($keys as $v2) {
if (strpos($v2, $v1) !== false && ($v1 !== $v2)) {
unset($archives[$k1]);
break;
}
}
}
unset($v1,$k1,$v2);
$type_index = [];
foreach ($archives as $key => $t) {
$type = explode('__', $t);
$length = count($type);
$url = '/category';
$type_index = $this->my_merge($type_index, $this->getArray(0, $length, $type, $url));
}
// dd($type_index);
$this->type_index = $type_index;
} | [
"private",
"function",
"resolveTypeIndex",
"(",
")",
"{",
"// 构建文件分类",
"$",
"archives",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"// 单页文件不做索引",
"if",
"(",
"in_array",
"(",
"$",
"file",
"[",
"'page_uuid'",
"]",
",",
"$",
"this",
"->",
"single_pages",
")",
")",
"{",
"continue",
";",
"}",
"// 文件类型处理",
"$",
"len",
"=",
"count",
"(",
"$",
"file",
"[",
"'type'",
"]",
")",
";",
"$",
"str",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"str",
".=",
"'__'",
".",
"$",
"file",
"[",
"'type'",
"]",
"[",
"$",
"i",
"]",
";",
"$",
"str",
"=",
"trim",
"(",
"$",
"str",
",",
"'__'",
")",
";",
"$",
"archives",
"[",
"]",
"=",
"$",
"str",
";",
"}",
"}",
"unset",
"(",
"$",
"file",
")",
";",
"$",
"archives",
"=",
"array_unique",
"(",
"$",
"archives",
")",
";",
"$",
"keys",
"=",
"$",
"archives",
";",
"foreach",
"(",
"$",
"archives",
"as",
"$",
"k1",
"=>",
"$",
"v1",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"v2",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"v2",
",",
"$",
"v1",
")",
"!==",
"false",
"&&",
"(",
"$",
"v1",
"!==",
"$",
"v2",
")",
")",
"{",
"unset",
"(",
"$",
"archives",
"[",
"$",
"k1",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"unset",
"(",
"$",
"v1",
",",
"$",
"k1",
",",
"$",
"v2",
")",
";",
"$",
"type_index",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"archives",
"as",
"$",
"key",
"=>",
"$",
"t",
")",
"{",
"$",
"type",
"=",
"explode",
"(",
"'__'",
",",
"$",
"t",
")",
";",
"$",
"length",
"=",
"count",
"(",
"$",
"type",
")",
";",
"$",
"url",
"=",
"'/category'",
";",
"$",
"type_index",
"=",
"$",
"this",
"->",
"my_merge",
"(",
"$",
"type_index",
",",
"$",
"this",
"->",
"getArray",
"(",
"0",
",",
"$",
"length",
",",
"$",
"type",
",",
"$",
"url",
")",
")",
";",
"}",
"// dd($type_index);",
"$",
"this",
"->",
"type_index",
"=",
"$",
"type_index",
";",
"}"
]
| [resolveTypeIndex 根据类型多级分类]
@DateTime 2018-10-09
@param [type] $arr [description]
@return [type] [description] | [
"[",
"resolveTypeIndex",
"根据类型多级分类",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L694-L736 |
seeruo/framework | src/Service/BuildService.php | BuildService.my_merge | private function my_merge($a, $b){
if (is_array($b)) {
foreach ($b as $k => $v) {
if (isset($a[$k])) {
$a[$k] = $this->my_merge($a[$k], $v);
}else{
$a[$k] = $v;
}
}
}
@asort($a);
return $a;
} | php | private function my_merge($a, $b){
if (is_array($b)) {
foreach ($b as $k => $v) {
if (isset($a[$k])) {
$a[$k] = $this->my_merge($a[$k], $v);
}else{
$a[$k] = $v;
}
}
}
@asort($a);
return $a;
} | [
"private",
"function",
"my_merge",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"b",
")",
")",
"{",
"foreach",
"(",
"$",
"b",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"k",
"]",
")",
")",
"{",
"$",
"a",
"[",
"$",
"k",
"]",
"=",
"$",
"this",
"->",
"my_merge",
"(",
"$",
"a",
"[",
"$",
"k",
"]",
",",
"$",
"v",
")",
";",
"}",
"else",
"{",
"$",
"a",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"}",
"@",
"asort",
"(",
"$",
"a",
")",
";",
"return",
"$",
"a",
";",
"}"
]
| [my_merge 数组深处合并]
@DateTime 2018-10-10
@param [type] $a [description]
@param [type] $b [description]
@return [type] [description] | [
"[",
"my_merge",
"数组深处合并",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L745-L757 |
seeruo/framework | src/Service/BuildService.php | BuildService.getArray | private function getArray($i, $length, $arr, $url){
$str=array();
if($i==$length-1){
$str[$arr[$i]] = [
'title' => $arr[$i],
'href' => $url.'/'.getpy($arr[$i]),
'uuid' => getpy($arr[$i])
];
}else{
$str[$arr[$i]]['title'] = $arr[$i];
$str[$arr[$i]]['href'] = $url.'/'.getpy($arr[$i]);
$str[$arr[$i]]['uuid'] = getpy($arr[$i]);
$str[$arr[$i]]['child'] = $this->getArray($i+1, $length, $arr, $str[$arr[$i]]['href']);
}
return $str;
} | php | private function getArray($i, $length, $arr, $url){
$str=array();
if($i==$length-1){
$str[$arr[$i]] = [
'title' => $arr[$i],
'href' => $url.'/'.getpy($arr[$i]),
'uuid' => getpy($arr[$i])
];
}else{
$str[$arr[$i]]['title'] = $arr[$i];
$str[$arr[$i]]['href'] = $url.'/'.getpy($arr[$i]);
$str[$arr[$i]]['uuid'] = getpy($arr[$i]);
$str[$arr[$i]]['child'] = $this->getArray($i+1, $length, $arr, $str[$arr[$i]]['href']);
}
return $str;
} | [
"private",
"function",
"getArray",
"(",
"$",
"i",
",",
"$",
"length",
",",
"$",
"arr",
",",
"$",
"url",
")",
"{",
"$",
"str",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"i",
"==",
"$",
"length",
"-",
"1",
")",
"{",
"$",
"str",
"[",
"$",
"arr",
"[",
"$",
"i",
"]",
"]",
"=",
"[",
"'title'",
"=>",
"$",
"arr",
"[",
"$",
"i",
"]",
",",
"'href'",
"=>",
"$",
"url",
".",
"'/'",
".",
"getpy",
"(",
"$",
"arr",
"[",
"$",
"i",
"]",
")",
",",
"'uuid'",
"=>",
"getpy",
"(",
"$",
"arr",
"[",
"$",
"i",
"]",
")",
"]",
";",
"}",
"else",
"{",
"$",
"str",
"[",
"$",
"arr",
"[",
"$",
"i",
"]",
"]",
"[",
"'title'",
"]",
"=",
"$",
"arr",
"[",
"$",
"i",
"]",
";",
"$",
"str",
"[",
"$",
"arr",
"[",
"$",
"i",
"]",
"]",
"[",
"'href'",
"]",
"=",
"$",
"url",
".",
"'/'",
".",
"getpy",
"(",
"$",
"arr",
"[",
"$",
"i",
"]",
")",
";",
"$",
"str",
"[",
"$",
"arr",
"[",
"$",
"i",
"]",
"]",
"[",
"'uuid'",
"]",
"=",
"getpy",
"(",
"$",
"arr",
"[",
"$",
"i",
"]",
")",
";",
"$",
"str",
"[",
"$",
"arr",
"[",
"$",
"i",
"]",
"]",
"[",
"'child'",
"]",
"=",
"$",
"this",
"->",
"getArray",
"(",
"$",
"i",
"+",
"1",
",",
"$",
"length",
",",
"$",
"arr",
",",
"$",
"str",
"[",
"$",
"arr",
"[",
"$",
"i",
"]",
"]",
"[",
"'href'",
"]",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
]
| [getArray 字符串转数组]
@DateTime 2018-10-10
@param [type] $i [description]
@param [type] $length [description]
@param [type] $arr [description]
@param [type] $url [description]
@return [type] [description] | [
"[",
"getArray",
"字符串转数组",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L768-L784 |
seeruo/framework | src/Service/BuildService.php | BuildService.resortByTime | private function resortByTime(&$files)
{
$length = count($files); // 文件数量
for($i=1; $i<$length; $i++) {
for($j=0; $j<$length - $i; $j++){
if ( (int)strtotime($files[$j]['date']) < (int)strtotime($files[$j+1]['date'])) {
$temp = $files[$j+1];
$files[$j+1] = $files[$j];
$files[$j] = $temp;
}
}
}
} | php | private function resortByTime(&$files)
{
$length = count($files); // 文件数量
for($i=1; $i<$length; $i++) {
for($j=0; $j<$length - $i; $j++){
if ( (int)strtotime($files[$j]['date']) < (int)strtotime($files[$j+1]['date'])) {
$temp = $files[$j+1];
$files[$j+1] = $files[$j];
$files[$j] = $temp;
}
}
}
} | [
"private",
"function",
"resortByTime",
"(",
"&",
"$",
"files",
")",
"{",
"$",
"length",
"=",
"count",
"(",
"$",
"files",
")",
";",
"// 文件数量",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"length",
"-",
"$",
"i",
";",
"$",
"j",
"++",
")",
"{",
"if",
"(",
"(",
"int",
")",
"strtotime",
"(",
"$",
"files",
"[",
"$",
"j",
"]",
"[",
"'date'",
"]",
")",
"<",
"(",
"int",
")",
"strtotime",
"(",
"$",
"files",
"[",
"$",
"j",
"+",
"1",
"]",
"[",
"'date'",
"]",
")",
")",
"{",
"$",
"temp",
"=",
"$",
"files",
"[",
"$",
"j",
"+",
"1",
"]",
";",
"$",
"files",
"[",
"$",
"j",
"+",
"1",
"]",
"=",
"$",
"files",
"[",
"$",
"j",
"]",
";",
"$",
"files",
"[",
"$",
"j",
"]",
"=",
"$",
"temp",
";",
"}",
"}",
"}",
"}"
]
| [resortByTime 对数组按照时间重新排序]
@DateTime 2018-10-09
@param [type] &$files [description]
@return [type] [description] | [
"[",
"resortByTime",
"对数组按照时间重新排序",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L809-L821 |
seeruo/framework | src/Service/BuildService.php | BuildService.checkSinglePages | public function checkSinglePages()
{
$sg_pgs = @$this->config['single_pages'] ?: [];
$sg_pgs = array_values($sg_pgs);
// 检查需要剔除的页面
$home_page = @$this->config['home_page'] ?: '';
if (!empty($home_page)) {
array_push($sg_pgs, $home_page);
}
if (!empty($sg_pgs)) {
array_walk($sg_pgs, function(&$d){
$source_dir = str_replace('\\', '/', $this->source_dir);
$d = md5($source_dir . '/' . $d);
});
}
$this->single_pages = $sg_pgs;
} | php | public function checkSinglePages()
{
$sg_pgs = @$this->config['single_pages'] ?: [];
$sg_pgs = array_values($sg_pgs);
// 检查需要剔除的页面
$home_page = @$this->config['home_page'] ?: '';
if (!empty($home_page)) {
array_push($sg_pgs, $home_page);
}
if (!empty($sg_pgs)) {
array_walk($sg_pgs, function(&$d){
$source_dir = str_replace('\\', '/', $this->source_dir);
$d = md5($source_dir . '/' . $d);
});
}
$this->single_pages = $sg_pgs;
} | [
"public",
"function",
"checkSinglePages",
"(",
")",
"{",
"$",
"sg_pgs",
"=",
"@",
"$",
"this",
"->",
"config",
"[",
"'single_pages'",
"]",
"?",
":",
"[",
"]",
";",
"$",
"sg_pgs",
"=",
"array_values",
"(",
"$",
"sg_pgs",
")",
";",
"// 检查需要剔除的页面",
"$",
"home_page",
"=",
"@",
"$",
"this",
"->",
"config",
"[",
"'home_page'",
"]",
"?",
":",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"home_page",
")",
")",
"{",
"array_push",
"(",
"$",
"sg_pgs",
",",
"$",
"home_page",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"sg_pgs",
")",
")",
"{",
"array_walk",
"(",
"$",
"sg_pgs",
",",
"function",
"(",
"&",
"$",
"d",
")",
"{",
"$",
"source_dir",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"this",
"->",
"source_dir",
")",
";",
"$",
"d",
"=",
"md5",
"(",
"$",
"source_dir",
".",
"'/'",
".",
"$",
"d",
")",
";",
"}",
")",
";",
"}",
"$",
"this",
"->",
"single_pages",
"=",
"$",
"sg_pgs",
";",
"}"
]
| [checkSinglePages 监测单页]
@DateTime 2018-10-09
@return [type] [description] | [
"[",
"checkSinglePages",
"监测单页",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L828-L844 |
seeruo/framework | src/Service/BuildService.php | BuildService.render | public function render($file, $data=[])
{
\Twig_Autoloader::register();
$loader = new \Twig_loader_Filesystem($this->themes_dir);
$twig = new \Twig_Environment(
$loader,
[
'cache' => false, //或者直接指定路径
'debug' => false
]
);
$template = $twig->loadTemplate($file);
$html = $template->render($data);
return $html;
} | php | public function render($file, $data=[])
{
\Twig_Autoloader::register();
$loader = new \Twig_loader_Filesystem($this->themes_dir);
$twig = new \Twig_Environment(
$loader,
[
'cache' => false, //或者直接指定路径
'debug' => false
]
);
$template = $twig->loadTemplate($file);
$html = $template->render($data);
return $html;
} | [
"public",
"function",
"render",
"(",
"$",
"file",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"\\",
"Twig_Autoloader",
"::",
"register",
"(",
")",
";",
"$",
"loader",
"=",
"new",
"\\",
"Twig_loader_Filesystem",
"(",
"$",
"this",
"->",
"themes_dir",
")",
";",
"$",
"twig",
"=",
"new",
"\\",
"Twig_Environment",
"(",
"$",
"loader",
",",
"[",
"'cache'",
"=>",
"false",
",",
"//或者直接指定路径",
"'debug'",
"=>",
"false",
"]",
")",
";",
"$",
"template",
"=",
"$",
"twig",
"->",
"loadTemplate",
"(",
"$",
"file",
")",
";",
"$",
"html",
"=",
"$",
"template",
"->",
"render",
"(",
"$",
"data",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| [render 模版解析]
@DateTime 2018-10-09
@param [type] $file [模版文件]
@param array $data [填充数据]
@return [type] [模版代码] | [
"[",
"render",
"模版解析",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L853-L867 |
seeruo/framework | src/Service/BuildService.php | BuildService.getFilesHashKey | public function getFilesHashKey()
{
$file_locker = [];
// $config = $this->config['config_root'].'/config.php';
// $file_config = [];
// $file = @$this->fileSys->getContent($this->config['config_root'].'/config.php');
// $file_config[] = $file['setting'];
$files_source = $this->fileSys->getFiles($this->source_dir);
$files_themes = $this->fileSys->getFiles($this->themes_dir);
$files = array_merge($files_source, $files_themes);
foreach ($files as $file) {
$file_locker[] = md5_file($file['file_path']);
}
return $file_locker;
} | php | public function getFilesHashKey()
{
$file_locker = [];
// $config = $this->config['config_root'].'/config.php';
// $file_config = [];
// $file = @$this->fileSys->getContent($this->config['config_root'].'/config.php');
// $file_config[] = $file['setting'];
$files_source = $this->fileSys->getFiles($this->source_dir);
$files_themes = $this->fileSys->getFiles($this->themes_dir);
$files = array_merge($files_source, $files_themes);
foreach ($files as $file) {
$file_locker[] = md5_file($file['file_path']);
}
return $file_locker;
} | [
"public",
"function",
"getFilesHashKey",
"(",
")",
"{",
"$",
"file_locker",
"=",
"[",
"]",
";",
"// $config = $this->config['config_root'].'/config.php';",
"// $file_config = [];",
"// $file = @$this->fileSys->getContent($this->config['config_root'].'/config.php');",
"// $file_config[] = $file['setting'];",
"$",
"files_source",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getFiles",
"(",
"$",
"this",
"->",
"source_dir",
")",
";",
"$",
"files_themes",
"=",
"$",
"this",
"->",
"fileSys",
"->",
"getFiles",
"(",
"$",
"this",
"->",
"themes_dir",
")",
";",
"$",
"files",
"=",
"array_merge",
"(",
"$",
"files_source",
",",
"$",
"files_themes",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"file_locker",
"[",
"]",
"=",
"md5_file",
"(",
"$",
"file",
"[",
"'file_path'",
"]",
")",
";",
"}",
"return",
"$",
"file_locker",
";",
"}"
]
| [getFilesHashKey 获取文件hash-key]
@DateTime 2018-09-23
@return [type] [description] | [
"[",
"getFilesHashKey",
"获取文件hash",
"-",
"key",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L875-L889 |
seeruo/framework | src/Service/BuildService.php | BuildService.listen | public function listen()
{
try {
Log::info('['.date('H:i:s').']文件监测程序运行中...');
while (true) {
sleep(1);
// 获取新key
$now_keys = $this->getFilesHashKey();
// 获取旧key
$old_keys = file_get_contents(ROOT.'/Config/lock.key');
$old_keys = explode('-', $old_keys);
// 监测key值变化
$diff_new = array_diff($now_keys, $old_keys);
$diff_old = array_diff($old_keys, $now_keys);
$diff = array_merge($diff_new, $diff_old);
// 如果有文件发生了修改删除,编辑
if (!empty($diff)) {
Log::info('['.date('H:i:s').']发现文件变动,开始执行渲染...');
$files_key_str = implode('-', $now_keys);
// 执行渲染操作
$this->run();
file_put_contents(ROOT.'/Config/lock.key', $files_key_str);
Log::info('['.date('H:i:s').']文件渲染已经完成!');
Log::info('['.date('H:i:s').']文件监测程序运行中...');
}
}
} catch (Exception $e) {
Log::info('['.date('H:i:s').']文件渲染错误,程序退出!');
exit();
}
} | php | public function listen()
{
try {
Log::info('['.date('H:i:s').']文件监测程序运行中...');
while (true) {
sleep(1);
// 获取新key
$now_keys = $this->getFilesHashKey();
// 获取旧key
$old_keys = file_get_contents(ROOT.'/Config/lock.key');
$old_keys = explode('-', $old_keys);
// 监测key值变化
$diff_new = array_diff($now_keys, $old_keys);
$diff_old = array_diff($old_keys, $now_keys);
$diff = array_merge($diff_new, $diff_old);
// 如果有文件发生了修改删除,编辑
if (!empty($diff)) {
Log::info('['.date('H:i:s').']发现文件变动,开始执行渲染...');
$files_key_str = implode('-', $now_keys);
// 执行渲染操作
$this->run();
file_put_contents(ROOT.'/Config/lock.key', $files_key_str);
Log::info('['.date('H:i:s').']文件渲染已经完成!');
Log::info('['.date('H:i:s').']文件监测程序运行中...');
}
}
} catch (Exception $e) {
Log::info('['.date('H:i:s').']文件渲染错误,程序退出!');
exit();
}
} | [
"public",
"function",
"listen",
"(",
")",
"{",
"try",
"{",
"Log",
"::",
"info",
"(",
"'['",
".",
"date",
"(",
"'H:i:s'",
")",
".",
"']文件监测程序运行中...');",
"",
"",
"while",
"(",
"true",
")",
"{",
"sleep",
"(",
"1",
")",
";",
"// 获取新key",
"$",
"now_keys",
"=",
"$",
"this",
"->",
"getFilesHashKey",
"(",
")",
";",
"// 获取旧key",
"$",
"old_keys",
"=",
"file_get_contents",
"(",
"ROOT",
".",
"'/Config/lock.key'",
")",
";",
"$",
"old_keys",
"=",
"explode",
"(",
"'-'",
",",
"$",
"old_keys",
")",
";",
"// 监测key值变化",
"$",
"diff_new",
"=",
"array_diff",
"(",
"$",
"now_keys",
",",
"$",
"old_keys",
")",
";",
"$",
"diff_old",
"=",
"array_diff",
"(",
"$",
"old_keys",
",",
"$",
"now_keys",
")",
";",
"$",
"diff",
"=",
"array_merge",
"(",
"$",
"diff_new",
",",
"$",
"diff_old",
")",
";",
"// 如果有文件发生了修改删除,编辑",
"if",
"(",
"!",
"empty",
"(",
"$",
"diff",
")",
")",
"{",
"Log",
"::",
"info",
"(",
"'['",
".",
"date",
"(",
"'H:i:s'",
")",
".",
"']发现文件变动,开始执行渲染...');",
"",
"",
"$",
"files_key_str",
"=",
"implode",
"(",
"'-'",
",",
"$",
"now_keys",
")",
";",
"// 执行渲染操作",
"$",
"this",
"->",
"run",
"(",
")",
";",
"file_put_contents",
"(",
"ROOT",
".",
"'/Config/lock.key'",
",",
"$",
"files_key_str",
")",
";",
"Log",
"::",
"info",
"(",
"'['",
".",
"date",
"(",
"'H:i:s'",
")",
".",
"']文件渲染已经完成!');",
"",
"",
"Log",
"::",
"info",
"(",
"'['",
".",
"date",
"(",
"'H:i:s'",
")",
".",
"']文件监测程序运行中...');",
"",
"",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"info",
"(",
"'['",
".",
"date",
"(",
"'H:i:s'",
")",
".",
"']文件渲染错误,程序退出!');",
"",
"",
"exit",
"(",
")",
";",
"}",
"}"
]
| [文件变动监听]
@Author danier [email protected]
@DateTime 2018-08-25
@return [type] | [
"[",
"文件变动监听",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Service/BuildService.php#L897-L927 |
webforge-labs/psc-cms | lib/Psc/Doctrine/NavigationNodeRepository.php | NavigationNodeRepository.findAllNodes | public function findAllNodes($context = NULL) {
$qb = $this->createQueryBuilder('node');
$qb->addSelect('page');
$qb->leftJoin('node.page', 'page');
$qb->andWhere($qb->expr()->eq('node.context', ':context'));
$query = $qb->getQuery();
$query->setParameter('context', $context ?: $this->context);
return $query->getResult();
} | php | public function findAllNodes($context = NULL) {
$qb = $this->createQueryBuilder('node');
$qb->addSelect('page');
$qb->leftJoin('node.page', 'page');
$qb->andWhere($qb->expr()->eq('node.context', ':context'));
$query = $qb->getQuery();
$query->setParameter('context', $context ?: $this->context);
return $query->getResult();
} | [
"public",
"function",
"findAllNodes",
"(",
"$",
"context",
"=",
"NULL",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'node'",
")",
";",
"$",
"qb",
"->",
"addSelect",
"(",
"'page'",
")",
";",
"$",
"qb",
"->",
"leftJoin",
"(",
"'node.page'",
",",
"'page'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'node.context'",
",",
"':context'",
")",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'context'",
",",
"$",
"context",
"?",
":",
"$",
"this",
"->",
"context",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
]
| Returns all Nodes (not filtered in any way except $context)
@return array | [
"Returns",
"all",
"Nodes",
"(",
"not",
"filtered",
"in",
"any",
"way",
"except",
"$context",
")"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/NavigationNodeRepository.php#L103-L113 |
webforge-labs/psc-cms | lib/Psc/Doctrine/NavigationNodeRepository.php | NavigationNodeRepository.exportParentPointer | public function exportParentPointer($locale, \Closure $qbHook = NULL) {
$qb = $this->childrenQueryBuilder(NULL, $qbHook ?: $this->getDefaultQueryBuilderHook());
$query = $qb->getQuery();
$nodes = $query->getResult();
$exported = array();
foreach ($nodes as $node) {
$exported[] = array(
'title'=>$node->getTitle($locale),
'parent'=>$node->getParent() !== NULL ? $node->getParent()->getTitle($locale) : NULL,
'depth'=>$node->getDepth()
);
}
return $exported;
} | php | public function exportParentPointer($locale, \Closure $qbHook = NULL) {
$qb = $this->childrenQueryBuilder(NULL, $qbHook ?: $this->getDefaultQueryBuilderHook());
$query = $qb->getQuery();
$nodes = $query->getResult();
$exported = array();
foreach ($nodes as $node) {
$exported[] = array(
'title'=>$node->getTitle($locale),
'parent'=>$node->getParent() !== NULL ? $node->getParent()->getTitle($locale) : NULL,
'depth'=>$node->getDepth()
);
}
return $exported;
} | [
"public",
"function",
"exportParentPointer",
"(",
"$",
"locale",
",",
"\\",
"Closure",
"$",
"qbHook",
"=",
"NULL",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"childrenQueryBuilder",
"(",
"NULL",
",",
"$",
"qbHook",
"?",
":",
"$",
"this",
"->",
"getDefaultQueryBuilderHook",
"(",
")",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"$",
"exported",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"exported",
"[",
"]",
"=",
"array",
"(",
"'title'",
"=>",
"$",
"node",
"->",
"getTitle",
"(",
"$",
"locale",
")",
",",
"'parent'",
"=>",
"$",
"node",
"->",
"getParent",
"(",
")",
"!==",
"NULL",
"?",
"$",
"node",
"->",
"getParent",
"(",
")",
"->",
"getTitle",
"(",
"$",
"locale",
")",
":",
"NULL",
",",
"'depth'",
"=>",
"$",
"node",
"->",
"getDepth",
"(",
")",
")",
";",
"}",
"return",
"$",
"exported",
";",
"}"
]
| Returns a parentPointer array, linked with just one title of $locale
useful for creating nested set examples
@return array[] | [
"Returns",
"a",
"parentPointer",
"array",
"linked",
"with",
"just",
"one",
"title",
"of",
"$locale"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/NavigationNodeRepository.php#L181-L196 |
webforge-labs/psc-cms | lib/Psc/Doctrine/NavigationNodeRepository.php | NavigationNodeRepository.getPath | public function getPath($node) {
// ACTIVE ?
$qb = $this->createQueryBuilder('node');
$qb
->where($qb->expr()->lte('node.lft', $node->getLft()))
->andWhere($qb->expr()->gte('node.rgt', $node->getRgt()))
->andWhere('node.context = :context')
->orderBy('node.lft', 'ASC')
;
/*
if (isset($config['root'])) {
$rootId = $wrapped->getPropertyValue($config['root']);
$qb->andWhere($rootId === null ?
$qb->expr()->isNull('node.'.$config['root']) :
$qb->expr()->eq('node.'.$config['root'], is_string($rootId) ? $qb->expr()->literal($rootId) : $rootId)
);
}
*/
$query = $qb->getQuery()->setParameter('context', $node->getContext());
return $query->getResult();
} | php | public function getPath($node) {
// ACTIVE ?
$qb = $this->createQueryBuilder('node');
$qb
->where($qb->expr()->lte('node.lft', $node->getLft()))
->andWhere($qb->expr()->gte('node.rgt', $node->getRgt()))
->andWhere('node.context = :context')
->orderBy('node.lft', 'ASC')
;
/*
if (isset($config['root'])) {
$rootId = $wrapped->getPropertyValue($config['root']);
$qb->andWhere($rootId === null ?
$qb->expr()->isNull('node.'.$config['root']) :
$qb->expr()->eq('node.'.$config['root'], is_string($rootId) ? $qb->expr()->literal($rootId) : $rootId)
);
}
*/
$query = $qb->getQuery()->setParameter('context', $node->getContext());
return $query->getResult();
} | [
"public",
"function",
"getPath",
"(",
"$",
"node",
")",
"{",
"// ACTIVE ?",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'node'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"'node.lft'",
",",
"$",
"node",
"->",
"getLft",
"(",
")",
")",
")",
"->",
"andWhere",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"gte",
"(",
"'node.rgt'",
",",
"$",
"node",
"->",
"getRgt",
"(",
")",
")",
")",
"->",
"andWhere",
"(",
"'node.context = :context'",
")",
"->",
"orderBy",
"(",
"'node.lft'",
",",
"'ASC'",
")",
";",
"/*\n if (isset($config['root'])) {\n $rootId = $wrapped->getPropertyValue($config['root']);\n $qb->andWhere($rootId === null ?\n $qb->expr()->isNull('node.'.$config['root']) :\n $qb->expr()->eq('node.'.$config['root'], is_string($rootId) ? $qb->expr()->literal($rootId) : $rootId)\n );\n }\n */",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"setParameter",
"(",
"'context'",
",",
"$",
"node",
"->",
"getContext",
"(",
")",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
]
| Get the path of a node
the path first element is the root node
the last node is $node itself
@param object $node
@return array() | [
"Get",
"the",
"path",
"of",
"a",
"node"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/NavigationNodeRepository.php#L310-L333 |
slashworks/control-bundle | src/Slashworks/AppBundle/Services/Api.php | Api.call | public static function call($method, $params, $url, $publickey, $oRemoteApp = null)
{
$response = "";
try {
$sOldErrorhandler = set_error_handler('Slashworks\AppBundle\Services\Api::errorHandler');
if(!self::$_container){
throw new \InvalidArgumentException("Container not given...");
}
if (!is_scalar($method)) {
throw new \Exception('Method name has no scalar value');
}
// check
if (is_array($params)) {
// no keys
$params = array_values($params);
} else {
throw new \Exception('Params must be given as array');
}
// prepares the request
$request = array(
'method' => $method,
'params' => $params,
'id' => rand(1, 999)
);
$request = json_encode($request);
$rsa = new \Crypt_RSA();
$rsa->loadKey($publickey);
$sAppPath = self::$_container->get('kernel')->getRootDir();
$sVendorPath = $sAppPath."/../vendor/slashworks/control-bundle/src/Slashworks/";
$sKeyPath = $sVendorPath."AppBundle/Resources/private/api/keys/server/";
$conairKey = file_get_contents($sKeyPath . "public.key");
$aRequest = array(
'pkey' => $conairKey,
'data' => base64_encode($rsa->encrypt($request))
);
$sRequest = json_encode($aRequest);
$headers = array(
'Content-Type: application/json'
);
if ($oRemoteApp->getApiAuthType() == "http-basic") {
$sUsername = $oRemoteApp->getApiAuthHttpUser();
$sPassword = $oRemoteApp->getApiAuthHttpPassword();
if (!empty($sUsername) && !empty($sPassword)) {
$headers[] = "Authorization: Basic " . base64_encode($oRemoteApp->getApiAuthHttpUser() . ":" . $oRemoteApp->getApiAuthHttpPassword());
}
}
$oRequest = curl_init($url);
curl_setopt($oRequest, CURLOPT_HTTPHEADER, $headers);
curl_setopt($oRequest, CURLOPT_TIMEOUT, 5);
curl_setopt($oRequest, CURLOPT_POST, 1);
curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest);
curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($oRequest);
$iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE);
$error = curl_error($oRequest);
curl_close($oRequest);
$rawResponse = $response;
if ($response == "") {
throw new \Exception("No content received for call on: ".$url);
}
if ($iHttpStatus === 200) {
$response = json_decode($response, true);
if (!isset($response['data'])) {
throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
}
$privateKey = file_get_contents(__DIR__ . "/../Resources/private/api/keys/server/private.key");
$rsa->loadKey($privateKey);
$data = base64_decode($response['data']);
$decoded = $rsa->decrypt($data);
$response['data'] = json_decode($decoded, true);
if (!is_array($response['data'])) {
throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
}
$response['data']['statuscode'] = $iHttpStatus;
if($iHttpStatus !== 200){
$response['error'] = true;
}
ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $decoded);
restore_error_handler();
return $response['data'];
} else {
ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $response);
restore_error_handler();
return array(
"statuscode" => $iHttpStatus,
"result" => json_encode(array(
"status" => false,
"error" => true,
"statuscode" => $iHttpStatus,
"message" => $response
)
)
);
}
} catch (ContextErrorException $e) {
restore_error_handler();
ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());
return array(
"statuscode" => $iHttpStatus,
"result" => json_encode(array(
"status" => false,
"error" => true,
"statuscode" => -1,
"message" => $e->getMessage()
)
)
);
} catch (\Exception $e) {
restore_error_handler();
ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());
return array(
"statuscode" => 500,
"result" => json_encode(array(
"status" => false,
"error" => true,
"statuscode" => -1,
"message" => $e->getMessage()
)
)
);
}
} | php | public static function call($method, $params, $url, $publickey, $oRemoteApp = null)
{
$response = "";
try {
$sOldErrorhandler = set_error_handler('Slashworks\AppBundle\Services\Api::errorHandler');
if(!self::$_container){
throw new \InvalidArgumentException("Container not given...");
}
if (!is_scalar($method)) {
throw new \Exception('Method name has no scalar value');
}
// check
if (is_array($params)) {
// no keys
$params = array_values($params);
} else {
throw new \Exception('Params must be given as array');
}
// prepares the request
$request = array(
'method' => $method,
'params' => $params,
'id' => rand(1, 999)
);
$request = json_encode($request);
$rsa = new \Crypt_RSA();
$rsa->loadKey($publickey);
$sAppPath = self::$_container->get('kernel')->getRootDir();
$sVendorPath = $sAppPath."/../vendor/slashworks/control-bundle/src/Slashworks/";
$sKeyPath = $sVendorPath."AppBundle/Resources/private/api/keys/server/";
$conairKey = file_get_contents($sKeyPath . "public.key");
$aRequest = array(
'pkey' => $conairKey,
'data' => base64_encode($rsa->encrypt($request))
);
$sRequest = json_encode($aRequest);
$headers = array(
'Content-Type: application/json'
);
if ($oRemoteApp->getApiAuthType() == "http-basic") {
$sUsername = $oRemoteApp->getApiAuthHttpUser();
$sPassword = $oRemoteApp->getApiAuthHttpPassword();
if (!empty($sUsername) && !empty($sPassword)) {
$headers[] = "Authorization: Basic " . base64_encode($oRemoteApp->getApiAuthHttpUser() . ":" . $oRemoteApp->getApiAuthHttpPassword());
}
}
$oRequest = curl_init($url);
curl_setopt($oRequest, CURLOPT_HTTPHEADER, $headers);
curl_setopt($oRequest, CURLOPT_TIMEOUT, 5);
curl_setopt($oRequest, CURLOPT_POST, 1);
curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest);
curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($oRequest);
$iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE);
$error = curl_error($oRequest);
curl_close($oRequest);
$rawResponse = $response;
if ($response == "") {
throw new \Exception("No content received for call on: ".$url);
}
if ($iHttpStatus === 200) {
$response = json_decode($response, true);
if (!isset($response['data'])) {
throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
}
$privateKey = file_get_contents(__DIR__ . "/../Resources/private/api/keys/server/private.key");
$rsa->loadKey($privateKey);
$data = base64_decode($response['data']);
$decoded = $rsa->decrypt($data);
$response['data'] = json_decode($decoded, true);
if (!is_array($response['data'])) {
throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
}
$response['data']['statuscode'] = $iHttpStatus;
if($iHttpStatus !== 200){
$response['error'] = true;
}
ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $decoded);
restore_error_handler();
return $response['data'];
} else {
ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $response);
restore_error_handler();
return array(
"statuscode" => $iHttpStatus,
"result" => json_encode(array(
"status" => false,
"error" => true,
"statuscode" => $iHttpStatus,
"message" => $response
)
)
);
}
} catch (ContextErrorException $e) {
restore_error_handler();
ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());
return array(
"statuscode" => $iHttpStatus,
"result" => json_encode(array(
"status" => false,
"error" => true,
"statuscode" => -1,
"message" => $e->getMessage()
)
)
);
} catch (\Exception $e) {
restore_error_handler();
ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());
return array(
"statuscode" => 500,
"result" => json_encode(array(
"status" => false,
"error" => true,
"statuscode" => -1,
"message" => $e->getMessage()
)
)
);
}
} | [
"public",
"static",
"function",
"call",
"(",
"$",
"method",
",",
"$",
"params",
",",
"$",
"url",
",",
"$",
"publickey",
",",
"$",
"oRemoteApp",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"\"\"",
";",
"try",
"{",
"$",
"sOldErrorhandler",
"=",
"set_error_handler",
"(",
"'Slashworks\\AppBundle\\Services\\Api::errorHandler'",
")",
";",
"if",
"(",
"!",
"self",
"::",
"$",
"_container",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Container not given...\"",
")",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Method name has no scalar value'",
")",
";",
"}",
"// check",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"// no keys",
"$",
"params",
"=",
"array_values",
"(",
"$",
"params",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Params must be given as array'",
")",
";",
"}",
"// prepares the request",
"$",
"request",
"=",
"array",
"(",
"'method'",
"=>",
"$",
"method",
",",
"'params'",
"=>",
"$",
"params",
",",
"'id'",
"=>",
"rand",
"(",
"1",
",",
"999",
")",
")",
";",
"$",
"request",
"=",
"json_encode",
"(",
"$",
"request",
")",
";",
"$",
"rsa",
"=",
"new",
"\\",
"Crypt_RSA",
"(",
")",
";",
"$",
"rsa",
"->",
"loadKey",
"(",
"$",
"publickey",
")",
";",
"$",
"sAppPath",
"=",
"self",
"::",
"$",
"_container",
"->",
"get",
"(",
"'kernel'",
")",
"->",
"getRootDir",
"(",
")",
";",
"$",
"sVendorPath",
"=",
"$",
"sAppPath",
".",
"\"/../vendor/slashworks/control-bundle/src/Slashworks/\"",
";",
"$",
"sKeyPath",
"=",
"$",
"sVendorPath",
".",
"\"AppBundle/Resources/private/api/keys/server/\"",
";",
"$",
"conairKey",
"=",
"file_get_contents",
"(",
"$",
"sKeyPath",
".",
"\"public.key\"",
")",
";",
"$",
"aRequest",
"=",
"array",
"(",
"'pkey'",
"=>",
"$",
"conairKey",
",",
"'data'",
"=>",
"base64_encode",
"(",
"$",
"rsa",
"->",
"encrypt",
"(",
"$",
"request",
")",
")",
")",
";",
"$",
"sRequest",
"=",
"json_encode",
"(",
"$",
"aRequest",
")",
";",
"$",
"headers",
"=",
"array",
"(",
"'Content-Type: application/json'",
")",
";",
"if",
"(",
"$",
"oRemoteApp",
"->",
"getApiAuthType",
"(",
")",
"==",
"\"http-basic\"",
")",
"{",
"$",
"sUsername",
"=",
"$",
"oRemoteApp",
"->",
"getApiAuthHttpUser",
"(",
")",
";",
"$",
"sPassword",
"=",
"$",
"oRemoteApp",
"->",
"getApiAuthHttpPassword",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sUsername",
")",
"&&",
"!",
"empty",
"(",
"$",
"sPassword",
")",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"\"Authorization: Basic \"",
".",
"base64_encode",
"(",
"$",
"oRemoteApp",
"->",
"getApiAuthHttpUser",
"(",
")",
".",
"\":\"",
".",
"$",
"oRemoteApp",
"->",
"getApiAuthHttpPassword",
"(",
")",
")",
";",
"}",
"}",
"$",
"oRequest",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"oRequest",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"headers",
")",
";",
"curl_setopt",
"(",
"$",
"oRequest",
",",
"CURLOPT_TIMEOUT",
",",
"5",
")",
";",
"curl_setopt",
"(",
"$",
"oRequest",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"oRequest",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"sRequest",
")",
";",
"curl_setopt",
"(",
"$",
"oRequest",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"oRequest",
")",
";",
"$",
"iHttpStatus",
"=",
"curl_getinfo",
"(",
"$",
"oRequest",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"$",
"error",
"=",
"curl_error",
"(",
"$",
"oRequest",
")",
";",
"curl_close",
"(",
"$",
"oRequest",
")",
";",
"$",
"rawResponse",
"=",
"$",
"response",
";",
"if",
"(",
"$",
"response",
"==",
"\"\"",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"No content received for call on: \"",
".",
"$",
"url",
")",
";",
"}",
"if",
"(",
"$",
"iHttpStatus",
"===",
"200",
")",
"{",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"response",
"[",
"'data'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid response format: \"",
".",
"htmlentities",
"(",
"$",
"rawResponse",
")",
")",
";",
"}",
"$",
"privateKey",
"=",
"file_get_contents",
"(",
"__DIR__",
".",
"\"/../Resources/private/api/keys/server/private.key\"",
")",
";",
"$",
"rsa",
"->",
"loadKey",
"(",
"$",
"privateKey",
")",
";",
"$",
"data",
"=",
"base64_decode",
"(",
"$",
"response",
"[",
"'data'",
"]",
")",
";",
"$",
"decoded",
"=",
"$",
"rsa",
"->",
"decrypt",
"(",
"$",
"data",
")",
";",
"$",
"response",
"[",
"'data'",
"]",
"=",
"json_decode",
"(",
"$",
"decoded",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"response",
"[",
"'data'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid response format: \"",
".",
"htmlentities",
"(",
"$",
"rawResponse",
")",
")",
";",
"}",
"$",
"response",
"[",
"'data'",
"]",
"[",
"'statuscode'",
"]",
"=",
"$",
"iHttpStatus",
";",
"if",
"(",
"$",
"iHttpStatus",
"!==",
"200",
")",
"{",
"$",
"response",
"[",
"'error'",
"]",
"=",
"true",
";",
"}",
"ApiLog",
"::",
"create",
"(",
"$",
"iHttpStatus",
",",
"$",
"oRemoteApp",
"->",
"getId",
"(",
")",
",",
"$",
"decoded",
")",
";",
"restore_error_handler",
"(",
")",
";",
"return",
"$",
"response",
"[",
"'data'",
"]",
";",
"}",
"else",
"{",
"ApiLog",
"::",
"create",
"(",
"$",
"iHttpStatus",
",",
"$",
"oRemoteApp",
"->",
"getId",
"(",
")",
",",
"$",
"response",
")",
";",
"restore_error_handler",
"(",
")",
";",
"return",
"array",
"(",
"\"statuscode\"",
"=>",
"$",
"iHttpStatus",
",",
"\"result\"",
"=>",
"json_encode",
"(",
"array",
"(",
"\"status\"",
"=>",
"false",
",",
"\"error\"",
"=>",
"true",
",",
"\"statuscode\"",
"=>",
"$",
"iHttpStatus",
",",
"\"message\"",
"=>",
"$",
"response",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ContextErrorException",
"$",
"e",
")",
"{",
"restore_error_handler",
"(",
")",
";",
"ApiLog",
"::",
"create",
"(",
"-",
"1",
",",
"$",
"oRemoteApp",
"->",
"getId",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"array",
"(",
"\"statuscode\"",
"=>",
"$",
"iHttpStatus",
",",
"\"result\"",
"=>",
"json_encode",
"(",
"array",
"(",
"\"status\"",
"=>",
"false",
",",
"\"error\"",
"=>",
"true",
",",
"\"statuscode\"",
"=>",
"-",
"1",
",",
"\"message\"",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"restore_error_handler",
"(",
")",
";",
"ApiLog",
"::",
"create",
"(",
"-",
"1",
",",
"$",
"oRemoteApp",
"->",
"getId",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"array",
"(",
"\"statuscode\"",
"=>",
"500",
",",
"\"result\"",
"=>",
"json_encode",
"(",
"array",
"(",
"\"status\"",
"=>",
"false",
",",
"\"error\"",
"=>",
"true",
",",
"\"statuscode\"",
"=>",
"-",
"1",
",",
"\"message\"",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
")",
";",
"}",
"}"
]
| @param $method
@param $params
@param $url
@param $publickey
@param null $oRemoteApp
@return array|mixed
@throws \Exception | [
"@param",
"$method",
"@param",
"$params",
"@param",
"$url",
"@param",
"$publickey",
"@param",
"null",
"$oRemoteApp"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Services/Api.php#L66-L223 |
phpmob/changmin | src/PhpMob/ChangMinBundle/Doctrine/ORM/TaxonRepository.php | TaxonRepository.findNodesTreeSorted | public function findNodesTreeSorted($rootCode = null)
{
$queryBuilder = $this->createQueryBuilder('o')
->addOrderBy('o.root')
->addOrderBy('o.left')
;
/** @var TaxonInterface $root */
if (null !== $rootCode && $root = $this->findOneBy(['code' => $rootCode])) {
$queryBuilder
->addSelect('root')
->addSelect('translation')
->innerJoin('o.root', 'root')
->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
//->andWhere('o.root = :root')
->andWhere($queryBuilder->expr()->between('o.left', $root->getLeft(), $root->getRight()))
//->setParameter('root', $root)
->setParameter('locale', $root->getTranslation()->getLocale())
;
}
return $queryBuilder->getQuery()->getResult();
} | php | public function findNodesTreeSorted($rootCode = null)
{
$queryBuilder = $this->createQueryBuilder('o')
->addOrderBy('o.root')
->addOrderBy('o.left')
;
/** @var TaxonInterface $root */
if (null !== $rootCode && $root = $this->findOneBy(['code' => $rootCode])) {
$queryBuilder
->addSelect('root')
->addSelect('translation')
->innerJoin('o.root', 'root')
->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
//->andWhere('o.root = :root')
->andWhere($queryBuilder->expr()->between('o.left', $root->getLeft(), $root->getRight()))
//->setParameter('root', $root)
->setParameter('locale', $root->getTranslation()->getLocale())
;
}
return $queryBuilder->getQuery()->getResult();
} | [
"public",
"function",
"findNodesTreeSorted",
"(",
"$",
"rootCode",
"=",
"null",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'o'",
")",
"->",
"addOrderBy",
"(",
"'o.root'",
")",
"->",
"addOrderBy",
"(",
"'o.left'",
")",
";",
"/** @var TaxonInterface $root */",
"if",
"(",
"null",
"!==",
"$",
"rootCode",
"&&",
"$",
"root",
"=",
"$",
"this",
"->",
"findOneBy",
"(",
"[",
"'code'",
"=>",
"$",
"rootCode",
"]",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"addSelect",
"(",
"'root'",
")",
"->",
"addSelect",
"(",
"'translation'",
")",
"->",
"innerJoin",
"(",
"'o.root'",
",",
"'root'",
")",
"->",
"innerJoin",
"(",
"'o.translations'",
",",
"'translation'",
",",
"'WITH'",
",",
"'translation.locale = :locale'",
")",
"//->andWhere('o.root = :root')",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"between",
"(",
"'o.left'",
",",
"$",
"root",
"->",
"getLeft",
"(",
")",
",",
"$",
"root",
"->",
"getRight",
"(",
")",
")",
")",
"//->setParameter('root', $root)",
"->",
"setParameter",
"(",
"'locale'",
",",
"$",
"root",
"->",
"getTranslation",
"(",
")",
"->",
"getLocale",
"(",
")",
")",
";",
"}",
"return",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/ChangMinBundle/Doctrine/ORM/TaxonRepository.php#L63-L85 |
phpmob/changmin | src/PhpMob/ChangMinBundle/Doctrine/ORM/TaxonRepository.php | TaxonRepository.createFilterQueryBuilder | public function createFilterQueryBuilder(string $locale, ?string $parentCode): QueryBuilder
{
$queryBuilder = $this->createQueryBuilder('o')
->addSelect('translation')
->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
->setParameter('locale', $locale)
;
if ($parentCode) {
if (!$parent = $this->findOneBy(['code' => $parentCode])) {
return $queryBuilder;
}
return $queryBuilder
->andWhere($queryBuilder->expr()->between('o.left', $parent->getLeft(), $parent->getRight()))
->andWhere('o.root = :rootCode')
->setParameter('rootCode', $parent->getRoot())
->addOrderBy('o.left')
;
}
return $queryBuilder
->addSelect('parent')
->leftJoin('o.parent', 'parent')
->andWhere($queryBuilder->expr()->between('o.left', 'parent.left', 'parent.right'))
->addOrderBy('o.left')
;
} | php | public function createFilterQueryBuilder(string $locale, ?string $parentCode): QueryBuilder
{
$queryBuilder = $this->createQueryBuilder('o')
->addSelect('translation')
->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
->setParameter('locale', $locale)
;
if ($parentCode) {
if (!$parent = $this->findOneBy(['code' => $parentCode])) {
return $queryBuilder;
}
return $queryBuilder
->andWhere($queryBuilder->expr()->between('o.left', $parent->getLeft(), $parent->getRight()))
->andWhere('o.root = :rootCode')
->setParameter('rootCode', $parent->getRoot())
->addOrderBy('o.left')
;
}
return $queryBuilder
->addSelect('parent')
->leftJoin('o.parent', 'parent')
->andWhere($queryBuilder->expr()->between('o.left', 'parent.left', 'parent.right'))
->addOrderBy('o.left')
;
} | [
"public",
"function",
"createFilterQueryBuilder",
"(",
"string",
"$",
"locale",
",",
"?",
"string",
"$",
"parentCode",
")",
":",
"QueryBuilder",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'o'",
")",
"->",
"addSelect",
"(",
"'translation'",
")",
"->",
"innerJoin",
"(",
"'o.translations'",
",",
"'translation'",
",",
"'WITH'",
",",
"'translation.locale = :locale'",
")",
"->",
"setParameter",
"(",
"'locale'",
",",
"$",
"locale",
")",
";",
"if",
"(",
"$",
"parentCode",
")",
"{",
"if",
"(",
"!",
"$",
"parent",
"=",
"$",
"this",
"->",
"findOneBy",
"(",
"[",
"'code'",
"=>",
"$",
"parentCode",
"]",
")",
")",
"{",
"return",
"$",
"queryBuilder",
";",
"}",
"return",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"between",
"(",
"'o.left'",
",",
"$",
"parent",
"->",
"getLeft",
"(",
")",
",",
"$",
"parent",
"->",
"getRight",
"(",
")",
")",
")",
"->",
"andWhere",
"(",
"'o.root = :rootCode'",
")",
"->",
"setParameter",
"(",
"'rootCode'",
",",
"$",
"parent",
"->",
"getRoot",
"(",
")",
")",
"->",
"addOrderBy",
"(",
"'o.left'",
")",
";",
"}",
"return",
"$",
"queryBuilder",
"->",
"addSelect",
"(",
"'parent'",
")",
"->",
"leftJoin",
"(",
"'o.parent'",
",",
"'parent'",
")",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"between",
"(",
"'o.left'",
",",
"'parent.left'",
",",
"'parent.right'",
")",
")",
"->",
"addOrderBy",
"(",
"'o.left'",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/ChangMinBundle/Doctrine/ORM/TaxonRepository.php#L90-L117 |
phore/phore-micro-app | src/Auth/AuthManager.php | AuthManager.doAuth | public function doAuth (string $userId, string $passwd)
{
if(($user = $this->userProvider->validateUser($userId, $passwd, $this->roleMap)) !== null) {
$this->authUser = $user;
if ($this->authMech instanceof SessionBasedAuthMech)
$this->authMech->setSessionUserId($userId);
return true;
}
throw new InvalidUserException("Cannot login user '$userId'");
} | php | public function doAuth (string $userId, string $passwd)
{
if(($user = $this->userProvider->validateUser($userId, $passwd, $this->roleMap)) !== null) {
$this->authUser = $user;
if ($this->authMech instanceof SessionBasedAuthMech)
$this->authMech->setSessionUserId($userId);
return true;
}
throw new InvalidUserException("Cannot login user '$userId'");
} | [
"public",
"function",
"doAuth",
"(",
"string",
"$",
"userId",
",",
"string",
"$",
"passwd",
")",
"{",
"if",
"(",
"(",
"$",
"user",
"=",
"$",
"this",
"->",
"userProvider",
"->",
"validateUser",
"(",
"$",
"userId",
",",
"$",
"passwd",
",",
"$",
"this",
"->",
"roleMap",
")",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"authUser",
"=",
"$",
"user",
";",
"if",
"(",
"$",
"this",
"->",
"authMech",
"instanceof",
"SessionBasedAuthMech",
")",
"$",
"this",
"->",
"authMech",
"->",
"setSessionUserId",
"(",
"$",
"userId",
")",
";",
"return",
"true",
";",
"}",
"throw",
"new",
"InvalidUserException",
"(",
"\"Cannot login user '$userId'\"",
")",
";",
"}"
]
| @param string $userId
@param string $passwd
@return bool
@throws InvalidUserException | [
"@param",
"string",
"$userId",
"@param",
"string",
"$passwd"
]
| train | https://github.com/phore/phore-micro-app/blob/6cf87a647b8b0be05afbfe6bd020650e98558c23/src/Auth/AuthManager.php#L95-L106 |
xinix-technology/norm | src/Norm/Cursor/MongoCursor.php | MongoCursor.getNext | public function getNext()
{
$next = $this->getCursor()->getNext();
return isset($next) ? $this->collection->attach($next) : null;
} | php | public function getNext()
{
$next = $this->getCursor()->getNext();
return isset($next) ? $this->collection->attach($next) : null;
} | [
"public",
"function",
"getNext",
"(",
")",
"{",
"$",
"next",
"=",
"$",
"this",
"->",
"getCursor",
"(",
")",
"->",
"getNext",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"next",
")",
"?",
"$",
"this",
"->",
"collection",
"->",
"attach",
"(",
"$",
"next",
")",
":",
"null",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MongoCursor.php#L27-L32 |
xinix-technology/norm | src/Norm/Cursor/MongoCursor.php | MongoCursor.translateCriteria | public function translateCriteria(array $criteria = array())
{
if (empty($criteria)) {
return $criteria;
}
$newCriteria = array();
foreach ($criteria as $key => $value) {
list($newKey, $newValue) = $this->grammarExpression($key, $value);
if (is_array($newValue)) {
if (!isset($newCriteria[$newKey])) {
$newCriteria[$newKey] = array();
}
$newCriteria[$newKey] = array_merge($newCriteria[$newKey], $newValue);
} else {
$newCriteria[$newKey] = $newValue;
}
}
return $newCriteria;
} | php | public function translateCriteria(array $criteria = array())
{
if (empty($criteria)) {
return $criteria;
}
$newCriteria = array();
foreach ($criteria as $key => $value) {
list($newKey, $newValue) = $this->grammarExpression($key, $value);
if (is_array($newValue)) {
if (!isset($newCriteria[$newKey])) {
$newCriteria[$newKey] = array();
}
$newCriteria[$newKey] = array_merge($newCriteria[$newKey], $newValue);
} else {
$newCriteria[$newKey] = $newValue;
}
}
return $newCriteria;
} | [
"public",
"function",
"translateCriteria",
"(",
"array",
"$",
"criteria",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"criteria",
")",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"newCriteria",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"newKey",
",",
"$",
"newValue",
")",
"=",
"$",
"this",
"->",
"grammarExpression",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"newValue",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"newCriteria",
"[",
"$",
"newKey",
"]",
")",
")",
"{",
"$",
"newCriteria",
"[",
"$",
"newKey",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"newCriteria",
"[",
"$",
"newKey",
"]",
"=",
"array_merge",
"(",
"$",
"newCriteria",
"[",
"$",
"newKey",
"]",
",",
"$",
"newValue",
")",
";",
"}",
"else",
"{",
"$",
"newCriteria",
"[",
"$",
"newKey",
"]",
"=",
"$",
"newValue",
";",
"}",
"}",
"return",
"$",
"newCriteria",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MongoCursor.php#L45-L69 |
xinix-technology/norm | src/Norm/Cursor/MongoCursor.php | MongoCursor.current | public function current()
{
$data = $this->getCursor()->current();
return isset($data) ? $this->collection->attach($data) : null;
} | php | public function current()
{
$data = $this->getCursor()->current();
return isset($data) ? $this->collection->attach($data) : null;
} | [
"public",
"function",
"current",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getCursor",
"(",
")",
"->",
"current",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"data",
")",
"?",
"$",
"this",
"->",
"collection",
"->",
"attach",
"(",
"$",
"data",
")",
":",
"null",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MongoCursor.php#L74-L79 |
xinix-technology/norm | src/Norm/Cursor/MongoCursor.php | MongoCursor.getCursor | public function getCursor()
{
if (is_null($this->cursor)) {
$rawCollection = $this->connection->getRaw()->{$this->collection->getName()};
if (empty($this->criteria)) {
$this->cursor = $rawCollection->find();
} else {
$this->cursor = $rawCollection->find($this->criteria);
}
if (isset($this->sorts)) {
$this->cursor->sort($this->sorts);
}
if (isset($this->skip)) {
$this->cursor->skip($this->skip);
}
if (isset($this->limit)) {
$this->cursor->limit($this->limit);
}
}
return $this->cursor;
} | php | public function getCursor()
{
if (is_null($this->cursor)) {
$rawCollection = $this->connection->getRaw()->{$this->collection->getName()};
if (empty($this->criteria)) {
$this->cursor = $rawCollection->find();
} else {
$this->cursor = $rawCollection->find($this->criteria);
}
if (isset($this->sorts)) {
$this->cursor->sort($this->sorts);
}
if (isset($this->skip)) {
$this->cursor->skip($this->skip);
}
if (isset($this->limit)) {
$this->cursor->limit($this->limit);
}
}
return $this->cursor;
} | [
"public",
"function",
"getCursor",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"cursor",
")",
")",
"{",
"$",
"rawCollection",
"=",
"$",
"this",
"->",
"connection",
"->",
"getRaw",
"(",
")",
"->",
"{",
"$",
"this",
"->",
"collection",
"->",
"getName",
"(",
")",
"}",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"criteria",
")",
")",
"{",
"$",
"this",
"->",
"cursor",
"=",
"$",
"rawCollection",
"->",
"find",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"cursor",
"=",
"$",
"rawCollection",
"->",
"find",
"(",
"$",
"this",
"->",
"criteria",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"sorts",
")",
")",
"{",
"$",
"this",
"->",
"cursor",
"->",
"sort",
"(",
"$",
"this",
"->",
"sorts",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"skip",
")",
")",
"{",
"$",
"this",
"->",
"cursor",
"->",
"skip",
"(",
"$",
"this",
"->",
"skip",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"limit",
")",
")",
"{",
"$",
"this",
"->",
"cursor",
"->",
"limit",
"(",
"$",
"this",
"->",
"limit",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"cursor",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MongoCursor.php#L116-L141 |
xinix-technology/norm | src/Norm/Cursor/MongoCursor.php | MongoCursor.grammarExpression | public function grammarExpression($key, $value)
{
if ($key === '!or' || $key === '!and') {
if (!is_array($value)) {
throw new Exception('[Norm/MongoCursor] "!or" and "!and" must have value as array.');
}
$newValue = array();
foreach ($value as $v) {
$newValue[] = $this->translateCriteria($v, true);
}
return array('$'.substr($key, 1), $newValue);
}
$splitted = explode('!', $key, 2);
$field = $splitted[0];
$schema = $this->collection->schema($field);
if (strlen($field) > 0 && $field[0] === '$') {
$field = '_'.substr($field, 1);
}
$operator = '$eq';
$multiValue = false;
if (isset($splitted[1])) {
switch ($splitted[1]) {
case 'like':
return array($field, array('$regex' => new \MongoRegex("/$value/i")));
case 'regex':
return array($field, array('$regex' => new \MongoRegex($value)));
case 'in':
case 'nin':
$operator = '$'.$splitted[1];
$multiValue = true;
break;
default:
$operator = '$'.$splitted[1];
break;
}
}
if ($field === '_id') {
if ($operator === '$eq') {
return array($field, new MongoId($value));
} else {
return array($field, array($operator => new MongoId($value)));
}
}
if (isset($schema)) {
if ($multiValue) {
if (!empty($value)) {
$newValue = array();
if(!is_array($value)){
$value = array($value);
}
foreach ($value as $k => $v) {
// TODO ini quickfix buat query norm array seperti mongo
// kalau ada yang lebih bagus caranya bisa dibenerin
if (!$schema instanceof \Norm\Schema\NormArray) {
$newValue[] = $schema->prepare($v);
}
}
$value = $newValue;
} else {
$value = array();
}
} else {
// TODO ini quickfix buat query norm array seperti mongo
// kalau ada yang lebih bagus caranya bisa dibenerin
if (!$schema instanceof \Norm\Schema\NormArray) {
$value = $schema->prepare($value);
}
}
}
$value = $this->connection->marshall($value);
if ($operator === '$eq') {
return array($field, $value);
} else {
return array($field, array($operator => $value));
}
} | php | public function grammarExpression($key, $value)
{
if ($key === '!or' || $key === '!and') {
if (!is_array($value)) {
throw new Exception('[Norm/MongoCursor] "!or" and "!and" must have value as array.');
}
$newValue = array();
foreach ($value as $v) {
$newValue[] = $this->translateCriteria($v, true);
}
return array('$'.substr($key, 1), $newValue);
}
$splitted = explode('!', $key, 2);
$field = $splitted[0];
$schema = $this->collection->schema($field);
if (strlen($field) > 0 && $field[0] === '$') {
$field = '_'.substr($field, 1);
}
$operator = '$eq';
$multiValue = false;
if (isset($splitted[1])) {
switch ($splitted[1]) {
case 'like':
return array($field, array('$regex' => new \MongoRegex("/$value/i")));
case 'regex':
return array($field, array('$regex' => new \MongoRegex($value)));
case 'in':
case 'nin':
$operator = '$'.$splitted[1];
$multiValue = true;
break;
default:
$operator = '$'.$splitted[1];
break;
}
}
if ($field === '_id') {
if ($operator === '$eq') {
return array($field, new MongoId($value));
} else {
return array($field, array($operator => new MongoId($value)));
}
}
if (isset($schema)) {
if ($multiValue) {
if (!empty($value)) {
$newValue = array();
if(!is_array($value)){
$value = array($value);
}
foreach ($value as $k => $v) {
// TODO ini quickfix buat query norm array seperti mongo
// kalau ada yang lebih bagus caranya bisa dibenerin
if (!$schema instanceof \Norm\Schema\NormArray) {
$newValue[] = $schema->prepare($v);
}
}
$value = $newValue;
} else {
$value = array();
}
} else {
// TODO ini quickfix buat query norm array seperti mongo
// kalau ada yang lebih bagus caranya bisa dibenerin
if (!$schema instanceof \Norm\Schema\NormArray) {
$value = $schema->prepare($value);
}
}
}
$value = $this->connection->marshall($value);
if ($operator === '$eq') {
return array($field, $value);
} else {
return array($field, array($operator => $value));
}
} | [
"public",
"function",
"grammarExpression",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"'!or'",
"||",
"$",
"key",
"===",
"'!and'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'[Norm/MongoCursor] \"!or\" and \"!and\" must have value as array.'",
")",
";",
"}",
"$",
"newValue",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"v",
")",
"{",
"$",
"newValue",
"[",
"]",
"=",
"$",
"this",
"->",
"translateCriteria",
"(",
"$",
"v",
",",
"true",
")",
";",
"}",
"return",
"array",
"(",
"'$'",
".",
"substr",
"(",
"$",
"key",
",",
"1",
")",
",",
"$",
"newValue",
")",
";",
"}",
"$",
"splitted",
"=",
"explode",
"(",
"'!'",
",",
"$",
"key",
",",
"2",
")",
";",
"$",
"field",
"=",
"$",
"splitted",
"[",
"0",
"]",
";",
"$",
"schema",
"=",
"$",
"this",
"->",
"collection",
"->",
"schema",
"(",
"$",
"field",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"field",
")",
">",
"0",
"&&",
"$",
"field",
"[",
"0",
"]",
"===",
"'$'",
")",
"{",
"$",
"field",
"=",
"'_'",
".",
"substr",
"(",
"$",
"field",
",",
"1",
")",
";",
"}",
"$",
"operator",
"=",
"'$eq'",
";",
"$",
"multiValue",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"splitted",
"[",
"1",
"]",
")",
")",
"{",
"switch",
"(",
"$",
"splitted",
"[",
"1",
"]",
")",
"{",
"case",
"'like'",
":",
"return",
"array",
"(",
"$",
"field",
",",
"array",
"(",
"'$regex'",
"=>",
"new",
"\\",
"MongoRegex",
"(",
"\"/$value/i\"",
")",
")",
")",
";",
"case",
"'regex'",
":",
"return",
"array",
"(",
"$",
"field",
",",
"array",
"(",
"'$regex'",
"=>",
"new",
"\\",
"MongoRegex",
"(",
"$",
"value",
")",
")",
")",
";",
"case",
"'in'",
":",
"case",
"'nin'",
":",
"$",
"operator",
"=",
"'$'",
".",
"$",
"splitted",
"[",
"1",
"]",
";",
"$",
"multiValue",
"=",
"true",
";",
"break",
";",
"default",
":",
"$",
"operator",
"=",
"'$'",
".",
"$",
"splitted",
"[",
"1",
"]",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"field",
"===",
"'_id'",
")",
"{",
"if",
"(",
"$",
"operator",
"===",
"'$eq'",
")",
"{",
"return",
"array",
"(",
"$",
"field",
",",
"new",
"MongoId",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"return",
"array",
"(",
"$",
"field",
",",
"array",
"(",
"$",
"operator",
"=>",
"new",
"MongoId",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"schema",
")",
")",
"{",
"if",
"(",
"$",
"multiValue",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"newValue",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array",
"(",
"$",
"value",
")",
";",
"}",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// TODO ini quickfix buat query norm array seperti mongo",
"// kalau ada yang lebih bagus caranya bisa dibenerin",
"if",
"(",
"!",
"$",
"schema",
"instanceof",
"\\",
"Norm",
"\\",
"Schema",
"\\",
"NormArray",
")",
"{",
"$",
"newValue",
"[",
"]",
"=",
"$",
"schema",
"->",
"prepare",
"(",
"$",
"v",
")",
";",
"}",
"}",
"$",
"value",
"=",
"$",
"newValue",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"array",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// TODO ini quickfix buat query norm array seperti mongo",
"// kalau ada yang lebih bagus caranya bisa dibenerin",
"if",
"(",
"!",
"$",
"schema",
"instanceof",
"\\",
"Norm",
"\\",
"Schema",
"\\",
"NormArray",
")",
"{",
"$",
"value",
"=",
"$",
"schema",
"->",
"prepare",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"connection",
"->",
"marshall",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"operator",
"===",
"'$eq'",
")",
"{",
"return",
"array",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"array",
"(",
"$",
"field",
",",
"array",
"(",
"$",
"operator",
"=>",
"$",
"value",
")",
")",
";",
"}",
"}"
]
| Generate a standard NORM query expression.
@param string $key
@param mixed $value
@return array | [
"Generate",
"a",
"standard",
"NORM",
"query",
"expression",
"."
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MongoCursor.php#L151-L241 |
xinix-technology/norm | src/Norm/Cursor/MongoCursor.php | MongoCursor.distinct | public function distinct($key) {
$rawCollection = $this->connection->getRaw()->{$this->collection->getName()};
$result = $rawCollection->distinct($key);
return $result;
} | php | public function distinct($key) {
$rawCollection = $this->connection->getRaw()->{$this->collection->getName()};
$result = $rawCollection->distinct($key);
return $result;
} | [
"public",
"function",
"distinct",
"(",
"$",
"key",
")",
"{",
"$",
"rawCollection",
"=",
"$",
"this",
"->",
"connection",
"->",
"getRaw",
"(",
")",
"->",
"{",
"$",
"this",
"->",
"collection",
"->",
"getName",
"(",
")",
"}",
";",
"$",
"result",
"=",
"$",
"rawCollection",
"->",
"distinct",
"(",
"$",
"key",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MongoCursor.php#L247-L252 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/Lobby/Plugin.php | Plugin.onTick | function onTick()
{
$timers = array();
$this->tick++;
if ($this->tick % 8 == 0)
{
gc_collect_cycles();
$mtime = microtime(true);
foreach($this->blockedPlayers as $login => $time)
{
$this->updateKarma($login);
}
$timers['blocked'] = microtime(true) - $mtime;
}
if ($this->tick % 15 == 0 && $this->maintenanceMode)
{
$this->connection->chatSendServerMessageToLanguage($this->dictionary->getChat(array(
array('textId' => 'maintenance', 'params' => array($this->maintenanceMessage))
)));
}
//If there is some match needing players
//find backup in ready players and send them to the match server
$mtime = microtime(true);
if($this->tick % 3 == 0)
{
$this->runReplacerMaker();
}
$timers['backups'] = microtime(true) - $mtime;
if (($this->config->matchMakerDelay == 0 && $this->isMatchMakerAllowed() && $this->tick % 2 == 0) || ($this->config->matchMakerDelay != 0 && $this->tick % $this->config->matchMakerDelay == 0))
{
$this->runMatchMaker();
}
foreach($this->replacerCountDown as $login => $countDown)
{
$login = (string) $login;
switch(--$countDown)
{
case -15:
unset($this->replacerCountDown[$login]);
break;
case 0:
$match = $this->matchMakingService->getPlayerCurrentMatch($login, $this->storage->serverLogin, $this->scriptName, $this->titleIdString);
$player = $this->storage->getPlayerObject($login);
if($match && $match->state >= Match::PREPARED)
{
if ($this->sendToServer($login, $match->matchServerLogin))
{
//TODO Add transfer textId to AbstractGUI
$this->gui->createLabel($this->gui->getTransferText(), $login, null, false, false);
$this->connection->addGuest($login, true);
$this->connection->chatSendServerMessageToLanguage($this->dictionary->getChat(array(
array('textId' => 'substituteMoved', 'params' => array(self::PREFIX, $player->nickName))
)));
$this->matchMakingService->updatePlayerState($this->replacers[$login], $match->id, Services\PlayerInfo::PLAYER_STATE_REPLACED);
}
else
{
//Something bad happened
}
}
else
{
\ManiaLive\Utilities\Logger::debug(sprintf('For replacer %s, match does not exist anymore', $login));
}
unset($match, $player);
//nobreak
default:
$this->replacerCountDown[$login] = $countDown;
break;
}
}
unset($login, $countDown);
$this->runJumper();
//Clean guest list for not in match players
if($this->tick % 29 == 0)
{
$mtime = microtime(true);
$guests = $this->connection->getGuestList(-1, 0);
if(count($guests))
{
$guests = Structures\Player::getPropertyFromArray($guests,'login');
$logins = $this->matchMakingService->getPlayersJustFinishedAllMatches($this->storage->serverLogin, $guests);
if($logins)
{
foreach($logins as $login)
{
$this->connection->removeGuest($login, true);
}
}
}
$timers['cleanGuest'] = microtime(true) - $mtime;
}
if($this->tick % 31 == 0)
{
$mtime = microtime(true);
$this->setLobbyInfo();
$timers['lobbyInfo'] = microtime(true) - $mtime;
}
if($this->tick % 6 == 0)
{
$mtime = microtime(true);
$this->updateLobbyWindow();
$timers['lobbyWindow'] = microtime(true) - $mtime;
}
if ($this->config->showMasters && $this->tick % 6 == 0)
{
$this->updateMasterList();
}
if($this->tick % 12 == 0)
{
if($this->scriptName == 'Elite' || $this->scriptName == 'Combo')
{
$endedMatches = $this->matchMakingService->getEndedMatchesSince($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
foreach($endedMatches as $endedMatch)
{
if($endedMatch->team1)
{
$states = $endedMatch->playersState;
$connectedPlayersCallBack = function ($login) use ($states) { return $states[$login] == Services\PlayerInfo::PLAYER_STATE_CONNECTED;};
$team1 = array_filter($endedMatch->team1, $connectedPlayersCallBack);
$team2 = array_filter($endedMatch->team2, $connectedPlayersCallBack);
$blue = implode(', ', array_map('\ManiaLib\Utils\Formatting::stripStyles', $team1));
$red = implode(', ', array_map('\ManiaLib\Utils\Formatting::stripStyles', $team2));
}
else
{
$blue = \ManiaLib\Utils\Formatting::stripStyles($endedMatch->players[0]);
$red = \ManiaLib\Utils\Formatting::stripStyles($endedMatch->players[1]);
}
$this->connection->chatSendServerMessage(sprintf(self::PREFIX.'$<$00f%s$> $o%d - %d$z $<$f00%s$>',$blue,$endedMatch->mapPointsTeam1, $endedMatch->mapPointsTeam2, $red));
}
}
}
// Update playerlist every 3sec
if($this->updatePlayerList && $this->tick % 3 == 0)
{
$maxAlliesCount = $this->matchMaker->getPlayersPerMatch() / 2 - 1;
$this->gui->updatePlayerList($this->blockedPlayers, $this->setLocalAllyAction, $this->unsetLocalAllyAction, $maxAlliesCount);
$this->updatePlayerList = false;
}
if ($this->tick % 12 == 0)
{
$this->registerLobby();
}
Services\PlayerInfo::CleanUp();
if($this->tick % 11 == 0)
{
$this->allyService->removePlayerAway();
}
$this->connection->executeMulticall();
//Debug
$timers = array_filter($timers, function($v) { return $v > 0.10; });
if(count($timers))
{
$line = array();
foreach($timers as $key => $value)
{
$line[] = sprintf('%s:%f',$key,$value);
}
\ManiaLive\Utilities\Logger::debug(implode('|', $line));
}
} | php | function onTick()
{
$timers = array();
$this->tick++;
if ($this->tick % 8 == 0)
{
gc_collect_cycles();
$mtime = microtime(true);
foreach($this->blockedPlayers as $login => $time)
{
$this->updateKarma($login);
}
$timers['blocked'] = microtime(true) - $mtime;
}
if ($this->tick % 15 == 0 && $this->maintenanceMode)
{
$this->connection->chatSendServerMessageToLanguage($this->dictionary->getChat(array(
array('textId' => 'maintenance', 'params' => array($this->maintenanceMessage))
)));
}
//If there is some match needing players
//find backup in ready players and send them to the match server
$mtime = microtime(true);
if($this->tick % 3 == 0)
{
$this->runReplacerMaker();
}
$timers['backups'] = microtime(true) - $mtime;
if (($this->config->matchMakerDelay == 0 && $this->isMatchMakerAllowed() && $this->tick % 2 == 0) || ($this->config->matchMakerDelay != 0 && $this->tick % $this->config->matchMakerDelay == 0))
{
$this->runMatchMaker();
}
foreach($this->replacerCountDown as $login => $countDown)
{
$login = (string) $login;
switch(--$countDown)
{
case -15:
unset($this->replacerCountDown[$login]);
break;
case 0:
$match = $this->matchMakingService->getPlayerCurrentMatch($login, $this->storage->serverLogin, $this->scriptName, $this->titleIdString);
$player = $this->storage->getPlayerObject($login);
if($match && $match->state >= Match::PREPARED)
{
if ($this->sendToServer($login, $match->matchServerLogin))
{
//TODO Add transfer textId to AbstractGUI
$this->gui->createLabel($this->gui->getTransferText(), $login, null, false, false);
$this->connection->addGuest($login, true);
$this->connection->chatSendServerMessageToLanguage($this->dictionary->getChat(array(
array('textId' => 'substituteMoved', 'params' => array(self::PREFIX, $player->nickName))
)));
$this->matchMakingService->updatePlayerState($this->replacers[$login], $match->id, Services\PlayerInfo::PLAYER_STATE_REPLACED);
}
else
{
//Something bad happened
}
}
else
{
\ManiaLive\Utilities\Logger::debug(sprintf('For replacer %s, match does not exist anymore', $login));
}
unset($match, $player);
//nobreak
default:
$this->replacerCountDown[$login] = $countDown;
break;
}
}
unset($login, $countDown);
$this->runJumper();
//Clean guest list for not in match players
if($this->tick % 29 == 0)
{
$mtime = microtime(true);
$guests = $this->connection->getGuestList(-1, 0);
if(count($guests))
{
$guests = Structures\Player::getPropertyFromArray($guests,'login');
$logins = $this->matchMakingService->getPlayersJustFinishedAllMatches($this->storage->serverLogin, $guests);
if($logins)
{
foreach($logins as $login)
{
$this->connection->removeGuest($login, true);
}
}
}
$timers['cleanGuest'] = microtime(true) - $mtime;
}
if($this->tick % 31 == 0)
{
$mtime = microtime(true);
$this->setLobbyInfo();
$timers['lobbyInfo'] = microtime(true) - $mtime;
}
if($this->tick % 6 == 0)
{
$mtime = microtime(true);
$this->updateLobbyWindow();
$timers['lobbyWindow'] = microtime(true) - $mtime;
}
if ($this->config->showMasters && $this->tick % 6 == 0)
{
$this->updateMasterList();
}
if($this->tick % 12 == 0)
{
if($this->scriptName == 'Elite' || $this->scriptName == 'Combo')
{
$endedMatches = $this->matchMakingService->getEndedMatchesSince($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
foreach($endedMatches as $endedMatch)
{
if($endedMatch->team1)
{
$states = $endedMatch->playersState;
$connectedPlayersCallBack = function ($login) use ($states) { return $states[$login] == Services\PlayerInfo::PLAYER_STATE_CONNECTED;};
$team1 = array_filter($endedMatch->team1, $connectedPlayersCallBack);
$team2 = array_filter($endedMatch->team2, $connectedPlayersCallBack);
$blue = implode(', ', array_map('\ManiaLib\Utils\Formatting::stripStyles', $team1));
$red = implode(', ', array_map('\ManiaLib\Utils\Formatting::stripStyles', $team2));
}
else
{
$blue = \ManiaLib\Utils\Formatting::stripStyles($endedMatch->players[0]);
$red = \ManiaLib\Utils\Formatting::stripStyles($endedMatch->players[1]);
}
$this->connection->chatSendServerMessage(sprintf(self::PREFIX.'$<$00f%s$> $o%d - %d$z $<$f00%s$>',$blue,$endedMatch->mapPointsTeam1, $endedMatch->mapPointsTeam2, $red));
}
}
}
// Update playerlist every 3sec
if($this->updatePlayerList && $this->tick % 3 == 0)
{
$maxAlliesCount = $this->matchMaker->getPlayersPerMatch() / 2 - 1;
$this->gui->updatePlayerList($this->blockedPlayers, $this->setLocalAllyAction, $this->unsetLocalAllyAction, $maxAlliesCount);
$this->updatePlayerList = false;
}
if ($this->tick % 12 == 0)
{
$this->registerLobby();
}
Services\PlayerInfo::CleanUp();
if($this->tick % 11 == 0)
{
$this->allyService->removePlayerAway();
}
$this->connection->executeMulticall();
//Debug
$timers = array_filter($timers, function($v) { return $v > 0.10; });
if(count($timers))
{
$line = array();
foreach($timers as $key => $value)
{
$line[] = sprintf('%s:%f',$key,$value);
}
\ManiaLive\Utilities\Logger::debug(implode('|', $line));
}
} | [
"function",
"onTick",
"(",
")",
"{",
"$",
"timers",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"tick",
"++",
";",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"8",
"==",
"0",
")",
"{",
"gc_collect_cycles",
"(",
")",
";",
"$",
"mtime",
"=",
"microtime",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"blockedPlayers",
"as",
"$",
"login",
"=>",
"$",
"time",
")",
"{",
"$",
"this",
"->",
"updateKarma",
"(",
"$",
"login",
")",
";",
"}",
"$",
"timers",
"[",
"'blocked'",
"]",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"mtime",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"15",
"==",
"0",
"&&",
"$",
"this",
"->",
"maintenanceMode",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"chatSendServerMessageToLanguage",
"(",
"$",
"this",
"->",
"dictionary",
"->",
"getChat",
"(",
"array",
"(",
"array",
"(",
"'textId'",
"=>",
"'maintenance'",
",",
"'params'",
"=>",
"array",
"(",
"$",
"this",
"->",
"maintenanceMessage",
")",
")",
")",
")",
")",
";",
"}",
"//If there is some match needing players\r",
"//find backup in ready players and send them to the match server\r",
"$",
"mtime",
"=",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"3",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"runReplacerMaker",
"(",
")",
";",
"}",
"$",
"timers",
"[",
"'backups'",
"]",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"mtime",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"config",
"->",
"matchMakerDelay",
"==",
"0",
"&&",
"$",
"this",
"->",
"isMatchMakerAllowed",
"(",
")",
"&&",
"$",
"this",
"->",
"tick",
"%",
"2",
"==",
"0",
")",
"||",
"(",
"$",
"this",
"->",
"config",
"->",
"matchMakerDelay",
"!=",
"0",
"&&",
"$",
"this",
"->",
"tick",
"%",
"$",
"this",
"->",
"config",
"->",
"matchMakerDelay",
"==",
"0",
")",
")",
"{",
"$",
"this",
"->",
"runMatchMaker",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"replacerCountDown",
"as",
"$",
"login",
"=>",
"$",
"countDown",
")",
"{",
"$",
"login",
"=",
"(",
"string",
")",
"$",
"login",
";",
"switch",
"(",
"--",
"$",
"countDown",
")",
"{",
"case",
"-",
"15",
":",
"unset",
"(",
"$",
"this",
"->",
"replacerCountDown",
"[",
"$",
"login",
"]",
")",
";",
"break",
";",
"case",
"0",
":",
"$",
"match",
"=",
"$",
"this",
"->",
"matchMakingService",
"->",
"getPlayerCurrentMatch",
"(",
"$",
"login",
",",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"this",
"->",
"scriptName",
",",
"$",
"this",
"->",
"titleIdString",
")",
";",
"$",
"player",
"=",
"$",
"this",
"->",
"storage",
"->",
"getPlayerObject",
"(",
"$",
"login",
")",
";",
"if",
"(",
"$",
"match",
"&&",
"$",
"match",
"->",
"state",
">=",
"Match",
"::",
"PREPARED",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sendToServer",
"(",
"$",
"login",
",",
"$",
"match",
"->",
"matchServerLogin",
")",
")",
"{",
"//TODO Add transfer textId to AbstractGUI\r",
"$",
"this",
"->",
"gui",
"->",
"createLabel",
"(",
"$",
"this",
"->",
"gui",
"->",
"getTransferText",
"(",
")",
",",
"$",
"login",
",",
"null",
",",
"false",
",",
"false",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"addGuest",
"(",
"$",
"login",
",",
"true",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"chatSendServerMessageToLanguage",
"(",
"$",
"this",
"->",
"dictionary",
"->",
"getChat",
"(",
"array",
"(",
"array",
"(",
"'textId'",
"=>",
"'substituteMoved'",
",",
"'params'",
"=>",
"array",
"(",
"self",
"::",
"PREFIX",
",",
"$",
"player",
"->",
"nickName",
")",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"matchMakingService",
"->",
"updatePlayerState",
"(",
"$",
"this",
"->",
"replacers",
"[",
"$",
"login",
"]",
",",
"$",
"match",
"->",
"id",
",",
"Services",
"\\",
"PlayerInfo",
"::",
"PLAYER_STATE_REPLACED",
")",
";",
"}",
"else",
"{",
"//Something bad happened \r",
"}",
"}",
"else",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"sprintf",
"(",
"'For replacer %s, match does not exist anymore'",
",",
"$",
"login",
")",
")",
";",
"}",
"unset",
"(",
"$",
"match",
",",
"$",
"player",
")",
";",
"//nobreak\r",
"default",
":",
"$",
"this",
"->",
"replacerCountDown",
"[",
"$",
"login",
"]",
"=",
"$",
"countDown",
";",
"break",
";",
"}",
"}",
"unset",
"(",
"$",
"login",
",",
"$",
"countDown",
")",
";",
"$",
"this",
"->",
"runJumper",
"(",
")",
";",
"//Clean guest list for not in match players\r",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"29",
"==",
"0",
")",
"{",
"$",
"mtime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"guests",
"=",
"$",
"this",
"->",
"connection",
"->",
"getGuestList",
"(",
"-",
"1",
",",
"0",
")",
";",
"if",
"(",
"count",
"(",
"$",
"guests",
")",
")",
"{",
"$",
"guests",
"=",
"Structures",
"\\",
"Player",
"::",
"getPropertyFromArray",
"(",
"$",
"guests",
",",
"'login'",
")",
";",
"$",
"logins",
"=",
"$",
"this",
"->",
"matchMakingService",
"->",
"getPlayersJustFinishedAllMatches",
"(",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"guests",
")",
";",
"if",
"(",
"$",
"logins",
")",
"{",
"foreach",
"(",
"$",
"logins",
"as",
"$",
"login",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"removeGuest",
"(",
"$",
"login",
",",
"true",
")",
";",
"}",
"}",
"}",
"$",
"timers",
"[",
"'cleanGuest'",
"]",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"mtime",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"31",
"==",
"0",
")",
"{",
"$",
"mtime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setLobbyInfo",
"(",
")",
";",
"$",
"timers",
"[",
"'lobbyInfo'",
"]",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"mtime",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"6",
"==",
"0",
")",
"{",
"$",
"mtime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"updateLobbyWindow",
"(",
")",
";",
"$",
"timers",
"[",
"'lobbyWindow'",
"]",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"mtime",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"showMasters",
"&&",
"$",
"this",
"->",
"tick",
"%",
"6",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"updateMasterList",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"12",
"==",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"scriptName",
"==",
"'Elite'",
"||",
"$",
"this",
"->",
"scriptName",
"==",
"'Combo'",
")",
"{",
"$",
"endedMatches",
"=",
"$",
"this",
"->",
"matchMakingService",
"->",
"getEndedMatchesSince",
"(",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"this",
"->",
"scriptName",
",",
"$",
"this",
"->",
"titleIdString",
")",
";",
"foreach",
"(",
"$",
"endedMatches",
"as",
"$",
"endedMatch",
")",
"{",
"if",
"(",
"$",
"endedMatch",
"->",
"team1",
")",
"{",
"$",
"states",
"=",
"$",
"endedMatch",
"->",
"playersState",
";",
"$",
"connectedPlayersCallBack",
"=",
"function",
"(",
"$",
"login",
")",
"use",
"(",
"$",
"states",
")",
"{",
"return",
"$",
"states",
"[",
"$",
"login",
"]",
"==",
"Services",
"\\",
"PlayerInfo",
"::",
"PLAYER_STATE_CONNECTED",
";",
"}",
";",
"$",
"team1",
"=",
"array_filter",
"(",
"$",
"endedMatch",
"->",
"team1",
",",
"$",
"connectedPlayersCallBack",
")",
";",
"$",
"team2",
"=",
"array_filter",
"(",
"$",
"endedMatch",
"->",
"team2",
",",
"$",
"connectedPlayersCallBack",
")",
";",
"$",
"blue",
"=",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"'\\ManiaLib\\Utils\\Formatting::stripStyles'",
",",
"$",
"team1",
")",
")",
";",
"$",
"red",
"=",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"'\\ManiaLib\\Utils\\Formatting::stripStyles'",
",",
"$",
"team2",
")",
")",
";",
"}",
"else",
"{",
"$",
"blue",
"=",
"\\",
"ManiaLib",
"\\",
"Utils",
"\\",
"Formatting",
"::",
"stripStyles",
"(",
"$",
"endedMatch",
"->",
"players",
"[",
"0",
"]",
")",
";",
"$",
"red",
"=",
"\\",
"ManiaLib",
"\\",
"Utils",
"\\",
"Formatting",
"::",
"stripStyles",
"(",
"$",
"endedMatch",
"->",
"players",
"[",
"1",
"]",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"chatSendServerMessage",
"(",
"sprintf",
"(",
"self",
"::",
"PREFIX",
".",
"'$<$00f%s$> $o%d - %d$z $<$f00%s$>'",
",",
"$",
"blue",
",",
"$",
"endedMatch",
"->",
"mapPointsTeam1",
",",
"$",
"endedMatch",
"->",
"mapPointsTeam2",
",",
"$",
"red",
")",
")",
";",
"}",
"}",
"}",
"// Update playerlist every 3sec\r",
"if",
"(",
"$",
"this",
"->",
"updatePlayerList",
"&&",
"$",
"this",
"->",
"tick",
"%",
"3",
"==",
"0",
")",
"{",
"$",
"maxAlliesCount",
"=",
"$",
"this",
"->",
"matchMaker",
"->",
"getPlayersPerMatch",
"(",
")",
"/",
"2",
"-",
"1",
";",
"$",
"this",
"->",
"gui",
"->",
"updatePlayerList",
"(",
"$",
"this",
"->",
"blockedPlayers",
",",
"$",
"this",
"->",
"setLocalAllyAction",
",",
"$",
"this",
"->",
"unsetLocalAllyAction",
",",
"$",
"maxAlliesCount",
")",
";",
"$",
"this",
"->",
"updatePlayerList",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"12",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"registerLobby",
"(",
")",
";",
"}",
"Services",
"\\",
"PlayerInfo",
"::",
"CleanUp",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"tick",
"%",
"11",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"allyService",
"->",
"removePlayerAway",
"(",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"executeMulticall",
"(",
")",
";",
"//Debug\r",
"$",
"timers",
"=",
"array_filter",
"(",
"$",
"timers",
",",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"$",
"v",
">",
"0.10",
";",
"}",
")",
";",
"if",
"(",
"count",
"(",
"$",
"timers",
")",
")",
"{",
"$",
"line",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"timers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"line",
"[",
"]",
"=",
"sprintf",
"(",
"'%s:%f'",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"implode",
"(",
"'|'",
",",
"$",
"line",
")",
")",
";",
"}",
"}"
]
| Core of the plugin | [
"Core",
"of",
"the",
"plugin"
]
| train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Lobby/Plugin.php#L337-L514 |
Kylob/Bootstrap | src/Navbar.php | Navbar.open | public function open($brand, $align = '', $inverse = false)
{
if (is_array($brand)) {
list($brand, $link) = (count($brand) > 1) ? $brand : each($brand);
} else {
$link = $this->page->url['base'];
}
$id = $this->page->id('navbar');
$class = 'navbar';
switch ($align) {
case 'top':
case 'bottom':
$class .= ' navbar-fixed-'.$align;
break;
case 'static':
$class .= ' navbar-static-top';
break;
case 'inverse':
$inverse = 'inverse';
break;
}
$class .= ($inverse !== false) ? ' navbar-inverse' : ' navbar-default';
$html = '<nav class="'.$class.'">';
$html .= '<div class="container-fluid">';
$html .= '<div class="navbar-header">';
$html .= $this->page->tag('button', array(
'type' => 'button',
'class' => 'navbar-toggle collapsed',
'data-toggle' => 'collapse',
'data-target' => '#'.$id,
), '<span class="sr-only">Toggle navigation</span>'.str_repeat('<span class="icon-bar"></span>', 3));
$html .= "\n\t".$this->page->tag('a', array('class' => 'navbar-brand', 'href' => $link), $brand);
$html .= '</div>';
$html .= '<div class="collapse navbar-collapse" id="'.$id.'">';
return "\n".$html;
} | php | public function open($brand, $align = '', $inverse = false)
{
if (is_array($brand)) {
list($brand, $link) = (count($brand) > 1) ? $brand : each($brand);
} else {
$link = $this->page->url['base'];
}
$id = $this->page->id('navbar');
$class = 'navbar';
switch ($align) {
case 'top':
case 'bottom':
$class .= ' navbar-fixed-'.$align;
break;
case 'static':
$class .= ' navbar-static-top';
break;
case 'inverse':
$inverse = 'inverse';
break;
}
$class .= ($inverse !== false) ? ' navbar-inverse' : ' navbar-default';
$html = '<nav class="'.$class.'">';
$html .= '<div class="container-fluid">';
$html .= '<div class="navbar-header">';
$html .= $this->page->tag('button', array(
'type' => 'button',
'class' => 'navbar-toggle collapsed',
'data-toggle' => 'collapse',
'data-target' => '#'.$id,
), '<span class="sr-only">Toggle navigation</span>'.str_repeat('<span class="icon-bar"></span>', 3));
$html .= "\n\t".$this->page->tag('a', array('class' => 'navbar-brand', 'href' => $link), $brand);
$html .= '</div>';
$html .= '<div class="collapse navbar-collapse" id="'.$id.'">';
return "\n".$html;
} | [
"public",
"function",
"open",
"(",
"$",
"brand",
",",
"$",
"align",
"=",
"''",
",",
"$",
"inverse",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"brand",
")",
")",
"{",
"list",
"(",
"$",
"brand",
",",
"$",
"link",
")",
"=",
"(",
"count",
"(",
"$",
"brand",
")",
">",
"1",
")",
"?",
"$",
"brand",
":",
"each",
"(",
"$",
"brand",
")",
";",
"}",
"else",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"page",
"->",
"url",
"[",
"'base'",
"]",
";",
"}",
"$",
"id",
"=",
"$",
"this",
"->",
"page",
"->",
"id",
"(",
"'navbar'",
")",
";",
"$",
"class",
"=",
"'navbar'",
";",
"switch",
"(",
"$",
"align",
")",
"{",
"case",
"'top'",
":",
"case",
"'bottom'",
":",
"$",
"class",
".=",
"' navbar-fixed-'",
".",
"$",
"align",
";",
"break",
";",
"case",
"'static'",
":",
"$",
"class",
".=",
"' navbar-static-top'",
";",
"break",
";",
"case",
"'inverse'",
":",
"$",
"inverse",
"=",
"'inverse'",
";",
"break",
";",
"}",
"$",
"class",
".=",
"(",
"$",
"inverse",
"!==",
"false",
")",
"?",
"' navbar-inverse'",
":",
"' navbar-default'",
";",
"$",
"html",
"=",
"'<nav class=\"'",
".",
"$",
"class",
".",
"'\">'",
";",
"$",
"html",
".=",
"'<div class=\"container-fluid\">'",
";",
"$",
"html",
".=",
"'<div class=\"navbar-header\">'",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"page",
"->",
"tag",
"(",
"'button'",
",",
"array",
"(",
"'type'",
"=>",
"'button'",
",",
"'class'",
"=>",
"'navbar-toggle collapsed'",
",",
"'data-toggle'",
"=>",
"'collapse'",
",",
"'data-target'",
"=>",
"'#'",
".",
"$",
"id",
",",
")",
",",
"'<span class=\"sr-only\">Toggle navigation</span>'",
".",
"str_repeat",
"(",
"'<span class=\"icon-bar\"></span>'",
",",
"3",
")",
")",
";",
"$",
"html",
".=",
"\"\\n\\t\"",
".",
"$",
"this",
"->",
"page",
"->",
"tag",
"(",
"'a'",
",",
"array",
"(",
"'class'",
"=>",
"'navbar-brand'",
",",
"'href'",
"=>",
"$",
"link",
")",
",",
"$",
"brand",
")",
";",
"$",
"html",
".=",
"'</div>'",
";",
"$",
"html",
".=",
"'<div class=\"collapse navbar-collapse\" id=\"'",
".",
"$",
"id",
".",
"'\">'",
";",
"return",
"\"\\n\"",
".",
"$",
"html",
";",
"}"
]
| Create a new navbar.
@param mixed $brand The name of your website. If this is a string then it will automatically link to your ``$page->url['base']``. If you want to override that, then make this an ``array($brand => $link)``.
@param string $align Either '**top**', '**bottom**', or '**static**' if you want to fix the alignment. If you're just trying to get to the next arg then you can declare '**inverse**' here, and we'll know what you're talking about.
@param mixed $inverse If this is anything but false (eg. '**inverse**'), then we will display the inverted or alternate navbar.
@return string
@example
```php
echo $bp->navbar->open(array('Website' => 'http://example.com'));
``` | [
"Create",
"a",
"new",
"navbar",
"."
]
| train | https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Navbar.php#L22-L58 |
Kylob/Bootstrap | src/Navbar.php | Navbar.menu | public function menu(array $links, array $options = array())
{
$align = (isset($options['pull'])) ? ' navbar-'.$options['pull'] : '';
unset($options['pull']);
return "\n\t".'<ul class="nav navbar-nav'.$align.'">'.$this->links('li', $links, $options).'</ul>';
} | php | public function menu(array $links, array $options = array())
{
$align = (isset($options['pull'])) ? ' navbar-'.$options['pull'] : '';
unset($options['pull']);
return "\n\t".'<ul class="nav navbar-nav'.$align.'">'.$this->links('li', $links, $options).'</ul>';
} | [
"public",
"function",
"menu",
"(",
"array",
"$",
"links",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"align",
"=",
"(",
"isset",
"(",
"$",
"options",
"[",
"'pull'",
"]",
")",
")",
"?",
"' navbar-'",
".",
"$",
"options",
"[",
"'pull'",
"]",
":",
"''",
";",
"unset",
"(",
"$",
"options",
"[",
"'pull'",
"]",
")",
";",
"return",
"\"\\n\\t\"",
".",
"'<ul class=\"nav navbar-nav'",
".",
"$",
"align",
".",
"'\">'",
".",
"$",
"this",
"->",
"links",
"(",
"'li'",
",",
"$",
"links",
",",
"$",
"options",
")",
".",
"'</ul>'",
";",
"}"
]
| Create a menu of links across your navbar.
@param array $links An ``array($name => $href, ...)`` of links. If ``$href`` is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with buttons.
@param array $options The options available here are:
- '**active**' => **$name**, **$href**, '**url**', '**urlquery**', or an **integer** (starting from 1).
- '**disabled**' => **$name**, **$href**, or an **integer** (starting from 1).
- '**pull**' => '**left**' (default) or '**right**'.
@return string
@example
```php
echo $bp->navbar->menu(array(
'Home' => '#',
'Work' => '#',
'Dropdown' => array(
'Action' => '#',
'More' => '#',
),
), array(
'active' => 'Home',
));
``` | [
"Create",
"a",
"menu",
"of",
"links",
"across",
"your",
"navbar",
"."
]
| train | https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Navbar.php#L87-L93 |
Kylob/Bootstrap | src/Navbar.php | Navbar.button | public function button($class, $name, array $options = array())
{
$class .= ' navbar-btn';
if (isset($options['pull'])) {
$class .= ' navbar-'.$options['pull'];
}
unset($options['pull']);
return "\n\t".parent::button($class, $name, $options);
} | php | public function button($class, $name, array $options = array())
{
$class .= ' navbar-btn';
if (isset($options['pull'])) {
$class .= ' navbar-'.$options['pull'];
}
unset($options['pull']);
return "\n\t".parent::button($class, $name, $options);
} | [
"public",
"function",
"button",
"(",
"$",
"class",
",",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"class",
".=",
"' navbar-btn'",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'pull'",
"]",
")",
")",
"{",
"$",
"class",
".=",
"' navbar-'",
".",
"$",
"options",
"[",
"'pull'",
"]",
";",
"}",
"unset",
"(",
"$",
"options",
"[",
"'pull'",
"]",
")",
";",
"return",
"\"\\n\\t\"",
".",
"parent",
"::",
"button",
"(",
"$",
"class",
",",
"$",
"name",
",",
"$",
"options",
")",
";",
"}"
]
| Exactly the same as ``$bp->button()``, except that it will receive a '**navbar-btn**' class.
@param string $class To pull it one way or the other, you can add the class '**navbar-right** or '**navbar-left**'.
@param string $name The text of your button.
@param array $options You can also pull the button here by adding ``array('pull' => 'right')`` or ``array('pull' => 'left')``.
@return string
@example
```php
echo $bp->navbar->button('primary', 'Sign In', array(
'pull' => 'right',
));
``` | [
"Exactly",
"the",
"same",
"as",
"$bp",
"-",
">",
"button",
"()",
"except",
"that",
"it",
"will",
"receive",
"a",
"**",
"navbar",
"-",
"btn",
"**",
"class",
"."
]
| train | https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Navbar.php#L112-L121 |
Kylob/Bootstrap | src/Navbar.php | Navbar.search | public function search($url, array $form = array())
{
if (!isset($form['class'])) {
$form['class'] = 'navbar-form navbar-right';
}
return "\n\t".parent::search($url, $form);
} | php | public function search($url, array $form = array())
{
if (!isset($form['class'])) {
$form['class'] = 'navbar-form navbar-right';
}
return "\n\t".parent::search($url, $form);
} | [
"public",
"function",
"search",
"(",
"$",
"url",
",",
"array",
"$",
"form",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"form",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"form",
"[",
"'class'",
"]",
"=",
"'navbar-form navbar-right'",
";",
"}",
"return",
"\"\\n\\t\"",
".",
"parent",
"::",
"search",
"(",
"$",
"url",
",",
"$",
"form",
")",
";",
"}"
]
| Exactly the same as ``$bp->search()``, except the ``<form>`` will receive a **'navbar-form navbar-right'** class.
@param string $url Where to send the search term.
@param array $form You can pull the search form left by adding ``array('class' => 'navbar-form navbar-left')``.
@return string
@example
```php
echo $bp->navbar->search('http://example.com', array(
'button' => false,
));
``` | [
"Exactly",
"the",
"same",
"as",
"$bp",
"-",
">",
"search",
"()",
"except",
"the",
"<form",
">",
"will",
"receive",
"a",
"**",
"navbar",
"-",
"form",
"navbar",
"-",
"right",
"**",
"class",
"."
]
| train | https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Navbar.php#L139-L146 |
Kylob/Bootstrap | src/Navbar.php | Navbar.text | public function text($string, $pull = false)
{
$align = (in_array($pull, array('left', 'right'))) ? ' navbar-'.$pull : '';
return "\n\t".'<p class="navbar-text'.$align.'">'.$this->addClass($string, array('a' => 'navbar-link')).'</p>';
} | php | public function text($string, $pull = false)
{
$align = (in_array($pull, array('left', 'right'))) ? ' navbar-'.$pull : '';
return "\n\t".'<p class="navbar-text'.$align.'">'.$this->addClass($string, array('a' => 'navbar-link')).'</p>';
} | [
"public",
"function",
"text",
"(",
"$",
"string",
",",
"$",
"pull",
"=",
"false",
")",
"{",
"$",
"align",
"=",
"(",
"in_array",
"(",
"$",
"pull",
",",
"array",
"(",
"'left'",
",",
"'right'",
")",
")",
")",
"?",
"' navbar-'",
".",
"$",
"pull",
":",
"''",
";",
"return",
"\"\\n\\t\"",
".",
"'<p class=\"navbar-text'",
".",
"$",
"align",
".",
"'\">'",
".",
"$",
"this",
"->",
"addClass",
"(",
"$",
"string",
",",
"array",
"(",
"'a'",
"=>",
"'navbar-link'",
")",
")",
".",
"'</p>'",
";",
"}"
]
| Add a string of text to your navbar.
@param string $string The message you would like to get across. It will be wrapped in a ``<p class="navbar-text">`` tag, and any ``<a>``'s will be classed with a '**navbar-link**'.
@param string $pull Either '**left**' or '**right**'.
@return string
@example
```php
echo $bp->navbar->text('You <a href="#">link</a> me');
``` | [
"Add",
"a",
"string",
"of",
"text",
"to",
"your",
"navbar",
"."
]
| train | https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Navbar.php#L162-L167 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Misc/TimeProvider.php | TimeProvider.freezeTime | public function freezeTime($now = null)
{
return $this->frozenTime = ($now === null ? $this->now() : $now);
} | php | public function freezeTime($now = null)
{
return $this->frozenTime = ($now === null ? $this->now() : $now);
} | [
"public",
"function",
"freezeTime",
"(",
"$",
"now",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"frozenTime",
"=",
"(",
"$",
"now",
"===",
"null",
"?",
"$",
"this",
"->",
"now",
"(",
")",
":",
"$",
"now",
")",
";",
"}"
]
| Sets const time, now() call will return 'frozen' time
@param null|int $now When null sets time from now() call as 'frozenTime'
@return int Returns frozen time value | [
"Sets",
"const",
"time",
"now",
"()",
"call",
"will",
"return",
"frozen",
"time"
]
| train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/TimeProvider.php#L46-L49 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.createFolder | public static function createFolder($bucketName, $path, $bizAttr = null)
{
$path = self::normalizerPath($path, true);
$path = self::cosUrlEncode($path);
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign($expired, $bucketName);
$data = [
'op' => 'create',
'biz_attr' => (isset($bizAttr) ? $bizAttr : ''),
];
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | php | public static function createFolder($bucketName, $path, $bizAttr = null)
{
$path = self::normalizerPath($path, true);
$path = self::cosUrlEncode($path);
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign($expired, $bucketName);
$data = [
'op' => 'create',
'biz_attr' => (isset($bizAttr) ? $bizAttr : ''),
];
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | [
"public",
"static",
"function",
"createFolder",
"(",
"$",
"bucketName",
",",
"$",
"path",
",",
"$",
"bizAttr",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"normalizerPath",
"(",
"$",
"path",
",",
"true",
")",
";",
"$",
"path",
"=",
"self",
"::",
"cosUrlEncode",
"(",
"$",
"path",
")",
";",
"$",
"expired",
"=",
"self",
"::",
"time",
"(",
")",
"+",
"self",
"::",
"EXPIRED_SECONDS",
";",
"$",
"url",
"=",
"self",
"::",
"generateResUrl",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign",
"(",
"$",
"expired",
",",
"$",
"bucketName",
")",
";",
"$",
"data",
"=",
"[",
"'op'",
"=>",
"'create'",
",",
"'biz_attr'",
"=>",
"(",
"isset",
"(",
"$",
"bizAttr",
")",
"?",
"$",
"bizAttr",
":",
"''",
")",
",",
"]",
";",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"req",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"'post'",
",",
"'timeout'",
"=>",
"self",
"::",
"$",
"timeout",
",",
"'data'",
"=>",
"$",
"data",
",",
"'header'",
"=>",
"[",
"'Authorization:'",
".",
"$",
"sign",
",",
"'Content-Type: application/json'",
",",
"]",
",",
"]",
";",
"return",
"self",
"::",
"sendRequest",
"(",
"$",
"req",
")",
";",
"}"
]
| 创建目录.
@param string $bucketName bucket名称
@param string $path 目录路径
@param string $bizAttr 目录属性
@return array | [
"创建目录",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L101-L128 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.prefixSearch | public static function prefixSearch(
$bucketName, $prefix, $num = 20,
$pattern = 'eListBoth', $order = 0,
$context = null)
{
$path = self::normalizerPath($prefix);
return self::listBase($bucketName, $path, $num,
$pattern, $order, $context);
} | php | public static function prefixSearch(
$bucketName, $prefix, $num = 20,
$pattern = 'eListBoth', $order = 0,
$context = null)
{
$path = self::normalizerPath($prefix);
return self::listBase($bucketName, $path, $num,
$pattern, $order, $context);
} | [
"public",
"static",
"function",
"prefixSearch",
"(",
"$",
"bucketName",
",",
"$",
"prefix",
",",
"$",
"num",
"=",
"20",
",",
"$",
"pattern",
"=",
"'eListBoth'",
",",
"$",
"order",
"=",
"0",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"normalizerPath",
"(",
"$",
"prefix",
")",
";",
"return",
"self",
"::",
"listBase",
"(",
"$",
"bucketName",
",",
"$",
"path",
",",
"$",
"num",
",",
"$",
"pattern",
",",
"$",
"order",
",",
"$",
"context",
")",
";",
"}"
]
| 目录列表(前缀搜索).
@param string $bucketName bucket名称
@param string $prefix 列出含此前缀的所有文件
@param int $num 拉取的总数
@param string $pattern eListBoth(默认),ListDirOnly,eListFileOnly
@param int $order 默认正序(=0), 填1为反序,
@param string $context 透传字段,用于翻页,前端不需理解,需要往前/往后翻页则透传回来
@return array | [
"目录列表",
"(",
"前缀搜索",
")",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L165-L174 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.statFolder | public static function statFolder($bucketName, $path)
{
$path = self::normalizerPath($path, true);
return self::statBase($bucketName, $path);
} | php | public static function statFolder($bucketName, $path)
{
$path = self::normalizerPath($path, true);
return self::statBase($bucketName, $path);
} | [
"public",
"static",
"function",
"statFolder",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"normalizerPath",
"(",
"$",
"path",
",",
"true",
")",
";",
"return",
"self",
"::",
"statBase",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
";",
"}"
]
| 查询目录信息.
@param string $bucketName bucket名称
@param string $path 目录路径
@return array | [
"查询目录信息",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L200-L205 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.delFolder | public static function delFolder($bucketName, $path)
{
$path = self::normalizerPath($path, true);
return self::delBase($bucketName, $path);
} | php | public static function delFolder($bucketName, $path)
{
$path = self::normalizerPath($path, true);
return self::delBase($bucketName, $path);
} | [
"public",
"static",
"function",
"delFolder",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"normalizerPath",
"(",
"$",
"path",
",",
"true",
")",
";",
"return",
"self",
"::",
"delBase",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
";",
"}"
]
| 删除目录.
@param string $bucketName bucket名称
@param string $path 目录路径
注意不能删除bucket下根目录/
@return array | [
"删除目录",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L216-L221 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.move | public static function move($bucketName, $srcPath, $dstPath, $toOverWrite = 0)
{
$srcPath = self::normalizerPath($srcPath);
$dstPath = self::normalizerPath($dstPath);
$srcPath = self::cosUrlEncode($srcPath);
$url = self::generateResUrl($bucketName, $srcPath);
$sign = Auth::appSign_once($srcPath, $bucketName);
$data = [
'op' => 'move',
'dest_fileid' => $dstPath,
'to_over_write' => $toOverWrite,
];
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization: '.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | php | public static function move($bucketName, $srcPath, $dstPath, $toOverWrite = 0)
{
$srcPath = self::normalizerPath($srcPath);
$dstPath = self::normalizerPath($dstPath);
$srcPath = self::cosUrlEncode($srcPath);
$url = self::generateResUrl($bucketName, $srcPath);
$sign = Auth::appSign_once($srcPath, $bucketName);
$data = [
'op' => 'move',
'dest_fileid' => $dstPath,
'to_over_write' => $toOverWrite,
];
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization: '.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | [
"public",
"static",
"function",
"move",
"(",
"$",
"bucketName",
",",
"$",
"srcPath",
",",
"$",
"dstPath",
",",
"$",
"toOverWrite",
"=",
"0",
")",
"{",
"$",
"srcPath",
"=",
"self",
"::",
"normalizerPath",
"(",
"$",
"srcPath",
")",
";",
"$",
"dstPath",
"=",
"self",
"::",
"normalizerPath",
"(",
"$",
"dstPath",
")",
";",
"$",
"srcPath",
"=",
"self",
"::",
"cosUrlEncode",
"(",
"$",
"srcPath",
")",
";",
"$",
"url",
"=",
"self",
"::",
"generateResUrl",
"(",
"$",
"bucketName",
",",
"$",
"srcPath",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign_once",
"(",
"$",
"srcPath",
",",
"$",
"bucketName",
")",
";",
"$",
"data",
"=",
"[",
"'op'",
"=>",
"'move'",
",",
"'dest_fileid'",
"=>",
"$",
"dstPath",
",",
"'to_over_write'",
"=>",
"$",
"toOverWrite",
",",
"]",
";",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"req",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"'post'",
",",
"'timeout'",
"=>",
"self",
"::",
"$",
"timeout",
",",
"'data'",
"=>",
"$",
"data",
",",
"'header'",
"=>",
"[",
"'Authorization: '",
".",
"$",
"sign",
",",
"'Content-Type: application/json'",
",",
"]",
",",
"]",
";",
"return",
"self",
"::",
"sendRequest",
"(",
"$",
"req",
")",
";",
"}"
]
| 移动(重命名)文件.
@param string $bucketName bucket名称
@param string $srcPath 源文件路径
@param string $dstPath 目的文件名(可以是单独文件名也可以是带目录的文件名)
@param int $toOverWrite 是否覆盖(当目的文件名已经存在同名文件时是否覆盖)
@return array | [
"移动",
"(",
"重命名",
")",
"文件",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L257-L286 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.uploadfile | private static function uploadfile($bucketName, $srcPath, $dstPath, $bizAttr = null, $insertOnly = null)
{
$srcPath = realpath($srcPath);
$dstPath = self::cosUrlEncode($dstPath);
if (filesize($srcPath) >= self::MAX_UNSLICE_FILE_SIZE) {
return [
'code' => self::COSAPI_PARAMS_ERROR,
'message' => 'file '.$srcPath.' larger then 20M, please use upload_slice interface',
'data' => [], ];
}
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $dstPath);
$sign = Auth::appSign($expired, $bucketName);
$sha1 = hash_file('sha1', $srcPath);
$data = [
'op' => 'upload',
'sha' => $sha1,
'biz_attr' => (isset($bizAttr) ? $bizAttr : ''),
];
if (function_exists('curl_file_create')) {
$data['filecontent'] = curl_file_create($srcPath);
} else {
$data['filecontent'] = '@'.$srcPath;
}
if (isset($insertOnly) && strlen($insertOnly) > 0) {
$data['insertOnly'] = (($insertOnly == 0 || $insertOnly == '0') ? 0 : 1);
}
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
],
];
return self::sendRequest($req);
} | php | private static function uploadfile($bucketName, $srcPath, $dstPath, $bizAttr = null, $insertOnly = null)
{
$srcPath = realpath($srcPath);
$dstPath = self::cosUrlEncode($dstPath);
if (filesize($srcPath) >= self::MAX_UNSLICE_FILE_SIZE) {
return [
'code' => self::COSAPI_PARAMS_ERROR,
'message' => 'file '.$srcPath.' larger then 20M, please use upload_slice interface',
'data' => [], ];
}
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $dstPath);
$sign = Auth::appSign($expired, $bucketName);
$sha1 = hash_file('sha1', $srcPath);
$data = [
'op' => 'upload',
'sha' => $sha1,
'biz_attr' => (isset($bizAttr) ? $bizAttr : ''),
];
if (function_exists('curl_file_create')) {
$data['filecontent'] = curl_file_create($srcPath);
} else {
$data['filecontent'] = '@'.$srcPath;
}
if (isset($insertOnly) && strlen($insertOnly) > 0) {
$data['insertOnly'] = (($insertOnly == 0 || $insertOnly == '0') ? 0 : 1);
}
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
],
];
return self::sendRequest($req);
} | [
"private",
"static",
"function",
"uploadfile",
"(",
"$",
"bucketName",
",",
"$",
"srcPath",
",",
"$",
"dstPath",
",",
"$",
"bizAttr",
"=",
"null",
",",
"$",
"insertOnly",
"=",
"null",
")",
"{",
"$",
"srcPath",
"=",
"realpath",
"(",
"$",
"srcPath",
")",
";",
"$",
"dstPath",
"=",
"self",
"::",
"cosUrlEncode",
"(",
"$",
"dstPath",
")",
";",
"if",
"(",
"filesize",
"(",
"$",
"srcPath",
")",
">=",
"self",
"::",
"MAX_UNSLICE_FILE_SIZE",
")",
"{",
"return",
"[",
"'code'",
"=>",
"self",
"::",
"COSAPI_PARAMS_ERROR",
",",
"'message'",
"=>",
"'file '",
".",
"$",
"srcPath",
".",
"' larger then 20M, please use upload_slice interface'",
",",
"'data'",
"=>",
"[",
"]",
",",
"]",
";",
"}",
"$",
"expired",
"=",
"self",
"::",
"time",
"(",
")",
"+",
"self",
"::",
"EXPIRED_SECONDS",
";",
"$",
"url",
"=",
"self",
"::",
"generateResUrl",
"(",
"$",
"bucketName",
",",
"$",
"dstPath",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign",
"(",
"$",
"expired",
",",
"$",
"bucketName",
")",
";",
"$",
"sha1",
"=",
"hash_file",
"(",
"'sha1'",
",",
"$",
"srcPath",
")",
";",
"$",
"data",
"=",
"[",
"'op'",
"=>",
"'upload'",
",",
"'sha'",
"=>",
"$",
"sha1",
",",
"'biz_attr'",
"=>",
"(",
"isset",
"(",
"$",
"bizAttr",
")",
"?",
"$",
"bizAttr",
":",
"''",
")",
",",
"]",
";",
"if",
"(",
"function_exists",
"(",
"'curl_file_create'",
")",
")",
"{",
"$",
"data",
"[",
"'filecontent'",
"]",
"=",
"curl_file_create",
"(",
"$",
"srcPath",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'filecontent'",
"]",
"=",
"'@'",
".",
"$",
"srcPath",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"insertOnly",
")",
"&&",
"strlen",
"(",
"$",
"insertOnly",
")",
">",
"0",
")",
"{",
"$",
"data",
"[",
"'insertOnly'",
"]",
"=",
"(",
"(",
"$",
"insertOnly",
"==",
"0",
"||",
"$",
"insertOnly",
"==",
"'0'",
")",
"?",
"0",
":",
"1",
")",
";",
"}",
"$",
"req",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"'post'",
",",
"'timeout'",
"=>",
"self",
"::",
"$",
"timeout",
",",
"'data'",
"=>",
"$",
"data",
",",
"'header'",
"=>",
"[",
"'Authorization:'",
".",
"$",
"sign",
",",
"]",
",",
"]",
";",
"return",
"self",
"::",
"sendRequest",
"(",
"$",
"req",
")",
";",
"}"
]
| 内部方法, 上传文件.
@param string $bucketName bucket名称
@param string $srcPath 本地文件路径
@param string $dstPath 上传的文件路径
@param string $bizAttr 文件属性
@param int $insertOnly 是否覆盖同名文件:0 覆盖,1:不覆盖
@return array | [
"内部方法",
"上传文件",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L329-L373 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.upload_slice | private static function upload_slice(
$bucketName, $srcPath, $dstPath,
$bizAttr = null, $sliceSize = null, $insertOnly = null)
{
$srcPath = realpath($srcPath);
$fileSize = filesize($srcPath);
$dstPath = self::cosUrlEncode($dstPath);
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $dstPath);
$sign = Auth::appSign($expired, $bucketName);
$sha1 = hash_file('sha1', $srcPath);
$ret = self::upload_prepare(
$fileSize, $sha1, $sliceSize,
$sign, $url, $bizAttr, $insertOnly);
if ($ret['code'] != 0) {
return $ret;
}
if (isset($ret['data'])
&& isset($ret['data']['url'])) {
//秒传命中,直接返回了url
return $ret;
}
$sliceSize = $ret['data']['slice_size'];
if ($sliceSize > self::SLICE_SIZE_3M ||
$sliceSize <= 0) {
$ret['code'] = self::COSAPI_PARAMS_ERROR;
$ret['message'] = 'illegal slice size';
return $ret;
}
$session = $ret['data']['session'];
$offset = $ret['data']['offset'];
$sliceCnt = ceil($fileSize / $sliceSize);
// expired seconds for one slice mutiply by slice count
// will be the expired seconds for whole file
$expired = self::time() + (self::EXPIRED_SECONDS * $sliceCnt);
$sign = Auth::appSign($expired, $bucketName);
$ret = self::upload_data(
$fileSize, $sha1, $sliceSize,
$sign, $url, $srcPath,
$offset, $session);
return $ret;
} | php | private static function upload_slice(
$bucketName, $srcPath, $dstPath,
$bizAttr = null, $sliceSize = null, $insertOnly = null)
{
$srcPath = realpath($srcPath);
$fileSize = filesize($srcPath);
$dstPath = self::cosUrlEncode($dstPath);
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $dstPath);
$sign = Auth::appSign($expired, $bucketName);
$sha1 = hash_file('sha1', $srcPath);
$ret = self::upload_prepare(
$fileSize, $sha1, $sliceSize,
$sign, $url, $bizAttr, $insertOnly);
if ($ret['code'] != 0) {
return $ret;
}
if (isset($ret['data'])
&& isset($ret['data']['url'])) {
//秒传命中,直接返回了url
return $ret;
}
$sliceSize = $ret['data']['slice_size'];
if ($sliceSize > self::SLICE_SIZE_3M ||
$sliceSize <= 0) {
$ret['code'] = self::COSAPI_PARAMS_ERROR;
$ret['message'] = 'illegal slice size';
return $ret;
}
$session = $ret['data']['session'];
$offset = $ret['data']['offset'];
$sliceCnt = ceil($fileSize / $sliceSize);
// expired seconds for one slice mutiply by slice count
// will be the expired seconds for whole file
$expired = self::time() + (self::EXPIRED_SECONDS * $sliceCnt);
$sign = Auth::appSign($expired, $bucketName);
$ret = self::upload_data(
$fileSize, $sha1, $sliceSize,
$sign, $url, $srcPath,
$offset, $session);
return $ret;
} | [
"private",
"static",
"function",
"upload_slice",
"(",
"$",
"bucketName",
",",
"$",
"srcPath",
",",
"$",
"dstPath",
",",
"$",
"bizAttr",
"=",
"null",
",",
"$",
"sliceSize",
"=",
"null",
",",
"$",
"insertOnly",
"=",
"null",
")",
"{",
"$",
"srcPath",
"=",
"realpath",
"(",
"$",
"srcPath",
")",
";",
"$",
"fileSize",
"=",
"filesize",
"(",
"$",
"srcPath",
")",
";",
"$",
"dstPath",
"=",
"self",
"::",
"cosUrlEncode",
"(",
"$",
"dstPath",
")",
";",
"$",
"expired",
"=",
"self",
"::",
"time",
"(",
")",
"+",
"self",
"::",
"EXPIRED_SECONDS",
";",
"$",
"url",
"=",
"self",
"::",
"generateResUrl",
"(",
"$",
"bucketName",
",",
"$",
"dstPath",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign",
"(",
"$",
"expired",
",",
"$",
"bucketName",
")",
";",
"$",
"sha1",
"=",
"hash_file",
"(",
"'sha1'",
",",
"$",
"srcPath",
")",
";",
"$",
"ret",
"=",
"self",
"::",
"upload_prepare",
"(",
"$",
"fileSize",
",",
"$",
"sha1",
",",
"$",
"sliceSize",
",",
"$",
"sign",
",",
"$",
"url",
",",
"$",
"bizAttr",
",",
"$",
"insertOnly",
")",
";",
"if",
"(",
"$",
"ret",
"[",
"'code'",
"]",
"!=",
"0",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"ret",
"[",
"'data'",
"]",
")",
"&&",
"isset",
"(",
"$",
"ret",
"[",
"'data'",
"]",
"[",
"'url'",
"]",
")",
")",
"{",
"//秒传命中,直接返回了url",
"return",
"$",
"ret",
";",
"}",
"$",
"sliceSize",
"=",
"$",
"ret",
"[",
"'data'",
"]",
"[",
"'slice_size'",
"]",
";",
"if",
"(",
"$",
"sliceSize",
">",
"self",
"::",
"SLICE_SIZE_3M",
"||",
"$",
"sliceSize",
"<=",
"0",
")",
"{",
"$",
"ret",
"[",
"'code'",
"]",
"=",
"self",
"::",
"COSAPI_PARAMS_ERROR",
";",
"$",
"ret",
"[",
"'message'",
"]",
"=",
"'illegal slice size'",
";",
"return",
"$",
"ret",
";",
"}",
"$",
"session",
"=",
"$",
"ret",
"[",
"'data'",
"]",
"[",
"'session'",
"]",
";",
"$",
"offset",
"=",
"$",
"ret",
"[",
"'data'",
"]",
"[",
"'offset'",
"]",
";",
"$",
"sliceCnt",
"=",
"ceil",
"(",
"$",
"fileSize",
"/",
"$",
"sliceSize",
")",
";",
"// expired seconds for one slice mutiply by slice count",
"// will be the expired seconds for whole file",
"$",
"expired",
"=",
"self",
"::",
"time",
"(",
")",
"+",
"(",
"self",
"::",
"EXPIRED_SECONDS",
"*",
"$",
"sliceCnt",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign",
"(",
"$",
"expired",
",",
"$",
"bucketName",
")",
";",
"$",
"ret",
"=",
"self",
"::",
"upload_data",
"(",
"$",
"fileSize",
",",
"$",
"sha1",
",",
"$",
"sliceSize",
",",
"$",
"sign",
",",
"$",
"url",
",",
"$",
"srcPath",
",",
"$",
"offset",
",",
"$",
"session",
")",
";",
"return",
"$",
"ret",
";",
"}"
]
| 内部方法,上传文件.
@param string $bucketName bucket名称
@param string $srcPath 本地文件路径
@param string $dstPath 上传的文件路径
@param string $bizAttr 文件属性
@param string $sliceSize 分片大小
@param int $insertOnly 是否覆盖同名文件:0 覆盖,1:不覆盖
@return array | [
"内部方法",
"上传文件",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L387-L438 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.upload_prepare | private static function upload_prepare(
$fileSize, $sha1, $sliceSize,
$sign, $url, $bizAttr = null, $insertOnly = null)
{
$data = [
'op' => 'upload_slice',
'filesize' => $fileSize,
'sha' => $sha1,
];
if (isset($bizAttr) && strlen($bizAttr)) {
$data['biz_attr'] = $bizAttr;
}
if (isset($insertOnly)) {
$data['insertOnly'] = (($insertOnly == 0) ? 0 : 1);
}
if ($sliceSize <= self::SLICE_SIZE_3M) {
$data['slice_size'] = $sliceSize;
} else {
$data['slice_size'] = self::SLICE_SIZE_3M;
}
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
],
];
$ret = self::sendRequest($req);
return $ret;
} | php | private static function upload_prepare(
$fileSize, $sha1, $sliceSize,
$sign, $url, $bizAttr = null, $insertOnly = null)
{
$data = [
'op' => 'upload_slice',
'filesize' => $fileSize,
'sha' => $sha1,
];
if (isset($bizAttr) && strlen($bizAttr)) {
$data['biz_attr'] = $bizAttr;
}
if (isset($insertOnly)) {
$data['insertOnly'] = (($insertOnly == 0) ? 0 : 1);
}
if ($sliceSize <= self::SLICE_SIZE_3M) {
$data['slice_size'] = $sliceSize;
} else {
$data['slice_size'] = self::SLICE_SIZE_3M;
}
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
],
];
$ret = self::sendRequest($req);
return $ret;
} | [
"private",
"static",
"function",
"upload_prepare",
"(",
"$",
"fileSize",
",",
"$",
"sha1",
",",
"$",
"sliceSize",
",",
"$",
"sign",
",",
"$",
"url",
",",
"$",
"bizAttr",
"=",
"null",
",",
"$",
"insertOnly",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"'op'",
"=>",
"'upload_slice'",
",",
"'filesize'",
"=>",
"$",
"fileSize",
",",
"'sha'",
"=>",
"$",
"sha1",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"bizAttr",
")",
"&&",
"strlen",
"(",
"$",
"bizAttr",
")",
")",
"{",
"$",
"data",
"[",
"'biz_attr'",
"]",
"=",
"$",
"bizAttr",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"insertOnly",
")",
")",
"{",
"$",
"data",
"[",
"'insertOnly'",
"]",
"=",
"(",
"(",
"$",
"insertOnly",
"==",
"0",
")",
"?",
"0",
":",
"1",
")",
";",
"}",
"if",
"(",
"$",
"sliceSize",
"<=",
"self",
"::",
"SLICE_SIZE_3M",
")",
"{",
"$",
"data",
"[",
"'slice_size'",
"]",
"=",
"$",
"sliceSize",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'slice_size'",
"]",
"=",
"self",
"::",
"SLICE_SIZE_3M",
";",
"}",
"$",
"req",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"'post'",
",",
"'timeout'",
"=>",
"self",
"::",
"$",
"timeout",
",",
"'data'",
"=>",
"$",
"data",
",",
"'header'",
"=>",
"[",
"'Authorization:'",
".",
"$",
"sign",
",",
"]",
",",
"]",
";",
"$",
"ret",
"=",
"self",
"::",
"sendRequest",
"(",
"$",
"req",
")",
";",
"return",
"$",
"ret",
";",
"}"
]
| 第一个分片控制消息.
@param string $fileSize 文件大小
@param string $sha1 文件sha值
@param string $sliceSize 分片大小
@param string $sign 签名
@param string $url URL
@param string $bizAttr 文件属性
@param string $insertOnly 同名文件是否覆盖
@return array | [
"第一个分片控制消息",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L453-L490 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.updateBase | private static function updateBase($bucketName, $path,
$bizAttr = null, $authority = null, $custom_headers_array = null)
{
$path = self::cosUrlEncode($path);
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign_once(
$path, $bucketName);
$data = [
'op' => 'update',
];
$flag = 0;
if (isset($bizAttr)) {
$data['biz_attr'] = $bizAttr;
$flag = $flag | 0x01;
}
if (isset($authority) && strlen($authority) > 0) {
if (self::isAuthorityValid($authority) == false) {
return [
'code' => self::COSAPI_PARAMS_ERROR,
'message' => 'parameter authority invalid',
];
}
$data['authority'] = $authority;
$flag = $flag | 0x80;
}
if (isset($custom_headers_array)) {
$data['custom_headers'] = [];
self::add_customer_header($data['custom_headers'], $custom_headers_array);
$flag = $flag | 0x40;
}
if ($flag != 0 && $flag != 1) {
$data['flag'] = $flag;
}
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | php | private static function updateBase($bucketName, $path,
$bizAttr = null, $authority = null, $custom_headers_array = null)
{
$path = self::cosUrlEncode($path);
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign_once(
$path, $bucketName);
$data = [
'op' => 'update',
];
$flag = 0;
if (isset($bizAttr)) {
$data['biz_attr'] = $bizAttr;
$flag = $flag | 0x01;
}
if (isset($authority) && strlen($authority) > 0) {
if (self::isAuthorityValid($authority) == false) {
return [
'code' => self::COSAPI_PARAMS_ERROR,
'message' => 'parameter authority invalid',
];
}
$data['authority'] = $authority;
$flag = $flag | 0x80;
}
if (isset($custom_headers_array)) {
$data['custom_headers'] = [];
self::add_customer_header($data['custom_headers'], $custom_headers_array);
$flag = $flag | 0x40;
}
if ($flag != 0 && $flag != 1) {
$data['flag'] = $flag;
}
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | [
"private",
"static",
"function",
"updateBase",
"(",
"$",
"bucketName",
",",
"$",
"path",
",",
"$",
"bizAttr",
"=",
"null",
",",
"$",
"authority",
"=",
"null",
",",
"$",
"custom_headers_array",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"cosUrlEncode",
"(",
"$",
"path",
")",
";",
"$",
"url",
"=",
"self",
"::",
"generateResUrl",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign_once",
"(",
"$",
"path",
",",
"$",
"bucketName",
")",
";",
"$",
"data",
"=",
"[",
"'op'",
"=>",
"'update'",
",",
"]",
";",
"$",
"flag",
"=",
"0",
";",
"if",
"(",
"isset",
"(",
"$",
"bizAttr",
")",
")",
"{",
"$",
"data",
"[",
"'biz_attr'",
"]",
"=",
"$",
"bizAttr",
";",
"$",
"flag",
"=",
"$",
"flag",
"|",
"0x01",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"authority",
")",
"&&",
"strlen",
"(",
"$",
"authority",
")",
">",
"0",
")",
"{",
"if",
"(",
"self",
"::",
"isAuthorityValid",
"(",
"$",
"authority",
")",
"==",
"false",
")",
"{",
"return",
"[",
"'code'",
"=>",
"self",
"::",
"COSAPI_PARAMS_ERROR",
",",
"'message'",
"=>",
"'parameter authority invalid'",
",",
"]",
";",
"}",
"$",
"data",
"[",
"'authority'",
"]",
"=",
"$",
"authority",
";",
"$",
"flag",
"=",
"$",
"flag",
"|",
"0x80",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"custom_headers_array",
")",
")",
"{",
"$",
"data",
"[",
"'custom_headers'",
"]",
"=",
"[",
"]",
";",
"self",
"::",
"add_customer_header",
"(",
"$",
"data",
"[",
"'custom_headers'",
"]",
",",
"$",
"custom_headers_array",
")",
";",
"$",
"flag",
"=",
"$",
"flag",
"|",
"0x40",
";",
"}",
"if",
"(",
"$",
"flag",
"!=",
"0",
"&&",
"$",
"flag",
"!=",
"1",
")",
"{",
"$",
"data",
"[",
"'flag'",
"]",
"=",
"$",
"flag",
";",
"}",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"req",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"'post'",
",",
"'timeout'",
"=>",
"self",
"::",
"$",
"timeout",
",",
"'data'",
"=>",
"$",
"data",
",",
"'header'",
"=>",
"[",
"'Authorization:'",
".",
"$",
"sign",
",",
"'Content-Type: application/json'",
",",
"]",
",",
"]",
";",
"return",
"self",
"::",
"sendRequest",
"(",
"$",
"req",
")",
";",
"}"
]
| 内部公共方法(更新文件和更新文件夹).
@param string $bucketName bucket名称
@param string $path 路径
@param string $bizAttr 文件/目录属性
@param string $authority : eInvalid/eWRPrivate(私有)/eWPrivateRPublic(公有读写)
@param array $custom_headers_array 携带的用户自定义头域,包括
'Cache-Control' => '*'
'Content-Type' => '*'
'Content-Disposition' => '*'
'Content-Language' => '*'
'x-cos-meta-自定义内容' => '*'
@return array|mixed | [
"内部公共方法",
"(",
"更新文件和更新文件夹",
")",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L682-L737 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.statBase | private static function statBase($bucketName, $path)
{
$path = self::cosUrlEncode($path);
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign($expired, $bucketName);
$data = [
'op' => 'stat',
];
$url = $url.'?'.http_build_query($data);
$req = [
'url' => $url,
'method' => 'get',
'timeout' => self::$timeout,
'header' => [
'Authorization:'.$sign,
],
];
return self::sendRequest($req);
} | php | private static function statBase($bucketName, $path)
{
$path = self::cosUrlEncode($path);
$expired = self::time() + self::EXPIRED_SECONDS;
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign($expired, $bucketName);
$data = [
'op' => 'stat',
];
$url = $url.'?'.http_build_query($data);
$req = [
'url' => $url,
'method' => 'get',
'timeout' => self::$timeout,
'header' => [
'Authorization:'.$sign,
],
];
return self::sendRequest($req);
} | [
"private",
"static",
"function",
"statBase",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"cosUrlEncode",
"(",
"$",
"path",
")",
";",
"$",
"expired",
"=",
"self",
"::",
"time",
"(",
")",
"+",
"self",
"::",
"EXPIRED_SECONDS",
";",
"$",
"url",
"=",
"self",
"::",
"generateResUrl",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign",
"(",
"$",
"expired",
",",
"$",
"bucketName",
")",
";",
"$",
"data",
"=",
"[",
"'op'",
"=>",
"'stat'",
",",
"]",
";",
"$",
"url",
"=",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"data",
")",
";",
"$",
"req",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"'get'",
",",
"'timeout'",
"=>",
"self",
"::",
"$",
"timeout",
",",
"'header'",
"=>",
"[",
"'Authorization:'",
".",
"$",
"sign",
",",
"]",
",",
"]",
";",
"return",
"self",
"::",
"sendRequest",
"(",
"$",
"req",
")",
";",
"}"
]
| 内部方法.
@param string $bucketName bucket名称
@param string $path 文件/目录路径
@return array | [
"内部方法",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L747-L770 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.delBase | private static function delBase($bucketName, $path)
{
if ($path == '/') {
return [
'code' => self::COSAPI_PARAMS_ERROR,
'message' => 'can not delete bucket using api! go to http://console.qcloud.com/cos to operate bucket',
];
}
$path = self::cosUrlEncode($path);
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign_once(
$path, $bucketName);
$data = [
'op' => 'delete',
];
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | php | private static function delBase($bucketName, $path)
{
if ($path == '/') {
return [
'code' => self::COSAPI_PARAMS_ERROR,
'message' => 'can not delete bucket using api! go to http://console.qcloud.com/cos to operate bucket',
];
}
$path = self::cosUrlEncode($path);
$url = self::generateResUrl($bucketName, $path);
$sign = Auth::appSign_once(
$path, $bucketName);
$data = [
'op' => 'delete',
];
$data = json_encode($data);
$req = [
'url' => $url,
'method' => 'post',
'timeout' => self::$timeout,
'data' => $data,
'header' => [
'Authorization:'.$sign,
'Content-Type: application/json',
],
];
return self::sendRequest($req);
} | [
"private",
"static",
"function",
"delBase",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"==",
"'/'",
")",
"{",
"return",
"[",
"'code'",
"=>",
"self",
"::",
"COSAPI_PARAMS_ERROR",
",",
"'message'",
"=>",
"'can not delete bucket using api! go to http://console.qcloud.com/cos to operate bucket'",
",",
"]",
";",
"}",
"$",
"path",
"=",
"self",
"::",
"cosUrlEncode",
"(",
"$",
"path",
")",
";",
"$",
"url",
"=",
"self",
"::",
"generateResUrl",
"(",
"$",
"bucketName",
",",
"$",
"path",
")",
";",
"$",
"sign",
"=",
"Auth",
"::",
"appSign_once",
"(",
"$",
"path",
",",
"$",
"bucketName",
")",
";",
"$",
"data",
"=",
"[",
"'op'",
"=>",
"'delete'",
",",
"]",
";",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"req",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"'post'",
",",
"'timeout'",
"=>",
"self",
"::",
"$",
"timeout",
",",
"'data'",
"=>",
"$",
"data",
",",
"'header'",
"=>",
"[",
"'Authorization:'",
".",
"$",
"sign",
",",
"'Content-Type: application/json'",
",",
"]",
",",
"]",
";",
"return",
"self",
"::",
"sendRequest",
"(",
"$",
"req",
")",
";",
"}"
]
| 内部私有方法.
@param string $bucketName bucket名称
@param string $path 文件/目录路径路径
@return array | [
"内部私有方法",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L780-L813 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.sendRequest | private static function sendRequest($req)
{
$rsp = Http::send($req);
$ret = json_decode($rsp, true);
if ($ret) {
if (0 === $ret['code']) {
return $ret;
} else {
return [
'code' => $ret['code'],
'message' => $ret['message'],
'data' => [],
];
}
} else {
return [
'code' => self::COSAPI_NETWORK_ERROR,
'message' => $rsp,
'data' => [],
];
}
} | php | private static function sendRequest($req)
{
$rsp = Http::send($req);
$ret = json_decode($rsp, true);
if ($ret) {
if (0 === $ret['code']) {
return $ret;
} else {
return [
'code' => $ret['code'],
'message' => $ret['message'],
'data' => [],
];
}
} else {
return [
'code' => self::COSAPI_NETWORK_ERROR,
'message' => $rsp,
'data' => [],
];
}
} | [
"private",
"static",
"function",
"sendRequest",
"(",
"$",
"req",
")",
"{",
"$",
"rsp",
"=",
"Http",
"::",
"send",
"(",
"$",
"req",
")",
";",
"$",
"ret",
"=",
"json_decode",
"(",
"$",
"rsp",
",",
"true",
")",
";",
"if",
"(",
"$",
"ret",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"ret",
"[",
"'code'",
"]",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"else",
"{",
"return",
"[",
"'code'",
"=>",
"$",
"ret",
"[",
"'code'",
"]",
",",
"'message'",
"=>",
"$",
"ret",
"[",
"'message'",
"]",
",",
"'data'",
"=>",
"[",
"]",
",",
"]",
";",
"}",
"}",
"else",
"{",
"return",
"[",
"'code'",
"=>",
"self",
"::",
"COSAPI_NETWORK_ERROR",
",",
"'message'",
"=>",
"$",
"rsp",
",",
"'data'",
"=>",
"[",
"]",
",",
"]",
";",
"}",
"}"
]
| 内部公共方法, 发送消息.
@param array $req
@return array | [
"内部公共方法",
"发送消息",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L847-L870 |
freyo/flysystem-qcloud-cos-v3 | src/Client/Cosapi.php | Cosapi.normalizerPath | private static function normalizerPath($path, $isfolder = false)
{
if (preg_match('/^\//', $path) == 0) {
$path = '/'.$path;
}
if ($isfolder == true) {
if (preg_match('/\/$/', $path) == 0) {
$path = $path.'/';
}
}
return $path;
} | php | private static function normalizerPath($path, $isfolder = false)
{
if (preg_match('/^\//', $path) == 0) {
$path = '/'.$path;
}
if ($isfolder == true) {
if (preg_match('/\/$/', $path) == 0) {
$path = $path.'/';
}
}
return $path;
} | [
"private",
"static",
"function",
"normalizerPath",
"(",
"$",
"path",
",",
"$",
"isfolder",
"=",
"false",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\//'",
",",
"$",
"path",
")",
"==",
"0",
")",
"{",
"$",
"path",
"=",
"'/'",
".",
"$",
"path",
";",
"}",
"if",
"(",
"$",
"isfolder",
"==",
"true",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/\\/$/'",
",",
"$",
"path",
")",
"==",
"0",
")",
"{",
"$",
"path",
"=",
"$",
"path",
".",
"'/'",
";",
"}",
"}",
"return",
"$",
"path",
";",
"}"
]
| 内部方法, 规整文件路径.
@param string $path 文件路径
@param bool $isfolder 是否为文件夹
@return string | [
"内部方法",
"规整文件路径",
"."
]
| train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Client/Cosapi.php#L907-L920 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.assets | public function assets($type = 'css')
{
$output = [];
$assets = $this->Assets->getAssets($type);
foreach ($assets as $asset) {
$output[] = $asset['output'];
}
return implode($this->eol, $output);
} | php | public function assets($type = 'css')
{
$output = [];
$assets = $this->Assets->getAssets($type);
foreach ($assets as $asset) {
$output[] = $asset['output'];
}
return implode($this->eol, $output);
} | [
"public",
"function",
"assets",
"(",
"$",
"type",
"=",
"'css'",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"assets",
"=",
"$",
"this",
"->",
"Assets",
"->",
"getAssets",
"(",
"$",
"type",
")",
";",
"foreach",
"(",
"$",
"assets",
"as",
"$",
"asset",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"$",
"asset",
"[",
"'output'",
"]",
";",
"}",
"return",
"implode",
"(",
"$",
"this",
"->",
"eol",
",",
"$",
"output",
")",
";",
"}"
]
| Get assets fot layout render.
@param string $type
@return string | [
"Get",
"assets",
"fot",
"layout",
"render",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L118-L127 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.beforeLayout | public function beforeLayout(Event $event, $layoutFile)
{
$pluginEvent = Plugin::getData('Core', 'View.beforeLayout');
if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeLayout')) {
call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $layoutFile]);
}
} | php | public function beforeLayout(Event $event, $layoutFile)
{
$pluginEvent = Plugin::getData('Core', 'View.beforeLayout');
if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeLayout')) {
call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $layoutFile]);
}
} | [
"public",
"function",
"beforeLayout",
"(",
"Event",
"$",
"event",
",",
"$",
"layoutFile",
")",
"{",
"$",
"pluginEvent",
"=",
"Plugin",
"::",
"getData",
"(",
"'Core'",
",",
"'View.beforeLayout'",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"pluginEvent",
"->",
"find",
"(",
"0",
")",
")",
"&&",
"Plugin",
"::",
"hasManifestEvent",
"(",
"'View.beforeLayout'",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"pluginEvent",
"->",
"find",
"(",
"0",
")",
",",
"[",
"$",
"this",
"->",
"_View",
",",
"$",
"event",
",",
"$",
"layoutFile",
"]",
")",
";",
"}",
"}"
]
| Is called before layout rendering starts. Receives the layout filename as an argument.
@param Event $event
@param string $layoutFile
@return void
@throws \JBZoo\Utils\Exception | [
"Is",
"called",
"before",
"layout",
"rendering",
"starts",
".",
"Receives",
"the",
"layout",
"filename",
"as",
"an",
"argument",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L138-L144 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.beforeRender | public function beforeRender(Event $event, $viewFile)
{
$this->Assets->loadPluginAssets();
$pluginEvent = Plugin::getData('Core', 'View.beforeRender');
if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeRender')) {
call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $viewFile]);
}
} | php | public function beforeRender(Event $event, $viewFile)
{
$this->Assets->loadPluginAssets();
$pluginEvent = Plugin::getData('Core', 'View.beforeRender');
if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeRender')) {
call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $viewFile]);
}
} | [
"public",
"function",
"beforeRender",
"(",
"Event",
"$",
"event",
",",
"$",
"viewFile",
")",
"{",
"$",
"this",
"->",
"Assets",
"->",
"loadPluginAssets",
"(",
")",
";",
"$",
"pluginEvent",
"=",
"Plugin",
"::",
"getData",
"(",
"'Core'",
",",
"'View.beforeRender'",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"pluginEvent",
"->",
"find",
"(",
"0",
")",
")",
"&&",
"Plugin",
"::",
"hasManifestEvent",
"(",
"'View.beforeRender'",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"pluginEvent",
"->",
"find",
"(",
"0",
")",
",",
"[",
"$",
"this",
"->",
"_View",
",",
"$",
"event",
",",
"$",
"viewFile",
"]",
")",
";",
"}",
"}"
]
| Is called after the controller’s beforeRender method but before the controller renders view and layout.
Receives the file being rendered as an argument.
@param Event $event
@param string $viewFile
@return void
@throws \JBZoo\Less\Exception
@throws \JBZoo\Utils\Exception | [
"Is",
"called",
"after",
"the",
"controller’s",
"beforeRender",
"method",
"but",
"before",
"the",
"controller",
"renders",
"view",
"and",
"layout",
".",
"Receives",
"the",
"file",
"being",
"rendered",
"as",
"an",
"argument",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L157-L165 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.beforeRenderFile | public function beforeRenderFile(Event $event, $viewFile)
{
$pluginEvent = Plugin::getData('Core', 'View.beforeRenderFile');
if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeRenderFile')) {
call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $viewFile]);
}
} | php | public function beforeRenderFile(Event $event, $viewFile)
{
$pluginEvent = Plugin::getData('Core', 'View.beforeRenderFile');
if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeRenderFile')) {
call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $viewFile]);
}
} | [
"public",
"function",
"beforeRenderFile",
"(",
"Event",
"$",
"event",
",",
"$",
"viewFile",
")",
"{",
"$",
"pluginEvent",
"=",
"Plugin",
"::",
"getData",
"(",
"'Core'",
",",
"'View.beforeRenderFile'",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"pluginEvent",
"->",
"find",
"(",
"0",
")",
")",
"&&",
"Plugin",
"::",
"hasManifestEvent",
"(",
"'View.beforeRenderFile'",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"pluginEvent",
"->",
"find",
"(",
"0",
")",
",",
"[",
"$",
"this",
"->",
"_View",
",",
"$",
"event",
",",
"$",
"viewFile",
"]",
")",
";",
"}",
"}"
]
| Is called before each view file is rendered. This includes elements, views, parent views and layouts.
@param Event $event
@param string $viewFile
@return void
@throws \JBZoo\Utils\Exception | [
"Is",
"called",
"before",
"each",
"view",
"file",
"is",
"rendered",
".",
"This",
"includes",
"elements",
"views",
"parent",
"views",
"and",
"layouts",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L176-L182 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.getBodyClasses | public function getBodyClasses()
{
$prefix = ($this->request->getParam('prefix')) ? 'prefix-' . $this->request->getParam('prefix') : 'prefix-site';
$classes = [
$prefix,
'theme-' . Str::low($this->_View->theme),
'plugin-' . Str::low($this->_View->plugin),
'view-' . Str::low($this->_View->name),
'tmpl-' . Str::low($this->_View->template),
'layout-' . Str::low($this->_View->layout)
];
$pass = (array) $this->request->getParam('pass');
if (count($pass)) {
$classes[] = 'item-id-' . array_shift($pass);
}
return implode(' ', $classes);
} | php | public function getBodyClasses()
{
$prefix = ($this->request->getParam('prefix')) ? 'prefix-' . $this->request->getParam('prefix') : 'prefix-site';
$classes = [
$prefix,
'theme-' . Str::low($this->_View->theme),
'plugin-' . Str::low($this->_View->plugin),
'view-' . Str::low($this->_View->name),
'tmpl-' . Str::low($this->_View->template),
'layout-' . Str::low($this->_View->layout)
];
$pass = (array) $this->request->getParam('pass');
if (count($pass)) {
$classes[] = 'item-id-' . array_shift($pass);
}
return implode(' ', $classes);
} | [
"public",
"function",
"getBodyClasses",
"(",
")",
"{",
"$",
"prefix",
"=",
"(",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
")",
"?",
"'prefix-'",
".",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
":",
"'prefix-site'",
";",
"$",
"classes",
"=",
"[",
"$",
"prefix",
",",
"'theme-'",
".",
"Str",
"::",
"low",
"(",
"$",
"this",
"->",
"_View",
"->",
"theme",
")",
",",
"'plugin-'",
".",
"Str",
"::",
"low",
"(",
"$",
"this",
"->",
"_View",
"->",
"plugin",
")",
",",
"'view-'",
".",
"Str",
"::",
"low",
"(",
"$",
"this",
"->",
"_View",
"->",
"name",
")",
",",
"'tmpl-'",
".",
"Str",
"::",
"low",
"(",
"$",
"this",
"->",
"_View",
"->",
"template",
")",
",",
"'layout-'",
".",
"Str",
"::",
"low",
"(",
"$",
"this",
"->",
"_View",
"->",
"layout",
")",
"]",
";",
"$",
"pass",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'pass'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"pass",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'item-id-'",
".",
"array_shift",
"(",
"$",
"pass",
")",
";",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}"
]
| Get body classes by view data.
@return string | [
"Get",
"body",
"classes",
"by",
"view",
"data",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L189-L208 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.head | public function head()
{
$output = [
'meta' => $this->_View->fetch('meta'),
'assets' => $this->assets('css'),
'fetch_css' => $this->_View->fetch('css'),
'fetch_css_bottom' => $this->_View->fetch('css_bottom'),
];
return implode('', $output);
} | php | public function head()
{
$output = [
'meta' => $this->_View->fetch('meta'),
'assets' => $this->assets('css'),
'fetch_css' => $this->_View->fetch('css'),
'fetch_css_bottom' => $this->_View->fetch('css_bottom'),
];
return implode('', $output);
} | [
"public",
"function",
"head",
"(",
")",
"{",
"$",
"output",
"=",
"[",
"'meta'",
"=>",
"$",
"this",
"->",
"_View",
"->",
"fetch",
"(",
"'meta'",
")",
",",
"'assets'",
"=>",
"$",
"this",
"->",
"assets",
"(",
"'css'",
")",
",",
"'fetch_css'",
"=>",
"$",
"this",
"->",
"_View",
"->",
"fetch",
"(",
"'css'",
")",
",",
"'fetch_css_bottom'",
"=>",
"$",
"this",
"->",
"_View",
"->",
"fetch",
"(",
"'css_bottom'",
")",
",",
"]",
";",
"return",
"implode",
"(",
"''",
",",
"$",
"output",
")",
";",
"}"
]
| Create head for layout.
@return string | [
"Create",
"head",
"for",
"layout",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L215-L225 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.initialize | public function initialize(array $config)
{
parent::initialize($config);
$this->dir = Configure::read('Cms.docDir');
$this->locale = Configure::read('App.defaultLocale');
$this->charset = Str::low(Configure::read('App.encoding'));
$this->eol = (Configure::read('debug')) ? PHP_EOL : '';
$this->tab = (Configure::read('debug')) ? Configure::read('Cms.lineTab') : '';
} | php | public function initialize(array $config)
{
parent::initialize($config);
$this->dir = Configure::read('Cms.docDir');
$this->locale = Configure::read('App.defaultLocale');
$this->charset = Str::low(Configure::read('App.encoding'));
$this->eol = (Configure::read('debug')) ? PHP_EOL : '';
$this->tab = (Configure::read('debug')) ? Configure::read('Cms.lineTab') : '';
} | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"config",
")",
"{",
"parent",
"::",
"initialize",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"dir",
"=",
"Configure",
"::",
"read",
"(",
"'Cms.docDir'",
")",
";",
"$",
"this",
"->",
"locale",
"=",
"Configure",
"::",
"read",
"(",
"'App.defaultLocale'",
")",
";",
"$",
"this",
"->",
"charset",
"=",
"Str",
"::",
"low",
"(",
"Configure",
"::",
"read",
"(",
"'App.encoding'",
")",
")",
";",
"$",
"this",
"->",
"eol",
"=",
"(",
"Configure",
"::",
"read",
"(",
"'debug'",
")",
")",
"?",
"PHP_EOL",
":",
"''",
";",
"$",
"this",
"->",
"tab",
"=",
"(",
"Configure",
"::",
"read",
"(",
"'debug'",
")",
")",
"?",
"Configure",
"::",
"read",
"(",
"'Cms.lineTab'",
")",
":",
"''",
";",
"}"
]
| Constructor hook method.
@param array $config | [
"Constructor",
"hook",
"method",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L232-L241 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.lang | public function lang($isLang = true)
{
list($lang, $region) = explode('_', $this->locale);
return ($isLang) ? Str::low($lang) : Str::low($region);
} | php | public function lang($isLang = true)
{
list($lang, $region) = explode('_', $this->locale);
return ($isLang) ? Str::low($lang) : Str::low($region);
} | [
"public",
"function",
"lang",
"(",
"$",
"isLang",
"=",
"true",
")",
"{",
"list",
"(",
"$",
"lang",
",",
"$",
"region",
")",
"=",
"explode",
"(",
"'_'",
",",
"$",
"this",
"->",
"locale",
")",
";",
"return",
"(",
"$",
"isLang",
")",
"?",
"Str",
"::",
"low",
"(",
"$",
"lang",
")",
":",
"Str",
"::",
"low",
"(",
"$",
"region",
")",
";",
"}"
]
| Site language.
@param bool|true $isLang
@return string
@throws \Exception | [
"Site",
"language",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L251-L255 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.meta | public function meta(array $rows, $block = null)
{
$output = [];
foreach ($rows as $row) {
$output[] = trim($row);
}
$output = implode($this->eol, $output) . $this->eol;
if ($block !== null) {
$this->_View->append($block, $output);
return null;
}
return $output;
} | php | public function meta(array $rows, $block = null)
{
$output = [];
foreach ($rows as $row) {
$output[] = trim($row);
}
$output = implode($this->eol, $output) . $this->eol;
if ($block !== null) {
$this->_View->append($block, $output);
return null;
}
return $output;
} | [
"public",
"function",
"meta",
"(",
"array",
"$",
"rows",
",",
"$",
"block",
"=",
"null",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"trim",
"(",
"$",
"row",
")",
";",
"}",
"$",
"output",
"=",
"implode",
"(",
"$",
"this",
"->",
"eol",
",",
"$",
"output",
")",
".",
"$",
"this",
"->",
"eol",
";",
"if",
"(",
"$",
"block",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_View",
"->",
"append",
"(",
"$",
"block",
",",
"$",
"output",
")",
";",
"return",
"null",
";",
"}",
"return",
"$",
"output",
";",
"}"
]
| Creates a link to an external resource and handles basic meta tags.
@param array $rows
@param null $block
@return null|string | [
"Creates",
"a",
"link",
"to",
"an",
"external",
"resource",
"and",
"handles",
"basic",
"meta",
"tags",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L264-L279 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper.type | public function type()
{
$lang = $this->lang();
$html = [
'<!doctype html>',
'<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6" '
. 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->',
'<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie7" '
. 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->',
'<!--[if IE 8]><html class="no-js lt-ie9 ie8" '
. 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->',
'<!--[if gt IE 8]><!--><html class="no-js" xmlns="http://www.w3.org/1999/xhtml" '
. 'lang="' . $lang . '" dir="' . $this->dir . '" '
. 'prefix="og: http://ogp.me/ns#" '
. '> <!--<![endif]-->',
];
return implode($this->eol, $html) . $this->eol;
} | php | public function type()
{
$lang = $this->lang();
$html = [
'<!doctype html>',
'<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6" '
. 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->',
'<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie7" '
. 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->',
'<!--[if IE 8]><html class="no-js lt-ie9 ie8" '
. 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->',
'<!--[if gt IE 8]><!--><html class="no-js" xmlns="http://www.w3.org/1999/xhtml" '
. 'lang="' . $lang . '" dir="' . $this->dir . '" '
. 'prefix="og: http://ogp.me/ns#" '
. '> <!--<![endif]-->',
];
return implode($this->eol, $html) . $this->eol;
} | [
"public",
"function",
"type",
"(",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"lang",
"(",
")",
";",
"$",
"html",
"=",
"[",
"'<!doctype html>'",
",",
"'<!--[if lt IE 7]><html class=\"no-js lt-ie9 lt-ie8 lt-ie7 ie6\" '",
".",
"'lang=\"'",
".",
"$",
"lang",
".",
"'\" dir=\"'",
".",
"$",
"this",
"->",
"dir",
".",
"'\"> <![endif]-->'",
",",
"'<!--[if IE 7]><html class=\"no-js lt-ie9 lt-ie8 ie7\" '",
".",
"'lang=\"'",
".",
"$",
"lang",
".",
"'\" dir=\"'",
".",
"$",
"this",
"->",
"dir",
".",
"'\"> <![endif]-->'",
",",
"'<!--[if IE 8]><html class=\"no-js lt-ie9 ie8\" '",
".",
"'lang=\"'",
".",
"$",
"lang",
".",
"'\" dir=\"'",
".",
"$",
"this",
"->",
"dir",
".",
"'\"> <![endif]-->'",
",",
"'<!--[if gt IE 8]><!--><html class=\"no-js\" xmlns=\"http://www.w3.org/1999/xhtml\" '",
".",
"'lang=\"'",
".",
"$",
"lang",
".",
"'\" dir=\"'",
".",
"$",
"this",
"->",
"dir",
".",
"'\" '",
".",
"'prefix=\"og: http://ogp.me/ns#\" '",
".",
"'> <!--<![endif]-->'",
",",
"]",
";",
"return",
"implode",
"(",
"$",
"this",
"->",
"eol",
",",
"$",
"html",
")",
".",
"$",
"this",
"->",
"eol",
";",
"}"
]
| Create html 5 document type.
@return string
@throws \Exception | [
"Create",
"html",
"5",
"document",
"type",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L288-L305 |
CakeCMS/Core | src/View/Helper/DocumentHelper.php | DocumentHelper._assignMeta | protected function _assignMeta($key)
{
if (Arr::key($key, $this->_View->viewVars)) {
$this->_View->assign($key, $this->_View->viewVars[$key]);
}
return $this;
} | php | protected function _assignMeta($key)
{
if (Arr::key($key, $this->_View->viewVars)) {
$this->_View->assign($key, $this->_View->viewVars[$key]);
}
return $this;
} | [
"protected",
"function",
"_assignMeta",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"Arr",
"::",
"key",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_View",
"->",
"viewVars",
")",
")",
"{",
"$",
"this",
"->",
"_View",
"->",
"assign",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_View",
"->",
"viewVars",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Assign data from view vars.
@param string $key
@return $this | [
"Assign",
"data",
"from",
"view",
"vars",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L313-L320 |
lode/fem | src/mysql.php | mysql.connect | public static function connect($config=null) {
if (empty($config)) {
$config = self::get_config();
}
self::$connection = new \mysqli($config['host'], $config['user'], $config['pass'], $config['name'], $config['port']);
self::$connection->set_charset('utf8');
$sql_modes = [
// force correct column types
'STRICT_ALL_TABLES',
// extra's later included in strict mode
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ZERO_DATE',
'NO_ZERO_IN_DATE',
// block the usage of double quotes to quote values
// as this is unsafe in some versions of mysql
// double quotes are now allowed to quote identifiers (next to backtick)
'ANSI_QUOTES',
];
$sql_modes_string = implode(',', $sql_modes);
self::raw("SET SQL_MODE='".$sql_modes_string."';");
} | php | public static function connect($config=null) {
if (empty($config)) {
$config = self::get_config();
}
self::$connection = new \mysqli($config['host'], $config['user'], $config['pass'], $config['name'], $config['port']);
self::$connection->set_charset('utf8');
$sql_modes = [
// force correct column types
'STRICT_ALL_TABLES',
// extra's later included in strict mode
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ZERO_DATE',
'NO_ZERO_IN_DATE',
// block the usage of double quotes to quote values
// as this is unsafe in some versions of mysql
// double quotes are now allowed to quote identifiers (next to backtick)
'ANSI_QUOTES',
];
$sql_modes_string = implode(',', $sql_modes);
self::raw("SET SQL_MODE='".$sql_modes_string."';");
} | [
"public",
"static",
"function",
"connect",
"(",
"$",
"config",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"self",
"::",
"get_config",
"(",
")",
";",
"}",
"self",
"::",
"$",
"connection",
"=",
"new",
"\\",
"mysqli",
"(",
"$",
"config",
"[",
"'host'",
"]",
",",
"$",
"config",
"[",
"'user'",
"]",
",",
"$",
"config",
"[",
"'pass'",
"]",
",",
"$",
"config",
"[",
"'name'",
"]",
",",
"$",
"config",
"[",
"'port'",
"]",
")",
";",
"self",
"::",
"$",
"connection",
"->",
"set_charset",
"(",
"'utf8'",
")",
";",
"$",
"sql_modes",
"=",
"[",
"// force correct column types",
"'STRICT_ALL_TABLES'",
",",
"// extra's later included in strict mode",
"'ERROR_FOR_DIVISION_BY_ZERO'",
",",
"'NO_ZERO_DATE'",
",",
"'NO_ZERO_IN_DATE'",
",",
"// block the usage of double quotes to quote values",
"// as this is unsafe in some versions of mysql",
"// double quotes are now allowed to quote identifiers (next to backtick)",
"'ANSI_QUOTES'",
",",
"]",
";",
"$",
"sql_modes_string",
"=",
"implode",
"(",
"','",
",",
"$",
"sql_modes",
")",
";",
"self",
"::",
"raw",
"(",
"\"SET SQL_MODE='\"",
".",
"$",
"sql_modes_string",
".",
"\"';\"",
")",
";",
"}"
]
| connects to the database, defined by ::get_config()
makes sure we have a strict and unicode aware connection
@see http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string
@param array $config optional, containing 'host', 'user', 'pass', 'name', and 'port' values
@return void | [
"connects",
"to",
"the",
"database",
"defined",
"by",
"::",
"get_config",
"()",
"makes",
"sure",
"we",
"have",
"a",
"strict",
"and",
"unicode",
"aware",
"connection"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L39-L63 |
lode/fem | src/mysql.php | mysql.select | public static function select($type, $sql, $binds=null) {
if (in_array($type, self::$types) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('unknown select type');
}
$results = self::query($sql, $binds);
return self::{'as_'.$type}($results);
} | php | public static function select($type, $sql, $binds=null) {
if (in_array($type, self::$types) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('unknown select type');
}
$results = self::query($sql, $binds);
return self::{'as_'.$type}($results);
} | [
"public",
"static",
"function",
"select",
"(",
"$",
"type",
",",
"$",
"sql",
",",
"$",
"binds",
"=",
"null",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"$",
"types",
")",
"==",
"false",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'unknown select type'",
")",
";",
"}",
"$",
"results",
"=",
"self",
"::",
"query",
"(",
"$",
"sql",
",",
"$",
"binds",
")",
";",
"return",
"self",
"::",
"{",
"'as_'",
".",
"$",
"type",
"}",
"(",
"$",
"results",
")",
";",
"}"
]
| executes a SELECT statement, and returns the result as array, row, or single field
@param string $type one of the ::AS_* consts
@param string $sql the base sql statement
@param array $binds bind values for the given sql, @see ::merge()
@return array result set | [
"executes",
"a",
"SELECT",
"statement",
"and",
"returns",
"the",
"result",
"as",
"array",
"row",
"or",
"single",
"field"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L91-L99 |
lode/fem | src/mysql.php | mysql.query | public static function query($sql, $binds=null) {
if (!empty($binds)) {
$sql = self::merge($sql, $binds);
}
// secure against wild update/delete statements
if (preg_match('{^(UPDATE|DELETE)\s}', $sql) && preg_match('{\s(WHERE|LIMIT)\s}', $sql) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('unsafe UPDATE/DELETE statement, use a WHERE/LIMIT clause');
}
return self::raw($sql);
} | php | public static function query($sql, $binds=null) {
if (!empty($binds)) {
$sql = self::merge($sql, $binds);
}
// secure against wild update/delete statements
if (preg_match('{^(UPDATE|DELETE)\s}', $sql) && preg_match('{\s(WHERE|LIMIT)\s}', $sql) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('unsafe UPDATE/DELETE statement, use a WHERE/LIMIT clause');
}
return self::raw($sql);
} | [
"public",
"static",
"function",
"query",
"(",
"$",
"sql",
",",
"$",
"binds",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"binds",
")",
")",
"{",
"$",
"sql",
"=",
"self",
"::",
"merge",
"(",
"$",
"sql",
",",
"$",
"binds",
")",
";",
"}",
"// secure against wild update/delete statements",
"if",
"(",
"preg_match",
"(",
"'{^(UPDATE|DELETE)\\s}'",
",",
"$",
"sql",
")",
"&&",
"preg_match",
"(",
"'{\\s(WHERE|LIMIT)\\s}'",
",",
"$",
"sql",
")",
"==",
"false",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'unsafe UPDATE/DELETE statement, use a WHERE/LIMIT clause'",
")",
";",
"}",
"return",
"self",
"::",
"raw",
"(",
"$",
"sql",
")",
";",
"}"
]
| executes any query on the database
protects against unsafe UPDATE or DELETE statements
blocks when they don't contain a WHERE or LIMIT clause
@param string $sql the base sql statement
@param array $binds bind values for the given sql, @see ::merge()
@return mysqli_result | [
"executes",
"any",
"query",
"on",
"the",
"database"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L111-L123 |
lode/fem | src/mysql.php | mysql.raw | public static function raw($sql) {
$exception = bootstrap::get_library('exception');
$response = bootstrap::get_library('response');
if (is_null(self::$connection)) {
throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE);
}
$result = self::$connection->query($sql);
self::$error_number = self::$connection->errno;
self::$error_message = self::$connection->error;
if (self::$error_number) {
throw new $exception(self::$error_message, self::$error_number);
}
if ($result instanceof \mysqli_result) {
self::$num_rows = $result->num_rows;
}
self::$insert_id = self::$connection->insert_id;
self::$affected_rows = self::$connection->affected_rows;
return $result;
} | php | public static function raw($sql) {
$exception = bootstrap::get_library('exception');
$response = bootstrap::get_library('response');
if (is_null(self::$connection)) {
throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE);
}
$result = self::$connection->query($sql);
self::$error_number = self::$connection->errno;
self::$error_message = self::$connection->error;
if (self::$error_number) {
throw new $exception(self::$error_message, self::$error_number);
}
if ($result instanceof \mysqli_result) {
self::$num_rows = $result->num_rows;
}
self::$insert_id = self::$connection->insert_id;
self::$affected_rows = self::$connection->affected_rows;
return $result;
} | [
"public",
"static",
"function",
"raw",
"(",
"$",
"sql",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"$",
"response",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'response'",
")",
";",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"connection",
")",
")",
"{",
"throw",
"new",
"$",
"exception",
"(",
"'no db connection'",
",",
"$",
"response",
"::",
"STATUS_SERVICE_UNAVAILABLE",
")",
";",
"}",
"$",
"result",
"=",
"self",
"::",
"$",
"connection",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"self",
"::",
"$",
"error_number",
"=",
"self",
"::",
"$",
"connection",
"->",
"errno",
";",
"self",
"::",
"$",
"error_message",
"=",
"self",
"::",
"$",
"connection",
"->",
"error",
";",
"if",
"(",
"self",
"::",
"$",
"error_number",
")",
"{",
"throw",
"new",
"$",
"exception",
"(",
"self",
"::",
"$",
"error_message",
",",
"self",
"::",
"$",
"error_number",
")",
";",
"}",
"if",
"(",
"$",
"result",
"instanceof",
"\\",
"mysqli_result",
")",
"{",
"self",
"::",
"$",
"num_rows",
"=",
"$",
"result",
"->",
"num_rows",
";",
"}",
"self",
"::",
"$",
"insert_id",
"=",
"self",
"::",
"$",
"connection",
"->",
"insert_id",
";",
"self",
"::",
"$",
"affected_rows",
"=",
"self",
"::",
"$",
"connection",
"->",
"affected_rows",
";",
"return",
"$",
"result",
";",
"}"
]
| executes a query on the database
similar to ::query(), except nothing is modified or checked anymore
@param string $sql
@return mysqli_result | [
"executes",
"a",
"query",
"on",
"the",
"database",
"similar",
"to",
"::",
"query",
"()",
"except",
"nothing",
"is",
"modified",
"or",
"checked",
"anymore"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L132-L155 |
lode/fem | src/mysql.php | mysql.get_config | protected static function get_config() {
if (getenv('APP_MYSQL')) {
$config = parse_url(getenv('APP_MYSQL'));
// strip of the leading slash
$config['name'] = substr($config['path'], 1);
// cleanup
unset($config['scheme']);
unset($config['path']);
}
else {
$config_file = \alsvanzelf\fem\ROOT_DIR.'config/mysql.ini';
if (file_exists($config_file) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('no db config found');
}
$config = parse_ini_file($config_file);
// decode the password
$config['pass'] = base64_decode($config['pass']);
}
// default the port number
if (empty($config['port'])) {
$config['port'] = 3306;
}
elseif (is_int($config['port']) === false) {
$config['port'] = (int) $config['port'];
}
return $config;
} | php | protected static function get_config() {
if (getenv('APP_MYSQL')) {
$config = parse_url(getenv('APP_MYSQL'));
// strip of the leading slash
$config['name'] = substr($config['path'], 1);
// cleanup
unset($config['scheme']);
unset($config['path']);
}
else {
$config_file = \alsvanzelf\fem\ROOT_DIR.'config/mysql.ini';
if (file_exists($config_file) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('no db config found');
}
$config = parse_ini_file($config_file);
// decode the password
$config['pass'] = base64_decode($config['pass']);
}
// default the port number
if (empty($config['port'])) {
$config['port'] = 3306;
}
elseif (is_int($config['port']) === false) {
$config['port'] = (int) $config['port'];
}
return $config;
} | [
"protected",
"static",
"function",
"get_config",
"(",
")",
"{",
"if",
"(",
"getenv",
"(",
"'APP_MYSQL'",
")",
")",
"{",
"$",
"config",
"=",
"parse_url",
"(",
"getenv",
"(",
"'APP_MYSQL'",
")",
")",
";",
"// strip of the leading slash",
"$",
"config",
"[",
"'name'",
"]",
"=",
"substr",
"(",
"$",
"config",
"[",
"'path'",
"]",
",",
"1",
")",
";",
"// cleanup",
"unset",
"(",
"$",
"config",
"[",
"'scheme'",
"]",
")",
";",
"unset",
"(",
"$",
"config",
"[",
"'path'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"config_file",
"=",
"\\",
"alsvanzelf",
"\\",
"fem",
"\\",
"ROOT_DIR",
".",
"'config/mysql.ini'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"config_file",
")",
"==",
"false",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'no db config found'",
")",
";",
"}",
"$",
"config",
"=",
"parse_ini_file",
"(",
"$",
"config_file",
")",
";",
"// decode the password",
"$",
"config",
"[",
"'pass'",
"]",
"=",
"base64_decode",
"(",
"$",
"config",
"[",
"'pass'",
"]",
")",
";",
"}",
"// default the port number",
"if",
"(",
"empty",
"(",
"$",
"config",
"[",
"'port'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'port'",
"]",
"=",
"3306",
";",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"config",
"[",
"'port'",
"]",
")",
"===",
"false",
")",
"{",
"$",
"config",
"[",
"'port'",
"]",
"=",
"(",
"int",
")",
"$",
"config",
"[",
"'port'",
"]",
";",
"}",
"return",
"$",
"config",
";",
"}"
]
| collects the config for connecting from:
- an environment variable `APP_MYSQL`
- a `config/mysql.ini` file
@note in the ini file, the password is expected to be in a base64 encoded format
to help against shoulder surfing
@return array with 'host', 'user', 'pass', 'name', 'port' values | [
"collects",
"the",
"config",
"for",
"connecting",
"from",
":",
"-",
"an",
"environment",
"variable",
"APP_MYSQL",
"-",
"a",
"config",
"/",
"mysql",
".",
"ini",
"file"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L167-L200 |
lode/fem | src/mysql.php | mysql.merge | private static function merge($sql, $binds) {
if (is_array($binds) == false) {
$binds = (array)$binds;
}
if (is_null(self::$connection)) {
$exception = bootstrap::get_library('exception');
$response = bootstrap::get_library('response');
throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE);
}
foreach ($binds as &$argument) {
$argument = self::$connection->real_escape_string($argument);
}
return vsprintf($sql, $binds);
} | php | private static function merge($sql, $binds) {
if (is_array($binds) == false) {
$binds = (array)$binds;
}
if (is_null(self::$connection)) {
$exception = bootstrap::get_library('exception');
$response = bootstrap::get_library('response');
throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE);
}
foreach ($binds as &$argument) {
$argument = self::$connection->real_escape_string($argument);
}
return vsprintf($sql, $binds);
} | [
"private",
"static",
"function",
"merge",
"(",
"$",
"sql",
",",
"$",
"binds",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"binds",
")",
"==",
"false",
")",
"{",
"$",
"binds",
"=",
"(",
"array",
")",
"$",
"binds",
";",
"}",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"connection",
")",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"$",
"response",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'response'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'no db connection'",
",",
"$",
"response",
"::",
"STATUS_SERVICE_UNAVAILABLE",
")",
";",
"}",
"foreach",
"(",
"$",
"binds",
"as",
"&",
"$",
"argument",
")",
"{",
"$",
"argument",
"=",
"self",
"::",
"$",
"connection",
"->",
"real_escape_string",
"(",
"$",
"argument",
")",
";",
"}",
"return",
"vsprintf",
"(",
"$",
"sql",
",",
"$",
"binds",
")",
";",
"}"
]
| merges bind values while escaping them
$sql can contain printf conversion specifications, i.e.:
- SELECT * WHERE `foo` = '%s';
- SELECT * WHERE `foo` > %d;
@param string $sql the base sql statement
@param array $binds bind values for the given sql
@return string input sql merged with bind values | [
"merges",
"bind",
"values",
"while",
"escaping",
"them"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L213-L228 |
webforge-labs/psc-cms | lib/Psc/Graph/Graph.php | Graph.add | public function add(Vertice $u, Vertice $v = NULL) {
/* wichtig hier ist dass wir nicht nur $this->addV($u) machen sondern auch die
zurückgegebene reference für E->add() benutzen
da sonst der Parameter zu E hinzugefügt wird, der nicht zwingend identisch mit der
gespeicherten Vertice sein muss
Dies ist Convenience da wir die label als identifier benutzen
*/
$u = $this->addV($u);
if (isset($v)) {
$v = $this->addV($v);
$this->E->add($u,$v);
}
return $this;
} | php | public function add(Vertice $u, Vertice $v = NULL) {
/* wichtig hier ist dass wir nicht nur $this->addV($u) machen sondern auch die
zurückgegebene reference für E->add() benutzen
da sonst der Parameter zu E hinzugefügt wird, der nicht zwingend identisch mit der
gespeicherten Vertice sein muss
Dies ist Convenience da wir die label als identifier benutzen
*/
$u = $this->addV($u);
if (isset($v)) {
$v = $this->addV($v);
$this->E->add($u,$v);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"Vertice",
"$",
"u",
",",
"Vertice",
"$",
"v",
"=",
"NULL",
")",
"{",
"/* wichtig hier ist dass wir nicht nur $this->addV($u) machen sondern auch die\n zurückgegebene reference für E->add() benutzen\n da sonst der Parameter zu E hinzugefügt wird, der nicht zwingend identisch mit der\n gespeicherten Vertice sein muss\n Dies ist Convenience da wir die label als identifier benutzen\n */",
"$",
"u",
"=",
"$",
"this",
"->",
"addV",
"(",
"$",
"u",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"v",
")",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"addV",
"(",
"$",
"v",
")",
";",
"$",
"this",
"->",
"E",
"->",
"add",
"(",
"$",
"u",
",",
"$",
"v",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Fügt Knoten/Kanten dem Graphen hinzu
Sind $u und $v nicht im Graphen enthalten, werden sie hinzugefügt.
Sind beide Parameter übergeben wird zusätzlich eine Kante von $u nach $v hinzugefügt
@param Vertice $u
@param Vertice $v ist $v gesetzt wird eine Kante zwischen $u und $v hinzugefügt. | [
"Fügt",
"Knoten",
"/",
"Kanten",
"dem",
"Graphen",
"hinzu"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/Graph.php#L64-L79 |
webforge-labs/psc-cms | lib/Psc/Graph/Graph.php | Graph.addV | public function addV(Vertice $u) {
if (!array_key_exists($u->label,$this->V))
$this->V[$u->label] =& $u;
return $this->V[$u->label];
} | php | public function addV(Vertice $u) {
if (!array_key_exists($u->label,$this->V))
$this->V[$u->label] =& $u;
return $this->V[$u->label];
} | [
"public",
"function",
"addV",
"(",
"Vertice",
"$",
"u",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"u",
"->",
"label",
",",
"$",
"this",
"->",
"V",
")",
")",
"$",
"this",
"->",
"V",
"[",
"$",
"u",
"->",
"label",
"]",
"=",
"&",
"$",
"u",
";",
"return",
"$",
"this",
"->",
"V",
"[",
"$",
"u",
"->",
"label",
"]",
";",
"}"
]
| Fügt dem Graphen einen Knoten hinzu
@return Vertice gibt die eingefügte Vertice zurück | [
"Fügt",
"dem",
"Graphen",
"einen",
"Knoten",
"hinzu"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/Graph.php#L86-L91 |
webforge-labs/psc-cms | lib/Psc/Graph/Graph.php | Graph.remove | public function remove(Vertice $u, Vertice $v = NULL) {
if (!isset($v)) {
$this->E->erase($v); // entferne alle Kanten
$this->remove($v); // entferne den Knoten
} else {
$this->E->remove($u,$v); // entferne die Kante
}
return $this;
} | php | public function remove(Vertice $u, Vertice $v = NULL) {
if (!isset($v)) {
$this->E->erase($v); // entferne alle Kanten
$this->remove($v); // entferne den Knoten
} else {
$this->E->remove($u,$v); // entferne die Kante
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"Vertice",
"$",
"u",
",",
"Vertice",
"$",
"v",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"v",
")",
")",
"{",
"$",
"this",
"->",
"E",
"->",
"erase",
"(",
"$",
"v",
")",
";",
"// entferne alle Kanten",
"$",
"this",
"->",
"remove",
"(",
"$",
"v",
")",
";",
"// entferne den Knoten",
"}",
"else",
"{",
"$",
"this",
"->",
"E",
"->",
"remove",
"(",
"$",
"u",
",",
"$",
"v",
")",
";",
"// entferne die Kante",
"}",
"return",
"$",
"this",
";",
"}"
]
| Entfernt einen Knoten/eine Kante aus dem Graphen
@param Vertice $v ist $v gesetzt wird eine Kante zwischen $u und $v entfernt. | [
"Entfernt",
"einen",
"Knoten",
"/",
"eine",
"Kante",
"aus",
"dem",
"Graphen"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/Graph.php#L98-L106 |
webforge-labs/psc-cms | lib/Psc/Graph/Graph.php | Graph.get | public function get($input) {
if ($input instanceof Vertice && $this->has($input)) {
return $this->V[$input->label];
} elseif (array_key_exists($input, $this->V)) {
return $this->V[$input];
} else {
return NULL;
}
} | php | public function get($input) {
if ($input instanceof Vertice && $this->has($input)) {
return $this->V[$input->label];
} elseif (array_key_exists($input, $this->V)) {
return $this->V[$input];
} else {
return NULL;
}
} | [
"public",
"function",
"get",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"$",
"input",
"instanceof",
"Vertice",
"&&",
"$",
"this",
"->",
"has",
"(",
"$",
"input",
")",
")",
"{",
"return",
"$",
"this",
"->",
"V",
"[",
"$",
"input",
"->",
"label",
"]",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"input",
",",
"$",
"this",
"->",
"V",
")",
")",
"{",
"return",
"$",
"this",
"->",
"V",
"[",
"$",
"input",
"]",
";",
"}",
"else",
"{",
"return",
"NULL",
";",
"}",
"}"
]
| Gibt einen Knoten des Graphen zurück
@return Vertice | [
"Gibt",
"einen",
"Knoten",
"des",
"Graphen",
"zurück"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/Graph.php#L123-L131 |
shi-yang/yii2-masonry | Masonry.php | Masonry.registerPlugin | protected function registerPlugin()
{
$id = $this->options['id'];
//get the displayed view and register the needed assets
$view = $this->getView();
MasonryAsset::register($view);
ImagesLoadedAsset::register($view);
$js = [];
$js[] = "var mscontainer$id = $('#$id');";
$js[] = "mscontainer$id.imagesLoaded(function(){mscontainer$id.masonry()});";
$view->registerJs(implode("\n", $js),View::POS_END);
} | php | protected function registerPlugin()
{
$id = $this->options['id'];
//get the displayed view and register the needed assets
$view = $this->getView();
MasonryAsset::register($view);
ImagesLoadedAsset::register($view);
$js = [];
$js[] = "var mscontainer$id = $('#$id');";
$js[] = "mscontainer$id.imagesLoaded(function(){mscontainer$id.masonry()});";
$view->registerJs(implode("\n", $js),View::POS_END);
} | [
"protected",
"function",
"registerPlugin",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
";",
"//get the displayed view and register the needed assets",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"MasonryAsset",
"::",
"register",
"(",
"$",
"view",
")",
";",
"ImagesLoadedAsset",
"::",
"register",
"(",
"$",
"view",
")",
";",
"$",
"js",
"=",
"[",
"]",
";",
"$",
"js",
"[",
"]",
"=",
"\"var mscontainer$id = $('#$id');\"",
";",
"$",
"js",
"[",
"]",
"=",
"\"mscontainer$id.imagesLoaded(function(){mscontainer$id.masonry()});\"",
";",
"$",
"view",
"->",
"registerJs",
"(",
"implode",
"(",
"\"\\n\"",
",",
"$",
"js",
")",
",",
"View",
"::",
"POS_END",
")",
";",
"}"
]
| Registers the widget and the related events | [
"Registers",
"the",
"widget",
"and",
"the",
"related",
"events"
]
| train | https://github.com/shi-yang/yii2-masonry/blob/7f50f65325af9d7e3a24eb20b99594ed4df14b44/Masonry.php#L73-L87 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBOGeneratorBundle/Generator/DoctrineTranslationGenerator.php | DoctrineTranslationGenerator.generate | public function generate(BundleInterface $bundle, $entity, ClassMetadataInfo $metadata, $forceOverwrite)
{
$parts = explode('\\', $entity);
$entityClass = array_pop($parts);
$langs = ['fr', 'en'];
$this->className = $entityClass.'Type';
$dirPath = $bundle->getPath().'/Resources/translations';
foreach ($langs as $lang) {
$this->classPath = $dirPath.'/'.'admin.'.$lang.'.yml';
$translations = '';
$entityHeader = str_repeat(' ', 4).strtolower($entityClass).":\n";
if (file_exists($this->classPath)) {
$translations = file_get_contents($this->classPath);
if (strpos($translations, $entityHeader) !== false) {
throw new \RuntimeException(sprintf('Unable to generate the %s entity translation as it already exists under the %s file', $this->className, $this->classPath));
}
} else {
$translations = $this->render('translations/admin.'.$lang.'.yml.twig', []);
}
if (count($metadata->identifier) > 1) {
throw new \RuntimeException('The form generator does not support entity classes with multiple primary keys.');
}
// add a trailing \n if not exists
if (substr($translations, -1, 1) != "\n") {
$translations .= "\n";
}
$parts = explode('\\', $entity);
array_pop($parts);
$translations .= $entityHeader;
$translations .= str_repeat(' ', 8).'entity_name: '.str_replace('_', ' ', ucfirst(strtolower($entityClass)))."\n";
foreach ($this->getFieldsFromMetadata($metadata) as $field => $meta) {
$translations .= str_repeat(' ', 8).$field.': '.str_replace('_', ' ', ucfirst(strtolower($field)))."\n";
}
file_put_contents($this->classPath, $translations);
}
} | php | public function generate(BundleInterface $bundle, $entity, ClassMetadataInfo $metadata, $forceOverwrite)
{
$parts = explode('\\', $entity);
$entityClass = array_pop($parts);
$langs = ['fr', 'en'];
$this->className = $entityClass.'Type';
$dirPath = $bundle->getPath().'/Resources/translations';
foreach ($langs as $lang) {
$this->classPath = $dirPath.'/'.'admin.'.$lang.'.yml';
$translations = '';
$entityHeader = str_repeat(' ', 4).strtolower($entityClass).":\n";
if (file_exists($this->classPath)) {
$translations = file_get_contents($this->classPath);
if (strpos($translations, $entityHeader) !== false) {
throw new \RuntimeException(sprintf('Unable to generate the %s entity translation as it already exists under the %s file', $this->className, $this->classPath));
}
} else {
$translations = $this->render('translations/admin.'.$lang.'.yml.twig', []);
}
if (count($metadata->identifier) > 1) {
throw new \RuntimeException('The form generator does not support entity classes with multiple primary keys.');
}
// add a trailing \n if not exists
if (substr($translations, -1, 1) != "\n") {
$translations .= "\n";
}
$parts = explode('\\', $entity);
array_pop($parts);
$translations .= $entityHeader;
$translations .= str_repeat(' ', 8).'entity_name: '.str_replace('_', ' ', ucfirst(strtolower($entityClass)))."\n";
foreach ($this->getFieldsFromMetadata($metadata) as $field => $meta) {
$translations .= str_repeat(' ', 8).$field.': '.str_replace('_', ' ', ucfirst(strtolower($field)))."\n";
}
file_put_contents($this->classPath, $translations);
}
} | [
"public",
"function",
"generate",
"(",
"BundleInterface",
"$",
"bundle",
",",
"$",
"entity",
",",
"ClassMetadataInfo",
"$",
"metadata",
",",
"$",
"forceOverwrite",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"entity",
")",
";",
"$",
"entityClass",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"langs",
"=",
"[",
"'fr'",
",",
"'en'",
"]",
";",
"$",
"this",
"->",
"className",
"=",
"$",
"entityClass",
".",
"'Type'",
";",
"$",
"dirPath",
"=",
"$",
"bundle",
"->",
"getPath",
"(",
")",
".",
"'/Resources/translations'",
";",
"foreach",
"(",
"$",
"langs",
"as",
"$",
"lang",
")",
"{",
"$",
"this",
"->",
"classPath",
"=",
"$",
"dirPath",
".",
"'/'",
".",
"'admin.'",
".",
"$",
"lang",
".",
"'.yml'",
";",
"$",
"translations",
"=",
"''",
";",
"$",
"entityHeader",
"=",
"str_repeat",
"(",
"' '",
",",
"4",
")",
".",
"strtolower",
"(",
"$",
"entityClass",
")",
".",
"\":\\n\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"classPath",
")",
")",
"{",
"$",
"translations",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"classPath",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"translations",
",",
"$",
"entityHeader",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to generate the %s entity translation as it already exists under the %s file'",
",",
"$",
"this",
"->",
"className",
",",
"$",
"this",
"->",
"classPath",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"translations",
"=",
"$",
"this",
"->",
"render",
"(",
"'translations/admin.'",
".",
"$",
"lang",
".",
"'.yml.twig'",
",",
"[",
"]",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"metadata",
"->",
"identifier",
")",
">",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The form generator does not support entity classes with multiple primary keys.'",
")",
";",
"}",
"// add a trailing \\n if not exists",
"if",
"(",
"substr",
"(",
"$",
"translations",
",",
"-",
"1",
",",
"1",
")",
"!=",
"\"\\n\"",
")",
"{",
"$",
"translations",
".=",
"\"\\n\"",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"entity",
")",
";",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"translations",
".=",
"$",
"entityHeader",
";",
"$",
"translations",
".=",
"str_repeat",
"(",
"' '",
",",
"8",
")",
".",
"'entity_name: '",
".",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"entityClass",
")",
")",
")",
".",
"\"\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFieldsFromMetadata",
"(",
"$",
"metadata",
")",
"as",
"$",
"field",
"=>",
"$",
"meta",
")",
"{",
"$",
"translations",
".=",
"str_repeat",
"(",
"' '",
",",
"8",
")",
".",
"$",
"field",
".",
"': '",
".",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"field",
")",
")",
")",
".",
"\"\\n\"",
";",
"}",
"file_put_contents",
"(",
"$",
"this",
"->",
"classPath",
",",
"$",
"translations",
")",
";",
"}",
"}"
]
| Generates the entity form class if it does not exist.
@param BundleInterface $bundle The bundle in which to create the class
@param string $entity The entity relative class name
@param ClassMetadataInfo $metadata The entity metadata class | [
"Generates",
"the",
"entity",
"form",
"class",
"if",
"it",
"does",
"not",
"exist",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Generator/DoctrineTranslationGenerator.php#L54-L100 |
ClanCats/Core | src/bundles/Database/Query/Insert.php | Query_Insert.values | public function values( array $values )
{
// do nothing if we get nothing
if ( empty( $values ) )
{
return $this;
}
// check if the the passed array is a collection.
// because we want to be able to insert bulk values.
if ( !\CCArr::is_collection( $values ) )
{
$values = array( $values );
}
// because we could recive the arrays in diffrent order
// we have to sort them by their key.
foreach( $values as $key => $value )
{
ksort( $value ); $values[$key] = $value;
}
// merge the new values with the existing ones.
$this->values = array_merge( $this->values, $values );
// return self so we can continue running the next function
return $this;
} | php | public function values( array $values )
{
// do nothing if we get nothing
if ( empty( $values ) )
{
return $this;
}
// check if the the passed array is a collection.
// because we want to be able to insert bulk values.
if ( !\CCArr::is_collection( $values ) )
{
$values = array( $values );
}
// because we could recive the arrays in diffrent order
// we have to sort them by their key.
foreach( $values as $key => $value )
{
ksort( $value ); $values[$key] = $value;
}
// merge the new values with the existing ones.
$this->values = array_merge( $this->values, $values );
// return self so we can continue running the next function
return $this;
} | [
"public",
"function",
"values",
"(",
"array",
"$",
"values",
")",
"{",
"// do nothing if we get nothing",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// check if the the passed array is a collection.",
"// because we want to be able to insert bulk values.",
"if",
"(",
"!",
"\\",
"CCArr",
"::",
"is_collection",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"array",
"(",
"$",
"values",
")",
";",
"}",
"// because we could recive the arrays in diffrent order ",
"// we have to sort them by their key.",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"ksort",
"(",
"$",
"value",
")",
";",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"// merge the new values with the existing ones.",
"$",
"this",
"->",
"values",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"values",
")",
";",
"// return self so we can continue running the next function",
"return",
"$",
"this",
";",
"}"
]
| Add values to the insert
@param array $values
@return void | [
"Add",
"values",
"to",
"the",
"insert"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Query/Insert.php#L45-L72 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/MenuController.php | MenuController.index | public function index()
{
if ( \Auth::user()->roles[0]->can('menu-read' ) ) {
$items = $this->menus->with('roles')
->where('parent_id', '=', '0')
->orderBy('sort_order', 'ASC')->get();
return \View::make('acl::admin.menus.index', [
'items' => $items,
'title' => 'list',
]);
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | php | public function index()
{
if ( \Auth::user()->roles[0]->can('menu-read' ) ) {
$items = $this->menus->with('roles')
->where('parent_id', '=', '0')
->orderBy('sort_order', 'ASC')->get();
return \View::make('acl::admin.menus.index', [
'items' => $items,
'title' => 'list',
]);
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | [
"public",
"function",
"index",
"(",
")",
"{",
"if",
"(",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"roles",
"[",
"0",
"]",
"->",
"can",
"(",
"'menu-read'",
")",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"menus",
"->",
"with",
"(",
"'roles'",
")",
"->",
"where",
"(",
"'parent_id'",
",",
"'='",
",",
"'0'",
")",
"->",
"orderBy",
"(",
"'sort_order'",
",",
"'ASC'",
")",
"->",
"get",
"(",
")",
";",
"return",
"\\",
"View",
"::",
"make",
"(",
"'acl::admin.menus.index'",
",",
"[",
"'items'",
"=>",
"$",
"items",
",",
"'title'",
"=>",
"'list'",
",",
"]",
")",
";",
"}",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
")",
"->",
"withErrors",
"(",
"trans",
"(",
"'acl::dashboard.unauthorized_access'",
")",
")",
";",
"}"
]
| Display a listing of the resource.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"resource",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/MenuController.php#L31-L43 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/MenuController.php | MenuController.create | public function create()
{
if ( \Auth::user()->roles[0]->can('menu-create' ) ) {
$items = $this->menus->pluck('name', 'id')->toarray();
$roles = Role::pluck('name', 'id')->toarray();
$selected = [];
return \View::make('acl::admin.menus.create', [
'items' => $items,
'roles' => $roles,
'selected' => $selected,
'title' => 'create',
]);
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | php | public function create()
{
if ( \Auth::user()->roles[0]->can('menu-create' ) ) {
$items = $this->menus->pluck('name', 'id')->toarray();
$roles = Role::pluck('name', 'id')->toarray();
$selected = [];
return \View::make('acl::admin.menus.create', [
'items' => $items,
'roles' => $roles,
'selected' => $selected,
'title' => 'create',
]);
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | [
"public",
"function",
"create",
"(",
")",
"{",
"if",
"(",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"roles",
"[",
"0",
"]",
"->",
"can",
"(",
"'menu-create'",
")",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"menus",
"->",
"pluck",
"(",
"'name'",
",",
"'id'",
")",
"->",
"toarray",
"(",
")",
";",
"$",
"roles",
"=",
"Role",
"::",
"pluck",
"(",
"'name'",
",",
"'id'",
")",
"->",
"toarray",
"(",
")",
";",
"$",
"selected",
"=",
"[",
"]",
";",
"return",
"\\",
"View",
"::",
"make",
"(",
"'acl::admin.menus.create'",
",",
"[",
"'items'",
"=>",
"$",
"items",
",",
"'roles'",
"=>",
"$",
"roles",
",",
"'selected'",
"=>",
"$",
"selected",
",",
"'title'",
"=>",
"'create'",
",",
"]",
")",
";",
"}",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
")",
"->",
"withErrors",
"(",
"trans",
"(",
"'acl::dashboard.unauthorized_access'",
")",
")",
";",
"}"
]
| Show the form for creating a new resource.
@return \Illuminate\Http\Response | [
"Show",
"the",
"form",
"for",
"creating",
"a",
"new",
"resource",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/MenuController.php#L50-L64 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/MenuController.php | MenuController.show | public function show($id)
{
if ( \Auth::user()->roles[0]->can('menu-read' ) ) {
$menu = $this->menus->findOrFail($id);
return view('admin.menus.show', compact('menu'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | php | public function show($id)
{
if ( \Auth::user()->roles[0]->can('menu-read' ) ) {
$menu = $this->menus->findOrFail($id);
return view('admin.menus.show', compact('menu'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"roles",
"[",
"0",
"]",
"->",
"can",
"(",
"'menu-read'",
")",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"menus",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"return",
"view",
"(",
"'admin.menus.show'",
",",
"compact",
"(",
"'menu'",
")",
")",
";",
"}",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
")",
"->",
"withErrors",
"(",
"trans",
"(",
"'acl::dashboard.unauthorized_access'",
")",
")",
";",
"}"
]
| Display the specified resource.
@param int $id
@return \Illuminate\Http\Response | [
"Display",
"the",
"specified",
"resource",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/MenuController.php#L95-L102 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/MenuController.php | MenuController.edit | public function edit($id)
{
if ( \Auth::user()->roles[0]->can('menu-update' ) ) {
$menu = $this->menus->findOrFail($id);
$items = $this->menus->pluck('name', 'id')->toarray();
$roles = Role::lists('name', 'id')->toarray();
$selected = $menu->roles->pluck('id')->toarray();
return view('admin.menus.edit', compact('menu', 'selected', 'roles', 'items'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | php | public function edit($id)
{
if ( \Auth::user()->roles[0]->can('menu-update' ) ) {
$menu = $this->menus->findOrFail($id);
$items = $this->menus->pluck('name', 'id')->toarray();
$roles = Role::lists('name', 'id')->toarray();
$selected = $menu->roles->pluck('id')->toarray();
return view('admin.menus.edit', compact('menu', 'selected', 'roles', 'items'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"roles",
"[",
"0",
"]",
"->",
"can",
"(",
"'menu-update'",
")",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"menus",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"items",
"=",
"$",
"this",
"->",
"menus",
"->",
"pluck",
"(",
"'name'",
",",
"'id'",
")",
"->",
"toarray",
"(",
")",
";",
"$",
"roles",
"=",
"Role",
"::",
"lists",
"(",
"'name'",
",",
"'id'",
")",
"->",
"toarray",
"(",
")",
";",
"$",
"selected",
"=",
"$",
"menu",
"->",
"roles",
"->",
"pluck",
"(",
"'id'",
")",
"->",
"toarray",
"(",
")",
";",
"return",
"view",
"(",
"'admin.menus.edit'",
",",
"compact",
"(",
"'menu'",
",",
"'selected'",
",",
"'roles'",
",",
"'items'",
")",
")",
";",
"}",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
")",
"->",
"withErrors",
"(",
"trans",
"(",
"'acl::dashboard.unauthorized_access'",
")",
")",
";",
"}"
]
| Show the form for editing the specified resource.
@param int $id
@return \Illuminate\Http\Response | [
"Show",
"the",
"form",
"for",
"editing",
"the",
"specified",
"resource",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/MenuController.php#L110-L121 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/MenuController.php | MenuController.update | public function update(Request $request, $id)
{
if ( \Auth::user()->roles[0]->can('menu-update' ) ) {
$input = $request->all();
$input['url'] = "admin/".str_plural(Str::lower($input['name'] != 'Dashboard' ? $string=str_replace(" ","_", $input['name']) : ''));
$menu = $this->menus->findOrFail($id);
$menu->update($input);
$menu->roles()->detach();
foreach ($request->roles as $_id) {
$role = Role::whereId($_id)->first();
$menu->assign($role);
}
\Session::flash('flash_message', 'Menu updated!');
return \Redirect::route('admin.menus.index', [
])->withMessage(trans('acl::menu.menus-controller-successfully_updated'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | php | public function update(Request $request, $id)
{
if ( \Auth::user()->roles[0]->can('menu-update' ) ) {
$input = $request->all();
$input['url'] = "admin/".str_plural(Str::lower($input['name'] != 'Dashboard' ? $string=str_replace(" ","_", $input['name']) : ''));
$menu = $this->menus->findOrFail($id);
$menu->update($input);
$menu->roles()->detach();
foreach ($request->roles as $_id) {
$role = Role::whereId($_id)->first();
$menu->assign($role);
}
\Session::flash('flash_message', 'Menu updated!');
return \Redirect::route('admin.menus.index', [
])->withMessage(trans('acl::menu.menus-controller-successfully_updated'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | [
"public",
"function",
"update",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"if",
"(",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"roles",
"[",
"0",
"]",
"->",
"can",
"(",
"'menu-update'",
")",
")",
"{",
"$",
"input",
"=",
"$",
"request",
"->",
"all",
"(",
")",
";",
"$",
"input",
"[",
"'url'",
"]",
"=",
"\"admin/\"",
".",
"str_plural",
"(",
"Str",
"::",
"lower",
"(",
"$",
"input",
"[",
"'name'",
"]",
"!=",
"'Dashboard'",
"?",
"$",
"string",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"_\"",
",",
"$",
"input",
"[",
"'name'",
"]",
")",
":",
"''",
")",
")",
";",
"$",
"menu",
"=",
"$",
"this",
"->",
"menus",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"menu",
"->",
"update",
"(",
"$",
"input",
")",
";",
"$",
"menu",
"->",
"roles",
"(",
")",
"->",
"detach",
"(",
")",
";",
"foreach",
"(",
"$",
"request",
"->",
"roles",
"as",
"$",
"_id",
")",
"{",
"$",
"role",
"=",
"Role",
"::",
"whereId",
"(",
"$",
"_id",
")",
"->",
"first",
"(",
")",
";",
"$",
"menu",
"->",
"assign",
"(",
"$",
"role",
")",
";",
"}",
"\\",
"Session",
"::",
"flash",
"(",
"'flash_message'",
",",
"'Menu updated!'",
")",
";",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
",",
"[",
"]",
")",
"->",
"withMessage",
"(",
"trans",
"(",
"'acl::menu.menus-controller-successfully_updated'",
")",
")",
";",
"}",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
")",
"->",
"withErrors",
"(",
"trans",
"(",
"'acl::dashboard.unauthorized_access'",
")",
")",
";",
"}"
]
| Update the specified resource in storage.
@param \Illuminate\Http\Request $request
@param int $id
@return \Illuminate\Http\Response | [
"Update",
"the",
"specified",
"resource",
"in",
"storage",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/MenuController.php#L130-L147 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/MenuController.php | MenuController.destroy | public function destroy($id)
{
if ( \Auth::user()->roles[0]->can('menu-delete' ) ) {
$this->menus->findOrFail($id)->delete();
return \Redirect::route('admin.menus.index', [
])->withMessage(trans('acl::menu.menus-controller-successfully_deleted'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | php | public function destroy($id)
{
if ( \Auth::user()->roles[0]->can('menu-delete' ) ) {
$this->menus->findOrFail($id)->delete();
return \Redirect::route('admin.menus.index', [
])->withMessage(trans('acl::menu.menus-controller-successfully_deleted'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"roles",
"[",
"0",
"]",
"->",
"can",
"(",
"'menu-delete'",
")",
")",
"{",
"$",
"this",
"->",
"menus",
"->",
"findOrFail",
"(",
"$",
"id",
")",
"->",
"delete",
"(",
")",
";",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
",",
"[",
"]",
")",
"->",
"withMessage",
"(",
"trans",
"(",
"'acl::menu.menus-controller-successfully_deleted'",
")",
")",
";",
"}",
"return",
"\\",
"Redirect",
"::",
"route",
"(",
"'admin.menus.index'",
")",
"->",
"withErrors",
"(",
"trans",
"(",
"'acl::dashboard.unauthorized_access'",
")",
")",
";",
"}"
]
| Remove the specified resource from storage.
@param int $id
@return \Illuminate\Http\Response | [
"Remove",
"the",
"specified",
"resource",
"from",
"storage",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/MenuController.php#L155-L163 |
joomlatools/joomlatools-platform-legacy | code/error/error.php | JError.getError | public static function getError($unset = false)
{
JLog::add('JError::getError() is deprecated.', JLog::WARNING, 'deprecated');
if (!isset(self::$stack[0]))
{
return false;
}
if ($unset)
{
$error = array_shift(self::$stack);
}
else
{
$error = &self::$stack[0];
}
return $error;
} | php | public static function getError($unset = false)
{
JLog::add('JError::getError() is deprecated.', JLog::WARNING, 'deprecated');
if (!isset(self::$stack[0]))
{
return false;
}
if ($unset)
{
$error = array_shift(self::$stack);
}
else
{
$error = &self::$stack[0];
}
return $error;
} | [
"public",
"static",
"function",
"getError",
"(",
"$",
"unset",
"=",
"false",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JError::getError() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"stack",
"[",
"0",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"unset",
")",
"{",
"$",
"error",
"=",
"array_shift",
"(",
"self",
"::",
"$",
"stack",
")",
";",
"}",
"else",
"{",
"$",
"error",
"=",
"&",
"self",
"::",
"$",
"stack",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"error",
";",
"}"
]
| Method for retrieving the last exception object in the error stack
@param boolean $unset True to remove the error from the stack.
@return JException|boolean Last JException object in the error stack or boolean false if none exist
@deprecated 12.1
@since 11.1 | [
"Method",
"for",
"retrieving",
"the",
"last",
"exception",
"object",
"in",
"the",
"error",
"stack"
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L123-L142 |
joomlatools/joomlatools-platform-legacy | code/error/error.php | JError.addToStack | public static function addToStack(JException &$e)
{
JLog::add('JError::addToStack() is deprecated.', JLog::WARNING, 'deprecated');
self::$stack[] = &$e;
} | php | public static function addToStack(JException &$e)
{
JLog::add('JError::addToStack() is deprecated.', JLog::WARNING, 'deprecated');
self::$stack[] = &$e;
} | [
"public",
"static",
"function",
"addToStack",
"(",
"JException",
"&",
"$",
"e",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JError::addToStack() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"self",
"::",
"$",
"stack",
"[",
"]",
"=",
"&",
"$",
"e",
";",
"}"
]
| Method to add non-JError thrown JExceptions to the JError stack for debugging purposes
@param JException &$e Add an exception to the stack.
@return void
@since 11.1
@deprecated 12.1 | [
"Method",
"to",
"add",
"non",
"-",
"JError",
"thrown",
"JExceptions",
"to",
"the",
"JError",
"stack",
"for",
"debugging",
"purposes"
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L169-L174 |
joomlatools/joomlatools-platform-legacy | code/error/error.php | JError.raise | public static function raise($level, $code, $msg, $info = null, $backtrace = false)
{
JLog::add('JError::raise() is deprecated.', JLog::WARNING, 'deprecated');
// Build error object
$class = $code == 404 ? 'JExceptionNotFound' : 'JException';
$exception = new $class($msg, $code, $level, $info, $backtrace);
return self::throwError($exception);
} | php | public static function raise($level, $code, $msg, $info = null, $backtrace = false)
{
JLog::add('JError::raise() is deprecated.', JLog::WARNING, 'deprecated');
// Build error object
$class = $code == 404 ? 'JExceptionNotFound' : 'JException';
$exception = new $class($msg, $code, $level, $info, $backtrace);
return self::throwError($exception);
} | [
"public",
"static",
"function",
"raise",
"(",
"$",
"level",
",",
"$",
"code",
",",
"$",
"msg",
",",
"$",
"info",
"=",
"null",
",",
"$",
"backtrace",
"=",
"false",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JError::raise() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"// Build error object",
"$",
"class",
"=",
"$",
"code",
"==",
"404",
"?",
"'JExceptionNotFound'",
":",
"'JException'",
";",
"$",
"exception",
"=",
"new",
"$",
"class",
"(",
"$",
"msg",
",",
"$",
"code",
",",
"$",
"level",
",",
"$",
"info",
",",
"$",
"backtrace",
")",
";",
"return",
"self",
"::",
"throwError",
"(",
"$",
"exception",
")",
";",
"}"
]
| Create a new JException object given the passed arguments
@param integer $level The error level - use any of PHP's own error levels for
this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR,
E_USER_WARNING, E_USER_NOTICE.
@param string $code The application-internal error code for this error
@param string $msg The error message, which may also be shown the user if need be.
@param mixed $info Optional: Additional error information (usually only
developer-relevant information that the user should never see,
like a database DSN).
@param boolean $backtrace Add a stack backtrace to the exception.
@return JException
@since 11.1
@deprecated 12.1 Use PHP Exception
@see JException | [
"Create",
"a",
"new",
"JException",
"object",
"given",
"the",
"passed",
"arguments"
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L195-L204 |
joomlatools/joomlatools-platform-legacy | code/error/error.php | JError.throwError | public static function throwError(&$exception)
{
JLog::add('JError::throwError() is deprecated.', JLog::WARNING, 'deprecated');
static $thrown = false;
// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
if ($thrown)
{
self::handleEcho($exception, array());
// Inifite loop.
jexit();
}
$thrown = true;
$level = $exception->get('level');
// See what to do with this kind of error
$handler = self::getErrorHandling($level);
$function = 'handle' . ucfirst($handler['mode']);
if (is_callable(array('JError', $function)))
{
$reference = call_user_func_array(array('JError', $function), array(&$exception, (isset($handler['options'])) ? $handler['options'] : array()));
}
else
{
// This is required to prevent a very unhelpful white-screen-of-death
jexit(
'JError::raise -> Static method JError::' . $function . ' does not exist. Contact a developer to debug' .
'<br /><strong>Error was</strong> <br />' . $exception->getMessage()
);
}
// We don't need to store the error, since JException already does that for us!
// Remove loop check
$thrown = false;
return $reference;
} | php | public static function throwError(&$exception)
{
JLog::add('JError::throwError() is deprecated.', JLog::WARNING, 'deprecated');
static $thrown = false;
// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
if ($thrown)
{
self::handleEcho($exception, array());
// Inifite loop.
jexit();
}
$thrown = true;
$level = $exception->get('level');
// See what to do with this kind of error
$handler = self::getErrorHandling($level);
$function = 'handle' . ucfirst($handler['mode']);
if (is_callable(array('JError', $function)))
{
$reference = call_user_func_array(array('JError', $function), array(&$exception, (isset($handler['options'])) ? $handler['options'] : array()));
}
else
{
// This is required to prevent a very unhelpful white-screen-of-death
jexit(
'JError::raise -> Static method JError::' . $function . ' does not exist. Contact a developer to debug' .
'<br /><strong>Error was</strong> <br />' . $exception->getMessage()
);
}
// We don't need to store the error, since JException already does that for us!
// Remove loop check
$thrown = false;
return $reference;
} | [
"public",
"static",
"function",
"throwError",
"(",
"&",
"$",
"exception",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JError::throwError() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"static",
"$",
"thrown",
"=",
"false",
";",
"// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!",
"if",
"(",
"$",
"thrown",
")",
"{",
"self",
"::",
"handleEcho",
"(",
"$",
"exception",
",",
"array",
"(",
")",
")",
";",
"// Inifite loop.",
"jexit",
"(",
")",
";",
"}",
"$",
"thrown",
"=",
"true",
";",
"$",
"level",
"=",
"$",
"exception",
"->",
"get",
"(",
"'level'",
")",
";",
"// See what to do with this kind of error",
"$",
"handler",
"=",
"self",
"::",
"getErrorHandling",
"(",
"$",
"level",
")",
";",
"$",
"function",
"=",
"'handle'",
".",
"ucfirst",
"(",
"$",
"handler",
"[",
"'mode'",
"]",
")",
";",
"if",
"(",
"is_callable",
"(",
"array",
"(",
"'JError'",
",",
"$",
"function",
")",
")",
")",
"{",
"$",
"reference",
"=",
"call_user_func_array",
"(",
"array",
"(",
"'JError'",
",",
"$",
"function",
")",
",",
"array",
"(",
"&",
"$",
"exception",
",",
"(",
"isset",
"(",
"$",
"handler",
"[",
"'options'",
"]",
")",
")",
"?",
"$",
"handler",
"[",
"'options'",
"]",
":",
"array",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"// This is required to prevent a very unhelpful white-screen-of-death",
"jexit",
"(",
"'JError::raise -> Static method JError::'",
".",
"$",
"function",
".",
"' does not exist. Contact a developer to debug'",
".",
"'<br /><strong>Error was</strong> <br />'",
".",
"$",
"exception",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"// We don't need to store the error, since JException already does that for us!",
"// Remove loop check",
"$",
"thrown",
"=",
"false",
";",
"return",
"$",
"reference",
";",
"}"
]
| Throw an error
@param JException &$exception An exception to throw.
@return JException A reference to the handled JException object
@deprecated 12.1 Use PHP Exception
@see JException
@since 11.1 | [
"Throw",
"an",
"error"
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L217-L257 |
joomlatools/joomlatools-platform-legacy | code/error/error.php | JError.raiseError | public static function raiseError($code, $msg, $info = null)
{
JLog::add('JError::raiseError() is deprecated.', JLog::WARNING, 'deprecated');
return self::raise(E_ERROR, $code, $msg, $info, true);
} | php | public static function raiseError($code, $msg, $info = null)
{
JLog::add('JError::raiseError() is deprecated.', JLog::WARNING, 'deprecated');
return self::raise(E_ERROR, $code, $msg, $info, true);
} | [
"public",
"static",
"function",
"raiseError",
"(",
"$",
"code",
",",
"$",
"msg",
",",
"$",
"info",
"=",
"null",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JError::raiseError() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"return",
"self",
"::",
"raise",
"(",
"E_ERROR",
",",
"$",
"code",
",",
"$",
"msg",
",",
"$",
"info",
",",
"true",
")",
";",
"}"
]
| Wrapper method for the raise() method with predefined error level of E_ERROR and backtrace set to true.
@param string $code The application-internal error code for this error
@param string $msg The error message, which may also be shown the user if need be.
@param mixed $info Optional: Additional error information (usually only
developer-relevant information that the user should
never see, like a database DSN).
@return JException $error The thrown JException object
@deprecated 12.1 Use PHP Exception
@see JError::raise()
@since 11.1 | [
"Wrapper",
"method",
"for",
"the",
"raise",
"()",
"method",
"with",
"predefined",
"error",
"level",
"of",
"E_ERROR",
"and",
"backtrace",
"set",
"to",
"true",
"."
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L274-L279 |
joomlatools/joomlatools-platform-legacy | code/error/error.php | JError.raiseWarning | public static function raiseWarning($code, $msg, $info = null)
{
JLog::add('JError::raiseWarning() is deprecated.', JLog::WARNING, 'deprecated');
return self::raise(E_WARNING, $code, $msg, $info);
} | php | public static function raiseWarning($code, $msg, $info = null)
{
JLog::add('JError::raiseWarning() is deprecated.', JLog::WARNING, 'deprecated');
return self::raise(E_WARNING, $code, $msg, $info);
} | [
"public",
"static",
"function",
"raiseWarning",
"(",
"$",
"code",
",",
"$",
"msg",
",",
"$",
"info",
"=",
"null",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JError::raiseWarning() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"return",
"self",
"::",
"raise",
"(",
"E_WARNING",
",",
"$",
"code",
",",
"$",
"msg",
",",
"$",
"info",
")",
";",
"}"
]
| Wrapper method for the {@link raise()} method with predefined error level of E_WARNING and backtrace set to false.
@param string $code The application-internal error code for this error
@param string $msg The error message, which may also be shown the user if need be.
@param mixed $info Optional: Additional error information (usually only
developer-relevant information that
the user should never see, like a database DSN).
@return JException $error The thrown JException object
@deprecated 12.1 Use PHP Exception
@see JError::raise()
@since 11.1 | [
"Wrapper",
"method",
"for",
"the",
"{",
"@link",
"raise",
"()",
"}",
"method",
"with",
"predefined",
"error",
"level",
"of",
"E_WARNING",
"and",
"backtrace",
"set",
"to",
"false",
"."
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L296-L301 |
joomlatools/joomlatools-platform-legacy | code/error/error.php | JError.raiseNotice | public static function raiseNotice($code, $msg, $info = null)
{
JLog::add('JError::raiseNotice() is deprecated.', JLog::WARNING, 'deprecated');
return self::raise(E_NOTICE, $code, $msg, $info);
} | php | public static function raiseNotice($code, $msg, $info = null)
{
JLog::add('JError::raiseNotice() is deprecated.', JLog::WARNING, 'deprecated');
return self::raise(E_NOTICE, $code, $msg, $info);
} | [
"public",
"static",
"function",
"raiseNotice",
"(",
"$",
"code",
",",
"$",
"msg",
",",
"$",
"info",
"=",
"null",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JError::raiseNotice() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"return",
"self",
"::",
"raise",
"(",
"E_NOTICE",
",",
"$",
"code",
",",
"$",
"msg",
",",
"$",
"info",
")",
";",
"}"
]
| Wrapper method for the {@link raise()} method with predefined error level of E_NOTICE and backtrace set to false.
@param string $code The application-internal error code for this error
@param string $msg The error message, which may also be shown the user if need be.
@param mixed $info Optional: Additional error information (usually only
developer-relevant information that the user
should never see, like a database DSN).
@return JException $error The thrown JException object
@deprecated 12.1 Use PHP Exception
@see raise()
@since 11.1 | [
"Wrapper",
"method",
"for",
"the",
"{",
"@link",
"raise",
"()",
"}",
"method",
"with",
"predefined",
"error",
"level",
"of",
"E_NOTICE",
"and",
"backtrace",
"set",
"to",
"false",
"."
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L318-L323 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.