Mage_Page_Block_Html_Head Class Reference

Inheritance diagram for Mage_Page_Block_Html_Head:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Page_Head

List of all members.

Public Member Functions

 addCss ($name, $params="")
 addJs ($name, $params="")
 addCssIe ($name, $params="")
 addJsIe ($name, $params="")
 addItem ($type, $name, $params=null, $if=null, $cond=null)
 removeItem ($type, $name)
 getCssJsHtml ()
 getChunkedItems ($items, $prefix='', $maxLen=450)
 getContentType ()
 getMediaType ()
 getCharset ()
 setTitle ($title)
 getTitle ()
 getDefaultTitle ()
 getDescription ()
 getKeywords ()
 getRobots ()
 getIncludes ()

Protected Member Functions

 _construct ()


Detailed Description

Definition at line 34 of file Head.php.


Member Function Documentation

_construct (  )  [protected]

Internal constructor, that is called from real constructor

Please override this one instead of overriding real __construct constructor

Please override this one instead of overriding real __construct constructor

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 36 of file Head.php.

00037     {
00038         $this->setTemplate('page/html/head.phtml');
00039     }

addCss ( name,
params = "" 
)

Definition at line 41 of file Head.php.

00042     {
00043         $this->addItem('skin_css', $name, $params);
00044         return $this;
00045     }

addCssIe ( name,
params = "" 
)

Definition at line 53 of file Head.php.

00054     {
00055         $this->addItem('skin_css', $name, $params, 'IE');
00056         return $this;
00057     }

addItem ( type,
name,
params = null,
if = null,
cond = null 
)

Definition at line 65 of file Head.php.

00066     {
00067         if ($type==='skin_css' && empty($params)) {
00068             $params = 'media="all"';
00069         }
00070         $this->_data['items'][$type.'/'.$name] = array(
00071             'type'   => $type,
00072             'name'   => $name,
00073             'params' => $params,
00074             'if'     => $if,
00075             'cond'   => $cond,
00076        );
00077         return $this;
00078     }

addJs ( name,
params = "" 
)

Definition at line 47 of file Head.php.

00048     {
00049         $this->addItem('js', $name, $params);
00050         return $this;
00051     }

addJsIe ( name,
params = "" 
)

Definition at line 59 of file Head.php.

00060     {
00061         $this->addItem('js', $name, $params, 'IE');
00062         return $this;
00063     }

getCharset (  ) 

Definition at line 196 of file Head.php.

00197     {
00198         if (empty($this->_data['charset'])) {
00199             $this->_data['charset'] = Mage::getStoreConfig('design/head/default_charset');
00200         }
00201         return $this->_data['charset'];
00202     }

getChunkedItems ( items,
prefix = '',
maxLen = 450 
)

Definition at line 165 of file Head.php.

00166     {
00167         $chunks = array();
00168         $chunk = $prefix;
00169         foreach ($items as $i=>$item) {
00170             if (strlen($chunk.','.$item)>$maxLen) {
00171                 $chunks[] = $chunk;
00172                 $chunk = $prefix;
00173             }
00174             $chunk .= ','.$item;
00175         }
00176         $chunks[] = $chunk;
00177         return $chunks;
00178     }

getContentType (  ) 

Definition at line 180 of file Head.php.

00181     {
00182         if (empty($this->_data['content_type'])) {
00183             $this->_data['content_type'] = $this->getMediaType().'; charset='.$this->getCharset();
00184         }
00185         return $this->_data['content_type'];
00186     }

getCssJsHtml (  ) 

Definition at line 86 of file Head.php.

00087     {
00088 //        return '';
00089         $lines = array();
00090         $baseJs = Mage::getBaseUrl('js');
00091         $html = '';
00092 
00093         $script = '<script type="text/javascript" src="%s" %s></script>';
00094         $stylesheet = '<link rel="stylesheet" type="text/css" href="%s" %s />';
00095         $alternate = '<link rel="alternate" type="%s" href="%s" %s />';
00096 
00097         foreach ($this->_data['items'] as $item) {
00098             if (!is_null($item['cond']) && !$this->getData($item['cond'])) {
00099                 continue;
00100             }
00101             $if = !empty($item['if']) ? $item['if'] : '';
00102             switch ($item['type']) {
00103                 case 'js':
00104                     #$lines[$if]['other'][] = sprintf($script, $baseJs.$item['name'], $item['params']);
00105                     $lines[$if]['script'][] = $item['name'];
00106                     break;
00107 
00108                 case 'js_css':
00109                     //proxying css will require real-time prepending path to all image urls, should we do it?
00110                     $lines[$if]['other'][] = sprintf($stylesheet, $baseJs.$item['name'], $item['params']);
00111                     #$lines[$if]['stylesheet'][] = $item['name'];
00112                     break;
00113 
00114                 case 'skin_js':
00115                     $lines[$if]['other'][] = sprintf($script, $this->getSkinUrl($item['name']), $item['params']);
00116                     break;
00117 
00118                 case 'skin_css':
00119                     $lines[$if]['other'][] = sprintf($stylesheet, $this->getSkinUrl($item['name']), $item['params']);
00120                     break;
00121 
00122                 case 'rss':
00123                     $lines[$if]['other'][] = sprintf($alternate, 'application/rss+xml'/*'text/xml' for IE?*/, $item['name'], $item['params']);
00124                     break;
00125             }
00126         }
00127 
00128         foreach ($lines as $if=>$items) {
00129             if (!empty($if)) {
00130                 $html .= '<!--[if '.$if.']>'."\n";
00131             }
00132             if (!empty($items['script'])) {
00133                 $scriptItems = array();
00134                 if (Mage::getStoreConfigFlag('dev/js/merge_files')) {
00135                     $scriptItems = $this->getChunkedItems($items['script'], 'index.php?c=auto&amp;f=');
00136                 } else {
00137                     $scriptItems = $items['script'];
00138                 }
00139                 foreach ($scriptItems as $item) {
00140                     $html .= sprintf($script, $baseJs.$item, '') . "\n";
00141                 }
00142 //                foreach (array_chunk($items['script'], 15) as $chunk) {
00143 //                    $html .= sprintf($script, $baseJs.'index.php/x.js?f='.join(',',$chunk), '')."\n";
00144 //                }
00145             }
00146             if (!empty($items['stylesheet'])) {
00147                 foreach ($this->getChunkedItems($items['stylesheet'], $baseJs.'index.php?c=auto&amp;f=') as $item) {
00148                     $html .= sprintf($stylesheet, $item, '')."\n";
00149                 }
00150 //                foreach (array_chunk($items['stylesheet'], 15) as $chunk) {
00151 //                    $html .= sprintf($stylesheet, $baseJs.'index.php/x.css?f='.join(',',$chunk), '')."\n";
00152 //                }
00153             }
00154             if (!empty($items['other'])) {
00155                 $html .= join("\n", $items['other'])."\n";
00156             }
00157             if (!empty($if)) {
00158                 $html .= '<![endif]-->'."\n";
00159             }
00160         }
00161 
00162         return $html;
00163     }

getDefaultTitle (  ) 

Definition at line 219 of file Head.php.

00220     {
00221         return Mage::getStoreConfig('design/head/default_title');
00222     }

getDescription (  ) 

Definition at line 224 of file Head.php.

00225     {
00226         if (empty($this->_data['description'])) {
00227             $this->_data['description'] = Mage::getStoreConfig('design/head/default_description');
00228         }
00229         return $this->_data['description'];
00230     }

getIncludes (  ) 

Get miscellanious scripts/styles to be included in head before head closing tag

Returns:
string

Definition at line 253 of file Head.php.

00254     {
00255         if (empty($this->_data['includes'])) {
00256             $this->_data['includes'] = Mage::getStoreConfig('design/head/includes');
00257         }
00258         return $this->_data['includes'];
00259     }

getKeywords (  ) 

Definition at line 232 of file Head.php.

00233     {
00234         if (empty($this->_data['keywords'])) {
00235             $this->_data['keywords'] = Mage::getStoreConfig('design/head/default_keywords');
00236         }
00237         return $this->_data['keywords'];
00238     }

getMediaType (  ) 

Definition at line 188 of file Head.php.

00189     {
00190         if (empty($this->_data['media_type'])) {
00191             $this->_data['media_type'] = Mage::getStoreConfig('design/head/default_media_type');
00192         }
00193         return $this->_data['media_type'];
00194     }

getRobots (  ) 

Definition at line 240 of file Head.php.

00241     {
00242         if (empty($this->_data['robots'])) {
00243             $this->_data['robots'] = Mage::getStoreConfig('design/head/default_robots');
00244         }
00245         return $this->_data['robots'];
00246     }

getTitle (  ) 

Definition at line 211 of file Head.php.

00212     {
00213         if (empty($this->_data['title'])) {
00214             $this->_data['title'] = $this->getDefaultTitle();
00215         }
00216         return htmlspecialchars(html_entity_decode($this->_data['title'], ENT_QUOTES, 'UTF-8'));
00217     }

removeItem ( type,
name 
)

Definition at line 80 of file Head.php.

00081     {
00082         unset($this->_data['items'][$type.'/'.$name]);
00083         return $this;
00084     }

setTitle ( title  ) 

Definition at line 204 of file Head.php.

00205     {
00206         $this->_data['title'] = Mage::getStoreConfig('design/head/title_prefix').' '.$title
00207             .' '.Mage::getStoreConfig('design/head/title_suffix');
00208         return $this;
00209     }


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

Generated on Sat Jul 4 17:24:30 2009 for Magento by  doxygen 1.5.8