Subsequent expressions are on a new line (see developer guide > PSR exceptions)

This commit is contained in:
Sam Georges 2014-11-01 12:00:45 +11:00
parent 665d78e7d6
commit c83797231d
51 changed files with 320 additions and 166 deletions

View File

@ -141,7 +141,8 @@ class FormController extends ControllerBehavior
$model = $this->controller->formCreateModelObject(); $model = $this->controller->formCreateModelObject();
$this->initForm($model); $this->initForm($model);
$this->controller->vars['formModel'] = $model; $this->controller->vars['formModel'] = $model;
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->controller->handleError($ex); $this->controller->handleError($ex);
} }
} }
@ -196,7 +197,8 @@ class FormController extends ControllerBehavior
$this->initForm($model); $this->initForm($model);
$this->controller->vars['formModel'] = $model; $this->controller->vars['formModel'] = $model;
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->controller->handleError($ex); $this->controller->handleError($ex);
} }
} }
@ -274,7 +276,8 @@ class FormController extends ControllerBehavior
$this->initForm($model); $this->initForm($model);
$this->controller->vars['formModel'] = $model; $this->controller->vars['formModel'] = $model;
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->controller->handleError($ex); $this->controller->handleError($ex);
} }
} }

View File

@ -346,7 +346,8 @@ class Controller extends Extendable
// )); // ));
// } // }
// } // }
} else { }
else {
$partialList = []; $partialList = [];
} }
@ -385,7 +386,8 @@ class Controller extends Extendable
/* /*
* No redirect is used, look for any flash messages * No redirect is used, look for any flash messages
*/ */
} elseif (Flash::check()) { }
elseif (Flash::check()) {
$responseContents['#layout-flash-messages'] = $this->makeLayoutPartial('flash_messages'); $responseContents['#layout-flash-messages'] = $this->makeLayoutPartial('flash_messages');
} }
@ -397,7 +399,8 @@ class Controller extends Extendable
} }
return Response::make()->setContent($responseContents); return Response::make()->setContent($responseContents);
} catch (ValidationException $ex) { }
catch (ValidationException $ex) {
/* /*
* Handle validation error gracefully * Handle validation error gracefully
*/ */
@ -406,14 +409,17 @@ class Controller extends Extendable
$responseContents['#layout-flash-messages'] = $this->makeLayoutPartial('flash_messages'); $responseContents['#layout-flash-messages'] = $this->makeLayoutPartial('flash_messages');
$responseContents['X_OCTOBER_ERROR_FIELDS'] = $ex->getFields(); $responseContents['X_OCTOBER_ERROR_FIELDS'] = $ex->getFields();
return Response::make($responseContents, 406); return Response::make($responseContents, 406);
} catch (MassAssignmentException $ex) { }
catch (MassAssignmentException $ex) {
return Response::make( return Response::make(
Lang::get('backend::lang.model.mass_assignment_failed', ['attribute' => $ex->getMessage()]), Lang::get('backend::lang.model.mass_assignment_failed', ['attribute' => $ex->getMessage()]),
500 500
); );
} catch (ApplicationException $ex) { }
catch (ApplicationException $ex) {
return Response::make($ex->getMessage(), 500); return Response::make($ex->getMessage(), 500);
} catch (Exception $ex) { }
catch (Exception $ex) {
return Response::make( return Response::make(
sprintf('"%s" on line %s of %s', $ex->getMessage(), $ex->getLine(), $ex->getFile()), sprintf('"%s" on line %s of %s', $ex->getMessage(), $ex->getLine(), $ex->getFile()),
500 500
@ -454,7 +460,8 @@ class Controller extends Extendable
$result = call_user_func_array([$widget, $handlerName], $this->params); $result = call_user_func_array([$widget, $handlerName], $this->params);
return ($result) ?: true; return ($result) ?: true;
} }
} else { }
else {
/* /*
* Process page specific handler (index_onSomething) * Process page specific handler (index_onSomething)
*/ */

View File

@ -52,7 +52,8 @@ class Auth extends Controller
} else { } else {
$this->bodyClass .= ' preload'; $this->bodyClass .= ' preload';
} }
} catch (Exception $ex) { }
catch (Exception $ex) {
Flash::error($ex->getMessage()); Flash::error($ex->getMessage());
} }
} }
@ -103,7 +104,8 @@ class Auth extends Controller
if (post('postback')) { if (post('postback')) {
return $this->restore_onSubmit(); return $this->restore_onSubmit();
} }
} catch (Exception $ex) { }
catch (Exception $ex) {
Flash::error($ex->getMessage()); Flash::error($ex->getMessage());
} }
} }
@ -156,7 +158,8 @@ class Auth extends Controller
if (!$userId || !$code) { if (!$userId || !$code) {
throw new ApplicationException(trans('backend::lang.account.reset_error')); throw new ApplicationException(trans('backend::lang.account.reset_error'));
} }
} catch (Exception $ex) { }
catch (Exception $ex) {
Flash::error($ex->getMessage()); Flash::error($ex->getMessage());
} }

View File

@ -176,7 +176,8 @@ class FileUpload extends FormWidgetBase
} }
throw new SystemException('Unable to find file, it may no longer exist'); throw new SystemException('Unable to find file, it may no longer exist');
} catch (Exception $ex) { }
catch (Exception $ex) {
return json_encode(['error' => $ex->getMessage()]); return json_encode(['error' => $ex->getMessage()]);
} }
} }
@ -243,7 +244,8 @@ class FileUpload extends FormWidgetBase
$file->thumb = $file->getThumb($this->imageWidth, $this->imageHeight, ['mode' => 'crop']); $file->thumb = $file->getThumb($this->imageWidth, $this->imageHeight, ['mode' => 'crop']);
$result = $file; $result = $file;
} catch (Exception $ex) { }
catch (Exception $ex) {
$result = json_encode(['error' => $ex->getMessage()]); $result = json_encode(['error' => $ex->getMessage()]);
} }

View File

@ -209,7 +209,8 @@ class Lists extends WidgetBase
$this->vars['pageLast'] = $this->records->getLastPage(); $this->vars['pageLast'] = $this->records->getLastPage();
$this->vars['pageFrom'] = $this->records->getFrom(); $this->vars['pageFrom'] = $this->records->getFrom();
$this->vars['pageTo'] = $this->records->getTo(); $this->vars['pageTo'] = $this->records->getTo();
} else { }
else {
$this->vars['recordTotal'] = $this->records->count(); $this->vars['recordTotal'] = $this->records->count();
$this->vars['pageCurrent'] = 1; $this->vars['pageCurrent'] = 1;
} }
@ -305,10 +306,11 @@ class Lists extends WidgetBase
: $table . '.' . $column->valueFrom; : $table . '.' . $column->valueFrom;
$relationSearchable[$column->relation][] = $columnName; $relationSearchable[$column->relation][] = $columnName;
}
/* /*
* Primary * Primary
*/ */
} else { else {
$columnName = isset($column->sqlSelect) $columnName = isset($column->sqlSelect)
? DbDongle::raw($this->parseTableName($column->sqlSelect, $primaryTable)) ? DbDongle::raw($this->parseTableName($column->sqlSelect, $primaryTable))
: $primaryTable . '.' . $column->columnName; : $primaryTable . '.' . $column->columnName;
@ -391,10 +393,11 @@ class Lists extends WidgetBase
$joinSql = $countQuery->select($joinSql)->toSql(); $joinSql = $countQuery->select($joinSql)->toSql();
$selects[] = Db::raw("(".$joinSql.") as ".$alias); $selects[] = Db::raw("(".$joinSql.") as ".$alias);
}
/* /*
* Primary column * Primary column
*/ */
} else { else {
$sqlSelect = $this->parseTableName($column->sqlSelect, $primaryTable); $sqlSelect = $this->parseTableName($column->sqlSelect, $primaryTable);
$selects[] = DbDongle::raw($sqlSelect . ' as '. $alias); $selects[] = DbDongle::raw($sqlSelect . ' as '. $alias);
} }
@ -449,7 +452,8 @@ class Lists extends WidgetBase
{ {
if ($this->showTree) { if ($this->showTree) {
$records = $this->model->getAllRoot(); $records = $this->model->getAllRoot();
} else { }
else {
$model = $this->prepareModel(); $model = $this->prepareModel();
$records = ($this->showPagination) $records = ($this->showPagination)
? $model->paginate($this->recordsPerPage) ? $model->paginate($this->recordsPerPage)
@ -544,10 +548,11 @@ class Lists extends WidgetBase
$definitions[$columnName]->invisible = false; $definitions[$columnName]->invisible = false;
$columns[$columnName] = $definitions[$columnName]; $columns[$columnName] = $definitions[$columnName];
} }
}
/* /*
* Use default column list * Use default column list
*/ */
} else { else {
foreach ($definitions as $columnName => $column) { foreach ($definitions as $columnName => $column) {
if ($column->invisible) { if ($column->invisible) {
continue; continue;
@ -617,9 +622,11 @@ class Lists extends WidgetBase
{ {
if (is_string($config)) { if (is_string($config)) {
$label = $config; $label = $config;
} elseif (isset($config['label'])) { }
elseif (isset($config['label'])) {
$label = $config['label']; $label = $config['label'];
} else { }
else {
$label = studly_case($name); $label = studly_case($name);
} }
@ -683,11 +690,14 @@ class Lists extends WidgetBase
if ($column->valueFrom) { if ($column->valueFrom) {
if (!array_key_exists($columnName, $record->getRelations())) { if (!array_key_exists($columnName, $record->getRelations())) {
$value = null; $value = null;
} elseif ($this->isColumnRelated($column, true)) { }
elseif ($this->isColumnRelated($column, true)) {
$value = implode(', ', $record->{$columnName}->lists($column->valueFrom)); $value = implode(', ', $record->{$columnName}->lists($column->valueFrom));
} elseif ($this->isColumnRelated($column)) { }
elseif ($this->isColumnRelated($column)) {
$value = $record->{$columnName}->{$column->valueFrom}; $value = $record->{$columnName}->{$column->valueFrom};
} else { }
else {
$value = $record->{$column->valueFrom}; $value = $record->{$column->valueFrom};
} }
/* /*
@ -695,10 +705,12 @@ class Lists extends WidgetBase
* so prevent the Model from attempting to load the relation * so prevent the Model from attempting to load the relation
* if the value is NULL. * if the value is NULL.
*/ */
} else { }
else {
if ($record->hasRelation($columnName) && array_key_exists($columnName, $record->attributes)) { if ($record->hasRelation($columnName) && array_key_exists($columnName, $record->attributes)) {
$value = $record->attributes[$columnName]; $value = $record->attributes[$columnName];
} else { }
else {
$value = $record->{$columnName}; $value = $record->{$columnName};
} }
} }
@ -881,7 +893,8 @@ class Lists extends WidgetBase
{ {
if (empty($term)) { if (empty($term)) {
$this->showTree = $this->getConfig('showTree', $this->showTree); $this->showTree = $this->getConfig('showTree', $this->showTree);
} else { }
else {
$this->showTree = false; $this->showTree = false;
} }
@ -926,7 +939,8 @@ class Lists extends WidgetBase
if ($column != $sortOptions['column'] || $sortOptions['direction'] == 'asc') { if ($column != $sortOptions['column'] || $sortOptions['direction'] == 'asc') {
$this->sortDirection = $sortOptions['direction'] = 'desc'; $this->sortDirection = $sortOptions['direction'] = 'desc';
} else { }
else {
$this->sortDirection = $sortOptions['direction'] = 'asc'; $this->sortDirection = $sortOptions['direction'] = 'asc';
} }
@ -962,15 +976,16 @@ class Lists extends WidgetBase
if ($this->showSorting && ($sortOptions = $this->getSession('sort'))) { if ($this->showSorting && ($sortOptions = $this->getSession('sort'))) {
$this->sortColumn = $sortOptions['column']; $this->sortColumn = $sortOptions['column'];
$this->sortDirection = $sortOptions['direction']; $this->sortDirection = $sortOptions['direction'];
}
/* /*
* Supplied default * Supplied default
*/ */
} else { else {
if (is_string($this->defaultSort)) { if (is_string($this->defaultSort)) {
$this->sortColumn = $this->defaultSort; $this->sortColumn = $this->defaultSort;
$this->sortDirection = 'desc'; $this->sortDirection = 'desc';
} elseif (is_array($this->defaultSort) && isset($this->defaultSort['column'])) { }
elseif (is_array($this->defaultSort) && isset($this->defaultSort['column'])) {
$this->sortColumn = $this->defaultSort['column']; $this->sortColumn = $this->defaultSort['column'];
$this->sortDirection = (isset($this->defaultSort['direction'])) ? $this->sortDirection = (isset($this->defaultSort['direction'])) ?
$this->defaultSort['direction'] : $this->defaultSort['direction'] :
@ -997,7 +1012,8 @@ class Lists extends WidgetBase
{ {
if ($column === null) { if ($column === null) {
return (count($this->getSortableColumns()) > 0); return (count($this->getSortableColumns()) > 0);
} else { }
else {
return array_key_exists($column, $this->getSortableColumns()); return array_key_exists($column, $this->getSortableColumns());
} }
} }

View File

@ -84,7 +84,8 @@ class Search extends WidgetBase
if ($this->customPartial) { if ($this->customPartial) {
return $this->controller->makePartial($this->customPartial); return $this->controller->makePartial($this->customPartial);
} else { }
else {
return $this->makePartial('search'); return $this->makePartial('search');
} }
} }
@ -134,7 +135,8 @@ class Search extends WidgetBase
{ {
if (strlen($term)) { if (strlen($term)) {
$this->putSession('term', $term); $this->putSession('term', $term);
} else { }
else {
$this->resetSession(); $this->resetSession();
} }

View File

@ -51,7 +51,8 @@
if (checked) { if (checked) {
$el.closest('tr').addClass('active') $el.closest('tr').addClass('active')
} else { }
else {
$('.list-checkbox input[type="checkbox"]', head).prop('checked', false) $('.list-checkbox input[type="checkbox"]', head).prop('checked', false)
$el.closest('tr').removeClass('active') $el.closest('tr').removeClass('active')
} }

View File

@ -202,7 +202,8 @@ class CmsCompoundObject extends CmsObject
foreach ($values as &$value) { foreach ($values as &$value) {
if (!is_array($value)) { if (!is_array($value)) {
$value = trim($value); $value = trim($value);
} else { }
else {
$trim($value); $trim($value);
} }
} }
@ -229,7 +230,8 @@ class CmsCompoundObject extends CmsObject
$code = preg_replace('/\?>$/', '', $code); $code = preg_replace('/\?>$/', '', $code);
$content[] = '<?php'.PHP_EOL.$this->code.PHP_EOL.'?>'; $content[] = '<?php'.PHP_EOL.$this->code.PHP_EOL.'?>';
} else { }
else {
$content[] = $this->code; $content[] = $this->code;
} }
} }
@ -322,7 +324,8 @@ class CmsCompoundObject extends CmsObject
if (self::$objectComponentPropertyMap !== null) { if (self::$objectComponentPropertyMap !== null) {
$objectComponentMap = self::$objectComponentPropertyMap; $objectComponentMap = self::$objectComponentPropertyMap;
} else { }
else {
$cached = Cache::get($key, false); $cached = Cache::get($key, false);
$unserialized = $cached ? @unserialize($cached) : false; $unserialized = $cached ? @unserialize($cached) : false;
$objectComponentMap = $unserialized ? $unserialized : []; $objectComponentMap = $unserialized ? $unserialized : [];
@ -343,7 +346,8 @@ class CmsCompoundObject extends CmsObject
if (!isset($this->settings['components'])) { if (!isset($this->settings['components'])) {
$objectComponentMap[$objectCode] = []; $objectComponentMap[$objectCode] = [];
} else { }
else {
foreach ($this->settings['components'] as $componentName => $componentSettings) { foreach ($this->settings['components'] as $componentName => $componentSettings) {
$nameParts = explode(' ', $componentName); $nameParts = explode(' ', $componentName);
if (count($nameParts > 1)) { if (count($nameParts > 1)) {

View File

@ -165,7 +165,8 @@ class CmsException extends ApplicationException
/* /*
* Errors occurring the PHP code base class (Cms\Classes\CodeBase) * Errors occurring the PHP code base class (Cms\Classes\CodeBase)
*/ */
} else { }
else {
$trace = $exception->getTrace(); $trace = $exception->getTrace();
if (isset($trace[1]['class'])) { if (isset($trace[1]['class'])) {
$class = $trace[1]['class']; $class = $trace[1]['class'];

View File

@ -320,7 +320,8 @@ class CmsObject implements ArrayAccess
$methodName = 'set'.ucfirst($key); $methodName = 'set'.ucfirst($key);
if (method_exists($this, $methodName)) { if (method_exists($this, $methodName)) {
$this->$methodName($value); $this->$methodName($value);
} else { }
else {
$this->$key = $value; $this->$key = $value;
} }
} }

View File

@ -75,7 +75,8 @@ class CmsObjectQuery
if ($this->useCache) { if ($this->useCache) {
return forward_static_call([$this->cmsObject, 'loadCached'], $this->theme, $fileName); return forward_static_call([$this->cmsObject, 'loadCached'], $this->theme, $fileName);
} else { }
else {
return forward_static_call([$this->cmsObject, 'load'], $this->theme, $fileName); return forward_static_call([$this->cmsObject, 'load'], $this->theme, $fileName);
} }
} }

View File

@ -59,7 +59,8 @@ class ComponentHelpers
array_walk($property[$name], function (&$_value, $key) { array_walk($property[$name], function (&$_value, $key) {
$_value = Lang::get($_value); $_value = Lang::get($_value);
}); });
} else { }
else {
$property[$name] = Lang::get($value); $property[$name] = Lang::get($value);
} }
} }

View File

@ -194,7 +194,8 @@ class Controller extends BaseController
*/ */
if (!$page->layout) { if (!$page->layout) {
$layout = Layout::initFallback($this->theme); $layout = Layout::initFallback($this->theme);
} elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) { }
elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) {
throw new CmsException(Lang::get('cms::lang.layout.not_found', ['name'=>$page->layout])); throw new CmsException(Lang::get('cms::lang.layout.not_found', ['name'=>$page->layout]));
} }
@ -280,7 +281,8 @@ class Controller extends BaseController
$template = $this->twig->loadTemplate($this->page->getFullPath()); $template = $this->twig->loadTemplate($this->page->getFullPath());
$this->pageContents = $template->render($this->vars); $this->pageContents = $template->render($this->vars);
CmsException::unmask(); CmsException::unmask();
} else { }
else {
$this->pageContents = $apiResult; $this->pageContents = $apiResult;
} }
@ -406,7 +408,8 @@ class Controller extends BaseController
$componentObj->alias = $alias; $componentObj->alias = $alias;
$this->vars[$alias] = $this->layout->components[$alias] = $componentObj; $this->vars[$alias] = $this->layout->components[$alias] = $componentObj;
} else { }
else {
if (!$componentObj = $manager->makeComponent($name, $this->pageObj, $properties)) { if (!$componentObj = $manager->makeComponent($name, $this->pageObj, $properties)) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name])); throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
} }
@ -446,7 +449,8 @@ class Controller extends BaseController
throw new CmsException(Lang::get('cms::lang.partial.invalid_name', ['name'=>$partial])); throw new CmsException(Lang::get('cms::lang.partial.invalid_name', ['name'=>$partial]));
} }
} }
} else { }
else {
$partialList = []; $partialList = [];
} }
@ -465,7 +469,8 @@ class Controller extends BaseController
*/ */
if (is_array($result)) { if (is_array($result)) {
$responseContents = array_merge($responseContents, $result); $responseContents = array_merge($responseContents, $result);
} elseif (is_string($result)) { }
elseif (is_string($result)) {
$responseContents['result'] = $result; $responseContents['result'] = $result;
} }
@ -485,16 +490,19 @@ class Controller extends BaseController
} }
return Response::make()->setContent($responseContents); return Response::make()->setContent($responseContents);
} catch (ValidationException $ex) { }
catch (ValidationException $ex) {
/* /*
* Handle validation errors * Handle validation errors
*/ */
$responseContents['X_OCTOBER_ERROR_FIELDS'] = $ex->getFields(); $responseContents['X_OCTOBER_ERROR_FIELDS'] = $ex->getFields();
$responseContents['X_OCTOBER_ERROR_MESSAGE'] = $ex->getMessage(); $responseContents['X_OCTOBER_ERROR_MESSAGE'] = $ex->getMessage();
return Response::make($responseContents, 406); return Response::make($responseContents, 406);
} catch (ApplicationException $ex) { }
catch (ApplicationException $ex) {
return Response::make($ex->getMessage(), 500); return Response::make($ex->getMessage(), 500);
} catch (Exception $ex) { }
catch (Exception $ex) {
/* /*
* Display a "dumbed down" error if custom page is activated * Display a "dumbed down" error if custom page is activated
* otherwise display a more detailed error. * otherwise display a more detailed error.
@ -535,10 +543,11 @@ class Controller extends BaseController
$result = $componentObj->$handlerName(); $result = $componentObj->$handlerName();
return ($result) ?: true; return ($result) ?: true;
} }
}
/* /*
* Process code section handler * Process code section handler
*/ */
} else { else {
if (method_exists($this->pageObj, $handler)) { if (method_exists($this->pageObj, $handler)) {
$result = $this->pageObj->$handler(); $result = $this->pageObj->$handler();
return ($result) ?: true; return ($result) ?: true;
@ -694,21 +703,25 @@ class Controller extends BaseController
if (!strlen($componentAlias)) { if (!strlen($componentAlias)) {
if ($this->componentContext !== null) { if ($this->componentContext !== null) {
$componentObj = $this->componentContext; $componentObj = $this->componentContext;
} elseif (($componentObj = $this->findComponentByPartial($partialName)) === null) { }
elseif (($componentObj = $this->findComponentByPartial($partialName)) === null) {
if ($throwException) { if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found', ['name'=>$name])); throw new CmsException(Lang::get('cms::lang.partial.not_found', ['name'=>$name]));
} else { }
else {
return false; return false;
} }
} }
/* /*
* Component alias is supplied * Component alias is supplied
*/ */
} else { }
else {
if (($componentObj = $this->findComponentByName($componentAlias)) === null) { if (($componentObj = $this->findComponentByName($componentAlias)) === null) {
if ($throwException) { if ($throwException) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$componentAlias])); throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$componentAlias]));
} else { }
else {
return false; return false;
} }
} }
@ -736,7 +749,8 @@ class Controller extends BaseController
if ($partial === null) { if ($partial === null) {
if ($throwException) { if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found', ['name'=>$name])); throw new CmsException(Lang::get('cms::lang.partial.not_found', ['name'=>$name]));
} else { }
else {
return false; return false;
} }
} }
@ -745,14 +759,16 @@ class Controller extends BaseController
* Set context for self access * Set context for self access
*/ */
$this->vars['__SELF__'] = $componentObj; $this->vars['__SELF__'] = $componentObj;
} else { }
else {
/* /*
* Process theme partial * Process theme partial
*/ */
if (($partial = Partial::loadCached($this->theme, $name)) === null) { if (($partial = Partial::loadCached($this->theme, $name)) === null) {
if ($throwException) { if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found', ['name'=>$name])); throw new CmsException(Lang::get('cms::lang.partial.not_found', ['name'=>$name]));
} else { }
else {
return false; return false;
} }
} }
@ -831,12 +847,14 @@ class Controller extends BaseController
*/ */
if ($event = $this->fireEvent('page.beforeRenderContent', [$name], true)) { if ($event = $this->fireEvent('page.beforeRenderContent', [$name], true)) {
$content = $event; $content = $event;
} elseif ($event = Event::fire('cms.page.beforeRenderContent', [$this, $name], true)) { }
elseif ($event = Event::fire('cms.page.beforeRenderContent', [$this, $name], true)) {
$content = $event; $content = $event;
}
/* /*
* Load content from theme * Load content from theme
*/ */
} elseif (($content = Content::loadCached($this->theme, $name)) === null) { elseif (($content = Content::loadCached($this->theme, $name)) === null) {
throw new CmsException(Lang::get('cms::lang.content.not_found', ['name'=>$name])); throw new CmsException(Lang::get('cms::lang.content.not_found', ['name'=>$name]));
} }
@ -988,7 +1006,8 @@ class Controller extends BaseController
if (is_array($url)) { if (is_array($url)) {
$_url = Request::getBaseUrl(); $_url = Request::getBaseUrl();
$_url .= CombineAssets::combine($url, $themePath); $_url .= CombineAssets::combine($url, $themePath);
} else { }
else {
$_url = Request::getBasePath().$themePath; $_url = Request::getBasePath().$themePath;
if ($url !== null) { if ($url !== null) {
$_url .= '/'.$url; $_url .= '/'.$url;

View File

@ -78,18 +78,20 @@ class FileHelper
public static function formatIniString($data, $level = 1) public static function formatIniString($data, $level = 1)
{ {
$content = null; $content = null;
$sections = []; $sections = [];
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (is_array($value)) { if (is_array($value)) {
if ($level == 1) { if ($level == 1) {
$sections[$key] = self::formatIniString($value, $level+1); $sections[$key] = self::formatIniString($value, $level+1);
} else { }
else {
foreach ($value as $val) { foreach ($value as $val) {
$content .= $key.'[] = "'.self::escapeIniString($val).'"'.PHP_EOL; $content .= $key.'[] = "'.self::escapeIniString($val).'"'.PHP_EOL;
} }
} }
} elseif (strlen($value)) { }
elseif (strlen($value)) {
$content .= $key.' = "'.self::escapeIniString($value).'"'.PHP_EOL; $content .= $key.' = "'.self::escapeIniString($value).'"'.PHP_EOL;
} }
} }

View File

@ -208,7 +208,8 @@ class Router
$cacheable = Config::get('cms.enableRoutesCache'); $cacheable = Config::get('cms.enableRoutesCache');
if ($cacheable) { if ($cacheable) {
$cached = Cache::get($key, false); $cached = Cache::get($key, false);
} else { }
else {
$cached = false; $cached = false;
} }

View File

@ -52,10 +52,12 @@ class SectionParser
$result['code'] = preg_replace('/\?\>\s*$/', '', $result['code']); $result['code'] = preg_replace('/\?\>\s*$/', '', $result['code']);
$result['markup'] = $sections[2]; $result['markup'] = $sections[2];
} elseif ($count == 2) { }
elseif ($count == 2) {
$result['settings'] = parse_ini_string($sections[0], true); $result['settings'] = parse_ini_string($sections[0], true);
$result['markup'] = $sections[1]; $result['markup'] = $sections[1];
} elseif ($count == 1) { }
elseif ($count == 1) {
$result['markup'] = $sections[0]; $result['markup'] = $sections[0];
} }
@ -83,10 +85,12 @@ class SectionParser
$result['settings'] = self::adjustLinePosition($content); $result['settings'] = self::adjustLinePosition($content);
$result['code'] = self::calculateLinePosition($content); $result['code'] = self::calculateLinePosition($content);
$result['markup'] = self::calculateLinePosition($content, 2); $result['markup'] = self::calculateLinePosition($content, 2);
} elseif ($count == 2) { }
elseif ($count == 2) {
$result['settings'] = self::adjustLinePosition($content); $result['settings'] = self::adjustLinePosition($content);
$result['markup'] = self::calculateLinePosition($content); $result['markup'] = self::calculateLinePosition($content);
} elseif ($count == 1) { }
elseif ($count == 1) {
$result['markup'] = 1; $result['markup'] = 1;
} }

View File

@ -76,7 +76,8 @@ class Index extends Controller
new ComponentList($this, 'componentList'); new ComponentList($this, 'componentList');
new AssetList($this, 'assetList'); new AssetList($this, 'assetList');
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
} }
} }
@ -238,7 +239,8 @@ class Index extends Controller
$deleted[] = $path; $deleted[] = $path;
} }
} }
} catch (Exception $ex) { }
catch (Exception $ex) {
$error = $ex->getMessage(); $error = $ex->getMessage();
} }

View File

@ -36,6 +36,7 @@ class Components extends FormWidgetBase
$manager = ComponentManager::instance(); $manager = ComponentManager::instance();
$manager->listComponents(); $manager->listComponents();
foreach ($this->model->settings['components'] as $name => $properties) { foreach ($this->model->settings['components'] as $name => $properties) {
list($name, $alias) = strpos($name, ' ') ? explode(' ', $name) : [$name, $name]; list($name, $alias) = strpos($name, ' ') ? explode(' ', $name) : [$name, $name];
@ -55,7 +56,8 @@ class Components extends FormWidgetBase
$componentObj->pluginIcon = $pluginDetails['icon']; $componentObj->pluginIcon = $pluginDetails['icon'];
} }
} }
} catch (Exception $ex) { }
catch (Exception $ex) {
$componentObj = new UnknownComponent(null, $properties, $ex->getMessage()); $componentObj = new UnknownComponent(null, $properties, $ex->getMessage());
$componentObj->alias = $alias; $componentObj->alias = $alias;
$componentObj->pluginIcon = 'icon-bug'; $componentObj->pluginIcon = 'icon-bug';

View File

@ -99,7 +99,8 @@ class DebugExtension extends Twig_Extension
$result .= $this->dump($vars, static::PAGE_CAPTION); $result .= $this->dump($vars, static::PAGE_CAPTION);
} else { }
else {
$this->variablePrefix = false; $this->variablePrefix = false;
for ($i = 2; $i < $count; $i++) { for ($i = 2; $i < $count; $i++) {
@ -108,9 +109,11 @@ class DebugExtension extends Twig_Extension
if ($var instanceof ComponentBase) { if ($var instanceof ComponentBase) {
$caption = [static::COMPONENT_CAPTION, get_class($var)]; $caption = [static::COMPONENT_CAPTION, get_class($var)];
} elseif (is_array($var)) { }
elseif (is_array($var)) {
$caption = static::ARRAY_CAPTION; $caption = static::ARRAY_CAPTION;
} else { }
else {
$caption = [static::OBJECT_CAPTION, get_class($var)]; $caption = [static::OBJECT_CAPTION, get_class($var)];
} }
@ -148,9 +151,11 @@ class DebugExtension extends Twig_Extension
if (!is_array($variables)) { if (!is_array($variables)) {
if ($variables instanceof Paginator) { if ($variables instanceof Paginator) {
$variables = $this->paginatorToArray($variables); $variables = $this->paginatorToArray($variables);
} elseif (is_object($variables)) { }
elseif (is_object($variables)) {
$variables = $this->objectToArray($variables); $variables = $this->objectToArray($variables);
} else { }
else {
$variables = [$variables]; $variables = [$variables];
} }
} }
@ -220,12 +225,15 @@ class DebugExtension extends Twig_Extension
{ {
if ($this->variablePrefix === true) { if ($this->variablePrefix === true) {
$output = '{{ <span>%s</span> }}'; $output = '{{ <span>%s</span> }}';
} elseif (is_array($this->variablePrefix)) { }
elseif (is_array($this->variablePrefix)) {
$prefix = implode('.', $this->variablePrefix); $prefix = implode('.', $this->variablePrefix);
$output = '{{ <span>'.$prefix.'.%s</span> }}'; $output = '{{ <span>'.$prefix.'.%s</span> }}';
} elseif ($this->variablePrefix) { }
elseif ($this->variablePrefix) {
$output = '{{ <span>'.$this->variablePrefix.'.%s</span> }}'; $output = '{{ <span>'.$this->variablePrefix.'.%s</span> }}';
} else { }
else {
$output = '%s'; $output = '%s';
} }
@ -279,11 +287,14 @@ class DebugExtension extends Twig_Extension
if ($variable instanceof ComponentBase) { if ($variable instanceof ComponentBase) {
$label = '<strong>Component</strong>'; $label = '<strong>Component</strong>';
} elseif ($variable instanceof Collection) { }
elseif ($variable instanceof Collection) {
$label = 'Collection('.$variable->count().')'; $label = 'Collection('.$variable->count().')';
} elseif ($variable instanceof Paginator) { }
elseif ($variable instanceof Paginator) {
$label = 'Paged Collection('.$variable->count().')'; $label = 'Paged Collection('.$variable->count().')';
} elseif ($variable instanceof Model) { }
elseif ($variable instanceof Model) {
$label = 'Model'; $label = 'Model';
} }

View File

@ -43,7 +43,8 @@ class FlashNode extends Twig_Node
->outdent() ->outdent()
->write('}'.PHP_EOL) ->write('}'.PHP_EOL)
; ;
} else { }
else {
$compiler $compiler
->addDebugInfo($this) ->addDebugInfo($this)
->write('$context["type"] = ') ->write('$context["type"] = ')

View File

@ -27,7 +27,8 @@ class FlashTokenParser extends Twig_TokenParser
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
$name = $token->getValue(); $name = $token->getValue();
} else { }
else {
$name = 'all'; $name = 'all';
} }
$stream->expect(Twig_Token::BLOCK_END_TYPE); $stream->expect(Twig_Token::BLOCK_END_TYPE);

View File

@ -54,7 +54,8 @@ class PlaceholderNode extends Twig_Node
$compiler->addDebugInfo($this); $compiler->addDebugInfo($this);
if (!$isText) { if (!$isText) {
$compiler->write("echo \$this->env->getExtension('CMS')->displayBlock("); $compiler->write("echo \$this->env->getExtension('CMS')->displayBlock(");
} else { }
else {
$compiler->write("echo twig_escape_filter(\$this->env, \$this->env->getExtension('CMS')->displayBlock("); $compiler->write("echo twig_escape_filter(\$this->env, \$this->env->getExtension('CMS')->displayBlock(");
} }
@ -67,7 +68,8 @@ class PlaceholderNode extends Twig_Node
if (!$isText) { if (!$isText) {
$compiler->raw(";\n"); $compiler->raw(";\n");
} else { }
else {
$compiler->raw(");\n"); $compiler->raw(");\n");
} }

View File

@ -43,7 +43,8 @@ class PlaceholderTokenParser extends Twig_TokenParser
$body = $this->parser->subparse([$this, 'decidePlaceholderEnd'], true); $body = $this->parser->subparse([$this, 'decidePlaceholderEnd'], true);
$stream->expect(Twig_Token::BLOCK_END_TYPE); $stream->expect(Twig_Token::BLOCK_END_TYPE);
} else { }
else {
$params = $this->loadParams($stream); $params = $this->loadParams($stream);
} }

View File

@ -175,7 +175,8 @@ class AssetList extends WidgetBase
['name'=>$path] ['name'=>$path]
)); ));
} }
} else { }
else {
$empty = File::isDirectoryEmpty($fullPath); $empty = File::isDirectoryEmpty($fullPath);
if ($empty === false) { if ($empty === false) {
throw new ApplicationException(Lang::get( throw new ApplicationException(Lang::get(
@ -197,7 +198,8 @@ class AssetList extends WidgetBase
} }
} }
} }
} catch (Exception $ex) { }
catch (Exception $ex) {
$error = $ex->getMessage(); $error = $ex->getMessage();
} }
@ -367,7 +369,8 @@ class AssetList extends WidgetBase
['file'=>$basename] ['file'=>$basename]
)); ));
} }
} elseif (is_dir($originalFullPath)) { }
elseif (is_dir($originalFullPath)) {
if (!@File::copyDirectory($originalFullPath, $newFullPath)) { if (!@File::copyDirectory($originalFullPath, $newFullPath)) {
throw new ApplicationException(Lang::get( throw new ApplicationException(Lang::get(
'cms::lang.asset.error_moving_directory', 'cms::lang.asset.error_moving_directory',
@ -538,7 +541,8 @@ class AssetList extends WidgetBase
'name' => $node->getFilename(), 'name' => $node->getFilename(),
'editable' => false 'editable' => false
]; ];
} elseif ($node->isFile()) { }
elseif ($node->isFile()) {
$files[] = (object)[ $files[] = (object)[
'type' => 'file', 'type' => 'file',
'path' => File::normalizePath($this->getRelativePath($node->getPathname())), 'path' => File::normalizePath($this->getRelativePath($node->getPathname())),
@ -704,7 +708,8 @@ class AssetList extends WidgetBase
$uploadedFile->move($this->getCurrentPath(), $uploadedFile->getClientOriginalName()); $uploadedFile->move($this->getCurrentPath(), $uploadedFile->getClientOriginalName());
die('success'); die('success');
} catch (Exception $ex) { }
catch (Exception $ex) {
$message = $fileName !== null $message = $fileName !== null
? Lang::get('cms::lang.asset.error_uploading_file', ['name' => $fileName, 'error' => $ex->getMessage()]) ? Lang::get('cms::lang.asset.error_uploading_file', ['name' => $fileName, 'error' => $ex->getMessage()])
: $ex->getMessage(); : $ex->getMessage();

View File

@ -176,7 +176,8 @@ class TemplateList extends WidgetBase
$filteredItems[] = $item; $filteredItems[] = $item;
} }
} }
} else { }
else {
$filteredItems = $normalizedItems; $filteredItems = $normalizedItems;
} }
@ -198,7 +199,8 @@ class TemplateList extends WidgetBase
} }
$foundGroups[$group]->items[] = $itemData; $foundGroups[$group]->items[] = $itemData;
} else { }
else {
$result[] = $itemData; $result[] = $itemData;
} }
} }
@ -283,7 +285,8 @@ class TemplateList extends WidgetBase
if (Str::contains(Str::lower($item->title), $word)) { if (Str::contains(Str::lower($item->title), $word)) {
return true; return true;
} }
} elseif (Str::contains(Str::lower($item->fileName), $word)) { }
elseif (Str::contains(Str::lower($item->fileName), $word)) {
return true; return true;
} }

View File

@ -336,7 +336,8 @@ if (window.jQuery === undefined)
try { try {
return JSON.parse(JSON.stringify(eval("({" + value + "})"))) return JSON.parse(JSON.stringify(eval("({" + value + "})")))
} catch (e) { }
catch (e) {
throw new Error('Error parsing the '+name+' attribute value. '+e) throw new Error('Error parsing the '+name+' attribute value. '+e)
} }
} }

View File

@ -178,7 +178,8 @@ class CombineAssets
{ {
if ($extension === null) { if ($extension === null) {
$this->aliases = []; $this->aliases = [];
} else { }
else {
$this->aliases[$extension] = []; $this->aliases[$extension] = [];
} }
@ -194,9 +195,11 @@ class CombineAssets
{ {
if ($extension === null) { if ($extension === null) {
return $this->aliases; return $this->aliases;
} elseif (isset($this->aliases[$extension])) { }
elseif (isset($this->aliases[$extension])) {
return $this->aliases[$extension]; return $this->aliases[$extension];
} else { }
else {
return null; return null;
} }
} }
@ -238,7 +241,8 @@ class CombineAssets
{ {
if ($extension === null) { if ($extension === null) {
$this->filters = []; $this->filters = [];
} else { }
else {
$this->filters[$extension] = []; $this->filters[$extension] = [];
} }
@ -254,9 +258,11 @@ class CombineAssets
{ {
if ($extension === null) { if ($extension === null) {
return $this->filters; return $this->filters;
} elseif (isset($this->filters[$extension])) { }
elseif (isset($this->filters[$extension])) {
return $this->filters[$extension]; return $this->filters[$extension];
} else { }
else {
return null; return null;
} }
} }
@ -316,7 +322,8 @@ class CombineAssets
if (count($combineCss) > count($combineJs)) { if (count($combineCss) > count($combineJs)) {
$extension = 'css'; $extension = 'css';
$assets = $combineCss; $assets = $combineCss;
} else { }
else {
$extension = 'js'; $extension = 'js';
$assets = $combineJs; $assets = $combineJs;
} }
@ -373,7 +380,8 @@ class CombineAssets
if ($actionExists) { if ($actionExists) {
return URL::action($combineAction, [$outputFilename], false); return URL::action($combineAction, [$outputFilename], false);
} else { }
else {
return Request::getBasePath().'/combine/'.$outputFilename; return Request::getBasePath().'/combine/'.$outputFilename;
} }
} }

View File

@ -33,7 +33,8 @@ class Controller extends BaseController
$combiner = new CombineAssets; $combiner = new CombineAssets;
return $combiner->getContents($cacheId); return $combiner->getContents($cacheId);
} catch (Exception $ex) { }
catch (Exception $ex) {
return '/* '.$ex->getMessage().' */'; return '/* '.$ex->getMessage().' */';
} }
} }

View File

@ -63,11 +63,13 @@ class ErrorHandler
if ($proposedException instanceof BaseException) { if ($proposedException instanceof BaseException) {
$exception = $proposedException; $exception = $proposedException;
// If there is an active mask prepared, use that. // If there is an active mask prepared, use that.
} elseif (static::$activeMask !== null) { }
elseif (static::$activeMask !== null) {
$exception = static::$activeMask; $exception = static::$activeMask;
$exception->setMask($proposedException); $exception->setMask($proposedException);
// Otherwise we should mask it with our own default scent. // Otherwise we should mask it with our own default scent.
} else { }
else {
$exception = new ApplicationException($proposedException->getMessage(), 0); $exception = new ApplicationException($proposedException->getMessage(), 0);
$exception->setMask($proposedException); $exception->setMask($proposedException);
} }
@ -100,7 +102,8 @@ class ErrorHandler
{ {
if (count(static::$maskLayers) > 0) { if (count(static::$maskLayers) > 0) {
static::$activeMask = array_pop(static::$maskLayers); static::$activeMask = array_pop(static::$maskLayers);
} else { }
else {
static::$activeMask = null; static::$activeMask = null;
} }
} }

View File

@ -320,13 +320,17 @@ class ExceptionBase extends Exception
foreach ($argument as $index => $obj) { foreach ($argument as $index => $obj) {
if (is_array($obj)) { if (is_array($obj)) {
$value = 'array('.count($obj).')'; $value = 'array('.count($obj).')';
} elseif (is_object($obj)) { }
elseif (is_object($obj)) {
$value = 'object('.get_class($obj).')'; $value = 'object('.get_class($obj).')';
} elseif (is_integer($obj)) { }
elseif (is_integer($obj)) {
$value = $obj; $value = $obj;
} elseif ($obj === null) { }
elseif ($obj === null) {
$value = "null"; $value = "null";
} else { }
else {
$value = "'".$obj."'"; $value = "'".$obj."'";
} }
@ -335,16 +339,21 @@ class ExceptionBase extends Exception
if (count($items)) { if (count($items)) {
$arg = 'array(' . count($argument) . ') [' . implode(', ', $items) . ']'; $arg = 'array(' . count($argument) . ') [' . implode(', ', $items) . ']';
} else { }
else {
$arg = 'array(0)'; $arg = 'array(0)';
} }
} elseif (is_object($argument)) { }
elseif (is_object($argument)) {
$arg = 'object('.get_class($argument).')'; $arg = 'object('.get_class($argument).')';
} elseif ($argument === null) { }
elseif ($argument === null) {
$arg = "null"; $arg = "null";
} elseif (is_integer($argument)) { }
elseif (is_integer($argument)) {
$arg = $argument; $arg = $argument;
} else { }
else {
$arg = "'".$argument."'"; $arg = "'".$argument."'";
} }

View File

@ -310,7 +310,8 @@ class MarkupManager
if ($replaceWith) { if ($replaceWith) {
$isWild = $callable; $isWild = $callable;
$isWild[0] = str_replace('*', $replaceWith, $callable[0]); $isWild[0] = str_replace('*', $replaceWith, $callable[0]);
} else { }
else {
$isWild = true; $isWild = true;
} }
} }
@ -319,7 +320,8 @@ class MarkupManager
if ($replaceWith) { if ($replaceWith) {
$isWild = $isWild ?: $callable; $isWild = $isWild ?: $callable;
$isWild[1] = str_replace('*', $replaceWith, $callable[1]); $isWild[1] = str_replace('*', $replaceWith, $callable[1]);
} else { }
else {
$isWild = true; $isWild = true;
} }
} }

View File

@ -390,7 +390,8 @@ class PluginManager
if (File::exists($path)) { if (File::exists($path)) {
$disabled = json_decode(File::get($path), true); $disabled = json_decode(File::get($path), true);
$this->disabledPlugins = array_merge($this->disabledPlugins, $disabled); $this->disabledPlugins = array_merge($this->disabledPlugins, $disabled);
} else { }
else {
$this->writeDisabled(); $this->writeDisabled();
} }
} }
@ -485,14 +486,16 @@ class PluginManager
foreach ($required as $require) { foreach ($required as $require) {
if (!$this->hasPlugin($require)) { if (!$this->hasPlugin($require)) {
$disable = true; $disable = true;
} elseif (($pluginObj = $this->findByIdentifier($require)) && $pluginObj->disabled) { }
elseif (($pluginObj = $this->findByIdentifier($require)) && $pluginObj->disabled) {
$disable = true; $disable = true;
} }
} }
if ($disable) { if ($disable) {
$this->disablePlugin($id); $this->disablePlugin($id);
} else { }
else {
$this->enablePlugin($id); $this->enablePlugin($id);
} }
} }

View File

@ -234,7 +234,8 @@ class SettingsManager
list($author, $plugin) = explode('.', $owner); list($author, $plugin) = explode('.', $owner);
$uri[] = strtolower($author); $uri[] = strtolower($author);
$uri[] = strtolower($plugin); $uri[] = strtolower($plugin);
} else { }
else {
$uri[] = strtolower($owner); $uri[] = strtolower($owner);
} }

View File

@ -161,7 +161,8 @@ class UpdateManager
try { try {
$result = $this->requestUpdateList(); $result = $this->requestUpdateList();
$newCount = array_get($result, 'update', 0); $newCount = array_get($result, 'update', 0);
} catch (Exception $ex) { }
catch (Exception $ex) {
$newCount = 0; $newCount = 0;
} }
@ -594,7 +595,8 @@ class UpdateManager
try { try {
$resultData = @json_decode($result->body, true); $resultData = @json_decode($result->body, true);
} catch (Exception $ex) { }
catch (Exception $ex) {
throw new ApplicationException(Lang::get('system::lang.server.response_invalid')); throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
} }

View File

@ -103,7 +103,8 @@ class VersionManager
if (is_array($details)) { if (is_array($details)) {
$comment = array_shift($details); $comment = array_shift($details);
$scripts = $details; $scripts = $details;
} else { }
else {
$comment = $details; $comment = $details;
$scripts = []; $scripts = [];
} }
@ -148,7 +149,8 @@ class VersionManager
foreach ($pluginHistory as $history) { foreach ($pluginHistory as $history) {
if ($history->type == self::HISTORY_TYPE_COMMENT) { if ($history->type == self::HISTORY_TYPE_COMMENT) {
$this->removeDatabaseComment($code, $history->version); $this->removeDatabaseComment($code, $history->version);
} elseif ($history->type == self::HISTORY_TYPE_SCRIPT) { }
elseif ($history->type == self::HISTORY_TYPE_SCRIPT) {
$this->removeDatabaseScript($code, $history->version, $history->detail); $this->removeDatabaseScript($code, $history->version, $history->detail);
} }
} }
@ -296,12 +298,14 @@ class VersionManager
'version' => $version, 'version' => $version,
'created_at' => new Carbon 'created_at' => new Carbon
]); ]);
} elseif ($version && $currentVersion) { }
elseif ($version && $currentVersion) {
Db::table('system_plugin_versions')->where('code', $code)->update([ Db::table('system_plugin_versions')->where('code', $code)->update([
'version' => $version, 'version' => $version,
'created_at' => new Carbon 'created_at' => new Carbon
]); ]);
} elseif ($currentVersion) { }
elseif ($currentVersion) {
Db::table('system_plugin_versions')->where('code', $code)->delete(); Db::table('system_plugin_versions')->where('code', $code)->delete();
} }

View File

@ -55,8 +55,9 @@ class CacheClear extends ClearCommand
$command = App::make('System\Console\CacheClear'); $command = App::make('System\Console\CacheClear');
$command->setLaravel(App::make('app')); $command->setLaravel(App::make('app'));
$command->fire(); $command->fire();
} catch (\Exception $ex) { }
catch (\Exception $ex) {
// Do nothing
} }
} }
} }

View File

@ -61,7 +61,8 @@ class OctoberUpdate extends Command
if ($updates == 0) { if ($updates == 0) {
$this->output->writeln('<info>No new updates found</info>'); $this->output->writeln('<info>No new updates found</info>');
return; return;
} else { }
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)));
} }

View File

@ -114,7 +114,8 @@ class OctoberUtil extends Command
if ($totalCount > 0) { if ($totalCount > 0) {
$this->comment(sprintf('Successfully deleted %s thumbs', $totalCount)); $this->comment(sprintf('Successfully deleted %s thumbs', $totalCount));
} else { }
else {
$this->comment('No thumbs found to delete'); $this->comment('No thumbs found to delete');
} }
} }

View File

@ -77,7 +77,8 @@ class MailTemplates extends Controller
}); });
Flash::success('The test message has been successfully sent.'); Flash::success('The test message has been successfully sent.');
} catch (Exception $ex) { }
catch (Exception $ex) {
Flash::error($ex->getMessage()); Flash::error($ex->getMessage());
} }
} }

View File

@ -75,7 +75,8 @@ class Settings extends Controller
$model = $this->createModel($item); $model = $this->createModel($item);
$this->initWidgets($model); $this->initWidgets($model);
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
} }
} }

View File

@ -166,7 +166,8 @@ class Updates extends Controller
$this->vars['hasUpdates'] = array_get($result, 'hasUpdates', false); $this->vars['hasUpdates'] = array_get($result, 'hasUpdates', false);
$this->vars['pluginList'] = array_get($result, 'plugins', []); $this->vars['pluginList'] = array_get($result, 'plugins', []);
$this->vars['themeList'] = array_get($result, 'themes', []); $this->vars['themeList'] = array_get($result, 'themes', []);
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
} }
@ -212,7 +213,8 @@ class Updates extends Controller
]; ];
$this->vars['updateSteps'] = $updateSteps; $this->vars['updateSteps'] = $updateSteps;
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
} }
@ -253,7 +255,8 @@ class Updates extends Controller
]; ];
$this->vars['updateSteps'] = $updateSteps; $this->vars['updateSteps'] = $updateSteps;
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
} }
@ -371,7 +374,8 @@ class Updates extends Controller
]); ]);
return $this->onForceUpdate(); return $this->onForceUpdate();
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
return $this->makePartial('project_form'); return $this->makePartial('project_form');
} }
@ -430,7 +434,8 @@ class Updates extends Controller
$this->vars['updateSteps'] = $updateSteps; $this->vars['updateSteps'] = $updateSteps;
return $this->makePartial('execute'); return $this->makePartial('execute');
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
return $this->makePartial('plugin_form'); return $this->makePartial('plugin_form');
} }
@ -502,7 +507,8 @@ class Updates extends Controller
{ {
try { try {
$this->vars['checked'] = post('checked'); $this->vars['checked'] = post('checked');
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->handleError($ex); $this->handleError($ex);
} }
return $this->makePartial('disable_form'); return $this->makePartial('disable_form');
@ -522,7 +528,8 @@ class Updates extends Controller
if ($disable) { if ($disable) {
$manager->disablePlugin($object->code, true); $manager->disablePlugin($object->code, true);
} else { }
else {
$manager->enablePlugin($object->code, true); $manager->enablePlugin($object->code, true);
} }
@ -534,7 +541,8 @@ class Updates extends Controller
if ($disable) { if ($disable) {
Flash::success(Lang::get('system::lang.plugins.disable_success')); Flash::success(Lang::get('system::lang.plugins.disable_success'));
} else { }
else {
Flash::success(Lang::get('system::lang.plugins.enable_success')); Flash::success(Lang::get('system::lang.plugins.enable_success'));
} }

View File

@ -98,11 +98,10 @@
success: function(data){ success: function(data){
setTimeout(function() { deferred.resolve() }, 600) setTimeout(function() { deferred.resolve() }, 600)
if (step.code == 'completeUpdate' || step.code == 'completeInstall') { if (step.code == 'completeUpdate' || step.code == 'completeInstall')
this.success(data) this.success(data)
} else { else
setLoadingBar(false) setLoadingBar(false)
}
}, },
error: function(data){ error: function(data){
setLoadingBar(false) setLoadingBar(false)
@ -121,12 +120,10 @@
var loadingBar = $('#executeLoadingBar'), var loadingBar = $('#executeLoadingBar'),
messageDiv = $('#executeMessage') messageDiv = $('#executeMessage')
if (state) { if (state)
loadingBar.removeClass('bar-loaded') loadingBar.removeClass('bar-loaded')
} else
else {
loadingBar.addClass('bar-loaded') loadingBar.addClass('bar-loaded')
}
if (message) if (message)
messageDiv.text(message) messageDiv.text(message)

View File

@ -29,7 +29,8 @@ class File extends FileBase
$uploadsDir = Config::get('cms.uploadsDir'); $uploadsDir = Config::get('cms.uploadsDir');
if ($this->isPublic()) { if ($this->isPublic()) {
return base_path() . $uploadsDir . '/public/'; return base_path() . $uploadsDir . '/public/';
} else { }
else {
return base_path() . $uploadsDir . '/protected/'; return base_path() . $uploadsDir . '/protected/';
} }
} }
@ -42,7 +43,8 @@ class File extends FileBase
$uploadsDir = Config::get('cms.uploadsDir'); $uploadsDir = Config::get('cms.uploadsDir');
if ($this->isPublic()) { if ($this->isPublic()) {
return Request::getBasePath() . $uploadsDir . '/public/'; return Request::getBasePath() . $uploadsDir . '/public/';
} else { }
else {
return Request::getBasePath() . $uploadsDir . '/protected/'; return Request::getBasePath() . $uploadsDir . '/protected/';
} }
} }

View File

@ -61,7 +61,8 @@ class MailSettings extends Model
if ($settings->smtp_authorization) { if ($settings->smtp_authorization) {
$config->set('mail.username', $settings->smtp_user); $config->set('mail.username', $settings->smtp_user);
$config->set('mail.password', $settings->smtp_password); $config->set('mail.password', $settings->smtp_password);
} else { }
else {
$config->set('mail.username', null); $config->set('mail.username', null);
$config->set('mail.password', null); $config->set('mail.password', null);
} }
@ -76,5 +77,6 @@ class MailSettings extends Model
$config->set('services.mailgun.secret', $settings->mailgun_secret); $config->set('services.mailgun.secret', $settings->mailgun_secret);
break; break;
} }
} }
} }

View File

@ -107,7 +107,8 @@ class MailTemplate extends Model
} }
self::$cache[$code] = $template; self::$cache[$code] = $template;
} else { }
else {
$template = self::$cache[$code]; $template = self::$cache[$code];
} }

View File

@ -58,7 +58,8 @@ class PluginVersion extends Model
if ($this->is_disabled) { if ($this->is_disabled) {
$manager->disablePlugin($this->code, true); $manager->disablePlugin($this->code, true);
} else { }
else {
$manager->enablePlugin($this->code, true); $manager->enablePlugin($this->code, true);
} }
@ -67,7 +68,8 @@ class PluginVersion extends Model
if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) { if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
$this->disabledByConfig = in_array($this->code, $configDisabled); $this->disabledByConfig = in_array($this->code, $configDisabled);
} }
} else { }
else {
$this->name = $this->code; $this->name = $this->code;
$this->description = Lang::get('system::lang.plugins.unknown_plugin'); $this->description = Lang::get('system::lang.plugins.unknown_plugin');
$this->orphaned = true; $this->orphaned = true;

View File

@ -47,7 +47,8 @@ class RequestLog extends Model
if (!$record->exists) { if (!$record->exists) {
$record->count = 1; $record->count = 1;
$record->save(); $record->save();
} else { }
else {
$record->increment('count'); $record->increment('count');
} }

View File

@ -20,7 +20,8 @@ class Status extends ReportWidgetBase
{ {
try { try {
$this->loadData(); $this->loadData();
} catch (Exception $ex) { }
catch (Exception $ex) {
$this->vars['error'] = $ex->getMessage(); $this->vars['error'] = $ex->getMessage();
} }

View File

@ -270,7 +270,8 @@ trait AssetMaker
if ($build == 'core') { if ($build == 'core') {
$build = 'v' . Parameters::get('system::core.build', 1); $build = 'v' . Parameters::get('system::core.build', 1);
} elseif ($pluginVersion = PluginVersion::getVersion($build)) { }
elseif ($pluginVersion = PluginVersion::getVersion($build)) {
$build = 'v' . $pluginVersion; $build = 'v' . $pluginVersion;
} }

View File

@ -33,19 +33,22 @@ trait ConfigMaker
*/ */
if (is_object($configFile)) { if (is_object($configFile)) {
$config = $configFile; $config = $configFile;
}
/* /*
* Embedded config * Embedded config
*/ */
} elseif (is_array($configFile)) { elseif (is_array($configFile)) {
$config = $this->makeConfigFromArray($configFile); $config = $this->makeConfigFromArray($configFile);
}
/* /*
* Process config from file contents * Process config from file contents
*/ */
} else { else {
if (isset($this->controller) && method_exists($this->controller, 'getConfigPath')) { if (isset($this->controller) && method_exists($this->controller, 'getConfigPath')) {
$configFile = $this->controller->getConfigPath($configFile); $configFile = $this->controller->getConfigPath($configFile);
} else { }
else {
$configFile = $this->getConfigPath($configFile); $configFile = $this->getConfigPath($configFile);
} }

View File

@ -74,7 +74,8 @@ class Loader implements Twig_LoaderInterface
try { try {
$this->findTemplate($name); $this->findTemplate($name);
return true; return true;
} catch (Exception $exception) { }
catch (Exception $exception) {
return false; return false;
} }
} }