Exemplo n.º 1
0
 /**
  * @param $name
  * @param array $placeholders
  *
  * @return string
  */
 public function getChunk($name, array $placeholders = array())
 {
     $this->pdoTools->debugParserMethod('getChunk', $name, $placeholders);
     $result = $this->pdoTools->getChunk($name, $placeholders);
     $this->pdoTools->debugParserMethod('getChunk', $name, $placeholders);
     return $result;
 }
Exemplo n.º 2
0
 /**
  * @param $chunkName
  * @param array $properties
  *
  * @return string
  */
 public function getChunk($chunkName, array $properties = array())
 {
     $name = $chunkName;
     $this->debugParser('getChunk', $name, $properties);
     if (strpos($chunkName, '!') === 0) {
         $chunkName = substr($chunkName, 1);
     }
     $result = $this->pdoTools->getChunk($chunkName, $properties);
     $this->debugParser('getChunk', $name, $properties);
     return $result;
 }
Exemplo n.º 3
0
 /**
  * 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']);
 }
Exemplo n.º 4
0
 /**
  * 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'] = 0;
     }
     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']));
         $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'], '[]~ ')), $row['context_key'], '', $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']);
 }
Exemplo n.º 5
0
 /**
  * Modern pagination: 1,2,..,8,9,...,13,14
  *
  * @param int $page
  * @param int $pages
  * @param string $url
  *
  * @return string
  */
 public function buildModernPagination($page = 1, $pages = 5, $url = '')
 {
     $pageLimit = $this->pdoTools->config['pageLimit'];
     if ($pageLimit >= $pages || $pageLimit < 7) {
         return $this->buildClassicPagination($page, $pages, $url);
     } else {
         $tmp = (int) floor($pageLimit / 3);
         $left = $right = $tmp;
         $center = $pageLimit - $tmp * 2;
     }
     $pagination = array();
     // Left
     for ($i = 1; $i <= $left; $i++) {
         if ($page == $i && !empty($this->pdoTools->config['tplPageActive'])) {
             $tpl = $this->pdoTools->config['tplPageActive'];
         } elseif (!empty($this->pdoTools->config['tplPage'])) {
             $tpl = $this->pdoTools->config['tplPage'];
         }
         $pagination[$i] = !empty($tpl) ? $this->makePageLink($url, $i, $tpl) : '';
     }
     // Right
     for ($i = $pages - $right + 1; $i <= $pages; $i++) {
         if ($page == $i && !empty($this->pdoTools->config['tplPageActive'])) {
             $tpl = $this->pdoTools->config['tplPageActive'];
         } elseif (!empty($this->pdoTools->config['tplPage'])) {
             $tpl = $this->pdoTools->config['tplPage'];
         }
         $pagination[$i] = !empty($tpl) ? $this->makePageLink($url, $i, $tpl) : '';
     }
     // Center
     if ($page <= $left) {
         $i = $left + 1;
         while ($i <= $center + $left) {
             if ($i == $center + $left && !empty($this->pdoTools->config['tplPageSkip'])) {
                 $tpl = $this->pdoTools->config['tplPageSkip'];
             } else {
                 $tpl = $this->pdoTools->config['tplPage'];
             }
             $pagination[$i] = !empty($tpl) ? $this->makePageLink($url, $i, $tpl) : '';
             $i++;
         }
     } elseif ($page > $pages - $right) {
         $i = $pages - $right - $center + 1;
         while ($i <= $pages - $right) {
             if ($i == $pages - $right - $center + 1 && !empty($this->pdoTools->config['tplPageSkip'])) {
                 $tpl = $this->pdoTools->config['tplPageSkip'];
             } else {
                 $tpl = $this->pdoTools->config['tplPage'];
             }
             $pagination[$i] = !empty($tpl) ? $this->makePageLink($url, $i, $tpl) : '';
             $i++;
         }
     } else {
         if ($page - $center < $left) {
             $i = $left + 1;
             while ($i <= $center + $left) {
                 if ($page == $i && !empty($this->pdoTools->config['tplPageActive'])) {
                     $tpl = $this->pdoTools->config['tplPageActive'];
                 } elseif (!empty($this->pdoTools->config['tplPage'])) {
                     $tpl = $this->pdoTools->config['tplPage'];
                 }
                 $pagination[$i] = !empty($tpl) ? $this->makePageLink($url, $i, $tpl) : '';
                 $i++;
             }
             if (!empty($this->pdoTools->config['tplPageSkip'])) {
                 $key = $page + 1 == $left + $center ? $pages - $right + 1 : $left + $center;
                 $pagination[$key] = $this->pdoTools->getChunk($this->pdoTools->config['tplPageSkip']);
             }
         } elseif ($page + $center - 1 > $pages - $right) {
             $i = $pages - $right - $center + 1;
             while ($i <= $pages - $right) {
                 if ($page == $i && !empty($this->pdoTools->config['tplPageActive'])) {
                     $tpl = $this->pdoTools->config['tplPageActive'];
                 } elseif (!empty($this->pdoTools->config['tplPage'])) {
                     $tpl = $this->pdoTools->config['tplPage'];
                 }
                 $pagination[$i] = !empty($tpl) ? $this->makePageLink($url, $i, $tpl) : '';
                 $i++;
             }
             if (!empty($this->pdoTools->config['tplPageSkip'])) {
                 $key = $page - 1 == $pages - $right - $center + 1 ? $left : $pages - $right - $center + 1;
                 $pagination[$key] = $this->pdoTools->getChunk($this->pdoTools->config['tplPageSkip']);
             }
         } else {
             $tmp = (int) floor(($center - 1) / 2);
             $i = $page - $tmp;
             while ($i < $page - $tmp + $center) {
                 if ($page == $i && !empty($this->pdoTools->config['tplPageActive'])) {
                     $tpl = $this->pdoTools->config['tplPageActive'];
                 } elseif (!empty($this->pdoTools->config['tplPage'])) {
                     $tpl = $this->pdoTools->config['tplPage'];
                 }
                 $pagination[$i] = !empty($tpl) ? $this->makePageLink($url, $i, $tpl) : '';
                 $i++;
             }
             if (!empty($this->pdoTools->config['tplPageSkip'])) {
                 $pagination[$left] = $pagination[$pages - $right + 1] = $this->pdoTools->getChunk($this->pdoTools->config['tplPageSkip']);
             }
         }
     }
     ksort($pagination);
     return implode($pagination);
 }
Exemplo n.º 6
0
 /**
  * @param $name
  * @param array $properties
  *
  * @return mixed|string
  */
 public function getChunk($name, array $properties = array())
 {
     return $this->pdoTools ? $this->pdoTools->getChunk($name, $properties) : $this->modx->getChunk($name, $properties);
 }