Exemplo n.º 1
0
 /** Get the content tree for this kind of content */
 function getTree($xmap, $parent, &$params)
 {
     if ($xmap->isNews) {
         // This component does not provide news content. don't waste time/resources
         return false;
     }
     if (!self::loadSobi()) {
         return;
     }
     $link_query = parse_url($parent->link);
     parse_str(html_entity_decode($link_query['query']), $link_vars);
     $sid = JArrayHelper::getValue($link_vars, 'sid', 1);
     $task = JArrayHelper::getValue($link_vars, 'task', null);
     if (in_array($task, array('search', 'entry.add'))) {
         return;
     }
     $db = JFactory::getDbo();
     $db->setQuery('SELECT * FROM `#__sobipro_object` where id=' . (int) $sid);
     $object = $db->loadObject();
     if ($object->oType == 'entry') {
         return;
     } elseif ($object->oType == 'category') {
         $sectionId = self::findCategorySection($object->parent);
     } else {
         $sectionId = $sid;
     }
     self::$sectionConfig = self::getSectionConfig($sectionId);
     $include_entries = JArrayHelper::getValue($params, 'include_entries', 1);
     $include_entries = $include_entries == 1 || $include_entries == 2 && $xmap->view == 'xml' || $include_entries == 3 && $xmap->view == 'html' || $xmap->view == 'navigator';
     $params['include_entries'] = $include_entries;
     $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority);
     $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq);
     if ($priority == '-1') {
         $priority = $parent->priority;
     }
     if ($changefreq == '-1') {
         $changefreq = $parent->changefreq;
     }
     $params['cat_priority'] = $priority;
     $params['cat_changefreq'] = $changefreq;
     $priority = JArrayHelper::getValue($params, 'entry_priority', $parent->priority);
     $changefreq = JArrayHelper::getValue($params, 'entry_changefreq', $parent->changefreq);
     if ($priority == '-1') {
         $priority = $parent->priority;
     }
     if ($changefreq == '-1') {
         $changefreq = $parent->changefreq;
     }
     $params['entry_priority'] = $priority;
     $params['entry_changefreq'] = $changefreq;
     $date = JFactory::getDate();
     $params['now'] = $date->toMySql();
     if ($include_entries) {
         $ordering = JArrayHelper::getValue($params, 'entries_order', 'b.position');
         $orderdir = JArrayHelper::getValue($params, 'entries_orderdir', 'ASC');
         if (!in_array($ordering, array('b.position', 'a.counter', 'b.validSince', 'a.updatedTime'))) {
             $ordering = 'b.position';
         }
         if (!in_array($orderdir, array('ASC', 'DESC'))) {
             $orderdir = 'ASC';
         }
         $params['ordering'] = $ordering . ' ' . $orderdir;
         $params['limit'] = '';
         $params['days'] = '';
         $limit = JArrayHelper::getValue($params, 'max_entries', '');
         if (intval($limit)) {
             $params['limit'] = ' LIMIT ' . $limit;
         }
         $days = JArrayHelper::getValue($params, 'max_age', '');
         if (intval($days)) {
             $params['days'] = ' AND a.publish_up >=\'' . strftime("%Y-%m-%d %H:%M:%S", $xmap->now - $days * 86400) . "' ";
         }
     }
     xmap_com_sobipro::getCategoryTree($xmap, $parent, $sid, $params);
 }