本文整理汇总了PHP中model::children方法的典型用法代码示例。如果您正苦于以下问题:PHP model::children方法的具体用法?PHP model::children怎么用?PHP model::children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::children方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
if (!$ret) {
header('HTTP/1.1: 404 Not Found');
exit;
}
echo json_encode($ret);
break;
case "children":
if (is_null(arg('id'))) {
header('HTTP/1.1: 400 Bad Request');
exit;
}
// Here we implemented the children method to return indexes for performance, keeping the backward compatibility
if (arg("int") === '1') {
echo json_encode(model::children(arg('id')));
} else {
echo json_encode(model_json::multi(model::children(arg('id'))));
}
break;
case "move":
if (is_null(arg('id')) || is_null(arg('target'))) {
header("HTTP/1.1: 400 Bad Request");
echo "Bad command";
exit;
}
if (!model::move(arg("id"), arg("target"))) {
header("HTTP/1.1: 409 Conflict");
echo "move Error, please change your values";
exit;
}
break;
default:
示例2: setKeys
/**
* Replace all substring occurences by another one in every keys on node and sub nodes.
* @param {Integer} $id node index
* @param {String} $old old substring value to replace
* @param {String} $new new substring value
*/
static function setKeys($id, $old, $new)
{
$keys = model::keys($id);
foreach ($keys as $key => $value) {
model::setKey($id, $key, str_replace($old, $new, $value));
}
$children = model::children($id);
for ($i = 0; $i < sizeof($children); $i++) {
model::setKeys($children[$i], $old, $new);
}
return true;
}
示例3: node
/**
* Gets a node and subnodes in array format
* @param {Integer} $id node index
* @param {Integer} $depth integer depth of recursion (0 means no limit, 1 for single node)
* @param {Integer} $flags integer of needed informations for the nodes
* @return {Array} array of nodes or empty array if no node found
*/
static function node($id, $depth = 0, $flags = 15)
{
if ($id === false) {
return false;
}
if ($id === null) {
return false;
}
if ($id === "") {
return false;
}
$contents = array();
$tags = model::tags($id);
if ($tags) {
$contents["tags"] = $tags;
}
$keys = model::keys($id);
if ($keys) {
$contents["keys"] = $keys;
}
if ($flags & 8) {
$contents["links"] = model_json::links($id);
$contents["rlinks"] = model_json::rlink($id);
}
if ($depth != 1) {
$children = model::children($id);
for ($i = 0; $i < sizeof($children); $i++) {
$contents["children"][] = model_json::node($children[$i], max($depth - 1, 0));
}
}
return model_json::node_jsontag($id, $contents);
}