GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#31)
by
unknown
29:04 queued 14:03
created

getButtonSelector()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
/**
3
 * Studioforty9_Recaptcha
4
 *
5
 * @category  Studioforty9
6
 * @package   Studioforty9_Recaptcha
7
 * @author    StudioForty9 <[email protected]>
8
 * @copyright 2015 StudioForty9 (http://www.studioforty9.com)
9
 * @license   https://github.com/studioforty9/recaptcha/blob/master/LICENCE BSD
10
 * @version   1.5.7
11
 * @link      https://github.com/studioforty9/recaptcha
12
 */
13
14
/**
15
 * Studioforty9_Recaptcha_Block_Explicit
16
 *
17
 * @category   Studioforty9
18
 * @package    Studioforty9_Recaptcha
19
 * @subpackage Block
20
 */
21
class Studioforty9_Recaptcha_Block_Explicit extends Mage_Core_Block_Template
22
{
23
    protected $_languages = array(
24
        'ar_DZ|ar_SA|ar_KW|ar_MA|ar_EG|az_AZ|' => 'ar',
25
        'bg_BG' => 'bg',
26
        'ca_ES' => 'ca',
27
        'zh_CN' => 'zh-CN',
28
        'zh_HK|zh_TW' => 'zh-TW',
29
        'hr_HR' => 'hr',
30
        'cs_CZ' => 'cs',
31
        'da_DK' => 'da',
32
        'nl_NL' => 'nl',
33
        'en_GB|en_AU|en_NZ|en_IE|cy_GB' => 'en-GB',
34
        'en_US|en_CA' => 'en',
35
        'fil_PH' => 'fil',
36
        'fi_FI' => 'fi',
37
        'fr_FR' => 'fr',
38
        'fr_CA' => 'fr-CA',
39
        'de_DE' => 'de',
40
        'de_AT)' => 'de-AT',
41
        'de_CH' => 'de-CH',
42
        'el_GR' => 'el',
43
        'he_IL' => 'iw',
44
        'hi_IN' => 'hi',
45
        'hu_HU' => 'hu',
46
        'gu_IN|id_ID' => 'id',
47
        'it_IT|it_CH' => 'it',
48
        'ja_JP' => 'ja',
49
        'ko_KR' => 'ko',
50
        'lv_LV' => 'lv',
51
        'lt_LT' => 'lt',
52
        'nb_NO' => 'no',
53
        'fa_IR' => 'fa',
54
        'pl_PL' => 'pl',
55
        'pt_BR' => 'pt-BR',
56
        'pt_PT' => 'pt-PT',
57
        'ro_RO' => 'ro',
58
        'ru_RU' => 'ru',
59
        'sr_RS' => 'sr',
60
        'sk_SK' => 'sk',
61
        'sl_SI' => 'sl',
62
        'es_ES|gl_ES' => 'es',
63
        'es_AR|es_CL|es_CO|es_CR|es_MX|es_PA|es_PE|es_VE' => 'es-419',
64
        'sv_SE' => 'sv',
65
        'th_TH' => 'th',
66
        'tr_TR' => 'tr',
67
        'uk_UA' => 'uk',
68
        'vi_VN' => 'vi'
69
    );
70
    
71
    /**
72
     * @var
73
     */
74
    protected $_shouldCallScript = null;
75
76
    /**
77
     * Is the block allowed to display.
78
     *
79
     * @param string $route
80
     * @return bool
81
     */
82
    public function isAllowed($route = '')
83
    {
84
        if ($this->hasData('allow')) {
85
            return (bool) $this->getData('allow');
86
        }
87
88
        return $this->_getHelper()->isAllowed($route);
89
    }
90
91
    /**
92
     * Get the recaptcha site key.
93
     *
94
     * @codeCoverageIgnore
95
     * @return string
96
     */
97
    public function getSiteKey()
98
    {
99
        return $this->_getHelper()->getSiteKey();
100
    }
101
102
    /**
103
     * Get the recaptcha theme setting.
104
     *
105
     * @codeCoverageIgnore
106
     * @return string
107
     */
108
    public function getTheme()
109
    {
110
        return $this->_getHelper()->getTheme();
111
    }
112
113
    /**
114
     * Get the recaptcha type setting.
115
     *
116
     * @codeCoverageIgnore
117
     * @return string
118
     */
119
    public function getType()
120
    {
121
        return $this->_getHelper()->getType();
122
    }
123
124
    /**
125
     * Get the recaptcha invisible setting.
126
     *
127
     * @codeCoverageIgnore
128
     * @return string
129
     */
130
    public function isInvisible()
131
    {
132
        return $this->_getHelper()->isInvisible();
133
    }
134
135
    /**
136
     * Get the recaptcha size setting.
137
     *
138
     * @codeCoverageIgnore
139
     * @return string
140
     */
141
    public function getSize()
142
    {
143
        return $this->_getHelper()->getSize();
144
    }
145
146
    /**
147
     * Get the reCAPTACHA javascript code.
148
     *
149
     * @return string
150
     */
151
    public function getRecaptchaScript()
152
    {
153
        if (! $this->_getHelper()->isEnabled()) {
154
            return '';
155
        }
156
157
        $language = Mage::app()->getLocale()->getLocale()->toString();
158
        $lang = 'en';
159
160
        foreach ($this->_languages as $options => $_lang) {
161
            if (stristr($options, $language)) {
162
                $lang = $_lang;
163
            }
164
        }
165
166
        $query = array(
167
            'onload' => 'onloadCallback',
168
            'render' => 'explicit',
169
            'hl'     => $lang
170
        );
171
172
        return sprintf(
173
            '<script src="https://www.google.com/recaptcha/api.js?%s" async defer></script>',
174
            http_build_query($query)
175
        );
176
    }
177
178
    /**
179
     * Get a unique ID for the recaptcha block.
180
     *
181
     * @return string
182
     */
183
    public function getRecaptchaId()
184
    {
185
        return uniqid();
186
    }
187
188
    /**
189
     * Get the recaptcha helper.
190
     *
191
     * @return Studioforty9_Recaptcha_Helper_Data
192
     */
193
    protected function _getHelper()
194
    {
195
        return Mage::helper('studioforty9_recaptcha');
196
    }
197
198
    /**
199
     * Should we call the script again ?
200
     *
201
     * @return bool
202
     */
203
    public function shouldCallScript()
204
    {
205
        if (is_null($this->_shouldCallScript)) {
206
            if (Mage::getSingleton('studioforty9_recaptcha/counter')->getCount()) {
207
                $this->_shouldCallScript = false;
208
            } else {
209
                Mage::getSingleton('studioforty9_recaptcha/counter')->increase();
210
                $this->_shouldCallScript = true;
211
            }
212
        }
213
214
        return $this->_shouldCallScript;
215
    }
216
217
    /**
218
     * Get the button selector for a specific route
219
     *
220
     * @param $currentRoute
221
     * @return bool
222
     */
223
    public function getButtonSelector($currentRoute)
224
    {
225
        $buttonsSelectors = Mage::helper('core/unserializeArray')->unserialize($this->_getHelper()->getButtonsSelector());
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
226
        foreach ($buttonsSelectors as $key => $buttonsSelector) {
227
            if (false !== strpos($currentRoute, $buttonsSelector['routes'])) {
228
                return $buttonsSelector['buttons'];
229
            }
230
        }
231
232
        return false;
233
    }
234
}
235