/**
  * @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;
 }
Exemple #2
0
 /**
  * @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');
 }