Source for file directories.php

Documentation is available at directories.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_finder
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_BASE'or die;
  11.  
  12.  
  13. // Load the base adapter.
  14. require_once JPATH_ADMINISTRATOR '/components/com_finder/helpers/indexer/adapter.php';
  15.  
  16. /**
  17.  * Renders a list of directories.
  18.  *
  19.  * @package     Joomla.Administrator
  20.  * @subpackage  com_finder
  21.  * @since       2.5
  22.  */
  23. {
  24.     /**
  25.      * The form field type.
  26.      *
  27.      * @var    string 
  28.      * @since  2.5
  29.      */
  30.     protected $type = 'Directories';
  31.  
  32.     /**
  33.      * Method to get the field options.
  34.      *
  35.      * @return  array  The field option objects.
  36.      *
  37.      * @since   2.5
  38.      */
  39.     public function getOptions()
  40.     {
  41.         $values array();
  42.         $options array();
  43.         $exclude array(
  44.             JPATH_ADMINISTRATOR,
  45.             JPATH_INSTALLATION,
  46.             JPATH_LIBRARIES,
  47.             JPATH_PLUGINS,
  48.             JPATH_SITE '/cache',
  49.             JPATH_SITE '/components',
  50.             JPATH_SITE '/includes',
  51.             JPATH_SITE '/language',
  52.             JPATH_SITE '/modules',
  53.             JPATH_THEMES,
  54.             JFactory::getApplication()->getCfg('log_path'),
  55.             JFactory::getApplication()->getCfg('tmp_path')
  56.         );
  57.  
  58.         // Get the base directories.
  59.         jimport('joomla.filesystem.folder');
  60.         $dirs JFolder::folders(JPATH_SITE'.'falsetrue);
  61.  
  62.         // Iterate through the base directories and find the subdirectories.
  63.         foreach ($dirs as $dir)
  64.         {
  65.             // Check if the directory should be excluded.
  66.             if (in_array($dir$exclude))
  67.             {
  68.                 continue;
  69.             }
  70.  
  71.             // Get the child directories.
  72.             $return JFolder::folders($dir'.'truetrue);
  73.  
  74.             // Merge the directories.
  75.             if (is_array($return))
  76.             {
  77.                 $values[$dir;
  78.                 $values array_merge($values$return);
  79.             }
  80.         }
  81.  
  82.         // Convert the values to options.
  83.         foreach ($values as $value)
  84.         {
  85.             $options[JHtml::_('select.option'str_replace(JPATH_SITE '/'''$value)str_replace(JPATH_SITE '/'''$values));
  86.         }
  87.  
  88.         // Add a null option.
  89.         array_unshift($optionsJHtml::_('select.option''''- ' JText::_('JNONE'' -'));
  90.  
  91.         return $options;
  92.     }
  93. }

Documentation generated on Tue, 19 Nov 2013 15:01:29 +0100 by phpDocumentor 1.4.3