Пример #1
0
 public function view()
 {
     $b = $this->getBlockObject();
     $a = $b->getBlockAreaObject();
     $this->arLayout = $this->getAreaLayoutObject();
     if (is_object($this->arLayout)) {
         $this->arLayout->setAreaObject($a);
         $this->set('columns', $this->arLayout->getAreaLayoutColumns());
         if ($this->arLayout->isAreaLayoutUsingThemeGridFramework()) {
             $this->render('view_grid');
         } else {
             $asset = new CSSAsset();
             $asset->setAssetURL(URL::to('/ccm/system/css/layout', $this->bID));
             $asset->setAssetSupportsMinification(false);
             $asset->setAssetSupportsCombination(false);
             $this->requireAsset($asset);
             $this->render('view');
         }
     } else {
         $this->set('columns', array());
     }
 }
 public function registerTemplateAssets()
 {
     $items = array();
     $h = Loader::helper("html");
     $dh = Loader::helper('file');
     if ($this->checkAssets == false) {
         return $items;
     } else {
         $al = AssetList::getInstance();
         $v = View::getInstance();
         foreach ($this->itemsToCheck as $t => $i) {
             if (file_exists($this->basePath . '/' . $i)) {
                 $identifier = substr($this->basePath, strpos($this->basePath, 'blocks'));
                 // $identifier = 'blocks/page_list', 'blocks/feature', 'blocks/page_list/templates/responsive', etc...
                 switch ($t) {
                     case 'CSS':
                         $asset = new CSSAsset($identifier);
                         $asset->setAssetURL($this->getBaseURL() . '/' . $i);
                         $asset->setAssetPath($this->basePath . '/' . $i);
                         $al->registerAsset($asset);
                         $v->requireAsset('css', $identifier);
                         break;
                     case 'JAVASCRIPT':
                         $asset = new JavascriptAsset($identifier);
                         $asset->setAssetURL($this->getBaseURL() . '/' . $i);
                         $asset->setAssetPath($this->basePath . '/' . $i);
                         $al->registerAsset($asset);
                         $v->requireAsset('javascript', $identifier);
                         break;
                 }
             }
         }
         $css = $dh->getDirectoryContents($this->basePath . '/' . DIRNAME_CSS);
         $js = $dh->getDirectoryContents($this->basePath . '/' . DIRNAME_JAVASCRIPT);
         if (count($css) > 0) {
             foreach ($css as $i) {
                 if (substr($i, -4) == '.css') {
                     $identifier = substr($this->basePath, strpos($this->basePath, 'blocks'), -4);
                     $asset = new CSSAsset($identifier);
                     $asset->setAssetURL($this->getBaseURL() . '/' . DIRNAME_CSS . '/' . $i);
                     $asset->setAssetPath($this->basePath . '/' . DIRNAME_CSS . '/' . $i);
                     $al->registerAsset($asset);
                     $v->requireAsset('css', 'blocks/' . $identifier);
                 }
             }
         }
         if (count($js) > 0) {
             foreach ($js as $i) {
                 if (substr($i, -3) == '.js') {
                     $identifier = substr($this->basePath, strpos($this->basePath, 'blocks'), -4);
                     $asset = new JavascriptAsset($identifier);
                     $asset->setAssetURL($this->getBaseURL() . '/' . DIRNAME_JAVASCRIPT . '/' . $i);
                     $asset->setAssetPath($this->basePath . '/' . DIRNAME_JAVASCRIPT . '/' . $i);
                     $al->registerAsset($asset);
                     $v->requireAsset('javascript', $identifier);
                 }
             }
         }
     }
 }
Пример #3
0
 public function css($file, $pkgHandle = null)
 {
     $asset = new CSSAsset();
     // if the first character is a / then that means we just go right through, it's a direct path
     if (substr($file, 0, 4) == 'http' || substr($file, 0, 2) == '//') {
         $asset->setAssetURL($file);
         $asset->setAssetIsLocal(false);
     } else {
         if (substr($file, 0, 1) == '/') {
             $asset->setAssetURL($file);
             $asset->setAssetPath(DIR_BASE . $file);
         } else {
             $v = View::getInstance();
             // checking the theme directory for it. It's just in the root.
             if ($v instanceof View && $v->getThemeDirectory() != '' && file_exists($v->getThemeDirectory() . '/' . $file)) {
                 $asset->setAssetURL($v->getThemePath() . '/' . $file);
                 $asset->setAssetPath($v->getThemeDirectory() . '/' . $file);
             } else {
                 if (file_exists(DIR_APPLICATION . '/' . DIRNAME_CSS . '/' . $file)) {
                     $asset->setAssetURL(REL_DIR_APPLICATION . '/' . DIRNAME_CSS . '/' . $file);
                     $asset->setAssetPath(DIR_APPLICATION . '/' . DIRNAME_CSS . '/' . $file);
                 } else {
                     if ($pkgHandle != null) {
                         if (file_exists(DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CSS . '/' . $file)) {
                             $asset->setAssetURL(REL_DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CSS . '/' . $file);
                             $asset->setAssetPath(DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CSS . '/' . $file);
                         } else {
                             if (file_exists(DIR_BASE_CORE . '/' . DIRNAME_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CSS . '/' . $file)) {
                                 $asset->setAssetURL(ASSETS_URL . '/' . DIRNAME_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CSS . '/' . $file);
                                 $asset->setAssetPath(DIR_BASE_CORE . '/' . DIRNAME_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CSS . '/' . $file);
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$asset->getAssetURL()) {
         $asset->setAssetURL(ASSETS_URL_CSS . '/' . $file);
         $asset->setAssetPath(DIR_BASE_CORE . '/' . DIRNAME_CSS . '/' . $file);
     }
     return $asset;
 }