Mage_Core_Helper_Abstract Class Reference

Inheritance diagram for Mage_Core_Helper_Abstract:

Mage_Adminhtml_Helper_Catalog Mage_Adminhtml_Helper_Data Mage_Adminhtml_Helper_Rss Mage_AdminNotification_Helper_Data Mage_AmazonPayments_Helper_Data Mage_Api_Helper_Data Mage_Backup_Helper_Data Mage_Bundle_Helper_Data Mage_Catalog_Helper_Category Mage_Catalog_Helper_Category_Flat Mage_Catalog_Helper_Data Mage_Catalog_Helper_Image Mage_Catalog_Helper_Map Mage_Catalog_Helper_Output Mage_Catalog_Helper_Product_Flat Mage_Catalog_Helper_Product_Options Mage_CatalogInventory_Helper_Data Mage_CatalogRule_Helper_Data Mage_CatalogSearch_Helper_Data Mage_Checkout_Helper_Data Mage_Cms_Helper_Data Mage_Cms_Helper_Page Mage_Compiler_Helper_Data Mage_Contacts_Helper_Data Mage_Core_Helper_Data Mage_Core_Helper_Http Mage_Core_Helper_Js Mage_Core_Helper_String Mage_Core_Helper_Url Mage_Cron_Helper_Data Mage_Customer_Helper_Address Mage_Customer_Helper_Data Mage_Dataflow_Helper_Data Mage_Directory_Helper_Data Mage_Downloadable_Helper_Data Mage_Downloadable_Helper_Download Mage_Downloadable_Helper_File Mage_Eav_Helper_Data Mage_Giftcert_Helper_Data Mage_GiftMessage_Helper_Data Mage_GoogleAnalytics_Helper_Data Mage_GoogleBase_Helper_Data Mage_GoogleCheckout_Helper_Data Mage_GoogleOptimizer_Helper_Data Mage_Install_Helper_Data Mage_Log_Helper_Data Mage_Newsletter_Helper_Data Mage_Page_Helper_Data Mage_Page_Helper_Html Mage_Page_Helper_Layout Mage_Paygate_Helper_Data Mage_Payment_Helper_Data Mage_Paypal_Helper_Data Mage_PaypalUk_Helper_Data Mage_Poll_Helper_Data Mage_Rating_Helper_Data Mage_Reports_Helper_Data Mage_Review_Helper_Data Mage_Rss_Helper_Catalog Mage_Rss_Helper_Data Mage_Rss_Helper_Order Mage_Rule_Helper_Data Mage_SalesRule_Helper_Data Mage_Sendfriend_Helper_Data Mage_Shipping_Helper_Data Mage_Sitemap_Helper_Data Mage_Tag_Helper_Data Mage_Tax_Helper_Data Mage_Usa_Helper_Data Mage_Weee_Helper_Data Mage_Wishlist_Helper_Data

List of all members.

Public Member Functions

 __ ()
 htmlEscape ($data, $allowedTags=null)
 urlEscape ($data)
 jsQuoteEscape ($data, $quote='\'')
 setLayout ($layout)
 getLayout ()
 urlEncode ($url)
 urlDecode ($url)
 translateArray ($arr=array())

Protected Member Functions

 _getRequest ()
 _loadCache ($id)
 _saveCache ($data, $id, $tags=array(), $lifeTime=false)
 _removeCache ($id)
 _cleanCache ($tags=array())
 _getModuleName ()
 _getUrl ($route, $params=array())

Protected Attributes

 $_moduleName
 $_request
 $_layout


Detailed Description

Abstract helper

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Abstract.php.


Member Function Documentation

__ (  ) 

Translate

Returns:
string

Definition at line 136 of file Abstract.php.

00137     {
00138         $args = func_get_args();
00139         $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getModuleName());
00140         array_unshift($args, $expr);
00141         return Mage::app()->getTranslator()->translate($args);
00142     }

_cleanCache ( tags = array()  )  [protected]

Cleaning cache

Parameters:
array $tags
Returns:
Mage_Core_Helper_Abstract

Definition at line 111 of file Abstract.php.

00112     {
00113         Mage::app()->cleanCache($tags);
00114         return $this;
00115     }

_getModuleName (  )  [protected]

Retrieve helper module name

Returns:
string

Definition at line 122 of file Abstract.php.

00123     {
00124         if (!$this->_moduleName) {
00125             $class = get_class($this);
00126             $this->_moduleName = substr($class, 0, strpos($class, '_Helper'));
00127         }
00128         return $this->_moduleName;
00129     }

_getRequest (  )  [protected]

Retrieve request object

Returns:
Zend_Controller_Request_Http

Definition at line 60 of file Abstract.php.

00061     {
00062         if (!$this->_request) {
00063             $this->_request = Mage::app()->getRequest();
00064         }
00065         return $this->_request;
00066     }

_getUrl ( route,
params = array() 
) [protected]

Retrieve url

Parameters:
string $route
array $params
Returns:
string

Definition at line 213 of file Abstract.php.

00214     {
00215         return Mage::getUrl($route, $params);
00216     }

_loadCache ( id  )  [protected]

Loading cache data

Parameters:
string $id
Returns:
mixed

Definition at line 74 of file Abstract.php.

00075     {
00076         return Mage::app()->loadCache($id);
00077     }

_removeCache ( id  )  [protected]

Removing cache

Parameters:
string $id
Returns:
Mage_Core_Helper_Abstract

Definition at line 99 of file Abstract.php.

00100     {
00101         Mage::app()->removeCache($id);
00102         return $this;
00103     }

_saveCache ( data,
id,
tags = array(),
lifeTime = false 
) [protected]

Saving cache

Parameters:
mixed $data
string $id
array $tags
Returns:
Mage_Core_Helper_Abstract

Definition at line 87 of file Abstract.php.

00088     {
00089         Mage::app()->saveCache($data, $id, $tags, $lifeTime);
00090         return $this;
00091     }

getLayout (  ) 

Retrieve layout model object

Returns:
Mage_Core_Model_Layout

Definition at line 235 of file Abstract.php.

00236     {
00237         return $this->_layout;
00238     }

htmlEscape ( data,
allowedTags = null 
)

Escape html entities

Parameters:
mixed $data
array $allowedTags
Returns:
mixed

Definition at line 151 of file Abstract.php.

00152     {
00153         if (is_array($data)) {
00154             $result = array();
00155             foreach ($data as $item) {
00156                 $result[] = $this->htmlEscape($item);
00157             }
00158         } else {
00159             // process single item
00160             if (strlen($data)) {
00161                 if (is_array($allowedTags) and !empty($allowedTags)) {
00162                     $allowed = implode('|', $allowedTags);
00163                     $result = preg_replace('/<([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)>/si', '##$1$2$3##', $data);
00164                     $result = htmlspecialchars($result);
00165                     $result = preg_replace('/##([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)##/si', '<$1$2$3>', $result);
00166                 } else {
00167                     $result = htmlspecialchars($data);
00168                 }
00169             } else {
00170                 $result = $data;
00171             }
00172         }
00173         return $result;
00174     }

jsQuoteEscape ( data,
quote = '\'' 
)

Escape quotes in java script

Parameters:
moxed $data
string $quote
Returns:
mixed

Definition at line 194 of file Abstract.php.

00195     {
00196         if (is_array($data)) {
00197             $result = array();
00198             foreach ($data as $item) {
00199                 $result[] = str_replace($quote, '\\'.$quote, $item);
00200             }
00201             return $result;
00202         }
00203         return str_replace($quote, '\\'.$quote, $data);
00204     }

setLayout ( layout  ) 

Declare layout

Parameters:
Mage_Core_Model_Layout $layout
Returns:
Mage_Core_Helper_Abstract

Definition at line 224 of file Abstract.php.

00225     {
00226         $this->_layout = $layout;
00227         return $this;
00228     }

translateArray ( arr = array()  ) 

Translate array

Parameters:
array $arr
Returns:
array

Definition at line 269 of file Abstract.php.

00270     {
00271         foreach ($arr as $k => $v) {
00272             if (is_array($v)) {
00273                 $v = self::translateArray($v);
00274             } elseif ($k === 'label') {
00275                 $v = self::__($v);
00276             }
00277             $arr[$k] = $v;
00278         }
00279         return $arr;
00280     }

urlDecode ( url  ) 

base64_dencode() for URLs dencoding

Parameters:
string $url
Returns:
string

Definition at line 257 of file Abstract.php.

00258     {
00259         $url = base64_decode(strtr($url, '-_,', '+/='));
00260         return Mage::getSingleton('core/url')->sessionUrlVar($url);
00261     }

urlEncode ( url  ) 

base64_encode() for URLs encoding

Parameters:
string $url
Returns:
string

Definition at line 246 of file Abstract.php.

00247     {
00248         return strtr(base64_encode($url), '+/=', '-_,');
00249     }

urlEscape ( data  ) 

Escape html entities in url

Parameters:
string $data
Returns:
string

Definition at line 182 of file Abstract.php.

00183     {
00184         return htmlspecialchars($data);
00185     }


Member Data Documentation

$_layout [protected]

Definition at line 53 of file Abstract.php.

$_moduleName [protected]

Definition at line 39 of file Abstract.php.

$_request [protected]

Definition at line 46 of file Abstract.php.


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

Generated on Sat Jul 4 17:23:55 2009 for Magento by  doxygen 1.5.8