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