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_Rule_Block_Actions
  • Mage_Rule_Block_Conditions
  • Mage_Rule_Block_Editable
  • Mage_Rule_Block_Newchild
  • Mage_Rule_Block_Rule
  • Mage_Rule_Helper_Data
  • Mage_Rule_Model_Abstract
  • Mage_Rule_Model_Action_Abstract
  • Mage_Rule_Model_Action_Collection
  • Mage_Rule_Model_Condition_Abstract
  • Mage_Rule_Model_Condition_Combine
  • Mage_Rule_Model_Condition_Product_Abstract
  • Mage_Rule_Model_Environment
  • Mage_Rule_Model_Mysql4_Rule
  • Mage_Rule_Model_Mysql4_Rule_Collection
  • Mage_Rule_Model_Renderer_Actions
  • Mage_Rule_Model_Renderer_Conditions
  • Mage_Rule_Model_Resource_Abstract
  • Mage_Rule_Model_Resource_Rule_Collection_Abstract

Interfaces

  • Mage_Rule_Model_Action_Interface
  • Mage_Rule_Model_Condition_Interface
  • 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_Rule
 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: /**
 29:  * Quote rule action abstract
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Rule
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: abstract class Mage_Rule_Model_Action_Abstract extends Varien_Object implements Mage_Rule_Model_Action_Interface
 36: {
 37:     public function __construct()
 38:     {
 39:         parent::__construct();
 40:         $this->loadAttributeOptions()->loadOperatorOptions()->loadValueOptions();
 41: 
 42:         foreach ($this->getAttributeOption() as $attr=>$dummy) { $this->setAttribute($attr); break; }
 43:         foreach ($this->getOperatorOption() as $operator=>$dummy) { $this->setOperator($operator); break; }
 44:     }
 45: 
 46:     public function getForm()
 47:     {
 48:         return $this->getRule()->getForm();
 49:     }
 50: 
 51:     public function asArray(array $arrAttributes = array())
 52:     {
 53:         $out = array(
 54:             'type'=>$this->getType(),
 55:             'attribute'=>$this->getAttribute(),
 56:             'operator'=>$this->getOperator(),
 57:             'value'=>$this->getValue(),
 58:         );
 59:         return $out;
 60:     }
 61: 
 62:     public function asXml()
 63:     {
 64:         $xml = "<type>".$this->getType()."</type>"
 65:             ."<attribute>".$this->getAttribute()."</attribute>"
 66:             ."<operator>".$this->getOperator()."</operator>"
 67:             ."<value>".$this->getValue()."</value>";
 68:         return $xml;
 69:     }
 70: 
 71:     public function loadArray(array $arr)
 72:     {
 73:         $this->addData(array(
 74:             'type'=>$arr['type'],
 75:             'attribute'=>$arr['attribute'],
 76:             'operator'=>$arr['operator'],
 77:             'value'=>$arr['value'],
 78:         ));
 79:         $this->loadAttributeOptions();
 80:         $this->loadOperatorOptions();
 81:         $this->loadValueOptions();
 82:         return $this;
 83:     }
 84: 
 85:     public function loadAttributeOptions()
 86:     {
 87:         $this->setAttributeOption(array());
 88:         return $this;
 89:     }
 90: 
 91:     public function getAttributeSelectOptions()
 92:     {
 93:         $opt = array();
 94:         foreach ($this->getAttributeOption() as $k=>$v) {
 95:             $opt[] = array('value'=>$k, 'label'=>$v);
 96:         }
 97:         return $opt;
 98:     }
 99: 
100:     public function getAttributeName()
101:     {
102:         return $this->getAttributeOption($this->getAttribute());
103:     }
104: 
105:     public function loadOperatorOptions()
106:     {
107:         $this->setOperatorOption(array(
108:             '=' => Mage::helper('rule')->__('to'),
109:             '+=' => Mage::helper('rule')->__('by'),
110:         ));
111:         return $this;
112:     }
113: 
114:     public function getOperatorSelectOptions()
115:     {
116:         $opt = array();
117:         foreach ($this->getOperatorOption() as $k=>$v) {
118:             $opt[] = array('value'=>$k, 'label'=>$v);
119:         }
120:         return $opt;
121:     }
122: 
123:     public function getOperatorName()
124:     {
125:         return $this->getOperatorOption($this->getOperator());
126:     }
127: 
128:     public function loadValueOptions()
129:     {
130:         $this->setValueOption(array());
131:         return $this;
132:     }
133: 
134:     public function getValueSelectOptions()
135:     {
136:         $opt = array();
137:         foreach ($this->getValueOption() as $k=>$v) {
138:             $opt[] = array('value'=>$k, 'label'=>$v);
139:         }
140:         return $opt;
141:     }
142: 
143:     public function getValueName()
144:     {
145:         $value = $this->getValue();
146:         return !empty($value) || 0===$value ? $value : '...';;
147:     }
148: 
149:     public function getNewChildSelectOptions()
150:     {
151:         return array(
152:             array('value'=>'', 'label'=>Mage::helper('rule')->__('Please choose an action to add...')),
153:         );
154:     }
155: 
156:     public function getNewChildName()
157:     {
158:         return $this->getAddLinkHtml();
159:     }
160: 
161:     public function asHtml()
162:     {
163:         return '';
164:     }
165: 
166:     public function asHtmlRecursive()
167:     {
168:         $str = $this->asHtml();
169:         return $str;
170:     }
171: 
172:     public function getTypeElement()
173:     {
174:         return $this->getForm()->addField('action:'.$this->getId().':type', 'hidden', array(
175:             'name'=>'rule[actions]['.$this->getId().'][type]',
176:             'value'=>$this->getType(),
177:             'no_span'=>true,
178:         ));
179:     }
180: 
181:     public function getAttributeElement()
182:     {
183:         return $this->getForm()->addField('action:'.$this->getId().':attribute', 'select', array(
184:             'name'=>'rule[actions]['.$this->getId().'][attribute]',
185:             'values'=>$this->getAttributeSelectOptions(),
186:             'value'=>$this->getAttribute(),
187:             'value_name'=>$this->getAttributeName(),
188:         ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
189:     }
190: 
191:     public function getOperatorElement()
192:     {
193:         return $this->getForm()->addField('action:'.$this->getId().':operator', 'select', array(
194:             'name'=>'rule[actions]['.$this->getId().'][operator]',
195:             'values'=>$this->getOperatorSelectOptions(),
196:             'value'=>$this->getOperator(),
197:             'value_name'=>$this->getOperatorName(),
198:         ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
199:     }
200: 
201:     public function getValueElement()
202:     {
203:         return $this->getForm()->addField('action:'.$this->getId().':value', 'text', array(
204:             'name'=>'rule[actions]['.$this->getId().'][value]',
205:             'value'=>$this->getValue(),
206:             'value_name'=>$this->getValueName(),
207:         ))->setRenderer(Mage::getBlockSingleton('rule/editable'));
208:     }
209: 
210:     public function getAddLinkHtml()
211:     {
212:         $src = Mage::getDesign()->getSkinUrl('images/rule_component_add.gif');
213:         $html = '<img src="'.$src.'" alt="" class="rule-param-add v-middle" />';
214:         return $html;
215:     }
216: 
217: 
218:     public function getRemoveLinkHtml()
219:     {
220:         $src = Mage::getDesign()->getSkinUrl('images/rule_component_remove.gif');
221:         $html = '<span class="rule-param"><a href="javascript:void(0)" class="rule-param-remove"><img src="'
222:             . $src . '" alt="" class="v-middle" /></a></span>';
223:         return $html;
224:     }
225: 
226:     public function asString($format='')
227:     {
228:         return "";
229:     }
230: 
231:     public function asStringRecursive($level=0)
232:     {
233:         $str = str_pad('', $level*3, ' ', STR_PAD_LEFT).$this->asString();
234:         return $str;
235:     }
236: 
237:     public function process()
238:     {
239:         return $this;
240:     }
241: }
242: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0