fec1055f7eda94c165d82b5b2759062903b79657
[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 'stylesheets' and all .js file in
16  * 'javascripts'.
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 $stylesheets;
25         // List of .js files
26         public $javascripts;
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 $stylesheets and the default script to
33          * member $javascripts. 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          *   * 'stylesheets' => list of .css files without any path
41          *   * 'javascripts' => 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['stylesheets']))
56                         $this->stylesheets = $params['stylesheets'];
57                 else
58                         $this->stylesheets = array();
59                         
60                 if (isset($params['javascripts']))
61                         $this->javascripts = $params['javascripts'];
62                 else
63                         $this->javascripts = 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_stylesheet') != '')
72                         $this->stylesheets[] = $CI->config->item('default_stylesheet');
73                 if ($CI->config->item('default_javascript') != '')
74                         $this->javascripts[] = $CI->config->item('default_javascript');
75                 
76                 // URL correct prefixes
77                 foreach ($this->stylesheets as $i => $val)
78                         $this->stylesheets[$i] = site_url("stylesheets/$val");
79                 foreach ($this->javascripts as $i => $val)
80                         $this->javascripts[$i] = site_url("javascript/$val");
81         }       
82 }
83
84 /* End of file HTML_head_params.php */
85 /* Location: ./application/libraries/HTML_head_params.php */