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();
50 $CI->load->helper('url');
52 if (isset($this->site_config))
53 $CI->load->config($this->site_config);
55 { /* TODO: no site config*/ }
57 if (isset($params['title']))
58 $this->title = $params['title'];
62 if (isset($params['css']))
63 $this->css = $params['css'];
67 if (isset($params['js']))
68 $this->js = $params['js'];
72 if (isset($params['metas']))
73 $this->metas = $params['metas'];
75 $this->metas = array();
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);
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");
91 /* End of file HTML_head_params.php */
92 /* Location: ./application/libraries/HTML_head_params.php */