[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_media/controllers/ -> folder.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: folder.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Media
   6   * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7   * @license        GNU/GPL, see LICENSE.php
   8   * Joomla! is free software. This version may have been modified pursuant to the
   9   * GNU General Public License, and as distributed it includes or is derivative
  10   * of works licensed under the GNU General Public License or other free or open
  11   * source software licenses. See COPYRIGHT.php for copyright notices and
  12   * details.
  13   */
  14  
  15  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  jimport('joomla.filesystem.file');
  19  jimport('joomla.filesystem.folder');
  20  
  21  /**
  22   * Weblinks Weblink Controller
  23   *
  24   * @package        Joomla
  25   * @subpackage    Media
  26   * @since 1.5
  27   */
  28  class MediaControllerFolder extends MediaController
  29  {
  30  
  31      /**
  32       * Deletes paths from the current path
  33       *
  34       * @param string $listFolder The image directory to delete a file from
  35       * @since 1.5
  36       */
  37  	function delete()
  38      {
  39          global $mainframe;
  40  
  41          JRequest::checkToken('request') or jexit( 'Invalid Token' );
  42  
  43          // Set FTP credentials, if given
  44          jimport('joomla.client.helper');
  45          JClientHelper::setCredentialsFromRequest('ftp');
  46  
  47          // Get some data from the request
  48          $tmpl    = JRequest::getCmd( 'tmpl' );
  49          $paths    = JRequest::getVar( 'rm', array(), '', 'array' );
  50          $folder = JRequest::getVar( 'folder', '', '', 'path');
  51  
  52          // Initialize variables
  53          $msg = array();
  54          $ret = true;
  55  
  56          if (count($paths)) {
  57              foreach ($paths as $path)
  58              {
  59                  if ($path !== JFile::makeSafe($path)) {
  60                      JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNDIRNAME'));
  61                      continue;
  62                  }
  63  
  64                  $fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path);
  65                  if (is_file($fullPath)) {
  66                      $ret |= !JFile::delete($fullPath);
  67                  } else if (is_dir($fullPath)) {
  68                      $files = JFolder::files($fullPath, '.', true);
  69                      $canDelete = true;
  70                      foreach ($files as $file) {
  71                          if ($file != 'index.html') {
  72                              $canDelete = false;
  73                          }
  74                      }
  75                      if ($canDelete) {
  76                          $ret |= !JFolder::delete($fullPath);
  77                      } else {
  78                          JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath.' '.JText::_('Not Empty!'));
  79                      }
  80                  }
  81              }
  82          }
  83          if ($tmpl == 'component') {
  84              // We are inside the iframe
  85              $mainframe->redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component');
  86          } else {
  87              $mainframe->redirect('index.php?option=com_media&folder='.$folder);
  88          }
  89      }
  90  
  91      /**
  92       * Create a folder
  93       *
  94       * @param string $path Path of the folder to create
  95       * @since 1.5
  96       */
  97  	function create()
  98      {
  99          global $mainframe;
 100  
 101          // Check for request forgeries
 102          JRequest::checkToken() or jexit( 'Invalid Token' );
 103  
 104          // Set FTP credentials, if given
 105          jimport('joomla.client.helper');
 106          JClientHelper::setCredentialsFromRequest('ftp');
 107  
 108          $folder            = JRequest::getCmd( 'foldername', '');
 109          $folderCheck    = JRequest::getVar( 'foldername', null, '', 'string', JREQUEST_ALLOWRAW);
 110          $parent            = JRequest::getVar( 'folderbase', '', '', 'path' );
 111  
 112          JRequest::setVar('folder', $parent);
 113  
 114          if (($folderCheck !== null) && ($folder !== $folderCheck)) {
 115              $mainframe->redirect('index.php?option=com_media&folder='.$parent, JText::_('WARNDIRNAME'));
 116          }
 117  
 118          if (strlen($folder) > 0) {
 119              $path = JPath::clean(COM_MEDIA_BASE.DS.$parent.DS.$folder);
 120              if (!is_dir($path) && !is_file($path))
 121              {
 122                  jimport('joomla.filesystem.*');
 123                  JFolder::create($path);
 124                  JFile::write($path.DS."index.html", "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>");
 125              }
 126              JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder);
 127          }
 128          $mainframe->redirect('index.php?option=com_media&folder='.$parent);
 129      }
 130  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1