Updating modules/system
This commit is contained in:
parent
347dff7e75
commit
f85087eac6
|
|
@ -47,19 +47,37 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Define path constants
|
||||
*/
|
||||
if (!defined('PATH_APP')) define('PATH_APP', app_path());
|
||||
if (!defined('PATH_BASE')) define('PATH_BASE', base_path());
|
||||
if (!defined('PATH_PUBLIC')) define('PATH_PUBLIC', public_path());
|
||||
if (!defined('PATH_STORAGE')) define('PATH_STORAGE', storage_path());
|
||||
if (!defined('PATH_PLUGINS')) define('PATH_PLUGINS', base_path() . Config::get('cms.pluginsDir', '/plugins'));
|
||||
if (!defined('PATH_APP')) {
|
||||
define('PATH_APP', app_path());
|
||||
}
|
||||
if (!defined('PATH_BASE')) {
|
||||
define('PATH_BASE', base_path());
|
||||
}
|
||||
if (!defined('PATH_PUBLIC')) {
|
||||
define('PATH_PUBLIC', public_path());
|
||||
}
|
||||
if (!defined('PATH_STORAGE')) {
|
||||
define('PATH_STORAGE', storage_path());
|
||||
}
|
||||
if (!defined('PATH_PLUGINS')) {
|
||||
define('PATH_PLUGINS', base_path() . Config::get('cms.pluginsDir', '/plugins'));
|
||||
}
|
||||
|
||||
/*
|
||||
* Register singletons
|
||||
*/
|
||||
App::singleton('string', function(){ return new \October\Rain\Support\Str; });
|
||||
App::singleton('backend.helper', function(){ return new \Backend\Classes\BackendHelper; });
|
||||
App::singleton('backend.menu', function() { return \Backend\Classes\NavigationManager::instance(); });
|
||||
App::singleton('backend.auth', function() { return \Backend\Classes\AuthManager::instance(); });
|
||||
App::singleton('string', function () {
|
||||
return new \October\Rain\Support\Str;
|
||||
});
|
||||
App::singleton('backend.helper', function () {
|
||||
return new \Backend\Classes\BackendHelper;
|
||||
});
|
||||
App::singleton('backend.menu', function () {
|
||||
return \Backend\Classes\NavigationManager::instance();
|
||||
});
|
||||
App::singleton('backend.auth', function () {
|
||||
return \Backend\Classes\AuthManager::instance();
|
||||
});
|
||||
|
||||
/*
|
||||
* Check for CLI or system/updates route and disable any plugin initialization
|
||||
|
|
@ -67,12 +85,14 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
*/
|
||||
$requestPath = \October\Rain\Router\Helper::normalizeUrl(\Request::path());
|
||||
$systemPath = \October\Rain\Router\Helper::normalizeUrl(Config::get('cms.backendUri') . '/system/updates');
|
||||
if (stripos($requestPath, $systemPath) === 0)
|
||||
if (stripos($requestPath, $systemPath) === 0) {
|
||||
PluginManager::$noInit = true;
|
||||
}
|
||||
|
||||
$updateCommands = ['october:up', 'october:update'];
|
||||
if (App::runningInConsole() && count(array_intersect($updateCommands, Request::server('argv'))) > 0)
|
||||
if (App::runningInConsole() && count(array_intersect($updateCommands, Request::server('argv'))) > 0) {
|
||||
PluginManager::$noInit = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register all plugins
|
||||
|
|
@ -83,7 +103,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Error handling for uncaught Exceptions
|
||||
*/
|
||||
App::error(function(\Exception $exception, $httpCode){
|
||||
App::error(function (\Exception $exception, $httpCode) {
|
||||
$handler = new ErrorHandler;
|
||||
return $handler->handleException($exception, $httpCode);
|
||||
});
|
||||
|
|
@ -91,9 +111,10 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Write all log events to the database
|
||||
*/
|
||||
Event::listen('illuminate.log', function($level, $message, $context){
|
||||
if (!DbDongle::hasDatabase())
|
||||
Event::listen('illuminate.log', function ($level, $message, $context) {
|
||||
if (!DbDongle::hasDatabase()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventLog::add($message, $level);
|
||||
});
|
||||
|
|
@ -101,7 +122,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Register basic Twig
|
||||
*/
|
||||
App::bindShared('twig', function($app) {
|
||||
App::bindShared('twig', function ($app) {
|
||||
$twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]);
|
||||
$twig->addExtension(new TwigExtension);
|
||||
return $twig;
|
||||
|
|
@ -110,14 +131,14 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Register .htm extension for Twig views
|
||||
*/
|
||||
App::make('view')->addExtension('htm', 'twig', function() {
|
||||
App::make('view')->addExtension('htm', 'twig', function () {
|
||||
return new TwigEngine(App::make('twig'));
|
||||
});
|
||||
|
||||
/*
|
||||
* Register Twig that will parse strings
|
||||
*/
|
||||
App::bindShared('twig.string', function($app) {
|
||||
App::bindShared('twig.string', function ($app) {
|
||||
$twig = $app['twig'];
|
||||
$twig->setLoader(new Twig_Loader_String);
|
||||
return $twig;
|
||||
|
|
@ -126,31 +147,35 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Override system mailer with mail settings
|
||||
*/
|
||||
Event::listen('mailer.beforeRegister', function() {
|
||||
if (MailSettings::isConfigured())
|
||||
Event::listen('mailer.beforeRegister', function () {
|
||||
if (MailSettings::isConfigured()) {
|
||||
MailSettings::applyConfigValues();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Override standard Mailer content with template
|
||||
*/
|
||||
Event::listen('mailer.beforeAddContent', function($mailer, $message, $view, $plain, $data){
|
||||
if (MailTemplate::addContentToMailer($message, $view, $data))
|
||||
Event::listen('mailer.beforeAddContent', function ($mailer, $message, $view, $plain, $data) {
|
||||
if (MailTemplate::addContentToMailer($message, $view, $data)) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Register other module providers
|
||||
*/
|
||||
foreach (Config::get('cms.loadModules', []) as $module) {
|
||||
if (strtolower(trim($module)) == 'system') continue;
|
||||
if (strtolower(trim($module)) == 'system') {
|
||||
continue;
|
||||
}
|
||||
App::register('\\' . $module . '\ServiceProvider');
|
||||
}
|
||||
|
||||
/*
|
||||
* Register navigation
|
||||
*/
|
||||
BackendMenu::registerCallback(function($manager) {
|
||||
BackendMenu::registerCallback(function ($manager) {
|
||||
$manager->registerMenuItems('October.System', [
|
||||
'system' => [
|
||||
'label' => 'system::lang.system.menu_label',
|
||||
|
|
@ -165,7 +190,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Register report widgets
|
||||
*/
|
||||
WidgetManager::instance()->registerReportWidgets(function($manager){
|
||||
WidgetManager::instance()->registerReportWidgets(function ($manager) {
|
||||
$manager->registerReportWidget('System\ReportWidgets\Status', [
|
||||
'label' => 'backend::lang.dashboard.status.widget_title_default',
|
||||
'context' => 'dashboard'
|
||||
|
|
@ -175,18 +200,27 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Register permissions
|
||||
*/
|
||||
BackendAuth::registerCallback(function($manager) {
|
||||
BackendAuth::registerCallback(function ($manager) {
|
||||
$manager->registerPermissions('October.System', [
|
||||
'system.manage_settings' => ['label' => 'system::lang.permissions.manage_system_settings', 'tab' => 'System'],
|
||||
'system.manage_updates' => ['label' => 'system::lang.permissions.manage_software_updates', 'tab' => 'System'],
|
||||
'system.manage_mail_templates' => ['label' => 'system::lang.permissions.manage_mail_templates', 'tab' => 'System'],
|
||||
'system.manage_settings' => [
|
||||
'label' => 'system::lang.permissions.manage_system_settings',
|
||||
'tab' => 'System'
|
||||
],
|
||||
'system.manage_updates' => [
|
||||
'label' => 'system::lang.permissions.manage_software_updates',
|
||||
'tab' => 'System'
|
||||
],
|
||||
'system.manage_mail_templates' => [
|
||||
'label' => 'system::lang.permissions.manage_mail_templates',
|
||||
'tab' => 'System'
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
/*
|
||||
* Register markup tags
|
||||
*/
|
||||
MarkupManager::instance()->registerCallback(function($manager){
|
||||
MarkupManager::instance()->registerCallback(function ($manager) {
|
||||
$manager->registerFunctions([
|
||||
// Functions
|
||||
'post' => 'post',
|
||||
|
|
@ -227,7 +261,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Register settings
|
||||
*/
|
||||
SettingsManager::instance()->registerCallback(function($manager){
|
||||
SettingsManager::instance()->registerCallback(function ($manager) {
|
||||
$manager->registerSettingItems('October.System', [
|
||||
'administrators' => [
|
||||
'label' => 'backend::lang.user.menu_label',
|
||||
|
|
@ -298,14 +332,18 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
/*
|
||||
* Override clear cache command
|
||||
*/
|
||||
App::bindShared('command.cache.clear', function($app) {
|
||||
App::bindShared('command.cache.clear', function ($app) {
|
||||
return new \System\Console\CacheClear($app['cache'], $app['files']);
|
||||
});
|
||||
|
||||
/*
|
||||
* Register the sidebar for the System main menu
|
||||
*/
|
||||
BackendMenu::registerContextSidenavPartial('October.System', 'system', '@/modules/system/partials/_system_sidebar.htm');
|
||||
BackendMenu::registerContextSidenavPartial(
|
||||
'October.System',
|
||||
'system',
|
||||
'@/modules/system/partials/_system_sidebar.htm'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,4 +54,4 @@ return [
|
|||
'SystemException' => 'System\Classes\SystemException',
|
||||
'ApplicationException' => 'System\Classes\ApplicationException',
|
||||
'ValidationException' => 'October\Rain\Support\ValidationException',
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -71,8 +71,9 @@ class SettingsModel extends ModelBehavior
|
|||
*/
|
||||
public function instance()
|
||||
{
|
||||
if (isset(self::$instances[$this->recordCode]))
|
||||
if (isset(self::$instances[$this->recordCode])) {
|
||||
return self::$instances[$this->recordCode];
|
||||
}
|
||||
|
||||
if (!$item = $this->getSettingsRecord()) {
|
||||
$this->model->initSettingsData();
|
||||
|
|
@ -127,8 +128,9 @@ class SettingsModel extends ModelBehavior
|
|||
*/
|
||||
public function getSettingsValue($key, $default = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->fieldValues))
|
||||
if (array_key_exists($key, $this->fieldValues)) {
|
||||
return $this->fieldValues[$key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
|
@ -136,7 +138,9 @@ class SettingsModel extends ModelBehavior
|
|||
/**
|
||||
* Default values to set for this model, override
|
||||
*/
|
||||
public function initSettingsData(){}
|
||||
public function initSettingsData()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the field values from the database record.
|
||||
|
|
@ -164,8 +168,9 @@ class SettingsModel extends ModelBehavior
|
|||
public function beforeModelSave()
|
||||
{
|
||||
$this->model->item = $this->recordCode;
|
||||
if ($this->fieldValues)
|
||||
if ($this->fieldValues) {
|
||||
$this->model->value = $this->fieldValues;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -182,8 +187,9 @@ class SettingsModel extends ModelBehavior
|
|||
*/
|
||||
public function setModelAttribute($key, $value)
|
||||
{
|
||||
if ($this->isKeyAllowed($key))
|
||||
if ($this->isKeyAllowed($key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fieldValues[$key] = $value;
|
||||
}
|
||||
|
|
@ -197,14 +203,16 @@ class SettingsModel extends ModelBehavior
|
|||
/*
|
||||
* Let the core columns through
|
||||
*/
|
||||
if ($key == 'id' || $key == 'value' || $key == 'item')
|
||||
if ($key == 'id' || $key == 'value' || $key == 'item') {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Let relations through
|
||||
*/
|
||||
if ($this->model->hasRelation($key))
|
||||
if ($this->model->hasRelation($key)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@
|
|||
*/
|
||||
class ApplicationException extends ExceptionBase
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,19 +21,18 @@ class Controller extends BaseController
|
|||
*/
|
||||
public function combine($name)
|
||||
{
|
||||
try {
|
||||
if (!strpos($name, '-'))
|
||||
throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name'=>$name]));
|
||||
|
||||
$parts = explode('-', $name);
|
||||
$cacheId = $parts[0];
|
||||
|
||||
$combiner = new CombineAssets;
|
||||
return $combiner->getContents($cacheId);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
return '/* '.$ex->getMessage().' */';
|
||||
}
|
||||
try {
|
||||
if (!strpos($name, '-')) {
|
||||
throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name' => $name]));
|
||||
}
|
||||
|
||||
$parts = explode('-', $name);
|
||||
$cacheId = $parts[0];
|
||||
|
||||
$combiner = new CombineAssets;
|
||||
return $combiner->getContents($cacheId);
|
||||
} catch (Exception $ex) {
|
||||
return '/* '.$ex->getMessage().' */';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,32 +40,34 @@ class ErrorHandler
|
|||
public function handleException(\Exception $proposedException, $httpCode = 500)
|
||||
{
|
||||
// Disable the error handler for test and CLI environment
|
||||
if (App::runningUnitTests() || App::runningInConsole())
|
||||
if (App::runningUnitTests() || App::runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Detect AJAX request and use error 500
|
||||
if (Request::ajax())
|
||||
return Response::make($proposedException->getMessage(), $httpCode);
|
||||
if (Request::ajax()) {
|
||||
return Response::make($proposedException->getMessage(), $httpCode);
|
||||
}
|
||||
|
||||
// Clear the output buffer
|
||||
while (ob_get_level())
|
||||
while (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
// Friendly error pages are used
|
||||
if (Config::get('cms.customErrorPage'))
|
||||
if (Config::get('cms.customErrorPage')) {
|
||||
return $this->handleCustomError();
|
||||
}
|
||||
|
||||
// If the exception is already our brand, use it.
|
||||
if ($proposedException instanceof BaseException) {
|
||||
$exception = $proposedException;
|
||||
}
|
||||
// If there is an active mask prepared, use that.
|
||||
elseif (static::$activeMask !== null) {
|
||||
} elseif (static::$activeMask !== null) {
|
||||
$exception = static::$activeMask;
|
||||
$exception->setMask($proposedException);
|
||||
}
|
||||
// Otherwise we should mask it with our own default scent.
|
||||
else {
|
||||
} else {
|
||||
$exception = new ApplicationException($proposedException->getMessage(), 0);
|
||||
$exception->setMask($proposedException);
|
||||
}
|
||||
|
|
@ -83,8 +85,9 @@ class ErrorHandler
|
|||
*/
|
||||
public static function applyMask(\Exception $exception)
|
||||
{
|
||||
if (static::$activeMask !== null)
|
||||
if (static::$activeMask !== null) {
|
||||
array_push(static::$maskLayers, static::$activeMask);
|
||||
}
|
||||
|
||||
static::$activeMask = $exception;
|
||||
}
|
||||
|
|
@ -95,10 +98,11 @@ class ErrorHandler
|
|||
*/
|
||||
public static function removeMask()
|
||||
{
|
||||
if (count(static::$maskLayers) > 0)
|
||||
if (count(static::$maskLayers) > 0) {
|
||||
static::$activeMask = array_pop(static::$maskLayers);
|
||||
else
|
||||
} else {
|
||||
static::$activeMask = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,12 +116,12 @@ class ErrorHandler
|
|||
|
||||
// Use the default view if no "/error" URL is found.
|
||||
$router = new Router($theme);
|
||||
if (!$router->findByUrl('/error'))
|
||||
if (!$router->findByUrl('/error')) {
|
||||
return View::make('cms::error');
|
||||
}
|
||||
|
||||
// Route to the CMS error page.
|
||||
$controller = new Controller($theme);
|
||||
return $controller->run('/error');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class ExceptionBase extends Exception
|
|||
$this->className = get_called_class();
|
||||
}
|
||||
|
||||
if ($this->errorType === null) {
|
||||
if ($this->errorType === null) {
|
||||
$this->errorType = 'Undefined';
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +140,9 @@ class ExceptionBase extends Exception
|
|||
*/
|
||||
public function getTrueException()
|
||||
{
|
||||
if ($this->mask !== null)
|
||||
if ($this->mask !== null) {
|
||||
return $this->mask;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -157,8 +158,9 @@ class ExceptionBase extends Exception
|
|||
*/
|
||||
public function getHighlight()
|
||||
{
|
||||
if ($this->highlight !== null)
|
||||
if ($this->highlight !== null) {
|
||||
return $this->highlight;
|
||||
}
|
||||
|
||||
if (!$this->fileContent && File::exists($this->file) && is_readable($this->file)) {
|
||||
$this->fileContent = @file($this->file);
|
||||
|
|
@ -167,13 +169,15 @@ class ExceptionBase extends Exception
|
|||
$errorLine = $this->line - 1;
|
||||
$startLine = $errorLine - 6;
|
||||
|
||||
if ($startLine < 0)
|
||||
if ($startLine < 0) {
|
||||
$startLine = 0;
|
||||
}
|
||||
|
||||
$endLine = $startLine + 12;
|
||||
$lineNum = count($this->fileContent);
|
||||
if ($endLine > $lineNum-1)
|
||||
if ($endLine > $lineNum-1) {
|
||||
$endLine = $lineNum-1;
|
||||
}
|
||||
|
||||
$areaLines = array_slice($this->fileContent, $startLine, $endLine - $startLine + 1);
|
||||
|
||||
|
|
@ -222,8 +226,8 @@ class ExceptionBase extends Exception
|
|||
|
||||
foreach ($traceInfo as $index => $event) {
|
||||
|
||||
$functionName = (isset($event['class']) && strlen($event['class']))
|
||||
? $event['class'].$event['type'].$event['function']
|
||||
$functionName = (isset($event['class']) && strlen($event['class']))
|
||||
? $event['class'].$event['type'].$event['function']
|
||||
: $event['function'];
|
||||
|
||||
$file = isset($event['file']) ? URL::to(str_replace(public_path(), '', $event['file'])) : null;
|
||||
|
|
@ -261,13 +265,18 @@ class ExceptionBase extends Exception
|
|||
*/
|
||||
$useFilter = false;
|
||||
foreach ($traceInfo as $event) {
|
||||
if (isset($event['class']) && $event['class'] == 'Illuminate\Exception\Handler' && $event['function'] == 'handleError') {
|
||||
if (
|
||||
isset($event['class']) &&
|
||||
$event['class'] == 'Illuminate\Exception\Handler' &&
|
||||
$event['function'] == 'handleError'
|
||||
) {
|
||||
$useFilter = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$useFilter)
|
||||
if (!$useFilter) {
|
||||
return $traceInfo;
|
||||
}
|
||||
|
||||
$filterResult = [];
|
||||
$pruneResult = true;
|
||||
|
|
@ -275,13 +284,18 @@ class ExceptionBase extends Exception
|
|||
/*
|
||||
* Prune the tail end of the trace from the framework exception handler.
|
||||
*/
|
||||
if (isset($event['class']) && $event['class'] == 'Illuminate\Exception\Handler' && $event['function'] == 'handleError') {
|
||||
if (
|
||||
isset($event['class']) &&
|
||||
$event['class'] == 'Illuminate\Exception\Handler' &&
|
||||
$event['function'] == 'handleError'
|
||||
) {
|
||||
$pruneResult = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($pruneResult)
|
||||
if ($pruneResult) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filterResult[$index] = $event;
|
||||
}
|
||||
|
|
@ -304,42 +318,39 @@ class ExceptionBase extends Exception
|
|||
$items = array();
|
||||
|
||||
foreach ($argument as $index => $obj) {
|
||||
if (is_array($obj))
|
||||
if (is_array($obj)) {
|
||||
$value = 'array('.count($obj).')';
|
||||
|
||||
elseif (is_object($obj))
|
||||
} elseif (is_object($obj)) {
|
||||
$value = 'object('.get_class($obj).')';
|
||||
|
||||
elseif (is_integer($obj))
|
||||
} elseif (is_integer($obj)) {
|
||||
$value = $obj;
|
||||
|
||||
elseif ($obj === null)
|
||||
} elseif ($obj === null) {
|
||||
$value = "null";
|
||||
|
||||
else
|
||||
} else {
|
||||
$value = "'".$obj."'";
|
||||
}
|
||||
|
||||
$items[] = $index . ' => ' . $value;
|
||||
}
|
||||
|
||||
if (count($items))
|
||||
if (count($items)) {
|
||||
$arg = 'array(' . count($argument) . ') [' . implode(', ', $items) . ']';
|
||||
else
|
||||
} else {
|
||||
$arg = 'array(0)';
|
||||
}
|
||||
elseif (is_object($argument))
|
||||
}
|
||||
} elseif (is_object($argument)) {
|
||||
$arg = 'object('.get_class($argument).')';
|
||||
elseif ($argument === null)
|
||||
} elseif ($argument === null) {
|
||||
$arg = "null";
|
||||
elseif (is_integer($argument))
|
||||
} elseif (is_integer($argument)) {
|
||||
$arg = $argument;
|
||||
else
|
||||
} else {
|
||||
$arg = "'".$argument."'";
|
||||
}
|
||||
|
||||
$argsArray[] = $arg;
|
||||
}
|
||||
|
||||
return implode(', ', $argsArray);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,12 +60,14 @@ class MarkupManager
|
|||
|
||||
foreach ($plugins as $id => $plugin) {
|
||||
$items = $plugin->registerMarkupTags();
|
||||
if (!is_array($items))
|
||||
if (!is_array($items)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($items as $type => $definitions) {
|
||||
if (!is_array($definitions))
|
||||
if (!is_array($definitions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->registerExtensions($type, $definitions);
|
||||
}
|
||||
|
|
@ -103,23 +105,24 @@ class MarkupManager
|
|||
*/
|
||||
public function registerExtensions($type, array $definitions)
|
||||
{
|
||||
if (is_null($this->items))
|
||||
if (is_null($this->items)) {
|
||||
$this->items = [];
|
||||
}
|
||||
|
||||
if (!array_key_exists($type, $this->items))
|
||||
if (!array_key_exists($type, $this->items)) {
|
||||
$this->items[$type] = [];
|
||||
}
|
||||
|
||||
foreach ($definitions as $name => $definition) {
|
||||
|
||||
switch ($type) {
|
||||
case self::EXTENSION_TOKEN_PARSER:
|
||||
$this->items[$type][] = $definition;
|
||||
break;
|
||||
|
||||
break;
|
||||
case self::EXTENSION_FILTER:
|
||||
case self::EXTENSION_FUNCTION:
|
||||
$this->items[$type][$name] = $definition;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -158,11 +161,13 @@ class MarkupManager
|
|||
*/
|
||||
public function listExtensions($type)
|
||||
{
|
||||
if ($this->items === null)
|
||||
if ($this->items === null) {
|
||||
$this->loadExtensions();
|
||||
}
|
||||
|
||||
if (!isset($this->items[$type]) || !is_array($this->items[$type]))
|
||||
if (!isset($this->items[$type]) || !is_array($this->items[$type])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->items[$type];
|
||||
}
|
||||
|
|
@ -201,8 +206,9 @@ class MarkupManager
|
|||
*/
|
||||
public function makeTwigFunctions($functions = [])
|
||||
{
|
||||
if (!is_array($functions))
|
||||
if (!is_array($functions)) {
|
||||
$functions = [];
|
||||
}
|
||||
|
||||
foreach ($this->listFunctions() as $name => $callable) {
|
||||
|
||||
|
|
@ -210,15 +216,16 @@ class MarkupManager
|
|||
* Handle a wildcard function
|
||||
*/
|
||||
if (strpos($name, '*') !== false && $this->isWildCallable($callable)) {
|
||||
$callable = function($name) use ($callable) {
|
||||
$callable = function ($name) use ($callable) {
|
||||
$arguments = array_slice(func_get_args(), 1);
|
||||
$method = $this->isWildCallable($callable, Str::camel($name));
|
||||
return call_user_func_array($method, $arguments);
|
||||
};
|
||||
}
|
||||
|
||||
if (!is_callable($callable))
|
||||
if (!is_callable($callable)) {
|
||||
throw new ApplicationException(sprintf('The markup function for %s is not callable.', $name));
|
||||
}
|
||||
|
||||
$functions[] = new Twig_SimpleFunction($name, $callable, ['is_safe' => ['html']]);
|
||||
}
|
||||
|
|
@ -233,8 +240,9 @@ class MarkupManager
|
|||
*/
|
||||
public function makeTwigFilters($filters = [])
|
||||
{
|
||||
if (!is_array($filters))
|
||||
if (!is_array($filters)) {
|
||||
$filters = [];
|
||||
}
|
||||
|
||||
foreach ($this->listFilters() as $name => $callable) {
|
||||
|
||||
|
|
@ -242,15 +250,16 @@ class MarkupManager
|
|||
* Handle a wildcard function
|
||||
*/
|
||||
if (strpos($name, '*') !== false && $this->isWildCallable($callable)) {
|
||||
$callable = function($name) use ($callable) {
|
||||
$callable = function ($name) use ($callable) {
|
||||
$arguments = array_slice(func_get_args(), 1);
|
||||
$method = $this->isWildCallable($callable, Str::camel($name));
|
||||
return call_user_func_array($method, $arguments);
|
||||
};
|
||||
}
|
||||
|
||||
if (!is_callable($callable))
|
||||
if (!is_callable($callable)) {
|
||||
throw new ApplicationException(sprintf('The markup filter for %s is not callable.', $name));
|
||||
}
|
||||
|
||||
$filters[] = new Twig_SimpleFilter($name, $callable, ['is_safe' => ['html']]);
|
||||
}
|
||||
|
|
@ -265,13 +274,15 @@ class MarkupManager
|
|||
*/
|
||||
public function makeTwigTokenParsers($parsers = [])
|
||||
{
|
||||
if (!is_array($parsers))
|
||||
if (!is_array($parsers)) {
|
||||
$parsers = [];
|
||||
}
|
||||
|
||||
$extraParsers = $this->listTokenParsers();
|
||||
foreach ($extraParsers as $obj) {
|
||||
if (!$obj instanceof Twig_TokenParser)
|
||||
if (!$obj instanceof Twig_TokenParser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parsers[] = $obj;
|
||||
}
|
||||
|
|
@ -290,30 +301,30 @@ class MarkupManager
|
|||
{
|
||||
$isWild = false;
|
||||
|
||||
if (is_string($callable) && strpos($callable, '*') !== false)
|
||||
if (is_string($callable) && strpos($callable, '*') !== false) {
|
||||
$isWild = $replaceWith ? str_replace('*', $replaceWith, $callable) : true;
|
||||
}
|
||||
|
||||
if (is_array($callable)) {
|
||||
if (is_string($callable[0]) && strpos($callable[0], '*') !== false) {
|
||||
if ($replaceWith) {
|
||||
$isWild = $callable;
|
||||
$isWild[0] = str_replace('*', $replaceWith, $callable[0]);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$isWild = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($callable[1]) && strpos($callable[1], '*') !== false) {
|
||||
if ($replaceWith) {
|
||||
$isWild = $isWild ?: $callable;
|
||||
$isWild[1] = str_replace('*', $replaceWith, $callable[1]);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$isWild = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $isWild;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,5 +39,4 @@ class ModelBehavior extends ModelBehaviorBase
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,16 @@ abstract class PluginBase extends ServiceProviderBase
|
|||
/**
|
||||
* Register method, called when the plugin is first registered.
|
||||
*/
|
||||
public function register() {}
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot method, called right before the request route.
|
||||
*/
|
||||
public function boot() {}
|
||||
public function boot()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers CMS markup tags introduced by this plugin.
|
||||
|
|
@ -125,10 +129,10 @@ abstract class PluginBase extends ServiceProviderBase
|
|||
public function registerConsoleCommand($key, $class)
|
||||
{
|
||||
$key = 'command.'.$key;
|
||||
$this->app[$key] = $this->app->share(function($app) use ($class){
|
||||
$this->app[$key] = $this->app->share(function ($app) use ($class) {
|
||||
return new $class;
|
||||
});
|
||||
|
||||
$this->commands($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,12 +88,14 @@ class PluginManager
|
|||
$pluginClassName = $className.'\Plugin';
|
||||
|
||||
// Autoloader failed?
|
||||
if (!class_exists($pluginClassName))
|
||||
if (!class_exists($pluginClassName)) {
|
||||
include_once $classPath.'/Plugin.php';
|
||||
}
|
||||
|
||||
// Not a valid plugin!
|
||||
if (!class_exists($pluginClassName))
|
||||
if (!class_exists($pluginClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classObj = new $pluginClassName($this->app);
|
||||
$classId = $this->getIdentifier($classObj);
|
||||
|
|
@ -101,8 +103,9 @@ class PluginManager
|
|||
/*
|
||||
* Check for disabled plugins
|
||||
*/
|
||||
if ($this->isDisabled($classId))
|
||||
if ($this->isDisabled($classId)) {
|
||||
$classObj->disabled = true;
|
||||
}
|
||||
|
||||
$this->plugins[$classId] = $classObj;
|
||||
$this->pathMap[$classId] = $classPath;
|
||||
|
|
@ -116,15 +119,18 @@ class PluginManager
|
|||
*/
|
||||
public function registerAll()
|
||||
{
|
||||
if ($this->registered)
|
||||
if ($this->registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->plugins as $pluginId => $plugin) {
|
||||
if ($plugin->disabled)
|
||||
if ($plugin->disabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!self::$noInit)
|
||||
if (!self::$noInit) {
|
||||
$plugin->register();
|
||||
}
|
||||
|
||||
$pluginPath = $this->getPluginPath($plugin);
|
||||
$pluginNamespace = strtolower($pluginId);
|
||||
|
|
@ -133,36 +139,41 @@ class PluginManager
|
|||
* Register plugin class autoloaders
|
||||
*/
|
||||
$autoloadPath = $pluginPath . '/vendor/autoload.php';
|
||||
if (File::isFile($autoloadPath))
|
||||
if (File::isFile($autoloadPath)) {
|
||||
require_once $autoloadPath;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register language namespaces
|
||||
*/
|
||||
$langPath = $pluginPath . '/lang';
|
||||
if (File::isDirectory($langPath))
|
||||
if (File::isDirectory($langPath)) {
|
||||
Lang::addNamespace($pluginNamespace, $langPath);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register configuration path
|
||||
*/
|
||||
$configPath = $pluginPath . '/config';
|
||||
if (File::isDirectory($configPath))
|
||||
if (File::isDirectory($configPath)) {
|
||||
Config::package($pluginNamespace, $configPath, $pluginNamespace);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register views path
|
||||
*/
|
||||
$viewsPath = $pluginPath . '/views';
|
||||
if (File::isDirectory($viewsPath))
|
||||
if (File::isDirectory($viewsPath)) {
|
||||
View::addNamespace($pluginNamespace, $viewsPath);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add routes, if available
|
||||
*/
|
||||
$routesFile = $pluginPath . '/routes.php';
|
||||
if (File::exists($routesFile))
|
||||
if (File::exists($routesFile)) {
|
||||
require $routesFile;
|
||||
}
|
||||
}
|
||||
|
||||
$this->registered = true;
|
||||
|
|
@ -173,15 +184,18 @@ class PluginManager
|
|||
*/
|
||||
public function bootAll()
|
||||
{
|
||||
if ($this->booted)
|
||||
if ($this->booted) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->plugins as $plugin) {
|
||||
if ($plugin->disabled)
|
||||
if ($plugin->disabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!self::$noInit)
|
||||
if (!self::$noInit) {
|
||||
$plugin->boot();
|
||||
}
|
||||
}
|
||||
|
||||
$this->booted = true;
|
||||
|
|
@ -202,8 +216,9 @@ class PluginManager
|
|||
public function getPluginPath($id)
|
||||
{
|
||||
$classId = $this->getIdentifier($id);
|
||||
if (!isset($this->pathMap[$classId]))
|
||||
if (!isset($this->pathMap[$classId])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->pathMap[$classId];
|
||||
}
|
||||
|
|
@ -234,8 +249,9 @@ class PluginManager
|
|||
*/
|
||||
public function findByNamespace($namespace)
|
||||
{
|
||||
if (!$this->hasPlugin($namespace))
|
||||
if (!$this->hasPlugin($namespace)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$classId = $this->getIdentifier($namespace);
|
||||
return $this->plugins[$classId];
|
||||
|
|
@ -246,11 +262,13 @@ class PluginManager
|
|||
*/
|
||||
public function findByIdentifier($identifier)
|
||||
{
|
||||
if (!isset($this->plugins[$identifier]))
|
||||
if (!isset($this->plugins[$identifier])) {
|
||||
$identifier = $this->normalizeIdentifier($identifier);
|
||||
}
|
||||
|
||||
if (!isset($this->plugins[$identifier]))
|
||||
if (!isset($this->plugins[$identifier])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->plugins[$identifier];
|
||||
}
|
||||
|
|
@ -290,8 +308,9 @@ class PluginManager
|
|||
$plugins = [];
|
||||
|
||||
$dirPath = $this->getPath();
|
||||
if (!File::isDirectory($dirPath))
|
||||
if (!File::isDirectory($dirPath)) {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath));
|
||||
$it->setMaxDepth(2);
|
||||
|
|
@ -319,8 +338,9 @@ class PluginManager
|
|||
public function getIdentifier($namespace)
|
||||
{
|
||||
$namespace = Str::normalizeClassName($namespace);
|
||||
if (strpos($namespace, '\\') === null)
|
||||
if (strpos($namespace, '\\') === null) {
|
||||
return $namespace;
|
||||
}
|
||||
|
||||
$parts = explode('\\', $namespace);
|
||||
$slice = array_slice($parts, 1, 2);
|
||||
|
|
@ -336,8 +356,9 @@ class PluginManager
|
|||
public function normalizeIdentifier($identifier)
|
||||
{
|
||||
foreach ($this->plugins as $id => $object) {
|
||||
if (strtolower($id) == strtolower($identifier))
|
||||
if (strtolower($id) == strtolower($identifier)) {
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
|
||||
return $identifier;
|
||||
|
|
@ -361,15 +382,15 @@ class PluginManager
|
|||
$path = $this->metaPath.'/disabled.json';
|
||||
|
||||
if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
|
||||
foreach ($configDisabled as $disabled)
|
||||
foreach ($configDisabled as $disabled) {
|
||||
$this->disabledPlugins[$disabled] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (File::exists($path)) {
|
||||
$disabled = json_decode(File::get($path), true);
|
||||
$this->disabledPlugins = array_merge($this->disabledPlugins, $disabled);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->writeDisabled();
|
||||
}
|
||||
}
|
||||
|
|
@ -382,8 +403,9 @@ class PluginManager
|
|||
public function isDisabled($id)
|
||||
{
|
||||
$code = $this->getIdentifier($id);
|
||||
if (array_key_exists($code, $this->disabledPlugins))
|
||||
if (array_key_exists($code, $this->disabledPlugins)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -403,14 +425,16 @@ class PluginManager
|
|||
public function disablePlugin($id, $isUser = false)
|
||||
{
|
||||
$code = $this->getIdentifier($id);
|
||||
if (array_key_exists($code, $this->disabledPlugins))
|
||||
if (array_key_exists($code, $this->disabledPlugins)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->disabledPlugins[$code] = $isUser;
|
||||
$this->writeDisabled();
|
||||
|
||||
if ($pluginObj = $this->findByIdentifier($code))
|
||||
if ($pluginObj = $this->findByIdentifier($code)) {
|
||||
$pluginObj->disabled = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -423,18 +447,21 @@ class PluginManager
|
|||
public function enablePlugin($id, $isUser = false)
|
||||
{
|
||||
$code = $this->getIdentifier($id);
|
||||
if (!array_key_exists($code, $this->disabledPlugins))
|
||||
if (!array_key_exists($code, $this->disabledPlugins)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Prevent system from enabling plugins disabled by the user
|
||||
if (!$isUser && $this->disabledPlugins[$code] === true)
|
||||
if (!$isUser && $this->disabledPlugins[$code] === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($this->disabledPlugins[$code]);
|
||||
$this->writeDisabled();
|
||||
|
||||
if ($pluginObj = $this->findByIdentifier($code))
|
||||
if ($pluginObj = $this->findByIdentifier($code)) {
|
||||
$pluginObj->disabled = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -450,22 +477,24 @@ class PluginManager
|
|||
protected function loadDependencies()
|
||||
{
|
||||
foreach ($this->plugins as $id => $plugin) {
|
||||
if (!$required = $this->getDependencies($plugin))
|
||||
if (!$required = $this->getDependencies($plugin)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$disable = false;
|
||||
foreach ($required as $require) {
|
||||
if (!$this->hasPlugin($require))
|
||||
if (!$this->hasPlugin($require)) {
|
||||
$disable = true;
|
||||
|
||||
elseif (($pluginObj = $this->findByIdentifier($require)) && $pluginObj->disabled)
|
||||
} elseif (($pluginObj = $this->findByIdentifier($require)) && $pluginObj->disabled) {
|
||||
$disable = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($disable)
|
||||
if ($disable) {
|
||||
$this->disablePlugin($id);
|
||||
else
|
||||
} else {
|
||||
$this->enablePlugin($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -476,11 +505,13 @@ class PluginManager
|
|||
*/
|
||||
public function getDependencies($plugin)
|
||||
{
|
||||
if (is_string($plugin) && (!$plugin = $this->findByIdentifier($identifer)))
|
||||
if (is_string($plugin) && (!$plugin = $this->findByIdentifier($identifer))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($plugin->require) || !$plugin->require)
|
||||
if (!isset($plugin->require) || !$plugin->require) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return is_array($plugin->require) ? $plugin->require : [$plugin->require];
|
||||
}
|
||||
|
|
@ -493,8 +524,9 @@ class PluginManager
|
|||
*/
|
||||
public function sortByDependencies($plugins = null)
|
||||
{
|
||||
if (!is_array($plugins))
|
||||
if (!is_array($plugins)) {
|
||||
$plugins = $this->getPlugins();
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$checklist = $plugins;
|
||||
|
|
@ -502,8 +534,9 @@ class PluginManager
|
|||
$loopCount = 0;
|
||||
while (count($checklist)) {
|
||||
|
||||
if (++$loopCount > 999)
|
||||
if (++$loopCount > 999) {
|
||||
throw new ApplicationException('Too much recursion');
|
||||
}
|
||||
|
||||
foreach ($checklist as $code => $plugin) {
|
||||
|
||||
|
|
@ -511,7 +544,7 @@ class PluginManager
|
|||
* Get dependencies and remove any aliens
|
||||
*/
|
||||
$depends = $this->getDependencies($plugin) ?: [];
|
||||
$depends = array_filter($depends, function($pluginCode) use ($plugins) {
|
||||
$depends = array_filter($depends, function ($pluginCode) use ($plugins) {
|
||||
return isset($plugins[$pluginCode]);
|
||||
});
|
||||
|
||||
|
|
@ -528,8 +561,9 @@ class PluginManager
|
|||
* Find dependencies that have not been checked
|
||||
*/
|
||||
$depends = array_diff($depends, $result);
|
||||
if (count($depends) > 0)
|
||||
if (count($depends) > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* All dependencies are checked
|
||||
|
|
@ -542,5 +576,4 @@ class PluginManager
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,8 +99,9 @@ class SettingsManager
|
|||
|
||||
foreach ($plugins as $id => $plugin) {
|
||||
$items = $plugin->registerSettings();
|
||||
if (!is_array($items))
|
||||
if (!is_array($items)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->registerSettingItems($id, $items);
|
||||
}
|
||||
|
|
@ -108,7 +109,7 @@ class SettingsManager
|
|||
/*
|
||||
* Sort settings items
|
||||
*/
|
||||
usort($this->items, function($a, $b) {
|
||||
usort($this->items, function ($a, $b) {
|
||||
return $a->order - $b->order;
|
||||
});
|
||||
|
||||
|
|
@ -122,11 +123,11 @@ class SettingsManager
|
|||
* Process each item in to a category array
|
||||
*/
|
||||
$catItems = [];
|
||||
foreach ($this->items as $item)
|
||||
{
|
||||
foreach ($this->items as $item) {
|
||||
$category = $item->category ?: 'Misc';
|
||||
if (!isset($catItems[$category]))
|
||||
if (!isset($catItems[$category])) {
|
||||
$catItems[$category] = [];
|
||||
}
|
||||
|
||||
$catItems[$category][] = $item;
|
||||
}
|
||||
|
|
@ -140,11 +141,13 @@ class SettingsManager
|
|||
*/
|
||||
public function listItems($context = null)
|
||||
{
|
||||
if ($this->items === null)
|
||||
if ($this->items === null) {
|
||||
$this->loadItems();
|
||||
}
|
||||
|
||||
if ($context !== null)
|
||||
if ($context !== null) {
|
||||
return $this->filterByContext($this->items, $context);
|
||||
}
|
||||
|
||||
return $this->items;
|
||||
}
|
||||
|
|
@ -163,12 +166,14 @@ class SettingsManager
|
|||
$filteredCategory = [];
|
||||
foreach ($category as $item) {
|
||||
$itemContext = is_array($item->context) ? $item->context : [$item->context];
|
||||
if (in_array($context, $itemContext))
|
||||
if (in_array($context, $itemContext)) {
|
||||
$filteredCategory[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($filteredCategory))
|
||||
if (count($filteredCategory)) {
|
||||
$filteredItems[$categoryName] = $filteredCategory;
|
||||
}
|
||||
}
|
||||
|
||||
return $filteredItems;
|
||||
|
|
@ -209,8 +214,9 @@ class SettingsManager
|
|||
*/
|
||||
public function registerSettingItems($owner, array $definitions)
|
||||
{
|
||||
if (!$this->items)
|
||||
if (!$this->items) {
|
||||
$this->items = [];
|
||||
}
|
||||
|
||||
foreach ($definitions as $code => $definition) {
|
||||
$item = array_merge(self::$itemDefaults, array_merge($definition, [
|
||||
|
|
@ -228,9 +234,9 @@ class SettingsManager
|
|||
list($author, $plugin) = explode('.', $owner);
|
||||
$uri[] = strtolower($author);
|
||||
$uri[] = strtolower($plugin);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$uri[] = strtolower($owner);
|
||||
}
|
||||
|
||||
$uri[] = strtolower($code);
|
||||
$uri = implode('/', $uri);
|
||||
|
|
@ -264,7 +270,7 @@ class SettingsManager
|
|||
{
|
||||
return (object)[
|
||||
'itemCode' => $this->contextItemCode,
|
||||
'owner' => $this->contextOwner
|
||||
'owner' => $this->contextOwner
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -276,15 +282,17 @@ class SettingsManager
|
|||
*/
|
||||
public function findSettingItem($owner, $code)
|
||||
{
|
||||
if ($this->allItems === null)
|
||||
if ($this->allItems === null) {
|
||||
$this->loadItems();
|
||||
}
|
||||
|
||||
$owner = strtolower($owner);
|
||||
$code = strtolower($code);
|
||||
|
||||
foreach ($this->allItems as $item) {
|
||||
if (strtolower($item->owner) == $owner && strtolower($item->code) == $code)
|
||||
if (strtolower($item->owner) == $owner && strtolower($item->code) == $code) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -298,13 +306,14 @@ class SettingsManager
|
|||
*/
|
||||
protected function filterItemPermissions($user, array $items)
|
||||
{
|
||||
array_filter($items, function($item) use ($user) {
|
||||
if (!$item->permissions || !count($item->permissions))
|
||||
array_filter($items, function ($item) use ($user) {
|
||||
if (!$item->permissions || !count($item->permissions)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->hasAnyAccess($item->permissions);
|
||||
});
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ class SystemException extends ExceptionBase
|
|||
parent::__construct($message, $code, $previous);
|
||||
Log::error($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,9 @@ class UpdateManager
|
|||
/*
|
||||
* Ensure temp directory exists
|
||||
*/
|
||||
if (!File::isDirectory($this->tempDirectory))
|
||||
if (!File::isDirectory($this->tempDirectory)) {
|
||||
File::makeDirectory($this->tempDirectory, 0777, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,8 +99,9 @@ class UpdateManager
|
|||
* Update modules
|
||||
*/
|
||||
$modules = Config::get('cms.loadModules', []);
|
||||
foreach ($modules as $module)
|
||||
foreach ($modules as $module) {
|
||||
$this->migrateModule($module);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update plugins
|
||||
|
|
@ -117,8 +119,9 @@ class UpdateManager
|
|||
*/
|
||||
if ($firstUp) {
|
||||
$modules = Config::get('cms.loadModules', []);
|
||||
foreach ($modules as $module)
|
||||
foreach ($modules as $module) {
|
||||
$this->seedModule($module);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -136,22 +139,23 @@ class UpdateManager
|
|||
* Already know about updates, never retry.
|
||||
*/
|
||||
$oldCount = Parameters::get('system::update.count');
|
||||
if ($oldCount > 0)
|
||||
if ($oldCount > 0) {
|
||||
return $oldCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retry period not passed, skipping.
|
||||
*/
|
||||
if (!$force && ($retryTimestamp = Parameters::get('system::update.retry'))) {
|
||||
if (Carbon::createFromTimeStamp($retryTimestamp)->isFuture())
|
||||
if (Carbon::createFromTimeStamp($retryTimestamp)->isFuture()) {
|
||||
return $oldCount;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $this->requestUpdateList();
|
||||
$newCount = array_get($result, 'update', 0);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$newCount = 0;
|
||||
}
|
||||
|
||||
|
|
@ -211,8 +215,9 @@ class UpdateManager
|
|||
*/
|
||||
$themes = [];
|
||||
foreach (array_get($result, 'themes', []) as $code => $info) {
|
||||
if (!$this->isThemeInstalled($code))
|
||||
if (!$this->isThemeInstalled($code)) {
|
||||
$themes[$code] = $info;
|
||||
}
|
||||
}
|
||||
$result['themes'] = $themes;
|
||||
|
||||
|
|
@ -265,7 +270,9 @@ class UpdateManager
|
|||
$this->note($note);
|
||||
}
|
||||
|
||||
if ($count == 0) break;
|
||||
if ($count == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Schema::dropIfExists('migrations');
|
||||
|
|
@ -310,8 +317,9 @@ class UpdateManager
|
|||
public function seedModule($module)
|
||||
{
|
||||
$className = '\\'.$module.'\Database\Seeds\DatabaseSeeder';
|
||||
if (!class_exists($className))
|
||||
if (!class_exists($className)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$seeder = App::make($className);
|
||||
$seeder->run();
|
||||
|
|
@ -340,8 +348,9 @@ class UpdateManager
|
|||
{
|
||||
$filePath = $this->getFilePath('core');
|
||||
|
||||
if (!Zip::extract($filePath, $this->baseDirectory))
|
||||
if (!Zip::extract($filePath, $this->baseDirectory)) {
|
||||
throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath]));
|
||||
}
|
||||
|
||||
@unlink($filePath);
|
||||
|
||||
|
|
@ -437,8 +446,9 @@ class UpdateManager
|
|||
$fileCode = $name . $hash;
|
||||
$filePath = $this->getFilePath($fileCode);
|
||||
|
||||
if (!Zip::extract($filePath, $this->baseDirectory . '/plugins/'))
|
||||
if (!Zip::extract($filePath, $this->baseDirectory . '/plugins/')) {
|
||||
throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath]));
|
||||
}
|
||||
|
||||
@unlink($filePath);
|
||||
}
|
||||
|
|
@ -467,8 +477,9 @@ class UpdateManager
|
|||
$fileCode = $name . $hash;
|
||||
$filePath = $this->getFilePath($fileCode);
|
||||
|
||||
if (!Zip::extract($filePath, $this->baseDirectory . '/themes/'))
|
||||
if (!Zip::extract($filePath, $this->baseDirectory . '/themes/')) {
|
||||
throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath]));
|
||||
}
|
||||
|
||||
$this->setThemeInstalled($name);
|
||||
@unlink($filePath);
|
||||
|
|
@ -541,12 +552,13 @@ class UpdateManager
|
|||
*/
|
||||
public function requestServerData($uri, $postData = [])
|
||||
{
|
||||
$result = Http::post($this->createServerUrl($uri), function($http) use ($postData) {
|
||||
$result = Http::post($this->createServerUrl($uri), function ($http) use ($postData) {
|
||||
$this->applyHttpAttributes($http, $postData);
|
||||
});
|
||||
|
||||
if ($result->code == 404)
|
||||
if ($result->code == 404) {
|
||||
throw new ApplicationException(Lang::get('system::lang.server.response_not_found'));
|
||||
}
|
||||
|
||||
if ($result->code != 200) {
|
||||
throw new ApplicationException(
|
||||
|
|
@ -560,13 +572,13 @@ class UpdateManager
|
|||
|
||||
try {
|
||||
$resultData = @json_decode($result->body, true);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
|
||||
}
|
||||
|
||||
if ($resultData === false || (is_string($resultData) && !strlen($resultData)))
|
||||
if ($resultData === false || (is_string($resultData) && !strlen($resultData))) {
|
||||
throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
|
||||
}
|
||||
|
||||
return $resultData;
|
||||
}
|
||||
|
|
@ -587,13 +599,14 @@ class UpdateManager
|
|||
$postData['project'] = $projectId;
|
||||
}
|
||||
|
||||
$result = Http::post($this->createServerUrl($uri), function($http) use ($postData, $filePath) {
|
||||
$result = Http::post($this->createServerUrl($uri), function ($http) use ($postData, $filePath) {
|
||||
$this->applyHttpAttributes($http, $postData);
|
||||
$http->toFile($filePath);
|
||||
});
|
||||
|
||||
if ($result->code != 200)
|
||||
if ($result->code != 200) {
|
||||
throw new ApplicationException(File::get($filePath));
|
||||
}
|
||||
|
||||
if (md5_file($filePath) != $expectedHash) {
|
||||
@unlink($filePath);
|
||||
|
|
@ -631,8 +644,9 @@ class UpdateManager
|
|||
protected function createServerUrl($uri)
|
||||
{
|
||||
$gateway = Config::get('cms.updateServer', 'http://octobercms.com/api');
|
||||
if (substr($gateway, -1) != '/')
|
||||
if (substr($gateway, -1) != '/') {
|
||||
$gateway .= '/';
|
||||
}
|
||||
|
||||
return $gateway . $uri;
|
||||
}
|
||||
|
|
@ -653,8 +667,9 @@ class UpdateManager
|
|||
$http->header('Rest-Sign', $this->createSignature($postData, $this->secret));
|
||||
}
|
||||
|
||||
if ($credentials = Config::get('cms.updateAuth'))
|
||||
if ($credentials = Config::get('cms.updateAuth')) {
|
||||
$http->auth($credentials);
|
||||
}
|
||||
|
||||
$http->noRedirect();
|
||||
$http->data($postData);
|
||||
|
|
@ -678,5 +693,4 @@ class UpdateManager
|
|||
{
|
||||
return base64_encode(hash_hmac('sha512', http_build_query($data, '', '&'), base64_decode($secret), true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,9 @@ class VersionManager
|
|||
{
|
||||
$code = (is_string($plugin)) ? $plugin : $this->pluginManager->getIdentifier($plugin);
|
||||
|
||||
if (!$this->hasVersionFile($code))
|
||||
if (!$this->hasVersionFile($code)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$currentVersion = $this->getLatestFileVersion($code);
|
||||
$databaseVersion = $this->getDatabaseVersion($code);
|
||||
|
|
@ -102,8 +103,7 @@ class VersionManager
|
|||
if (is_array($details)) {
|
||||
$comment = array_shift($details);
|
||||
$scripts = $details;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$comment = $details;
|
||||
$scripts = [];
|
||||
}
|
||||
|
|
@ -112,8 +112,9 @@ class VersionManager
|
|||
* Apply scripts, if any
|
||||
*/
|
||||
foreach ($scripts as $script) {
|
||||
if ($this->hasDatabaseHistory($code, $version, $script))
|
||||
if ($this->hasDatabaseHistory($code, $version, $script)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->applyDatabaseScript($code, $version, $script);
|
||||
}
|
||||
|
|
@ -121,8 +122,9 @@ class VersionManager
|
|||
/*
|
||||
* Register the comment and update the version
|
||||
*/
|
||||
if (!$this->hasDatabaseHistory($code, $version))
|
||||
if (!$this->hasDatabaseHistory($code, $version)) {
|
||||
$this->applyDatabaseComment($code, $version, $comment);
|
||||
}
|
||||
|
||||
$this->setDatabaseVersion($code, $version);
|
||||
|
||||
|
|
@ -136,24 +138,32 @@ class VersionManager
|
|||
{
|
||||
$code = (is_string($plugin)) ? $plugin : $this->pluginManager->getIdentifier($plugin);
|
||||
|
||||
if (!$this->hasVersionFile($code))
|
||||
if (!$this->hasVersionFile($code)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pluginHistory = $this->getDatabaseHistory($code);
|
||||
$pluginHistory = array_reverse($pluginHistory);
|
||||
|
||||
foreach ($pluginHistory as $history) {
|
||||
if ($history->type == self::HISTORY_TYPE_COMMENT)
|
||||
if ($history->type == self::HISTORY_TYPE_COMMENT) {
|
||||
$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->setDatabaseVersion($code);
|
||||
|
||||
if (isset($this->fileVersions[$code])) unset($this->fileVersions[$code]);
|
||||
if (isset($this->databaseVersions[$code])) unset($this->databaseVersions[$code]);
|
||||
if (isset($this->databaseHistory[$code])) unset($this->databaseHistory[$code]);
|
||||
if (isset($this->fileVersions[$code])) {
|
||||
unset($this->fileVersions[$code]);
|
||||
}
|
||||
if (isset($this->databaseVersions[$code])) {
|
||||
unset($this->databaseVersions[$code]);
|
||||
}
|
||||
if (isset($this->databaseHistory[$code])) {
|
||||
unset($this->databaseHistory[$code]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -165,12 +175,14 @@ class VersionManager
|
|||
public function purgePlugin($pluginCode)
|
||||
{
|
||||
$versions = Db::table('system_plugin_versions')->where('code', $pluginCode);
|
||||
if ($countVersions = $versions->count())
|
||||
if ($countVersions = $versions->count()) {
|
||||
$versions->delete();
|
||||
}
|
||||
|
||||
$history = Db::table('system_plugin_history')->where('code', $pluginCode);
|
||||
if ($countHistory = $history->count())
|
||||
if ($countHistory = $history->count()) {
|
||||
$history->delete();
|
||||
}
|
||||
|
||||
return (($countHistory + $countVersions) > 0) ? true : false;
|
||||
}
|
||||
|
|
@ -185,10 +197,11 @@ class VersionManager
|
|||
protected function getLatestFileVersion($code)
|
||||
{
|
||||
$versionInfo = $this->getFileVersions($code);
|
||||
if (!$versionInfo)
|
||||
if (!$versionInfo) {
|
||||
return self::NO_VERSION_VALUE;
|
||||
}
|
||||
|
||||
$latest = trim(key(array_slice($versionInfo, -1 , 1)));
|
||||
$latest = trim(key(array_slice($versionInfo, -1, 1)));
|
||||
return $latest;
|
||||
}
|
||||
|
||||
|
|
@ -197,8 +210,9 @@ class VersionManager
|
|||
*/
|
||||
protected function getNewFileVersions($code, $version = null)
|
||||
{
|
||||
if ($version === null)
|
||||
if ($version === null) {
|
||||
$version = self::NO_VERSION_VALUE;
|
||||
}
|
||||
|
||||
$versions = $this->getFileVersions($code);
|
||||
$position = array_search($version, array_keys($versions));
|
||||
|
|
@ -210,14 +224,15 @@ class VersionManager
|
|||
*/
|
||||
protected function getFileVersions($code)
|
||||
{
|
||||
if ($this->fileVersions !== null && array_key_exists($code, $this->fileVersions))
|
||||
if ($this->fileVersions !== null && array_key_exists($code, $this->fileVersions)) {
|
||||
return $this->fileVersions[$code];
|
||||
}
|
||||
|
||||
$versionFile = $this->getVersionFile($code);
|
||||
$versionInfo = Yaml::parseFile($versionFile);
|
||||
|
||||
if ($versionInfo) {
|
||||
uksort($versionInfo, function($a, $b){
|
||||
uksort($versionInfo, function ($a, $b) {
|
||||
return version_compare($a, $b);
|
||||
});
|
||||
}
|
||||
|
|
@ -257,7 +272,10 @@ class VersionManager
|
|||
}
|
||||
|
||||
if (!isset($this->databaseVersions[$code])) {
|
||||
$this->databaseVersions[$code] = Db::table('system_plugin_versions')->where('code', $code)->pluck('version');
|
||||
$this->databaseVersions[$code] = Db::table('system_plugin_versions')
|
||||
->where('code', $code)
|
||||
->pluck('version')
|
||||
;
|
||||
}
|
||||
|
||||
return (isset($this->databaseVersions[$code]))
|
||||
|
|
@ -278,14 +296,12 @@ class VersionManager
|
|||
'version' => $version,
|
||||
'created_at' => new Carbon
|
||||
]);
|
||||
}
|
||||
elseif ($version && $currentVersion){
|
||||
} elseif ($version && $currentVersion) {
|
||||
Db::table('system_plugin_versions')->where('code', $code)->update([
|
||||
'version' => $version,
|
||||
'created_at' => new Carbon
|
||||
]);
|
||||
}
|
||||
elseif ($currentVersion) {
|
||||
} elseif ($currentVersion) {
|
||||
Db::table('system_plugin_versions')->where('code', $code)->delete();
|
||||
}
|
||||
|
||||
|
|
@ -362,8 +378,9 @@ class VersionManager
|
|||
*/
|
||||
protected function getDatabaseHistory($code)
|
||||
{
|
||||
if ($this->databaseHistory !== null && array_key_exists($code, $this->databaseHistory))
|
||||
if ($this->databaseHistory !== null && array_key_exists($code, $this->databaseHistory)) {
|
||||
return $this->databaseHistory[$code];
|
||||
}
|
||||
|
||||
$historyInfo = Db::table('system_plugin_history')->where('code', $code)->get();
|
||||
return $this->databaseHistory[$code] = $historyInfo;
|
||||
|
|
@ -375,18 +392,22 @@ class VersionManager
|
|||
protected function hasDatabaseHistory($code, $version, $script = null)
|
||||
{
|
||||
$historyInfo = $this->getDatabaseHistory($code);
|
||||
if (!$historyInfo)
|
||||
if (!$historyInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($historyInfo as $history) {
|
||||
if ($history->version != $version)
|
||||
if ($history->version != $version) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($history->type == self::HISTORY_TYPE_COMMENT && !$script)
|
||||
if ($history->type == self::HISTORY_TYPE_COMMENT && !$script) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($history->type == self::HISTORY_TYPE_SCRIPT && $history->detail == $script)
|
||||
if ($history->type == self::HISTORY_TYPE_SCRIPT && $history->detail == $script) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -425,4 +446,4 @@ class VersionManager
|
|||
$this->notes = [];
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ class CacheClear extends ClearCommand
|
|||
$command = App::make('System\Console\CacheClear');
|
||||
$command->setLaravel(App::make('app'));
|
||||
$command->fire();
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
catch (\Exception $ex) {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,13 +33,15 @@ class OctoberDown extends Command
|
|||
*/
|
||||
public function fire()
|
||||
{
|
||||
if (!$this->confirmToProceed('This will DESTROY all database tables.'))
|
||||
if (!$this->confirmToProceed('This will DESTROY all database tables.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$manager = UpdateManager::instance()->resetNotes()->uninstall();
|
||||
|
||||
foreach ($manager->getNotes() as $note)
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +68,8 @@ class OctoberDown extends Command
|
|||
*/
|
||||
protected function getDefaultConfirmCallback()
|
||||
{
|
||||
return function() { return true; };
|
||||
return function () {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ class OctoberUp extends Command
|
|||
|
||||
$this->output->writeln('<info>Migrating application and plugins...</info>');
|
||||
|
||||
foreach ($manager->getNotes() as $note)
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,5 +55,4 @@ class OctoberUp extends Command
|
|||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,8 +65,7 @@ class OctoberUpdate extends Command
|
|||
if ($updates == 0) {
|
||||
$this->output->writeln('<info>No new updates found</info>');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
|
||||
}
|
||||
|
||||
|
|
@ -125,5 +124,4 @@ class OctoberUpdate extends Command
|
|||
['plugins', null, InputOption::VALUE_NONE, 'Update plugin files only.'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,11 +79,13 @@ class OctoberUtil extends Command
|
|||
|
||||
protected function utilPurgeThumbs()
|
||||
{
|
||||
if (!$uploadsDir = Config::get('cms.uploadsDir'))
|
||||
if (!$uploadsDir = Config::get('cms.uploadsDir')) {
|
||||
return $this->error('No uploads directory defined in config (cms.uploadsDir)');
|
||||
}
|
||||
|
||||
if (!$this->confirmToProceed('This will PERMANENTLY DELETE all thumbs in the uploads directory.'))
|
||||
if (!$this->confirmToProceed('This will PERMANENTLY DELETE all thumbs in the uploads directory.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$uploadsDir = base_path() . $uploadsDir;
|
||||
$totalCount = 0;
|
||||
|
|
@ -92,7 +94,7 @@ class OctoberUtil extends Command
|
|||
* Recursive function to scan the directory for files beginning
|
||||
* with "thumb_" and repeat itself on directories.
|
||||
*/
|
||||
$purgeFunc = function($targetDir) use (&$purgeFunc, &$totalCount) {
|
||||
$purgeFunc = function ($targetDir) use (&$purgeFunc, &$totalCount) {
|
||||
if ($files = File::glob($targetDir.'/thumb_*')) {
|
||||
foreach ($files as $file) {
|
||||
$this->info('Purged: '. basename($file));
|
||||
|
|
@ -110,10 +112,10 @@ class OctoberUtil extends Command
|
|||
|
||||
$purgeFunc($uploadsDir);
|
||||
|
||||
if ($totalCount > 0)
|
||||
if ($totalCount > 0) {
|
||||
$this->comment(sprintf('Successfully deleted %s thumbs', $totalCount));
|
||||
else
|
||||
} else {
|
||||
$this->comment('No thumbs found to delete');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,9 @@ class PluginInstall extends Command
|
|||
PluginManager::instance()->loadPlugins();
|
||||
$manager->updatePlugin($code);
|
||||
|
||||
foreach ($manager->getNotes() as $note)
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,5 +81,4 @@ class PluginInstall extends Command
|
|||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,15 +42,17 @@ class PluginRefresh extends Command
|
|||
$manager = UpdateManager::instance()->resetNotes();
|
||||
|
||||
$manager->rollbackPlugin($pluginName);
|
||||
foreach ($manager->getNotes() as $note)
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
|
||||
$manager->resetNotes();
|
||||
$this->output->writeln('<info>Reinstalling plugin...</info>');
|
||||
$manager->updatePlugin($pluginName);
|
||||
|
||||
foreach ($manager->getNotes() as $note)
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,5 +74,4 @@ class PluginRefresh extends Command
|
|||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,11 +43,13 @@ class PluginRemove extends Command
|
|||
$pluginName = $this->argument('name');
|
||||
$pluginName = $pluginManager->normalizeIdentifier($pluginName);
|
||||
|
||||
if (!$pluginManager->hasPlugin($pluginName))
|
||||
if (!$pluginManager->hasPlugin($pluginName)) {
|
||||
return $this->error(sprintf('Unable to find a registered plugin called "%s"', $pluginName));
|
||||
}
|
||||
|
||||
if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName)))
|
||||
if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rollback plugin
|
||||
|
|
@ -55,8 +57,9 @@ class PluginRemove extends Command
|
|||
$manager = UpdateManager::instance()->resetNotes();
|
||||
$manager->rollbackPlugin($pluginName);
|
||||
|
||||
foreach ($manager->getNotes() as $note)
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete from file system
|
||||
|
|
@ -95,7 +98,8 @@ class PluginRemove extends Command
|
|||
*/
|
||||
protected function getDefaultConfirmCallback()
|
||||
{
|
||||
return function() { return true; };
|
||||
return function () {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,5 +48,4 @@ class EventLogs extends Controller
|
|||
Flash::success(Lang::get('system::lang.event_log.empty_success'));
|
||||
return $this->listRefresh();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,5 +37,4 @@ class MailLayouts extends Controller
|
|||
BackendMenu::setContext('October.System', 'system', 'settings');
|
||||
SettingsManager::setContext('October.System', 'mail_templates');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,11 @@ class MailTemplates extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
/* @todo Remove line if year >= 2015 */ if (!\System\Models\MailLayout::whereCode('default')->count()) { \Eloquent::unguard(); with(new \System\Database\Seeds\SeedSetupMailLayouts)->run(); }
|
||||
/* @todo Remove lines if year >= 2015 */
|
||||
if (!\System\Models\MailLayout::whereCode('default')->count()) {
|
||||
\Eloquent::unguard();
|
||||
with(new \System\Database\Seeds\SeedSetupMailLayouts)->run();
|
||||
}
|
||||
|
||||
MailTemplate::syncAll();
|
||||
$this->asExtension('ListController')->index();
|
||||
|
|
@ -67,16 +71,14 @@ class MailTemplates extends Controller
|
|||
'email' => $user->email,
|
||||
'name' => $user->full_name,
|
||||
];
|
||||
Mail::send($model->code, [], function($message) use ($vars) {
|
||||
Mail::send($model->code, [], function ($message) use ($vars) {
|
||||
extract($vars);
|
||||
$message->to($email, $name);
|
||||
});
|
||||
|
||||
Flash::success('The test message has been successfully sent.');
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
Flash::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,5 +48,4 @@ class RequestLogs extends Controller
|
|||
Flash::success(Lang::get('system::lang.request_log.empty_success'));
|
||||
return $this->listRefresh();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,9 @@ class Settings extends Controller
|
|||
$this->vars['parentLabel'] = Lang::get('system::lang.settings.menu_label');
|
||||
|
||||
try {
|
||||
if (!$item = $this->findSettingItem($author, $plugin, $code))
|
||||
if (!$item = $this->findSettingItem($author, $plugin, $code)) {
|
||||
throw new ApplicationException(Lang::get('system::lang.settings.not_found'));
|
||||
}
|
||||
|
||||
$this->pageTitle = $item->label;
|
||||
|
||||
|
|
@ -74,8 +75,7 @@ class Settings extends Controller
|
|||
|
||||
$model = $this->createModel($item);
|
||||
$this->initWidgets($model);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->handleError($ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -111,8 +111,9 @@ class Settings extends Controller
|
|||
*/
|
||||
public function formRender($options = [])
|
||||
{
|
||||
if (!$this->formWidget)
|
||||
if (!$this->formWidget) {
|
||||
throw new ApplicationException(Lang::get('backend::lang.form.behavior_not_ready'));
|
||||
}
|
||||
|
||||
return $this->formWidget->render($options);
|
||||
}
|
||||
|
|
@ -138,9 +139,9 @@ class Settings extends Controller
|
|||
*/
|
||||
protected function createModel($item)
|
||||
{
|
||||
if (!isset($item->class) || !strlen($item->class))
|
||||
if (!isset($item->class) || !strlen($item->class)) {
|
||||
throw new ApplicationException(Lang::get('system::lang.settings.missing_model'));
|
||||
|
||||
}
|
||||
|
||||
$class = $item->class;
|
||||
$model = $class::instance();
|
||||
|
|
@ -166,5 +167,4 @@ class Settings extends Controller
|
|||
|
||||
return $item;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,17 +77,21 @@ class Updates extends Controller
|
|||
*/
|
||||
public function listInjectRowClass($record, $definition = null)
|
||||
{
|
||||
if ($record->disabledByConfig)
|
||||
if ($record->disabledByConfig) {
|
||||
return 'hidden';
|
||||
}
|
||||
|
||||
if ($record->orphaned || $record->is_disabled)
|
||||
if ($record->orphaned || $record->is_disabled) {
|
||||
return 'safe disabled';
|
||||
}
|
||||
|
||||
if ($definition != 'manage')
|
||||
if ($definition != 'manage') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($record->disabledBySystem)
|
||||
if ($record->disabledBySystem) {
|
||||
return 'negative';
|
||||
}
|
||||
|
||||
return 'positive';
|
||||
}
|
||||
|
|
@ -100,20 +104,25 @@ class Updates extends Controller
|
|||
/*
|
||||
* Address timeout limits
|
||||
*/
|
||||
if (!ini_get('safe_mode'))
|
||||
if (!ini_get('safe_mode')) {
|
||||
set_time_limit(3600);
|
||||
}
|
||||
|
||||
$manager = UpdateManager::instance();
|
||||
$stepCode = post('code');
|
||||
|
||||
switch ($stepCode) {
|
||||
case 'downloadCore':
|
||||
if ($this->disableCoreUpdates) return;
|
||||
if ($this->disableCoreUpdates) {
|
||||
return;
|
||||
}
|
||||
$manager->downloadCore(post('hash'));
|
||||
break;
|
||||
|
||||
case 'extractCore':
|
||||
if ($this->disableCoreUpdates) return;
|
||||
if ($this->disableCoreUpdates) {
|
||||
return;
|
||||
}
|
||||
$manager->extractCore(post('hash'), post('build'));
|
||||
break;
|
||||
|
||||
|
|
@ -170,8 +179,7 @@ class Updates extends Controller
|
|||
$this->vars['hasUpdates'] = array_get($result, 'update', false);
|
||||
$this->vars['pluginList'] = array_get($result, 'plugins', []);
|
||||
$this->vars['themeList'] = array_get($result, 'themes', []);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->handleError($ex);
|
||||
}
|
||||
|
||||
|
|
@ -217,8 +225,7 @@ class Updates extends Controller
|
|||
];
|
||||
|
||||
$this->vars['updateSteps'] = $updateSteps;
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->handleError($ex);
|
||||
}
|
||||
|
||||
|
|
@ -236,10 +243,14 @@ class Updates extends Controller
|
|||
$core = [$coreHash, $coreBuild];
|
||||
|
||||
$plugins = post('plugins', []);
|
||||
if (!is_array($plugins)) $plugins = [];
|
||||
if (!is_array($plugins)) {
|
||||
$plugins = [];
|
||||
}
|
||||
|
||||
$themes = post('themes', []);
|
||||
if (!is_array($themes)) $themes = [];
|
||||
if (!is_array($themes)) {
|
||||
$themes = [];
|
||||
}
|
||||
|
||||
/*
|
||||
* Update steps
|
||||
|
|
@ -255,8 +266,7 @@ class Updates extends Controller
|
|||
];
|
||||
|
||||
$this->vars['updateSteps'] = $updateSteps;
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->handleError($ex);
|
||||
}
|
||||
|
||||
|
|
@ -265,14 +275,17 @@ class Updates extends Controller
|
|||
|
||||
protected function buildUpdateSteps($core, $plugins, $themes)
|
||||
{
|
||||
if (!is_array($core))
|
||||
if (!is_array($core)) {
|
||||
$core = [null, null];
|
||||
}
|
||||
|
||||
if (!is_array($plugins))
|
||||
if (!is_array($plugins)) {
|
||||
$plugins = [];
|
||||
}
|
||||
|
||||
if (!is_array($themes))
|
||||
if (!is_array($themes)) {
|
||||
$themes = [];
|
||||
}
|
||||
|
||||
$updateSteps = [];
|
||||
list($coreHash, $coreBuild) = $core;
|
||||
|
|
@ -357,8 +370,9 @@ class Updates extends Controller
|
|||
public function onAttachProject()
|
||||
{
|
||||
try {
|
||||
if (!$projectId = post('project_id'))
|
||||
if (!$projectId = post('project_id')) {
|
||||
throw new ApplicationException(Lang::get('system::lang.project.id.missing'));
|
||||
}
|
||||
|
||||
$manager = UpdateManager::instance();
|
||||
$result = $manager->requestProjectDetails($projectId);
|
||||
|
|
@ -370,8 +384,7 @@ class Updates extends Controller
|
|||
]);
|
||||
|
||||
return $this->onForceUpdate();
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->handleError($ex);
|
||||
return $this->makePartial('project_form');
|
||||
}
|
||||
|
|
@ -399,14 +412,16 @@ class Updates extends Controller
|
|||
public function onInstallPlugin()
|
||||
{
|
||||
try {
|
||||
if (!$code = post('code'))
|
||||
if (!$code = post('code')) {
|
||||
throw new ApplicationException(Lang::get('system::lang.install.missing_plugin_name'));
|
||||
}
|
||||
|
||||
$manager = UpdateManager::instance();
|
||||
$result = $manager->requestPluginDetails($code);
|
||||
|
||||
if (!isset($result['code']) || !isset($result['hash']))
|
||||
if (!isset($result['code']) || !isset($result['hash'])) {
|
||||
throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
|
||||
}
|
||||
|
||||
$name = $result['code'];
|
||||
$hash = $result['hash'];
|
||||
|
|
@ -428,8 +443,7 @@ class Updates extends Controller
|
|||
$this->vars['updateSteps'] = $updateSteps;
|
||||
|
||||
return $this->makePartial('execute');
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->handleError($ex);
|
||||
return $this->makePartial('plugin_form');
|
||||
}
|
||||
|
|
@ -444,8 +458,9 @@ class Updates extends Controller
|
|||
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
|
||||
|
||||
foreach ($checkedIds as $objectId) {
|
||||
if (!$object = PluginVersion::find($objectId))
|
||||
if (!$object = PluginVersion::find($objectId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rollback plugin
|
||||
|
|
@ -478,8 +493,9 @@ class Updates extends Controller
|
|||
$manager = UpdateManager::instance();
|
||||
|
||||
foreach ($checkedIds as $objectId) {
|
||||
if (!$object = PluginVersion::find($objectId))
|
||||
if (!$object = PluginVersion::find($objectId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Refresh plugin
|
||||
|
|
@ -499,8 +515,7 @@ class Updates extends Controller
|
|||
{
|
||||
try {
|
||||
$this->vars['checked'] = post('checked');
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->handleError($ex);
|
||||
}
|
||||
return $this->makePartial('disable_form');
|
||||
|
|
@ -514,13 +529,15 @@ class Updates extends Controller
|
|||
$manager = PluginManager::instance();
|
||||
|
||||
foreach ($checkedIds as $objectId) {
|
||||
if (!$object = PluginVersion::find($objectId))
|
||||
if (!$object = PluginVersion::find($objectId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($disable)
|
||||
if ($disable) {
|
||||
$manager->disablePlugin($object->code, true);
|
||||
else
|
||||
} else {
|
||||
$manager->enablePlugin($object->code, true);
|
||||
}
|
||||
|
||||
$object->is_disabled = $disable;
|
||||
$object->save();
|
||||
|
|
@ -528,12 +545,12 @@ class Updates extends Controller
|
|||
|
||||
}
|
||||
|
||||
if ($disable)
|
||||
if ($disable) {
|
||||
Flash::success(Lang::get('system::lang.plugins.disable_success'));
|
||||
else
|
||||
} else {
|
||||
Flash::success(Lang::get('system::lang.plugins.enable_success'));
|
||||
}
|
||||
|
||||
return Redirect::to(Backend::url('system/updates/manage'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbDeferredBindings extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('deferred_bindings', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('deferred_bindings', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('master_type')->index();
|
||||
|
|
@ -26,5 +25,4 @@ class DbDeferredBindings extends Migration
|
|||
{
|
||||
Schema::dropIfExists('deferred_bindings');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbSystemFiles extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_files', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('system_files', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('disk_name');
|
||||
|
|
@ -31,5 +30,4 @@ class DbSystemFiles extends Migration
|
|||
{
|
||||
Schema::dropIfExists('system_files');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbSystemPluginVersions extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_plugin_versions', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('system_plugin_versions', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('code')->index();
|
||||
|
|
@ -22,5 +21,4 @@ class DbSystemPluginVersions extends Migration
|
|||
{
|
||||
Schema::dropIfExists('system_plugin_versions');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbSystemPluginHistory extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_plugin_history', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('system_plugin_history', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('code')->index();
|
||||
|
|
@ -24,5 +23,4 @@ class DbSystemPluginHistory extends Migration
|
|||
{
|
||||
Schema::dropIfExists('system_plugin_history');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class DbSystemSettings extends Migration
|
||||
class DbSystemSettings extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_settings', function($table)
|
||||
{
|
||||
Schema::create('system_settings', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('item')->nullable()->index();
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ class DbSystemParameters extends Migration
|
|||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_parameters', function($table)
|
||||
{
|
||||
Schema::create('system_parameters', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('namespace', 100);
|
||||
|
|
|
|||
|
|
@ -8,18 +8,15 @@ class DbSystemAddDisabledFlag extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::table('system_plugin_versions', function(Blueprint $table)
|
||||
{
|
||||
Schema::table('system_plugin_versions', function (Blueprint $table) {
|
||||
$table->boolean('is_disabled')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('system_plugin_versions', function($table)
|
||||
{
|
||||
Schema::table('system_plugin_versions', function (Blueprint $table) {
|
||||
$table->dropColumn('is_disabled');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbSystemMailTemplates extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_mail_templates', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('system_mail_templates', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('code')->nullable();
|
||||
|
|
@ -27,5 +26,4 @@ class DbSystemMailTemplates extends Migration
|
|||
{
|
||||
Schema::dropIfExists('system_mail_templates');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbSystemMailLayouts extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_mail_layouts', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('system_mail_layouts', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('name')->nullable();
|
||||
|
|
@ -26,5 +25,4 @@ class DbSystemMailLayouts extends Migration
|
|||
{
|
||||
Schema::dropIfExists('system_mail_layouts');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbCronQueue extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('cron_queue', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('cron_queue', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->integer('delay')->default(0);
|
||||
|
|
@ -24,5 +23,4 @@ class DbCronQueue extends Migration
|
|||
{
|
||||
Schema::dropIfExists('cron_queue');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbSystemEventLogs extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_event_logs', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('system_event_logs', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->string('level')->nullable()->index();
|
||||
|
|
@ -23,5 +22,4 @@ class DbSystemEventLogs extends Migration
|
|||
{
|
||||
Schema::dropIfExists('system_event_logs');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ class DbSystemRequestLogs extends Migration
|
|||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('system_request_logs', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('system_request_logs', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id');
|
||||
$table->integer('status_code')->nullable();
|
||||
|
|
@ -24,5 +23,4 @@ class DbSystemRequestLogs extends Migration
|
|||
{
|
||||
Schema::dropIfExists('system_request_logs');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ class DbSystemSessions extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sessions', function(Blueprint $table)
|
||||
{
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->text('payload')->nullable();
|
||||
$table->integer('last_activity')->nullable();
|
||||
|
|
@ -30,5 +29,4 @@ class DbSystemSessions extends Migration
|
|||
{
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,5 +17,4 @@ class DatabaseSeeder extends Seeder
|
|||
|
||||
$this->call('System\Database\Seeds\SeedSetupMailLayouts');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,5 +75,4 @@ This is an automatic message. Please do not reply to it.
|
|||
'content_text' => $text,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,4 +139,4 @@ return [
|
|||
'zip' => [
|
||||
'extract_failed' => "Konnte Core-Datei ':file' nicht entpacken.",
|
||||
],
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,97 +2,97 @@
|
|||
|
||||
return array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| such as the size rules. Feel free to tweak each of these messages.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| such as the size rules. Feel free to tweak each of these messages.
|
||||
|
|
||||
*/
|
||||
|
||||
"accepted" => ":attribute muss bestätigt werden.",
|
||||
"active_url" => ":attribute ist keine gültige URL.",
|
||||
"after" => ":attribute muss ein Datum nach :date sein.",
|
||||
"alpha" => ":attribute darf nur Buchstaben enthalten.",
|
||||
"alpha_dash" => ":attribute darf nur Buchstaben, Ziffern und Bindestriche enthalten.",
|
||||
"alpha_num" => ":attribute darf nur Buchstaben und Ziffern enthalten.",
|
||||
"array" => ":attribute muss ein Array sein.",
|
||||
"before" => ":attribute muss ein Datum vor :date sein.",
|
||||
"between" => array(
|
||||
"numeric" => ":attribute muss zwischen :min und :max liegen.",
|
||||
"file" => ":attribute muss zwischen :min und :max kilobytes groß sein.",
|
||||
"string" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.",
|
||||
"array" => ":attribute-Elementanzahl muss zwischen :min und :max liegen.",
|
||||
),
|
||||
"confirmed" => "Bestätigung zu :attribute stimmt nicht überein",
|
||||
"date" => ":attribute ist kein gültiges Datum.",
|
||||
"date_format" => ":attribute hat kein gültiges Datumsformat :format.",
|
||||
"different" => ":attribute und :other müssen sich unterscheiden.",
|
||||
"digits" => "Das :attribute benötigt :digits Zeichen.",
|
||||
"digits_between" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.",
|
||||
"email" => "Format von :attribute ist ungültig.",
|
||||
"exists" => "Das ausgewählte Attribut :attribute ist ungültig.",
|
||||
"image" => ":attribute muss ein Bild sein.",
|
||||
"in" => "Das ausgewählte Attribut :attribute ist ungültig.",
|
||||
"integer" => ":attribute muss eine Ganzzahl (integer) sein.",
|
||||
"ip" => ":attribute muss eine gültige IP-Adresse sein.",
|
||||
"max" => array(
|
||||
"numeric" => ":attribute darf nicht größer als :max sein.",
|
||||
"file" => ":attribute darf nicht größer als :max kilobytes sein.",
|
||||
"string" => "Dateiname von :attribute darf nicht mehr als :max Zeichen haben.",
|
||||
"array" => ":attribute darf nicht mehr als :max Elemente besitzen.",
|
||||
),
|
||||
"mimes" => ":attribute muss eine Datei des Typs: :values sein.",
|
||||
"min" => array(
|
||||
"numeric" => ":attribute muss mindestens :min sein.",
|
||||
"file" => ":attribute darf nicht kleiner als :min kilobytes sein.",
|
||||
"string" => "Dateiname von :attribute darf nicht weniger als :min Zeichen haben.",
|
||||
"array" => ":attribute darf nicht weniger als :min Elemente besitzen.",
|
||||
),
|
||||
"not_in" => "Das ausgewählte Attribut :attribute ist ungültig.",
|
||||
"numeric" => ":attribute muss eine Zahl sein.",
|
||||
"regex" => "Format von :attribute ist ungültig.",
|
||||
"required" => ":attribute wird benötigt.",
|
||||
"required_if" => ":attribute wird benötigt, wenn :other den Wert :value hat.",
|
||||
"required_with" => ":attribute wird benötigt, wenn :values existiert.",
|
||||
"required_without" => ":attribute wird benötigt, wenn :values nicht existiert.",
|
||||
"same" => ":attribute und :other müssen übereinstimmen.",
|
||||
"size" => array(
|
||||
"numeric" => ":attribute muss :size groß sein.",
|
||||
"file" => ":attribute muss :size kilobytes groß sein.",
|
||||
"string" => "Name von :attribute muss :size Zeichen beinhalten.",
|
||||
"array" => ":attribute muss :size Elemente beinhalten.",
|
||||
),
|
||||
"unique" => ":attribute muss eindeutig sein.",
|
||||
"url" => "Format von :attribute ist ungültig.",
|
||||
"accepted" => ":attribute muss bestätigt werden.",
|
||||
"active_url" => ":attribute ist keine gültige URL.",
|
||||
"after" => ":attribute muss ein Datum nach :date sein.",
|
||||
"alpha" => ":attribute darf nur Buchstaben enthalten.",
|
||||
"alpha_dash" => ":attribute darf nur Buchstaben, Ziffern und Bindestriche enthalten.",
|
||||
"alpha_num" => ":attribute darf nur Buchstaben und Ziffern enthalten.",
|
||||
"array" => ":attribute muss ein Array sein.",
|
||||
"before" => ":attribute muss ein Datum vor :date sein.",
|
||||
"between" => array(
|
||||
"numeric" => ":attribute muss zwischen :min und :max liegen.",
|
||||
"file" => ":attribute muss zwischen :min und :max kilobytes groß sein.",
|
||||
"string" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.",
|
||||
"array" => ":attribute-Elementanzahl muss zwischen :min und :max liegen.",
|
||||
),
|
||||
"confirmed" => "Bestätigung zu :attribute stimmt nicht überein",
|
||||
"date" => ":attribute ist kein gültiges Datum.",
|
||||
"date_format" => ":attribute hat kein gültiges Datumsformat :format.",
|
||||
"different" => ":attribute und :other müssen sich unterscheiden.",
|
||||
"digits" => "Das :attribute benötigt :digits Zeichen.",
|
||||
"digits_between" => ":attribute-Zeichenanzahl muss zwischen :min und :max liegen.",
|
||||
"email" => "Format von :attribute ist ungültig.",
|
||||
"exists" => "Das ausgewählte Attribut :attribute ist ungültig.",
|
||||
"image" => ":attribute muss ein Bild sein.",
|
||||
"in" => "Das ausgewählte Attribut :attribute ist ungültig.",
|
||||
"integer" => ":attribute muss eine Ganzzahl (integer) sein.",
|
||||
"ip" => ":attribute muss eine gültige IP-Adresse sein.",
|
||||
"max" => array(
|
||||
"numeric" => ":attribute darf nicht größer als :max sein.",
|
||||
"file" => ":attribute darf nicht größer als :max kilobytes sein.",
|
||||
"string" => "Dateiname von :attribute darf nicht mehr als :max Zeichen haben.",
|
||||
"array" => ":attribute darf nicht mehr als :max Elemente besitzen.",
|
||||
),
|
||||
"mimes" => ":attribute muss eine Datei des Typs: :values sein.",
|
||||
"min" => array(
|
||||
"numeric" => ":attribute muss mindestens :min sein.",
|
||||
"file" => ":attribute darf nicht kleiner als :min kilobytes sein.",
|
||||
"string" => "Dateiname von :attribute darf nicht weniger als :min Zeichen haben.",
|
||||
"array" => ":attribute darf nicht weniger als :min Elemente besitzen.",
|
||||
),
|
||||
"not_in" => "Das ausgewählte Attribut :attribute ist ungültig.",
|
||||
"numeric" => ":attribute muss eine Zahl sein.",
|
||||
"regex" => "Format von :attribute ist ungültig.",
|
||||
"required" => ":attribute wird benötigt.",
|
||||
"required_if" => ":attribute wird benötigt, wenn :other den Wert :value hat.",
|
||||
"required_with" => ":attribute wird benötigt, wenn :values existiert.",
|
||||
"required_without" => ":attribute wird benötigt, wenn :values nicht existiert.",
|
||||
"same" => ":attribute und :other müssen übereinstimmen.",
|
||||
"size" => array(
|
||||
"numeric" => ":attribute muss :size groß sein.",
|
||||
"file" => ":attribute muss :size kilobytes groß sein.",
|
||||
"string" => "Name von :attribute muss :size Zeichen beinhalten.",
|
||||
"array" => ":attribute muss :size Elemente beinhalten.",
|
||||
),
|
||||
"unique" => ":attribute muss eindeutig sein.",
|
||||
"url" => "Format von :attribute ist ungültig.",
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => array(),
|
||||
'custom' => array(),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap attribute place-holders
|
||||
| with something more reader friendly such as E-Mail Address instead
|
||||
| of "email". This simply helps us make messages a little cleaner.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap attribute place-holders
|
||||
| with something more reader friendly such as E-Mail Address instead
|
||||
| of "email". This simply helps us make messages a little cleaner.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => array(),
|
||||
'attributes' => array(),
|
||||
|
||||
);
|
||||
|
|
|
|||
|
|
@ -237,4 +237,4 @@ return [
|
|||
'manage_other_administrators' => 'Gestionar otros administradores',
|
||||
'view_the_dashboard' => 'Ver el Tablero'
|
||||
]
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -95,4 +95,4 @@ return array(
|
|||
|
||||
'attributes' => array(),
|
||||
|
||||
);
|
||||
);
|
||||
|
|
|
|||
|
|
@ -237,4 +237,4 @@ return [
|
|||
'manage_other_administrators' => 'Beheer mede-beheerders',
|
||||
'view_the_dashboard' => 'Bekijk het dashboard'
|
||||
]
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -139,4 +139,4 @@ return [
|
|||
'zip' => [
|
||||
'extract_failed' => "Kunde inte packa upp core-fil ':file'.",
|
||||
],
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -105,4 +105,4 @@ return array(
|
|||
|
||||
'attributes' => array(),
|
||||
|
||||
);
|
||||
);
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ class EventLog extends Model
|
|||
$record->message = $message;
|
||||
$record->level = $level;
|
||||
|
||||
if ($details !== null)
|
||||
if ($details !== null) {
|
||||
$record->details = (array) $details;
|
||||
}
|
||||
|
||||
$record->save();
|
||||
|
||||
|
|
@ -60,10 +61,10 @@ class EventLog extends Model
|
|||
*/
|
||||
public function getSummaryAttribute()
|
||||
{
|
||||
if (preg_match("/with message '(.+)' in/", $this->message, $match))
|
||||
if (preg_match("/with message '(.+)' in/", $this->message, $match)) {
|
||||
return $match[1];
|
||||
}
|
||||
|
||||
return Str::limit($this->message, 100);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@ class File extends FileBase
|
|||
public function getStorageDirectory()
|
||||
{
|
||||
$uploadsDir = Config::get('cms.uploadsDir');
|
||||
if ($this->isPublic())
|
||||
if ($this->isPublic()) {
|
||||
return base_path() . $uploadsDir . '/public/';
|
||||
else
|
||||
} else {
|
||||
return base_path() . $uploadsDir . '/protected/';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -39,9 +40,10 @@ class File extends FileBase
|
|||
public function getPublicDirectory()
|
||||
{
|
||||
$uploadsDir = Config::get('cms.uploadsDir');
|
||||
if ($this->isPublic())
|
||||
if ($this->isPublic()) {
|
||||
return Request::getBasePath() . $uploadsDir . '/public/';
|
||||
else
|
||||
} else {
|
||||
return Request::getBasePath() . $uploadsDir . '/protected/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class MailLayout extends Model
|
|||
|
||||
public function beforeDelete()
|
||||
{
|
||||
if ($this->is_locked)
|
||||
if ($this->is_locked) {
|
||||
throw new ApplicationException('Cannot delete this template because it is locked');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ class MailSettings extends Model
|
|||
if ($settings->smtp_authorization) {
|
||||
$config->set('mail.username', $settings->smtp_user);
|
||||
$config->set('mail.password', $settings->smtp_password);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$config->set('mail.username', null);
|
||||
$config->set('mail.password', null);
|
||||
}
|
||||
|
|
@ -78,4 +77,4 @@ class MailSettings extends Model
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,18 +55,21 @@ class MailTemplate extends Model
|
|||
* Clean up non-customized templates
|
||||
*/
|
||||
foreach ($dbTemplates as $code => $is_custom) {
|
||||
if ($is_custom)
|
||||
if ($is_custom) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!array_key_exists($code, $templates))
|
||||
if (!array_key_exists($code, $templates)) {
|
||||
self::whereCode($code)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create new templates
|
||||
*/
|
||||
if (count($newTemplates))
|
||||
if (count($newTemplates)) {
|
||||
$categories = MailLayout::lists('id', 'code');
|
||||
}
|
||||
|
||||
foreach ($newTemplates as $code => $description) {
|
||||
$sections = self::getTemplateSections($code);
|
||||
|
|
@ -99,13 +102,14 @@ class MailTemplate extends Model
|
|||
public static function addContentToMailer($message, $code, $data)
|
||||
{
|
||||
if (!isset(self::$cache[$code])) {
|
||||
if (!$template = self::whereCode($code)->first())
|
||||
if (!$template = self::whereCode($code)->first()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$cache[$code] = $template;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$template = self::$cache[$code];
|
||||
}
|
||||
|
||||
/*
|
||||
* Get Twig to load from a string
|
||||
|
|
@ -158,8 +162,9 @@ class MailTemplate extends Model
|
|||
$plugins = PluginManager::instance()->getPlugins();
|
||||
foreach ($plugins as $pluginId => $pluginObj) {
|
||||
$templates = $pluginObj->registerMailTemplates();
|
||||
if (!is_array($templates))
|
||||
if (!is_array($templates)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->registerMailTemplates($templates);
|
||||
}
|
||||
|
|
@ -171,8 +176,9 @@ class MailTemplate extends Model
|
|||
*/
|
||||
public function listRegisteredTemplates()
|
||||
{
|
||||
if (self::$registeredTemplates === null)
|
||||
if (self::$registeredTemplates === null) {
|
||||
$this->loadRegisteredTemplates();
|
||||
}
|
||||
|
||||
return self::$registeredTemplates;
|
||||
}
|
||||
|
|
@ -199,9 +205,10 @@ class MailTemplate extends Model
|
|||
*/
|
||||
public function registerMailTemplates(array $definitions)
|
||||
{
|
||||
if (!static::$registeredTemplates)
|
||||
if (!static::$registeredTemplates) {
|
||||
static::$registeredTemplates = [];
|
||||
}
|
||||
|
||||
static::$registeredTemplates = array_merge(static::$registeredTemplates, $definitions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,12 +36,14 @@ class Parameters extends Model
|
|||
*/
|
||||
public static function get($key, $default = null)
|
||||
{
|
||||
if (array_key_exists($key, static::$cache))
|
||||
if (array_key_exists($key, static::$cache)) {
|
||||
return static::$cache[$key];
|
||||
}
|
||||
|
||||
$record = static::findRecord($key)->first();
|
||||
if (!$record)
|
||||
if (!$record) {
|
||||
return static::$cache[$key] = $default;
|
||||
}
|
||||
|
||||
return static::$cache[$key] = $record->value;
|
||||
}
|
||||
|
|
@ -93,5 +95,4 @@ class Parameters extends Model
|
|||
|
||||
return $query;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,18 +56,18 @@ class PluginVersion extends Model
|
|||
$this->{$attribute} = Lang::get($info);
|
||||
}
|
||||
|
||||
if ($this->is_disabled)
|
||||
if ($this->is_disabled) {
|
||||
$manager->disablePlugin($this->code, true);
|
||||
else
|
||||
} else {
|
||||
$manager->enablePlugin($this->code, true);
|
||||
}
|
||||
|
||||
$this->disabledBySystem = $pluginObj->disabled;
|
||||
|
||||
if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
|
||||
$this->disabledByConfig = in_array($this->code, $configDisabled);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->name = $this->code;
|
||||
$this->description = Lang::get('system::lang.plugins.unknown_plugin');
|
||||
$this->orphaned = true;
|
||||
|
|
@ -90,5 +90,4 @@ class PluginVersion extends Model
|
|||
? self::$versionCache[$pluginCode]
|
||||
: null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,12 +47,10 @@ class RequestLog extends Model
|
|||
if (!$record->exists) {
|
||||
$record->count = 1;
|
||||
$record->save();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$record->increment('count');
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,4 @@ return [
|
|||
*/
|
||||
'Indatus\Dispatcher\ServiceProvider',
|
||||
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ class Status extends ReportWidgetBase
|
|||
{
|
||||
try {
|
||||
$this->loadData();
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
$this->vars['error'] = $ex->getMessage();
|
||||
}
|
||||
|
||||
|
|
@ -46,4 +45,4 @@ class Status extends ReportWidgetBase
|
|||
$manager = UpdateManager::instance();
|
||||
$this->vars['updates'] = $manager->check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* Register System routes before all user routes.
|
||||
*/
|
||||
App::before(function($request) {
|
||||
App::before(function ($request) {
|
||||
|
||||
/*
|
||||
* Combine JavaScript and StyleSheet assets
|
||||
|
|
|
|||
|
|
@ -35,22 +35,27 @@ trait AssetMaker
|
|||
*/
|
||||
public function makeAssets($type = null)
|
||||
{
|
||||
if ($type != null) $type = strtolower($type);
|
||||
if ($type != null) {
|
||||
$type = strtolower($type);
|
||||
}
|
||||
$result = null;
|
||||
$reserved = ['build'];
|
||||
$pathCache = [];
|
||||
|
||||
if ($type == null || $type == 'css'){
|
||||
if ($type == null || $type == 'css') {
|
||||
foreach ($this->assets['css'] as $asset) {
|
||||
|
||||
/*
|
||||
* Prevent duplicates
|
||||
*/
|
||||
$path = $this->getAssetEntryBuildPath($asset);
|
||||
if (isset($pathCache[$path])) continue;
|
||||
if (isset($pathCache[$path])) {
|
||||
continue;
|
||||
}
|
||||
$pathCache[$path] = true;
|
||||
|
||||
$attributes = HTML::attributes(array_merge([
|
||||
$attributes = HTML::attributes(array_merge(
|
||||
[
|
||||
'rel' => 'stylesheet',
|
||||
'href' => $path
|
||||
],
|
||||
|
|
@ -61,17 +66,20 @@ trait AssetMaker
|
|||
}
|
||||
}
|
||||
|
||||
if ($type == null || $type == 'rss'){
|
||||
if ($type == null || $type == 'rss') {
|
||||
foreach ($this->assets['rss'] as $asset) {
|
||||
|
||||
/*
|
||||
* Prevent duplicates
|
||||
*/
|
||||
$path = $this->getAssetEntryBuildPath($asset);
|
||||
if (isset($pathCache[$path])) continue;
|
||||
if (isset($pathCache[$path])) {
|
||||
continue;
|
||||
}
|
||||
$pathCache[$path] = true;
|
||||
|
||||
$attributes = HTML::attributes(array_merge([
|
||||
$attributes = HTML::attributes(array_merge(
|
||||
[
|
||||
'rel' => 'alternate',
|
||||
'href' => $path,
|
||||
'title' => 'RSS',
|
||||
|
|
@ -91,10 +99,13 @@ trait AssetMaker
|
|||
* Prevent duplicates
|
||||
*/
|
||||
$path = $this->getAssetEntryBuildPath($asset);
|
||||
if (isset($pathCache[$path])) continue;
|
||||
if (isset($pathCache[$path])) {
|
||||
continue;
|
||||
}
|
||||
$pathCache[$path] = true;
|
||||
|
||||
$attributes = HTML::attributes(array_merge([
|
||||
$attributes = HTML::attributes(array_merge(
|
||||
[
|
||||
'src' => $path
|
||||
],
|
||||
array_except($asset['attributes'], $reserved)
|
||||
|
|
@ -118,16 +129,19 @@ trait AssetMaker
|
|||
{
|
||||
$jsPath = $this->getAssetPath($name);
|
||||
|
||||
if (isset($this->controller))
|
||||
if (isset($this->controller)) {
|
||||
$this->controller->addJs($jsPath, $attributes);
|
||||
}
|
||||
|
||||
if (is_string($attributes))
|
||||
if (is_string($attributes)) {
|
||||
$attributes = ['build' => $attributes];
|
||||
}
|
||||
|
||||
$jsPath = $this->getAssetScheme($jsPath);
|
||||
|
||||
if (!in_array($jsPath, $this->assets['js']))
|
||||
if (!in_array($jsPath, $this->assets['js'])) {
|
||||
$this->assets['js'][] = ['path' => $jsPath, 'attributes' => $attributes];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -141,16 +155,19 @@ trait AssetMaker
|
|||
{
|
||||
$cssPath = $this->getAssetPath($name);
|
||||
|
||||
if (isset($this->controller))
|
||||
if (isset($this->controller)) {
|
||||
$this->controller->addCss($cssPath, $attributes);
|
||||
}
|
||||
|
||||
if (is_string($attributes))
|
||||
if (is_string($attributes)) {
|
||||
$attributes = ['build' => $attributes];
|
||||
}
|
||||
|
||||
$cssPath = $this->getAssetScheme($cssPath);
|
||||
|
||||
if (!in_array($cssPath, $this->assets['css']))
|
||||
if (!in_array($cssPath, $this->assets['css'])) {
|
||||
$this->assets['css'][] = ['path' => $cssPath, 'attributes' => $attributes];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -164,16 +181,19 @@ trait AssetMaker
|
|||
{
|
||||
$rssPath = $this->getAssetPath($name);
|
||||
|
||||
if (isset($this->controller))
|
||||
if (isset($this->controller)) {
|
||||
$this->controller->addRss($rssPath, $attributes);
|
||||
}
|
||||
|
||||
if (is_string($attributes))
|
||||
if (is_string($attributes)) {
|
||||
$attributes = ['build' => $attributes];
|
||||
}
|
||||
|
||||
$rssPath = $this->getAssetScheme($rssPath);
|
||||
|
||||
if (!in_array($rssPath, $this->assets['rss']))
|
||||
if (!in_array($rssPath, $this->assets['rss'])) {
|
||||
$this->assets['rss'][] = ['path' => $rssPath, 'attributes' => $attributes];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -202,22 +222,27 @@ trait AssetMaker
|
|||
*/
|
||||
public function getAssetPath($fileName, $assetPath = null)
|
||||
{
|
||||
if (preg_match("/(\/\/|http|https)/", $fileName))
|
||||
if (preg_match("/(\/\/|http|https)/", $fileName)) {
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
if (!$assetPath)
|
||||
if (!$assetPath) {
|
||||
$assetPath = $this->assetPath;
|
||||
}
|
||||
|
||||
if (substr($fileName, 0, 1) == '/' || $assetPath === null)
|
||||
if (substr($fileName, 0, 1) == '/' || $assetPath === null) {
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
if (!is_array($assetPath))
|
||||
if (!is_array($assetPath)) {
|
||||
$assetPath = [$assetPath];
|
||||
}
|
||||
|
||||
foreach ($assetPath as $path) {
|
||||
$_fileName = $path . '/' . $fileName;
|
||||
if (File::isFile(PATH_BASE . '/' . $_fileName))
|
||||
if (File::isFile(PATH_BASE . '/' . $_fileName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $_fileName;
|
||||
|
|
@ -243,10 +268,11 @@ trait AssetMaker
|
|||
if (isset($asset['attributes']['build'])) {
|
||||
$build = $asset['attributes']['build'];
|
||||
|
||||
if ($build == 'core')
|
||||
if ($build == 'core') {
|
||||
$build = 'v' . Parameters::get('system::core.build', 1);
|
||||
elseif ($pluginVersion = PluginVersion::getVersion($build))
|
||||
} elseif ($pluginVersion = PluginVersion::getVersion($build)) {
|
||||
$build = 'v' . $pluginVersion;
|
||||
}
|
||||
|
||||
$path .= '?' . $build;
|
||||
}
|
||||
|
|
@ -261,13 +287,14 @@ trait AssetMaker
|
|||
*/
|
||||
protected function getAssetScheme($asset)
|
||||
{
|
||||
if (preg_match("/(\/\/|http|https)/", $asset))
|
||||
if (preg_match("/(\/\/|http|https)/", $asset)) {
|
||||
return $asset;
|
||||
}
|
||||
|
||||
if (substr($asset, 0, 1) == '/')
|
||||
if (substr($asset, 0, 1) == '/') {
|
||||
$asset = Request::getBasePath() . $asset;
|
||||
}
|
||||
|
||||
return $asset;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,27 +33,28 @@ trait ConfigMaker
|
|||
*/
|
||||
if (is_object($configFile)) {
|
||||
$config = $configFile;
|
||||
}
|
||||
|
||||
/*
|
||||
* Embedded config
|
||||
*/
|
||||
elseif (is_array($configFile)) {
|
||||
} elseif (is_array($configFile)) {
|
||||
$config = $this->makeConfigFromArray($configFile);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
else
|
||||
} else {
|
||||
$configFile = $this->getConfigPath($configFile);
|
||||
}
|
||||
|
||||
if (!File::isFile($configFile))
|
||||
throw new SystemException(Lang::get('system::lang.config.not_found', ['file' => $configFile, 'location' => get_called_class()]));
|
||||
if (!File::isFile($configFile)) {
|
||||
throw new SystemException(Lang::get(
|
||||
'system::lang.config.not_found',
|
||||
['file' => $configFile, 'location' => get_called_class()]
|
||||
));
|
||||
}
|
||||
|
||||
$config = Yaml::parse(File::get($configFile));
|
||||
|
||||
|
|
@ -63,7 +64,9 @@ trait ConfigMaker
|
|||
$publicFile = File::localToPublic($configFile);
|
||||
if ($results = Event::fire('system.extendConfigFile', [$publicFile, $config])) {
|
||||
foreach ($results as $result) {
|
||||
if (!is_array($result)) continue;
|
||||
if (!is_array($result)) {
|
||||
continue;
|
||||
}
|
||||
$config = array_merge($config, $result);
|
||||
}
|
||||
}
|
||||
|
|
@ -75,8 +78,12 @@ trait ConfigMaker
|
|||
* Validate required configuration
|
||||
*/
|
||||
foreach ($requiredConfig as $property) {
|
||||
if (!property_exists($config, $property))
|
||||
throw new SystemException(Lang::get('system::lang.config.required', ['property' => $property, 'location' => get_called_class()]));
|
||||
if (!property_exists($config, $property)) {
|
||||
throw new SystemException(Lang::get(
|
||||
'system::lang.config.required',
|
||||
['property' => $property, 'location' => get_called_class()]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
|
@ -92,8 +99,9 @@ trait ConfigMaker
|
|||
{
|
||||
$object = new stdClass();
|
||||
|
||||
if (!is_array($configArray))
|
||||
if (!is_array($configArray)) {
|
||||
return $object;
|
||||
}
|
||||
|
||||
foreach ($configArray as $name => $value) {
|
||||
$_name = camel_case($name);
|
||||
|
|
@ -113,24 +121,29 @@ trait ConfigMaker
|
|||
*/
|
||||
public function getConfigPath($fileName, $configPath = null)
|
||||
{
|
||||
if (!isset($this->configPath))
|
||||
if (!isset($this->configPath)) {
|
||||
$this->configPath = $this->guessConfigPath();
|
||||
}
|
||||
|
||||
if (!$configPath)
|
||||
if (!$configPath) {
|
||||
$configPath = $this->configPath;
|
||||
}
|
||||
|
||||
$fileName = File::symbolizePath($fileName, $fileName);
|
||||
|
||||
if (File::isLocalPath($fileName) || realpath($fileName) !== false)
|
||||
if (File::isLocalPath($fileName) || realpath($fileName) !== false) {
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
if (!is_array($configPath))
|
||||
if (!is_array($configPath)) {
|
||||
$configPath = [$configPath];
|
||||
}
|
||||
|
||||
foreach ($configPath as $path) {
|
||||
$_fileName = $path . '/' . $fileName;
|
||||
if (File::isFile($_fileName))
|
||||
if (File::isFile($_fileName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $_fileName;
|
||||
|
|
@ -160,5 +173,4 @@ trait ConfigMaker
|
|||
$guessedPath = $classFile ? $classFile . '/' . $classFolder . $suffix : null;
|
||||
return $guessedPath;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,4 +96,4 @@ trait PropertyContainer
|
|||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,16 +49,18 @@ trait ViewMaker
|
|||
*/
|
||||
public function makePartial($partial, $params = [], $throwException = true)
|
||||
{
|
||||
if (!File::isPathSymbol($partial) && realpath($partial) === false)
|
||||
if (!File::isPathSymbol($partial) && realpath($partial) === false) {
|
||||
$partial = '_' . strtolower($partial) . '.htm';
|
||||
}
|
||||
|
||||
$partialPath = $this->getViewPath($partial);
|
||||
|
||||
if (!File::isFile($partialPath)) {
|
||||
if ($throwException)
|
||||
if ($throwException) {
|
||||
throw new SystemException(Lang::get('backend::lang.partial.not_found', ['name' => $partialPath]));
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->makeFileContents($partialPath, $params);
|
||||
|
|
@ -85,8 +87,9 @@ trait ViewMaker
|
|||
*/
|
||||
public function makeViewContent($contents, $layout = null)
|
||||
{
|
||||
if ($this->suppressLayout || $this->layout == '')
|
||||
if ($this->suppressLayout || $this->layout == '') {
|
||||
return $contents;
|
||||
}
|
||||
|
||||
// Append any undefined block content to the body block
|
||||
Block::set('undefinedBlock', $contents);
|
||||
|
|
@ -105,16 +108,18 @@ trait ViewMaker
|
|||
public function makeLayout($name = null, $params = [], $throwException = true)
|
||||
{
|
||||
$layout = ($name === null) ? $this->layout : $name;
|
||||
if ($layout == '')
|
||||
if ($layout == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$layoutPath = $this->getViewPath($layout . '.htm', $this->layoutPath);
|
||||
|
||||
if (!File::isFile($layoutPath)) {
|
||||
if ($throwException)
|
||||
if ($throwException) {
|
||||
throw new SystemException(Lang::get('cms::lang.layout.not_found', ['name' => $layoutPath]));
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->makeFileContents($layoutPath, $params);
|
||||
|
|
@ -128,8 +133,9 @@ trait ViewMaker
|
|||
*/
|
||||
public function makeLayoutPartial($partial, $params = [])
|
||||
{
|
||||
if (!File::isLocalPath($partial) && !File::isPathSymbol($partial))
|
||||
if (!File::isLocalPath($partial) && !File::isPathSymbol($partial)) {
|
||||
$partial = '_' . strtolower($partial);
|
||||
}
|
||||
|
||||
return $this->makeLayout($partial, $params);
|
||||
}
|
||||
|
|
@ -144,24 +150,29 @@ trait ViewMaker
|
|||
*/
|
||||
public function getViewPath($fileName, $viewPath = null)
|
||||
{
|
||||
if (!isset($this->viewPath))
|
||||
if (!isset($this->viewPath)) {
|
||||
$this->viewPath = $this->guessViewPath();
|
||||
}
|
||||
|
||||
if (!$viewPath)
|
||||
if (!$viewPath) {
|
||||
$viewPath = $this->viewPath;
|
||||
}
|
||||
|
||||
$fileName = File::symbolizePath($fileName, $fileName);
|
||||
|
||||
if (File::isLocalPath($fileName) || realpath($fileName) !== false)
|
||||
if (File::isLocalPath($fileName) || realpath($fileName) !== false) {
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
if (!is_array($viewPath))
|
||||
if (!is_array($viewPath)) {
|
||||
$viewPath = [$viewPath];
|
||||
}
|
||||
|
||||
foreach ($viewPath as $path) {
|
||||
$_fileName = $path . '/' . $fileName;
|
||||
if (File::isFile($_fileName))
|
||||
if (File::isFile($_fileName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $_fileName;
|
||||
|
|
@ -176,11 +187,13 @@ trait ViewMaker
|
|||
*/
|
||||
public function makeFileContents($filePath, $extraParams = [])
|
||||
{
|
||||
if (!strlen($filePath) || !File::isFile($filePath))
|
||||
if (!strlen($filePath) || !File::isFile($filePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_array($extraParams))
|
||||
if (!is_array($extraParams)) {
|
||||
$extraParams = [];
|
||||
}
|
||||
|
||||
$vars = array_merge($this->vars, $extraParams);
|
||||
|
||||
|
|
@ -216,4 +229,4 @@ trait ViewMaker
|
|||
$guessedPath = $classFile ? $classFile . '/' . $classFolder . $suffix : null;
|
||||
return ($isPublic) ? File::localToPublic($guessedPath) : $guessedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,5 +29,4 @@ class Engine implements EngineInterface
|
|||
$template = $this->environment->loadTemplate($path);
|
||||
return $template->render($vars);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,5 +102,4 @@ class Extension extends Twig_Extension
|
|||
{
|
||||
return URL::to($url);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,15 +32,18 @@ class Loader implements Twig_LoaderInterface
|
|||
{
|
||||
$finder = App::make('view')->getFinder();
|
||||
|
||||
if (isset($this->cache[$name]))
|
||||
if (isset($this->cache[$name])) {
|
||||
return $this->cache[$name];
|
||||
}
|
||||
|
||||
if (File::isFile($name))
|
||||
if (File::isFile($name)) {
|
||||
return $this->cache[$name] = $name;
|
||||
}
|
||||
|
||||
$view = $name;
|
||||
if (File::extension($view) == $this->extension)
|
||||
if (File::extension($view) == $this->extension) {
|
||||
$view = substr($view, 0, -strlen($this->extension));
|
||||
}
|
||||
|
||||
$path = $finder->find($view);
|
||||
return $this->cache[$name] = $path;
|
||||
|
|
@ -71,9 +74,8 @@ class Loader implements Twig_LoaderInterface
|
|||
try {
|
||||
$this->findTemplate($name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception $exception) {
|
||||
} catch (Exception $exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue