12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
-
- namespace SCF\Additionals;
-
- class Carousel
- {
-
- /**
- * @var array
- */
- private $picArray = [];
-
- /**
- * @var string
- */
- private $picDirectory;
-
- /**
- * Carousel constructor.
- * @param $directory
- */
- public function __construct($directory)
- {
- $this->picDirectory = $directory;
- $this->setPicArray();
- }
-
- /**
- * SET PICTURE ARRAY
- */
- public function setPicArray()
- {
- $this->picArray = $this->scanDirForFiles();
- }
-
- /**
- * @return array $this->picArray
- */
- public function getPicArray()
- {
- return $this->picArray;
- }
-
- /**
- * @return array $tempArray
- */
- private function scanDirForFiles()
- {
- $tempArray = [];
- $dir = $this->picDirectory;
- if ($handle = opendir($dir)) {
- $shortDir = strstr($dir, 'Styles');
- while (($file = readdir($handle)) !== false) {
- if (!in_array($file, array(".", "..")) && !is_dir($dir . $file)) {
- $tempArray[] = $shortDir . $file;
- }
-
- }
- }
-
- return $tempArray;
-
- }
- }
|