Ejemplo n.º 1
0
 /**
  * On Ajax files
  *
  * @return  void
  */
 public function onAjax_files()
 {
     $this->loadMeForAjax();
     $folder = $this->app->input->get('folder', '', 'string');
     if (!strstr($folder, JPATH_SITE)) {
         $folder = JPATH_SITE . '/' . $folder;
     }
     $pathA = JPath::clean($folder);
     $folder = array();
     $files = array();
     $images = array();
     FabrikWorker::readImages($pathA, "/", $folders, $images, $this->ignoreFolders);
     if (!array_key_exists('/', $images)) {
         $images['/'] = array();
     }
     echo json_encode($images['/']);
 }
Ejemplo n.º 2
0
 /**
  * Internal function to recursive scan directories
  * @param string Path to scan
  * @param string root path of this folder
  * @param array  Value array of all existing folders
  * @param array  Value array of all existing images
  * @param bol make options out for the results
  */
 public function readImages($imagePath, $folderPath, &$folders, &$images, $aFolderFilter, $makeOptions = true)
 {
     $imgFiles = FabrikWorker::fabrikReadDirectory($imagePath, '.', false, false, $aFolderFilter);
     foreach ($imgFiles as $file) {
         $ff_ = $folderPath . $file . '/';
         $ff = $folderPath . $file;
         $i_f = $imagePath . '/' . $file;
         if (is_dir($i_f) && $file != 'CVS' && $file != '.svn') {
             if (!in_array($file, $aFolderFilter)) {
                 $folders[] = JHTML::_('select.option', $ff_);
                 FabrikWorker::readImages($i_f, $ff_, $folders, $images, $aFolderFilter);
             }
         } else {
             if (preg_match('/bmp|gif|jpg|png/i', $file) && is_file($i_f)) {
                 // leading / we don't need
                 $imageFile = substr($ff, 1);
                 $images[$folderPath][] = $makeOptions ? JHTML::_('select.option', $imageFile, $file) : $file;
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  *
  */
 function getAdminLists(&$lists)
 {
     /**
      * IMPORTANT NOTE FOR HACKERS!
      * 	if your images folder contains massive sub directories which you dont want fabrik
      * accessing (and hance slowing down to a crawl the loading of this page)
      * then put the folders in the $ignoreFolders array
      */
     $params = $this->getParams();
     $images = array();
     $folders = array();
     $path = $params->get('imagepath', '/');
     $file = $params->get('imagefile');
     $folders[] = JHTML::_('select.option', '/', '/');
     FabrikWorker::readImages(JPATH_SITE, "/", $folders, $images, $this->ignoreFolders);
     $lists['folders'] = JHTML::_('select.genericlist', $folders, 'params[imagepath]', 'class="inputbox" size="1" ', 'value', 'text', $path);
     $javascript = "onchange=\"previewImage()\" onfocus=\"previewImage()\"";
     $is = JArrayHelper::getValue($images, $path, array());
     $lists['imagefiles'] = JHTML::_('select.genericlist', $is, 'params[imagefile]', 'class="inputbox" size="10" multiple="multiple" ' . $javascript, 'value', 'text', $file);
     $defRootFolder = $params->get('selectImage_root_folder', '');
     $lists['selectImage_root_folder'] = JHTML::_('select.genericlist', $folders, 'params[selectImage_root_folder]', "class=\"inputbox\"  size=\"1\" ", 'value', 'text', $defRootFolder);
 }