mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Clean up
This commit is contained in:
parent
5a9d62d54a
commit
40269cb6e2
@ -433,7 +433,7 @@ class CmsCompoundObject extends CmsObject
|
||||
* Determine if an attribute exists on the object.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
@ -459,7 +459,7 @@ class CmsCompoundObject extends CmsObject
|
||||
{
|
||||
if (in_array($method, $this->passthru)) {
|
||||
$collection = $this->get();
|
||||
return call_user_func_array(array($collection, $method), $parameters);
|
||||
return call_user_func_array([$collection, $method], $parameters);
|
||||
}
|
||||
|
||||
return parent::__call($method, $parameters);
|
||||
|
@ -17,19 +17,19 @@ use Exception;
|
||||
class CmsException extends ApplicationException
|
||||
{
|
||||
/**
|
||||
* @var Cms\Classes\CmsCompoundObject A reference to a CMS object used for masking errors.
|
||||
* @var \Cms\Classes\CmsCompoundObject A reference to a CMS object used for masking errors.
|
||||
*/
|
||||
protected $compoundObject;
|
||||
|
||||
/**
|
||||
* @var array Collection of error codes for each error distinction.
|
||||
*/
|
||||
protected static $errorCodes = array(
|
||||
protected static $errorCodes = [
|
||||
100 => 'General',
|
||||
200 => 'INI Settings',
|
||||
300 => 'PHP Content',
|
||||
400 => 'Twig Template'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Creates the CMS exception object.
|
||||
|
@ -343,7 +343,7 @@ class Index extends Controller
|
||||
{
|
||||
$class = $this->resolveTypeClassName($type);
|
||||
|
||||
if (!($template = call_user_func(array($class, 'load'), $this->theme, $path))) {
|
||||
if (!($template = call_user_func([$class, 'load'], $this->theme, $path))) {
|
||||
throw new ApplicationException(trans('cms::lang.template.not_found'));
|
||||
}
|
||||
|
||||
|
@ -62,13 +62,13 @@ class DebugExtension extends Twig_Extension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFunction('dump', [$this, 'runDump'], array(
|
||||
return [
|
||||
new Twig_SimpleFunction('dump', [$this, 'runDump'], [
|
||||
'is_safe' => ['html'],
|
||||
'needs_context' => true,
|
||||
'needs_environment' => true
|
||||
)),
|
||||
);
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +141,7 @@ class DebugExtension extends Twig_Extension
|
||||
/**
|
||||
* Dump information about a variable
|
||||
*
|
||||
* @param mixed $variable Variable to dump
|
||||
* @param mixed $variables Variable to dump
|
||||
* @param mixed $caption Caption [and subcaption] of the dump
|
||||
* @return void
|
||||
*/
|
||||
|
@ -33,7 +33,7 @@ class FlashTokenParser extends Twig_TokenParser
|
||||
}
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
$body = $this->parser->subparse(array($this, 'decideIfEnd'), true);
|
||||
$body = $this->parser->subparse([$this, 'decideIfEnd'], true);
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
return new FlashNode($name, $body, $lineno, $this->getTag());
|
||||
@ -41,7 +41,7 @@ class FlashTokenParser extends Twig_TokenParser
|
||||
|
||||
public function decideIfEnd(Twig_Token $token)
|
||||
{
|
||||
return $token->test(array('endflash'));
|
||||
return $token->test(['endflash']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,7 +195,7 @@ class ComponentList extends WidgetBase
|
||||
|
||||
protected function getPluginComponents($plugin)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
$pluginClass = get_class($plugin);
|
||||
foreach ($this->pluginComponentList as $componentInfo) {
|
||||
if ($componentInfo->pluginClass == $pluginClass) {
|
||||
@ -219,7 +219,9 @@ class ComponentList extends WidgetBase
|
||||
|
||||
protected function updateList()
|
||||
{
|
||||
return ['#'.$this->getId('component-list') => $this->makePartial('items', ['items'=>$this->getData()])];
|
||||
return ['#'.$this->getId('component-list') => $this->makePartial('items', [
|
||||
'items' => $this->getData()]
|
||||
)];
|
||||
}
|
||||
|
||||
protected function itemMatchesSearch(&$words, $item)
|
||||
|
@ -17,6 +17,8 @@ use Backend\Classes\WidgetBase;
|
||||
*/
|
||||
class TemplateList extends WidgetBase
|
||||
{
|
||||
use \Backend\Traits\SelectableWidget;
|
||||
|
||||
protected $searchTerm = false;
|
||||
|
||||
protected $dataSource;
|
||||
@ -25,8 +27,6 @@ class TemplateList extends WidgetBase
|
||||
|
||||
protected $groupStatusCache = false;
|
||||
|
||||
protected $selectedTemplatesCache = false;
|
||||
|
||||
/**
|
||||
* @var string object property to use as a title.
|
||||
*/
|
||||
@ -78,6 +78,7 @@ class TemplateList extends WidgetBase
|
||||
$this->alias = $alias;
|
||||
$this->dataSource = $dataSource;
|
||||
$this->theme = Theme::getEditTheme();
|
||||
$this->selectionInputName = 'template';
|
||||
|
||||
parent::__construct($controller, []);
|
||||
|
||||
@ -129,11 +130,6 @@ class TemplateList extends WidgetBase
|
||||
$this->setGroupStatus(Input::get('group'), Input::get('status'));
|
||||
}
|
||||
|
||||
public function onSelect()
|
||||
{
|
||||
$this->extendSelection();
|
||||
}
|
||||
|
||||
public function onUpdate()
|
||||
{
|
||||
$this->extendSelection();
|
||||
@ -305,7 +301,9 @@ class TemplateList extends WidgetBase
|
||||
|
||||
protected function updateList()
|
||||
{
|
||||
return ['#'.$this->getId('template-list') => $this->makePartial('items', ['items'=>$this->getData()])];
|
||||
return [
|
||||
'#'.$this->getId('template-list') => $this->makePartial('items', ['items' => $this->getData()])
|
||||
];
|
||||
}
|
||||
|
||||
protected function itemMatchesSearch($words, $item)
|
||||
@ -387,41 +385,4 @@ class TemplateList extends WidgetBase
|
||||
$this->groupStatusCache = $statuses;
|
||||
$this->putSession($this->getThemeSessionKey('groups'), $statuses);
|
||||
}
|
||||
|
||||
protected function getSelectedTemplates()
|
||||
{
|
||||
if ($this->selectedTemplatesCache !== false) {
|
||||
return $this->selectedTemplatesCache;
|
||||
}
|
||||
|
||||
$templates = $this->getSession($this->getThemeSessionKey('selected'), []);
|
||||
if (!is_array($templates)) {
|
||||
return $this->selectedTemplatesCache = [];
|
||||
}
|
||||
|
||||
return $this->selectedTemplatesCache = $templates;
|
||||
}
|
||||
|
||||
protected function extendSelection()
|
||||
{
|
||||
$items = Input::get('template', []);
|
||||
$currentSelection = $this->getSelectedTemplates();
|
||||
|
||||
$this->putSession($this->getThemeSessionKey('selected'), array_merge($currentSelection, $items));
|
||||
}
|
||||
|
||||
protected function resetSelection()
|
||||
{
|
||||
$this->putSession($this->getThemeSessionKey('selected'), []);
|
||||
}
|
||||
|
||||
protected function isTemplateSelected($item)
|
||||
{
|
||||
$selectedTemplates = $this->getSelectedTemplates();
|
||||
if (!is_array($selectedTemplates) || !isset($selectedTemplates[$item->fileName])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $selectedTemplates[$item->fileName];
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
id="<?= $cbId ?>"
|
||||
type="checkbox"
|
||||
name="template[<?= e($item->fileName) ?>]"
|
||||
<?= $this->isTemplateSelected($item) ? 'checked' : null ?>
|
||||
<?= $this->isItemSelected($item->fileName) ? 'checked' : null ?>
|
||||
data-request="<?= $this->getEventHandler('onSelect') ?>"
|
||||
value="1">
|
||||
<label for="<?= $cbId ?>">Select</label>
|
||||
|
Loading…
x
Reference in New Issue
Block a user