Ejemplo n.º 1
0
 /**
  * Method to get cities item data
  *
  * @access public
  * @return array
  */
 function getData()
 {
     // Lets load the types if it doesn't already exist
     if (empty($this->_data)) {
         $query = $this->_buildQuery();
         $this->_db->setQuery($query);
         $rows = $this->_db->loadObjectList();
         //establish the hierarchy of the categories
         $children = array();
         //set depth limit
         $levellimit = 10;
         foreach ($rows as $child) {
             $parent = $child->parent_id;
             $list = @$children[$parent] ? $children[$parent] : array();
             array_push($list, $child);
             $children[$parent] = $list;
         }
         //get list of the items
         $list = hotelguide_city::treerecurse(0, '', array(), $children, false, max(0, $levellimit - 1));
         $total = count($list);
         jimport('joomla.html.pagination');
         $this->_pagination = new JPagination($total, $this->getState('limitstart'), $this->getState('limit'));
         $this->_data = array_slice($list, $this->_pagination->limitstart, $this->_pagination->limit);
     }
     return $this->_data;
 }
Ejemplo n.º 2
0
 /**
  * Get the room tree
  * based on the joomla 1.0 treerecurse 
  *
  * @access public
  * @return array
  */
 function treerecurse($id, $indent, $list, &$children, $title, $maxlevel = 9999, $level = 0, $type = 1)
 {
     if (@$children[$id] && $level <= $maxlevel) {
         foreach ($children[$id] as $v) {
             $id = $v->id;
             if ($type) {
                 $pre = '<sup>|_</sup>&nbsp;';
                 $spacer = '.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
             } else {
                 $pre = '- ';
                 $spacer = '&nbsp;&nbsp;';
             }
             if ($title) {
                 if ($v->parent_id == 0) {
                     $txt = '' . $v->name;
                 } else {
                     $txt = $pre . $v->name;
                 }
             } else {
                 if ($v->parent_id == 0) {
                     $txt = '';
                 } else {
                     $txt = $pre;
                 }
             }
             $pt = $v->parent_id;
             $list[$id] = $v;
             $list[$id]->treename = "{$indent}{$txt}";
             $list[$id]->children = count(@$children[$id]);
             $list = hotelguide_city::treerecurse($id, $indent . $spacer, $list, $children, $title, $maxlevel, $level + 1, $type);
         }
     }
     return $list;
 }