Exemple #1
0
 /**
  * Registers the assets. Makes sure the assets pre-existed on the published folder prior registration.
  */
 public function registerAssets()
 {
     // make sure core hasn't been registered previously
     $dirs = array('css', 'js');
     foreach ($this->assets as $key => $files) {
         if (in_array($key, $dirs)) {
             $files = is_array($files) ? $files : array($files);
             foreach ($files as $file) {
                 $filePath = Foundation::getAssetsPath() . DIRECTORY_SEPARATOR . $key . DIRECTORY_SEPARATOR . $file;
                 if (file_exists($filePath) && is_file($filePath)) {
                     $method = strcasecmp($key, 'css') === 0 ? 'registerCssFile' : 'registerScriptFile';
                     call_user_func(array(\Yii::app()->clientScript, "{$method}"), Foundation::getAssetsUrl() . "/{$key}/{$file}");
                 }
             }
         }
     }
 }
Exemple #2
0
 /**
  * Registers the needed CSS file.
  * @param string $url the CSS URL. If null, a default CSS URL will be used.
  */
 public static function registerCssFile($url = null)
 {
     if ($url !== null) {
         \Yii::app()->getClientScript()->registerCssFile($url);
     } else {
         Foundation::registerCoreCss();
     }
 }