BcUtil::getTemplateList PHP Method

getTemplateList() public static method

レイアウトテンプレートのリストを取得する
public static getTemplateList ( string $path, string $plugin, string $theme ) : array
$path string
$plugin string
$theme string
return array
    public static function getTemplateList($path, $plugin, $theme)
    {
        if ($plugin) {
            $templatesPathes = App::path('View', $plugin);
        } else {
            $templatesPathes = App::path('View');
            if ($theme) {
                array_unshift($templatesPathes, WWW_ROOT . 'theme' . DS . $theme . DS);
            }
        }
        $_templates = array();
        foreach ($templatesPathes as $templatesPath) {
            $templatesPath .= $path . DS;
            $folder = new Folder($templatesPath);
            $files = $folder->read(true, true);
            $foler = null;
            if ($files[1]) {
                if ($_templates) {
                    $_templates = array_merge($_templates, $files[1]);
                } else {
                    $_templates = $files[1];
                }
            }
        }
        $templates = array();
        foreach ($_templates as $template) {
            $ext = Configure::read('BcApp.templateExt');
            if ($template != 'installations' . $ext) {
                $template = basename($template, $ext);
                $templates[$template] = $template;
            }
        }
        return $templates;
    }

Usage Example

Example #1
0
 /**
  * フォルダのテンプレートリストを取得する
  *
  * @param $contentId
  * @param $theme
  * @return array
  */
 public function getFolderTemplateList($contentId, $theme)
 {
     $folderTemplates = BcUtil::getTemplateList('ContentFolders', '', $theme);
     if ($contentId != 1) {
         $parentTemplate = $this->getParentTemplate($contentId, 'folder');
         $searchKey = array_search($parentTemplate, $folderTemplates);
         if ($searchKey !== false) {
             unset($folderTemplates[$searchKey]);
         }
         array_unshift($folderTemplates, array('' => '親フォルダの設定に従う(' . $parentTemplate . ')'));
     }
     return $folderTemplates;
 }
All Usage Examples Of BcUtil::getTemplateList