Merge pull request #3690 from nathan-van-der-werf/feature/cleanup

Code cleanups
This commit is contained in:
Samuel Georges 2018-08-30 13:12:42 +10:00 committed by GitHub
commit 5cc327c45c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
126 changed files with 286 additions and 742 deletions

View File

@ -5,7 +5,6 @@ use Str;
use Lang;
use Flash;
use Event;
use Input;
use Redirect;
use Backend;
use Backend\Classes\ControllerBehavior;
@ -437,8 +436,7 @@ class FormController extends ControllerBehavior
protected function createModel()
{
$class = $this->config->modelClass;
$model = new $class;
return $model;
return new $class;
}
/**
@ -473,7 +471,7 @@ class FormController extends ControllerBehavior
$redirect = Redirect::to($redirectUrl);
} else {
// Process relative redirects
$redirect = ($redirectUrl) ? Backend::redirect($redirectUrl) : null;
$redirect = $redirectUrl ? Backend::redirect($redirectUrl) : null;
}
return $redirect;

View File

@ -590,9 +590,7 @@ class ImportExportController extends ControllerBehavior
{
$lists = $this->controller->makeLists();
$widget = isset($lists[$definition])
? $lists[$definition]
: reset($lists);
$widget = $lists[$definition] ?? reset($lists);
/*
* Parse options
@ -697,8 +695,7 @@ class ImportExportController extends ControllerBehavior
$widgetConfig->alias = $type.'OptionsForm';
$widgetConfig->arrayName = ucfirst($type).'Options';
$widget = $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
return $widget;
return $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
}
return null;

View File

@ -1,6 +1,5 @@
<?php namespace Backend\Behaviors;
use Str;
use Lang;
use Event;
use Flash;

View File

@ -2,7 +2,6 @@
use Db;
use Lang;
use Event;
use Request;
use Form as FormHelper;
use Backend\Classes\ControllerBehavior;
@ -379,11 +378,9 @@ class RelationController extends ControllerBehavior
/*
* Pivot widget
*/
if ($this->manageMode == 'pivot') {
if ($this->pivotWidget = $this->makePivotWidget()) {
$this->controller->relationExtendPivotWidget($this->pivotWidget, $this->field, $this->model);
$this->pivotWidget->bindToController();
}
if ($this->manageMode == 'pivot' && $this->pivotWidget = $this->makePivotWidget()) {
$this->controller->relationExtendPivotWidget($this->pivotWidget, $this->field, $this->model);
$this->pivotWidget->bindToController();
}
}
@ -423,7 +420,7 @@ class RelationController extends ControllerBehavior
/*
* Determine the partial to use based on the supplied section option
*/
$section = (isset($options['section'])) ? $options['section'] : null;
$section = $options['section'] ?? null;
switch (strtolower($section)) {
case 'toolbar':
return $this->toolbarWidget ? $this->toolbarWidget->render() : null;
@ -695,22 +692,22 @@ class RelationController extends ControllerBehavior
/*
* Constrain the list by the search widget, if available
*/
if ($this->toolbarWidget && $this->getConfig('view[showSearch]')) {
if ($searchWidget = $this->toolbarWidget->getSearchWidget()) {
$searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) {
$widget->setSearchTerm($searchWidget->getActiveTerm());
return $widget->onRefresh();
});
if ($this->toolbarWidget && $this->getConfig('view[showSearch]')
&& $searchWidget = $this->toolbarWidget->getSearchWidget()
) {
$searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) {
$widget->setSearchTerm($searchWidget->getActiveTerm());
return $widget->onRefresh();
});
/*
* Persist the search term across AJAX requests only
*/
if (Request::ajax()) {
$widget->setSearchTerm($searchWidget->getActiveTerm());
}
else {
$searchWidget->setActiveTerm(null);
}
/*
* Persist the search term across AJAX requests only
*/
if (Request::ajax()) {
$widget->setSearchTerm($searchWidget->getActiveTerm());
}
else {
$searchWidget->setActiveTerm(null);
}
}
}
@ -905,8 +902,7 @@ class RelationController extends ControllerBehavior
$config->model->setRelation('pivot', $pivotModel);
}
$widget = $this->makeWidget('Backend\Widgets\Form', $config);
return $widget;
return $this->makeWidget('Backend\Widgets\Form', $config);
}
//
@ -1448,9 +1444,8 @@ class RelationController extends ControllerBehavior
if ($this->eventTarget == 'button-link') {
return 'backend::lang.relation.link_a_new';
}
else {
return 'backend::lang.relation.add_a_new';
}
return 'backend::lang.relation.add_a_new';
case 'form':
if ($this->readOnly) {
return 'backend::lang.relation.preview_name';
@ -1511,9 +1506,8 @@ class RelationController extends ControllerBehavior
if ($this->eventTarget == 'button-add') {
return 'list';
}
else {
return 'form';
}
return 'form';
}
}
@ -1522,14 +1516,12 @@ class RelationController extends ControllerBehavior
*/
protected function evalFormContext($mode = 'manage', $exists = false)
{
$config = isset($this->config->{$mode}) ? $this->config->{$mode} : [];
$config = $this->config->{$mode} ?? [];
if ($context = array_get($config, 'context')) {
if (is_array($context)) {
$context = $exists
? array_get($context, 'update')
: array_get($context, 'create');
}
if (($context = array_get($config, 'context')) && is_array($context)) {
$context = $exists
? array_get($context, 'update')
: array_get($context, 'create');
}
if (!$context) {
@ -1605,9 +1597,8 @@ class RelationController extends ControllerBehavior
if ($throwException) {
throw new ApplicationException('Missing configuration for '.$mode.'.'.$type.' in RelationController definition '.$this->field);
}
else {
return false;
}
return false;
}
return $this->makeConfig($config);

View File

@ -55,7 +55,7 @@ class ReorderController extends ControllerBehavior
* - simple: October\Rain\Database\Traits\Sortable
* - nested: October\Rain\Database\Traits\NestedTree
*/
protected $sortMode = null;
protected $sortMode;
/**
* @var Backend\Classes\WidgetBase Reference to the widget used for the toolbar.

View File

@ -150,9 +150,7 @@ class AuthManager extends RainAuthManager
$tabs = [];
foreach ($this->listPermissions() as $permission) {
$tab = isset($permission->tab)
? $permission->tab
: 'backend::lang.form.undefined_tab';
$tab = $permission->tab ?? 'backend::lang.form.undefined_tab';
if (!array_key_exists($tab, $tabs)) {
$tabs[$tab] = [];

View File

@ -82,8 +82,8 @@ class BackendController extends ControllerBase
/*
* Look for a Module controller
*/
$module = isset($params[0]) ? $params[0] : 'backend';
$controller = isset($params[1]) ? $params[1] : 'index';
$module = $params[0] ?? 'backend';
$controller = $params[1] ?? 'index';
self::$action = $action = isset($params[2]) ? $this->parseAction($params[2]) : 'index';
self::$params = $controllerParams = array_slice($params, 3);
$controllerClass = '\\'.$module.'\Controllers\\'.$controller;
@ -100,7 +100,7 @@ class BackendController extends ControllerBase
*/
if (count($params) >= 2) {
list($author, $plugin) = $params;
$controller = isset($params[2]) ? $params[2] : 'index';
$controller = $params[2] ?? 'index';
self::$action = $action = isset($params[3]) ? $this->parseAction($params[3]) : 'index';
self::$params = $controllerParams = array_slice($params, 4);
$controllerClass = '\\'.$author.'\\'.$plugin.'\Controllers\\'.$controller;
@ -136,7 +136,7 @@ class BackendController extends ControllerBase
$controller = Str::normalizeClassName($controller);
$controllerFile = $inPath.strtolower(str_replace('\\', '/', $controller)) . '.php';
if ($controllerFile = File::existsInsensitive($controllerFile)) {
include_once($controllerFile);
include_once $controllerFile;
}
}

View File

@ -1,6 +1,5 @@
<?php namespace Backend\Classes;
use App;
use Lang;
use View;
use Flash;
@ -361,7 +360,7 @@ class Controller extends Extendable
}
// Load the view
if (!$this->suppressView && is_null($result)) {
if (!$this->suppressView && $result === null) {
return $this->makeView($actionName);
}
@ -520,7 +519,7 @@ class Controller extends Extendable
if (($widget = $this->widget->{$widgetName}) && $widget->methodExists($handlerName)) {
$result = $this->runAjaxHandlerForWidget($widget, $handlerName);
return ($result) ?: true;
return $result ?: true;
}
}
else {
@ -531,7 +530,7 @@ class Controller extends Extendable
if ($this->methodExists($pageHandler)) {
$result = call_user_func_array([$this, $pageHandler], $this->params);
return ($result) ?: true;
return $result ?: true;
}
/*
@ -539,7 +538,7 @@ class Controller extends Extendable
*/
if ($this->methodExists($handler)) {
$result = call_user_func_array([$this, $handler], $this->params);
return ($result) ?: true;
return $result ?: true;
}
/*
@ -551,7 +550,7 @@ class Controller extends Extendable
foreach ((array) $this->widget as $widget) {
if ($widget->methodExists($handler)) {
$result = $this->runAjaxHandlerForWidget($widget, $handler);
return ($result) ?: true;
return $result ?: true;
}
}
}

View File

@ -81,7 +81,7 @@ class ControllerBehavior extends ExtensionBase
/*
* Return all config
*/
if (is_null($name)) {
if ($name === null) {
return $this->config;
}

View File

@ -54,7 +54,7 @@ class FilterScope
/**
* @var string Specifies contextual visibility of this form scope.
*/
public $context = null;
public $context;
/**
* @var bool Specify if the scope is disabled or not.

View File

@ -94,12 +94,12 @@ class FormField
/**
* @var string Specifies contextual visibility of this form field.
*/
public $context = null;
public $context;
/**
* @var bool Specifies if this field is mandatory.
*/
public $required = null;
public $required;
/**
* @var bool Specify if the field is read-only or not.
@ -234,9 +234,8 @@ class FormField
return [];
}
else {
$this->options = $value;
}
$this->options = $value;
return $this;
}
@ -266,7 +265,7 @@ class FormField
*/
protected function evalConfig($config)
{
if (is_null($config)) {
if ($config === null) {
$config = [];
}
@ -567,9 +566,8 @@ class FormField
if ($arrayName) {
return $arrayName.'['.implode('][', HtmlHelper::nameToArray($this->fieldName)).']';
}
else {
return $this->fieldName;
}
return $this->fieldName;
}
/**

View File

@ -35,7 +35,7 @@ class FormTabs implements IteratorAggregate, ArrayAccess
/**
* @var bool Should these tabs stretch to the bottom of the page layout.
*/
public $stretch = null;
public $stretch;
/**
* @var boolean If set to TRUE, fields will not be displayed in tabs.
@ -232,6 +232,6 @@ class FormTabs implements IteratorAggregate, ArrayAccess
*/
public function offsetGet($offset)
{
return isset($this->fields[$offset]) ? $this->fields[$offset] : null;
return $this->fields[$offset] ?? null;
}
}

View File

@ -317,7 +317,7 @@ class NavigationManager
{
$activeItem = null;
if (!is_null($owner) && !is_null($code)) {
if ($owner !== null && $code !== null) {
$activeItem = @$this->items[$this->makeItemKey($owner, $code)];
} else {
foreach ($this->listMainMenuItems() as $item) {
@ -466,9 +466,7 @@ class NavigationManager
{
$key = $owner.$mainMenuItemCode;
return array_key_exists($key, $this->contextSidenavPartials)
? $this->contextSidenavPartials[$key]
: null;
return $this->contextSidenavPartials[$key] ?? null;
}
/**

View File

@ -80,11 +80,10 @@ abstract class Skin
? $this->publicSkinPath . $path
: $this->skinPath . $path;
}
else {
return $isPublic
? $this->defaultPublicSkinPath . $path
: $this->defaultSkinPath . $path;
}
return $isPublic
? $this->defaultPublicSkinPath . $path
: $this->defaultSkinPath . $path;
}
/**

View File

@ -1,7 +1,5 @@
<?php namespace Backend\Classes;
use Str;
use File;
use October\Rain\Html\Helper as HtmlHelper;
use October\Rain\Extension\Extendable;
use stdClass;
@ -65,7 +63,7 @@ abstract class WidgetBase extends Extendable
* If no alias is set by the configuration.
*/
if (!isset($this->alias)) {
$this->alias = (isset($this->config->alias)) ? $this->config->alias : $this->defaultAlias;
$this->alias = $this->config->alias ?? $this->defaultAlias;
}
/*

View File

@ -103,7 +103,7 @@ class WidgetManager
$widgetInfo = ['code' => $widgetInfo];
}
$widgetCode = isset($widgetInfo['code']) ? $widgetInfo['code'] : null;
$widgetCode = $widgetInfo['code'] ?? null;
if (!$widgetCode) {
$widgetCode = Str::getClassId($className);

View File

@ -54,9 +54,8 @@ class Auth extends Controller
if (post('postback')) {
return $this->signin_onSubmit();
}
else {
$this->bodyClass .= ' preload';
}
$this->bodyClass .= ' preload';
}
catch (Exception $ex) {
Flash::error($ex->getMessage());
@ -75,7 +74,7 @@ class Auth extends Controller
throw new ValidationException($validation);
}
if (is_null($remember = config('cms.backendForceRemember', true))) {
if (($remember = config('cms.backendForceRemember', true)) === null) {
$remember = (bool) post('remember');
}

View File

@ -1,7 +1,6 @@
<?php namespace Backend\Controllers;
use Redirect;
use BackendAuth;
use BackendMenu;
use Backend\Classes\Controller;
use Backend\Widgets\ReportContainer;

View File

@ -1,7 +1,6 @@
<?php namespace Backend\Controllers;
use BackendMenu;
use BackendAuth;
use Backend\Classes\Controller;
use System\Classes\SettingsManager;

View File

@ -3,7 +3,6 @@
use View;
use Response;
use BackendMenu;
use BackendAuth;
use Backend\Classes\Controller;
use System\Classes\SettingsManager;

View File

@ -26,25 +26,25 @@ class DatePicker extends FormWidgetBase
/**
* @var string Provide an explicit date display format.
*/
public $format = null;
public $format;
/**
* @var string the minimum/earliest date that can be selected.
* eg: 2000-01-01
*/
public $minDate = null;
public $minDate;
/**
* @var string the maximum/latest date that can be selected.
* eg: 2020-12-31
*/
public $maxDate = null;
public $maxDate;
/**
* @var string number of years either side or array of upper/lower range
* eg: 10 or [1900,1999]
*/
public $yearRange = null;
public $yearRange;
/**
* @var int first day of the week
@ -90,13 +90,13 @@ class DatePicker extends FormWidgetBase
$this->mode = strtolower($this->mode);
if ($this->minDate !== null) {
$this->minDate = is_integer($this->minDate)
$this->minDate = is_int($this->minDate)
? Carbon::createFromTimestamp($this->minDate)
: Carbon::parse($this->minDate);
}
if ($this->maxDate !== null) {
$this->maxDate = is_integer($this->maxDate)
$this->maxDate = is_int($this->maxDate)
? Carbon::createFromTimestamp($this->maxDate)
: Carbon::parse($this->maxDate);
}

View File

@ -1,6 +1,5 @@
<?php namespace Backend\FormWidgets;
use Str;
use Input;
use Request;
use Response;
@ -36,17 +35,17 @@ class FileUpload extends FormWidgetBase
/**
* @var string Prompt text to display for the upload button.
*/
public $prompt = null;
public $prompt;
/**
* @var int Preview image width
*/
public $imageWidth = null;
public $imageWidth;
/**
* @var int Preview image height
*/
public $imageHeight = null;
public $imageHeight;
/**
* @var mixed Collection of acceptable file types.
@ -207,7 +206,7 @@ class FileUpload extends FormWidgetBase
$cssDimensions = '';
if ($mode == 'block') {
$cssDimensions .= ($this->imageWidth)
$cssDimensions .= $this->imageWidth
? 'width: '.$this->imageWidth.'px;'
: 'width: '.$this->imageHeight.'px;';
@ -216,7 +215,7 @@ class FileUpload extends FormWidgetBase
: 'height: auto;';
}
else {
$cssDimensions .= ($this->imageWidth)
$cssDimensions .= $this->imageWidth
? 'width: '.$this->imageWidth.'px;'
: 'width: auto;';

View File

@ -1,7 +1,5 @@
<?php namespace Backend\FormWidgets;
use Lang;
use ApplicationException;
use System\Classes\MediaLibrary;
use Backend\Classes\FormField;
use Backend\Classes\FormWidgetBase;
@ -37,12 +35,12 @@ class MediaFinder extends FormWidgetBase
/**
* @var int Preview image width
*/
public $imageWidth = null;
public $imageWidth;
/**
* @var int Preview image height
*/
public $imageHeight = null;
public $imageHeight;
//
// Object properties

View File

@ -1,7 +1,5 @@
<?php namespace Backend\FormWidgets;
use Lang;
use ApplicationException;
use Backend\Classes\FormWidgetBase;
/**
@ -213,7 +211,7 @@ class RecordFinder extends FormWidgetBase
{
list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom);
if (!is_null($model)) {
if ($model !== null) {
return $model->{$attribute};
}

View File

@ -1,11 +1,8 @@
<?php namespace Backend\FormWidgets;
use Db;
use Lang;
use Backend\Classes\FormField;
use Backend\Classes\FormWidgetBase;
use ApplicationException;
use SystemException;
use Illuminate\Database\Eloquent\Relations\Relation as RelationBase;
/**

View File

@ -2,7 +2,6 @@
use Lang;
use ApplicationException;
use Backend\Classes\FormField;
use Backend\Classes\FormWidgetBase;
/**
@ -40,12 +39,12 @@ class Repeater extends FormWidgetBase
/**
* @var int Minimum items required. Pre-displays those items when not using groups
*/
public $minItems = null;
public $minItems;
/**
* @var int Maximum items permitted
*/
public $maxItems = null;
public $maxItems;
//
// Object properties

View File

@ -29,7 +29,7 @@ class RichEditor extends FormWidgetBase
/**
* @var boolean Determines whether content has HEAD and HTML tags.
*/
public $toolbarButtons = null;
public $toolbarButtons;
/**
* @var boolean If true, the editor is set to read-only mode

View File

@ -30,7 +30,7 @@ class TagList extends FormWidgetBase
/**
* @var mixed Predefined options settings. Set to true to get from model.
*/
public $options = null;
public $options;
/**
* @var string Mode for the return value. Values: string, array, relation.

View File

@ -136,7 +136,6 @@ return [
'setup_title' => 'Настройка на списък',
'setup_help' => 'Използвайте тикчетата, за да изберете колони, които искате да видите в списъка. Можете да промените позицията на колони, като ги плъзнете нагоре или надолу.',
'records_per_page' => 'Записи на страница',
'records_per_page_help' => 'Select the number of records per page to display. Please note that high number of records on a single page can reduce performance.',
'records_per_page_help' => 'Изберете брой на записи за показване на страница. Моля, имайте предвид, че голям брой записи на една страница може да забави работата на страницата.',
'delete_selected' => 'Изтрии избраните',
'delete_selected_empty' => 'Не са избрани записи за изтриване.',

View File

@ -555,8 +555,6 @@ return [
'direction_asc' => 'صعودی',
'direction_desc' => 'نزولی',
'folder' => 'پوشه',
'direction_asc' => 'صعودی',
'direction_desc' => 'نزولی',
'no_files_found' => 'فایلی با درخواست شما یافت نشد',
'delete_empty' => 'لطفا موارد را جهت حذف انتخاب نمایید',
'delete_confirm' => 'آیا از حذف مورد(های) انتخاب شده اطمینان دارید؟',

View File

@ -131,9 +131,7 @@ class BrandSetting extends Model
self::get('custom_css')
);
$css = $parser->getCss();
return $css;
return $parser->getCss();
}
//

View File

@ -182,8 +182,6 @@ class EditorSetting extends Model
$parser->parse($customStyles);
$css = $parser->getCss();
return $css;
return $parser->getCss();
}
}

View File

@ -9,7 +9,6 @@ use BackendAuth;
use DirectoryIterator;
use DateTime;
use DateTimeZone;
use Carbon\Carbon;
/**
* Backend preferences for the backend user

View File

@ -96,12 +96,11 @@ class User extends UserBase
if ($this->avatar) {
return $this->avatar->getThumb($size, $size, $options);
}
else {
return '//www.gravatar.com/avatar/' .
md5(strtolower(trim($this->email))) .
'?s='. $size .
'&d='. urlencode($default);
}
return '//www.gravatar.com/avatar/' .
md5(strtolower(trim($this->email))) .
'?s='. $size .
'&d='. urlencode($default);
}
/**

View File

@ -1,8 +1,6 @@
<?php namespace Backend\Models;
use Exception;
use BackendAuth;
use October\Rain\Database\Model;
use SystemException;
use October\Rain\Auth\Models\Preferences as PreferencesBase;

View File

@ -3,7 +3,6 @@
use Str;
use Backend\Classes\FormField;
use October\Rain\Halcyon\Model as HalcyonModel;
use October\Rain\Database\Model as DatabaseModel;
/**
* Implements special logic for processing form data, typically from from postback, and

View File

@ -2,7 +2,6 @@
use Str;
use Session;
use SystemException;
/**
* Session Maker Trait
@ -55,7 +54,7 @@ trait SessionMaker
return $currentStore;
}
return isset($currentStore[$key]) ? $currentStore[$key] : $default;
return $currentStore[$key] ?? $default;
}
/**

View File

@ -32,7 +32,7 @@ class Filter extends WidgetBase
* @var string The context of this filter, scopes that do not belong
* to this context will not be shown.
*/
public $context = null;
public $context;
//
// Object properties
@ -151,11 +151,11 @@ class Filter extends WidgetBase
$min = $scope->value[0];
$max = $scope->value[1];
$params['minStr'] = $min ? $min : '';
$params['min'] = $min ? $min : null;
$params['minStr'] = $min ?: '';
$params['min'] = $min ?: null;
$params['maxStr'] = $max ? $max : '∞';
$params['max'] = $max ? $max : null;
$params['maxStr'] = $max ?: '∞';
$params['max'] = $max ?: null;
}
break;
@ -195,7 +195,7 @@ class Filter extends WidgetBase
break;
case 'checkbox':
$checked = post('value') == 'true' ? true : false;
$checked = post('value') == 'true';
$this->setScopeValue($scope, $checked);
break;
@ -263,7 +263,7 @@ class Filter extends WidgetBase
case 'text':
$values = post('options.value');
if (!is_null($values) && $values !== '') {
if ($values !== null && $values !== '') {
list($value) = $values;
}
else {
@ -574,7 +574,7 @@ class Filter extends WidgetBase
* Check that the filter scope matches the active context
*/
if ($scopeObj->context !== null) {
$context = (is_array($scopeObj->context)) ? $scopeObj->context : [$scopeObj->context];
$context = is_array($scopeObj->context) ? $scopeObj->context : [$scopeObj->context];
if (!in_array($this->getContext(), $context)) {
continue;
}
@ -634,8 +634,8 @@ class Filter extends WidgetBase
*/
protected function makeFilterScope($name, $config)
{
$label = (isset($config['label'])) ? $config['label'] : null;
$scopeType = isset($config['type']) ? $config['type'] : null;
$label = $config['label'] ?? null;
$scopeType = $config['type'] ?? null;
$scope = new FilterScope($name, $label);
$scope->displayAs($scopeType, $config);
@ -755,6 +755,8 @@ class Filter extends WidgetBase
}
}
break;
case 'numberrange':
if (is_array($scope->value) && count($scope->value) > 1) {
list($min, $max) = array_values($scope->value);

View File

@ -56,7 +56,7 @@ class Form extends WidgetBase
* @var string The context of this form, fields that do not belong
* to this context will not be shown.
*/
public $context = null;
public $context;
/**
* @var string If the field element names should be contained in an array.
@ -686,7 +686,7 @@ class Form extends WidgetBase
* Check that the form field matches the active context
*/
if ($fieldObj->context !== null) {
$context = (is_array($fieldObj->context)) ? $fieldObj->context : [$fieldObj->context];
$context = is_array($fieldObj->context) ? $fieldObj->context : [$fieldObj->context];
if (!in_array($this->getContext(), $context)) {
continue;
}
@ -779,7 +779,7 @@ class Form extends WidgetBase
*/
protected function makeFormField($name, $config = [])
{
$label = (isset($config['label'])) ? $config['label'] : null;
$label = $config['label'] ?? null;
list($fieldName, $fieldContext) = $this->getFieldName($name);
$field = new FormField($fieldName, $label);
@ -806,11 +806,11 @@ class Form extends WidgetBase
* Defined field type
*/
else {
$fieldType = isset($config['type']) ? $config['type'] : null;
if (!is_string($fieldType) && !is_null($fieldType)) {
$fieldType = $config['type'] ?? null;
if (!is_string($fieldType) && $fieldType !== null) {
throw new ApplicationException(Lang::get(
'backend::lang.field.invalid_type',
['type'=>gettype($fieldType)]
['type' => gettype($fieldType)]
));
}
@ -873,7 +873,7 @@ class Form extends WidgetBase
* Defer the execution of option data collection
*/
$field->options(function () use ($field, $config) {
$fieldOptions = isset($config['options']) ? $config['options'] : null;
$fieldOptions = $config['options'] ?? null;
$fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
return $fieldOptions;
});
@ -1106,8 +1106,7 @@ class Form extends WidgetBase
}
if ($field->type === 'widget') {
$widget = $this->makeFormFieldWidget($field);
return $widget->showLabels;
return $this->makeFormFieldWidget($field)->showLabels;
}
return true;
@ -1343,9 +1342,9 @@ class Form extends WidgetBase
$key = array_shift($parts);
if (isset($array[$key])) {
return $array[$key];
} else {
return $default;
}
return $default;
}
foreach ($parts as $segment) {

View File

@ -1,10 +1,8 @@
<?php namespace Backend\Widgets;
use Db;
use App;
use Html;
use Lang;
use Input;
use Backend;
use DbDongle;
use Carbon\Carbon;
@ -16,7 +14,6 @@ use Backend\Classes\ListColumn;
use Backend\Classes\WidgetBase;
use October\Rain\Database\Model;
use ApplicationException;
use DateTime;
/**
* List Widget
@ -874,7 +871,7 @@ class Lists extends WidgetBase
$config['searchable'] = false;
}
$columnType = isset($config['type']) ? $config['type'] : null;
$columnType = $config['type'] ?? null;
$column = new ListColumn($name, $label);
$column->displayAs($columnType, $config);
@ -1221,7 +1218,7 @@ class Lists extends WidgetBase
$dateTime = $this->validateDateTimeValue($value, $column);
$format = $column->format !== null ? $column->format : 'g:i A';
$format = $column->format ?? 'g:i A';
$value = $dateTime->format($format);
@ -1479,19 +1476,18 @@ class Lists extends WidgetBase
$this->sortColumn = $sortOptions['column'];
$this->sortDirection = $sortOptions['direction'];
}
/*
* Supplied default
*/
else {
/*
* Supplied default
*/
if (is_string($this->defaultSort)) {
$this->sortColumn = $this->defaultSort;
$this->sortDirection = 'desc';
}
elseif (is_array($this->defaultSort) && isset($this->defaultSort['column'])) {
$this->sortColumn = $this->defaultSort['column'];
$this->sortDirection = (isset($this->defaultSort['direction'])) ?
$this->defaultSort['direction'] :
'desc';
$this->sortDirection = $this->defaultSort['direction'] ?? 'desc';
}
}
@ -1516,9 +1512,8 @@ class Lists extends WidgetBase
if ($column === null) {
return (count($this->getSortableColumns()) > 0);
}
else {
return array_key_exists($column, $this->getSortableColumns());
}
return array_key_exists($column, $this->getSortableColumns());
}
/**

View File

@ -38,7 +38,7 @@ class MediaManager extends WidgetBase
const FILTER_EVERYTHING = 'everything';
protected $brokenImageHash = null;
protected $brokenImageHash;
/**
* @var boolean Determines whether the widget is in readonly mode or not
@ -636,7 +636,7 @@ class MediaManager extends WidgetBase
$urlAndSize = $this->getCropEditImageUrlAndSize($path, $cropSessionKey);
$width = $urlAndSize['dimensions'][0];
$height = $urlAndSize['dimensions'][1] ? $urlAndSize['dimensions'][1] : 1;
$height = $urlAndSize['dimensions'][1] ?: 1;
$this->vars['currentSelectionMode'] = $selectionParams['mode'];
$this->vars['currentSelectionWidth'] = $selectionParams['width'];
@ -784,9 +784,7 @@ class MediaManager extends WidgetBase
protected function getCurrentFolder()
{
$folder = $this->getSession('media_folder', self::FOLDER_ROOT);
return $folder;
return $this->getSession('media_folder', self::FOLDER_ROOT);
}
protected function setFilter($filter)
@ -860,7 +858,7 @@ class MediaManager extends WidgetBase
if ($result) {
if (!isset($result['mode'])) {
$result['mode'] = MediaManager::SELECTION_MODE_NORMAL;
$result['mode'] = self::SELECTION_MODE_NORMAL;
}
if (!isset($result['width'])) {
@ -875,7 +873,7 @@ class MediaManager extends WidgetBase
}
return [
'mode' => MediaManager::SELECTION_MODE_NORMAL,
'mode' => self::SELECTION_MODE_NORMAL,
'width' => null,
'height' => null
];
@ -884,9 +882,9 @@ class MediaManager extends WidgetBase
protected function setSelectionParams($selectionMode, $selectionWidth, $selectionHeight)
{
if (!in_array($selectionMode, [
MediaManager::SELECTION_MODE_NORMAL,
MediaManager::SELECTION_MODE_FIXED_RATIO,
MediaManager::SELECTION_MODE_FIXED_SIZE
self::SELECTION_MODE_NORMAL,
self::SELECTION_MODE_FIXED_RATIO,
self::SELECTION_MODE_FIXED_SIZE
])) {
throw new ApplicationException('Invalid input data');
}
@ -1000,9 +998,7 @@ class MediaManager extends WidgetBase
$partition = implode('/', array_slice(str_split($itemSignature, 3), 0, 3)) . '/';
$result = $this->getThumbnailDirectory().$partition.$thumbFile;
return $result;
return $this->getThumbnailDirectory().$partition.$thumbFile;
}
protected function getThumbnailImageUrl($imagePath)
@ -1140,10 +1136,10 @@ class MediaManager extends WidgetBase
protected function resizeImage($fullThumbnailPath, $thumbnailParams, $tempFilePath)
{
$thumbnailDir = dirname($fullThumbnailPath);
if (!File::isDirectory($thumbnailDir)) {
if (File::makeDirectory($thumbnailDir, 0777, true) === false) {
throw new SystemException('Error creating thumbnail directory');
}
if (!File::isDirectory($thumbnailDir)
&& File::makeDirectory($thumbnailDir, 0777, true) === false
) {
throw new SystemException('Error creating thumbnail directory');
}
$targetDimensions = $this->getTargetDimensions($thumbnailParams['width'], $thumbnailParams['height'], $tempFilePath);
@ -1181,10 +1177,10 @@ class MediaManager extends WidgetBase
{
try {
$thumbnailDir = dirname($path);
if (!File::isDirectory($thumbnailDir)) {
if (File::makeDirectory($thumbnailDir, 0777, true) === false)
return;
if (!File::isDirectory($thumbnailDir) && File::makeDirectory($thumbnailDir, 0777, true) === false) {
return;
}
File::copy($this->getBrokenImagePath(), $path);
}
catch (Exception $ex) {
@ -1422,31 +1418,29 @@ class MediaManager extends WidgetBase
* If the target dimensions are provided, resize the original image and
* return its URL and dimensions.
*/
else {
$originalFilePath = $fullSessionDirectoryPath.'/'.$originalThumbFileName;
if (!File::isFile($originalFilePath)) {
throw new SystemException('The original image is not found in the cropping session directory.');
}
$resizedThumbFileName = 'resized-'.$params['width'].'-'.$params['height'].'.'.$extension;
$tempFilePath = $fullSessionDirectoryPath.'/'.$resizedThumbFileName;
Resizer::open($originalFilePath)
->resize($params['width'], $params['height'], [
'mode' => 'exact'
])
->save($tempFilePath)
;
$url = $this->getThumbnailImageUrl($sessionDirectoryPath.'/'.$resizedThumbFileName);
$dimensions = getimagesize($tempFilePath);
return [
'url' => $url,
'dimensions' => $dimensions
];
$originalFilePath = $fullSessionDirectoryPath.'/'.$originalThumbFileName;
if (!File::isFile($originalFilePath)) {
throw new SystemException('The original image is not found in the cropping session directory.');
}
$resizedThumbFileName = 'resized-'.$params['width'].'-'.$params['height'].'.'.$extension;
$tempFilePath = $fullSessionDirectoryPath.'/'.$resizedThumbFileName;
Resizer::open($originalFilePath)
->resize($params['width'], $params['height'], [
'mode' => 'exact'
])
->save($tempFilePath)
;
$url = $this->getThumbnailImageUrl($sessionDirectoryPath.'/'.$resizedThumbFileName);
$dimensions = getimagesize($tempFilePath);
return [
'url' => $url,
'dimensions' => $dimensions
];
}
catch (Exception $ex) {
if ($sessionDirectoryCreated) {

View File

@ -416,7 +416,7 @@ class ReportContainer extends WidgetBase
$property = [
'property' => $name,
'title' => isset($params['title']) ? Lang::get($params['title']) : $name,
'type' => isset($params['type']) ? $params['type'] : 'string'
'type' => $params['type'] ?? 'string'
];
foreach ($params as $name => $value) {

View File

@ -98,9 +98,9 @@ class Search extends WidgetBase
if ($this->partial) {
return $this->controller->makePartial($this->partial);
} else {
return $this->makePartial('search');
}
return $this->makePartial('search');
}
/**

View File

@ -34,12 +34,12 @@ class Table extends WidgetBase
/**
* @var Backend\Widgets\Table\DatasourceBase
*/
protected $dataSource = null;
protected $dataSource;
/**
* @var string Field name used for request data.
*/
protected $fieldName = null;
protected $fieldName;
/**
* @var string

View File

@ -1,7 +1,6 @@
<?php namespace Cms;
use App;
use Lang;
use Event;
use Backend;
use BackendMenu;

View File

@ -3,7 +3,6 @@
use File;
use Lang;
use Config;
use Cms\Classes\Theme;
use Cms\Helpers\File as FileHelper;
use October\Rain\Extension\Extendable;
use ApplicationException;
@ -35,7 +34,7 @@ class Asset extends Extendable
/**
* @var string Specifies the file name, the CMS object was loaded from.
*/
protected $originalFileName = null;
protected $originalFileName;
/**
* @var string Last modified time.

View File

@ -73,7 +73,7 @@ class CmsCompoundObject extends CmsObject
/**
* @var array|null Cache for component properties.
*/
protected static $objectComponentPropertyMap = null;
protected static $objectComponentPropertyMap;
/**
* @var mixed Cache store for the getViewBag method.
@ -279,7 +279,7 @@ class CmsCompoundObject extends CmsObject
else {
$cached = Cache::get($key, false);
$unserialized = $cached ? @unserialize(@base64_decode($cached)) : false;
$objectComponentMap = $unserialized ? $unserialized : [];
$objectComponentMap = $unserialized ?: [];
if ($objectComponentMap) {
self::$objectComponentPropertyMap = $objectComponentMap;
}

View File

@ -53,17 +53,6 @@ class CmsObject extends HalcyonModel implements CmsObjectContract
*/
protected $themeCache;
/**
* Create a new CMS object instance.
*
* @param array $attributes
* @return void
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
/**
* The "booting" method of the model.
* @return void

View File

@ -1,6 +1,5 @@
<?php namespace Cms\Classes;
use ApplicationException;
use October\Rain\Support\Collection as CollectionBase;
/**

View File

@ -94,7 +94,7 @@ class CodeBase extends Extendable implements ArrayAccess
*/
public function offsetGet($offset)
{
return isset($this->controller->vars[$offset]) ? $this->controller->vars[$offset] : null;
return $this->controller->vars[$offset] ?? null;
}
/**

View File

@ -192,11 +192,9 @@ class CodeParser
$path = array_get($data, 'filePath', $this->getCacheFilePath());
if (is_file($path)) {
if ($className = $this->extractClassFromFile($path)) {
if (class_exists($className)) {
$data['className'] = $className;
return $data;
}
if (($className = $this->extractClassFromFile($path)) && class_exists($className)) {
$data['className'] = $className;
return $data;
}
@unlink($path);
@ -271,10 +269,8 @@ class CodeParser
{
$cached = $this->getCachedInfo();
if ($cached !== null) {
if (array_key_exists($this->filePath, $cached)) {
return $cached[$this->filePath];
}
if ($cached !== null && array_key_exists($this->filePath, $cached)) {
return $cached[$this->filePath];
}
return null;

View File

@ -3,8 +3,6 @@
use Str;
use Lang;
use Config;
use Cms\Classes\CodeBase;
use Cms\Classes\CmsException;
use October\Rain\Extension\Extendable;
use BadMethodCallException;

View File

@ -106,9 +106,7 @@ class ComponentHelpers
public static function getComponentName($component)
{
$details = $component->componentDetails();
$name = (isset($details['name']))
? $details['name']
: 'cms::lang.component.unnamed';
$name = $details['name'] ?? 'cms::lang.component.unnamed';
return Lang::get($name);
}
@ -121,9 +119,7 @@ class ComponentHelpers
public static function getComponentDescription($component)
{
$details = $component->componentDetails();
$name = (isset($details['description']))
? $details['description']
: 'cms::lang.component.no_description';
$name = $details['description'] ?? 'cms::lang.component.no_description';
return Lang::get($name);
}

View File

@ -2,9 +2,7 @@
use Cms;
use Url;
use Str;
use App;
use File;
use View;
use Lang;
use Flash;
@ -22,13 +20,10 @@ use Cms\Twig\Extension as CmsTwigExtension;
use Cms\Models\MaintenanceSetting;
use System\Models\RequestLog;
use System\Helpers\View as ViewHelper;
use System\Classes\ErrorHandler;
use System\Classes\CombineAssets;
use System\Twig\Extension as SystemTwigExtension;
use October\Rain\Exception\AjaxException;
use October\Rain\Exception\SystemException;
use October\Rain\Exception\ValidationException;
use October\Rain\Exception\ApplicationException;
use October\Rain\Parse\Bracket as TextParser;
use Illuminate\Http\RedirectResponse;
@ -102,12 +97,12 @@ class Controller
/**
* @var self Cache of self
*/
protected static $instance = null;
protected static $instance;
/**
* @var \Cms\Classes\ComponentBase Object of the active component, used internally.
*/
protected $componentContext = null;
protected $componentContext;
/**
* @var array Component partial stack, used internally.
@ -121,7 +116,7 @@ class Controller
*/
public function __construct($theme = null)
{
$this->theme = $theme ? $theme : Theme::getActiveTheme();
$this->theme = $theme ?: Theme::getActiveTheme();
if (!$this->theme) {
throw new CmsException(Lang::get('cms::lang.theme.active.not_found'));
}
@ -335,7 +330,7 @@ class Controller
if (
$useAjax &&
($handler = post('_handler')) &&
($this->verifyCsrfToken()) &&
$this->verifyCsrfToken() &&
($handlerResponse = $this->runAjaxHandler($handler)) &&
$handlerResponse !== true
) {
@ -487,7 +482,7 @@ class Controller
$useCache = !Config::get('cms.twigNoCache');
$isDebugMode = Config::get('app.debug', false);
$strictVariables = Config::get('cms.enableTwigStrictVariables', false);
$strictVariables = is_null($strictVariables) ? $isDebugMode : $strictVariables;
$strictVariables = $strictVariables ?? $isDebugMode;
$forceBytecode = Config::get('cms.forceBytecodeInvalidation', false);
$options = [
@ -731,7 +726,7 @@ class Controller
if ($componentObj && $componentObj->methodExists($handlerName)) {
$this->componentContext = $componentObj;
$result = $componentObj->runAjaxHandler($handlerName);
return ($result) ?: true;
return $result ?: true;
}
}
/*
@ -740,12 +735,12 @@ class Controller
else {
if (method_exists($this->pageObj, $handler)) {
$result = $this->pageObj->$handler();
return ($result) ?: true;
return $result ?: true;
}
if (!$this->layout->isFallBack() && method_exists($this->layoutObj, $handler)) {
$result = $this->layoutObj->$handler();
return ($result) ?: true;
return $result ?: true;
}
/*
@ -754,7 +749,7 @@ class Controller
if (($componentObj = $this->findComponentByHandler($handler)) !== null) {
$this->componentContext = $componentObj;
$result = $componentObj->runAjaxHandler($handler);
return ($result) ?: true;
return $result ?: true;
}
}
@ -834,23 +829,19 @@ class Controller
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found_name', ['name'=>$partialName]));
}
else {
return false;
}
return false;
}
}
/*
* Component alias is supplied
*/
else {
if (($componentObj = $this->findComponentByName($componentAlias)) === null) {
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$componentAlias]));
}
else {
return false;
}
elseif (($componentObj = $this->findComponentByName($componentAlias)) === null) {
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$componentAlias]));
}
return false;
}
$partial = null;
@ -874,9 +865,8 @@ class Controller
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found_name', ['name'=>$name]));
}
else {
return false;
}
return false;
}
/*
@ -884,18 +874,15 @@ class Controller
*/
$this->vars['__SELF__'] = $componentObj;
}
else {
/*
* Process theme partial
*/
if (($partial = Partial::loadCached($this->theme, $name)) === null) {
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found_name', ['name'=>$name]));
}
else {
return false;
}
/*
* Process theme partial
*/
elseif (($partial = Partial::loadCached($this->theme, $name)) === null) {
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found_name', ['name'=>$name]));
}
return false;
}
/*
@ -1374,15 +1361,10 @@ class Controller
if (substr($paramName, 0, 1) == ':') {
$routeParamName = substr($paramName, 1);
$newPropertyValue = array_key_exists($routeParamName, $routerParameters)
? $routerParameters[$routeParamName]
: null;
$newPropertyValue = $routerParameters[$routeParamName] ?? null;
}
else {
$newPropertyValue = array_key_exists($paramName, $parameters)
? $parameters[$paramName]
: null;
$newPropertyValue = $parameters[$paramName] ?? null;
}
$component->setProperty($propertyName, $newPropertyValue);

View File

@ -1,8 +1,6 @@
<?php namespace Cms\Classes;
use Lang;
use Cms\Classes\Theme;
use Cms\Classes\Layout;
use ApplicationException;
use October\Rain\Filesystem\Definitions as FileDefinitions;

View File

@ -13,7 +13,7 @@ class PartialStack
/**
* @var array The current partial "object" being rendered.
*/
public $activePartial = null;
public $activePartial;
/**
* @var array Collection of previously rendered partial "objects".

View File

@ -5,7 +5,6 @@ use File;
use Cache;
use Config;
use Event;
use SystemException;
use October\Rain\Router\Router as RainRouter;
use October\Rain\Router\Helper as RouterHelper;
@ -331,14 +330,12 @@ class Router
$key = $this->getUrlListCacheKey();
$urlList = Cache::get($key, false);
if (
$urlList &&
($urlList = @unserialize(@base64_decode($urlList))) &&
is_array($urlList)
if ($urlList
&& ($urlList = @unserialize(@base64_decode($urlList)))
&& is_array($urlList)
&& array_key_exists($url, $urlList)
) {
if (array_key_exists($url, $urlList)) {
return $urlList[$url];
}
return $urlList[$url];
}
return null;

View File

@ -34,7 +34,7 @@ class Theme
/**
* @var mixed Keeps the cached configuration file values.
*/
protected $configCache = null;
protected $configCache;
/**
* @var mixed Active theme cache in memory
@ -518,8 +518,7 @@ class Theme
public function __get($name)
{
if ($this->hasCustomData()) {
$theme = $this->getCustomData();
return $theme->{$name};
return $this->getCustomData()->{$name};
}
return null;

View File

@ -1,7 +1,6 @@
<?php namespace Cms\Components;
use File;
use Config;
use Cms\Classes\ComponentBase;
use System\Classes\CombineAssets;

View File

@ -1,6 +1,5 @@
<?php namespace Cms\Components;
use Cms\Classes\CodeBase;
use Cms\Classes\ComponentBase;
class UnknownComponent extends ComponentBase

View File

@ -5,7 +5,6 @@ use Lang;
use Flash;
use Config;
use Request;
use Response;
use Exception;
use BackendMenu;
use Cms\Widgets\AssetList;
@ -21,7 +20,6 @@ use Cms\Classes\CmsCompoundObject;
use Cms\Classes\ComponentManager;
use Cms\Classes\ComponentPartial;
use Backend\Classes\Controller;
use Backend\Classes\WidgetManager;
use October\Rain\Router\Router as RainRouter;
use ApplicationException;
use Cms\Classes\Asset;
@ -181,10 +179,10 @@ class Index extends Controller
$templateData['code'] = $this->convertLineEndings($templateData['code']);
}
if (!Request::input('templateForceSave') && $template->mtime) {
if (Request::input('templateMtime') != $template->mtime) {
throw new ApplicationException('mtime-mismatch');
}
if (!Request::input('templateForceSave') && $template->mtime
&& Request::input('templateMtime') != $template->mtime
) {
throw new ApplicationException('mtime-mismatch');
}
$template->attributes = [];
@ -428,9 +426,7 @@ class Index extends Controller
$widgetConfig->model = $template;
$widgetConfig->alias = $alias ?: 'form'.studly_case($type).md5($template->getFileName()).uniqid();
$widget = $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
return $widget;
return $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
}
protected function upgradeSettings($settings)
@ -462,9 +458,7 @@ class Index extends Controller
}
$properties = json_decode($componentProperties[$index], true);
unset($properties['oc.alias']);
unset($properties['inspectorProperty']);
unset($properties['inspectorClassName']);
unset($properties['oc.alias'], $properties['inspectorProperty'], $properties['inspectorClassName']);
$settings[$section] = $properties;
}
}

View File

@ -1,17 +1,11 @@
<?php namespace Cms\Controllers;
use Str;
use Lang;
use File;
use Flash;
use Backend;
use Redirect;
use BackendMenu;
use Backend\Classes\Controller;
use ApplicationException;
use System\Classes\SettingsManager;
use Cms\Models\ThemeLog;
use Exception;
/**
* Request Logs controller

View File

@ -1,6 +1,5 @@
<?php namespace Cms\Controllers;
use Flash;
use Backend;
use BackendMenu;
use ApplicationException;
@ -132,8 +131,7 @@ class ThemeOptions extends Controller
protected function getThemeData($dirName)
{
$theme = $this->findThemeObject($dirName);
$model = ThemeData::forTheme($theme);
return $model;
return ThemeData::forTheme($theme);
}
protected function findThemeObject($name = null)

View File

@ -1,15 +1,12 @@
<?php namespace Cms\Controllers;
use File;
use Yaml;
use Flash;
use Config;
use Backend;
use Redirect;
use BackendMenu;
use ValidationException;
use ApplicationException;
use Cms\Models\ThemeData;
use Cms\Models\ThemeExport;
use Cms\Models\ThemeImport;
use Cms\Classes\Theme as CmsTheme;
@ -117,8 +114,7 @@ class Themes extends Controller
$widgetConfig->arrayName = 'Theme';
$widgetConfig->context = 'update';
$widget = $this->makeWidget(Form::class, $widgetConfig);
return $widget;
return $this->makeWidget(Form::class, $widgetConfig);
}
//
@ -175,8 +171,7 @@ class Themes extends Controller
$widgetConfig->arrayName = 'Theme';
$widgetConfig->context = 'create';
$widget = $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
return $widget;
return $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
}
//
@ -258,8 +253,7 @@ class Themes extends Controller
$widgetConfig->model->theme = $theme;
$widgetConfig->arrayName = 'ThemeExport';
$widget = $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
return $widget;
return $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
}
//
@ -295,8 +289,7 @@ class Themes extends Controller
$widgetConfig->model->theme = $theme;
$widgetConfig->arrayName = 'ThemeImport';
$widget = $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
return $widget;
return $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
}
//

View File

@ -1,6 +1,5 @@
<?php namespace Cms\FormWidgets;
use Lang;
use Backend\Classes\FormWidgetBase;
use Cms\Classes\ComponentManager;
use Cms\Classes\ComponentHelpers;

View File

@ -12,7 +12,7 @@ use Route;
*/
class Cms
{
protected static $actionExists = null;
protected static $actionExists;
/**
* Returns a URL in context of the Frontend

View File

@ -255,7 +255,6 @@ return [
'name' => 'CMS',
'manage_content' => 'Halda kodulehe sisufaile',
'manage_assets' => 'Manage website assets - images, JavaScript files, CSS files',
'manage_pages' => 'Create, modify and delete website pages',
'manage_pages' => 'Loo, muuda ja kustuta kodulehe lehti',
'manage_layouts' => 'Create, modify and delete CMS layouts',
'manage_partials' => 'Create, modify and delete CMS partials',

View File

@ -93,11 +93,11 @@ class ThemeData extends Model
}
try {
$themeData = ThemeData::firstOrCreate(['theme' => $dirName]);
$themeData = self::firstOrCreate(['theme' => $dirName]);
}
catch (Exception $ex) {
// Database failed
$themeData = new ThemeData(['theme' => $dirName]);
$themeData = new self(['theme' => $dirName]);
}
return self::$instances[$dirName] = $themeData;

View File

@ -1,7 +1,6 @@
<?php namespace Cms\Models;
use File;
use Lang;
use Model;
use Response;
use ApplicationException;

View File

@ -1,7 +1,6 @@
<?php namespace Cms\Models;
use File;
use Lang;
use Model;
use ApplicationException;
use October\Rain\Filesystem\Zip;

View File

@ -72,12 +72,12 @@ trait UrlMaker
/**
* @var string URL cache
*/
protected $url = null;
protected $url;
/**
* @var string Page where detected component is found.
*/
protected static $urlPageName = null;
protected static $urlPageName;
/**
* Changes the component used for generating the URLs dynamically.

View File

@ -374,7 +374,7 @@ class DebugExtension extends Twig_Extension
}
$method = $parts[1];
return isset($this->commentMap[$method]) ? $this->commentMap[$method] : null;
return $this->commentMap[$method] ?? null;
}
/**
@ -608,6 +608,6 @@ class DebugExtension extends Twig_Extension
$strings[] = $key . ': ' . $value;
}
return join('; ', $strings);
return implode('; ', $strings);
}
}

View File

@ -1,15 +1,11 @@
<?php namespace Cms\Twig;
use Flash;
use Block;
use Event;
use Twig_Extension;
use Twig_TokenParser;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
use Cms\Classes\Controller;
use Cms\Classes\CmsException;
use ApplicationException;
/**
* The CMS Twig extension class implements the basic CMS Twig functions and filters.

View File

@ -2,7 +2,6 @@
use Twig_Node;
use Twig_Compiler;
use Twig_Node_Expression;
/**
* Represents a flash node

View File

@ -2,7 +2,6 @@
use Twig_Node;
use Twig_Token;
use Twig_Node_Print;
use Twig_TokenParser;
/**

View File

@ -5,18 +5,12 @@ use Url;
use File;
use Lang;
use Input;
use Config;
use Request;
use Response;
use Validator;
use Cms\Classes\Theme;
use Cms\Classes\Asset;
use Backend\Classes\WidgetBase;
use System\Classes\PluginManager;
use ApplicationException;
use ValidationException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use October\Rain\Filesystem\Definitions as FileDefinitions;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;

View File

@ -78,17 +78,9 @@ class ComponentList extends WidgetBase
$pluginDetails = $plugin->pluginDetails();
$pluginName = isset($pluginDetails['name'])
? $pluginDetails['name']
: Lang::get('system::lang.plugin.unnamed');
$pluginIcon = isset($pluginDetails['icon'])
? $pluginDetails['icon']
: 'icon-puzzle-piece';
$pluginDescription = isset($pluginDetails['description'])
? $pluginDetails['description']
: null;
$pluginName = $pluginDetails['name'] ?? Lang::get('system::lang.plugin.unnamed');
$pluginIcon = $pluginDetails['icon'] ?? 'icon-puzzle-piece';
$pluginDescription = $pluginDetails['description'] ?? null;
$pluginClass = get_class($plugin);

View File

@ -4,7 +4,6 @@ use Str;
use File;
use Input;
use Request;
use Response;
use Cms\Classes\Theme;
use Backend\Classes\WidgetBase;
@ -63,7 +62,7 @@ class TemplateList extends WidgetBase
/**
* @var string Extra CSS class name to apply to the control.
*/
public $controlClass = null;
public $controlClass;
/**
* @var string A list of file name patterns to suppress / hide.
@ -372,10 +371,8 @@ class TemplateList extends WidgetBase
{
$operator = $exact ? 'is' : 'contains';
if (strlen($item->title)) {
if (Str::$operator(Str::lower($item->title), $word)) {
return true;
}
if (strlen($item->title) && Str::$operator(Str::lower($item->title), $word)) {
return true;
}
if (Str::$operator(Str::lower($item->fileName), $word)) {

View File

@ -1,13 +1,11 @@
<?php namespace System;
use App;
use Lang;
use View;
use Event;
use Config;
use Backend;
use Request;
use Validator;
use BackendMenu;
use BackendAuth;
use Twig_Environment;
@ -22,7 +20,6 @@ use System\Twig\Loader as TwigLoader;
use System\Twig\Extension as TwigExtension;
use System\Models\EventLog;
use System\Models\MailSetting;
use System\Models\MailTemplate;
use System\Classes\CombineAssets;
use Backend\Classes\WidgetManager;
use October\Rain\Support\ModuleServiceProvider;

View File

@ -6,7 +6,6 @@ use Cache;
use Log;
use Exception;
use System\Classes\ModelBehavior;
use ApplicationException;
/**
* Settings model extension

View File

@ -11,7 +11,6 @@ use Config;
use Request;
use Response;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
use Assetic\Asset\AssetCache;
use Assetic\Asset\AssetCollection;
use Assetic\Factory\AssetFactory;
@ -488,9 +487,8 @@ class CombineAssets
if ($actionExists) {
return Url::action($combineAction, [$outputFilename], false);
}
else {
return '/combine/'.$outputFilename;
}
return '/combine/'.$outputFilename;
}
/**

View File

@ -6,8 +6,6 @@ use System\Models\MailPartial;
use System\Models\MailTemplate;
use System\Models\MailBrandSetting;
use System\Helpers\View as ViewHelper;
use System\Classes\PluginManager;
use System\Classes\MarkupManager;
use System\Twig\MailPartialTokenParser;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;

View File

@ -5,7 +5,6 @@ use Twig_TokenParser;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
use ApplicationException;
use System\Classes\PluginManager;
/**
* This class manages Twig functions, token parsers and filters.
@ -116,7 +115,7 @@ class MarkupManager
{
$items = $this->transactionMode ? 'transactionItems' : 'items';
if (is_null($this->$items)) {
if ($this->$items === null) {
$this->$items = [];
}

View File

@ -256,9 +256,8 @@ class PluginBase extends ServiceProviderBase
if ($exceptionMessage) {
throw new SystemException($exceptionMessage);
}
else {
$this->loadedYamlConfiguration = [];
}
$this->loadedYamlConfiguration = [];
}
else {
$this->loadedYamlConfiguration = Yaml::parse(file_get_contents($yamlFilePath));

View File

@ -302,9 +302,7 @@ class PluginManager
*/
public function exists($id)
{
return (!$this->findByIdentifier($id) || $this->isDisabled($id))
? false
: true;
return !(!$this->findByIdentifier($id) || $this->isDisabled($id));
}
/**
@ -760,7 +758,7 @@ class PluginManager
/*
* Delete from file system
*/
if ($pluginPath = PluginManager::instance()->getPluginPath($id)) {
if ($pluginPath = self::instance()->getPluginPath($id)) {
File::deleteDirectory($pluginPath);
}
}

View File

@ -3,7 +3,6 @@
use Event;
use Backend;
use BackendAuth;
use System\Classes\PluginManager;
use SystemException;
/**

View File

@ -2,7 +2,6 @@
use Lang;
use ApplicationException;
use System\Classes\CombineAssets;
use Illuminate\Routing\Controller as ControllerBase;
use Exception;

View File

@ -189,10 +189,11 @@ class UpdateManager
/*
* Retry period not passed, skipping.
*/
if (!$force && ($retryTimestamp = Parameter::get('system::update.retry'))) {
if (Carbon::createFromTimeStamp($retryTimestamp)->isFuture()) {
return $oldCount;
}
if (!$force
&& ($retryTimestamp = Parameter::get('system::update.retry'))
&& Carbon::createFromTimeStamp($retryTimestamp)->isFuture()
) {
return $oldCount;
}
try {
@ -250,9 +251,9 @@ class UpdateManager
*/
$plugins = [];
foreach (array_get($result, 'plugins', []) as $code => $info) {
$info['name'] = isset($names[$code]) ? $names[$code] : $code;
$info['old_version'] = isset($versions[$code]) ? $versions[$code] : false;
$info['icon'] = isset($icons[$code]) ? $icons[$code] : false;
$info['name'] = $names[$code] ?? $code;
$info['old_version'] = $versions[$code] ?? false;
$info['icon'] = $icons[$code] ?? false;
/*
* If a plugin has updates frozen, or cannot be updated,
@ -535,11 +536,11 @@ class UpdateManager
/*
* Remove the plugin database and version
*/
if (!($plugin = $this->pluginManager->findByIdentifier($name))) {
if ($this->versionManager->purgePlugin($name)) {
$this->note('<info>Purged from database:</info> ' . $name);
return $this;
}
if (!($plugin = $this->pluginManager->findByIdentifier($name))
&& $this->versionManager->purgePlugin($name)
) {
$this->note('<info>Purged from database:</info> ' . $name);
return $this;
}
if ($this->versionManager->removePlugin($plugin)) {

View File

@ -1,6 +1,5 @@
<?php namespace System\Classes;
use Str;
use File;
use Yaml;
use Db;
@ -79,7 +78,7 @@ class VersionManager
*/
public function updatePlugin($plugin, $stopOnVersion = null)
{
$code = (is_string($plugin)) ? $plugin : $this->pluginManager->getIdentifier($plugin);
$code = is_string($plugin) ? $plugin : $this->pluginManager->getIdentifier($plugin);
if (!$this->hasVersionFile($code)) {
return false;
@ -111,7 +110,7 @@ class VersionManager
*/
public function listNewVersions($plugin)
{
$code = (is_string($plugin)) ? $plugin : $this->pluginManager->getIdentifier($plugin);
$code = is_string($plugin) ? $plugin : $this->pluginManager->getIdentifier($plugin);
if (!$this->hasVersionFile($code)) {
return [];
@ -165,7 +164,7 @@ class VersionManager
*/
public function removePlugin($plugin, $stopOnVersion = null)
{
$code = (is_string($plugin)) ? $plugin : $this->pluginManager->getIdentifier($plugin);
$code = is_string($plugin) ? $plugin : $this->pluginManager->getIdentifier($plugin);
if (!$this->hasVersionFile($code)) {
return false;
@ -229,7 +228,7 @@ class VersionManager
$history->delete();
}
return (($countHistory + $countVersions) > 0) ? true : false;
return ($countHistory + $countVersions) > 0;
}
//
@ -246,8 +245,7 @@ class VersionManager
return self::NO_VERSION_VALUE;
}
$latest = trim(key(array_slice($versionInfo, -1, 1)));
return $latest;
return trim(key(array_slice($versionInfo, -1, 1)));
}
/**
@ -327,9 +325,7 @@ class VersionManager
;
}
return (isset($this->databaseVersions[$code]))
? $this->databaseVersions[$code]
: self::NO_VERSION_VALUE;
return $this->databaseVersions[$code] ?? self::NO_VERSION_VALUE;
}
/**

View File

@ -3,7 +3,6 @@
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
/**
* Console command to tear down the database.
@ -27,14 +26,6 @@ class OctoberDown extends Command
*/
protected $description = 'Destroys all database tables for October and all plugins.';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
@ -50,14 +41,6 @@ class OctoberDown extends Command
;
}
/**
* Get the console command arguments.
*/
protected function getArguments()
{
return [];
}
/**
* Get the console command options.
*/

View File

@ -46,14 +46,6 @@ class OctoberEnv extends Command
*/
protected $connection;
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
@ -274,7 +266,7 @@ class OctoberEnv extends Command
return "'$value'";
} elseif (is_bool($value)) {
return $value ? 'true' : 'false';
} elseif (is_null($value)) {
} elseif ($value === null) {
return 'null';
}

View File

@ -2,8 +2,6 @@
use File;
use Artisan;
use Cms\Classes\Theme;
use Cms\Classes\ThemeManager;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
@ -29,14 +27,6 @@ class OctoberFresh extends Command
*/
protected $description = 'Removes the demo theme and plugin.';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
@ -59,14 +49,6 @@ class OctoberFresh extends Command
}
}
/**
* Get the console command arguments.
*/
protected function getArguments()
{
return [];
}
/**
* Get the console command options.
*/

View File

@ -3,13 +3,9 @@
use Db;
use App;
use Str;
use Url;
use PDO;
use File;
use Config;
use Artisan;
use Cms\Classes\Theme;
use Cms\Classes\ThemeManager;
use Backend\Database\Seeds\SeedSetupAdmin;
use System\Classes\UpdateManager;
use October\Rain\Config\ConfigWriter;
@ -87,14 +83,6 @@ class OctoberInstall extends Command
$this->displayOutro();
}
/**
* Get the console command arguments.
*/
protected function getArguments()
{
return [];
}
/**
* Get the console command options.
*/

View File

@ -73,14 +73,6 @@ class OctoberMirror extends Command
protected $destinationPath;
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/

View File

@ -2,8 +2,6 @@
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
/**
* Console command to migrate the database.
@ -25,14 +23,6 @@ class OctoberUp extends Command
*/
protected $description = 'Builds database tables for October and all plugins.';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
@ -45,20 +35,4 @@ class OctoberUp extends Command
->update()
;
}
/**
* Get the console command arguments.
*/
protected function getArguments()
{
return [];
}
/**
* Get the console command options.
*/
protected function getOptions()
{
return [];
}
}

View File

@ -1,11 +1,9 @@
<?php namespace System\Console;
use Str;
use Config;
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
/**
* Console command to perform a system update.
@ -30,14 +28,6 @@ class OctoberUpdate extends Command
*/
protected $description = 'Updates October CMS and all plugins, database and files.';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/
@ -72,9 +62,8 @@ class OctoberUpdate extends Command
$this->output->writeln('<info>No new updates found</info>');
return;
}
else {
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
}
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
$coreHash = $disableCore ? null : array_get($updateList, 'core.hash');
$coreBuild = array_get($updateList, 'core.build');
@ -113,14 +102,6 @@ class OctoberUpdate extends Command
$this->call('october:up');
}
/**
* Get the console command arguments.
*/
protected function getArguments()
{
return [];
}
/**
* Get the console command options.
*/

View File

@ -46,14 +46,6 @@ class OctoberUtil extends Command
*/
protected $description = 'Utility commands for October';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*/

View File

@ -2,7 +2,6 @@
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use System\Classes\PluginManager;
@ -29,15 +28,6 @@ class PluginInstall extends Command
*/
protected $description = 'Install a plugin from the October marketplace.';
/**
* Create a new command instance.
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
* @return void
@ -76,13 +66,4 @@ class PluginInstall extends Command
['name', InputArgument::REQUIRED, 'The name of the plugin. Eg: AuthorName.PluginName'],
];
}
/**
* Get the console command options.
* @return array
*/
protected function getOptions()
{
return [];
}
}

View File

@ -3,7 +3,6 @@
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use System\Classes\PluginManager;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
/**
@ -30,15 +29,6 @@ class PluginRefresh extends Command
*/
protected $description = 'Removes and re-adds an existing plugin.';
/**
* Create a new command instance.
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
* @return void
@ -78,13 +68,4 @@ class PluginRefresh extends Command
['name', InputArgument::REQUIRED, 'The name of the plugin. Eg: AuthorName.PluginName'],
];
}
/**
* Get the console command options.
* @return array
*/
protected function getOptions()
{
return [];
}
}

View File

@ -33,15 +33,6 @@ class PluginRemove extends Command
*/
protected $description = 'Removes an existing plugin.';
/**
* Create a new command instance.
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
* @return void

Some files were not shown because too many files have changed in this diff Show More