Esempio n. 1
0
    public static function renderStyles(){
               
         if (count(self::$_styles) == 0)
               return FALSE;      
               
         self::$_styles = array_unique(self::$_styles);      
               
         switch ( Kohana::$environment){
           
              case Kohana::DEVELOPMENT:
              case Kohana::STAGING:
              case kohana::TESTING:     
              default:
                                      
                 foreach (self::$_styles as $style){
                       echo HTML::style("media/styles/".$style);
                 }
                  
                 break;
                 
             case Kohana::PRODUCTION:
               
               ?><link rel='stylesheet' type='text/css' href='<?php 
echo url::base();
?>
min/index.php?b=media/styles&amp;f=<?php 
echo implode(",", self::$_styles);
?>
' /><?

                 break;                        
          } 
          
    }
Esempio n. 2
0
 public function action_index()
 {
     $this->template->header->css = HTML::style("themes/default/media/css/home.css");
     $this->template->header->title = __('Welcome');
     $this->template->content = View::factory('pages/welcome/main');
     $this->template->content->set(array('public_registration_enabled' => (bool) Swiftriver::get_setting('public_registration_enabled'), 'anonymous' => $this->anonymous));
 }
Esempio n. 3
0
 /**
  * Add style
  *
  * @param   string  $path
  */
 public function addStyle($path, $media = 'screen')
 {
     if (Filesystem::getExtension($path) == 'css') {
         isset($this->styles->{$media}) or $this->styles->{$media} = new Core_ArrayObject();
         $this->styles->{$media}->{$path} = HTML::style(self::preparePath($path), array('media' => $media));
     }
 }
Esempio n. 4
0
 public function render()
 {
     // calculate the dependencies just once
     !$this->_loaded_dependencies and $this->load_dependencies();
     // sort the assets
     usort($this->_assets, array($this, 'sort_assets'));
     $output = "\n";
     foreach ($this->_assets as $group) {
         $styles = Arr::get($group, 'css_files', array());
         $scripts = Arr::get($group, 'js_files', array());
         // css files
         foreach ($styles as $file => $params) {
             $wrapper = Arr::get($params, 'wrapper', array('', ''));
             $attributes = Arr::get($params, 'attributes', NULL);
             $output .= $wrapper[0] . "\n";
             $output .= HTML::style($file, $attributes) . "\n";
             $output .= $wrapper[1] . "\n";
         }
         // js files
         foreach ($scripts as $file => $params) {
             $wrapper = Arr::get($params, 'wrapper', array('', ''));
             $attributes = Arr::get($params, 'attributes', NULL);
             $output .= $wrapper[0] . "\n";
             $output .= HTML::style($file, $attributes) . "\n";
             $output .= $wrapper[1] . "\n";
         }
     }
     return $output;
 }
Esempio n. 5
0
 protected function css_assets()
 {
     $current_version = File::get(__DIR__ . "/../../.version");
     $basefiles = array('css/main.css', 'css/jquery.jgrowl.css', 'css/ui.jqgrid.css', 'css/fullcalendar.css', 'css/main.css', 'css/jquery.timepicker.css', 'css/jquery.signaturepad.css', 'css/searchFilter.css', 'css/ui.multiselect.css', 'css/chosen.css', 'css/jquery.Jcrop.css', 'css/jquery.realperson.css', 'css/tagit.css', 'css/wColorPicker.min.css', 'css/wPaint.min.css', 'css/jqueryui-editable.css', 'css/timecube.jquery.css', 'css/toastr.min.css');
     $image_files = array('chosen-sprite.png', '*****@*****.**', 'Jcrop.gif', 'pen.png');
     $response = '';
     if (App::isLocal()) {
         foreach ($basefiles as $basefile) {
             $response .= HTML::style($basefile);
         }
     } else {
         $cssfilename = '/temp/' . $current_version . '.css';
         $cssfile = __DIR__ . '/../../public' . $cssfilename;
         $str = '';
         foreach ($basefiles as $basefile) {
             $basefile1 = __DIR__ . '/../../public/' . $basefile;
             $str .= File::get($basefile1);
         }
         foreach ($image_files as $image) {
             $new_image = '../css/' . $image;
             $str = str_replace($image, $new_image, $str);
         }
         File::put($cssfile, $str);
         $response .= HTML::style($cssfilename);
     }
     return $response;
 }
Esempio n. 6
0
 /**
  * Creates a stylesheet link with LESS support
  *
  * @param   string  $style       file name
  * @param   array   $attributes  default attributes
  * @param   bool    $index       include the index page
  * @param   array   $imports     compare file date for these too, CSS and LESS in style @import
  * @return  string
  */
 public static function style($file, array $attributes = null, $index = false, $imports = null)
 {
     $imports = (array) $imports;
     // Compile only .less files
     if (substr_compare($file, '.less', -5, 5, false) === 0) {
         $css = substr_replace($file, 'css', -4);
         $compiled = is_file($css) ? filemtime($css) : 0;
         try {
             // Check if imported files have changed
             $compile = filemtime($file) > $compiled;
             if (!$compile && !empty($imports)) {
                 foreach ($imports as $import) {
                     if (filemtime($import) > $compiled) {
                         $compile = true;
                         break;
                     }
                 }
             }
             // Compile LESS
             if ($compile) {
                 $compiler = new self($file);
                 file_put_contents($css, $compiler->parse());
             }
             $file = $css;
         } catch (Exception $e) {
             Kohana::$log->add(Kohana::ERROR, __METHOD__ . ': Error compiling LESS file ' . $file . ', ' . $e->getMessage());
         }
     }
     return HTML::style($file . '?' . filemtime($file), $attributes, $index);
 }
Esempio n. 7
0
 public static function add_css_file($filename, $stack, $name, $after = null)
 {
     //build filename
     $filename = 'media/css/' . $filename . '.css';
     $script = HTML::style($filename);
     self::add_to_stack($script, 'css', $stack, $name, $after);
 }
Esempio n. 8
0
 public static function add($url, $attributes = array())
 {
     if (Str::endsWith($url, '.js')) {
         $url .= '?v=' . rand(0, 999);
         $asset = \HTML::script($url, $attributes);
         $nscript = array('url' => $url, 'html' => $asset);
         $am = Session::get('asset_manager_js', array());
         foreach ($am as $script) {
             if ($url == $script['url']) {
                 return false;
             }
         }
         $am[] = $nscript;
         Session::put('asset_manager_js', $am);
     } elseif (Str::endsWith($url, '.css')) {
         $url .= '?v=' . rand(0, 999);
         $asset = \HTML::style($url, $attributes);
         $nstyle = array('url' => $url, 'html' => $asset);
         $am = Session::get('asset_manager_css', array());
         foreach ($am as $style) {
             if ($url == $style['url']) {
                 return false;
             }
         }
         $am[] = $nstyle;
         Session::put('asset_manager_css', $am);
         return true;
     }
 }
Esempio n. 9
0
 function getCSS()
 {
     // FIXME: this is a hack which will not be needed once
     //        we have dynamic CSS.
     $css = WikiTheme::getCSS();
     $css->pushcontent(HTML::style(array('type' => 'text/css'), new RawXml(sprintf("<!--\nbody {background-image: url(%s);}\n-->", $this->getImageURL('uhhbackground.jpg')))));
     return $css;
 }
Esempio n. 10
0
 /**
  * Get single CSS asset
  *
  * @param $handle
  * @return bool|string
  */
 public static function get_css($handle)
 {
     if (!isset(self::$_css[$handle])) {
         return false;
     }
     $asset = self::$_css[$handle];
     return HTML::style($asset['src'], $asset['attrs']);
 }
Esempio n. 11
0
 /**
  * 样式别名加载(支持批量加载,后期可拓展为自动多文件压缩合并)
  * @return string
  */
 function style()
 {
     $styleArray = array_map(function ($aliases) {
         $cssUrl = asset_static($aliases);
         return HTML::style($cssUrl);
     }, func_get_args());
     return implode('', array_filter($styleArray));
 }
Esempio n. 12
0
 /**
  * Gets the default css links for the rte
  *  
  * @return string
  */
 public static function get_styles_html()
 {
     $html = array();
     foreach (self::_get_config('styles') as $style) {
         $html[] = HTML::style(url::base() . $style);
     }
     return implode("\n", $html);
 }
Esempio n. 13
0
 public function styles()
 {
     $result = '';
     foreach ($this->styles as $i => $file) {
         $result .= \HTML::style($file);
     }
     return $result;
 }
Esempio n. 14
0
 /**
  * Test generating a link to CSS files
  *
  * @group laravel
  */
 public function testGeneratingStyle()
 {
     $html1 = HTML::style('foo.css');
     $html2 = HTML::style('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js');
     $html3 = HTML::style('foo.css', array('media' => 'print'));
     $this->assertEquals('<link href="http://localhost/foo.css" media="all" type="text/css" rel="stylesheet">' . PHP_EOL, $html1);
     $this->assertEquals('<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js" media="all" type="text/css" rel="stylesheet">' . PHP_EOL, $html2);
     $this->assertEquals('<link href="http://localhost/foo.css" media="print" type="text/css" rel="stylesheet">' . PHP_EOL, $html3);
 }
/**
 * @param array                    $params
 * @param Smarty_Internal_Template $smarty
 *
 * @throws SmartyException
 * @return string
 *
 * @author Kovács Vince
 */
function smarty_function_html_style($params, Smarty_Internal_Template &$smarty)
{
    if (!isset($params['_url'])) {
        throw new SmartyException('Missing _url attribute for html_style tag');
    }
    $url = $params['_url'];
    unset($params['_url']);
    return HTML::style($url, $params);
}
Esempio n. 16
0
 /**
  * Вывод скриптов
  */
 public function output()
 {
     if ($this->glue) {
         echo HTML::style(File::pathToUri($this->glue()));
     } else {
         foreach ($this as $style) {
             echo HTML::style(File::pathToUri($style)) . "\n";
         }
     }
 }
 /**
  * 样式别名加载(支持批量加载,后期可拓展为自动多文件压缩合并)
  * @param  dynamic  mixed  配置文件中的别名
  * @return string
  */
 function style()
 {
     $cssAliases = Config::get('extend.cssAliases');
     $styleArray = array_map(function ($aliases) use($cssAliases) {
         if (isset($cssAliases[$aliases])) {
             return HTML::style($cssAliases[$aliases]);
         }
     }, func_get_args());
     return implode('', array_filter($styleArray));
 }
Esempio n. 18
0
 function getCSS()
 {
     // FIXME: this is a hack which will not be needed once
     //        we have dynamic CSS.
     $css = Theme::getCSS();
     $css->pushcontent(HTML::style(array('type' => 'text/css'), new RawXml(sprintf("<!--\nbody {background-image: url(%s);}\n-->\n", $this->getImageURL('bgpaper8')))));
     //for non-browse pages, like former editpage, message etc.
     //$this->getImageURL('bggranular')));
     return $css;
 }
Esempio n. 19
0
File: helper.php Progetto: ajb/rfpez
 public static function asset($n)
 {
     if (preg_match('/^css/', $n)) {
         $ext = Config::get('assets.use_minified') === false ? ".css" : ".min.css?t=" . Config::get('deploy_timestamp');
         return HTML::style($n . $ext);
     } elseif (preg_match('/^js/', $n)) {
         $ext = Config::get('assets.use_minified') === false ? ".js" : ".min.js?t=" . Config::get('deploy_timestamp');
         return HTML::script($n . $ext);
     } else {
         throw new \Exception("Can't handle that asset type.");
     }
 }
/**
 * 样式别名加载(支持批量加载)
 * @param  string|array $aliases    配置文件中的别名
 * @param  array        $attributes 标签中需要加入的其它参数的数组
 * @return string
 */
function style($aliases, $attributes = array(), $interim = '')
{
    if (is_array($aliases)) {
        foreach ($aliases as $k => $v) {
            $interim .= is_int($k) ? style($v, $attributes, $interim) : style($k, $v, $interim);
        }
        return $interim;
    }
    $cssAliases = Config::get('extend.webAssets.cssAliases');
    $url = isset($cssAliases[$aliases]) ? $cssAliases[$aliases] : $aliases;
    return HTML::style($url, $attributes);
}
Esempio n. 21
0
 /**
  * Загружаем Bootstrap с CDN
  */
 public function hookAssets()
 {
     $theme = config('bootstrap.theme', 'default');
     switch ($theme) {
         case 'default':
             echo HTML::style('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css');
             break;
         default:
             echo HTML::style('http://netdna.bootstrapcdn.com/bootswatch/2.3.0/' . $theme . '/bootstrap.min.css');
     }
     echo HTML::style('http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css');
     echo HTML::script('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js');
 }
Esempio n. 22
0
 public function style_files(array $style_files = array())
 {
     if (count($style_files)) {
         $this->_style_files = $style_files;
         return $this;
     } else {
         $html = '';
         foreach ($this->_style_files as $file) {
             $html .= HTML::style($file);
         }
         return $html;
     }
 }
Esempio n. 23
0
 public static function stylesheet_link_tag($source, array $attributes = NULL)
 {
     if (strpos('//', $source) === FALSE && isset($source[0]) && $source[0] !== '/') {
         $version = '';
         if (Kohana::$config->load('assets.versionizable') === TRUE) {
             $file_name = Assets::get_file($source, 'css');
             if ($file_name && is_file($file_name)) {
                 $version = '-' . hash_hmac_file('md5', $file_name, Kohana::$config->load('assets.versionizable.hmac_password'));
             }
         }
         $source = '/assets/' . $source . $version . '.css';
     }
     return HTML::style($source, $attributes);
 }
Esempio n. 24
0
 public static function getCss($filelist, $folder = 'css')
 {
     $filearr = explode(',', $filelist);
     $out = '';
     //$theme = Kohana::$config->load('webinfo','theme');
     foreach ($filearr as $file) {
         $tfile = DOCROOT . "/public/{$folder}/" . $file;
         $file = "/public/{$folder}/{$file}";
         if (file_exists($tfile)) {
             $out .= HTML::style($file);
         }
     }
     return $out;
 }
Esempio n. 25
0
 public function __toString()
 {
     $html = "";
     if (!empty($this->conditional)) {
         $html .= "<!--[if " . $this->conditional . "]>\n";
     }
     if (isset($this->inline)) {
         $html .= "<style type='text/css'>" . $this->inline . "</style>\n";
     } else {
         $html .= HTML::style($this->file, $this->attributes, $this->protocol, $this->index) . "\n";
     }
     if (!empty($this->conditional)) {
         $html .= "<![endif]-->";
     }
     return $html;
 }
 /**
  * Takes rendered piece of html inside compress tag
  * and finds all css and js files to compress them.
  * @param string piece of rendered html
  * @return html with compressed css or js file
  */
 public static function compress($html)
 {
     if (in_array(Kohana::$environment, Kohana::$config->load('compress_for_twig.disabled_in_environments'))) {
         return $html;
     }
     preg_match_all('/<link[ a-zA-Z0-9="]+href="(.+?)"/s', $html, $files);
     if (Arr::get($files, 1)) {
         $result = Compress::instance('stylesheets')->styles(self::fix_paths(Arr::get($files, 1)));
         return HTML::style($result);
     }
     preg_match_all('/<script[ a-zA-Z0-9="]+src="(.+?)"/s', $html, $files);
     if (Arr::get($files, 1)) {
         $result = Compress::instance('javascripts')->scripts(self::fix_paths(Arr::get($files, 1)));
         return HTML::script($result);
     }
     return $html;
 }
Esempio n. 27
0
?>
">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title><?php 
echo $title;
?>
 | Kohana <?php 
echo __('User Guide');
?>
</title>

<?php 
foreach ($styles as $style => $media) {
    echo HTML::style($style, array('media' => $media), NULL, TRUE), "\n";
}
?>

<?php 
foreach ($scripts as $script) {
    echo HTML::script($script, NULL, NULL, TRUE), "\n";
}
?>

<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body>
Esempio n. 28
0
<!-- resources/views/auth/login.blade.php -->

<html>
    <head>
    @section('head')
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
        <?php 
echo HTML::style('css/materialize.css');
?>
        <?php 
echo HTML::style('css/style.css');
?>
    @show
    </head>
    <body>
        <nav class = 'grey darken-4'>
            <div class="nav-wrapper">
              <a href="#" class="brand-logo center">Logo</a>
            </div>
        </nav>
        <div class="container">
        @if (Session::has('message'))
            <div class="flash alert-info">
                <p>{{ Session::get('message') }}</p>
            </div>
        @endif
        @if ($errors->any())
            <div class='flash alert-danger'>
            @foreach ( $errors->all() as $error )
                <p>{{ $error }}</p>
Esempio n. 29
0
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" dir="ltr" lang="en-US">

<head>

   <title><?php 
echo $title;
?>
</title>

   <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

   <?php 
foreach ($styles as $file => $type) {
    echo HTML::style($file, array('media' => $type)), "\n";
}
?>

   <?php 
foreach ($scripts as $file) {
    echo HTML::script($file), "\n";
}
?>

   <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

</head>

<body>
Esempio n. 30
0
 public function render()
 {
     $html = '';
     foreach ($this as $field) {
         if ($field[2] == '7') {
             $html .= "<!--[if lt " . $field[1] . " 7]>\n" . HTML::style($field[0]) . "<![endif]-->";
         } else {
             if ($field[2] == '8') {
                 $html .= "<!--[if lt " . $field[1] . " 8]>\n" . HTML::style($field[0]) . "<![endif]-->";
             } else {
                 $html .= "<!--[if " . $field[1] . "]>\n" . HTML::style($field[0]) . "<![endif]-->";
             }
         }
         $html .= "\r\n";
     }
     return $html;
 }