public function __construct($config, $name, $folderName = null) { parent::__construct($config); $this->name = $name; $folderName = $folderName ? $folderName : $name; $this->folder = $this->path . '/' . strtolower($folderName); $this->parser = $this->createParser($this->folder); }
public function __construct($config) { parent::__construct($config); $cacheKey = $this->getCacheKey(); // check cache if ($this->isCacheEnabled() && ($cache = $this->loadCache(-1, $cacheKey))) { $this->folderMap = (array) $cache->data; return; } foreach (new \DirectoryIterator($this->folder) as $file) { if ($file->isDot()) { continue; } if ($file->isDir()) { $dirName = $file->getFilename(); $indexGiven = preg_match('/(\\d+)\\-/', $dirName, $matches); if ($indexGiven) { $index = (int) $matches[1]; // index already exists. finding the next free slot ... while (isset($this->folderMap[$index])) { $index++; } $this->folderMap[$index] = $this->createFolder($dirName, str_replace($matches[0], '', $dirName)); sort($this->folderMap); } else { $this->folderMap[] = $this->createFolder($dirName, $dirName); } } } sort($this->folderMap); if ($this->config->get('navigation.sortreverse')) { krsort($this->folderMap); } if ($this->isCacheEnabled()) { $this->saveToCache($this->folderMap, (object) array('lastModified' => -1, 'sha1Hash' => $cacheKey)); } }