homepage, categories pages; javascript and stylesheets renamed to js and css resp.
[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 default stylesheet and default script
9  * if any from 'application/config/p2p-tube.php' so they don't have to be added
10  * manually.
11  *
12  * The variables are passed as data in 'application/views/html_begin.php' which
13  * is going to generate the tags based on their information.
14  *
15  * All .css files must be located in 'css' and all .js file in
16  * 'js'.
17  *
18  * @category    Library
19  * @author              Călin-Andrei Burloiu
20  */
21 class Html_head_params {
22         public $title;
23         // List of .css files
24         public $css;
25         // List of .js files
26         public $js;
27         // Dictionary for meta tags: name => content
28         public $metas;
29         
30         /**
31          * Initializes member variables with the parameters provided and adds the
32          * default stylesheet to member $css and the default script to
33          * member $js. The URL prefixes are also added to filenames.
34          *
35          * Do not add in the parameters list the default stylesheet and script!
36          *
37          * @access              public
38          * @param               array $params   asscociative list with the following parameters:
39          *   * 'title' => HTML title tag content (page title)
40          *   * 'css' => list of .css files without any path
41          *   * 'js' => list of .js files without any path
42          *   * 'metas' => associative list of "name => content" meta
43          */
44         public function __construct($params)
45         {
46                 $CI =& get_instance();
47                 $CI->load->helper('url');
48                 $CI->load->config('p2p-tube');
49                 
50                 if (isset($params['title']))
51                         $this->title = $params['title'];
52                 else
53                         $this->title = '';
54                         
55                 if (isset($params['css']))
56                         $this->css = $params['css'];
57                 else
58                         $this->css = array();
59                         
60                 if (isset($params['js']))
61                         $this->js = $params['js'];
62                 else
63                         $this->js = array();
64                 
65                 if (isset($params['metas']))
66                         $this->metas = $params['metas'];
67                 else
68                         $this->metas = array();
69                         
70                 // Default parameters from configuration file
71                 if ($CI->config->item('default_css') != '')
72                         $this->css[] = $CI->config->item('default_css');
73                 if ($CI->config->item('default_js') != '')
74                         $this->js[] = $CI->config->item('default_js');
75                 
76                 // URL correct prefixes
77                 foreach ($this->css as $i => $val)
78                         $this->css[$i] = site_url("css/$val");
79                 foreach ($this->js as $i => $val)
80                         $this->js[$i] = site_url("js/$val");
81         }       
82 }
83
84 /* End of file HTML_head_params.php */
85 /* Location: ./application/libraries/HTML_head_params.php */