PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/components/com_hwdmediashare/views/albums/view.html.php

https://gitlab.com/ppapadatis/Videolearn
PHP | 153 lines | 101 code | 25 blank | 27 comment | 19 complexity | 3814e7de62025142706ed1741813d33b MD5 | raw file
  1. <?php
  2. /**
  3. * @version SVN $Id: view.html.php 459 2012-08-13 12:58:37Z dhorsfall $
  4. * @package hwdMediaShare
  5. * @copyright Copyright (C) 2011 Highwood Design Limited. All rights reserved.
  6. * @license GNU General Public License http://www.gnu.org/copyleft/gpl.html
  7. * @author Dave Horsfall
  8. * @since 14-Nov-2011 20:55:42
  9. */
  10. // No direct access to this file
  11. defined('_JEXEC') or die('Restricted access');
  12. // Import Joomla view library
  13. jimport('joomla.application.component.view');
  14. /**
  15. * HTML View class for the hwdMediaShare Component
  16. */
  17. class hwdMediaShareViewAlbums extends JView
  18. {
  19. protected $view_item = 'album';
  20. protected $elementType = 2;
  21. protected $elementName = 'Album';
  22. // Overwriting JView display method
  23. function display($tpl = null)
  24. {
  25. // Get data from the model
  26. $items = $this->get('Items');
  27. $pagination = $this->get('Pagination');
  28. $state = $this->get('State');
  29. // Download links
  30. hwdMediaShareFactory::load('downloads');
  31. hwdMediaShareFactory::load('files');
  32. JLoader::register('JHtmlHwdIcon', JPATH_COMPONENT . '/helpers/icon.php');
  33. JLoader::register('JHtmlString', JPATH_LIBRARIES.'/joomla/html/html/string.php');
  34. // Check for errors.
  35. if (count($errors = $this->get('Errors')))
  36. {
  37. JError::raiseWarning(500, implode("\n", $errors));
  38. return false;
  39. }
  40. if (count($items) == 0)
  41. {
  42. JFactory::getApplication()->enqueueMessage( JText::_('COM_HWDMS_NOTICE_NO_ALBUMS') );
  43. }
  44. if ($items === false)
  45. {
  46. JError::raiseError(404, JText::_('COM_HWDMS_ERROR'));
  47. return false;
  48. }
  49. $params = &$state->params;
  50. $hwdms = hwdMediaShareFactory::getInstance();
  51. $config = $hwdms->getConfig();
  52. //Escape strings for HTML output
  53. $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
  54. $this->assign('maxLevelcat', $params->get('maxLevelcat', -1));
  55. $this->assign('columns', $params->get('list_columns', 3));
  56. $this->assign('display', $state->get('media.display'));
  57. $this->assign('return', base64_encode(JFactory::getURI()->toString()));
  58. $this->assignRef('items', $items);
  59. $this->assignRef('pagination', $pagination);
  60. $this->assignRef('state', $state);
  61. $this->assignRef('params', $params);
  62. $this->_prepareDocument();
  63. parent::display($tpl);
  64. }
  65. /**
  66. * Prepares the document
  67. */
  68. protected function _prepareDocument()
  69. {
  70. $app = JFactory::getApplication();
  71. $menus = $app->getMenu();
  72. $pathway = $app->getPathway();
  73. $title = null;
  74. $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/hwd.css');
  75. if ($this->state->params->get('load_joomla_css') != 0) $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/joomla.css');
  76. // Because the application sets a default page title,
  77. // we need to get it from the menu item itself
  78. $menu = $menus->getActive();
  79. if ($menu)
  80. {
  81. $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
  82. }
  83. else
  84. {
  85. $this->params->def('page_heading', JText::_('COM_HWDMS_ALBUMS'));
  86. }
  87. $title = $this->params->get('page_title', '');
  88. // If the menu item does not concern this item
  89. if ($menu && ($menu->query['option'] != 'com_hwdmediashare' || $menu->query['view'] != 'albums'))
  90. {
  91. // If this is not a single item menu item, set the page title to the item title
  92. $title = JText::_('COM_HWDMS_ALBUMS');
  93. // Breadcrumb support
  94. $path = array(array('title' => JText::_('COM_HWDMS_ALBUMS'), 'link' => ''));
  95. $path = array_reverse($path);
  96. foreach($path as $item)
  97. {
  98. $pathway->addItem($item['title'], $item['link']);
  99. }
  100. }
  101. // Check for empty title and add site name if param is set
  102. if (empty($title)) {
  103. $title = $app->getCfg('sitename');
  104. }
  105. elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
  106. $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
  107. }
  108. elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
  109. $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
  110. }
  111. if (empty($title)) {
  112. $title = JText::_('COM_HWDMS_ALBUMS');
  113. }
  114. $this->document->setTitle($title);
  115. if ($this->params->get('meta_desc'))
  116. {
  117. $this->document->setDescription($this->params->get('meta_desc'));
  118. }
  119. if ($this->params->get('meta_keys'))
  120. {
  121. $this->document->setMetadata('keywords', $this->params->get('meta_keys'));
  122. }
  123. if ($this->params->get('meta_rights'))
  124. {
  125. $this->document->setMetadata('copyright', $this->params->get('meta_rights'));
  126. }
  127. }
  128. }