本文整理汇总了PHP中modX::getChildIds方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::getChildIds方法的具体用法?PHP modX::getChildIds怎么用?PHP modX::getChildIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::getChildIds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templateBranch
/**
* Recursive template of branch of menu
*
* @param array $row
*
* @return mixed|string
*/
public function templateBranch($row = array())
{
$children = '';
$row['level'] = $this->level;
if (!empty($row['children']) && ($this->isHere($row['id']) || empty($this->pdoTools->config['hideSubMenus'])) && $this->checkResource($row['id'])) {
$idx = 1;
$this->level++;
$count = count($row['children']);
foreach ($row['children'] as $v) {
$v['idx'] = $idx++;
$v['last'] = (int) $v['idx'] == $count;
$children .= $this->templateBranch($v);
}
$this->level--;
$row['children'] = $count;
} else {
$row['children'] = isset($row['children']) ? count($row['children']) : 0;
}
if (!empty($this->pdoTools->config['countChildren'])) {
if ($ids = $this->modx->getChildIds($row['id'])) {
$tstart = microtime(true);
$count = $this->modx->getCount('modResource', array('id:IN' => $ids, 'published' => true, 'deleted' => false));
$this->modx->queryTime += microtime(true) - $tstart;
$this->modx->executedQueries++;
$this->pdoTools->addTime('Got the number of active children for resource "' . $row['id'] . '": ' . $count);
} else {
$count = 0;
}
$row['children'] = $count;
}
if (!empty($children)) {
$pls = $this->addWayFinderPlaceholders(array('wrapper' => $children, 'classes' => ' class="' . $this->pdoTools->config['innerClass'] . '"', 'classNames' => $this->pdoTools->config['innerClass'], 'classnames' => $this->pdoTools->config['innerClass'], 'level' => $this->level));
$row['wrapper'] = $this->pdoTools->parseChunk($this->pdoTools->config['tplInner'], $pls);
} else {
$row['wrapper'] = '';
}
if (empty($row['menutitle']) && !empty($row['pagetitle'])) {
$row['menutitle'] = $row['pagetitle'];
}
$classes = $this->getClasses($row);
if (!empty($classes)) {
$row['classNames'] = $row['classnames'] = $classes;
$row['classes'] = ' class="' . $classes . '"';
} else {
$row['classNames'] = $row['classnames'] = $row['classes'] = '';
}
if (!empty($this->pdoTools->config['useWeblinkUrl']) && $row['class_key'] == 'modWebLink') {
$row['link'] = is_numeric(trim($row['content'], '[]~ ')) ? $this->modx->makeUrl(intval(trim($row['content'], '[]~ ')), '', '', $this->pdoTools->config['scheme']) : $row['content'];
} else {
$row['link'] = $this->modx->makeUrl($row['id'], $row['context_key'], '', $this->pdoTools->config['scheme']);
}
$row['title'] = !empty($this->pdoTools->config['titleOfLinks']) ? $row[$this->pdoTools->config['titleOfLinks']] : '';
$tpl = $this->getTpl($row);
$row = $this->addWayFinderPlaceholders($row);
return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']);
}
示例2: getQuery
public function getQuery($currentParent)
{
/* build query */
$c = $this->modx->newQuery('modResource');
$c->leftJoin('modResource', 'Children');
$c->select($this->modx->getSelectColumns('modResource', 'modResource'));
$c->select(array('COUNT(Children.id) AS children'));
$c->where(array('parent' => $currentParent));
/* if restricting to contexts */
if (!empty($this->config['context'])) {
$ctxs = $this->prepareForIn($this->config['context']);
$c->where(array('modResource.context_key:IN' => $ctxs));
} else {
$c->where(array('modResource.context_key' => $this->modx->context->get('key')));
}
/* if excluding resources */
if (!empty($this->config['excludeResources'])) {
$ex = $this->prepareForIn($this->config['excludeResources']);
$c->where(array('modResource.id:NOT IN' => $ex));
}
/* if excluding all children of certain resources */
if (!empty($this->config['excludeChildrenOf'])) {
$excludingParents = is_array($this->config['excludeChildrenOf']) ? $this->config['excludeChildrenOf'] : explode(',', $this->config['excludeChildrenOf']);
$excludedChildren = array();
foreach ($excludingParents as $excludingParent) {
$childrenIds = $this->modx->getChildIds($excludingParent, 10);
$excludedChildren = array_merge($excludedChildren, $childrenIds);
}
$excludedChildren = array_unique($excludedChildren);
$c->where(array('modResource.id:NOT IN' => $excludedChildren));
}
/* if restricting to templates */
if (!empty($this->config['allowedtemplates'])) {
$tpls = $this->prepareForIn($this->config['allowedtemplates']);
$c->innerJoin('modTemplate', 'Template');
$c->where(array('Template.' . $this->config['templateFilter'] . ':IN' => $tpls));
}
/* where filtering */
if (!empty($this->config['where'])) {
$where = is_array($this->config['where']) ? $this->config['where'] : $this->modx->fromJSON($this->config['where']);
$c->where($where);
}
/* sorting/grouping */
$c->sortby($this->config['sortBy'], $this->config['sortDir']);
$c->groupby('modResource.id');
return $c;
}
示例3: __construct
public function __construct(modX &$modx, $scriptProperties = array())
{
$this->modx =& $modx;
$modx->addPackage('msrevaluation', MODX_BASE_PATH . 'core/components/msrevaluation/model/');
$this->config = $scriptProperties;
$this->config['assets_path'] = $modx->getOption('assets_path') . 'components/msrevaluation/';
$this->config['core_path'] = $modx->getOption('core_path') . 'components/msrevaluation/';
$this->config['assets_url'] = $modx->getOption('assets_url') . 'components/msrevaluation/';
$this->config['core_url'] = $modx->getOption('base_url') . 'core/components/msrevaluation/';
$this->config['connectorUrl'] = $this->config['assets_url'] . 'connector.php';
$protectedResources = array_merge(explode(',', $modx->getOption('protected_parents')), explode(',', $modx->getOption('protect_from_revaluation')));
$this->config['protected'] = array();
foreach ($protectedResources as $parent) {
if (!($parent = (int) trim($parent))) {
continue;
}
$childs = $modx->getChildIds($parent, 5, array('context' => 'web'));
$this->config['protected'] = array_merge($this->config['protected'], $childs, array($parent));
}
return true;
}
示例4: getChildIds
/**
* @param null $id
* @param int $depth
* @param array $options
*
* @return array
*/
public function getChildIds($id = null, $depth = 10, array $options = array())
{
return $this->modx->getChildIds($id, $depth, $options);
}