PageRenderTime 22ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://gitlab.com/ppapadatis/Videolearn
PHP | 284 lines | 193 code | 36 blank | 55 comment | 30 complexity | 0360004cd946934096cd58ee548e9408 MD5 | raw file
  1. <?php
  2. /**
  3. * @version SVN $Id: view.html.php 1184 2013-02-25 15:34:00Z 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 01-Dec-2011 09:57:02
  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 hwdMediaShareViewUpload extends JView
  18. {
  19. // Overwriting JView display method
  20. function display($tpl = null)
  21. {
  22. $hwdms = hwdMediaShareFactory::getInstance();
  23. $config = $hwdms->getConfig();
  24. if (!JFactory::getUser()->authorise('hwdmediashare.upload','com_hwdmediashare')
  25. && !JFactory::getUser()->authorise('hwdmediashare.import','com_hwdmediashare'))
  26. {
  27. JFactory::getApplication()->enqueueMessage( JText::_('COM_HWDMS_ERROR_NOAUTHORISED_ADDMEDIA') );
  28. JFactory::getApplication()->redirect( $config->get('no_access_redirect') > 0 ? ContentHelperRoute::getArticleRoute($config->get('no_access_redirect')) : hwdMediaShareHelperRoute::getMediaRoute() );
  29. }
  30. hwdMediaShareFactory::load('utilities');
  31. // Get data from the model
  32. $form = $this->get('Form');
  33. $script = $this->get('Script');
  34. $state = $this->get('State');
  35. $standardExtensions = $this->get('standardExtensions');
  36. $largeExtensions = $this->get('largeExtensions');
  37. $platformExtensions = $this->get('platformExtensions');
  38. // Get any binds
  39. $assocAlbum = $this->get('assocAlbum');
  40. $assocGroup = $this->get('assocGroup');
  41. $assocPlaylist = $this->get('assocPlaylist');
  42. $assocResponse = $this->get('assocResponse');
  43. $assocCategory = $this->get('assocCategory');
  44. // Download links
  45. hwdMediaShareFactory::load('files');
  46. JLoader::register('JHtmlHwdIcon', JPATH_COMPONENT . '/helpers/icon.php');
  47. // Check for errors.
  48. if (count($errors = $this->get('Errors')))
  49. {
  50. JError::raiseWarning(500, implode("\n", $errors));
  51. return false;
  52. }
  53. // Check for errors.
  54. if ($this->get('terms') === true)
  55. {
  56. $tpl = 'terms';
  57. }
  58. if ($config->get('enable_uploads_file') == 1)
  59. {
  60. if ($config->get('upload_tool_fancy') == 1 && (is_array($standardExtensions) && count($standardExtensions) > 0))
  61. {
  62. $fancyUploadHtml = $this->get('FancyUploadScript');
  63. }
  64. if ($config->get('upload_tool_perl') == 1)
  65. {
  66. $uberUploadHtml = $this->get('UberUploadScript');
  67. $this->uberUploadHtml = $uberUploadHtml;
  68. }
  69. }
  70. $params = &$state->params;
  71. //Escape strings for HTML output
  72. $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
  73. $this->assign('template', JRequest::getWord( 'tmpl', '' ));
  74. $this->assign('maxLevelcat', $params->get('maxLevelcat', -1));
  75. $this->assign('columns', $params->get('list_columns', 3));
  76. $this->assign('return', base64_encode(JFactory::getURI()->toString()));
  77. $this->assignRef('params', $params);
  78. $this->assignRef('form', $form);
  79. $this->assignRef('state', $state);
  80. $this->assignRef('standardExtensions', $standardExtensions);
  81. $this->assignRef('largeExtensions', $largeExtensions);
  82. $this->assignRef('platformExtensions', $platformExtensions);
  83. $this->assignRef('uberUploadHtml', $uberUploadHtml);
  84. // Binds
  85. $this->assignRef('assocAlbum', $assocAlbum);
  86. $this->assignRef('assocGroup', $assocGroup);
  87. $this->assignRef('assocCategory', $assocCategory);
  88. $this->assignRef('utilities', hwdMediaShareUtilities::getInstance());
  89. $this->_prepareDocument();
  90. parent::display($tpl);
  91. }
  92. /**
  93. * Prepares the document
  94. */
  95. protected function _prepareDocument()
  96. {
  97. $app = JFactory::getApplication();
  98. $menus = $app->getMenu();
  99. $title = null;
  100. JHtml::_('behavior.framework', true);
  101. $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/hwd.css');
  102. if ($this->state->params->get('load_joomla_css') != 0) $this->document->addStyleSheet(JURI::base( true ).'/media/com_hwdmediashare/assets/css/joomla.css');
  103. if ($this->params->get('upload_tool_fancy') == 1)
  104. {
  105. $this->document->addScript(JURI::root() . "/media/com_hwdmediashare/assets/javascript/Swiff.Uploader.js");
  106. $this->document->addScript(JURI::root() . "/media/com_hwdmediashare/assets/javascript/Fx.ProgressBar.js");
  107. $this->document->addScript(JURI::root() . "/media/com_hwdmediashare/assets/javascript/FancyUpload2.js");
  108. $this->document->addStyleSheet(JURI::root() . "media/com_hwdmediashare/assets/css/fancy.css");
  109. }
  110. // Because the application sets a default page title,
  111. // we need to get it from the menu item itself
  112. $menu = $menus->getActive();
  113. if ($menu)
  114. {
  115. $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
  116. }
  117. else
  118. {
  119. $this->params->def('page_heading', JText::_('COM_HWDMS_UPLOAD'));
  120. }
  121. $title = $this->params->get('page_title', '');
  122. if (empty($title))
  123. {
  124. $title = JText::_('COM_HWDMS_UPLOAD');
  125. }
  126. elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
  127. {
  128. $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
  129. }
  130. elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
  131. {
  132. $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
  133. }
  134. $this->document->setTitle($title);
  135. if ($this->params->get('meta_desc'))
  136. {
  137. $this->document->setDescription($this->params->get('meta_desc'));
  138. }
  139. if ($this->params->get('meta_keys'))
  140. {
  141. $this->document->setMetadata('keywords', $this->params->get('meta_keys'));
  142. }
  143. if ($this->params->get('meta_rights'))
  144. {
  145. $this->document->setMetadata('copyright', $this->params->get('meta_rights'));
  146. }
  147. if ($this->params->get('meta_author'))
  148. {
  149. //$this->document->setMetadata('author', $this->params->get('meta_author'));
  150. }
  151. }
  152. /**
  153. * Method to set up the document properties
  154. *
  155. * @return void
  156. */
  157. protected function getPlatformUploadForm()
  158. {
  159. // Load hwdMediaShare config
  160. $hwdms = hwdMediaShareFactory::getInstance();
  161. $config = $hwdms->getConfig();
  162. $pluginClass = 'plgHwdmediashare'.$config->get('platform');
  163. $pluginPath = JPATH_ROOT.'/plugins/hwdmediashare/'.$config->get('platform').'/'.$config->get('platform').'.php';
  164. // Import hwdMediaShare plugins
  165. if (file_exists($pluginPath))
  166. {
  167. JLoader::register($pluginClass, $pluginPath);
  168. $player = call_user_func(array($pluginClass, 'getInstance'));
  169. return $player->getUploadForm();
  170. }
  171. }
  172. /**
  173. * Method to set up the document properties
  174. *
  175. * @return void
  176. */
  177. protected function getReadableAllowedMediaTypes($method=null)
  178. {
  179. hwdMediaShareFactory::load('upload');
  180. return hwdMediaShareUpload::getReadableAllowedMediaTypes($method);
  181. }
  182. /**
  183. * Method to set up the document properties
  184. *
  185. * @return void
  186. */
  187. protected function getReadableAllowedExtensions($extensions)
  188. {
  189. hwdMediaShareFactory::load('upload');
  190. return hwdMediaShareUpload::getReadableAllowedExtensions($extensions);
  191. }
  192. /**
  193. * Method to set up the document properties
  194. *
  195. * @return void
  196. */
  197. protected function getReadableAllowedRemotes()
  198. {
  199. hwdMediaShareFactory::load('remote');
  200. return hwdMediaShareRemote::getReadableAllowedRemotes();
  201. }
  202. /**
  203. * Method to set up the document properties
  204. *
  205. * @return void
  206. */
  207. protected function getAssociated()
  208. {
  209. $buffer = null;
  210. $messages = array();
  211. if (isset($this->assocAlbum->id))
  212. {
  213. $messages[] = 'New media will be added to '.$this->escape($this->assocAlbum->title).' album';
  214. $buffer .= '<input type="hidden" name="jform[album_id]" value="'.$this->assocAlbum->id.'" />';
  215. $buffer .= '<input type="hidden" name="jform_album_id" value="'.$this->assocAlbum->id.'" />';
  216. }
  217. if (isset($this->assocGroup->id))
  218. {
  219. $messages[] = 'New media will be added to '.$this->escape($this->assocGroup->title).' group';
  220. $buffer .= '<input type="hidden" name="jform[group_id]" value="'.$this->assocGroup->id.'" />';
  221. $buffer .= '<input type="hidden" name="jform_group_id" value="'.$this->assocGroup->id.'" />';
  222. }
  223. if (isset($this->assocCategory->id))
  224. {
  225. $messages[] = 'New media will be added to '.$this->escape($this->assocCategory->title).' category';
  226. $buffer .= '<input type="hidden" name="jform[catid]" value="'.$this->assocCategory->id.'" />';
  227. $buffer .= '<input type="hidden" name="jform_catid" value="'.$this->assocCategory->id.'" />';
  228. }
  229. // Build the return string. If messages exist render them
  230. if (is_array($messages) && count($messages))
  231. {
  232. $buffer .= "<div id=\"system-message-container\">";
  233. $buffer .= "\n<dl id=\"system-message\">";
  234. $buffer .= "\n<dt class=\"message\">Message</dt>";
  235. $buffer .= "\n<dd class=\"message message\">";
  236. $buffer .= "\n\t<ul>";
  237. foreach ($messages as $message)
  238. {
  239. $buffer .= "\n\t\t<li>" . $message . "</li>";
  240. }
  241. $buffer .= "\n\t</ul>";
  242. $buffer .= "\n</dd>";
  243. $buffer .= "\n</dl>";
  244. $buffer .= "\n</div>";
  245. }
  246. return $buffer;
  247. }
  248. }