1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
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
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'.
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.
16 * All .css files must be located in 'css' and all .js file in
20 * @author Călin-Andrei Burloiu
22 class Html_head_params {
28 // Dictionary for meta tags: name => content
31 protected $site_config = 'p2p-tube';
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.
38 * Do not add in the parameters list the default stylesheet and script!
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
47 public function __construct($params)
49 $CI =& get_instance();
51 if (isset($this->site_config))
52 $CI->load->config($this->site_config);
54 { /* TODO: no site config*/ }
56 if (isset($params['title']))
57 $this->title = $params['title'];
61 if (isset($params['css']))
62 $this->css = $params['css'];
66 if (isset($params['js']))
67 $this->js = $params['js'];
71 if (isset($params['metas']))
72 $this->metas = $params['metas'];
74 $this->metas = array();
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);
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");
90 /* End of file HTML_head_params.php */
91 /* Location: ./application/libraries/HTML_head_params.php */