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_Customer_AccountController
  • Mage_Customer_AddressController
  • Mage_Customer_Block_Account
  • Mage_Customer_Block_Account_Dashboard
  • Mage_Customer_Block_Account_Dashboard_Address
  • Mage_Customer_Block_Account_Dashboard_Block
  • Mage_Customer_Block_Account_Dashboard_Hello
  • Mage_Customer_Block_Account_Dashboard_Info
  • Mage_Customer_Block_Account_Dashboard_Newsletter
  • Mage_Customer_Block_Account_Dashboard_Sidebar
  • Mage_Customer_Block_Account_Forgotpassword
  • Mage_Customer_Block_Account_Navigation
  • Mage_Customer_Block_Account_Resetpassword
  • Mage_Customer_Block_Address_Book
  • Mage_Customer_Block_Address_Edit
  • Mage_Customer_Block_Address_Renderer_Default
  • Mage_Customer_Block_Form_Edit
  • Mage_Customer_Block_Form_Login
  • Mage_Customer_Block_Form_Register
  • Mage_Customer_Block_Newsletter
  • Mage_Customer_Block_Widget_Abstract
  • Mage_Customer_Block_Widget_Dob
  • Mage_Customer_Block_Widget_Gender
  • Mage_Customer_Block_Widget_Name
  • Mage_Customer_Block_Widget_Taxvat
  • Mage_Customer_Helper_Address
  • Mage_Customer_Helper_Data
  • Mage_Customer_Model_Address
  • Mage_Customer_Model_Address_Abstract
  • Mage_Customer_Model_Address_Api
  • Mage_Customer_Model_Address_Api_V2
  • Mage_Customer_Model_Address_Config
  • Mage_Customer_Model_Api2_Customer
  • Mage_Customer_Model_Api2_Customer_Address
  • Mage_Customer_Model_Api2_Customer_Address_Rest
  • Mage_Customer_Model_Api2_Customer_Address_Rest_Admin_V1
  • Mage_Customer_Model_Api2_Customer_Address_Rest_Customer_V1
  • Mage_Customer_Model_Api2_Customer_Address_Validator
  • Mage_Customer_Model_Api2_Customer_Rest
  • Mage_Customer_Model_Api2_Customer_Rest_Admin_V1
  • Mage_Customer_Model_Api2_Customer_Rest_Customer_V1
  • Mage_Customer_Model_Api_Resource
  • Mage_Customer_Model_Attribute
  • Mage_Customer_Model_Attribute_Backend_Data_Boolean
  • Mage_Customer_Model_Attribute_Data
  • Mage_Customer_Model_Attribute_Data_Abstract
  • Mage_Customer_Model_Attribute_Data_Boolean
  • Mage_Customer_Model_Attribute_Data_Date
  • Mage_Customer_Model_Attribute_Data_File
  • Mage_Customer_Model_Attribute_Data_Hidden
  • Mage_Customer_Model_Attribute_Data_Image
  • Mage_Customer_Model_Attribute_Data_Multiline
  • Mage_Customer_Model_Attribute_Data_Multiselect
  • Mage_Customer_Model_Attribute_Data_Postcode
  • Mage_Customer_Model_Attribute_Data_Select
  • Mage_Customer_Model_Attribute_Data_Text
  • Mage_Customer_Model_Attribute_Data_Textarea
  • Mage_Customer_Model_Config_Share
  • Mage_Customer_Model_Convert_Adapter_Customer
  • Mage_Customer_Model_Convert_Parser_Customer
  • Mage_Customer_Model_Customer
  • Mage_Customer_Model_Customer_Api
  • Mage_Customer_Model_Customer_Api_V2
  • Mage_Customer_Model_Customer_Attribute_Backend_Billing
  • Mage_Customer_Model_Customer_Attribute_Backend_Password
  • Mage_Customer_Model_Customer_Attribute_Backend_Shipping
  • Mage_Customer_Model_Customer_Attribute_Backend_Store
  • Mage_Customer_Model_Customer_Attribute_Backend_Website
  • Mage_Customer_Model_Customer_Attribute_Source_Group
  • Mage_Customer_Model_Customer_Attribute_Source_Store
  • Mage_Customer_Model_Customer_Attribute_Source_Website
  • Mage_Customer_Model_Entity_Address
  • Mage_Customer_Model_Entity_Address_Attribute_Backend_Region
  • Mage_Customer_Model_Entity_Address_Attribute_Backend_Street
  • Mage_Customer_Model_Entity_Address_Attribute_Collection
  • Mage_Customer_Model_Entity_Address_Attribute_Source_Country
  • Mage_Customer_Model_Entity_Address_Attribute_Source_Region
  • Mage_Customer_Model_Entity_Address_Collection
  • Mage_Customer_Model_Entity_Attribute
  • Mage_Customer_Model_Entity_Attribute_Collection
  • Mage_Customer_Model_Entity_Customer
  • Mage_Customer_Model_Entity_Customer_Collection
  • Mage_Customer_Model_Entity_Form_Attribute
  • Mage_Customer_Model_Entity_Form_Attribute_Collection
  • Mage_Customer_Model_Entity_Group
  • Mage_Customer_Model_Entity_Group_Collection
  • Mage_Customer_Model_Entity_Setup
  • Mage_Customer_Model_Entity_Wishlist_Collection
  • Mage_Customer_Model_Form
  • Mage_Customer_Model_Group
  • Mage_Customer_Model_Group_Api
  • Mage_Customer_Model_Group_Api_V2
  • Mage_Customer_Model_Observer
  • Mage_Customer_Model_Resource_Address
  • Mage_Customer_Model_Resource_Address_Attribute_Backend_Region
  • Mage_Customer_Model_Resource_Address_Attribute_Backend_Street
  • Mage_Customer_Model_Resource_Address_Attribute_Collection
  • Mage_Customer_Model_Resource_Address_Attribute_Source_Country
  • Mage_Customer_Model_Resource_Address_Attribute_Source_Region
  • Mage_Customer_Model_Resource_Address_Collection
  • Mage_Customer_Model_Resource_Attribute
  • Mage_Customer_Model_Resource_Attribute_Collection
  • Mage_Customer_Model_Resource_Customer
  • Mage_Customer_Model_Resource_Customer_Collection
  • Mage_Customer_Model_Resource_Form_Attribute
  • Mage_Customer_Model_Resource_Form_Attribute_Collection
  • Mage_Customer_Model_Resource_Group
  • Mage_Customer_Model_Resource_Group_Collection
  • Mage_Customer_Model_Resource_Setup
  • Mage_Customer_Model_Resource_Wishlist_Collection
  • Mage_Customer_Model_Session
  • Mage_Customer_ReviewController

Interfaces

  • Mage_Customer_Block_Address_Renderer_Interface

Exceptions

  • Mage_Customer_Exception
  • 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_Customer
 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:  * Customer address helper
 29:  *
 30:  * @author      Magento Core Team <core@magentocommerce.com>
 31:  */
 32: class Mage_Customer_Helper_Address extends Mage_Core_Helper_Abstract
 33: {
 34:     /**
 35:      * VAT Validation parameters XML paths
 36:      */
 37:     const XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT = 'customer/create_account/viv_disable_auto_group_assign_default';
 38:     const XML_PATH_VIV_ON_EACH_TRANSACTION         = 'customer/create_account/viv_on_each_transaction';
 39:     const XML_PATH_VAT_VALIDATION_ENABLED          = 'customer/create_account/auto_group_assign';
 40:     const XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE = 'customer/create_account/tax_calculation_address_type';
 41:     const XML_PATH_VAT_FRONTEND_VISIBILITY = 'customer/create_account/vat_frontend_visibility';
 42: 
 43:     /**
 44:      * Array of Customer Address Attributes
 45:      *
 46:      * @var array
 47:      */
 48:     protected $_attributes;
 49: 
 50:     /**
 51:      * Customer address config node per website
 52:      *
 53:      * @var array
 54:      */
 55:     protected $_config          = array();
 56: 
 57:     /**
 58:      * Customer Number of Lines in a Street Address per website
 59:      *
 60:      * @var array
 61:      */
 62:     protected $_streetLines     = array();
 63:     protected $_formatTemplate  = array();
 64: 
 65:     /**
 66:      * Addresses url
 67:      */
 68:     public function getBookUrl()
 69:     {
 70: 
 71:     }
 72: 
 73:     public function getEditUrl()
 74:     {
 75: 
 76:     }
 77: 
 78:     public function getDeleteUrl()
 79:     {
 80: 
 81:     }
 82: 
 83:     public function getCreateUrl()
 84:     {
 85: 
 86:     }
 87: 
 88:     public function getRenderer($renderer)
 89:     {
 90:         if(is_string($renderer) && $className = Mage::getConfig()->getBlockClassName($renderer)) {
 91:             return new $className();
 92:         } else {
 93:             return $renderer;
 94:         }
 95:     }
 96: 
 97:     /**
 98:      * Return customer address config value by key and store
 99:      *
100:      * @param string $key
101:      * @param Mage_Core_Model_Store|int|string $store
102:      * @return string|null
103:      */
104:     public function getConfig($key, $store = null)
105:     {
106:         $websiteId = Mage::app()->getStore($store)->getWebsiteId();
107: 
108:         if (!isset($this->_config[$websiteId])) {
109:             $this->_config[$websiteId] = Mage::getStoreConfig('customer/address', $store);
110:         }
111:         return isset($this->_config[$websiteId][$key]) ? (string)$this->_config[$websiteId][$key] : null;
112:     }
113: 
114:     /**
115:      * Return Number of Lines in a Street Address for store
116:      *
117:      * @param Mage_Core_Model_Store|int|string $store
118:      * @return int
119:      */
120:     public function getStreetLines($store = null)
121:     {
122:         $websiteId = Mage::app()->getStore($store)->getWebsiteId();
123:         if (!isset($this->_streetLines[$websiteId])) {
124:             $attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'street');
125:             $lines = (int)$attribute->getMultilineCount();
126:             if($lines <= 0) {
127:                 $lines = 2;
128:             }
129:             $this->_streetLines[$websiteId] = min(4, $lines);
130:         }
131: 
132:         return $this->_streetLines[$websiteId];
133:     }
134: 
135:     public function getFormat($code)
136:     {
137:         $format = Mage::getSingleton('customer/address_config')->getFormatByCode($code);
138:         return $format->getRenderer() ? $format->getRenderer()->getFormat() : '';
139:     }
140: 
141:     /**
142:      * Determine if specified address config value can be shown
143:      *
144:      * @param string $key
145:      * @return bool
146:      */
147:     public function canShowConfig($key)
148:     {
149:         return (bool)$this->getConfig($key);
150:     }
151: 
152:     /**
153:      * Return array of Customer Address Attributes
154:      *
155:      * @return array
156:      */
157:     public function getAttributes()
158:     {
159:         if (is_null($this->_attributes)) {
160:             $this->_attributes = array();
161:             /* @var $config Mage_Eav_Model_Config */
162:             $config = Mage::getSingleton('eav/config');
163:             foreach ($config->getEntityAttributeCodes('customer_address') as $attributeCode) {
164:                 $this->_attributes[$attributeCode] = $config->getAttribute('customer_address', $attributeCode);
165:             }
166:         }
167:         return $this->_attributes;
168:     }
169: 
170:     /**
171:      * Get string with frontend validation classes for attribute
172:      *
173:      * @param string $attributeCode
174:      * @return string
175:      */
176:     public function getAttributeValidationClass($attributeCode)
177:     {
178:         /** @var $attribute Mage_Customer_Model_Attribute */
179:         $attribute = isset($this->_attributes[$attributeCode]) ? $this->_attributes[$attributeCode]
180:             : Mage::getSingleton('eav/config')->getAttribute('customer_address', $attributeCode);
181:         $class = $attribute ? $attribute->getFrontend()->getClass() : '';
182: 
183:         if (in_array($attributeCode, array('firstname', 'middlename', 'lastname', 'prefix', 'suffix', 'taxvat'))) {
184:             if ($class && !$attribute->getIsVisible()) {
185:                 $class = ''; // address attribute is not visible thus its validation rules are not applied
186:             }
187: 
188:             /** @var $customerAttribute Mage_Customer_Model_Attribute */
189:             $customerAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
190:             $class .= $customerAttribute && $customerAttribute->getIsVisible()
191:                 ? $customerAttribute->getFrontend()->getClass() : '';
192:             $class = implode(' ', array_unique(array_filter(explode(' ', $class))));
193:         }
194: 
195:         return $class;
196:     }
197: 
198:     /**
199:      * Convert streets array to new street lines count
200:      * Examples of use:
201:      *  $origStreets = array('street1', 'street2', 'street3', 'street4')
202:      *  $toCount = 3
203:      *  Result:
204:      *   array('street1 street2', 'street3', 'street4')
205:      *  $toCount = 2
206:      *  Result:
207:      *   array('street1 street2', 'street3 street4')
208:      *
209:      * @param array $origStreets
210:      * @param int   $toCount
211:      * @return array
212:      */
213:     public function convertStreetLines($origStreets, $toCount)
214:     {
215:         $lines = array();
216:         if (!empty($origStreets) && $toCount > 0) {
217:             $countArgs = (int)floor(count($origStreets)/$toCount);
218:             $modulo = count($origStreets) % $toCount;
219:             $offset = 0;
220:             $neededLinesCount = 0;
221:             for ($i = 0; $i < $toCount; $i++) {
222:                 $offset += $neededLinesCount;
223:                 $neededLinesCount = $countArgs;
224:                 if ($modulo > 0) {
225:                     ++$neededLinesCount;
226:                     --$modulo;
227:                 }
228:                 $values = array_slice($origStreets, $offset, $neededLinesCount);
229:                 if (is_array($values)) {
230:                     $lines[] = implode(' ', $values);
231:                 }
232:             }
233:         }
234: 
235:         return $lines;
236:     }
237: 
238:     /**
239:      * Check whether VAT ID validation is enabled
240:      *
241:      * @param Mage_Core_Model_Store|string|int $store
242:      * @return bool
243:      */
244:     public function isVatValidationEnabled($store = null)
245:     {
246:         return (bool)Mage::getStoreConfig(self::XML_PATH_VAT_VALIDATION_ENABLED, $store);
247:     }
248: 
249:     /**
250:      * Retrieve disable auto group assign default value
251:      *
252:      * @return bool
253:      */
254:     public function getDisableAutoGroupAssignDefaultValue()
255:     {
256:         return (bool)Mage::getStoreConfig(self::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT);
257:     }
258: 
259:     /**
260:      * Retrieve 'validate on each transaction' value
261:      *
262:      * @param Mage_Core_Model_Store|string|int $store
263:      * @return bool
264:      */
265:     public function getValidateOnEachTransaction($store = null)
266:     {
267:         return (bool)Mage::getStoreConfig(self::XML_PATH_VIV_ON_EACH_TRANSACTION, $store);
268:     }
269: 
270:     /**
271:      * Retrieve customer address type on which tax calculation must be based
272:      *
273:      * @param Mage_Core_Model_Store|string|int|null $store
274:      * @return string
275:      */
276:     public function getTaxCalculationAddressType($store = null)
277:     {
278:         return (string)Mage::getStoreConfig(self::XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE, $store);
279:     }
280: 
281:     /**
282:      * Check if VAT ID address attribute has to be shown on frontend (on Customer Address management forms)
283:      *
284:      * @return boolean
285:      */
286:     public function isVatAttributeVisible()
287:     {
288:         return (bool)Mage::getStoreConfig(self::XML_PATH_VAT_FRONTEND_VISIBILITY);
289:     }
290: }
291: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0