Overview

Namespaces

  • None
  • PHP

Classes

  • Eabi_DpdEE_Block_Adminhtml_Config_Form_Field_Country
  • Eabi_DpdEE_Block_Info_Payment
  • Eabi_DpdEE_Block_Invoice
  • Eabi_DpdEE_Block_Order_Courier
  • Eabi_DpdEE_Helper_Data
  • Eabi_DpdEE_Model_Api
  • Eabi_DpdEE_Model_Button_Courier
  • Eabi_DpdEE_Model_Config
  • Eabi_DpdEE_Model_Flat
  • Eabi_DpdEE_Model_Observer
  • Eabi_DpdEE_Model_Payment_Processor
  • Eabi_DpdEE_Model_Post
  • Eabi_DpdEE_Model_Source_Label_Position
  • Eabi_DpdEE_Model_Source_Service
  • Eabi_Livehandler_Adminhtml_LivehandlerController
  • Eabi_Livehandler_Adminhtml_RemoveController
  • Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Button
  • Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Remove
  • Eabi_Livehandler_Block_Email
  • Eabi_LiveHandler_Block_Footer
  • Eabi_Livehandler_Helper_Data
  • Eabi_Livehandler_Helper_Keypair
  • Eabi_Livehandler_IndexController
  • Eabi_Livehandler_Model_Abstract
  • Eabi_Livehandler_Model_Action_Abstract
  • Eabi_Livehandler_Model_Action_Postoffice_Print
  • Eabi_Livehandler_Model_Action_Postoffice_Send
  • Eabi_Livehandler_Model_Adminhtml_Gridmanager
  • Eabi_Livehandler_Model_Directory_Collection
  • Eabi_Livehandler_Model_Entry
  • Eabi_Livehandler_Model_File_Object
  • Eabi_Livehandler_Model_Mysql4_Entry
  • Eabi_Livehandler_Model_Mysql4_Entry_Collection
  • Eabi_Livehandler_Model_Ordergrid
  • Eabi_Livehandler_Model_System_Config_Backend_Button
  • Eabi_Postoffice_Adminhtml_PostofficeController
  • Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_License
  • Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_Remove
  • Eabi_Postoffice_Block_Config_Rebuildbutton
  • Eabi_Postoffice_Helper_Countrycode
  • Eabi_Postoffice_Helper_Data
  • Eabi_Postoffice_IndexController
  • Eabi_Postoffice_Model_Carrier_Abstract
  • Eabi_Postoffice_Model_Carrier_Result
  • Eabi_Postoffice_Model_Carriermodule
  • Eabi_Postoffice_Model_Mysql4_Carriermodule
  • Eabi_Postoffice_Model_Mysql4_Carriermodule_Collection
  • Eabi_Postoffice_Model_Mysql4_Office
  • Eabi_Postoffice_Model_Mysql4_Office_Collection
  • Eabi_Postoffice_Model_Observer
  • Eabi_Postoffice_Model_Office
  • Eabi_Postoffice_Model_Orderview
  • Eabi_Postoffice_Model_Source_Sendevent
  • Eabi_Postoffice_Model_Updater
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /*
  3: 
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * or OpenGPL v3 license (GNU Public License V3.0)
  9:  * that is bundled with this package in the file LICENSE.txt.
 10:  * It is also available through the world-wide-web at this URL:
 11:  * http://opensource.org/licenses/osl-3.0.php
 12:  * or
 13:  * http://www.gnu.org/licenses/gpl-3.0.txt
 14:  * If you did not receive a copy of the license and are unable to
 15:  * obtain it through the world-wide-web, please send an email
 16:  * to info@e-abi.ee so we can send you a copy immediately.
 17:  *
 18:  * DISCLAIMER
 19:  *
 20:  * Do not edit or add to this file if you wish to upgrade this module to newer
 21:  * versions in the future.
 22:  *
 23:  * @category   Eabi
 24:  * @package    Eabi_Dpd
 25:  * @copyright  Copyright (c) 2014 Aktsiamaailm LLC (http://en.e-abi.ee/)
 26:  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 27:  * @license    http://www.gnu.org/licenses/gpl-3.0.txt  GNU Public License V3.0
 28:  * @author     Matis Halmann
 29:  * 
 30:  
 31:  */
 32: 
 33: /**
 34:  * <p>Represents backend for the <code>Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Button</code></p>
 35:  * 
 36:  *
 37:  * @author Matis
 38:  * @see Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Button
 39:  */
 40: class Eabi_Livehandler_Model_System_Config_Backend_Button extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array {
 41:     protected $_eventPrefix = 'eabi_livehandler_system_config_backend_button';
 42: 
 43:     /**
 44:      * <p>Attempts to auto load Order Manager action buttons from following locations:</p>
 45:      * <ul>
 46:          <li>app/code/community/Eabi/Livehandler/Model/Action</li>
 47:          <li>app/code/local/Eabi/Livehandler/Model/Action</li>
 48:      </ul>
 49:      * <p>Verifies their validity and if new found, then they are added to the configuration automatically.</p>
 50:      */
 51:     protected function _afterLoad() {
 52:         parent::_afterLoad();
 53: //        Zend_Debug::dump($this->getValue());
 54:         $dirnames = array(
 55:             Mage::getBaseDir('code').'/community/Eabi/Livehandler/Model/Action',
 56:             Mage::getBaseDir('code').'/local/Eabi/Livehandler/Model/Action',
 57:         );
 58:         $foundNames = array();
 59:         foreach ($dirnames as $dirname) {
 60:             if (is_dir($dirname) && !$this->getEabi()->getConfigData('eabi_livehandler/admintools/disable_actions_read')) {
 61:                 $directoryLister = new Eabi_Livehandler_Model_Directory_Collection($dirname, true);
 62:                 $filenames = $directoryLister->filesPaths();
 63:                 foreach ($filenames as $filename) {
 64:                     $className = str_replace(array($dirname, '\\'), array('', '/'), $filename);
 65:                     if (strpos($className, '.php') !== false) {
 66:                         $className = ltrim(strtolower(str_replace(array('.php', '/'), array('', '_'), $className)), '_');
 67:                         if ($className != 'abstract') {
 68:                             $foundNames[$className] = $className;
 69:                         }
 70:                     }
 71:                 }
 72:                 
 73:             }
 74:         }
 75:         $values = $this->getValue();
 76:         $existingValues = array();
 77:         $valuesToRemove = array();
 78:         if (is_array($values)) {
 79:             uasort($values, array(__CLASS__, '_sortAction'));
 80:             
 81:             foreach ($values as $key => $value) {
 82:                 $existingValues[$value['button_name']] = $value['button_name'];
 83:                 $modelName = 'eabi_livehandler/action_'.$value['button_name'];
 84:                 if (strpos($value['button_name'], '/')) {
 85:                     $modelName = $value['button_name'];
 86:                 }
 87:                 $testModel = Mage::getModel($modelName);
 88:                 if (!$testModel || !($testModel instanceof Eabi_Livehandler_Model_Action_Abstract)) {
 89:                     $valuesToRemove[] = $key;
 90:                 }
 91:                 
 92:             }
 93:         }
 94:         if (count($foundNames) && !is_array($values)) {
 95:             $values = array();
 96:         }
 97:         $valueAdded = false;
 98:         foreach ($foundNames as $foundName) {
 99:             if (!isset($existingValues[$foundName])) {
100:                 $testModel = Mage::getModel('eabi_livehandler/action_'.$foundName);
101:                 if ($testModel && $testModel instanceof Eabi_Livehandler_Model_Action_Abstract) {
102:                     $values['_' . time() . '_' . mt_rand(0, 999)] = array(
103:                         'button_name' => $foundName,
104:                         'sort_order' => "0",
105:                         'disabled' => "0"
106:                     );
107:                     $valueAdded = true;
108:                 }
109:                 
110:             }
111:         }
112:         foreach ($valuesToRemove as $valueToRemove) {
113:             unset($values[$valueToRemove]);
114:         }
115:         if ($valueAdded || count($valuesToRemove) || true) {
116:             $this->setValue($values);
117:         }
118:         
119:         
120:     }
121:     
122:     public function isValueChanged() {
123:         $oldValue = @unserialize($this->getOldValue());
124:         if (is_array($oldValue)) {
125:             return $oldValue != $this->getValue();
126:         }
127:         return parent::isValueChanged();
128:     }
129: 
130: 
131:     /**
132:      * <p>Sorts buttons by their sort order ascending and leaves disabled buttons as least important.</p>
133:      * @param array $a
134:      * @param array $b
135:      * @return int
136:      */
137:     public static function _sortAction($a, $b) {
138:         if ((bool)$a['disabled'] && !(bool)$b['disabled']) {
139:             return 1;
140:         }
141:         if (!(bool)$a['disabled'] && (bool)$b['disabled']) {
142:             return -1;
143:         }
144:         if ((int)$a['sort_order'] == (int)$b['sort_order']) {
145:             return 0;
146:         }
147:         return (int)$a['sort_order'] < (int)$b['sort_order']?-1:1;
148:     }
149:     
150:     /**
151:      * 
152:      * @return Eabi_Livehandler_Helper_Data
153:      */
154:     protected function getEabi() {
155:         return Mage::helper('eabi');
156:     }
157:     
158:     
159:     
160: }
161: 
162: 
DPD Eesti - Pakivedu.ee Shipping module for Magento API documentation generated by ApiGen 2.8.0