예제 #1
0
 /**
  *
  * @static
  * @return array
  */
 public static function collect()
 {
     if (null === self::$_collection) {
         $themes = Axis_Collect_Theme::collect();
         $layouts = array();
         $designPath = Axis::config('system/path') . '/app/design/front';
         foreach ($themes as $theme) {
             $path = $designPath . '/' . $theme . '/layouts';
             if (!file_exists($path)) {
                 continue;
             }
             $dir = opendir($path);
             while ($file = readdir($dir)) {
                 if (is_dir($path . '/' . $file) || substr($file, 0, 7) != 'layout_') {
                     continue;
                 }
                 $layout = substr($file, 0, -6);
                 if (isset($layouts[$layout])) {
                     $layouts[$layout]['themes'][] = $theme;
                     continue;
                 }
                 $layouts[$layout] = array('name' => $layout, 'themes' => array($theme));
             }
         }
         $collection = array();
         foreach ($layouts as $key => $layout) {
             $collection[$key] = $layout['name'] . ' (' . implode(', ', $layout['themes']) . ')';
         }
         self::$_collection = $collection;
     }
     return self::$_collection;
 }
예제 #2
0
 public function listAction()
 {
     if ($this->_hasParam('templateId')) {
         $templateId = $this->_getParam('templateId');
         $theme = Axis::single('core/template')->getTemplateNameById($templateId);
         $themes = array_unique(array($theme, 'fallback', 'default'));
     } else {
         $themes = Axis_Collect_Theme::collect();
     }
     //        $layouts = Axis_Collect_Layout::collect();
     $layouts = array();
     $designPath = Axis::config('system/path') . '/app/design/front';
     foreach ($themes as $theme) {
         $path = $designPath . '/' . $theme . '/layouts';
         if (!file_exists($path)) {
             continue;
         }
         $dir = opendir($path);
         while ($file = readdir($dir)) {
             if (is_dir($path . '/' . $file) || substr($file, 0, 7) != 'layout_') {
                 continue;
             }
             $layout = substr($file, 0, -6);
             if (isset($layouts[$layout])) {
                 $layouts[$layout]['themes'][] = $theme;
                 continue;
             }
             $layouts[$layout] = array('name' => $layout, 'themes' => array($theme));
         }
     }
     $data = array();
     foreach ($layouts as $key => $layout) {
         $name = $layout['name'] . ' (' . implode(', ', $layout['themes']) . ')';
         $data[] = array('id' => $key, 'name' => $name);
     }
     return $this->_helper->json->setData($data)->sendSuccess();
 }