コード例 #1
0
ファイル: PageLoader.php プロジェクト: joernroeder/pocomd
 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);
 }
コード例 #2
0
 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));
     }
 }