コード例 #1
0
ファイル: item.php プロジェクト: notzen/e107
 /**
  * Get Category model instance
  * @return plugin_featurebox_category
  */
 public function getCategory()
 {
     if (null === $this->_category) {
         $this->_category = new plugin_featurebox_category();
         $this->_category->load($this->get('fb_category'));
     }
     return $this->_category;
 }
コード例 #2
0
ファイル: e_shortcode.php プロジェクト: armpit/e107
 /**
  * Render featurebox list
  * @param plugin_featurebox_category $category
  * @param string $ctemplate category template
  * @param array $parm
  */
 public function render($category, $ctemplate, $parm)
 {
     $tmpl = $this->getFboxTemplate($ctemplate);
     $cols = intval(vartrue($parm['cols'], 1));
     $limit = intval(varset($parm['limit'], $category->sc_featurebox_category_limit()));
     $from = (intval(vartrue($parm['from'], 1)) - 1) * $limit;
     $category->setParam('cols', $cols)->setParam('no_fill_empty', isset($parm['no_fill_empty']) ? 1 : 0)->setParam('limit', $limit)->setParam('from', $from);
     $tree = $category->getItemTree(true);
     if ($tree->isEmpty()) {
         return '';
     }
     $total = $tree->getTotal();
     $category->setParam('total', $total);
     $counter = 1;
     $col_counter = 1;
     $cols_counter = 1;
     // column counter
     $ret = '';
     foreach ($tree->getTree() as $id => $node) {
         $tmpl_item = e107::getTemplate('featurebox', 'featurebox', $node->get('fb_template'));
         if (!$tmpl_item) {
             $tmpl_item = e107::getTemplate('featurebox', 'featurebox', 'default', true, true);
         }
         // reset column counter
         if ($col_counter > $cols) {
             $col_counter = 1;
         }
         // item container (category template)
         $tmpl_item = $tmpl['item_start'] . $tmpl_item . $tmpl['item_end'];
         // add column start
         if (1 == $col_counter && vartrue($tmpl['col_start'])) {
             $tmpl_item = $tmpl['col_start'] . $tmpl_item;
         }
         // there is more
         if ($total - $counter > 0) {
             // add column end if column end reached
             if ($cols == $col_counter && vartrue($tmpl['col_end'])) {
                 $tmpl_item .= $tmpl['col_end'];
             } elseif ($cols != $col_counter && 1 != $col_counter) {
                 $tmpl_item .= $tmpl['item_separator'];
             }
         } else {
             $empty_cnt = $cols - $col_counter;
             if ($empty_cnt > 0 && !$category->getParam('no_fill_empty')) {
                 // empty items fill
                 $tmp = new plugin_featurebox_item();
                 $tmp->setCategory($category);
                 $tmp_tmpl_item = $tmpl['item_separator'] . $tmpl['item_start'] . varset($tmpl['item_empty'], '<div><!-- --></div>') . $tmpl['item_end'];
                 for ($index = 1; $index <= $empty_cnt; $index++) {
                     $tmpl_item .= $tmp->setParam('counter', $counter + $index)->setParam('cols', $cols)->setParam('col_counter', $col_counter + $index)->setParam('cols_counter', $cols_counter)->setParam('limit', $category->get('fb_category_limit'))->setParam('total', $total)->toHTML($tmp_tmpl_item);
                 }
                 unset($tmp, $tmp_tmpl_item);
             }
             // add column end
             $tmpl_item .= varset($tmpl['col_end']);
         }
         $ret .= $node->setParam('counter', $counter)->setParam('cols', $cols)->setParam('col_counter', $col_counter)->setParam('cols_counter', $cols_counter)->setParam('limit', $category->get('fb_category_limit'))->setParam('total', $total)->setCategory($category)->toHTML($tmpl_item);
         if ($cols == $col_counter) {
             $cols_counter++;
         }
         $counter++;
         $col_counter++;
     }
     return $ret;
 }