/** * getSortedUuids function. * * @access public * @return array */ public function getSortedUuids() { $arrUuids = $this->arrUuids; $strSortKey = $this->strSortKey; $strSortDirection = 'ASC'; if (preg_match('#^([^_]*)_([a-zA-Z]{3,4})$#', $this->strSortKey, $arrMatches)) { $strSortKey = $arrMatches[1]; $strSortDirection = $arrMatches[2]; } elseif ($this->strSortKey == 'custom') { $arrUuids = $this->arrCustomIds; } $objImageSorter = new \ImageSorter($arrUuids); $objImageSorter->sortImagesBy($strSortKey, $strSortDirection); $arrUuids = $objImageSorter->getImageUuids(); return $arrUuids; }
/** * getRandomPreviewImage function. * * @access protected * @return int */ protected function getRandomPreviewImage() { if (count($this->objAlbum->images) < 1) { return null; } // Deserialize $this->objAlbum->images = deserialize($this->objAlbum->images); // Get all image ids and save them in the images array $objImageSorter = new \ImageSorter($this->objAlbum->images, $GLOBALS['TL_DCA']['tl_photoalbums2_album']['fields']['images']['eval']['extensions']); $this->objAlbum->images = $objImageSorter->getImageUuids(); return $this->objAlbum->images[mt_rand(0, count($this->objAlbum->images) - 1)]; }
public function getSortedImages() { if (!$this->sortfiles) { return false; } // Set arrays $arrSortfiles = array(); // Import $this->import('Database'); $this->import('Files'); // Get Sortfiles $objSortfiles = $this->Database->prepare("SELECT " . $this->sortfiles . " FROM " . $this->strTable . " WHERE id=?")->execute($this->currentRecord); // Fetch $arrSortfiles = $objSortfiles->fetchAssoc(); $arrUuids = deserialize($arrSortfiles[$this->sortfiles]); // Create new object from ImageSorter and get unsorted files $objImageSorter = new ImageSorter($arrUuids, $this->extensions); $objImageSorter->sortImagesBy('custom', 'ASC'); return $objImageSorter->getImageUuids(); }