.

WidgetJCSS Class Reference

Print CSS and JS includes. More...

Inheritance diagram for WidgetJCSS:
IWidget IRenderer

List of all members.

Public Member Functions

  __construct ($page_data)
  render ($policy=self::ALL)
  Renders.

Static Public Member Functions

static  output ($page_data, $policy=self::ALL)
  Output Mete INformatins an JS/CSS incldues.

Public Attributes

  $page_data
const  ALL = 1792
const  CSS = 1024
const  JS = 512
const  META = 256

Protected Member Functions

  collect (PageData $page_data, $policy)
  Issue an event to collect JS and CSS files.
  collect_css (PageData $page_data)
  Collect CSS.
  collect_js (PageData $page_data)
  Collect Javascript.
  invoke_collect_event ($type)
  Run event to collect files of given type.
  preprocess_css ($page_data)
  Replace CSS with compressed, if necessary.
  preprocess_js ($page_data)
  Replace CSS with compressed, if necessary.
  replace_by_compressed ($type, $arr_files)
  Replace a bunch of files with their compressed version.
  translate_conditional_css_type ($type)
  Translate JCSSManager conditional CSS types to HeadData conditional CSS types.

Detailed Description

Print CSS and JS includes.

Definition at line 5 of file jcss.widget.php.


Constructor & Destructor Documentation

WidgetJCSS::__construct ( page_data  ) 

Definition at line 30 of file jcss.widget.php.

00030                                                 {
00031                 $this->page_data = $page_data;
00032         }

Member Function Documentation

WidgetJCSS::collect ( PageData page_data,
policy  
) [protected]

Issue an event to collect JS and CSS files.

Parameters:
int  $policy Defines what to collect

Definition at line 113 of file jcss.widget.php.

00113                                                                  {
00114                 if (Common::flag_is_set($policy, self::JS)) {
00115                         $this->collect_js($page_data);
00116                 }       
00117                 if (Common::flag_is_set($policy, self::CSS)) {
00118                         $this->collect_css($page_data);
00119                 }
00120         }
WidgetJCSS::collect_css ( PageData page_data  )  [protected]

Collect CSS.

Definition at line 135 of file jcss.widget.php.

00135                                                             {
00136                 foreach(JCSSManager::get_css_types() as $type) {
00137                         $css_files = $this->invoke_collect_event($type);
00138                         $css_files = array_reverse($css_files);
00139                         switch($type) {
00140                                 case JCSSManager::TYPE_CSS:
00141                                         foreach($css_files as $f) {
00142                                                 $page_data->head->add_css_file($f, true);
00143                                         }
00144                                         break;
00145                                 default:
00146                                         foreach($css_files as $f) {
00147                                                 $page_data->head->add_conditional_css_file(
00148                                                         $this->translate_conditional_css_type($type), 
00149                                                         $f, 
00150                                                         true
00151                                                 );
00152                                         }
00153                                         break;                                  
00154                         }
00155                 }
00156         }
WidgetJCSS::collect_js ( PageData page_data  )  [protected]

Collect Javascript.

Definition at line 125 of file jcss.widget.php.

00125                                                            {
00126                 $js_files = $this->invoke_collect_event(JCSSManager::TYPE_JS);
00127                 foreach(array_reverse($js_files) as $f) {
00128                         $page_data->head->add_js_file($f, true);
00129                 }
00130         }
WidgetJCSS::invoke_collect_event ( type  )  [protected]

Run event to collect files of given type.

Returns:
array

Definition at line 173 of file jcss.widget.php.

00173                                                        {
00174                 $files = array();
00175                 EventSource::Instance()->invoke_event('jcssmanager_collect', $type, $files);
00176                 return $files;
00177         }
static WidgetJCSS::output ( page_data,
policy = self::ALL  
) [static]

Output Mete INformatins an JS/CSS incldues.

Parameters:
PageData  $page_data
int  $policy
Returns:
string

Definition at line 25 of file jcss.widget.php.

00025                                                                      {
00026                 $w = new WidgetJCSS($page_data);
00027                 return $w->render($policy);
00028         }
WidgetJCSS::preprocess_css ( page_data  )  [protected]

Replace CSS with compressed, if necessary.

Parameters:
PageData  $page_data

Definition at line 57 of file jcss.widget.php.

00057                                                       {
00058                 $page_data->head->css_files = $this->replace_by_compressed(JCSSManager::TYPE_CSS, $page_data->head->css_files);
00059                 foreach($page_data->head->conditional_css_files as $browser => $files) {
00060                         switch ($browser) {
00061                                 case HeadData::IE50:
00062                                         $type = JCSSManager::TYPE_CSS_IE50;
00063                                         break;
00064                                 case HeadData::IE55:
00065                                         $type = JCSSManager::TYPE_CSS_IE55;
00066                                         break;
00067                                 case HeadData::IE6:
00068                                         $type = JCSSManager::TYPE_CSS_IE6;
00069                                         break;
00070                                 case HeadData::IE7:
00071                                         $type = JCSSManager::TYPE_CSS_IE7;
00072                                         break;
00073                                 default:
00074                                         continue;
00075                                         break;
00076                         }
00077                         $page_data->head->conditional_css_files[$browser] = $this->replace_by_compressed($type, $files);
00078                 }
00079         }
WidgetJCSS::preprocess_js ( page_data  )  [protected]

Replace CSS with compressed, if necessary.

Parameters:
PageData  $page_data

Definition at line 86 of file jcss.widget.php.

00086                                                      {
00087                 $page_data->head->js_files = $this->replace_by_compressed(JCSSManager::TYPE_JS, $page_data->head->js_files);
00088         }
WidgetJCSS::render ( policy = self::ALL  ) 

Renders.

Parameters:
int  $policy
Returns:
string

Implements IRenderer.

Definition at line 40 of file jcss.widget.php.

00040                                                   {
00041                 $this->collect($this->page_data, $policy);
00042                 Load::models('jcsscompressedfiles');
00043                 if (Common::flag_is_set($policy, self::CSS)) {
00044                         $this->preprocess_css($this->page_data);
00045                 }
00046                 if (Common::flag_is_set($policy, self::JS)) {
00047                         $this->preprocess_js($this->page_data);
00048                 }
00049                 return $this->page_data->head->render($policy);
00050         }
WidgetJCSS::replace_by_compressed ( type,
arr_files  
) [protected]

Replace a bunch of files with their compressed version.

Definition at line 93 of file jcss.widget.php.

00093                                                                     {
00094                 $arr_files = array_unique($arr_files);
00095                 if (count($arr_files) == 0 || !Config::get_value(ConfigJCSSManager::USE_COMPRESSED)) {
00096                         return $arr_files;
00097                 }
00098                 
00099                 $compressed_files = JCSSCompressedFiles::find($type);
00100                 $ret = $arr_files;
00101                 foreach($compressed_files as $compressed_file) {
00102                         $ret = $compressed_file->substitute($ret);
00103                 }
00104                 
00105                 return $ret;
00106         }
WidgetJCSS::translate_conditional_css_type ( type  )  [protected]

Translate JCSSManager conditional CSS types to HeadData conditional CSS types.

Parameters:
$type  A string type
Returns:
string

Definition at line 164 of file jcss.widget.php.

00164                                                                  {
00165                 return substr($type, 4);
00166         }

Member Data Documentation

WidgetJCSS::$page_data

Definition at line 16 of file jcss.widget.php.

const WidgetJCSS::ALL = 1792

Definition at line 9 of file jcss.widget.php.

const WidgetJCSS::CSS = 1024

Definition at line 8 of file jcss.widget.php.

const WidgetJCSS::JS = 512

Definition at line 7 of file jcss.widget.php.

const WidgetJCSS::META = 256

Definition at line 6 of file jcss.widget.php.


The documentation for this class was generated from the following file: