plugin detection created as a widget; can't tell yet if swarmplayer is installed
[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                 $CI->load->helper('url');
51                 
52                 if (isset($this->site_config))
53                         $CI->load->config($this->site_config);
54                 else
55                 { /* TODO: no site config*/ }
56                 
57                 if (isset($params['title']))
58                         $this->title = $params['title'];
59                 else
60                         $this->title = '';
61                         
62                 if (isset($params['css']))
63                         $this->css = $params['css'];
64                 else
65                         $this->css = array();
66                         
67                 if (isset($params['js']))
68                         $this->js = $params['js'];
69                 else
70                         $this->js = array();
71                 
72                 if (isset($params['metas']))
73                         $this->metas = $params['metas'];
74                 else
75                         $this->metas = array();
76                         
77                 // Default parameters from configuration file
78                 $this->css = array_merge(
79                         $CI->config->item('autoload_css'), $this->css);
80                 $this->js = array_merge(
81                         $CI->config->item('autoload_js'), $this->js);
82                 
83                 // URL correct prefixes
84                 foreach ($this->css as $i => $val)
85                         $this->css[$i] = site_url("css/$val");
86                 foreach ($this->js as $i => $val)
87                         $this->js[$i] = site_url("js/$val");
88         }       
89 }
90
91 /* End of file HTML_head_params.php */
92 /* Location: ./application/libraries/HTML_head_params.php */