Merge if constructs
This commit is contained in:
parent
0947406343
commit
02bd38cfb1
|
|
@ -379,11 +379,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -695,22 +693,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1524,12 +1522,10 @@ class RelationController extends ControllerBehavior
|
|||
{
|
||||
$config = isset($this->config->{$mode}) ? $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) {
|
||||
|
|
|
|||
|
|
@ -1478,10 +1478,11 @@ 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';
|
||||
|
|
|
|||
|
|
@ -1039,10 +1039,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);
|
||||
|
|
@ -1080,10 +1080,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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -828,15 +828,12 @@ class Controller
|
|||
/*
|
||||
* 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;
|
||||
|
|
@ -870,18 +867,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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -331,14 +331,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;
|
||||
|
|
|
|||
|
|
@ -180,10 +180,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 = [];
|
||||
|
|
|
|||
|
|
@ -372,10 +372,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)) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue