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 ( 951ad1...29ba67 )
by Alexey
08:55
created

BApplication::setMbEncoding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * @author Sergey Glagolev <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2014 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 * @package backend.components
8
 */
9
10
/**
11
 * Class BApplication
12
 *
13
 * @property BMenu $menu
14
 * @property BBreadcrumbsManager $breadcrumbs
15
 */
16
class BApplication extends CWebApplication
17
{
18
  const CLASS_PREFIX = 'B';
19
20
  /**
21
   * Удаление префикса класса
22
   *
23
   * @param string $className
24
   *
25
   * @return string mixed
26
   */
27 60
  public static function cutClassPrefix($className)
28
  {
29 60
    return preg_replace('/^'.self::CLASS_PREFIX.'([A-Z])(.*)/', '$1$2', $className);
30
  }
31
32
  /**
33
   * Получение id контроллера из BModule::$controllerMap
34
   * если он не находится, то возвращается обычный ID контроллера
35
   * @return string
36
   */
37 4
  public static function getMappedControllerId()
38
  {
39 4
    $controllerMap = Yii::app()->controller->module->controllerMap;
40 4
    $controllerClass = get_class(Yii::app()->controller);
41 4
    $mappedId = array_search($controllerClass, $controllerMap);
42
43 4
    return $mappedId ? : Yii::app()->controller->id;
44
  }
45
46 4
  public function getFrontendRoot()
47
  {
48 4
    return GlobalConfig::instance()->rootPath.'/';
49
  }
50
51 4
  public function getFrontendUrl()
52
  {
53 4
    return $this->request->getHostInfo().'/';
54
  }
55
56
  public function registerAjaxUpdateError()
57
  {
58
    Yii::app()->clientScript->registerScript('ajaxUpdateError', '
59
      function ajaxUpdateError(xhr, err)
60
      {
61
        if( xhr.status === 0 && xhr.readyState === 0 )
62
        {
63
          console.log("Ajax request aborted");
64
          return;
65
        }
66
67
        if( xhr.status === 401 )
68
          assigner.open(
69
            "'.Yii::app()->controller->createUrl("/base/index", array('popup' => true)).'",
70
            {width : "800", height : "400", left : "50%", top : "50%", marginTop : "-250px", marginLeft: "-400px"}
71
          );
72
        else
73
        {
74
          if( !err )
75
          {
76
            if( xhr.status && !/^\s*$/.test(xhr.status) )
77
              err = "Error " + xhr.status;
78
            else
79
            {
80
              err = "Error";
81
            }
82
83
            if( xhr.responseText && !/^\s*$/.test(xhr.responseText) )
84
              err = err + ": " + xhr.responseText;
85
          }
86
87
          alert(err);
88
        }
89
      }', CClientScript::POS_HEAD);
90
  }
91
92
  protected function init()
93
  {
94
    $this->setModules($this->findModules(Yii::getPathOfAlias('backend')));
95
96
    $this->params->project = preg_replace("/^www./", '', Yii::app()->request->serverName);
97
98
    parent::init();
99
  }
100
101
  /**
102
   * @param string $basePath
103
   *
104
   * @return array
105
   */
106
  protected function findModules($basePath)
107
  {
108
    $modulesPath = $basePath.DIRECTORY_SEPARATOR.'modules';
109
    $modules = array();
110
111
    foreach(glob($modulesPath.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR) as $moduleDirectory)
112
    {
113
      if( preg_match("/\w+/", basename($moduleDirectory)) )
114
      {
115
        $moduleName = basename($moduleDirectory);
116
        $modules[$moduleName] = array('autoloaded' => true);
117
118
        if( $submodules = $this->findModules($moduleDirectory) )
119
          $modules[$moduleName]['modules'] = $submodules;
120
      }
121
    }
122
123
    return $modules;
124
  }
125
}