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
Push — master ( 076939...ca2e78 )
by Eoghan
04:33
created

_getHelper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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.0
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
     * Is the block allowed to display.
73
     *
74
     * @param string $route
75
     * @return bool
76
     */
77
    public function isAllowed($route = '')
78
    {
79
        if ($this->hasData('allow')) {
80
            return (bool) $this->getData('allow');
81
        }
82
83
        return $this->_getHelper()->isAllowed($route);
84
    }
85
86
    /**
87
     * Get the recaptcha site key.
88
     *
89
     * @codeCoverageIgnore
90
     * @return string
91
     */
92
    public function getSiteKey()
93
    {
94
        return $this->_getHelper()->getSiteKey();
95
    }
96
97
    /**
98
     * Get the recaptcha theme setting.
99
     *
100
     * @codeCoverageIgnore
101
     * @return string
102
     */
103
    public function getTheme()
104
    {
105
        return $this->_getHelper()->getTheme();
106
    }
107
108
    /**
109
     * Get the recaptcha type setting.
110
     *
111
     * @codeCoverageIgnore
112
     * @return string
113
     */
114
    public function getType()
115
    {
116
        return $this->_getHelper()->getType();
117
    }
118
119
    /**
120
     * Get the recaptcha size setting.
121
     *
122
     * @codeCoverageIgnore
123
     * @return string
124
     */
125
    public function getSize()
126
    {
127
        return $this->_getHelper()->getSize();
128
    }
129
130
    /**
131
     * Get the reCAPTACHA javascript code.
132
     *
133
     * @return string
134
     */
135
    public function getRecaptchaScript()
136
    {
137
        if (! $this->_getHelper()->isEnabled()) {
138
            return '';
139
        }
140
141
        $language = Mage::app()->getLocale()->getLocale()->toString();
142
        $lang = 'en';
143
144
        foreach ($this->_languages as $options => $_lang) {
145
            if (stristr($options, $language)) {
146
                $lang = $_lang;
147
            }
148
        }
149
150
        $query = array(
151
            'onload' => 'onloadCallback',
152
            'render' => 'explicit',
153
            'hl'     => $lang
154
        );
155
156
        return sprintf(
157
            '<script src="https://www.google.com/recaptcha/api.js?%s" async defer></script>',
158
            http_build_query($query)
159
        );
160
    }
161
162
    /**
163
     * Get a unique ID for the recaptcha block.
164
     *
165
     * @return string
166
     */
167
    public function getRecaptchaId()
168
    {
169
        return uniqid();
170
    }
171
172
    /**
173
     * Get the recaptcha helper.
174
     *
175
     * @return Studioforty9_Recaptcha_Helper_Data
176
     */
177
    protected function _getHelper()
178
    {
179
        return Mage::helper('studioforty9_recaptcha');
180
    }
181
}
182