From 2cbaed9965a3d5277e41be1b66cd13303709414a Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Thu, 8 Feb 2018 23:10:12 +0100 Subject: [PATCH] * [MOD] Improved CSS & JS resources handling. * [MOD] Improved bootstrap workflow. Work in progress. --- .gitignore | 1 + .../config/strings.js.inc | 0 .../web/Controllers/AccountFileController.php | 18 +- .../web/Controllers/BootstrapController.php | 17 +- .../Helpers/Account/AccountHelper.php | 6 +- .../web/Controllers/Helpers/LayoutHelper.php | 22 +- .../web/Controllers/IndexController.php | 2 + .../web/Controllers/MainController.php | 8 +- .../web/Controllers/ResourceController.php | 129 ++++ .../web/Controllers/SimpleControllerBase.php | 56 +- .../web/Controllers/Traits/ItemTrait.php | 4 +- .../views/_partials/error-list.inc | 4 +- lib/Base.php | 2 +- lib/SP/Account/Account.php | 13 +- lib/SP/Account/AccountCrypt.php | 5 +- lib/SP/Account/AccountHistory.php | 4 +- lib/SP/Account/AccountHistoryCrypt.php | 5 +- lib/SP/Account/AccountUtil.php | 7 +- lib/SP/Api/ApiBase.php | 14 +- lib/SP/Api/ApiRequest.php | 14 +- lib/SP/Api/ApiUtil.php | 2 +- lib/SP/Api/SyspassApi.php | 12 +- lib/SP/Bootstrap.php | 627 +++++++++--------- lib/SP/Config/Config.php | 2 +- lib/SP/Config/ConfigUtil.php | 6 +- lib/SP/Controller/LoginController.php | 42 +- .../Core/Acl/AccountPermissionException.php | 2 +- lib/SP/Core/Acl/Acl.php | 77 ++- lib/SP/Core/Acl/UnauthorizedPageException.php | 2 +- lib/SP/Core/Backup.php | 18 +- lib/SP/Core/CryptPKI.php | 6 +- lib/SP/Core/Dic/Injector.php | 1 + lib/SP/Core/Events/EventDispatcherBase.php | 4 +- .../Exceptions/InitializationException.php | 35 + lib/SP/Core/Exceptions/SPException.php | 26 +- lib/SP/Core/Init.php | 8 +- lib/SP/Core/Installer.php | 71 +- lib/SP/Core/Language.php | 6 +- lib/SP/Core/OldCrypt.php | 9 +- lib/SP/Core/Plugin/PluginUtil.php | 4 +- lib/SP/Core/Session/Session.php | 20 + lib/SP/Core/Traits/InjectableTrait.php | 1 + lib/SP/Core/Upgrade/Crypt.php | 6 +- lib/SP/Core/Upgrade/Upgrade.php | 117 ++-- lib/SP/Core/XmlExport.php | 28 +- lib/SP/DataModel/TrackData.php | 2 +- lib/SP/Html/DataGrid/DataGridBase.php | 2 +- lib/SP/Html/Minify.php | 201 ++++-- lib/SP/Import/CsvImportBase.php | 4 +- lib/SP/Import/FileImport.php | 20 +- lib/SP/Import/Import.php | 8 +- lib/SP/Import/SyspassImport.php | 8 +- lib/SP/Import/XmlFileImport.php | 8 +- lib/SP/Import/XmlImportTrait.php | 6 +- lib/SP/Mgmt/ApiTokens/ApiToken.php | 6 +- lib/SP/Mgmt/Categories/Category.php | 6 +- lib/SP/Mgmt/CustomFields/CustomField.php | 4 +- lib/SP/Mgmt/CustomFields/CustomFieldDef.php | 6 +- lib/SP/Mgmt/CustomFields/CustomFieldsUtil.php | 8 +- lib/SP/Mgmt/Customers/Customer.php | 8 +- lib/SP/Mgmt/Files/File.php | 2 +- lib/SP/Mgmt/Groups/Group.php | 8 +- lib/SP/Mgmt/ItemBaseTrait.php | 4 +- lib/SP/Mgmt/Notices/Notice.php | 12 +- lib/SP/Mgmt/Plugins/Plugin.php | 2 +- lib/SP/Mgmt/Profiles/Profile.php | 10 +- lib/SP/Mgmt/PublicLinks/PublicLink.php | 10 +- lib/SP/Mgmt/Tags/Tag.php | 8 +- lib/SP/Mgmt/Users/User.php | 12 +- lib/SP/Mgmt/Users/UserLdap.php | 3 +- lib/SP/Mgmt/Users/UserMigrate.php | 6 +- lib/SP/Mgmt/Users/UserPass.php | 4 +- lib/SP/Mgmt/Users/UserPassRecover.php | 4 +- lib/SP/Mgmt/Users/UserSSO.php | 3 +- lib/SP/Mvc/View/Template.php | 8 +- lib/SP/Providers/Auth/Auth.php | 12 +- lib/SP/Providers/Auth/Database/Database.php | 12 +- lib/SP/Providers/Auth/Ldap/LdapBase.php | 14 +- lib/SP/Providers/Auth/Ldap/LdapMsAds.php | 3 +- lib/SP/Providers/Auth/Ldap/LdapStd.php | 3 +- .../Account/AccountFileRepository.php | 4 +- .../Account/AccountHistoryRepository.php | 3 +- .../Account/AccountRepository.php | 8 +- .../AuthToken/AuthTokenRepository.php | 4 +- .../Category/CategoryRepository.php | 4 +- .../Repositories/Client/ClientRepository.php | 5 +- .../CustomField/CustomFieldDefRepository.php | 2 +- .../CustomField/CustomFieldRepository.php | 4 +- lib/SP/Repositories/NoSuchItemException.php | 38 ++ .../Repositories/Plugin/PluginRepository.php | 2 +- .../PublicLink/PublicLinkRepository.php | 12 +- lib/SP/Repositories/Tag/TagRepository.php | 4 +- lib/SP/Repositories/User/UserRepository.php | 17 +- .../UserGroup/UserGroupRepository.php | 8 +- .../UserPassRecoverRepository.php | 4 +- .../UserProfile/UserProfileRepository.php | 8 +- lib/SP/Services/Account/AccountService.php | 6 +- lib/SP/Services/Auth/LoginService.php | 53 +- .../Services/AuthToken/AuthTokenService.php | 4 +- lib/SP/Services/Category/CategoryService.php | 2 +- lib/SP/Services/Client/ClientService.php | 2 +- lib/SP/Services/Config/ConfigService.php | 2 +- .../Services/PublicLink/PublicLinkService.php | 4 +- lib/SP/Services/Tag/TagService.php | 2 +- .../User/UpdatedMasterPassException.php | 2 +- lib/SP/Services/User/UserPassService.php | 6 +- lib/SP/Services/User/UserService.php | 1 + .../Services/UserGroup/UserGroupService.php | 2 +- .../UserProfile/UserProfileService.php | 2 +- lib/SP/Storage/DBUtil.php | 5 +- lib/SP/Storage/Database.php | 2 +- lib/SP/Storage/DbWrapper.php | 11 +- lib/SP/Storage/MySQLHandler.php | 6 +- lib/SP/Util/Checks.php | 10 +- lib/SP/Util/Connection.php | 6 +- lib/SP/Util/ErrorUtil.php | 4 +- lib/SP/Util/Json.php | 2 +- lib/SP/Util/Util.php | 4 +- lib/SP/Util/Wiki/DokuWikiApi.php | 7 +- lib/SP/Util/Wiki/DokuWikiApiBase.php | 10 +- public/css/css.php | 54 -- public/css/fonts.css | 8 +- public/css/fonts.min.css | 2 +- public/js/js.php | 72 -- schemas/dbstructure.sql | 2 +- 125 files changed, 1216 insertions(+), 1104 deletions(-) rename public/js/strings.js.php => app/config/strings.js.inc (100%) create mode 100644 app/modules/web/Controllers/ResourceController.php create mode 100644 lib/SP/Core/Exceptions/InitializationException.php create mode 100644 lib/SP/Repositories/NoSuchItemException.php delete mode 100644 public/css/css.php delete mode 100644 public/js/js.php diff --git a/.gitignore b/.gitignore index 49f253c6..52fa9d98 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,7 @@ app/cache/* app/backup/* app/config/* !app/config/actions.xml +!app/config/*.inc res/ tools/ app/temp/* diff --git a/public/js/strings.js.php b/app/config/strings.js.inc similarity index 100% rename from public/js/strings.js.php rename to app/config/strings.js.inc diff --git a/app/modules/web/Controllers/AccountFileController.php b/app/modules/web/Controllers/AccountFileController.php index 93408114..d2d17723 100644 --- a/app/modules/web/Controllers/AccountFileController.php +++ b/app/modules/web/Controllers/AccountFileController.php @@ -64,7 +64,7 @@ class AccountFileController extends ControllerBase implements CrudControllerInte { try { if (null === ($fileData = $this->accountFileService->getById($id))) { - throw new SPException(SPException::SP_INFO, __u('El archivo no existe')); + throw new SPException(__u('El archivo no existe'), SPException::INFO); } $this->view->addTemplate('file', 'itemshow'); @@ -104,7 +104,7 @@ class AccountFileController extends ControllerBase implements CrudControllerInte { try { if (null === ($fileData = $this->accountFileService->getById($id))) { - throw new SPException(SPException::SP_INFO, __u('El archivo no existe')); + throw new SPException(__u('El archivo no existe'), SPException::INFO); } // Enviamos el archivo al navegador @@ -135,13 +135,13 @@ class AccountFileController extends ControllerBase implements CrudControllerInte $file = $this->router->request()->files()->get('inFile'); if ($accountId === 0 || null === $file) { - throw new SPException(SPException::SP_ERROR, __u('CONSULTA INVÁLIDA')); + throw new SPException(__u('CONSULTA INVÁLIDA'), SPException::ERROR); } $allowedExts = $this->configData->getFilesAllowedExts(); if (count($allowedExts) === 0) { - throw new SPException(SPException::SP_ERROR, __u('No hay extensiones permitidas')); + throw new SPException(__u('No hay extensiones permitidas'), SPException::ERROR); } $fileData = new FileData(); @@ -155,27 +155,27 @@ class AccountFileController extends ControllerBase implements CrudControllerInte $fileData->setExtension(mb_strtoupper(pathinfo($fileData->getName(), PATHINFO_EXTENSION))); if (!in_array($fileData->getExtension(), $allowedExts, true)) { - throw new SPException(SPException::SP_ERROR, __u('Tipo de archivo no soportado'), sprintf(__('Extensión: %s'), $fileData->getExtension())); + throw new SPException(__u('Tipo de archivo no soportado'), SPException::ERROR, sprintf(__('Extensión: %s'), $fileData->getExtension())); } } else { - throw new SPException(SPException::SP_ERROR, __u('Archivo inválido'), sprintf(__u('Archivo: %s'), $fileData->getName())); + throw new SPException(__u('Archivo inválido'), SPException::ERROR, sprintf(__u('Archivo: %s'), $fileData->getName())); } if (!file_exists($file['tmp_name'])) { - throw new SPException(SPException::SP_ERROR, __u('Error interno al leer el archivo'), sprintf(__u('Máximo tamaño: %s'), Util::getMaxUpload())); + throw new SPException(__u('Error interno al leer el archivo'), SPException::ERROR, sprintf(__u('Máximo tamaño: %s'), Util::getMaxUpload())); } $allowedSize = $this->configData->getFilesAllowedSize(); if ($fileData->getSize() > ($allowedSize * 1000)) { - throw new SPException(SPException::SP_ERROR, __u('Tamaño de archivo superado'), sprintf(__u('Máximo tamaño: %d KB'), $fileData->getRoundSize())); + throw new SPException(__u('Tamaño de archivo superado'), SPException::ERROR, sprintf(__u('Máximo tamaño: %d KB'), $fileData->getRoundSize())); } // Leemos el archivo a una variable $fileData->setContent(file_get_contents($file['tmp_name'])); if ($fileData->getContent() === false) { - throw new SPException(SPException::SP_ERROR, __u('Error interno al leer el archivo')); + throw new SPException(__u('Error interno al leer el archivo'), SPException::ERROR); } $this->accountFileService->create($fileData); diff --git a/app/modules/web/Controllers/BootstrapController.php b/app/modules/web/Controllers/BootstrapController.php index 0a236577..be782042 100644 --- a/app/modules/web/Controllers/BootstrapController.php +++ b/app/modules/web/Controllers/BootstrapController.php @@ -24,11 +24,9 @@ namespace SP\Modules\Web\Controllers; -use Exception; use SP\Bootstrap; use SP\Core\CryptPKI; use SP\Core\Plugin\PluginUtil; -use SP\Core\SessionFactory; use SP\Http\Cookies; use SP\Http\Response; use SP\Providers\Auth\Browser\Browser; @@ -42,16 +40,18 @@ class BootstrapController extends SimpleControllerBase { /** * Returns environment data + * + * @throws \SP\Core\Exceptions\FileNotFoundException + * @throws \SP\Core\Exceptions\SPException */ public function getEnvironmentAction() { $configData = $this->config->getConfigData(); $data = [ - 'lang' => require PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'strings.js.php', + 'lang' => require CONFIG_PATH . DIRECTORY_SEPARATOR . 'strings.js.inc', 'locale' => $configData->getSiteLang(), 'app_root' => Bootstrap::$WEBURI, - 'pk' => '', 'max_file_size' => $configData->getFilesAllowedSize(), 'check_updates' => $this->session->getAuthCompleted() && ($configData->isCheckUpdates() || $configData->isChecknotices()) @@ -61,15 +61,10 @@ class BootstrapController extends SimpleControllerBase 'cookies_enabled' => Cookies::checkCookies(), 'plugins' => PluginUtil::getEnabledPlugins(), 'loggedin' => $this->session->isLoggedIn(), - 'authbasic_autologin' => Browser::getServerAuthUser() && $configData->isAuthBasicAutoLoginEnabled() + 'authbasic_autologin' => Browser::getServerAuthUser() && $configData->isAuthBasicAutoLoginEnabled(), + 'pk' => $this->session->getPublicKey() ?: (new CryptPKI())->getPublicKey() ]; - try { - $CryptPKI = new CryptPKI(); - $data['pk'] = SessionFactory::getPublicKey() ?: $CryptPKI->getPublicKey(); - } catch (Exception $e) { - } - Response::printJson($data, 0); } } \ No newline at end of file diff --git a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php index 1d56162e..427e9487 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php @@ -174,11 +174,11 @@ class AccountHelper extends HelperBase public function checkActionAccess() { if (!$this->acl->checkUserAccess($this->actionId)) { - throw new UnauthorizedPageException(SPException::SP_INFO); + throw new UnauthorizedPageException(SPException::INFO); } if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getId())) { - throw new UpdatedMasterPassException(SPException::SP_INFO); + throw new UpdatedMasterPassException(SPException::INFO); } } @@ -204,7 +204,7 @@ class AccountHelper extends HelperBase $accountAcl = $this->accountAcl->getAcl($acccountAclDto); if ($accountAcl === null || !$accountAcl->checkAccountAccess()) { - throw new AccountPermissionException(SPException::SP_INFO); + throw new AccountPermissionException(SPException::INFO); } return $accountAcl; diff --git a/app/modules/web/Controllers/Helpers/LayoutHelper.php b/app/modules/web/Controllers/Helpers/LayoutHelper.php index 2349804d..3dcac9fd 100644 --- a/app/modules/web/Controllers/Helpers/LayoutHelper.php +++ b/app/modules/web/Controllers/Helpers/LayoutHelper.php @@ -137,9 +137,10 @@ class LayoutHelper extends HelperBase { $version = Util::getVersionStringNormalized(); + $jsUri = Bootstrap::$WEBURI . '/index.php?r=resource/js'; $jsVersionHash = md5($version); - $this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?v=' . $jsVersionHash); - $this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?g=1&v=' . $jsVersionHash); + $this->view->append('jsLinks', $jsUri . '&v=' . $jsVersionHash); + $this->view->append('jsLinks', $jsUri . '&g=1&v=' . $jsVersionHash); $themeInfo = $this->theme->getThemeInfo(); @@ -147,7 +148,7 @@ class LayoutHelper extends HelperBase $themeJsBase = urlencode($this->theme->getThemePath() . DIRECTORY_SEPARATOR . 'js'); $themeJsFiles = urlencode(implode(',', $themeInfo['js'])); - $this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash); + $this->view->append('jsLinks', $jsUri . '&f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash); } $userPreferences = $this->session->getUserData()->getPreferences(); @@ -158,15 +159,12 @@ class LayoutHelper extends HelperBase $resultsAsCards = $this->configData->isResultsAsCards(); } + $cssUri = Bootstrap::$WEBURI . '/index.php?r=resource/css'; $cssVersionHash = md5($version . $resultsAsCards); - $this->view->append('cssLinks', Bootstrap::$WEBROOT . '/public/css/css.php?v=' . $cssVersionHash); + $this->view->append('cssLinks', $cssUri . '&v=' . $cssVersionHash); if (isset($themeInfo['css'])) { - if ($resultsAsCards) { - $themeInfo['css'][] = 'search-card.min.css'; - } else { - $themeInfo['css'][] = 'search-grid.min.css'; - } + $themeInfo['css'][] = $resultsAsCards ? 'search-card.min.css' : 'search-grid.min.css'; if ($this->configData->isDokuwikiEnabled()) { $themeInfo['css'][] = 'styles-wiki.min.css'; @@ -175,7 +173,7 @@ class LayoutHelper extends HelperBase $themeCssBase = urlencode($this->theme->getThemePath() . DIRECTORY_SEPARATOR . 'css'); $themeCssFiles = urlencode(implode(',', $themeInfo['css'])); - $this->view->append('cssLinks', Bootstrap::$WEBROOT . '/public/css/css.php?f=' . $themeCssFiles . '&b=' . $themeCssBase . '&v=' . $jsVersionHash); + $this->view->append('cssLinks', $cssUri . '&f=' . $themeCssFiles . '&b=' . $themeCssBase . '&v=' . $jsVersionHash); } // Cargar los recursos de los plugins @@ -185,11 +183,11 @@ class LayoutHelper extends HelperBase $cssResources = $Plugin->getCssResources(); if (count($jsResources) > 0) { - $this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?f=' . urlencode(implode(',', $jsResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'js') . '&v=' . $jsVersionHash); + $this->view->append('jsLinks', $jsUri . '&f=' . urlencode(implode(',', $jsResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'js') . '&v=' . $jsVersionHash); } if (count($cssResources) > 0) { - $this->view->append('cssLinks', Bootstrap::$WEBROOT . '/public/css/css.php?f=' . urlencode(implode(',', $cssResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'css') . '&v=' . $jsVersionHash); + $this->view->append('cssLinks', $cssUri . '&f=' . urlencode(implode(',', $cssResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'css') . '&v=' . $jsVersionHash); } } } diff --git a/app/modules/web/Controllers/IndexController.php b/app/modules/web/Controllers/IndexController.php index cfe8ed0f..69a7379a 100644 --- a/app/modules/web/Controllers/IndexController.php +++ b/app/modules/web/Controllers/IndexController.php @@ -38,6 +38,8 @@ class IndexController extends ControllerBase { /** * Index action + * + * @throws \SP\Core\Dic\ContainerException */ public function indexAction() { diff --git a/app/modules/web/Controllers/MainController.php b/app/modules/web/Controllers/MainController.php index 0c740a31..dd03b78e 100644 --- a/app/modules/web/Controllers/MainController.php +++ b/app/modules/web/Controllers/MainController.php @@ -387,7 +387,7 @@ class MainController extends ControllerBase implements ActionsInterface if (!Checks::checkPhpVersion()) { $errors[] = [ - 'type' => SPException::SP_CRITICAL, + 'type' => SPException::CRITICAL, 'description' => __('Versión de PHP requerida >= ') . ' 5.6.0 <= 7.0', 'hint' => __('Actualice la versión de PHP para que la aplicación funcione correctamente') ]; @@ -398,7 +398,7 @@ class MainController extends ControllerBase implements ActionsInterface if (count($modules) > 0) { foreach ($modules as $module) { $error[] = [ - 'type' => SPException::SP_WARNING, + 'type' => SPException::WARNING, 'description' => sprintf('%s (%s)', __('Módulo no disponible'), $module), 'hint' => __('Sin este módulo la aplicación puede no funcionar correctamente.') ]; @@ -407,14 +407,14 @@ class MainController extends ControllerBase implements ActionsInterface if (@file_exists(__FILE__ . "\0Nullbyte")) { $errors[] = [ - 'type' => SPException::SP_WARNING, + 'type' => SPException::WARNING, 'description' => __('La version de PHP es vulnerable al ataque NULL Byte (CVE-2006-7243)'), 'hint' => __('Actualice la versión de PHP para usar sysPass de forma segura')]; } if (!Checks::secureRNGIsAvailable()) { $errors[] = [ - 'type' => SPException::SP_WARNING, + 'type' => SPException::WARNING, 'description' => __('No se encuentra el generador de números aleatorios.'), 'hint' => __('Sin esta función un atacante puede utilizar su cuenta al resetear la clave')]; } diff --git a/app/modules/web/Controllers/ResourceController.php b/app/modules/web/Controllers/ResourceController.php new file mode 100644 index 00000000..a4efc2c2 --- /dev/null +++ b/app/modules/web/Controllers/ResourceController.php @@ -0,0 +1,129 @@ +. + */ + +namespace SP\Modules\Web\Controllers; + +use SP\Html\Minify; +use SP\Http\Request; + +/** + * Class ResourceController + * + * @package SP\Modules\Web\Controllers + */ +class ResourceController extends SimpleControllerBase +{ + /** + * @var Minify + */ + protected $minify; + + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + * @throws \ReflectionException + * @throws \SP\Core\Dic\ContainerException + */ + public function cssAction() + { + $file = Request::analyze('f'); + $base = Request::analyze('b'); + + $minify = new Minify(); + + if ($file && $base) { + $minify->setType(Minify::FILETYPE_CSS) + ->setBase(urldecode($base), true) + ->addFilesFromString(urldecode($file)) + ->getMinified(); + } else { + $minify->setType(Minify::FILETYPE_CSS) + ->setBase(PUBLIC_PATH . DIRECTORY_SEPARATOR . 'css') + ->addFiles(['reset.min.css', + 'jquery-ui.min.css', + 'jquery-ui.structure.min.css', + 'jquery.tagsinput.min.css', + 'fonts.min.css', + 'material-icons.min.css', + 'toastr.min.css', + 'magnific-popup.min.css' + ], false) + ->getMinified(); + } + } + + /** + * @throws \Psr\Container\ContainerExceptionInterface + * @throws \Psr\Container\NotFoundExceptionInterface + * @throws \ReflectionException + * @throws \SP\Core\Dic\ContainerException + */ + public function jsAction() + { + $file = Request::analyze('f'); + $base = Request::analyze('b'); + + $minify = new Minify(); + + if ($file && $base) { + $minify->setType(Minify::FILETYPE_JS) + ->setBase(urldecode($base), true) + ->addFilesFromString(urldecode($file)) + ->getMinified(); + } else { + $minify->setType(Minify::FILETYPE_JS) + ->setBase(PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js'); + + $group = Request::analyze('g', 0); + + if ($group === 0) { + $minify->addFiles([ + 'jquery-3.2.0.min.js', + 'jquery-migrate-3.0.0.min.js', + 'jquery.fileDownload.min.js', + 'clipboard.min.js', + 'selectize.min.js', + 'selectize-plugins.min.js', + 'zxcvbn-async.min.js', + 'jsencrypt.min.js', + 'spark-md5.min.js', + 'moment.min.js', + 'moment-timezone.min.js', + 'toastr.min.js', + 'jquery.magnific-popup.min.js', + 'eventsource.min.js'], false); + } elseif ($group === 1) { + // FIXME: use MIN version + $minify->addFiles([ + 'app.js', + 'app-triggers.js', + 'app-actions.js', + 'app-requests.js', + 'app-main.js'], false); + } + + $minify->getMinified(); + } + } +} \ No newline at end of file diff --git a/app/modules/web/Controllers/SimpleControllerBase.php b/app/modules/web/Controllers/SimpleControllerBase.php index 379951ab..776586d8 100644 --- a/app/modules/web/Controllers/SimpleControllerBase.php +++ b/app/modules/web/Controllers/SimpleControllerBase.php @@ -24,13 +24,12 @@ namespace SP\Modules\Web\Controllers; +use Klein\Klein; use SP\Config\Config; -use SP\Core\Acl\Acl; use SP\Core\Events\EventDispatcher; use SP\Core\Session\Session; use SP\Core\Traits\InjectableTrait; use SP\Core\UI\Theme; -use SP\Storage\Database; /** * Class SimpleControllerBase @@ -41,32 +40,53 @@ abstract class SimpleControllerBase { use InjectableTrait; - /** @var int Módulo a usar */ + /** + * @var int Módulo a usar + */ protected $action; - /** @var string Nombre del controlador */ + /** + * @var string Nombre del controlador + */ protected $controllerName; - /** @var EventDispatcher */ + /** + * @var EventDispatcher + */ protected $eventDispatcher; - /** @var Config */ + /** + * @var Config + */ protected $config; - /** @var Session */ + /** + * @var Session + */ protected $session; - /** @var Database */ - protected $db; - /** @var Theme */ + /** + * @var Theme + */ protected $theme; - /** @var \SP\Core\Acl\Acl */ - protected $acl; + /** + * @var string + */ + protected $actionName; + /** + * @var Klein + */ + protected $router; /** - * Constructor + * SimpleControllerBase constructor. + * + * @param $actionName + * @throws \ReflectionException + * @throws \SP\Core\Dic\ContainerException */ - public function __construct() + public function __construct($actionName) { $this->injectDependencies(); $class = static::class; $this->controllerName = substr($class, strrpos($class, '\\') + 1, -strlen('Controller')); + $this->actionName = $actionName; if (method_exists($this, 'initialize')) { $this->initialize(); @@ -76,18 +96,16 @@ abstract class SimpleControllerBase /** * @param Config $config * @param Session $session - * @param Database $db * @param Theme $theme * @param EventDispatcher $ev - * @param Acl $acl + * @param Klein $router */ - public function inject(Config $config, Session $session, Database $db, Theme $theme, EventDispatcher $ev, Acl $acl) + public function inject(Config $config, Session $session, Theme $theme, EventDispatcher $ev, Klein $router) { $this->config = $config; $this->session = $session; - $this->db = $db; $this->theme = $theme; $this->eventDispatcher = $ev; - $this->acl = $acl; + $this->router = $router; } } \ No newline at end of file diff --git a/app/modules/web/Controllers/Traits/ItemTrait.php b/app/modules/web/Controllers/Traits/ItemTrait.php index 270105b4..8c04816e 100644 --- a/app/modules/web/Controllers/Traits/ItemTrait.php +++ b/app/modules/web/Controllers/Traits/ItemTrait.php @@ -101,7 +101,7 @@ trait ItemTrait $customFieldService->create($customFieldData); } } catch (CryptoException $e) { - throw new SPException(SPException::SP_ERROR, __u('Error interno')); + throw new SPException(__u('Error interno'), SPException::ERROR); } } } @@ -144,7 +144,7 @@ trait ItemTrait $customFieldService->update($customFieldData); } } catch (CryptoException $e) { - throw new SPException(SPException::SP_ERROR, __u('Error interno')); + throw new SPException(__u('Error interno'), SPException::ERROR); } } } diff --git a/app/modules/web/themes/material-blue/views/_partials/error-list.inc b/app/modules/web/themes/material-blue/views/_partials/error-list.inc index 501979bf..7f350956 100644 --- a/app/modules/web/themes/material-blue/views/_partials/error-list.inc +++ b/app/modules/web/themes/material-blue/views/_partials/error-list.inc @@ -7,7 +7,7 @@