Public Member Functions | |
setUseAbsoluteLinks ($flag) | |
setUseSessionInUrl ($flag) | |
blockDirective ($construction) | |
layoutDirective ($construction) | |
skinDirective ($construction) | |
mediaDirective ($construction) | |
storeDirective ($construction) | |
htmlescapeDirective ($construction) | |
Protected Member Functions | |
_getBlockParameters ($value) | |
Protected Attributes | |
$_useAbsoluteLinks = false | |
$_useSessionInUrl | |
Static Protected Attributes | |
static | $_urlInstance |
Definition at line 35 of file Filter.php.
_getBlockParameters | ( | $ | value | ) | [protected] |
Retrieve block parameters
mixed | $value |
Definition at line 170 of file Filter.php.
00171 { 00172 $tokenizer = new Varien_Filter_Template_Tokenizer_Parameter(); 00173 $tokenizer->setString($value); 00174 00175 return $tokenizer->tokenize(); 00176 }
blockDirective | ( | $ | construction | ) |
Retrieve Block html directive
array | $construction |
Definition at line 88 of file Filter.php.
00089 { 00090 $skipParams = array('type', 'id', 'output'); 00091 $blockParameters = $this->_getIncludeParameters($construction[2]); 00092 $layout = Mage::app()->getLayout(); 00093 00094 if (isset($blockParameters['type'])) { 00095 $type = $blockParameters['type']; 00096 $block = $layout->createBlock($type, null, $blockParameters); 00097 } elseif (isset($blockParameters['id'])) { 00098 $block = $layout->createBlock('cms/block'); 00099 if ($block) { 00100 $block->setBlockId($blockParameters['id']) 00101 ->setBlockParams($blockParameters); 00102 foreach ($blockParameters as $k => $v) { 00103 if (in_array($k, $skipParams)) { 00104 continue; 00105 } 00106 $block->setDataUsingMethod($k, $v); 00107 } 00108 } 00109 } 00110 if (!$block) { 00111 return ''; 00112 } 00113 if (isset($blockParameters['output'])) { 00114 $method = $blockParameters['output']; 00115 } 00116 if (!isset($method) || !is_string($method) || !is_callable(array($block, $method))) { 00117 $method = 'toHtml'; 00118 } 00119 return $block->$method(); 00120 }
htmlescapeDirective | ( | $ | construction | ) |
Directive for converting special characters to HTML entities Supported options: allowed_tags - Comma separated html tags that have not to be converted
array | $construction |
Definition at line 274 of file Filter.php.
00275 { 00276 $params = $this->_getIncludeParameters($construction[2]); 00277 if (!isset($params['var'])) { 00278 return ''; 00279 } 00280 00281 $allowedTags = null; 00282 if (isset($params['allowed_tags'])) { 00283 $allowedTags = preg_split('/\s*\,\s*/', $params['allowed_tags'], 0, PREG_SPLIT_NO_EMPTY); 00284 } 00285 00286 return Mage::helper('core')->htmlEscape($params['var'], $allowedTags); 00287 }
layoutDirective | ( | $ | construction | ) |
Retrieve layout html directive
array | $construction |
Definition at line 128 of file Filter.php.
00129 { 00130 $skipParams = array('handle', 'area'); 00131 00132 $params = $this->_getIncludeParameters($construction[2]); 00133 $layout = Mage::getModel('core/layout'); 00134 /* @var $layout Mage_Core_Model_Layout */ 00135 if (isset($params['area'])) { 00136 $layout->setArea($params['area']); 00137 } 00138 else { 00139 $layout->setArea(Mage::app()->getLayout()->getArea()); 00140 } 00141 00142 $layout->getUpdate()->addHandle($params['handle']); 00143 $layout->getUpdate()->load(); 00144 00145 $layout->generateXml(); 00146 $layout->generateBlocks(); 00147 00148 foreach ($layout->getAllBlocks() as $blockName => $block) { 00149 /* @var $block Mage_Core_Block_Abstract */ 00150 foreach ($params as $k => $v) { 00151 if (in_array($k, $skipParams)) { 00152 continue; 00153 } 00154 00155 $block->setDataUsingMethod($k, $v); 00156 $layout->addOutputBlock($blockName); 00157 } 00158 } 00159 00160 $layout->setDirectOutput(false); 00161 return $layout->getOutput(); 00162 }
mediaDirective | ( | $ | construction | ) |
Retrieve media file URL directive
array | $construction |
Definition at line 200 of file Filter.php.
00201 { 00202 $params = $this->_getIncludeParameters($construction[2]); 00203 return Mage::getBaseUrl('media') . $params['url']; 00204 }
setUseAbsoluteLinks | ( | $ | flag | ) |
setUseSessionInUrl | ( | $ | flag | ) |
skinDirective | ( | $ | construction | ) |
Retrieve Skin URL directive
array | $construction |
Definition at line 184 of file Filter.php.
00185 { 00186 $params = $this->_getIncludeParameters($construction[2]); 00187 $params['_absolute'] = $this->_useAbsoluteLinks; 00188 00189 $url = Mage::getDesign()->getSkinUrl($params['url'], $params); 00190 00191 return $url; 00192 }
storeDirective | ( | $ | construction | ) |
Retrieve store URL directive Support url and direct_url properties
array | $construction |
Definition at line 213 of file Filter.php.
00214 { 00215 $params = $this->_getIncludeParameters($construction[2]); 00216 if (!isset($params['_query'])) { 00217 $params['_query'] = array(); 00218 } 00219 foreach ($params as $k => $v) { 00220 if (strpos($k, '_query_') === 0) { 00221 $params['_query'][substr($k, 7)] = $v; 00222 unset($params[$k]); 00223 } 00224 } 00225 $params['_absolute'] = $this->_useAbsoluteLinks; 00226 00227 if ($this->_useSessionInUrl === false) { 00228 $params['_nosid'] = true; 00229 } 00230 00231 if (isset($params['direct_url'])) { 00232 $path = ''; 00233 $params['_direct'] = $params['direct_url']; 00234 unset($params['direct_url']); 00235 } 00236 else { 00237 $path = $params['url']; 00238 unset($params['url']); 00239 } 00240 00241 if (!self::$_urlInstance) { 00242 self::$_urlInstance = Mage::getModel('core/url')->setStore( 00243 Mage::app()->getStore(Mage::getDesign()->getStore())->getId() 00244 ); 00245 } 00246 $_urlInstanceOldStore = null; 00247 if (!empty($path) && !Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL) 00248 && !Mage::app()->isSingleStoreMode()) 00249 { 00250 $params['_query']['___store'] = Mage::app()->getStore(Mage::getDesign()->getStore())->getCode(); 00251 } elseif (!empty($path) && Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL) 00252 && !Mage::app()->isSingleStoreMode()) 00253 { 00254 $_urlInstanceOldStore = self::$_urlInstance->getStore(); 00255 self::$_urlInstance->setStore(Mage::app()->getStore(Mage::getDesign()->getStore())->getCode()); 00256 } 00257 00258 $url = self::$_urlInstance->getUrl($path, $params); 00259 if (null ==! $_urlInstanceOldStore) { 00260 self::$_urlInstance->setStore($_urlInstanceOldStore); 00261 } 00262 00263 return $url; 00264 }
$_urlInstance [static, protected] |
Definition at line 56 of file Filter.php.
$_useAbsoluteLinks = false [protected] |
Definition at line 42 of file Filter.php.
$_useSessionInUrl [protected] |
Definition at line 49 of file Filter.php.