コード例 #1
0
ファイル: Assets.php プロジェクト: NegoCore/core
 /**
  * Get assets URL
  *
  * @param string $src Source name
  * @param string $type Type of asset
  * @param string $module Module name
  * @return string
  * @throws Kohana_Exception
  */
 public static function get_url($src = null, $type = null, $module = null)
 {
     static $_config;
     if ($_config === null) {
         $_config = Kohana::$config->load('assets');
     }
     // Assets URL
     $url = $_config['url'];
     // Only the Assets URL
     if ($src === null) {
         return $url;
     }
     // Trim
     $url = trim($url, '/') . '/';
     // Source is external
     if (strpos($src, '//') !== false) {
         return $src;
     }
     // WebApp Asset
     if (strpos($src, 'webapp') !== false) {
         return WebApp::get_url($src, $module);
     }
     // Module or Application path
     if ($module !== null) {
         $url .= $_config['mod_path'] . '/' . $module;
     } else {
         $url .= $_config['app_path'];
     }
     //
     return $url . '/assets/' . $type . '/' . $src;
 }
コード例 #2
0
ファイル: WebApp.php プロジェクト: NegoCore/core
 /**
  * Perform RequireJS config
  *
  * @return Config_Group|mixed
  * @throws NegoCore_Exception
  */
 protected static function _get_requirejs_config()
 {
     // Main configuration
     $config = WebApp::get_config('requirejs');
     if (empty($config) || !isset($config['paths'])) {
         throw new NegoCore_Exception('Configuration for RequireJS is corrupted in WebApp.');
     }
     // Set WebApp Paths
     $config['paths']['modules'] = rtrim(WebApp::get_url('', ''), '/');
     $config['paths']['webapp'] = WebApp::get_url('webapp');
     $config['paths']['bootstrap'] = WebApp::get_url('webapp/bootstrap');
     $config['paths']['core'] = WebApp::get_url('webapp/core/lib');
     $config['paths']['mixin'] = WebApp::get_url('webapp/mixins');
     // WebApp files is loaded every request
     if (Kohana::$environment === Kohana::DEVELOPMENT) {
         $config['urlArgs'] = 'v=' . time();
     }
     // Return as JSON
     return $config;
 }