本文整理汇总了PHP中modX::getParentIds方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::getParentIds方法的具体用法?PHP modX::getParentIds怎么用?PHP modX::getParentIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::getParentIds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param modX $modx
* @param array $config
*/
public function __construct(modX &$modx, $config = array())
{
$this->modx =& $modx;
$config = array_merge(array('firstClass' => 'first', 'lastClass' => 'last', 'hereClass' => 'active', 'parentClass' => '', 'rowClass' => '', 'outerClass' => '', 'innerClass' => '', 'levelClass' => '', 'selfClass' => '', 'webLinkClass' => '', 'limit' => 0, 'hereId' => 0), $config, array('return' => 'data'));
if (empty($config['tplInner']) && !empty($config['tplOuter'])) {
$config['tplInner'] = $config['tplOuter'];
}
if (empty($config['hereId']) && !empty($modx->resource)) {
$config['hereId'] = $modx->resource->id;
}
$fqn = $modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
if ($pdoClass = $modx->loadClass($fqn, '', false, true)) {
$this->pdoTools = new $pdoClass($modx, $config);
} elseif ($pdoClass = $modx->loadClass($fqn, MODX_CORE_PATH . 'components/pdotools/model/', false, true)) {
$this->pdoTools = new $pdoClass($modx, $config);
} else {
$this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not load pdoFetch from "MODX_CORE_PATH/components/pdotools/model/".');
return false;
}
if ($config['hereId'] && ($currentResource = $this->pdoTools->getObject('modResource', $config['hereId']))) {
$tmp = $modx->getParentIds($currentResource['id'], 100, array('context' => $currentResource['context_key']));
$tmp[] = $config['hereId'];
$this->parentTree = array_flip($tmp);
}
$modx->lexicon->load('pdotools:pdomenu');
return true;
}
示例2: getProfitResourceGroups
/** @inheritdoc} */
public function getProfitResourceGroups($id = 0)
{
$groups = array();
$key = $this->MlmSystem->namespace;
$options = array('cache_key' => $key . '/profit/group/' . __CLASS__ . '/resource/' . $id, 'cacheTime' => 0);
if ($resource = $this->modx->getObject('modResource', array('id' => $id)) and !($groups = $this->MlmSystem->getCache($options))) {
$ids = $this->modx->getParentIds($id, 10, array('context' => $resource->get('context_key')));
$ids[] = $id;
$ids = array_unique($ids);
$q = $this->modx->newQuery('modResourceGroupResource', array('document:IN' => $ids));
$q->leftJoin('MlmSystemProfitGroup', 'MlmSystemProfitGroup', 'MlmSystemProfitGroup.group = modResourceGroupResource.document_group');
$q->where(array('MlmSystemProfitGroup.class' => 'modResourceGroup'));
$q->select('document_group,profit');
$q->sortby('profit');
$q->groupby('MlmSystemProfitGroup.group');
$tstart = microtime(true);
if ($q->prepare() && $q->stmt->execute()) {
$this->modx->queryTime += microtime(true) - $tstart;
$this->modx->executedQueries++;
while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
$groups[$row['document_group']] = $row['profit'];
}
}
$this->MlmSystem->setCache($groups, $options);
}
return $groups;
}
示例3: __construct
/**
* @param modX $modx
* @param array $config
*/
public function __construct(modX &$modx, $config = array())
{
$this->modx =& $modx;
$config = array_merge(array('firstClass' => 'first', 'lastClass' => 'last', 'hereClass' => 'active', 'parentClass' => '', 'rowClass' => '', 'outerClass' => '', 'innerClass' => '', 'levelClass' => '', 'selfClass' => '', 'webLinkClass' => '', 'limit' => 0, 'hereId' => 0), $config, array('return' => 'data'));
if (empty($config['tplInner']) && !empty($config['tplOuter'])) {
$config['tplInner'] = $config['tplOuter'];
}
if (empty($config['hereId']) && !empty($modx->resource)) {
$config['hereId'] = $modx->resource->id;
}
$fqn = $modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
$path = $modx->getOption('pdofetch_class_path', null, MODX_CORE_PATH . 'components/pdotools/model/', true);
if ($pdoClass = $modx->loadClass($fqn, $path, false, true)) {
$this->pdoTools = new $pdoClass($modx, $config);
} else {
return;
}
if ($config['hereId']) {
$here = $this->pdoTools->getObject('modResource', $config['hereId'], array('select' => 'id, context_key'));
if ($here) {
$tmp = $modx->getParentIds($here['id'], 100, array('context' => $here['context_key']));
$tmp[] = $config['hereId'];
$this->parentTree = array_flip($tmp);
}
}
$modx->lexicon->load('pdotools:pdomenu');
}
示例4: getUltimateParent
/**
* @param int $resource
* @param string $context
* @return mixed
*/
public function getUltimateParent($resource = 0, $context = '')
{
$parents = $this->modx->getParentIds($resource, 10, array('context' => $context));
$parents = array_reverse($parents);
return isset($parents[1]) ? $parents[1] : 0;
}
示例5: getParentIds
/**
* @param null $id
* @param int $height
* @param array $options
*
* @return array
*/
public function getParentIds($id = null, $height = 10, array $options = array())
{
return $this->modx->getParentIds($id, $height, $options);
}
示例6: getBreadCrumbs
/**
* @param $config
*/
public function getBreadCrumbs($config)
{
$mode = $this->modx->getOption('mode', $config);
$resource = $this->modx->getOption('resource', $config);
if ($mode === modSystemEvent::MODE_NEW || !$resource) {
if (!isset($_GET['parent'])) {
return;
}
$resource = $this->modx->getObject('modResource', $_GET['parent']);
if (!$resource) {
return;
}
}
$context = $resource->get('context_key');
if ($context != 'web') {
$this->modx->reloadContext($context);
}
/** @TODO Prepare as System Setting */
$limit = 3;
$resources = $this->modx->getParentIds($resource->get('id'), $limit, array('context' => $context));
if ($mode === modSystemEvent::MODE_NEW) {
array_unshift($resources, $_GET['parent']);
}
$crumbs = array();
$root = $this->modx->toJSON(array('text' => $context, 'className' => 'first', 'root' => true, 'url' => '?'));
$controllerConfig = $this->modx->controller->config;
$action = $controllerConfig['controller'];
if ($action == 'resource/create') {
$action = 'resource/update';
}
if (isset($controllerConfig['id'])) {
if ($controllerConfig['controller'] == 'resource/create') {
$actionObj = $this->modx->getObject('modAction', array('controller' => 'resource/update'));
$action = $actionObj->get('id');
} else {
$action = $controllerConfig['id'];
}
}
$isAll = false;
for ($i = count($resources) - 1; $i >= 0; $i--) {
$resId = $resources[$i];
if ($resId == 0) {
continue;
}
$parent = $this->modx->getObject('modResource', $resId);
if (!$parent) {
break;
}
if ($parent->get('parent') == 0) {
$isAll = true;
}
$crumbs[] = array('text' => $parent->get('pagetitle'), 'url' => '?a=' . $action . '&id=' . $parent->get('id'));
}
if (count($resources) == $limit && !$isAll) {
array_unshift($crumbs, array('text' => '...'));
}
// Add pagetitle of current page
if ($mode === modSystemEvent::MODE_NEW) {
$pagetitle = $this->modx->lexicon('new_document');
} else {
$pagetitle = $resource->get('pagetitle');
}
$crumbs[] = array('text' => $pagetitle);
$crumbs = $this->modx->toJSON($crumbs);
$this->modx->controller->addJavascript($this->config['jsUrl'] . 'mgr/moddevtools.js');
$this->modx->controller->addJavascript($this->config['jsUrl'] . 'mgr/widgets/breadcrumbs.panel.js');
$this->modx->controller->addHtml("<script>\n Ext.onReady(function() {\n var header = Ext.getCmp('modx-resource-header').ownerCt;\n header.insert(1, {\n xtype: 'moddevtools-breadcrumbs-panel'\n ,id: 'resource-breadcrumbs'\n ,desc: ''\n ,root : {$root}\n });\n header.doLayout();\n\n var crumbCmp = Ext.getCmp('resource-breadcrumbs');\n var bd = { trail : {$crumbs}};\n\t\t crumbCmp.updateDetail(bd);\n\n\t\t Ext.getCmp('modx-resource-pagetitle').on('keyup', function(){\n bd.trail[bd.trail.length-1] = {text: crumbCmp.getPagetitle()};\n crumbCmp._updatePanel(bd);\n });\n });\n </script>");
}