/** * Get Skin's Page Templates * @param boolean $reload * @return array */ public function getTemplates($reload = false) { if (!is_array($this->templates) || $reload) { $this->templates = array(); $order = array(); $tplDir = $this->checkDir('tpl/pages/'); if (!empty($tplDir)) { // Scan Directories foreach (glob($tplDir . '*', GLOB_ONLYDIR | GLOB_MARK) as $dir) { $config = $dir . 'config.json'; if (file_exists($config)) { $template = new Page_Template($dir); $this->templates[$template->getName()] = $template; $order[$template->getName()] = $template->getOrder(); } else { // Scan Sub-Directories foreach (glob($dir . '*', GLOB_ONLYDIR | GLOB_MARK) as $dir) { $config = $dir . 'config.json'; if (file_exists($config)) { $template = new Page_Template($dir); $this->templates[$template->getName()] = $template; $order[$template->getName()] = $template->getOrder(); } } } } } // Re-Order Templates array_multisort($order, SORT_ASC, $this->templates); } return $this->templates; }