public function display($tpl = null) { // Automatically fetch items, total and pagination - and assign them to the template $this->setAutoClean(false); $this->fetchItems(); $document =& JFactory::getDocument(); // Get some variables $layout = $this->params->get('layout', 'default'); $clayout = $this->params->get('clayout', 'default'); // Load the layout-specific stylesheet $this->addCss('view-categories-' . $clayout . '.css'); // Get the parent-category from our model $model =& $this->getModel(); $parent = $model->getParent(); // Set the page title $page_title = $this->params->get('page_title'); if ($this->params->get('show_page_title') == 1 && !empty($page_title)) { $document->setTitle($page_title); $parent->title = $page_title; } elseif (!empty($parent->title)) { $document->setTitle($parent->title); } // Loop through the list to set things right if (count($this->items) > 0) { foreach ($this->items as $id => $item) { if ($this->params->get('show_category_title') == 0) { $item->title = null; } if ($this->params->get('show_category_description') == 0) { $item->description = null; } $layout = $item->params->get('layout', $layout); $needles = array('category_id' => $item->id, 'category_alias' => $item->alias, 'layout' => $layout); $item->link = SimplelistsHelper::getUrl($needles); // Reinsert this item $this->items[$id] = $item; } } else { $this->assignRef('message', JText::_('No categories found')); } // prepare the image if ($this->params->get('show_category_image') && !empty($parent->image)) { $parent->image = JHTML::image($parent->image, $parent->title, 'title="' . $parent->title . '" class="simplelists" align="' . $parent->image_position . '"'); } else { $parent->image = null; } // prepare the title if ($this->params->get('show_category_title') == 0) { $parent->title = null; } // prepare the description if ($this->params->get('show_category_description') == 0) { $parent->description = null; } $this->assignRef('category', $parent); parent::display($tpl); }
public function getUrl(&$params) { $category_id = (int) $params->get('category_id'); $Itemid = (int) $params->get('menu_id'); $layout = $params->get('layout'); $needles = array('category_id' => $category_id, 'Itemid' => $Itemid, 'layout' => $layout); return SimplelistsHelper::getUrl($needles); }
public function getList(&$params) { // Get some system variables $mainframe =& JFactory::getApplication(); $db =& JFactory::getDBO(); $user =& JFactory::getUser(); // Read the module parameters $count = (int) $params->get('count', 5); $category_id = (int) $params->get('category_id'); $ordering = $params->get('ordering'); $layout = $params->get('layout'); $Itemid = (int) $params->get('menu_id'); // Initialize some variables $aid = $user->get('aid', 0); $nullDate = $db->getNullDate(); $date =& JFactory::getDate(); $now = $date->toMySQL(); switch ($ordering) { case 'alpha': $o = 'w.title ASC'; break; case 'ralpha': $o = 'w.title DESC'; break; case 'date': $o = 'w.created DESC, w.modified DESC'; break; case 'rdate': $o = 'w.created ASC, w.modified ASC'; break; case 'random': $o = 'RAND()'; break; default: $o = 'w.ordering'; break; } $where = 'ORDER BY ' . $o; $query = 'SELECT w.*, c.title AS category, c.id AS category_id, c.alias AS category_alias' . ' FROM #__simplelists_categories AS sc' . ' LEFT JOIN #__simplelists_items AS w ON w.id = sc.id' . ' LEFT JOIN #__categories AS c ON c.id = sc.category_id' . ' WHERE sc.category_id = ' . $category_id . ' AND c.published = 1' . ' AND w.published = 1' . ' ' . $where; $db->setQuery($query, 0, $count); $rows = $db->loadObjectList(); // Get the Itemid if ($Itemid > 0) { $menu_item = SimplelistsHelper::getMenuItemFromItemId($Itemid); if (!empty($menu_item)) { $layout = !empty($menu_item->layout) ? $menu_item->layout : 'default'; } else { $layout = null; } } else { $menu_item = SimplelistsHelper::getMenuItem($category_id, $layout); if ($menu_item != null) { if (isset($menu_item->query['layout'])) { $layout = $menu_item->query['layout']; } $Itemid = $menu_item->id; } } $i = 0; $lists = array(); if (!empty($rows)) { foreach ($rows as $row) { $needles = array('category_id' => $row->category_id, 'category_alias' => $row->category_alias, 'item_id' => $row->id, 'item_alias' => $row->alias, 'Itemid' => $Itemid, 'layout' => $layout); $row->href = $row->alias ? $row->alias : 'item' . $row->id; $row->link = SimplelistsHelper::getUrl($needles); $row->title = htmlspecialchars($row->title); $row->params = YireoHelper::toParameter($row->params); if ($params->get('show_image', 0) == 1) { $align = $row->params->get('picture_alignment'); if (empty($align)) { $align = $params->get('image_align', 'left'); } $attributes = 'alt="' . $row->title . '" title="' . $row->title . '" class="simplelists" style="float:' . $align . '"'; $image_file = JPATH_SITE . DS . str_replace('/', DS, $row->picture); if (is_file($image_file)) { $size = getimagesize($image_file); $attributes .= 'width="' . $size[0] . '" height="' . $size[1] . '"'; } $row->picture = JHTML::image($row->picture, $row->title, $attributes); } else { $row->picture = null; } $lists[$i] = $row; $i++; } } return $lists; }
public function getUrl($item = null) { return SimplelistsHelper::getUrl($item->link); }
public function prepareCategory($category, $layout) { // Sanity check if (!is_object($category)) { return null; } // Convert the parameters to an object $category->params = YireoHelper::toParameter($category->params); $params = $this->params; // Override the default parameters with the category parameters foreach ($category->params->toArray() as $name => $value) { if ($value != '') { $params->set($name, $value); } } // Override the layout $layout = $category->params->get('layout'); if (!empty($layout)) { $this->setLayout($layout); } // Prepare the category URL if ($params->get('show_category_parent') && !empty($category->parent)) { $needles = array('category_id' => $category->parent->id); if (isset($category->parent->alias)) { $needles['category_alias'] = $category->parent->alias; } $category->parent->link = SimplelistsHelper::getUrl($needles); } // Loop through the child-categories if ($params->get('show_category_childs') && !empty($category->childs)) { foreach ($category->childs as $child) { $child->params = YireoHelper::toParameter($child->params); $child_layout = $child->params->get('layout', $layout); $needles = array('category_id' => $child->id, 'category_alias' => $child->alias, 'layout' => $child_layout); $child->link = SimplelistsHelper::getUrl($needles); } } // Set the correct page-title if ($params->get('show_page_title') == 1 && $params->get('page_title') != '') { $category->title = $params->get('page_title'); } // Run the category content through Content Plugins if ($params->get('show_category_description') && !empty($category->description)) { $category->text = $category->description; $this->firePlugins($category, array()); $category->description = $category->text; $category->text = null; } // Prepare the category image if ($params->get('show_category_image') && isset($category->image) && !empty($category->image)) { $category->image = JHTML::image($category->image, $category->title, array('align' => $category->image_position)); } else { $params->set('show_category_image', 0); } }