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); }
/** * Method to set the current category * * @access public * @param int ID of current item * @param int ID of parent category * @return string HTML output */ public function getCurrentCategory($categories, $item_id = 0) { // If there is no current item yet and we only have one category, select it if ($item_id == 0) { if (count($categories) == 1) { $current = $categories; } else { $application = JFactory::getApplication(); $option = JRequest::getCmd('option'); $id = $application->getUserStateFromRequest($option . 'filter_category_id', 'filter_category_id', 0, 'int'); $current = SimplelistsHelper::getCategory($id); } // Fetch the categories currently selected with the item } else { $current = SimplelistsHelper::getCategories($item_id); } return $current; }
public function display($tpl = null) { // Give a warning if no categories are configured SimplelistsHelper::checkCategories(); // Fetch the item automatically $this->fetchItem(true); // Modify the item a bit $this->item->image_default_folder = COM_SIMPLELISTS_DIR; $this->item->image_default_uri = COM_SIMPLELISTS_BASEURL; $this->item->picture_folder = $this->item->image_default_folder; $this->item->picture_uri = $this->item->image_default_uri; $this->item->picture_path = null; if (!empty($this->item->picture)) { $this->item->picture_path = JPATH_SITE . DS . $this->item->picture; $this->item->picture_uri = str_replace(DS, '/', $this->item->picture); $this->item->picture_folder = dirname($this->item->picture_uri); } // Add extra filtering lists $defaultCategory = $this->item->id == 0 ? (int) $this->getFilter('category_id', null, null, 'com_simplelists_items_') : null; $categories_params = array('item_id' => $this->item->id, 'multiple' => 1, 'current' => $defaultCategory); $this->lists['categories'] = SimplelistsHTML::selectCategories('categories[]', $categories_params); // Construct the modal boxes $modal = array(); $modal['picture'] = 'index.php?option=com_simplelists&view=files&tmpl=component&type=picture&current=' . $this->item->picture; if ($this->item->picture) { $modal['picture'] .= '&folder=' . $this->item->picture_folder; } $this->assignRef('modal', $modal); // Construct the slider-panel jimport('joomla.html.pane'); $pane =& JPane::getInstance('sliders'); $this->assignRef('pane', $pane); // Include extra JavaScript $this->addJs('mootools-cookie.js'); $this->addJs('view-browser.js'); // Load the plugins $link_plugins = SimplelistsPluginHelper::getPlugins('simplelistslink'); $this->assignRef('link_plugins', $link_plugins); // Add extra stuff JHTML::_('behavior.tooltip'); JHTML::_('behavior.modal', 'a.modal-button'); parent::display($tpl); }
public function display($tpl = null) { // Set extra toolbar items for the page JToolBarHelper::preferences('com_simplelists', '480'); //JToolBarHelper::help( 'screen.simplelist' ); // Preliminary check to see if any categories have been configured yet SimplelistsHelper::checkCategories(); // Automatically fetch items, total and pagination - and assign them to the template $this->fetchItems(); // Prepare data for each simplelists item foreach ($this->items as $index => $item) { $item->categories = SimplelistsHelper::getCategories($item->id); $item->edit_link = JRoute::_('index.php?option=com_simplelists&view=item&task=edit&cid[]=' . $item->id); $this->items[$index] = $item; } // build list of categories $category_id_params = array('current' => $this->getFilter('category_id'), 'javascript' => 1, 'nullvalue' => 1); $this->lists['category_id'] = SimplelistsHTML::selectCategories('filter_category_id', $category_id_params); $this->lists['link_type'] = SimplelistsHTML::selectLinkType($this->getFilter('link_type')); 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); }
* @author Yireo * @package SimpleLists * @copyright Copyright (C) 2012 * @license GNU Public License * @link http://www.yireo.com/ */ // no direct access defined('_JEXEC') or die('Restricted access'); // Define constants for all pages define('COM_SIMPLELISTS_DIR', 'images/simplelists/'); define('COM_SIMPLELISTS_BASE', JPATH_ROOT . '/' . COM_SIMPLELISTS_DIR); define('COM_SIMPLELISTS_BASEURL', JURI::root() . COM_SIMPLELISTS_DIR); // Manage common includes require_once JPATH_COMPONENT . '/helpers/acl.php'; require_once JPATH_COMPONENT . '/helpers/helper.php'; require_once JPATH_COMPONENT . '/helpers/plugin.php'; // Make sure the user is authorized to view this page if (SimpleListsHelperAcl::isAuthorized() == false) { $application = JFactory::getApplication(); $application->redirect('index.php', JText::_('COM_SIMPLELISTS_NOT_AUTHORIZED')); } // Require the base controller require_once JPATH_COMPONENT . '/controller.php'; // General checks SimplelistsHelper::checkDirectory(); SimplelistsHelper::checkVersions(); // Initialize the controller $controller = new SimplelistsController(); // Perform the Request task $controller->execute(JRequest::getCmd('task')); $controller->redirect();
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); }
/** * Method to return the current filelist * * @access public * @param null * @return array */ public function getList() { // Only process the list once per request static $list; if (is_array($list)) { return $list; } // Initialize variables $folder = $this->getState('folder'); $folderPath = JPATH_SITE . '/' . $folder; $type = $this->getState('type'); // Initialize the lists $files = array(); $subfolders = array(); $docs = array(); // Get the list of files and folders from the given folder if (is_readable($folderPath)) { $fileList = JFolder::files($folderPath); $subfolderList = JFolder::folders($folderPath); } else { $fileList = false; $subfolderList = false; } // Iterate over the files if they exist if ($fileList !== false) { foreach ($fileList as $file) { // Skip this file if it is not readable if (is_file($folderPath . '/' . $file) == false) { continue; } // Skip files starting with a dot if (substr($file, 0, 1) == '.') { continue; } // Skip specific files if (strtolower($file) == 'index.html' || preg_match('/\\.(php)$/', $file)) { continue; } $tmp = new JObject(); $tmp->name = $file; $tmp->path = $folderPath . '/' . $file; $tmp->path_relative = $folder . $file; $tmp->path_uri = $tmp->path_relative; $tmp->size = filesize($tmp->path); $ext = strtolower(JFile::getExt($file)); switch ($ext) { // Image case 'jpg': case 'png': case 'gif': case 'xcf': case 'odg': case 'bmp': case 'jpeg': $info = @getimagesize($tmp->path); $size = @filesize($tmp->path); $tmp->width = @$info[0]; $tmp->height = @$info[1]; $tmp->src_width = $tmp->width; $tmp->src_height = $tmp->height; $tmp->type = @$info[2]; $tmp->mime = @$info['mime']; $maxsize = 60; if ($info[0] > $maxsize || $info[1] > $maxsize) { $dimensions = MediaHelper::imageResize($info[0], $info[1], $maxsize); $tmp->width = $dimensions[0]; $tmp->height = $dimensions[1]; } $maxbits = 524288; if ($size > $maxbits) { $tmp->src = JURI::root() . SimplelistsHelper::createThumbnail($tmp->path, $ext, $tmp->src_width, $tmp->src_height, $tmp->width, $tmp->height); } else { $tmp->src = JURI::root() . $tmp->path_relative; } $files[] = $tmp; break; // Non-image document // Non-image document default: if ($type != 'link_file') { break; } // First read the Media Manager parameters and check if this extension is allowed $media_params = JComponentHelper::getParams('com_media'); $allowable = explode(',', $media_params->get('upload_extensions')); if (in_array($ext, $allowable) == false) { break; } if (file_exists(JPATH_SITE . '/media/media/images/mime-icon-32/' . $ext . '.png')) { $tmp->path_relative = '/media/media/images/mime-icon-32/' . $ext . '.png'; } elseif (file_exists(JPATH_SITE . '/media/media/images/con_info.png')) { $tmp->path_relative = '/media/media/images/con_info.png'; } elseif (file_exists(JPATH_ADMINISTRATOR . '/components/com_media/images/mime-icon-32/' . $ext . '.png')) { $tmp->path_relative = '/administrator/components/com_media/images/mime-icon-32/' . $ext . '.png'; } elseif (file_exists(JPATH_ADMINISTRATOR . '/components/com_media/images/con_info.png')) { $tmp->path_relative = '/administrator/components/com_media/images/con_info.png'; } $tmp->src = $tmp->path_relative; $info = @getimagesize(JPATH_SITE . '/' . $tmp->path_relative); $tmp->width = @$info[0]; $tmp->height = @$info[1]; $files[] = $tmp; break; } } } // Iterate over the folders if they exist if ($subfolderList !== false) { foreach ($subfolderList as $subfolder) { $tmp = new JObject(); $tmp->name = basename($subfolder); $tmp->path = JPath::clean($folderPath . '/' . $subfolder); $tmp->path_relative = str_replace(JPATH_ROOT . '/', '', $tmp->path); $tmp->path_uri = $tmp->path_relative; $count = MediaHelper::countFiles($tmp->path); $tmp->files = $count[0]; $tmp->subfolders = $count[1]; $subfolders[] = $tmp; } } $list = array('subfolders' => $subfolders, 'docs' => $docs, 'files' => $files); return $list; }
protected function addPathway($category) { // Sanity check if (!is_object($category)) { return null; } $application = JFactory::getApplication(); $pathway = $application->getPathway(); if ($category->parent_id > 0) { $pathway->addItem($category->title); $parent = SimplelistsHelper::getCategory($category->parent_id); $this->addPathway($parent); } }