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_Paypal
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: * Renderer for service JavaScript code that disables corresponding paypal methods on page load
30: * @author Magento Core Team <core@magentocommerce.com>
31: */
32: class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store
33: extends Mage_Adminhtml_Block_Abstract
34: implements Varien_Data_Form_Element_Renderer_Interface
35: {
36: /**
37: * Path to template file
38: *
39: * @var string
40: */
41: protected $_template = 'paypal/system/config/fieldset/store.phtml';
42:
43: /**
44: * Render service JavaScript code
45: *
46: * @param Varien_Data_Form_Element_Abstract $element
47: * @return string
48: */
49: public function render(Varien_Data_Form_Element_Abstract $element)
50: {
51: return $this->toHtml();
52: }
53:
54: /**
55: * Returns list of disabled (in the Default or the Website Scope) paypal methods
56: *
57: * @return array
58: */
59: protected function getPaypalDisabledMethods()
60: {
61: // Assoc array that contains info about paypal methods (their IDs and corresponding Config Paths)
62: $methods = array(
63: 'express' => 'payment/paypal_express/active',
64: 'wps' => 'payment/paypal_standard/active',
65: 'wpp' => 'payment/paypal_direct/active',
66: 'wpppe' => 'payment/paypaluk_direct/active',
67: 'verisign' => 'payment/verisign/active',
68: 'expresspe' => 'payment/paypaluk_express/active'
69: );
70: // Retrieve a code of the current website
71: $website = $this->getRequest()->getParam('website');
72:
73: $configRoot = Mage::getConfig()->getNode(null, 'website', $website);
74:
75: $disabledMethods = array();
76: foreach ($methods as $methodId => $methodPath) {
77: $isEnabled = (int) $configRoot->descend($methodPath);
78: if ($isEnabled === 0) {
79: $disabledMethods[$methodId] = $isEnabled;
80: }
81: }
82:
83: return $disabledMethods;
84: }
85: }
86: