Ejemplo n.º 1
0
 public static function buildMenu(array $data = array(), DocumentParser $modx, $_DL, prepare_DL_Extender $_eDL)
 {
     $params = $_DL->getCFGDef('params', array());
     if ($_DL->getCfgDef('currentDepth', 1) < $_DL->getCFGDef('maxDepth', 5)) {
         $params['currentDepth'] = $_DL->getCfgDef('currentDepth', 1) + 1;
         $params['parents'] = $data['id'];
         $params['idType'] = 'parents';
         $params['documents'] = '';
         $data['dl.submenu'] = $modx->runSnippet('DLBuildMenu', $params);
     } else {
         $data['dl.submenu'] = '';
     }
     $data['dl.currentDepth'] = $_DL->getCfgDef('currentDepth', 1);
     if (($parentIDs = $_eDL->getStore('parentIDs')) === null) {
         $parentIDs = array_values($modx->getParentIds($modx->documentObject['id']));
         $_eDL->setStore('parentIDs', $parentIDs);
     }
     $isActive = is_array($parentIDs) && in_array($data['id'], $parentIDs) || $data['id'] == $modx->documentObject['id'];
     $activeClass = $_DL->getCfgDef('activeClass', 'active');
     if ($isActive) {
         $data['dl.class'] .= ' ' . $activeClass;
     }
     if (strpos($data['dl.class'], 'current') !== false && strpos($data['dl.class'], ' ' . $activeClass) === false) {
         $data['dl.class'] = str_replace('current', 'current ' . $activeClass, $data['dl.class']);
     }
     $tpl = empty($data['dl.submenu']) ? 'noChildrenRowTPL' : 'mainRowTpl';
     $_DL->renderTPL = $_DL->getCfgDef($tpl);
     if (strpos($data['dl.class'], 'current') !== false) {
         $_DL->renderTPL = $_DL->getCfgDef('TplCurrent', $_DL->renderTPL);
         $_DL->renderTPL = $_DL->getCfgDef('TplCurrent' . $data['dl.currentDepth'], $_DL->renderTPL);
         if (empty($data['dl.submenu'])) {
             $_DL->renderTPL = $_DL->getCfgDef('TplCurrentNoChildren' . $data['dl.currentDepth'], $_DL->renderTPL);
         }
     }
     return $data;
 }