Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage
  • Mage_Adminhtml_Block_Html_Date
  • Mage_Adminhtml_Block_Html_Select
  • Mage_Api_Model_Wsdl_Config_Element
  • Mage_Captcha_Adminhtml_RefreshController
  • Mage_Captcha_RefreshController
  • Mage_Core_AjaxController
  • Mage_Core_Block_Abstract
  • Mage_Core_Block_Flush
  • Mage_Core_Block_Html_Calendar
  • Mage_Core_Block_Html_Date
  • Mage_Core_Block_Html_Link
  • Mage_Core_Block_Html_Select
  • Mage_Core_Block_Messages
  • Mage_Core_Block_Profiler
  • Mage_Core_Block_Store_Switcher
  • Mage_Core_Block_Template
  • Mage_Core_Block_Template_Facade
  • Mage_Core_Block_Template_Smarty
  • Mage_Core_Block_Template_Zend
  • Mage_Core_Block_Text
  • Mage_Core_Block_Text_List
  • Mage_Core_Block_Text_List_Item
  • Mage_Core_Block_Text_List_Link
  • Mage_Core_Block_Text_Tag
  • Mage_Core_Block_Text_Tag_Css
  • Mage_Core_Block_Text_Tag_Css_Admin
  • Mage_Core_Block_Text_Tag_Debug
  • Mage_Core_Block_Text_Tag_Js
  • Mage_Core_Block_Text_Tag_Meta
  • Mage_Core_Controller_Front_Action
  • Mage_Core_Controller_Front_Router
  • Mage_Core_Controller_Request_Http
  • Mage_Core_Controller_Response_Http
  • Mage_Core_Controller_Varien_Action
  • Mage_Core_Controller_Varien_Front
  • Mage_Core_Controller_Varien_Router_Abstract
  • Mage_Core_Controller_Varien_Router_Admin
  • Mage_Core_Controller_Varien_Router_Default
  • Mage_Core_Controller_Varien_Router_Standard
  • Mage_Core_Helper_Abstract
  • Mage_Core_Helper_Cookie
  • Mage_Core_Helper_Data
  • Mage_Core_Helper_File_Storage
  • Mage_Core_Helper_File_Storage_Database
  • Mage_Core_Helper_Hint
  • Mage_Core_Helper_Http
  • Mage_Core_Helper_Js
  • Mage_Core_Helper_String
  • Mage_Core_Helper_Translate
  • Mage_Core_Helper_Url
  • Mage_Core_Helper_Url_Rewrite
  • Mage_Core_IndexController
  • Mage_Core_Model_Abstract
  • Mage_Core_Model_App
  • Mage_Core_Model_App_Area
  • Mage_Core_Model_App_Emulation
  • Mage_Core_Model_Cache
  • Mage_Core_Model_Calculator
  • Mage_Core_Model_Config
  • Mage_Core_Model_Config_Base
  • Mage_Core_Model_Config_Data
  • Mage_Core_Model_Config_Element
  • Mage_Core_Model_Config_Options
  • Mage_Core_Model_Config_System
  • Mage_Core_Model_Cookie
  • Mage_Core_Model_Date
  • Mage_Core_Model_Design
  • Mage_Core_Model_Design_Package
  • Mage_Core_Model_Design_Source_Design
  • Mage_Core_Model_Email
  • Mage_Core_Model_Email_Info
  • Mage_Core_Model_Email_Template
  • Mage_Core_Model_Email_Template_Filter
  • Mage_Core_Model_Email_Template_Mailer
  • Mage_Core_Model_Email_Transport
  • Mage_Core_Model_Encryption
  • Mage_Core_Model_File_Storage
  • Mage_Core_Model_File_Storage_Abstract
  • Mage_Core_Model_File_Storage_Database
  • Mage_Core_Model_File_Storage_Database_Abstract
  • Mage_Core_Model_File_Storage_Directory_Database
  • Mage_Core_Model_File_Storage_File
  • Mage_Core_Model_File_Storage_Flag
  • Mage_Core_Model_File_Uploader
  • Mage_Core_Model_File_Validator_AvailablePath
  • Mage_Core_Model_File_Validator_NotProtectedExtension
  • Mage_Core_Model_Flag
  • Mage_Core_Model_Input_Filter
  • Mage_Core_Model_Input_Filter_MaliciousCode
  • Mage_Core_Model_Language
  • Mage_Core_Model_Layout
  • Mage_Core_Model_Layout_Data
  • Mage_Core_Model_Layout_Element
  • Mage_Core_Model_Layout_Update
  • Mage_Core_Model_Locale
  • Mage_Core_Model_Locale_Config
  • Mage_Core_Model_Log_Adapter
  • Mage_Core_Model_Magento_Api
  • Mage_Core_Model_Magento_Api_V2
  • Mage_Core_Model_Message
  • Mage_Core_Model_Message_Abstract
  • Mage_Core_Model_Message_Collection
  • Mage_Core_Model_Message_Error
  • Mage_Core_Model_Message_Notice
  • Mage_Core_Model_Message_Success
  • Mage_Core_Model_Message_Warning
  • Mage_Core_Model_Mysql4_Abstract
  • Mage_Core_Model_Mysql4_Cache
  • Mage_Core_Model_Mysql4_Collection_Abstract
  • Mage_Core_Model_Mysql4_Config
  • Mage_Core_Model_Mysql4_Config_Data
  • Mage_Core_Model_Mysql4_Config_Data_Collection
  • Mage_Core_Model_Mysql4_Design
  • Mage_Core_Model_Mysql4_Design_Collection
  • Mage_Core_Model_Mysql4_Design_Package_Collection
  • Mage_Core_Model_Mysql4_Design_Theme
  • Mage_Core_Model_Mysql4_Email_Template
  • Mage_Core_Model_Mysql4_Email_Template_Collection
  • Mage_Core_Model_Mysql4_File_Storage_Abstract
  • Mage_Core_Model_Mysql4_File_Storage_Database
  • Mage_Core_Model_Mysql4_File_Storage_Directory_Database
  • Mage_Core_Model_Mysql4_File_Storage_File
  • Mage_Core_Model_Mysql4_Flag
  • Mage_Core_Model_Mysql4_Language
  • Mage_Core_Model_Mysql4_Language_Collection
  • Mage_Core_Model_Mysql4_Layout
  • Mage_Core_Model_Mysql4_Resource
  • Mage_Core_Model_Mysql4_Session
  • Mage_Core_Model_Mysql4_Store
  • Mage_Core_Model_Mysql4_Store_Collection
  • Mage_Core_Model_Mysql4_Store_Group
  • Mage_Core_Model_Mysql4_Store_Group_Collection
  • Mage_Core_Model_Mysql4_Translate
  • Mage_Core_Model_Mysql4_Translate_String
  • Mage_Core_Model_Mysql4_Url_Rewrite
  • Mage_Core_Model_Mysql4_Url_Rewrite_Collection
  • Mage_Core_Model_Mysql4_Variable
  • Mage_Core_Model_Mysql4_Variable_Collection
  • Mage_Core_Model_Mysql4_Website
  • Mage_Core_Model_Mysql4_Website_Collection
  • Mage_Core_Model_Observer
  • Mage_Core_Model_Resource
  • Mage_Core_Model_Resource_Abstract
  • Mage_Core_Model_Resource_Cache
  • Mage_Core_Model_Resource_Config
  • Mage_Core_Model_Resource_Config_Data
  • Mage_Core_Model_Resource_Config_Data_Collection
  • Mage_Core_Model_Resource_Db_Abstract
  • Mage_Core_Model_Resource_Db_Collection_Abstract
  • Mage_Core_Model_Resource_Design
  • Mage_Core_Model_Resource_Design_Collection
  • Mage_Core_Model_Resource_Design_Package_Collection
  • Mage_Core_Model_Resource_Email_Template
  • Mage_Core_Model_Resource_Email_Template_Collection
  • Mage_Core_Model_Resource_Entity_Abstract
  • Mage_Core_Model_Resource_Entity_Table
  • Mage_Core_Model_Resource_File_Storage_Abstract
  • Mage_Core_Model_Resource_File_Storage_Database
  • Mage_Core_Model_Resource_File_Storage_Directory_Database
  • Mage_Core_Model_Resource_File_Storage_File
  • Mage_Core_Model_Resource_Flag
  • Mage_Core_Model_Resource_Helper_Abstract
  • Mage_Core_Model_Resource_Helper_Mysql4
  • Mage_Core_Model_Resource_Iterator
  • Mage_Core_Model_Resource_Language
  • Mage_Core_Model_Resource_Language_Collection
  • Mage_Core_Model_Resource_Layout
  • Mage_Core_Model_Resource_Resource
  • Mage_Core_Model_Resource_Session
  • Mage_Core_Model_Resource_Setup
  • Mage_Core_Model_Resource_Setup_Query_Modifier
  • Mage_Core_Model_Resource_Store
  • Mage_Core_Model_Resource_Store_Collection
  • Mage_Core_Model_Resource_Store_Group
  • Mage_Core_Model_Resource_Store_Group_Collection
  • Mage_Core_Model_Resource_Transaction
  • Mage_Core_Model_Resource_Translate
  • Mage_Core_Model_Resource_Translate_String
  • Mage_Core_Model_Resource_Type_Abstract
  • Mage_Core_Model_Resource_Type_Db
  • Mage_Core_Model_Resource_Type_Db_Mysqli
  • Mage_Core_Model_Resource_Type_Db_Mysqli_Setup
  • Mage_Core_Model_Resource_Type_Db_Pdo_Mysql
  • Mage_Core_Model_Resource_Url_Rewrite
  • Mage_Core_Model_Resource_Url_Rewrite_Collection
  • Mage_Core_Model_Resource_Variable
  • Mage_Core_Model_Resource_Variable_Collection
  • Mage_Core_Model_Resource_Website
  • Mage_Core_Model_Resource_Website_Collection
  • Mage_Core_Model_Session
  • Mage_Core_Model_Session_Abstract
  • Mage_Core_Model_Session_Abstract_Varien
  • Mage_Core_Model_Session_Abstract_Zend
  • Mage_Core_Model_Source_Email_Variables
  • Mage_Core_Model_Store
  • Mage_Core_Model_Store_Api
  • Mage_Core_Model_Store_Api_V2
  • Mage_Core_Model_Store_Group
  • Mage_Core_Model_Template
  • Mage_Core_Model_Translate
  • Mage_Core_Model_Translate_Expr
  • Mage_Core_Model_Translate_Inline
  • Mage_Core_Model_Translate_String
  • Mage_Core_Model_Url
  • Mage_Core_Model_Url_Rewrite
  • Mage_Core_Model_Url_Validator
  • Mage_Core_Model_Variable
  • Mage_Core_Model_Variable_Config
  • Mage_Core_Model_Variable_Observer
  • Mage_Core_Model_Website
  • Mage_Page_Block_Switch
  • Mage_Page_Block_Template_Container
  • Mage_Page_Block_Template_Links
  • Mage_Page_Block_Template_Links_Block
  • Mage_Sales_Model_Quote_Address_Total_Collector

Exceptions

  • Mage_Core_Controller_Varien_Exception
  • Mage_Core_Exception
  • Mage_Core_Model_Session_Exception
  • Mage_Core_Model_Store_Exception

Functions

  • destruct
  • is_dir_writeable
  • is_empty_date
  • mageCoreErrorHandler
  • mageDebugBacktrace
  • mageDelTree
  • mageFindClassFile
  • mageParseCsv
  • mageSendErrorFooter
  • mageSendErrorHeader
  • mageUndoMagicQuotes
  • now
  • sys_get_temp_dir
  • uc_words
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Core
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Core data helper
 29:  *
 30:  * @author      Magento Core Team <core@magentocommerce.com>
 31:  */
 32: class Mage_Core_Helper_String extends Mage_Core_Helper_Abstract
 33: {
 34:     const ICONV_CHARSET = 'UTF-8';
 35: 
 36:     /**
 37:      * Truncate a string to a certain length if necessary, appending the $etc string.
 38:      * $remainder will contain the string that has been replaced with $etc.
 39:      *
 40:      * @param string $string
 41:      * @param int $length
 42:      * @param string $etc
 43:      * @param string &$remainder
 44:      * @param bool $breakWords
 45:      * @return string
 46:      */
 47:     public function truncate($string, $length = 80, $etc = '...', &$remainder = '', $breakWords = true)
 48:     {
 49:         $remainder = '';
 50:         if (0 == $length) {
 51:             return '';
 52:         }
 53: 
 54:         $originalLength = $this->strlen($string);
 55:         if ($originalLength > $length) {
 56:             $length -= $this->strlen($etc);
 57:             if ($length <= 0) {
 58:                 return '';
 59:             }
 60:             $preparedString = $string;
 61:             $preparedlength = $length;
 62:             if (!$breakWords) {
 63:                 $preparedString = preg_replace('/\s+?(\S+)?$/u', '', $this->substr($string, 0, $length + 1));
 64:                 $preparedlength = $this->strlen($preparedString);
 65:             }
 66:             $remainder = $this->substr($string, $preparedlength, $originalLength);
 67:             return $this->substr($preparedString, 0, $length) . $etc;
 68:         }
 69: 
 70:         return $string;
 71:     }
 72: 
 73:     /**
 74:      * Retrieve string length using default charset
 75:      *
 76:      * @param string $string
 77:      * @return int
 78:      */
 79:     public function strlen($string)
 80:     {
 81:         return iconv_strlen($string, self::ICONV_CHARSET);
 82:     }
 83: 
 84:     /**
 85:      * Passthrough to iconv_substr()
 86:      *
 87:      * @param string $string
 88:      * @param int $offset
 89:      * @param int $length
 90:      * @return string
 91:      */
 92:     public function substr($string, $offset, $length = null)
 93:     {
 94:         $string = $this->cleanString($string);
 95:         if (is_null($length)) {
 96:             $length = $this->strlen($string) - $offset;
 97:         }
 98:         return iconv_substr($string, $offset, $length, self::ICONV_CHARSET);
 99:     }
100: 
101:     /**
102:      * Split string and appending $insert string after $needle
103:      *
104:      * @param string $str
105:      * @param integer $length
106:      * @param string $needle
107:      * @param string $insert
108:      * @return string
109:      */
110:     public function splitInjection($str, $length = 50, $needle = '-', $insert = ' ')
111:     {
112:         $str = $this->str_split($str, $length);
113:         $newStr = '';
114:         foreach ($str as $part) {
115:             if ($this->strlen($part) >= $length) {
116:                 $lastDelimetr = $this->strpos($this->strrev($part), $needle);
117:                 $tmpNewStr = '';
118:                 $tmpNewStr = $this->substr($this->strrev($part), 0, $lastDelimetr)
119:                     . $insert . $this->substr($this->strrev($part), $lastDelimetr);
120:                 $newStr .= $this->strrev($tmpNewStr);
121:             } else {
122:                 $newStr .= $part;
123:             }
124:         }
125:         return $newStr;
126:     }
127: 
128:     /**
129:      * Binary-safe strrev()
130:      *
131:      * @param string $str
132:      * @return string
133:      */
134:     public function strrev($str)
135:     {
136:         $result = '';
137:         $strlen = $this->strlen($str);
138:         if (!$strlen) {
139:             return $result;
140:         }
141:         for ($i = $strlen-1; $i >= 0; $i--) {
142:             $result .= $this->substr($str, $i, 1);
143:         }
144:         return $result;
145:     }
146: 
147:     /**
148:      * Binary-safe variant of str_split()
149:      * + option not to break words
150:      * + option to trim spaces (between each word)
151:      * + option to set character(s) (pcre pattern) to be considered as words separator
152:      *
153:      * @param string $str
154:      * @param int $length
155:      * @param bool $keepWords
156:      * @param bool $trim
157:      * @param string $wordSeparatorRegex
158:      * @return array
159:      */
160:     public function str_split($str, $length = 1, $keepWords = false, $trim = false, $wordSeparatorRegex = '\s')
161:     {
162:         $result = array();
163:         $strlen = $this->strlen($str);
164:         if ((!$strlen) || (!is_int($length)) || ($length <= 0)) {
165:             return $result;
166:         }
167:         // trim
168:         if ($trim) {
169:             $str = trim(preg_replace('/\s{2,}/siu', ' ', $str));
170:         }
171:         // do a usual str_split, but safe for our encoding
172:         if ((!$keepWords) || ($length < 2)) {
173:             for ($offset = 0; $offset < $strlen; $offset += $length) {
174:                 $result[] = $this->substr($str, $offset, $length);
175:             }
176:         }
177:         // split smartly, keeping words
178:         else {
179:             $split = preg_split('/(' . $wordSeparatorRegex . '+)/siu', $str, null, PREG_SPLIT_DELIM_CAPTURE);
180:             $i        = 0;
181:             $space    = '';
182:             $spaceLen = 0;
183:             foreach ($split as $key => $part) {
184:                 if ($trim) {
185:                     // ignore spaces (even keys)
186:                     if ($key % 2) {
187:                         continue;
188:                     }
189:                     $space    = ' ';
190:                     $spaceLen = 1;
191:                 }
192:                 if (empty($result[$i])) {
193:                     $currentLength = 0;
194:                     $result[$i]    = '';
195:                     $space         = '';
196:                     $spaceLen      = 0;
197:                 }
198:                 else {
199:                     $currentLength = $this->strlen($result[$i]);
200:                 }
201:                 $partLength = $this->strlen($part);
202:                 // add part to current last element
203:                 if (($currentLength + $spaceLen + $partLength) <= $length) {
204:                     $result[$i] .= $space . $part;
205:                 }
206:                 // add part to new element
207:                 elseif ($partLength <= $length) {
208:                     $i++;
209:                     $result[$i] = $part;
210:                 }
211:                 // break too long part recursively
212:                 else {
213:                     foreach ($this->str_split($part, $length, false, $trim, $wordSeparatorRegex) as $subpart) {
214:                         $i++;
215:                         $result[$i] = $subpart;
216:                     }
217:                 }
218:             }
219:         }
220:         // remove last element, if empty
221:         if ($count = count($result)) {
222:             if ($result[$count - 1] === '') {
223:                 unset($result[$count - 1]);
224:             }
225:         }
226:         // remove first element, if empty
227:         if (isset($result[0]) && $result[0] === '') {
228:             array_shift($result);
229:         }
230:         return $result;
231:     }
232: 
233:     /**
234:      * Split words
235:      *
236:      * @param string $str The source string
237:      * @param bool $uniqueOnly Unique words only
238:      * @param int $maxWordLength Limit words count
239:      * @param string $wordSeparatorRegexp
240:      * @return array
241:      */
242:     function splitWords($str, $uniqueOnly = false, $maxWordLength = 0, $wordSeparatorRegexp = '\s')
243:     {
244:         $result = array();
245:         $split = preg_split('#' . $wordSeparatorRegexp . '#siu', $str, null, PREG_SPLIT_NO_EMPTY);
246:         foreach ($split as $word) {
247:             if ($uniqueOnly) {
248:                 $result[$word] = $word;
249:             }
250:             else {
251:                 $result[] = $word;
252:             }
253:         }
254:         if ($maxWordLength && count($result) > $maxWordLength) {
255:             $result = array_slice($result, 0, $maxWordLength);
256:         }
257:         return $result;
258:     }
259: 
260:     /**
261:      * Clean non UTF-8 characters
262:      *
263:      * @param string $string
264:      * @return string
265:      */
266:     public function cleanString($string)
267:     {
268:         return '"libiconv"' == ICONV_IMPL ?
269:             iconv(self::ICONV_CHARSET, self::ICONV_CHARSET . '//IGNORE', $string) : $string;
270:     }
271: 
272:     /**
273:      * Find position of first occurrence of a string
274:      *
275:      * @param string $haystack
276:      * @param string $needle
277:      * @param int $offset
278:      * @return int|false
279:      */
280:     public function strpos($haystack, $needle, $offset = null)
281:     {
282:         return iconv_strpos($haystack, $needle, $offset, self::ICONV_CHARSET);
283:     }
284: 
285:     /**
286:      * Sorts array with multibyte string keys
287:      *
288:      * @param array $sort
289:      * @return array
290:      */
291:     public function ksortMultibyte(array &$sort)
292:     {
293:         if (empty($sort)) {
294:             return false;
295:         }
296:         $oldLocale = setlocale(LC_COLLATE, "0");
297:         $localeCode = Mage::app()->getLocale()->getLocaleCode();
298:         // use fallback locale if $localeCode is not available
299:         setlocale(LC_COLLATE,  $localeCode . '.UTF8', 'C.UTF-8', 'en_US.utf8');
300:         ksort($sort, SORT_LOCALE_STRING);
301:         setlocale(LC_COLLATE, $oldLocale);
302: 
303:         return $sort;
304:     }
305: 
306: }
307: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0