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: class Mage_Rule_Model_Action_Collection extends Mage_Rule_Model_Action_Abstract
 29: {
 30:     public function __construct()
 31:     {
 32:         parent::__construct();
 33:         $this->setActions(array());
 34:         $this->setType('rule/action_collection');
 35:     }
 36: 
 37:     /**
 38:      * Returns array containing actions in the collection
 39:      *
 40:      * Output example:
 41:      * array(
 42:      *   {action::asArray},
 43:      *   {action::asArray}
 44:      * )
 45:      *
 46:      * @return array
 47:      */
 48:     public function asArray(array $arrAttributes = array())
 49:     {
 50:         $out = parent::asArray();
 51: 
 52:         foreach ($this->getActions() as $item) {
 53:             $out['actions'][] = $item->asArray();
 54:         }
 55:         return $out;
 56:     }
 57: 
 58:     public function loadArray(array $arr)
 59:     {
 60:         if (!empty($arr['actions']) && is_array($arr['actions'])) {
 61:             foreach ($arr['actions'] as $actArr) {
 62:                 if (empty($actArr['type'])) {
 63:                     continue;
 64:                 }
 65:                 $action = Mage::getModel($actArr['type']);
 66:                 $action->loadArray($actArr);
 67:                 $this->addAction($action);
 68:             }
 69:         }
 70:         return $this;
 71:     }
 72: 
 73:     public function addAction(Mage_Rule_Model_Action_Interface $action)
 74:     {
 75:         $actions = $this->getActions();
 76: 
 77:         $action->setRule($this->getRule());
 78: 
 79:         $actions[] = $action;
 80:         if (!$action->getId()) {
 81:             $action->setId($this->getId().'.'.sizeof($actions));
 82:         }
 83: 
 84:         $this->setActions($actions);
 85:         return $this;
 86:     }
 87: 
 88:     public function asHtml()
 89:     {
 90:         $html = $this->getTypeElement()->toHtml().'Perform following actions: ';
 91:         if ($this->getId()!='1') {
 92:             $html.= $this->getRemoveLinkHtml();
 93:         }
 94:         return $html;
 95:     }
 96:    public function getNewChildElement()
 97:    {
 98:        return $this->getForm()->addField('action:'.$this->getId().':new_child', 'select', array(
 99:            'name'=>'rule[actions]['.$this->getId().'][new_child]',
100:            'values'=>$this->getNewChildSelectOptions(),
101:            'value_name'=>$this->getNewChildName(),
102:        ))->setRenderer(Mage::getBlockSingleton('rule/newchild'));
103:     }
104: 
105:     public function asHtmlRecursive()
106:     {
107:         $html = $this->asHtml().'<ul id="action:'.$this->getId().':children">';
108:         foreach ($this->getActions() as $cond) {
109:             $html .= '<li>'.$cond->asHtmlRecursive().'</li>';
110:         }
111:         $html .= '<li>'.$this->getNewChildElement()->getHtml().'</li></ul>';
112:         return $html;
113:     }
114: 
115:     public function asString($format='')
116:     {
117:         $str = Mage::helper('rule')->__("Perform following actions");
118:         return $str;
119:     }
120: 
121:     public function asStringRecursive($level=0)
122:     {
123:         $str = $this->asString();
124:         foreach ($this->getActions() as $action) {
125:             $str .= "\n".$action->asStringRecursive($level+1);
126:         }
127:         return $str;
128:     }
129: 
130:     public function process()
131:     {
132:         foreach ($this->getActions() as $action) {
133:             $action->process();
134:         }
135:         return $this;
136:     }
137: }
138: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0