X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=application%2Flibraries%2FHtml_head_params.php;h=08a792d5de295820bb0cf3caf95b37e82c4c69a1;hb=42b8f76ab32990f2668a4e3346374de7bad91be2;hp=fec1055f7eda94c165d82b5b2759062903b79657;hpb=44e76cbf029fbec96b9a91837963b872f4984004;p=living-lab-site.git diff --git a/application/libraries/Html_head_params.php b/application/libraries/Html_head_params.php index fec1055..08a792d 100644 --- a/application/libraries/Html_head_params.php +++ b/application/libraries/Html_head_params.php @@ -5,15 +5,16 @@ * included inside the head tag like: title, stylesheets, scripts and meta * information. * - * The constructor automatically adds the default stylesheet and default script - * if any from 'application/config/p2p-tube.php' so they don't have to be added - * manually. + * The constructor automatically adds the autoload-configured CSSs and JSs + * if any from "application/config/${site_config}.php" so they don't have to be + * added manually. The configuration parameters are: + * 'autoload_css', 'autoload_js'. * * The variables are passed as data in 'application/views/html_begin.php' which * is going to generate the tags based on their information. * - * All .css files must be located in 'stylesheets' and all .js file in - * 'javascripts'. + * All .css files must be located in 'css' and all .js file in + * 'js'. * * @category Library * @author Călin-Andrei Burloiu @@ -21,46 +22,51 @@ class Html_head_params { public $title; // List of .css files - public $stylesheets; + public $css; // List of .js files - public $javascripts; + public $js; // Dictionary for meta tags: name => content public $metas; + protected $site_config = 'p2p-tube'; + /** * Initializes member variables with the parameters provided and adds the - * default stylesheet to member $stylesheets and the default script to - * member $javascripts. The URL prefixes are also added to filenames. + * default stylesheet to member $css and the default script to + * member $js. The URL prefixes are also added to filenames. * * Do not add in the parameters list the default stylesheet and script! * * @access public * @param array $params asscociative list with the following parameters: * * 'title' => HTML title tag content (page title) - * * 'stylesheets' => list of .css files without any path - * * 'javascripts' => list of .js files without any path + * * 'css' => list of .css files without any path + * * 'js' => list of .js files without any path * * 'metas' => associative list of "name => content" meta */ public function __construct($params) { $CI =& get_instance(); - $CI->load->helper('url'); - $CI->load->config('p2p-tube'); + + if (isset($this->site_config)) + $CI->load->config($this->site_config); + else + { /* TODO: no site config*/ } if (isset($params['title'])) $this->title = $params['title']; else $this->title = ''; - if (isset($params['stylesheets'])) - $this->stylesheets = $params['stylesheets']; + if (isset($params['css'])) + $this->css = $params['css']; else - $this->stylesheets = array(); + $this->css = array(); - if (isset($params['javascripts'])) - $this->javascripts = $params['javascripts']; + if (isset($params['js'])) + $this->js = $params['js']; else - $this->javascripts = array(); + $this->js = array(); if (isset($params['metas'])) $this->metas = $params['metas']; @@ -68,16 +74,16 @@ class Html_head_params { $this->metas = array(); // Default parameters from configuration file - if ($CI->config->item('default_stylesheet') != '') - $this->stylesheets[] = $CI->config->item('default_stylesheet'); - if ($CI->config->item('default_javascript') != '') - $this->javascripts[] = $CI->config->item('default_javascript'); + $this->css = array_merge( + $CI->config->item('autoload_css'), $this->css); + $this->js = array_merge( + $CI->config->item('autoload_js'), $this->js); // URL correct prefixes - foreach ($this->stylesheets as $i => $val) - $this->stylesheets[$i] = site_url("stylesheets/$val"); - foreach ($this->javascripts as $i => $val) - $this->javascripts[$i] = site_url("javascript/$val"); + foreach ($this->css as $i => $val) + $this->css[$i] = site_url("css/$val"); + foreach ($this->js as $i => $val) + $this->js[$i] = site_url("js/$val"); } }