Esempio n. 1
0
 private function handleStatic($filenames, $type)
 {
     /* Fix to prevent debug bar from rendering on this page */
     $config = Kohana::config('debug_toolbar');
     if ($config) {
         $config->set('auto_render', false);
     }
     /* end fix */
     if ($filenames === null) {
         $this->response = "/* No {$type} TO BE FOUND */";
         return;
     }
     if (Kohana_Core::$environment != Kohana::DEVELOPMENT && self::check(300) === FALSE) {
         self::set(300);
     }
     $this->response->headers('Content-Type', File::mime_by_ext($type));
     $body = "";
     $filenames = preg_replace("/\\.{$type}\$/", '', $filenames);
     foreach (explode(',', $filenames) as $key) {
         $key = basename($key, ".{$type}");
         $file = Kohana::find_file('views/' . $type, $key, $type);
         if (!$file) {
             $body .= "/* No such file or directory ({$key}.{$type}) */\n";
             continue;
         }
         $body .= implode('', array('/* (', str_replace(DOCROOT, '', $file), ") */\n"));
         $body .= file_get_contents($file);
     }
     /* Play nice with minify module if its enabled */
     if (Kohana::config('minify.enabled', false) && class_exists('Minify')) {
         $body = Minify::factory($type)->set($body)->min();
     }
     $this->response->body($body);
 }
Esempio n. 2
0
 public function after()
 {
     if ($this->auto_render) {
         $styles = array('base.css', 'master.css');
         $scripts = array('jquery-1.4.1.js');
         $this->template->styles = array_merge($styles, $this->template->styles);
         $this->template->scripts = array_merge($scripts, $this->template->scripts);
         $this->template->styles = Minify::factory('css')->minify($this->template->styles);
         $this->template->scripts = Minify::factory('js')->minify($this->template->scripts);
     }
     parent::after();
 }