Jitamin /
jitamin
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of Jitamin. |
||
| 5 | * |
||
| 6 | * Copyright (C) Jitamin Team |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Jitamin\Helper; |
||
| 13 | |||
| 14 | use Jitamin\Foundation\Base; |
||
| 15 | use Jitamin\Foundation\Http\Router; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Application Helper. |
||
| 19 | */ |
||
| 20 | class AppHelper extends Base |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Get setting variable. |
||
| 24 | * |
||
| 25 | * @param string $param |
||
| 26 | * @param mixed $default_value |
||
| 27 | * |
||
| 28 | * @return mixed |
||
| 29 | */ |
||
| 30 | public function setting($param, $default_value = '') |
||
| 31 | { |
||
| 32 | return $this->settingModel->get($param, $default_value); |
||
|
0 ignored issues
–
show
|
|||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Set active class if request is in path. |
||
| 37 | * |
||
| 38 | * @param string $controller |
||
| 39 | * @param string $action |
||
| 40 | * @param string $slug |
||
| 41 | * @param string $plugin |
||
| 42 | * |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | public function setActive($controller, $action = '', $slug = '', $plugin = '') |
||
| 46 | { |
||
| 47 | $currentController = strtolower($this->getRouterController()); |
||
| 48 | $currentAction = strtolower($this->getRouterAction()); |
||
| 49 | $controller = strtolower($controller); |
||
| 50 | $action = strtolower($action); |
||
| 51 | |||
| 52 | $result = $currentController === $controller; |
||
| 53 | |||
| 54 | if ($result && $action !== '') { |
||
| 55 | $result = $currentAction === $action; |
||
| 56 | } |
||
| 57 | |||
| 58 | if ($result && $plugin !== '') { |
||
| 59 | $result = strtolower($this->getPluginName()) === strtolower($plugin); |
||
| 60 | } |
||
| 61 | |||
| 62 | if (!$result && $slug !== '') { |
||
| 63 | if ($this->getRouterController() == 'Project/ProjectController' && $this->getRouterAction() == 'show') { |
||
| 64 | list($className, $method) = $this->getProjectDefaultView($slug); |
||
| 65 | $result = $controller == strtolower($className) && $action == strtolower($method); |
||
| 66 | } elseif ($this->getRouterController() == 'Dashboard/DashboardController' && $this->getRouterAction() == 'index') { |
||
| 67 | list($className, $method) = $this->getDashboard(); |
||
| 68 | $result = $controller == strtolower($className) && $action == strtolower($method); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | return $result ? 'class="active"' : ''; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Get plugin name from route. |
||
| 77 | * |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | public function getPluginName() |
||
| 81 | { |
||
| 82 | return $this->router->getPlugin(); |
||
|
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Get router controller. |
||
| 87 | * |
||
| 88 | * @return string |
||
| 89 | */ |
||
| 90 | public function getRouterController() |
||
| 91 | { |
||
| 92 | return $this->router->getController(); |
||
|
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Get router action. |
||
| 97 | * |
||
| 98 | * @return string |
||
| 99 | */ |
||
| 100 | public function getRouterAction() |
||
| 101 | { |
||
| 102 | return $this->router->getAction(); |
||
|
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Get javascript language code. |
||
| 107 | * |
||
| 108 | * @return string |
||
| 109 | */ |
||
| 110 | public function jsLang() |
||
| 111 | { |
||
| 112 | return $this->languageModel->getJsLanguageCode(); |
||
|
0 ignored issues
–
show
The property
languageModel does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Get date format for Jquery DatePicker. |
||
| 117 | * |
||
| 118 | * @return string |
||
| 119 | */ |
||
| 120 | public function getJsDateFormat() |
||
| 121 | { |
||
| 122 | $format = $this->dateParser->getUserDateFormat(); |
||
|
0 ignored issues
–
show
The property
dateParser does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 123 | $format = str_replace('m', 'mm', $format); |
||
| 124 | $format = str_replace('Y', 'yy', $format); |
||
| 125 | $format = str_replace('d', 'dd', $format); |
||
| 126 | |||
| 127 | return $format; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Get time format for Jquery Plugin DateTimePicker. |
||
| 132 | * |
||
| 133 | * @return string |
||
| 134 | */ |
||
| 135 | public function getJsTimeFormat() |
||
| 136 | { |
||
| 137 | $format = $this->dateParser->getUserTimeFormat(); |
||
|
0 ignored issues
–
show
The property
dateParser does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 138 | $format = str_replace('H', 'HH', $format); |
||
| 139 | $format = str_replace('i', 'mm', $format); |
||
| 140 | $format = str_replace('g', 'h', $format); |
||
| 141 | $format = str_replace('a', 'tt', $format); |
||
| 142 | |||
| 143 | return $format; |
||
| 144 | } |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Get current skin. |
||
| 148 | * |
||
| 149 | * @return string |
||
| 150 | */ |
||
| 151 | public function getSkin() |
||
| 152 | { |
||
| 153 | return $this->skinModel->getCurrentSkin(); |
||
|
0 ignored issues
–
show
The property
skinModel does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 154 | } |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Get current skin. |
||
| 158 | * |
||
| 159 | * @return string |
||
| 160 | */ |
||
| 161 | public function getLayout() |
||
| 162 | { |
||
| 163 | return $this->skinModel->getCurrentLayout(); |
||
|
0 ignored issues
–
show
The property
skinModel does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 164 | } |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Get default view of project. |
||
| 168 | * |
||
| 169 | * @return array |
||
| 170 | */ |
||
| 171 | public function getProjectDefaultView($slug = '', $forController = false) |
||
| 172 | { |
||
| 173 | if ($slug === null) { |
||
| 174 | $slug = $this->setting('project_view', null); |
||
| 175 | } |
||
| 176 | |||
| 177 | switch ($slug) { |
||
| 178 | case 'gantt': |
||
| 179 | $controller = 'Task/TaskController'; |
||
| 180 | $action = 'gantt'; |
||
| 181 | break; |
||
| 182 | case 'board': |
||
| 183 | $controller = 'Project/Board/BoardController'; |
||
| 184 | $action = 'show'; |
||
| 185 | break; |
||
| 186 | case 'list': |
||
| 187 | $controller = 'Task/TaskController'; |
||
| 188 | $action = 'index'; |
||
| 189 | break; |
||
| 190 | case 'calendar': |
||
| 191 | $controller = 'CalendarController'; |
||
| 192 | $action = 'show'; |
||
| 193 | break; |
||
| 194 | default: |
||
| 195 | $controller = 'Project/ProjectController'; |
||
| 196 | $action = 'overview'; |
||
| 197 | } |
||
| 198 | $controller = $forController ? 'Jitamin\\Http\\Controllers\\'.str_replace('/', '\\', $controller) : $controller; |
||
| 199 | |||
| 200 | return [$controller, $action]; |
||
| 201 | } |
||
| 202 | |||
| 203 | /** |
||
| 204 | * Get current dashboard. |
||
| 205 | * |
||
| 206 | * @return array |
||
| 207 | */ |
||
| 208 | public function getDashboard($forController = false) |
||
| 209 | { |
||
| 210 | $slug = $this->skinModel->getCurrentDashboard(); |
||
|
0 ignored issues
–
show
The property
skinModel does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 211 | switch ($slug) { |
||
| 212 | case 'projects': |
||
| 213 | $controller = 'Dashboard/ProjectController'; |
||
| 214 | $action = 'index'; |
||
| 215 | break; |
||
| 216 | case 'stars': |
||
| 217 | $controller = 'Dashboard/ProjectController'; |
||
| 218 | $action = 'starred'; |
||
| 219 | break; |
||
| 220 | case 'calendar': |
||
| 221 | $controller = 'Dashboard/DashboardController'; |
||
| 222 | $action = 'calendar'; |
||
| 223 | break; |
||
| 224 | case 'activities': |
||
| 225 | $controller = 'Dashboard/DashboardController'; |
||
| 226 | $action = 'activities'; |
||
| 227 | break; |
||
| 228 | case 'tasks': |
||
| 229 | $controller = 'Dashboard/DashboardController'; |
||
| 230 | $action = 'tasks'; |
||
| 231 | break; |
||
| 232 | default: |
||
| 233 | $controller = 'Dashboard/ProjectController'; |
||
| 234 | $action = 'index'; |
||
| 235 | } |
||
| 236 | |||
| 237 | $controller = $forController ? 'Jitamin\\Http\\Controllers\\'.str_replace('/', '\\', $controller) : $controller; |
||
| 238 | |||
| 239 | return [$controller, $action]; |
||
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * Get current timezone. |
||
| 244 | * |
||
| 245 | * @return string |
||
| 246 | */ |
||
| 247 | public function getTimezone() |
||
| 248 | { |
||
| 249 | return $this->timezoneModel->getCurrentTimezone(); |
||
|
0 ignored issues
–
show
The property
timezoneModel does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 250 | } |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Get session flash message. |
||
| 254 | * |
||
| 255 | * @return string |
||
| 256 | */ |
||
| 257 | public function flashMessage() |
||
| 258 | { |
||
| 259 | $success_message = $this->flash->getMessage('success'); |
||
|
0 ignored issues
–
show
The property
flash does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 260 | $failure_message = $this->flash->getMessage('failure'); |
||
|
0 ignored issues
–
show
The property
flash does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 261 | |||
| 262 | if (!empty($success_message)) { |
||
| 263 | return '<div class="alert alert-success alert-dismissible alert-fade-out">'. |
||
| 264 | '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'. |
||
| 265 | $this->helper->text->e($success_message). |
||
|
0 ignored issues
–
show
The property
helper does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 266 | '</div>'; |
||
| 267 | } |
||
| 268 | |||
| 269 | if (!empty($failure_message)) { |
||
| 270 | return '<div class="alert alert-error alert-dismissible">'. |
||
| 271 | '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'. |
||
| 272 | $this->helper->text->e($failure_message). |
||
|
0 ignored issues
–
show
The property
helper does not exist on object<Jitamin\Helper\AppHelper>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 273 | '</div>'; |
||
| 274 | } |
||
| 275 | |||
| 276 | return ''; |
||
| 277 | } |
||
| 278 | } |
||
| 279 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.