public function __construct() { $this->_auth = Auth::instance(); $this->_user = Auth::instance()->get_user(); $this->_assets = new Assets(); $this->_assets->group($this->_assets_group); $this->set_config_variable('base_url', $this->base_url()); }
public function testCommand() { app()->register(\Skimia\Assets\AssetsServiceProvider::class); $scannerMock = $this->getMockedScanner($this->getGeneratedFilePath()); $this->assertFalse($scannerMock->loadScanned()); $commandMock = $this->getMockedCommand($scannerMock, $this->getDirectories()); //var_dump(Cache::get('skimia.assets.collections.builded', [])); $this->invokeCommandWithPrompt($commandMock); $this->assertTrue($this->getCommandOutput()->contains('angularjs')); //verifie si la question a été posée $this->assertTrue($this->getCommandOutput()->contains('<ask>Update Assets')); $this->assertTrue(File::exists($this->getGeneratedFilePath())); require $this->getGeneratedFilePath(); $this->assertArrayHasKey('js-stack', Assets::group('default')->getCollections()); File::delete($this->getGeneratedFilePath()); }
public function init_media() { parent::init_media(); $this->template_js_params['ACE_THEME'] = Config::get('ace', 'theme', 'textmate'); $this->template_js_params['DEFAULT_FILTER'] = Config::get('site', 'default_filter_id', ''); Assets::package(array('jquery', 'bootstrap', 'notify', 'select2', 'dropzone', 'fancybox', 'datepicker', 'underscore', 'core')); foreach (array('.js', '-message.js') as $file_name) { $filename = Kohana::$cache_dir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('i18n', NULL)) . I18n::lang() . $file_name; if (file_exists($filename)) { Assets::js('i18n', BASE_URL . 'cms/cache/i18n/' . I18n::lang() . $file_name, 'global', FALSE, 0); } } $file = $this->request->controller(); $directory = $this->request->directory(); if (!empty($directory)) { $file = $directory . '/' . $file; } $file = strtolower($file); if (Kohana::find_file('media', FileSystem::normalize_path('js/controller/' . $file), 'js')) { Assets::js('controller.' . $file, ADMIN_RESOURCES . 'js/controller/' . $file . '.js', 'global', FALSE, 999); } Assets::group('global', 'events', '<script type="text/javascript">' . Assets::merge_files('js/events', 'js') . '</script>', 'global'); }
/** * Генерация HTML кода CSS, JS, Meta * * По умолчанию выводятся все группы CSS, JS, Meta, если вы выводите JS * код перед тегом </body>, то непобхимо передать параметр FALSE и сделать * вывод JS кода в нужно месте с помощью * * <?php echo Assets::js(); ?> * * @param boolean $include_js Включить в вывод JavaScript * @return string */ public function render($js_footer = FALSE) { $html = Assets::group('FRONTEND') . Assets::css() . Assets::js($js_footer); return $html; }
favicon.ico" rel="favourites icon" /> <?php echo Assets::group('global', 'js_params'); ?> <?php Observer::notify('layout_backend_head_before'); ?> <?php echo Assets::css(); ?> <?php echo Assets::js(); ?> <?php echo Assets::group('global', 'events'); ?> <?php Observer::notify('layout_backend_head_after'); ?> </head> <body id="body_<?php echo $page_body_id; ?> " class="<?php echo $request->query('type'); ?> <?php echo $theme; ?> main-menu-fixed">
/** * Display a group of JS tags * @param string $group * @param array $files * @return string */ public static function js_group($group = null, $files = null) { self::$group = $group; self::init(); // Start benchmark if (self::$_enable_benchmark) { self::$_ci->benchmark->mark("Assets::js_group(" . $group . ")_start"); } // Add to process container self::_add_assets($files, $group, 'js'); // And process it if (self::$_cache_info and self::$freeze) { } else { self::_process('js', $group); } // End benchmark if (self::$_enable_benchmark) { self::$_ci->benchmark->mark("Assets::js_group(" . $group . ")_end"); } // Tags return self::_generate_tags('js'); }
/** * Simply displays the generated tags * @param string $type which assets should be displayed * @param mixed $css CSS files * @param mixed $js JS files * @param array $cfg * @return string */ public static function all($type = 'all', $css = null, $js = null, $group = null, $cfg = null) { self::$group = $group; self::init(); // Configuration if ($cfg) { self::configure($cfg); } // Overwrite CSS files if ($css) { self::$_css = array(); self::_add_css($css, $group); } // Overwrite JS files if ($js) { self::$_js = array(); self::_add_js($js, $group); } // Display all the tags echo self::get($type); }
/** * Assigns the template [View] as the request response. */ public function after() { parent::after(); if ($this->auto_render === TRUE) { if ($this->request->is_ajax() === TRUE or $this->json !== NULL) { if ($this->json !== NULL) { if (is_array($this->json) and !isset($this->json['status'])) { $this->json['status'] = TRUE; } $this->response->headers('Content-type', 'application/json'); $this->template = json_encode($this->json); } else { $this->only_content = TRUE; } } else { $js_string = ''; foreach ($this->template_js_params as $var => $value) { $value = json_encode($value); $js_string .= "var {$var} = {$value};\n"; } Assets::group('global', 'js_params', '<script type="text/javascript">' . $js_string . '</script>', 'global'); } if ($this->only_content) { $this->template = $this->template->content; } if ($this->template instanceof View) { $this->template->set('request', $this->request); } Observer::notify('template_before_render', $this->request); $this->response->body($this->template); } }