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_Oauth
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: * OAuth abstract authorization block
29: *
30: * @category Mage
31: * @package Mage_Oauth
32: * @author Magento Core Team <core@magentocommerce.com>
33: * @method string getToken()
34: * @method Mage_Oauth_Block_AuthorizeBaseAbstract setToken() setToken(string $token)
35: * @method boolean getIsSimple()
36: * @method Mage_Oauth_Block_Authorize_Button setIsSimple() setIsSimple(boolean $flag)
37: * @method boolean getHasException()
38: * @method Mage_Oauth_Block_AuthorizeBaseAbstract setIsException() setHasException(boolean $flag)
39: * @method boolean getVerifier()
40: * @method Mage_Oauth_Block_AuthorizeBaseAbstract setVerifier() setVerifier(string $verifier)
41: * @method boolean getIsLogged()
42: * @method Mage_Oauth_Block_AuthorizeBaseAbstract setIsLogged() setIsLogged(boolean $flag)
43: */
44: abstract class Mage_Oauth_Block_Authorize_Abstract extends Mage_Core_Block_Template
45: {
46: /**
47: * Helper
48: *
49: * @var Mage_Oauth_Helper_Data
50: */
51: protected $_helper;
52:
53: /**
54: * Consumer model
55: *
56: * @var Mage_Oauth_Model_Consumer
57: */
58: protected $_consumer;
59:
60: /**
61: * Constructor
62: */
63: public function __construct()
64: {
65: parent::__construct();
66: $this->_helper = Mage::helper('oauth');
67: }
68:
69: /**
70: * Get consumer instance by token value
71: *
72: * @return Mage_Oauth_Model_Consumer
73: */
74: public function getConsumer()
75: {
76: if (null === $this->_consumer) {
77: /** @var $token Mage_Oauth_Model_Token */
78: $token = Mage::getModel('oauth/token');
79: $token->load($this->getToken(), 'token');
80: $this->_consumer = $token->getConsumer();
81: }
82: return $this->_consumer;
83: }
84:
85: /**
86: * Get absolute path to template
87: *
88: * Load template from adminhtml/default area flag is_simple is set
89: *
90: * @return string
91: */
92: public function getTemplateFile()
93: {
94: if (!$this->getIsSimple()) {
95: return parent::getTemplateFile();
96: }
97:
98: //load base template from admin area
99: $params = array(
100: '_relative' => true,
101: '_area' => 'adminhtml',
102: '_package' => 'default'
103: );
104: return Mage::getDesign()->getTemplateFilename($this->getTemplate(), $params);
105: }
106: }
107: