/components/com_hwdmediashare/views/albums/view.html.php
PHP | 153 lines | 101 code | 25 blank | 27 comment | 19 complexity | 3814e7de62025142706ed1741813d33b MD5 | raw file
- <?php
- /**
- * @version SVN $Id: view.html.php 459 2012-08-13 12:58:37Z dhorsfall $
- * @package hwdMediaShare
- * @copyright Copyright (C) 2011 Highwood Design Limited. All rights reserved.
- * @license GNU General Public License http://www.gnu.org/copyleft/gpl.html
- * @author Dave Horsfall
- * @since 14-Nov-2011 20:55:42
- */
- // No direct access to this file
- defined('_JEXEC') or die('Restricted access');
- // Import Joomla view library
- jimport('joomla.application.component.view');
- /**
- * HTML View class for the hwdMediaShare Component
- */
- class hwdMediaShareViewAlbums extends JView
- {
- protected $view_item = 'album';
- protected $elementType = 2;
- protected $elementName = 'Album';
-
- // Overwriting JView display method
- function display($tpl = null)
- {
- // Get data from the model
- $items = $this->get('Items');
- $pagination = $this->get('Pagination');
- $state = $this->get('State');
- // Download links
- hwdMediaShareFactory::load('downloads');
- hwdMediaShareFactory::load('files');
- JLoader::register('JHtmlHwdIcon', JPATH_COMPONENT . '/helpers/icon.php');
- JLoader::register('JHtmlString', JPATH_LIBRARIES.'/joomla/html/html/string.php');
- // Check for errors.
- if (count($errors = $this->get('Errors')))
- {
- JError::raiseWarning(500, implode("\n", $errors));
- return false;
- }
-
- if (count($items) == 0)
- {
- JFactory::getApplication()->enqueueMessage( JText::_('COM_HWDMS_NOTICE_NO_ALBUMS') );
- }
-
- if ($items === false)
- {
- JError::raiseError(404, JText::_('COM_HWDMS_ERROR'));
- return false;
- }
- $params = &$state->params;
- $hwdms = hwdMediaShareFactory::getInstance();
- $config = $hwdms->getConfig();
- //Escape strings for HTML output
- $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
- $this->assign('maxLevelcat', $params->get('maxLevelcat', -1));
- $this->assign('columns', $params->get('list_columns', 3));
- $this->assign('display', $state->get('media.display'));
- $this->assign('return', base64_encode(JFactory::getURI()->toString()));
-
- $this->assignRef('items', $items);
- $this->assignRef('pagination', $pagination);
- $this->assignRef('state', $state);
- $this->assignRef('params', $params);
- $this->_prepareDocument();
- parent::display($tpl);
- }
- /**
- * Prepares the document
- */
- protected function _prepareDocument()
- {
- $app = JFactory::getApplication();
- $menus = $app->getMenu();
- $pathway = $app->getPathway();
- $title = null;
- $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/hwd.css');
- if ($this->state->params->get('load_joomla_css') != 0) $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/joomla.css');
- // Because the application sets a default page title,
- // we need to get it from the menu item itself
- $menu = $menus->getActive();
- if ($menu)
- {
- $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
- }
- else
- {
- $this->params->def('page_heading', JText::_('COM_HWDMS_ALBUMS'));
- }
- $title = $this->params->get('page_title', '');
- // If the menu item does not concern this item
- if ($menu && ($menu->query['option'] != 'com_hwdmediashare' || $menu->query['view'] != 'albums'))
- {
- // If this is not a single item menu item, set the page title to the item title
- $title = JText::_('COM_HWDMS_ALBUMS');
-
- // Breadcrumb support
- $path = array(array('title' => JText::_('COM_HWDMS_ALBUMS'), 'link' => ''));
-
- $path = array_reverse($path);
- foreach($path as $item)
- {
- $pathway->addItem($item['title'], $item['link']);
- }
- }
-
- // Check for empty title and add site name if param is set
- if (empty($title)) {
- $title = $app->getCfg('sitename');
- }
- elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
- $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
- }
- elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
- $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
- }
- if (empty($title)) {
- $title = JText::_('COM_HWDMS_ALBUMS');
- }
- $this->document->setTitle($title);
- if ($this->params->get('meta_desc'))
- {
- $this->document->setDescription($this->params->get('meta_desc'));
- }
- if ($this->params->get('meta_keys'))
- {
- $this->document->setMetadata('keywords', $this->params->get('meta_keys'));
- }
- if ($this->params->get('meta_rights'))
- {
- $this->document->setMetadata('copyright', $this->params->get('meta_rights'));
- }
- }
- }