video thumbnails are displayed as slideshow when mouse is over; video widget bugs...
[living-lab-site.git] / application / libraries / Html_head_params.php
1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
2
3 /**
4  * Library HTML_head_params contains HTML information that is going to be 
5  * included inside the head tag like: title, stylesheets, scripts and meta
6  * information.
7  *
8  * The constructor automatically adds the autoload-configured CSSs and JSs 
9  * if any from "application/config/${site_config}.php" so they don't have to be
10  * added manually. The configuration parameters are:
11  * 'autoload_css', 'autoload_js'.
12  *
13  * The variables are passed as data in 'application/views/html_begin.php' which
14  * is going to generate the tags based on their information.
15  *
16  * All .css files must be located in 'css' and all .js file in
17  * 'js'.
18  *
19  * @category    Library
20  * @author              Călin-Andrei Burloiu
21  */
22 class Html_head_params {
23         public $title;
24         // List of .css files
25         public $css;
26         // List of .js files
27         public $js;
28         // Dictionary for meta tags: name => content
29         public $metas;
30         
31         protected $site_config = 'p2p-tube';
32         
33         /**
34          * Initializes member variables with the parameters provided and adds the
35          * default stylesheet to member $css and the default script to
36          * member $js. The URL prefixes are also added to filenames.
37          *
38          * Do not add in the parameters list the default stylesheet and script!
39          *
40          * @access              public
41          * @param               array $params   asscociative list with the following parameters:
42          *   * 'title' => HTML title tag content (page title)
43          *   * 'css' => list of .css files without any path
44          *   * 'js' => list of .js files without any path
45          *   * 'metas' => associative list of "name => content" meta
46          */
47         public function __construct($params)
48         {
49                 $CI =& get_instance();
50                 
51                 if (isset($this->site_config))
52                         $CI->load->config($this->site_config);
53                 else
54                 { /* TODO: no site config*/ }
55                 
56                 if (isset($params['title']))
57                         $this->title = $params['title'];
58                 else
59                         $this->title = '';
60                         
61                 if (isset($params['css']))
62                         $this->css = $params['css'];
63                 else
64                         $this->css = array();
65                         
66                 if (isset($params['js']))
67                         $this->js = $params['js'];
68                 else
69                         $this->js = array();
70                 
71                 if (isset($params['metas']))
72                         $this->metas = $params['metas'];
73                 else
74                         $this->metas = array();
75                         
76                 // Default parameters from configuration file
77                 $this->css = array_merge(
78                         $CI->config->item('autoload_css'), $this->css);
79                 $this->js = array_merge(
80                         $CI->config->item('autoload_js'), $this->js);
81                 
82                 // URL correct prefixes
83                 foreach ($this->css as $i => $val)
84                         $this->css[$i] = site_url("css/$val");
85                 foreach ($this->js as $i => $val)
86                         $this->js[$i] = site_url("js/$val");
87         }       
88 }
89
90 /* End of file HTML_head_params.php */
91 /* Location: ./application/libraries/HTML_head_params.php */