PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://gitlab.com/ppapadatis/Videolearn
PHP | 218 lines | 150 code | 31 blank | 37 comment | 26 complexity | 14fda61c01be1a14cf01a52883b50bac MD5 | raw file
  1. <?php
  2. /**
  3. * @version SVN $Id: view.html.php 917 2013-01-16 10:58:32Z 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 15-Apr-2011 10:13:15
  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 hwdMediaShareViewAlbum extends JView
  18. {
  19. // Overwriting JView display method
  20. function display($tpl = null)
  21. {
  22. $app = & JFactory::getApplication();
  23. // Get the album data from the model
  24. $album = $this->get('Album');
  25. // Get the media data from the model
  26. $items = $this->get('Items');
  27. $pagination = $this->get('Pagination');
  28. $state = $this->get('State');
  29. $album->nummedia = $this->get('NumMedia');
  30. // Download links
  31. hwdMediaShareFactory::load('files');
  32. hwdMediaShareFactory::load('downloads');
  33. hwdMediaShareFactory::load('media');
  34. hwdMediaShareFactory::load('utilities');
  35. JLoader::register('JHtmlHwdIcon', JPATH_COMPONENT . '/helpers/icon.php');
  36. JLoader::register('JHtmlString', JPATH_LIBRARIES.'/joomla/html/html/string.php');
  37. // Check for errors.
  38. if (count($errors = $this->get('Errors')))
  39. {
  40. JError::raiseError(500, implode('<br />', $errors));
  41. return false;
  42. }
  43. if (count($items) == 0)
  44. {
  45. JFactory::getApplication()->enqueueMessage( JText::_('COM_HWDMS_NOTICE_NO_MEDIA_IN_ALBUM') );
  46. }
  47. $params = &$state->params;
  48. //Escape strings for HTML output
  49. $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
  50. $this->assign('maxLevelcat', $params->get('maxLevelcat', -1));
  51. $this->assign('columns', $params->get('list_columns', 3));
  52. $this->assign('return', base64_encode(JFactory::getURI()->toString()));
  53. $this->assignRef('params', $params);
  54. $this->assignRef('album', $album);
  55. $this->assignRef('parent', $parent);
  56. $this->assignRef('items', $items);
  57. $this->assignRef('state', $state);
  58. $this->assignRef('pagination', $pagination);
  59. $this->assignRef('display', JRequest::getWord( 'display', 'details' ));
  60. $this->assignRef('utilities', hwdMediaShareUtilities::getInstance());
  61. $model = $this->getModel();
  62. $model->hit();
  63. $this->_prepareDocument();
  64. // Display the view
  65. parent::display($tpl);
  66. }
  67. /**
  68. * Prepares the document
  69. */
  70. protected function _prepareDocument()
  71. {
  72. $app = JFactory::getApplication();
  73. $menus = $app->getMenu();
  74. $pathway = $app->getPathway();
  75. $title = null;
  76. $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/hwd.css');
  77. if ($this->state->params->get('load_joomla_css') != 0) $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/joomla.css');
  78. // Because the application sets a default page title,
  79. // we need to get it from the menu item itself
  80. $menu = $menus->getActive();
  81. if ($menu)
  82. {
  83. $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
  84. }
  85. else
  86. {
  87. $this->params->def('page_heading', JText::_('COM_HWDMS_ALBUM'));
  88. }
  89. $title = $this->params->get('page_title', '');
  90. $id = (int) @$menu->query['id'];
  91. // If the menu item does not concern this item
  92. if ($menu && ($menu->query['option'] != 'com_hwdmediashare' || $menu->query['view'] != 'album' || $id != $this->album->id))
  93. {
  94. // If this is not a single item menu item, set the page title to the item title
  95. if ($this->album->title)
  96. {
  97. $title = $this->album->title;
  98. }
  99. // Breadcrumb support
  100. $path = array(array('title' => $this->album->title, 'link' => ''));
  101. $path = array_reverse($path);
  102. foreach($path as $item)
  103. {
  104. $pathway->addItem($item['title'], $item['link']);
  105. }
  106. }
  107. // Check for empty title and add site name if param is set
  108. if (empty($title)) {
  109. $title = $app->getCfg('sitename');
  110. }
  111. elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
  112. $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
  113. }
  114. elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
  115. $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
  116. }
  117. if (empty($title)) {
  118. $title = $this->album->title;
  119. }
  120. $this->document->setTitle($title);
  121. if ($this->album->params->get('meta_desc'))
  122. {
  123. $this->document->setDescription($this->album->params->get('meta_desc'));
  124. }
  125. elseif ($this->params->get('meta_desc'))
  126. {
  127. $this->document->setDescription($this->params->get('meta_desc'));
  128. }
  129. else
  130. {
  131. $this->document->setDescription($this->escape(JHtmlString::truncate($this->album->description, $this->params->get('list_desc_truncate'), true, false)));
  132. }
  133. if ($this->album->params->get('meta_keys'))
  134. {
  135. $this->document->setMetadata('keywords', $this->album->params->get('meta_keys'));
  136. }
  137. elseif ($this->params->get('meta_keys'))
  138. {
  139. $this->document->setMetadata('keywords', $this->params->get('meta_keys'));
  140. }
  141. if ($this->album->params->get('meta_rights'))
  142. {
  143. $this->document->setMetadata('keywords', $this->album->params->get('meta_rights'));
  144. }
  145. elseif ($this->params->get('meta_rights'))
  146. {
  147. $this->document->setMetadata('copyright', $this->params->get('meta_rights'));
  148. }
  149. if ($this->album->params->get('meta_author') == 1)
  150. {
  151. $this->document->setMetadata('author', $this->album->author);
  152. }
  153. elseif ($this->params->get('meta_author') == 1)
  154. {
  155. $this->document->setMetadata('author', $this->album->author);
  156. }
  157. }
  158. /**
  159. * Method to get the publish status HTML
  160. *
  161. * @param object Field object
  162. * @param string Type of the field
  163. * @param string The ajax task that it should call
  164. * @return string HTML source
  165. **/
  166. public function getCategories( &$item )
  167. {
  168. if (!isset($item))
  169. {
  170. return;
  171. }
  172. $href = '';
  173. if (count($item->categories) > 0)
  174. {
  175. foreach ($item->categories as $value)
  176. {
  177. $href.= '<a href="'.JRoute::_(hwdMediaShareHelperRoute::getCategoryRoute($value->id)).'">' . $value->title . '</a> ';
  178. }
  179. unset($value);
  180. }
  181. else
  182. {
  183. $href = JText::_('COM_HWDMS_NONE');
  184. }
  185. return $href;
  186. }
  187. }