本文整理汇总了PHP中getChildren函数的典型用法代码示例。如果您正苦于以下问题:PHP getChildren函数的具体用法?PHP getChildren怎么用?PHP getChildren使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getChildren函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChildren
function getChildren(&$modx, $parent, $deltime = 0)
{
if (empty($deltime)) {
$deltime = time();
}
$success = false;
$kids = $modx->getCollection('modResource', array('parent' => $parent, 'deleted' => true));
if (count($kids) > 0) {
/* the resource has children resources, we'll need to undelete those too */
foreach ($kids as $kid) {
$locked = $kid->addLock();
if ($locked !== true) {
$user = $modx->getObject('modUser', $locked);
if ($user) {
$modx->error->failure($modx->lexicon('resource_locked_by', array('id' => $kid->get('id'), 'user' => $user->get('username'))));
}
}
$kid->set('deleted', 0);
$kid->set('deletedby', 0);
$kid->set('deletedon', 0);
$success = $kid->save();
if ($success) {
$success = getChildren($modx, $kid->get('id'), $deltime);
}
}
}
return $success;
}
示例2: menuData
public function menuData()
{
//authcheck($url);
/* 列出所有节点 */
$ids = isset($_POST['id']) ? $this->_post('id') : $this->_get('id');
$id = isset($_POST['id']) || isset($_GET['id']) ? intval($ids) : 0;
$map['pid'] = array('eq', $id);
$map['tree'] = array('eq', 1);
$db = M('auth_rule');
/* 如果是超级用户,所有列表 */
if (session('id') == C('SUPER_ADMIN')) {
$result = $db->field('iconCls,id,level,name,action,pid,sort,tree,title text,whetherclick')->where($map)->order('sort asc')->select();
} else {
//否则通过权限查看
$accessList = getAccessNodeList(session('id'));
$map['id'] = array('in', $accessList);
$result = $db->field('iconCls,id,level,name,action,pid,sort,tree,title text,whetherclick')->where($map)->order('sort asc')->select();
//dump($result);die;
}
for ($i = 0; $i < count($result); $i++) {
/* 加入result[i][attributes][url] 节点 */
$result[$i]['attributes']['name'] = $result[$i]['name'];
$result[$i]['attributes']['whetherclick'] = $result[$i]['whetherclick'];
/* 加入state节点 */
if (getChildren($db, $result[$i]['id'])) {
$result[$i]['state'] = 'closed';
} else {
$result[$i]['state'] = 'open';
}
}
$this->ajaxReturn($result);
}
示例3: getChildren
function getChildren($parent)
{
global $dbase;
global $table_prefix;
global $children;
global $site_start;
global $site_unavailable_page;
$db->debug = true;
$sql = "SELECT id FROM {$dbase}.`" . $table_prefix . "site_content` WHERE {$dbase}.`" . $table_prefix . "site_content`.parent=" . $parent . " AND deleted=0;";
$rs = mysql_query($sql);
$limit = mysql_num_rows($rs);
if ($limit > 0) {
// the document has children documents, we'll need to delete those too
for ($i = 0; $i < $limit; $i++) {
$row = mysql_fetch_assoc($rs);
if ($row['id'] == $site_start) {
echo "The document you are trying to delete is a folder containing document " . $row['id'] . ". This document is registered as the 'Site start' document, and cannot be deleted. Please assign another document as your 'Site start' document and try again.";
exit;
}
if ($row['id'] == $site_unavailable_page) {
echo "The document you are trying to delete is a folder containing document " . $row['id'] . ". This document is registered as the 'Site unavailable page' document, and cannot be deleted. Please assign another document as your 'Site unavailable page' document and try again.";
exit;
}
$children[] = $row['id'];
getChildren($row['id']);
//echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
}
}
}
示例4: getChildren
function getChildren($parent)
{
global $modx;
global $children;
global $site_start;
global $site_unavailable_page;
global $error_page;
global $unauthorized_page;
$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent={$parent} AND deleted=0");
// the document has children documents, we'll need to delete those too
while ($childid = $modx->db->getValue($rs)) {
if ($childid == $site_start) {
$modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site start' document, and cannot be deleted. Please assign another document as your 'Site start' document and try again.");
}
if ($childid == $site_unavailable_page) {
$modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unavailable page' document, and cannot be deleted. Please assign another document as your 'Site unavailable page' document and try again.");
}
if ($childid == $error_page) {
$modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site error page' document, and cannot be deleted. Please assign another document as your 'Site error page' document and try again.");
}
if ($childid == $unauthorized_page) {
$modx->webAlertAndQuit("The document you are trying to delete is a folder containing document {$childid}. This document is registered as the 'Site unauthorized page' document, and cannot be deleted. Please assign another document as your 'Site unauthorized page' document and try again.");
}
$children[] = $childid;
getChildren($childid);
//echo "Found childNode of parentNode $parent: ".$childid."<br />";
}
}
示例5: getChildren
function getChildren($rowAll, $visualAssessmentTermIDParent, $level = 0, $studentResults = null)
{
$childrenCount = 0;
$json = '';
$jsonInt = '';
$json = $json = ',"children": [';
foreach ($rowAll as $row) {
if ($row['visualAssessmentTermIDParent'] == $visualAssessmentTermIDParent) {
++$childrenCount;
$title = addslashes($row['term']);
if ($row['description'] != '') {
$title = addslashes($row['term']) . ' - ' . addslashes($row['description']);
}
$jsonInt .= '{"name": "' . $row['term'] . '", "class": "' . $row['visualAssessmentTermID'] . '", "level": "' . $level . '", "title": "' . $title . '"';
if ($studentResults != null) {
foreach ($studentResults as $studentResult) {
if ($studentResult['visualAssessmentTermID'] == $row['visualAssessmentTermID']) {
$jsonInt .= ', "attainment": "' . 'attainment' . $studentResult['attainment'] . '"';
exit;
}
}
}
$jsonInt .= getChildren($rowAll, $row['visualAssessmentTermID'], $level + 1, $studentResults);
$jsonInt .= '},';
}
}
if ($jsonInt != '') {
$jsonInt = substr($jsonInt, 0, -1);
}
$json .= $jsonInt;
$json .= ']';
return $json;
}
示例6: generateSubmenu
function generateSubmenu($pageId, $parentPath)
{
$ret = '<div class="cms-breadcrumbsubmenu"><ul>';
global $userId;
$children = getChildren($pageId, $userId);
foreach ($children as $child) {
$ret .= "<li><span><a href='{$parentPath}{$child[1]}'>{$child[2]}</a></span></li><br>";
}
$ret .= '</ul></div>';
return $ret;
}
示例7: getNumberOfTrees
function getNumberOfTrees($tree)
{
$result = 0;
foreach ($tree as $value) {
if (getChildren($value) % 2 == 0) {
$result++;
}
$result = $result + getNumberOfTrees($value);
}
return $result;
}
示例8: getXmlTree
function getXmlTree($file)
{
$data = implode("", file($file));
$xml = xml_parser_create();
xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($xml, $data, $vals, $index);
xml_parser_free($xml);
$tree = array();
$i = 0;
array_push($tree, array('tag' => $vals[$i]['tag'], 'attributes' => $vals[$i]['attributes'], 'children' => getChildren($vals, $i)));
return $tree;
}
示例9: getChildren
function getChildren($children)
{
if (!$children) {
return '';
}
$childrenVal = '<ul class="list-unstyled">';
foreach ($children as $child) {
$childrenVal .= '<li><strong>' . $child->description . '</strong> (<a href="' . \yii\helpers\Url::to(['view', 'id' => $child->name]) . '">' . $child->name . '</a>)</li>';
$childrenVal .= getChildren($child->getChildren()->orderBy(['type' => SORT_ASC, 'name' => SORT_ASC])->all());
}
return $childrenVal . '</ul><br />';
}
示例10: getChildren
function getChildren($groupid)
{
global $metricid;
$haschildren = false;
$sql = "SELECT description,id,parent_id,1 as type,'' as full_name,'' as country FROM entity_groups where id=" . $groupid;
$result = mysql_query($sql);
$e = mysql_fetch_assoc($result);
$output[] = $e;
$sql = "SELECT description,id,parent_id,1 as type,'' as full_name,'' as country FROM entity_groups where parent_id=" . $groupid;
$sql .= " order by description ";
$result = mysql_query($sql);
while ($e = mysql_fetch_assoc($result)) {
$tmp = getChildren($e['id']);
if (!empty($tmp)) {
foreach ($tmp as $item) {
$output[] = $item;
$haschildren = true;
}
}
}
$sql = "select ticker as description,entities.id,entity_group_id as parent_id,2 as type,full_name,countries.name as country ";
$sql .= "from entities ";
$sql .= "JOIN entities_entity_groups on entities.id=entities_entity_groups.entity_id ";
//$sql.= "LEFT join countries on countries.id=entities.country_id ";
$sql .= " LEFT join countries_entities on countries_entities.entity_id=entities.id ";
$sql .= " LEFT join countries on countries_entities.country_id=countries.id ";
if (!empty($metricid)) {
$sql .= "JOIN entities_metrics on entities_metrics.entity_id = entities.id ";
}
$sql .= " where entities_entity_groups.entity_group_id=" . $groupid;
if (!empty($metricid)) {
$sql .= " and entities_metrics.metric_id =" . $metricid;
}
//OFP 2/12/2012 - Had to add the following for USDXCD which was an example of an entity associated
//with multiple countries and would result in invalid duplicate entires being returned in this query.
$sql .= " and (countries_entities.default_country=1 OR countries_entities.default_country is null)";
$sql .= " order by description ";
//echo $sql;
$result = mysql_query($sql);
if ($result != null) {
while ($e = mysql_fetch_assoc($result)) {
$output[] = $e;
$haschildren = true;
}
}
if ($haschildren == false) {
//if this node has no children, remove it.
array_pop($output);
}
return $output;
//echo "<BR> schedule id: ".$q."<BR>";
//echo "<table border='1'>";
}
示例11: getChildren
function getChildren($parent)
{
global $modx;
global $children;
global $deltime;
$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='{$parent}' AND deleted=1 AND deletedon='{$deltime}'");
// the document has children documents, we'll need to delete those too
while ($row = $modx->db->getRow($rs)) {
$children[] = $row['id'];
getChildren($row['id']);
//echo "Found childNode of parentNode $parent: ".$row['id']."<br />";
}
}
示例12: getChildren
function getChildren($itemMenu)
{
$tmp = "";
$filhos = $itemMenu->getChildren();
if (!empty($filhos)) {
$tmp = "<ul>";
foreach ($filhos as $value) {
$tmp .= "<li style='display:block !important'>" . $value->get('title') . "</li>";
$tmp .= getChildren($value);
}
$tmp .= "</ul>";
}
return $tmp;
}
示例13: getChildren
function getChildren($parent)
{
global $children;
global $deltime, $modx;
//$db->debug = true;
$rs = $modx->db->select('id', '[+prefix+]site_content', "parent={$parent} AND deleted=1 AND deletedon='{$deltime}'");
if ($modx->db->getRecordCount($rs) > 0) {
// the document has children documents, we'll need to delete those too
while ($row = $modx->db->getRow($rs)) {
$children[] = $row['id'];
getChildren($row['id']);
}
}
}
示例14: __getChildrenCount
/**
* Retrives active categories count
* @param Varien_Object| $object
* @return integer
*/
public function __getChildrenCount($object)
{
if (Mage::getStoreConfig('catalog/frontend/flat_catalog_category')) {
if (!$object->getChildrenCount()) {
$count = 0;
if ($object->getChildrenNodes()) {
foreach ($object->getChildrenNodes() as $child) {
if ($child->getIsActive()) {
$count++;
}
}
return $count;
}
if ($object->getChildren()) {
foreach ($object->getChildren() as $child) {
if ($child->getIsActive()) {
$count++;
}
}
return $count;
}
}
return $object->getChildrenCount();
} else {
if ($object->getChildrenCount()) {
$count = 0;
foreach ($object->getChildren() as $child) {
if ($child->getIsActive()) {
$count++;
}
}
return $count;
}
}
return 0;
}
示例15: getCategories
function getCategories($d)
{
global $baseurl, $f, $p, $local, $cats;
$topcat = $d->find('#e1 > li');
foreach ($topcat as $top) {
//echo $top->innertext . "\n";
$catname = $top->find('a > div', 0)->innertext;
$caturl = $top->find('a', 0)->href;
$catpath = "|";
$cats[] = array($catname, $catpath, $caturl);
// echo "Saved category /" . $catname . "\n";
getProducts($caturl, $catpath . $catname);
getChildren($caturl, $catpath . $catname);
}
}