Exemple #1
0
 /**
  * Read's all images from folder
  * @param <string> $targetFolder
  * @param <string> $arrange
  * @return <array> Sorted array of pictures
  */
 public static function ag_imageArrayFromFolder($targetFolder)
 {
     $images = array();
     if (!agHelper::ag_exists($targetFolder)) {
         return null;
     }
     $dh = opendir($targetFolder);
     if ($dh) {
         $ag_ext_valid = array("jpg", "jpeg", "gif", "png");
         // SET VALID IMAGE EXTENSION
         while (($f = readdir($dh)) !== false) {
             if (is_numeric(array_search(strtolower(agHelper::ag_getExtension(basename($f))), $ag_ext_valid))) {
                 $images[] = $f;
             }
         }
     }
     closedir($dh);
     return $images;
 }
Exemple #2
0
 /**
  *  Reads description files
  */
 private function readDescriptionFiles()
 {
     // Create Images Array
     unset($this->descArray);
     if (file_exists($this->imagesFolderPhysicalPath)) {
         $ag_images = array();
         $ag_files = JFolder::files($this->imagesFolderPhysicalPath);
         $ag_ext_valid = array("jpg", "jpeg", "gif", "png");
         // SET VALID IMAGE EXTENSION
         foreach ($ag_files as $key => $value) {
             if (is_numeric(array_search(strtolower(agHelper::ag_getExtension(basename($value))), $ag_ext_valid))) {
                 $ag_images[] = $value;
             }
         }
         $ag_files = array_merge($ag_images, JFolder::folders($this->imagesFolderPhysicalPath));
         if (!empty($ag_files)) {
             foreach ($ag_files as $key => $f) {
                 // Set image name as imageDescription value, as predifined value
                 $this->descArray[$f] = $f;
                 // Set Possible Description File Apsolute Path // Instant patch for upper and lower case...
                 $ag_pathWithStripExt = $this->imagesFolderPhysicalPath . agHelper::ag_removExtension($f);
                 $descriptionFileApsolutePath = $ag_pathWithStripExt . ".XML";
                 if (file_exists($ag_pathWithStripExt . ".xml")) {
                     $descriptionFileApsolutePath = $ag_pathWithStripExt . ".xml";
                 }
                 if (file_exists($descriptionFileApsolutePath)) {
                     // Check is descriptions file exists
                     $ag_imgXML_xml = JFactory::getXML($descriptionFileApsolutePath);
                     $ag_imgXML_captions = $ag_imgXML_xml->captions;
                     $lang = JFactory::getLanguage();
                     $langTag = strtolower($lang->getTag());
                     // GET DEFAULT LABEL
                     if (!empty($ag_imgXML_captions->caption)) {
                         foreach ($ag_imgXML_captions->caption as $ag_imgXML_caption) {
                             if (strtolower($ag_imgXML_caption->attributes()->lang->data()) == "default") {
                                 $this->descArray[$f] = $ag_imgXML_caption->data();
                             }
                         }
                     }
                     // GET CURRENT LANG LABEL
                     if (!empty($ag_imgXML_captions->caption)) {
                         foreach ($ag_imgXML_captions->caption as $ag_imgXML_caption) {
                             if (strtolower($ag_imgXML_caption->attributes()->lang->data()) == strtolower($langTag)) {
                                 $this->descArray[$f] = $ag_imgXML_caption->data();
                             }
                         }
                     }
                     // RICH TEXT SUPPORT
                     if ($this->params['plainTextCaptions']) {
                         $this->descArray[$f] = strip_tags($this->descArray[$f]);
                     }
                 }
             }
         }
         // if(file_exists($descriptionFileApsolutePath))
     } else {
         $this->descArray = null;
     }
 }