diff --git a/administrator/components/com_media/controllers/file.php b/administrator/components/com_media/controllers/file.php index 2610996826a98..7768ac5596e8b 100644 --- a/administrator/components/com_media/controllers/file.php +++ b/administrator/components/com_media/controllers/file.php @@ -202,6 +202,8 @@ public function delete() { JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN')); + $user = JFactory::getUser(); + // Get some data from the request $tmpl = $this->input->get('tmpl'); $paths = $this->input->get('rm', array(), 'array'); @@ -217,18 +219,25 @@ public function delete() $this->setRedirect($redirect); - // Nothing to delete + // Just return if there's nothing to do if (empty($paths)) { + $this->setMessage(JText::_('JERROR_NO_ITEMS_SELECTED'), 'error'); + return true; } - // Authorize the user - if (!$this->authoriseUser('delete')) + if (!$user->authorise('core.delete', 'com_media')) { + // User is not authorised to delete + JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED')); + return false; } + // Need this to enqueue messages. + $app = JFactory::getApplication(); + // Set FTP credentials, if given JClientHelper::setCredentialsFromRequest('ftp'); @@ -237,17 +246,18 @@ public function delete() $ret = true; - foreach ($paths as $path) - { - if ($path !== JFile::makeSafe($path)) - { - // Filename is not safe - $filename = htmlspecialchars($path, ENT_COMPAT, 'UTF-8'); - JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', substr($filename, strlen(COM_MEDIA_BASE)))); + $safePaths = array_intersect($paths, array_map(array('JFile', 'makeSafe'), $paths)); + $unsafePaths = array_diff($paths, $safePaths); - continue; - } + foreach ($unsafePaths as $path) + { + $path = JPath::clean(implode(DIRECTORY_SEPARATOR, array($folder, $path))); + $path = htmlspecialchars($path, ENT_COMPAT, 'UTF-8'); + $app->enqueueMessage(JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', $path), 'error'); + } + foreach ($safePaths as $path) + { $fullPath = JPath::clean(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path))); $object_file = new JObject(array('filepath' => $fullPath)); @@ -269,12 +279,9 @@ public function delete() // Trigger the onContentAfterDelete event. $dispatcher->trigger('onContentAfterDelete', array('com_media.file', &$object_file)); - $this->setMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); - - continue; + $app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); } - - if (is_dir($object_file->filepath)) + elseif (is_dir($object_file->filepath)) { $contents = JFolder::files($object_file->filepath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html')); @@ -299,11 +306,11 @@ public function delete() continue; } - $ret &= JFolder::delete($object_file->filepath); + $ret &= !JFolder::delete($object_file->filepath); // Trigger the onContentAfterDelete event. $dispatcher->trigger('onContentAfterDelete', array('com_media.folder', &$object_file)); - $this->setMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); + $app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); } } diff --git a/administrator/components/com_media/controllers/folder.php b/administrator/components/com_media/controllers/folder.php index 4841d82d2f52f..ddcffe4ff1e1b 100644 --- a/administrator/components/com_media/controllers/folder.php +++ b/administrator/components/com_media/controllers/folder.php @@ -63,77 +63,82 @@ public function delete() return false; } + // Need this to enqueue messages. + $app = JFactory::getApplication(); + // Set FTP credentials, if given JClientHelper::setCredentialsFromRequest('ftp'); - $ret = true; - JPluginHelper::importPlugin('content'); $dispatcher = JEventDispatcher::getInstance(); - if (count($paths)) + $ret = true; + + $safePaths = array_intersect($paths, array_map(array('JFile', 'makeSafe'), $paths)); + $unsafePaths = array_diff($paths, $safePaths); + + foreach ($unsafePaths as $path) + { + $path = JPath::clean(implode(DIRECTORY_SEPARATOR, array($folder, $path))); + $path = htmlspecialchars($path, ENT_COMPAT, 'UTF-8'); + $app->enqueueMessage(JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', $path), 'error'); + } + + foreach ($safePaths as $path) { - foreach ($paths as $path) + $fullPath = JPath::clean(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path))); + $object_file = new JObject(array('filepath' => $fullPath)); + + if (is_file($object_file->filepath)) { - if ($path !== JFile::makeSafe($path)) + // Trigger the onContentBeforeDelete event. + $result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.file', &$object_file)); + + if (in_array(false, $result, true)) { - $dirname = htmlspecialchars($path, ENT_COMPAT, 'UTF-8'); - JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_WARNDIRNAME', substr($dirname, strlen(COM_MEDIA_BASE)))); + // There are some errors in the plugins + $errors = $object_file->getErrors(); + JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('
', $errors))); + continue; } - $fullPath = JPath::clean(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path))); - $object_file = new JObject(array('filepath' => $fullPath)); + $ret &= JFile::delete($object_file->filepath); - if (is_file($object_file->filepath)) + // Trigger the onContentAfterDelete event. + $dispatcher->trigger('onContentAfterDelete', array('com_media.file', &$object_file)); + $app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); + } + elseif (is_dir($object_file->filepath)) + { + $contents = JFolder::files($object_file->filepath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html')); + + if (!empty($contents)) { - // Trigger the onContentBeforeDelete event. - $result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.file', &$object_file)); - - if (in_array(false, $result, true)) - { - // There are some errors in the plugins - $errors = $object_file->getErrors(); - JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('
', $errors))); - continue; - } - - $ret &= JFile::delete($object_file->filepath); - - // Trigger the onContentAfterDelete event. - $dispatcher->trigger('onContentAfterDelete', array('com_media.file', &$object_file)); - $this->setMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); + // This makes no sense... + $folderPath = substr($object_file->filepath, strlen(COM_MEDIA_BASE)); + JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY', $folderPath)); + + continue; } - elseif (is_dir($object_file->filepath)) + + // Trigger the onContentBeforeDelete event. + $result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.folder', &$object_file)); + + if (in_array(false, $result, true)) { - $contents = JFolder::files($object_file->filepath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html')); - - if (empty($contents)) - { - // Trigger the onContentBeforeDelete event. - $result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.folder', &$object_file)); - - if (in_array(false, $result, true)) - { - // There are some errors in the plugins - $errors = $object_file->getErrors(); - JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('
', $errors))); - continue; - } - - $ret &= !JFolder::delete($object_file->filepath); - - // Trigger the onContentAfterDelete event. - $dispatcher->trigger('onContentAfterDelete', array('com_media.folder', &$object_file)); - $this->setMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); - } - else - { - // This makes no sense... - $folderPath = substr($object_file->filepath, strlen(COM_MEDIA_BASE)); - JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY', $folderPath)); - } + // There are some errors in the plugins + $errors = $object_file->getErrors(); + JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('
', $errors))); + + continue; } + + $ret &= !JFolder::delete($object_file->filepath); + + // Trigger the onContentAfterDelete event. + $dispatcher->trigger('onContentAfterDelete', array('com_media.folder', &$object_file)); + $app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE)))); } } diff --git a/administrator/components/com_media/views/medialist/tmpl/details.php b/administrator/components/com_media/views/medialist/tmpl/details.php index c17b907deaa58..fa6cd1fa9b91b 100644 --- a/administrator/components/com_media/views/medialist/tmpl/details.php +++ b/administrator/components/com_media/views/medialist/tmpl/details.php @@ -8,13 +8,46 @@ */ defined('_JEXEC') or die; -$user = JFactory::getUser(); $params = JComponentHelper::getParams('com_media'); $path = 'file_path'; JHtml::_('jquery.framework'); +JHtml::_('behavior.core'); -JFactory::getDocument()->addScriptDeclaration( +$doc = JFactory::getDocument(); + +// Need to override this core function because we use a different form id +$doc->addScriptDeclaration( + " + Joomla.isChecked = function( isitchecked, form ) { + if ( typeof form === 'undefined' ) { + form = document.getElementById( 'mediamanager-form' ); + } + + form.boxchecked.value += isitchecked ? 1 : -1; + + // If we don't have a checkall-toggle, done. + if ( !form.elements[ 'checkall-toggle' ] ) return; + + // Toggle main toggle checkbox depending on checkbox selection + var c = true, + i, e, n; + + for ( i = 0, n = form.elements.length; i < n; i++ ) { + e = form.elements[ i ]; + + if ( e.type == 'checkbox' && e.name != 'checkall-toggle' && !e.checked ) { + c = false; + break; + } + } + + form.elements[ 'checkall-toggle' ].checked = c; + }; + " +); + +$doc->addScriptDeclaration( " jQuery(document).ready(function($){ window.parent.document.updateUploader(); @@ -52,55 +85,46 @@

- state->folder != '') : ?> - get($path, 'images') . '/' . $this->state->folder; ?> - - get($path, 'images'); ?> - + get($path, 'images'), + ($this->state->folder != '') ? '/' . $this->state->folder : ''; + ?>

- - - - - - - - authorise('core.delete', 'com_media')):?> - - - - - - loadTemplate('up'); ?> - - folders); $i < $n; $i++) : - $this->setFolder($i); - echo $this->loadTemplate('folder'); - endfor; ?> - - documents); $i < $n; $i++) : - $this->setDoc($i); - echo $this->loadTemplate('doc'); - endfor; ?> - - videos); $i < $n; $i++) : - $this->setVideo($i); - echo $this->loadTemplate('video'); - endfor; ?> - - images); $i < $n; $i++) : - $this->setImage($i); - echo $this->loadTemplate('img'); - endfor; ?> - - -
+ + + + + + + + + canDelete) : ?> + + + + + + loadTemplate('up'), + $this->loadTemplate('folders'), + $this->loadTemplate('docs'), + $this->loadTemplate('videos'), + $this->loadTemplate('imgs'); + ?> + +
+ + +
+
+ + - diff --git a/administrator/components/com_media/views/medialist/tmpl/details_doc.php b/administrator/components/com_media/views/medialist/tmpl/details_doc.php deleted file mode 100644 index f75420636886b..0000000000000 --- a/administrator/components/com_media/views/medialist/tmpl/details_doc.php +++ /dev/null @@ -1,42 +0,0 @@ -trigger('onContentBeforeDisplay', array('com_media.file', &$this->_tmp_doc, &$params)); -?> - - - - - _tmp_doc->icon_16, $this->_tmp_doc->title, null, true, true) ? JHtml::_('image', $this->_tmp_doc->icon_16, $this->_tmp_doc->title, array('width' => 16, 'height' => 16), true) : JHtml::_('image', 'media/con_info.png', $this->_tmp_doc->title, array('width' => 16, 'height' => 16), true);?> - - - _tmp_doc->title; ?> - -   - - - - _tmp_doc->size); ?> - -authorise('core.delete', 'com_media')):?> - - - - - - -trigger('onContentAfterDisplay', array('com_media.file', &$this->_tmp_doc, &$params)); diff --git a/administrator/components/com_media/views/medialist/tmpl/details_docs.php b/administrator/components/com_media/views/medialist/tmpl/details_docs.php new file mode 100644 index 0000000000000..7a126f00d9462 --- /dev/null +++ b/administrator/components/com_media/views/medialist/tmpl/details_docs.php @@ -0,0 +1,49 @@ + + +documents as $i => $doc) : ?> + trigger('onContentBeforeDisplay', array('com_media.file', &$doc, &$params)); ?> + + + + icon_16, $doc->title, null, true, true) ? JHtml::_('image', $doc->icon_16, $doc->title, array('width' => 16, 'height' => 16), true) : JHtml::_('image', 'media/con_info.png', $doc->title, array('width' => 16, 'height' => 16), true); ?> + + + + + title; ?> + + +   + + + size); ?> + + + canDelete) : ?> + + + + + name, false, 'rm', 'cb-document'); ?> + + + + + trigger('onContentAfterDisplay', array('com_media.file', &$doc, &$params)); ?> + diff --git a/administrator/components/com_media/views/medialist/tmpl/details_folder.php b/administrator/components/com_media/views/medialist/tmpl/details_folder.php deleted file mode 100644 index 8f2467c9699fe..0000000000000 --- a/administrator/components/com_media/views/medialist/tmpl/details_folder.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - _tmp_folder->name; ?> - -   - - -   - - - authorise('core.delete', 'com_media')):?> - - - - - - diff --git a/administrator/components/com_media/views/medialist/tmpl/details_folders.php b/administrator/components/com_media/views/medialist/tmpl/details_folders.php new file mode 100644 index 0000000000000..526286fbfbb99 --- /dev/null +++ b/administrator/components/com_media/views/medialist/tmpl/details_folders.php @@ -0,0 +1,38 @@ + + +folders as $i => $folder) : ?> + path_relative; ?> + + + + + + + name; ?> + + +   + +   + + canDelete) : ?> + + + + + name, false, 'rm', 'cb-folder'); ?> + + + + diff --git a/administrator/components/com_media/views/medialist/tmpl/details_img.php b/administrator/components/com_media/views/medialist/tmpl/details_img.php deleted file mode 100644 index fab73ddd9d32f..0000000000000 --- a/administrator/components/com_media/views/medialist/tmpl/details_img.php +++ /dev/null @@ -1,42 +0,0 @@ -trigger('onContentBeforeDisplay', array('com_media.file', &$this->_tmp_img, &$params)); -?> - - - - _tmp_img->path_relative, JText::sprintf('COM_MEDIA_IMAGE_TITLE', $this->_tmp_img->title, JHtml::_('number.bytes', $this->_tmp_img->size)), array('width' => $this->_tmp_img->width_16, 'height' => $this->_tmp_img->height_16)); ?> - - - escape($this->_tmp_img->title); ?> - - - _tmp_img->width, $this->_tmp_img->height); ?> - - - _tmp_img->size); ?> - - authorise('core.delete', 'com_media')):?> - - - - - - -trigger('onContentAfterDisplay', array('com_media.file', &$this->_tmp_img, &$params)); diff --git a/administrator/components/com_media/views/medialist/tmpl/details_imgs.php b/administrator/components/com_media/views/medialist/tmpl/details_imgs.php new file mode 100644 index 0000000000000..1f2727542db41 --- /dev/null +++ b/administrator/components/com_media/views/medialist/tmpl/details_imgs.php @@ -0,0 +1,54 @@ + + +images as $i => $image) : ?> + trigger('onContentBeforeDisplay', array('com_media.file', &$image, &$params)); ?> + + + + path_relative, JText::sprintf('COM_MEDIA_IMAGE_TITLE', $image->title, JHtml::_('number.bytes', $image->size)), array('width' => $image->width_16, 'height' => $image->height_16)); ?> + + + + + + escape($image->title); ?> + + + + + width, $image->height); ?> + + + + size); ?> + + + canDelete) : ?> + + + + + name, false, 'rm', 'cb-image'); ?> + + + + trigger('onContentAfterDisplay', array('com_media.file', &$image, &$params)); ?> + diff --git a/administrator/components/com_media/views/medialist/tmpl/details_video.php b/administrator/components/com_media/views/medialist/tmpl/details_video.php deleted file mode 100644 index 7cc7e71f1177e..0000000000000 --- a/administrator/components/com_media/views/medialist/tmpl/details_video.php +++ /dev/null @@ -1,54 +0,0 @@ -trigger('onContentBeforeDisplay', array('com_media.file', &$this->_tmp_video, &$params)); - -JFactory::getDocument()->addScriptDeclaration(" -jQuery(document).ready(function($){ - window.parent.jQuery('#videoPreview').on('hidden', function () { - window.parent.jQuery('#mejsPlayer')[0].player.pause(); - }); -}); -"); -?> - - - - _tmp_video->icon_16, $this->_tmp_video->title, null, true); ?> - - - - _tmp_video->name, 10, false); ?> - - - - - - - _tmp_video->size); ?> - - authorise('core.delete', 'com_media')):?> - - - - - - - -trigger('onContentAfterDisplay', array('com_media.file', &$this->_tmp_video, &$params)); diff --git a/administrator/components/com_media/views/medialist/tmpl/details_videos.php b/administrator/components/com_media/views/medialist/tmpl/details_videos.php new file mode 100644 index 0000000000000..a7980c0bac40b --- /dev/null +++ b/administrator/components/com_media/views/medialist/tmpl/details_videos.php @@ -0,0 +1,62 @@ +addScriptDeclaration(" +jQuery(document).ready(function($){ + window.parent.jQuery('#videoPreview').on('hidden', function () { + window.parent.jQuery('#mejsPlayer')[0].player.pause(); + }); +}); +"); +?> + +videos as $i => $video) : ?> + trigger('onContentBeforeDisplay', array('com_media.file', &$video, &$params)); ?> + + + + icon_16, $video->title, null, true); ?> + + + + + + name, 10, false); ?> + + + + + + + + + size); ?> + + + canDelete) : ?> + + + + + name, false, 'rm', 'cb-video'); ?> + + + + + trigger('onContentAfterDisplay', array('com_media.file', &$video, &$params)); ?> + diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs.php b/administrator/components/com_media/views/medialist/tmpl/thumbs.php index 7a2de699ad51d..a3eefc89de627 100644 --- a/administrator/components/com_media/views/medialist/tmpl/thumbs.php +++ b/administrator/components/com_media/views/medialist/tmpl/thumbs.php @@ -12,8 +12,42 @@ $path = 'file_path'; JHtml::_('jquery.framework'); +JHtml::_('behavior.core'); -JFactory::getDocument()->addScriptDeclaration( +$doc = JFactory::getDocument(); + +// Need to override this core function because we use a different form id +$doc->addScriptDeclaration( + " + Joomla.isChecked = function( isitchecked, form ) { + if ( typeof form === 'undefined' ) { + form = document.getElementById( 'mediamanager-form' ); + } + + form.boxchecked.value += isitchecked ? 1 : -1; + + // If we don't have a checkall-toggle, done. + if ( !form.elements[ 'checkall-toggle' ] ) return; + + // Toggle main toggle checkbox depending on checkbox selection + var c = true, + i, e, n; + + for ( i = 0, n = form.elements.length; i < n; i++ ) { + e = form.elements[ i ]; + + if ( e.type == 'checkbox' && e.name != 'checkall-toggle' && !e.checked ) { + c = false; + break; + } + } + + form.elements[ 'checkall-toggle' ].checked = c; + }; + " +); + +$doc->addScriptDeclaration( " jQuery(document).ready(function($){ window.parent.document.updateUploader(); @@ -51,42 +85,34 @@

- state->folder != '') : ?> - get($path, 'images') . '/' . $this->state->folder; ?> - - get($path, 'images'); ?> - + get($path, 'images'), + ($this->state->folder != '') ? '/' . $this->state->folder : ''; + ?>

+
+ +
+ diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs_doc.php b/administrator/components/com_media/views/medialist/tmpl/thumbs_doc.php deleted file mode 100644 index 146f250cbcc56..0000000000000 --- a/administrator/components/com_media/views/medialist/tmpl/thumbs_doc.php +++ /dev/null @@ -1,34 +0,0 @@ -trigger('onContentBeforeDisplay', array('com_media.file', &$this->_tmp_doc, &$params)); -?> - -
  • - authorise('core.delete', 'com_media')):?> - × - -
    - -
    - - _tmp_doc->icon_32, $this->_tmp_doc->name, null, true, true) ? JHtml::_('image', $this->_tmp_doc->icon_32, $this->_tmp_doc->title, null, true) : JHtml::_('image', 'media/con_info.png', $this->_tmp_doc->name, null, true); ?> -
    -
    - _tmp_doc->name, 10, false); ?> -
    -
  • -trigger('onContentAfterDisplay', array('com_media.file', &$this->_tmp_doc, &$params)); diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs_docs.php b/administrator/components/com_media/views/medialist/tmpl/thumbs_docs.php new file mode 100644 index 0000000000000..3c9c4940ea8a4 --- /dev/null +++ b/administrator/components/com_media/views/medialist/tmpl/thumbs_docs.php @@ -0,0 +1,40 @@ + + +documents as $i => $doc) : ?> + trigger('onContentBeforeDisplay', array('com_media.file', &$doc, &$params)); ?> +
  • + canDelete) : ?> + × +
    + name, false, 'rm', 'cb-document'); ?> +
    +
    + + +
    + + icon_32, $doc->name, null, true, true) ? JHtml::_('image', $doc->icon_32, $doc->title, null, true) : JHtml::_('image', 'media/con_info.png', $doc->name, null, true); ?> + +
    + +
    + name, 10, false); ?> +
    +
  • + trigger('onContentAfterDisplay', array('com_media.file', &$doc, &$params)); ?> + diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs_folder.php b/administrator/components/com_media/views/medialist/tmpl/thumbs_folder.php deleted file mode 100644 index 113073dd5430c..0000000000000 --- a/administrator/components/com_media/views/medialist/tmpl/thumbs_folder.php +++ /dev/null @@ -1,28 +0,0 @@ - -
  • - authorise('core.delete', 'com_media')):?> - × - -
    - -
    - - - -
    -
    - _tmp_folder->name, 10, false); ?> -
    -
  • diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs_folders.php b/administrator/components/com_media/views/medialist/tmpl/thumbs_folders.php new file mode 100644 index 0000000000000..31cf6eb08b20c --- /dev/null +++ b/administrator/components/com_media/views/medialist/tmpl/thumbs_folders.php @@ -0,0 +1,35 @@ + +folders as $i => $folder) : ?> +
  • + canDelete):?> + × +
    + name, false, 'rm', 'cb-folder'); ?> +
    +
    + + +
    + + + +
    + +
    + + name, 10, false); ?> + +
    +
  • + diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs_img.php b/administrator/components/com_media/views/medialist/tmpl/thumbs_img.php deleted file mode 100644 index 7206239e652e4..0000000000000 --- a/administrator/components/com_media/views/medialist/tmpl/thumbs_img.php +++ /dev/null @@ -1,37 +0,0 @@ -trigger('onContentBeforeDisplay', array('com_media.file', &$this->_tmp_img, &$params)); -?> - -
  • - authorise('core.delete', 'com_media')):?> - × - -
    - -
    - - _tmp_img->path_relative, JText::sprintf('COM_MEDIA_IMAGE_TITLE', $this->_tmp_img->title, JHtml::_('number.bytes', $this->_tmp_img->size)), array('width' => $this->_tmp_img->width_60, 'height' => $this->_tmp_img->height_60)); ?> - -
    -
    - _tmp_img->name, 10, false); ?> -
    -
  • -trigger('onContentAfterDisplay', array('com_media.file', &$this->_tmp_img, &$params)); diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs_imgs.php b/administrator/components/com_media/views/medialist/tmpl/thumbs_imgs.php new file mode 100644 index 0000000000000..8a06417c52ea9 --- /dev/null +++ b/administrator/components/com_media/views/medialist/tmpl/thumbs_imgs.php @@ -0,0 +1,44 @@ + + +images as $i => $img) : ?> + trigger('onContentBeforeDisplay', array('com_media.file', &$img, &$params)); ?> +
  • + canDelete):?> + × +
    + name, false, 'rm', 'cb-image'); ?> +
    +
    + + +
    + + path_relative, JText::sprintf('COM_MEDIA_IMAGE_TITLE', $img->title, JHtml::_('number.bytes', $img->size)), array('width' => $img->width_60, 'height' => $img->height_60)); ?> + +
    + +
    + + name, 10, false); ?> + +
    +
  • + trigger('onContentAfterDisplay', array('com_media.file', &$img, &$params)); ?> + diff --git a/administrator/components/com_media/views/medialist/tmpl/thumbs_video.php b/administrator/components/com_media/views/medialist/tmpl/thumbs_videos.php similarity index 51% rename from administrator/components/com_media/views/medialist/tmpl/thumbs_video.php rename to administrator/components/com_media/views/medialist/tmpl/thumbs_videos.php index e479e50687e8a..4676a5837116b 100644 --- a/administrator/components/com_media/views/medialist/tmpl/thumbs_video.php +++ b/administrator/components/com_media/views/medialist/tmpl/thumbs_videos.php @@ -11,10 +11,8 @@ use Joomla\Registry\Registry; -$user = JFactory::getUser(); $params = new Registry; $dispatcher = JEventDispatcher::getInstance(); -$dispatcher->trigger('onContentBeforeDisplay', array('com_media.file', &$this->_tmp_video, &$params)); JFactory::getDocument()->addScriptDeclaration(" jQuery(document).ready(function($){ @@ -24,22 +22,26 @@ }); "); ?> - +videos as $i => $video) : ?> + trigger('onContentBeforeDisplay', array('com_media.file', &$video, &$params)); ?>
  • - authorise('core.delete', 'com_media')):?> - × - + canDelete):?> + × +
    + name, false, 'rm', 'cb-video'); ?> +
    +
    - _tmp_video->icon_32, $this->_tmp_video->title, null, true); ?> + icon_32, $video->title, null, true); ?>
    +
    - - _tmp_video->name, 10, false); ?> + + name, 10, false); ?>
  • -trigger('onContentAfterDisplay', array('com_media.file', &$this->_tmp_video, &$params)); + trigger('onContentAfterDisplay', array('com_media.file', &$video, &$params)); ?> + diff --git a/administrator/components/com_media/views/medialist/view.html.php b/administrator/components/com_media/views/medialist/view.html.php index 80c1c1a9c88f6..5eb3186223169 100644 --- a/administrator/components/com_media/views/medialist/view.html.php +++ b/administrator/components/com_media/views/medialist/view.html.php @@ -37,14 +37,14 @@ public function display($tpl = null) // Do not allow cache $app->allowCache(false); - $images = $this->get('images'); - $documents = $this->get('documents'); - $folders = $this->get('folders'); - $videos = $this->get('videos'); - $state = $this->get('state'); + $this->images = $this->get('images'); + $this->documents = $this->get('documents'); + $this->folders = $this->get('folders'); + $this->videos = $this->get('videos'); + $this->state = $this->get('state'); // Check for invalid folder name - if (empty($state->folder)) + if (empty($this->state->folder)) { $dirname = JFactory::getApplication()->input->getPath('folder', ''); @@ -55,97 +55,9 @@ public function display($tpl = null) } } - $this->baseURL = JUri::root(); - $this->images = &$images; - $this->documents = &$documents; - $this->folders = &$folders; - $this->state = &$state; - $this->videos = &$videos; + $user = JFactory::getUser(); + $this->canDelete = $user->authorise('core.delete', 'com_media'); parent::display($tpl); } - - /** - * Set the active folder - * - * @param integer $index Folder position - * - * @return void - * - * @since 1.0 - */ - public function setFolder($index = 0) - { - if (isset($this->folders[$index])) - { - $this->_tmp_folder = &$this->folders[$index]; - } - else - { - $this->_tmp_folder = new JObject; - } - } - - /** - * Set the active image - * - * @param integer $index Image position - * - * @return void - * - * @since 1.0 - */ - public function setImage($index = 0) - { - if (isset($this->images[$index])) - { - $this->_tmp_img = &$this->images[$index]; - } - else - { - $this->_tmp_img = new JObject; - } - } - - /** - * Set the active doc - * - * @param integer $index Doc position - * - * @return void - * - * @since 1.0 - */ - public function setDoc($index = 0) - { - if (isset($this->documents[$index])) - { - $this->_tmp_doc = &$this->documents[$index]; - } - else - { - $this->_tmp_doc = new JObject; - } - } - - /** - * Set the active video - * - * @param integer $index Doc position - * - * @return void - * - * @since 3.5 - */ - public function setVideo($index = 0) - { - if (isset($this->videos[$index])) - { - $this->_tmp_video = &$this->videos[$index]; - } - else - { - $this->_tmp_video = new JObject; - } - } }