diff --git a/.travis.yml b/.travis.yml index 8881edd4..74c2d9ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ language: php sudo: false php: - - '7.0' - - '7.1' -# - '7.2' +- '7.0' +- '7.1' +- '7.2' branches: only: @@ -15,27 +15,28 @@ addons: mariadb: '10.1' before_script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter && ./cc-test-reporter before-build - - composer self-update - - composer install --prefer-source --no-interaction --dev +- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter +- chmod +x ./cc-test-reporter && ./cc-test-reporter before-build +- composer self-update +- composer install --prefer-source --no-interaction --dev script: ./vendor/bin/phpunit -c ./tests/phpunit.xml --testsuite Core after_script: - - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then mv ./tests/_output/coverage-clover.xml clover.xml && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -t clover; fi +- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then mv ./tests/_output/coverage-clover.xml clover.xml && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -t clover; fi notifications: + email: nuxsmin@syspass.org on_success: never on_failure: always env: - - DB_SERVER=127.0.0.1 DB_NAME=syspass DB_USER=root DB_PASS= +- DB_SERVER=127.0.0.1 DB_NAME=syspass DB_USER=root DB_PASS= before_install: - - mysql -e 'DROP DATABASE IF EXISTS `'"$DB_NAME"'`;' - - mysql -e 'CREATE DATABASE `'"$DB_NAME"'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;' - - mysql $DB_NAME < ./schemas/dbstructure.sql +- mysql -e 'DROP DATABASE IF EXISTS `'"$DB_NAME"'`;' +- mysql -e 'CREATE DATABASE `'"$DB_NAME"'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;' +- mysql $DB_NAME < ./schemas/dbstructure.sql cache: directories: diff --git a/app/modules/api/Controllers/Help/AccountHelp.php b/app/modules/api/Controllers/Help/AccountHelp.php index a66eb41d..e4907bed 100644 --- a/app/modules/api/Controllers/Help/AccountHelp.php +++ b/app/modules/api/Controllers/Help/AccountHelp.php @@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help; * * @package SP\Modules\Api\Controllers\Help */ -class AccountHelp implements HelpInterface +final class AccountHelp implements HelpInterface { use HelpTrait; diff --git a/app/modules/api/Controllers/Help/CategoryHelp.php b/app/modules/api/Controllers/Help/CategoryHelp.php index 2c7f5412..82f44a33 100644 --- a/app/modules/api/Controllers/Help/CategoryHelp.php +++ b/app/modules/api/Controllers/Help/CategoryHelp.php @@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help; * * @package SP\Modules\Api\Controllers\Help */ -class CategoryHelp implements HelpInterface +final class CategoryHelp implements HelpInterface { use HelpTrait; diff --git a/app/modules/api/Controllers/Help/ClientHelp.php b/app/modules/api/Controllers/Help/ClientHelp.php index 4c3cec04..688719b3 100644 --- a/app/modules/api/Controllers/Help/ClientHelp.php +++ b/app/modules/api/Controllers/Help/ClientHelp.php @@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help; * * @package SP\Modules\Api\Controllers\Help */ -class ClientHelp implements HelpInterface +final class ClientHelp implements HelpInterface { use HelpTrait; diff --git a/app/modules/api/Controllers/Help/ConfigHelp.php b/app/modules/api/Controllers/Help/ConfigHelp.php index 75155eb7..491e20fd 100644 --- a/app/modules/api/Controllers/Help/ConfigHelp.php +++ b/app/modules/api/Controllers/Help/ConfigHelp.php @@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help; * * @package SP\Modules\Api\Controllers\Help */ -class ConfigHelp implements HelpInterface +final class ConfigHelp implements HelpInterface { use HelpTrait; diff --git a/app/modules/api/Controllers/Help/TagHelp.php b/app/modules/api/Controllers/Help/TagHelp.php index c9af3083..6c464362 100644 --- a/app/modules/api/Controllers/Help/TagHelp.php +++ b/app/modules/api/Controllers/Help/TagHelp.php @@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help; * * @package SP\Modules\Api\Controllers\Help */ -class TagHelp implements HelpInterface +final class TagHelp implements HelpInterface { use HelpTrait; diff --git a/app/modules/web/Controllers/ConfigManagerController.php b/app/modules/web/Controllers/ConfigManagerController.php index 4f499ba0..2a8433ed 100644 --- a/app/modules/web/Controllers/ConfigManagerController.php +++ b/app/modules/web/Controllers/ConfigManagerController.php @@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers; use SP\Bootstrap; use SP\Core\Acl\Acl; +use SP\Core\AppInfoInterface; use SP\Core\Crypt\CryptSessionHandler; use SP\Core\Events\Event; use SP\Core\Language; @@ -44,7 +45,6 @@ use SP\Services\UserGroup\UserGroupService; use SP\Services\UserProfile\UserProfileService; use SP\Storage\Database\DatabaseUtil; use SP\Storage\Database\DBStorageInterface; -use SP\Util\Util; /** * Class ConfigManagerController @@ -279,7 +279,7 @@ final class ConfigManagerController extends ControllerBase $template->addTemplate('backup'); $template->assign('pharIsAvailable', $this->extensionChecker->checkPharAvailable()); - $template->assign('siteName', Util::getAppInfo('appname')); + $template->assign('siteName', AppInfoInterface::APP_NAME); $template->assign('backupDir', BACKUP_PATH); $template->assign('backupPath', Bootstrap::$WEBROOT . '/backup'); diff --git a/app/modules/web/Controllers/Helpers/ItemPresetHelper.php b/app/modules/web/Controllers/Helpers/ItemPresetHelper.php index 30f1f3de..e9dfe520 100644 --- a/app/modules/web/Controllers/Helpers/ItemPresetHelper.php +++ b/app/modules/web/Controllers/Helpers/ItemPresetHelper.php @@ -38,7 +38,7 @@ use SP\Services\UserGroup\UserGroupService; * * @package SP\Modules\Web\Controllers\Helpers */ -class ItemPresetHelper extends HelperBase +final class ItemPresetHelper extends HelperBase { /** * @var SelectItemAdapter diff --git a/app/modules/web/Controllers/Helpers/LayoutHelper.php b/app/modules/web/Controllers/Helpers/LayoutHelper.php index cec2174b..86b5bd02 100644 --- a/app/modules/web/Controllers/Helpers/LayoutHelper.php +++ b/app/modules/web/Controllers/Helpers/LayoutHelper.php @@ -27,6 +27,7 @@ namespace SP\Modules\Web\Controllers\Helpers; use SP\Bootstrap; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; +use SP\Core\AppInfoInterface; use SP\Core\Crypt\CryptPKI; use SP\Core\Exceptions\SPException; use SP\Core\Language; @@ -36,7 +37,6 @@ use SP\Html\DataGrid\DataGridAction; use SP\Http\Uri; use SP\Plugin\PluginManager; use SP\Services\Install\Installer; -use SP\Util\Util; use SP\Util\Version; /** @@ -101,8 +101,11 @@ final class LayoutHelper extends HelperBase $this->view->assign('isInstalled', $this->configData->isInstalled()); $this->view->assign('sk', $this->loggedIn ? $this->context->generateSecurityKey() : ''); - $this->view->assign('appInfo', Util::getAppInfo()); - $this->view->assign('appVersion', Installer::VERSION_TEXT); + $this->view->assign('app_name', AppInfoInterface::APP_NAME); + $this->view->assign('app_desc', AppInfoInterface::APP_DESC); + $this->view->assign('app_website_url', AppInfoInterface::APP_WEBSITE_URL); + $this->view->assign('app_blog_url', AppInfoInterface::APP_BLOG_URL); + $this->view->assign('app_version', Installer::VERSION_TEXT); $this->view->assign('isDemoMode', $this->configData->isDemoEnabled()); $this->view->assign('icons', $this->theme->getIcons()); $this->view->assign('logoIcon', Bootstrap::$WEBURI . '/public/images/logo_icon.png'); @@ -336,7 +339,7 @@ final class LayoutHelper extends HelperBase 'route' => Acl::getActionRoute(ActionsInterface::PLUGIN) ]); - $actions[] = $actionPlugins; + $actions[] = $actionPlugins; } if ($acl->checkUserAccess(ActionsInterface::CONFIG)) { diff --git a/app/modules/web/Controllers/ItemPresetController.php b/app/modules/web/Controllers/ItemPresetController.php index 24658646..08c9d929 100644 --- a/app/modules/web/Controllers/ItemPresetController.php +++ b/app/modules/web/Controllers/ItemPresetController.php @@ -45,7 +45,7 @@ use SP\Util\Filter; * * @package SP\Modules\Web\Controllers */ -class ItemPresetController extends ControllerBase implements CrudControllerInterface +final class ItemPresetController extends ControllerBase implements CrudControllerInterface { use JsonTrait, ItemTrait; diff --git a/app/modules/web/Controllers/StatusController.php b/app/modules/web/Controllers/StatusController.php index 0577453c..0d320750 100644 --- a/app/modules/web/Controllers/StatusController.php +++ b/app/modules/web/Controllers/StatusController.php @@ -26,10 +26,10 @@ namespace SP\Modules\Web\Controllers; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; +use SP\Core\AppInfoInterface; use SP\Core\Exceptions\CheckException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; -use SP\Util\Util; use SP\Util\Version; /** @@ -44,6 +44,9 @@ final class StatusController extends SimpleControllerBase /** * checkReleaseAction * + * @return bool + * @throws \DI\DependencyException + * @throws \DI\NotFoundException * @throws \GuzzleHttp\Exception\GuzzleException */ public function checkReleaseAction() @@ -52,7 +55,7 @@ final class StatusController extends SimpleControllerBase $this->extensionChecker->checkCurlAvailable(true); $request = $this->dic->get(Client::class) - ->request('GET', Util::getAppInfo('appupdates')); + ->request('GET', AppInfoInterface::APP_UPDATES_URL); if ($request->getStatusCode() === 200 && strpos($request->getHeaderLine('content-type'), 'application/json') !== false @@ -101,6 +104,9 @@ final class StatusController extends SimpleControllerBase /** * checkNoticesAction * + * @return bool + * @throws \DI\DependencyException + * @throws \DI\NotFoundException * @throws \GuzzleHttp\Exception\GuzzleException */ public function checkNoticesAction() @@ -109,7 +115,7 @@ final class StatusController extends SimpleControllerBase $this->extensionChecker->checkCurlAvailable(true); $request = $this->dic->get(Client::class) - ->request('GET', Util::getAppInfo('appnotices')); + ->request('GET', AppInfoInterface::APP_NOTICES_URL); if ($request->getStatusCode() === 200 && strpos($request->getHeaderLine('content-type'), 'application/json') !== false diff --git a/app/modules/web/themes/material-blue/views/_layouts/main.inc b/app/modules/web/themes/material-blue/views/_layouts/main.inc index 115f9031..6f5bec87 100644 --- a/app/modules/web/themes/material-blue/views/_layouts/main.inc +++ b/app/modules/web/themes/material-blue/views/_layouts/main.inc @@ -2,7 +2,7 @@ - <?php echo $appInfo['appname'], ' :: ', $appInfo['appdesc']; ?> + <?php printf('%s :: %s', $app_name, $app_desc); ?> @@ -21,7 +21,8 @@
-
+
includePartial('fixed-header'); diff --git a/app/modules/web/themes/material-blue/views/_partials/fixed-header.inc b/app/modules/web/themes/material-blue/views/_partials/fixed-header.inc index 0dbecfde..bec8a659 100644 --- a/app/modules/web/themes/material-blue/views/_partials/fixed-header.inc +++ b/app/modules/web/themes/material-blue/views/_partials/fixed-header.inc @@ -83,7 +83,7 @@
- +
diff --git a/app/modules/web/themes/material-blue/views/_partials/footer.inc b/app/modules/web/themes/material-blue/views/_partials/footer.inc index edc5c164..4976a6e5 100644 --- a/app/modules/web/themes/material-blue/views/_partials/footer.inc +++ b/app/modules/web/themes/material-blue/views/_partials/footer.inc @@ -49,13 +49,13 @@
- - + +  ::  - cygnux.org + cygnux.org
diff --git a/app/modules/web/themes/material-blue/views/install/index.inc b/app/modules/web/themes/material-blue/views/install/index.inc index 5dda5a68..7c681265 100644 --- a/app/modules/web/themes/material-blue/views/install/index.inc +++ b/app/modules/web/themes/material-blue/views/install/index.inc @@ -5,7 +5,7 @@ ?>
-

+

includePartial('error-list'); ?> diff --git a/composer.json b/composer.json index b7eda244..8d2951af 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,10 @@ "doctrine/common": "~v2.7", "guzzlehttp/guzzle": "~6.3", "monolog/monolog": "^1.23", - "ext-pdo": "*" + "ext-pdo": "*", + "ext-dom": "*", + "ext-gd": "*", + "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "^6", diff --git a/lib/SP/Core/AppInfoInterface.php b/lib/SP/Core/AppInfoInterface.php new file mode 100644 index 00000000..3f83df3d --- /dev/null +++ b/lib/SP/Core/AppInfoInterface.php @@ -0,0 +1,44 @@ +. + */ + +namespace SP\Core; + + +/** + * Interface AppInfoInterface + * + * @package SP\Core + */ +interface AppInfoInterface +{ + const APP_NAME = 'sysPass'; + const APP_DESC = 'Systems Password Manager'; + const APP_ALIAS = 'SPM'; + const APP_WEBSITE_URL = 'https://www.syspass.org'; + const APP_BLOG_URL = 'https://www.cygnux.org'; + const APP_DOC_URL = 'https://doc.syspass.org'; + const APP_UPDATES_URL = 'https://api.github.com/repos/nuxsmin/sysPass/releases/latest'; + const APP_NOTICES_URL = 'https://api.github.com/repos/nuxsmin/sysPass/issues?milestone=none&state=open&labels=Notices'; + const APP_ISSUES_URL = 'https://github.com/nuxsmin/sysPass/issues'; +} \ No newline at end of file diff --git a/lib/SP/Core/SessionUtil.php b/lib/SP/Core/SessionUtil.php index 5637d6fd..86767ed2 100644 --- a/lib/SP/Core/SessionUtil.php +++ b/lib/SP/Core/SessionUtil.php @@ -31,7 +31,7 @@ defined('APP_ROOT') || die(); * * @package SP */ -class SessionUtil +final class SessionUtil { /** * Limpiar la sesión del usuario diff --git a/lib/SP/Core/UI/ThemeIcons.php b/lib/SP/Core/UI/ThemeIcons.php index 67a99d89..f563396f 100644 --- a/lib/SP/Core/UI/ThemeIcons.php +++ b/lib/SP/Core/UI/ThemeIcons.php @@ -34,7 +34,7 @@ defined('APP_ROOT') || die(); * * @package SP\Core */ -class ThemeIcons +final class ThemeIcons { /** * @var IconInterface[] diff --git a/lib/SP/Html/DataGrid/DataGrid.php b/lib/SP/Html/DataGrid/DataGrid.php index cd1943a9..7722c3aa 100644 --- a/lib/SP/Html/DataGrid/DataGrid.php +++ b/lib/SP/Html/DataGrid/DataGrid.php @@ -38,14 +38,14 @@ final class DataGrid extends DataGridBase * * @var string */ - private $_title = ''; + private $title = ''; /** * @return string */ public function getTitle() { - return $this->_title; + return $this->title; } /** @@ -55,7 +55,7 @@ final class DataGrid extends DataGridBase */ public function setTitle($title) { - $this->_title = $title; + $this->title = $title; return $this; } diff --git a/lib/SP/Html/DataGrid/DataGridActionSearch.php b/lib/SP/Html/DataGrid/DataGridActionSearch.php index 4d393c2b..7cfab7e7 100644 --- a/lib/SP/Html/DataGrid/DataGridActionSearch.php +++ b/lib/SP/Html/DataGrid/DataGridActionSearch.php @@ -36,14 +36,14 @@ final class DataGridActionSearch extends DataGridActionBase /** * @var string */ - private $_onSubmitFunction = ''; + private $onSubmitFunction = ''; /** * Los argumentos de la función OnSubmit * * @var array */ - private $_onSubmitArgs = []; + private $onSubmitArgs = []; /** * DataGridActionSearch constructor. @@ -64,11 +64,11 @@ final class DataGridActionSearch extends DataGridActionBase { $args = []; - foreach ($this->_onSubmitArgs as $arg) { + foreach ($this->onSubmitArgs as $arg) { $args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg; } - return count($args) > 0 ? 'return ' . $this->_onSubmitFunction . '(' . implode(',', $args) . ');' : $this->_onSubmitFunction; + return count($args) > 0 ? 'return ' . $this->onSubmitFunction . '(' . implode(',', $args) . ');' : $this->onSubmitFunction; } /** @@ -76,7 +76,7 @@ final class DataGridActionSearch extends DataGridActionBase */ public function setOnSubmitFunction($onSubmitFunction) { - $this->_onSubmitFunction = $onSubmitFunction; + $this->onSubmitFunction = $onSubmitFunction; } /** @@ -84,6 +84,6 @@ final class DataGridActionSearch extends DataGridActionBase */ public function setOnSubmitArgs($args) { - $this->_onSubmitArgs[] = $args; + $this->onSubmitArgs[] = $args; } } \ No newline at end of file diff --git a/lib/SP/Html/DataGrid/DataGridBase.php b/lib/SP/Html/DataGrid/DataGridBase.php index ba3b920f..a4a65975 100644 --- a/lib/SP/Html/DataGrid/DataGridBase.php +++ b/lib/SP/Html/DataGrid/DataGridBase.php @@ -44,87 +44,87 @@ abstract class DataGridBase implements DataGridInterface * * @var int */ - protected $_time = 0; + protected $time = 0; /** * El id de la matriz * * @var string */ - protected $_id = ''; + protected $id = ''; /** * La cabecera de la matriz * * @var DataGridHeaderInterface */ - protected $_header; + protected $header; /** * Los datos de la matriz * * @var DataGridData */ - protected $_data; + protected $data; /** * El paginador * * @var DataGridPagerBase */ - protected $_pager; + protected $pager; /** * Las acciones asociadas a los elementos de la matriz * * @var DataGridActionInterface[] */ - protected $_actions; + protected $actions; /** * @var int */ - protected $_actionsCount = 0; + protected $actionsCount = 0; /** * Las acciones asociadas a los elementos de la matriz que se muestran en un menú * * @var DataGridActionInterface[] */ - protected $_actionsMenu; + protected $actionsMenu; /** * @var int */ - protected $_actionsMenuCount = 0; + protected $actionsMenuCount = 0; /** * La acción a realizar al cerrar la matriz * * @var int */ - protected $_onCloseAction = 0; + protected $onCloseAction = 0; /** * La plantilla a utilizar para presentar la cabecera * * @var string */ - protected $_headerTemplate; + protected $headerTemplate; /** * La plantilla a utilizar para presentar las acciones * * @var string */ - protected $_actionsTemplate; + protected $actionsTemplate; /** * La plantilla a utilizar para presentar el paginador * * @var string */ - protected $_pagerTemplate; + protected $pagerTemplate; /** * La plantilla a utilizar para presentar los datos * * @var string */ - protected $_rowsTemplate; + protected $rowsTemplate; /** * La plantilla a utilizar para presentar la tabla * * @var string */ - protected $_tableTemplate; + protected $tableTemplate; /** * @var Theme */ @@ -145,7 +145,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getOnCloseAction() { - return $this->_onCloseAction; + return $this->onCloseAction; } /** @@ -155,7 +155,7 @@ abstract class DataGridBase implements DataGridInterface */ public function setOnCloseAction(ActionsInterface $action) { - $this->_onCloseAction = $action; + $this->onCloseAction = $action; return $this; } @@ -165,7 +165,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getId() { - return $this->_id; + return $this->id; } /** @@ -175,7 +175,7 @@ abstract class DataGridBase implements DataGridInterface */ public function setId($id) { - $this->_id = $id; + $this->id = $id; return $this; } @@ -185,7 +185,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getHeader() { - return $this->_header; + return $this->header; } /** @@ -195,7 +195,7 @@ abstract class DataGridBase implements DataGridInterface */ public function setHeader(DataGridHeaderInterface $header) { - $this->_header = $header; + $this->header = $header; return $this; } @@ -205,7 +205,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getData() { - return $this->_data; + return $this->data; } /** @@ -215,7 +215,7 @@ abstract class DataGridBase implements DataGridInterface */ public function setData(DataGridDataInterface $data) { - $this->_data = $data; + $this->data = $data; return $this; } @@ -229,24 +229,24 @@ abstract class DataGridBase implements DataGridInterface public function setDataActions(DataGridActionInterface $action, $isMenu = false) { if ($isMenu === false) { - if (null === $this->_actions) { - $this->_actions = new SplObjectStorage(); + if (null === $this->actions) { + $this->actions = new SplObjectStorage(); } - $this->_actions->attach($action); + $this->actions->attach($action); if (!$action->isSkip()) { - $this->_actionsCount++; + $this->actionsCount++; } } else { - if (null === $this->_actionsMenu) { - $this->_actionsMenu = new SplObjectStorage(); + if (null === $this->actionsMenu) { + $this->actionsMenu = new SplObjectStorage(); } - $this->_actionsMenu->attach($action); + $this->actionsMenu->attach($action); if (!$action->isSkip()) { - $this->_actionsMenuCount++; + $this->actionsMenuCount++; } } @@ -258,7 +258,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataActions() { - return $this->_actions; + return $this->actions; } /** @@ -280,7 +280,7 @@ abstract class DataGridBase implements DataGridInterface public function setDataHeaderTemplate($template, $base = null) { try { - $this->_headerTemplate = $this->checkTemplate($template, $base); + $this->headerTemplate = $this->checkTemplate($template, $base); } catch (FileNotFoundException $e) { processException($e); } @@ -316,7 +316,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataHeaderTemplate() { - return $this->_headerTemplate; + return $this->headerTemplate; } /** @@ -329,7 +329,7 @@ abstract class DataGridBase implements DataGridInterface public function setDataActionsTemplate($template) { try { - $this->_actionsTemplate = $this->checkTemplate($template); + $this->actionsTemplate = $this->checkTemplate($template); } catch (FileNotFoundException $e) { logger($e->getMessage()); } @@ -344,7 +344,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataActionsTemplate() { - return $this->_actionsTemplate; + return $this->actionsTemplate; } /** @@ -358,7 +358,7 @@ abstract class DataGridBase implements DataGridInterface public function setDataPagerTemplate($template, $base = null) { try { - $this->_pagerTemplate = $this->checkTemplate($template, $base); + $this->pagerTemplate = $this->checkTemplate($template, $base); } catch (FileNotFoundException $e) { logger($e->getMessage()); } @@ -373,7 +373,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataPagerTemplate() { - return $this->_pagerTemplate; + return $this->pagerTemplate; } /** @@ -385,7 +385,7 @@ abstract class DataGridBase implements DataGridInterface public function setDataRowTemplate($template, $base = null) { try { - $this->_rowsTemplate = $this->checkTemplate($template, $base); + $this->rowsTemplate = $this->checkTemplate($template, $base); } catch (FileNotFoundException $e) { processException($e); } @@ -398,7 +398,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataRowTemplate() { - return $this->_rowsTemplate; + return $this->rowsTemplate; } /** @@ -408,7 +408,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getPager() { - return $this->_pager; + return $this->pager; } /** @@ -420,7 +420,7 @@ abstract class DataGridBase implements DataGridInterface */ public function setPager(DataGridPagerInterface $pager) { - $this->_pager = $pager; + $this->pager = $pager; return $this; } @@ -430,8 +430,8 @@ abstract class DataGridBase implements DataGridInterface */ public function updatePager() { - if ($this->_pager instanceof DataGridPagerInterface) { - $this->_pager->setTotalRows($this->_data->getDataCount()); + if ($this->pager instanceof DataGridPagerInterface) { + $this->pager->setTotalRows($this->data->getDataCount()); } return $this; @@ -442,7 +442,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getTime() { - return abs($this->_time); + return abs($this->time); } /** @@ -452,7 +452,7 @@ abstract class DataGridBase implements DataGridInterface */ public function setTime($time) { - $this->_time = $time; + $this->time = $time; return $this; } @@ -464,7 +464,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataActionsMenu() { - return $this->_actionsMenu; + return $this->actionsMenu; } /** @@ -478,7 +478,7 @@ abstract class DataGridBase implements DataGridInterface { $actions = []; - foreach ($this->_actions as $action) { + foreach ($this->actions as $action) { if ($action->getRuntimeFilter()($filter)) { $actions[] = $action; } @@ -498,7 +498,7 @@ abstract class DataGridBase implements DataGridInterface { $actions = []; - foreach ($this->_actionsMenu as $action) { + foreach ($this->actionsMenu as $action) { if ($action->getRuntimeFilter()($filter)) { $actions[] = $action; } @@ -512,7 +512,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataTableTemplate() { - return $this->_tableTemplate; + return $this->tableTemplate; } /** @@ -524,7 +524,7 @@ abstract class DataGridBase implements DataGridInterface public function setDataTableTemplate($template, $base = null) { try { - $this->_tableTemplate = $this->checkTemplate($template, $base); + $this->tableTemplate = $this->checkTemplate($template, $base); } catch (FileNotFoundException $e) { processException($e); } @@ -537,7 +537,7 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataActionsMenuCount() { - return $this->_actionsMenuCount; + return $this->actionsMenuCount; } /** @@ -545,6 +545,6 @@ abstract class DataGridBase implements DataGridInterface */ public function getDataActionsCount() { - return $this->_actionsCount; + return $this->actionsCount; } } \ No newline at end of file diff --git a/lib/SP/Html/DataGrid/DataGridDataBase.php b/lib/SP/Html/DataGrid/DataGridDataBase.php index 5ca2f265..9c17b10b 100644 --- a/lib/SP/Html/DataGrid/DataGridDataBase.php +++ b/lib/SP/Html/DataGrid/DataGridDataBase.php @@ -41,36 +41,36 @@ abstract class DataGridDataBase implements DataGridDataInterface * * @var array */ - private $_data = []; + private $data = []; /** * Las columnas a mostrar de los datos obtenidos * * @var array */ - private $_sources = []; + private $sources = []; /** * La columna que identifica cada elemento de los datos de la matriz * * @var int */ - private $_sourceId = 0; + private $sourceId = 0; /** * Las columnas a mostrar de los datos obtenidos que son representadas con iconos * * @var array */ - private $_sourcesWithIcon = []; + private $sourcesWithIcon = []; /** * @var int */ - private $_dataCount = 0; + private $dataCount = 0; /** * @return array */ public function getDataRowSourcesWithIcon() { - return $this->_sourcesWithIcon; + return $this->sourcesWithIcon; } /** @@ -81,7 +81,7 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function addDataRowSource($source, $isMethod = false, callable $filter = null, $truncate = true) { - $this->_sources[] = [ + $this->sources[] = [ 'name' => $source, 'isMethod' => $isMethod, 'filter' => $filter, @@ -94,7 +94,7 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function setDataRowSourceId($id) { - $this->_sourceId = $id; + $this->sourceId = $id; } /** @@ -102,7 +102,7 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function getDataRowSources() { - return $this->_sources; + return $this->sources; } /** @@ -110,7 +110,7 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function getDataRowSourceId() { - return $this->_sourceId; + return $this->sourceId; } /** @@ -118,7 +118,7 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function getData() { - return $this->_data; + return $this->data; } /** @@ -126,8 +126,8 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function setData(QueryResult $queryResult) { - $this->_dataCount = $queryResult->getTotalNumRows(); - $this->_data = $queryResult->getDataAsArray(); + $this->dataCount = $queryResult->getTotalNumRows(); + $this->data = $queryResult->getDataAsArray(); } /** @@ -137,7 +137,7 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function addDataRowSourceWithIcon($source, IconInterface $icon, $value = 1) { - $this->_sourcesWithIcon[] = [ + $this->sourcesWithIcon[] = [ 'field' => $source, 'icon' => $icon, 'value' => $value @@ -151,6 +151,6 @@ abstract class DataGridDataBase implements DataGridDataInterface */ public function getDataCount() { - return $this->_dataCount; + return $this->dataCount; } } \ No newline at end of file diff --git a/lib/SP/Html/DataGrid/DataGridHeaderBase.php b/lib/SP/Html/DataGrid/DataGridHeaderBase.php index 04724bcf..e826055a 100644 --- a/lib/SP/Html/DataGrid/DataGridHeaderBase.php +++ b/lib/SP/Html/DataGrid/DataGridHeaderBase.php @@ -38,23 +38,23 @@ abstract class DataGridHeaderBase implements DataGridHeaderInterface * * @var array */ - private $_headers = array(); + private $headers = []; /** * El ancho de las columnas * * @var int */ - private $_width = 0; + private $width = 0; /** * @param $header string */ public function addHeader($header) { - $this->_headers[] = $header; + $this->headers[] = $header; - $numHeaders = count($this->_headers); - $this->_width = ($numHeaders > 0) ? floor(65 / $numHeaders) : 65; + $numHeaders = count($this->headers); + $this->width = ($numHeaders > 0) ? floor(65 / $numHeaders) : 65; } /** @@ -62,7 +62,7 @@ abstract class DataGridHeaderBase implements DataGridHeaderInterface */ public function getWidth() { - return $this->_width; + return $this->width; } /** @@ -70,6 +70,6 @@ abstract class DataGridHeaderBase implements DataGridHeaderInterface */ public function getHeaders() { - return $this->_headers; + return $this->headers; } } \ No newline at end of file diff --git a/lib/SP/Html/DataGrid/DataGridHeaderSort.php b/lib/SP/Html/DataGrid/DataGridHeaderSort.php index 475567fd..4134d4db 100644 --- a/lib/SP/Html/DataGrid/DataGridHeaderSort.php +++ b/lib/SP/Html/DataGrid/DataGridHeaderSort.php @@ -38,19 +38,19 @@ final class DataGridHeaderSort extends DataGridHeaderBase /** * @var DataGridActionInterface[] */ - private $_actions; + private $actions; /** * @var DataGridSortInterface[] */ - private $_sortFields; + private $sortFields; /** * @return DataGridSortInterface[] */ public function getSortFields() { - return $this->_sortFields; + return $this->sortFields; } /** @@ -58,7 +58,7 @@ final class DataGridHeaderSort extends DataGridHeaderBase */ public function getActions() { - return $this->_actions; + return $this->actions; } /** @@ -66,11 +66,11 @@ final class DataGridHeaderSort extends DataGridHeaderBase */ public function addAction($action) { - if (null === $this->_actions) { - $this->_actions = new SplObjectStorage(); + if (null === $this->actions) { + $this->actions = new SplObjectStorage(); } - $this->_actions->attach($action); + $this->actions->attach($action); } /** @@ -80,11 +80,11 @@ final class DataGridHeaderSort extends DataGridHeaderBase */ public function addSortField($field) { - if (null === $this->_sortFields) { - $this->_sortFields = new SplObjectStorage(); + if (null === $this->sortFields) { + $this->sortFields = new SplObjectStorage(); } - $this->_sortFields->attach($field); + $this->sortFields->attach($field); return $this; } diff --git a/lib/SP/Html/DataGrid/DataGridPagerBase.php b/lib/SP/Html/DataGrid/DataGridPagerBase.php index 774988a6..0c9fe3cb 100644 --- a/lib/SP/Html/DataGrid/DataGridPagerBase.php +++ b/lib/SP/Html/DataGrid/DataGridPagerBase.php @@ -38,66 +38,66 @@ abstract class DataGridPagerBase implements DataGridPagerInterface /** * @var int */ - protected $_sortKey = 0; + protected $sortKey = 0; /** * @var int */ - protected $_sortOrder = 0; + protected $sortOrder = 0; /** * @var int */ - protected $_limitStart = 0; + protected $limitStart = 0; /** * @var int */ - protected $_limitCount = 0; + protected $limitCount = 0; /** * @var int */ - protected $_totalRows = 0; + protected $totalRows = 0; /** * @var bool */ - protected $_filterOn = false; + protected $filterOn = false; /** * @var string */ - protected $_onClickFunction = ''; + protected $onClickFunction = ''; /** * @var array */ - protected $_onClickArgs = array(); + protected $onClickArgs = []; /** * @var IconInterface */ - protected $_iconPrev; + protected $iconPrev; /** * @var IconInterface */ - protected $_iconNext; + protected $iconNext; /** * @var IconInterface */ - protected $_iconFirst; + protected $iconFirst; /** * @var IconInterface */ - protected $_iconLast; + protected $iconLast; /** * @var DataGridActionSearch */ - protected $_sourceAction; + protected $sourceAction; /** * @var string */ - protected $_sk; + protected $sk; /** * @return int */ public function getSortOrder() { - return $this->_sortOrder; + return $this->sortOrder; } /** @@ -107,7 +107,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setSortOrder($sortOrder) { - $this->_sortOrder = $sortOrder; + $this->sortOrder = $sortOrder; return $this; } @@ -119,7 +119,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setSk($sk) { - $this->_sk = $sk; + $this->sk = $sk; return $this; } @@ -129,7 +129,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getIconPrev() { - return $this->_iconPrev; + return $this->iconPrev; } /** @@ -139,7 +139,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setIconPrev(IconInterface $iconPrev) { - $this->_iconPrev = $iconPrev; + $this->iconPrev = $iconPrev; return $this; } @@ -149,7 +149,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getIconNext() { - return $this->_iconNext; + return $this->iconNext; } /** @@ -159,7 +159,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setIconNext(IconInterface $iconNext) { - $this->_iconNext = $iconNext; + $this->iconNext = $iconNext; return $this; } @@ -169,7 +169,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getIconFirst() { - return $this->_iconFirst; + return $this->iconFirst; } /** @@ -179,7 +179,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setIconFirst(IconInterface $iconFirst) { - $this->_iconFirst = $iconFirst; + $this->iconFirst = $iconFirst; return $this; } @@ -189,7 +189,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getIconLast() { - return $this->_iconLast; + return $this->iconLast; } /** @@ -199,7 +199,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setIconLast(IconInterface $iconLast) { - $this->_iconLast = $iconLast; + $this->iconLast = $iconLast; return $this; } @@ -211,7 +211,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getSortKey() { - return $this->_sortKey; + return $this->sortKey; } /** @@ -223,7 +223,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setSortKey($sortKey) { - $this->_sortKey = $sortKey; + $this->sortKey = $sortKey; return $this; } @@ -235,7 +235,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getLimitStart() { - return $this->_limitStart; + return $this->limitStart; } /** @@ -247,7 +247,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setLimitStart($limitStart) { - $this->_limitStart = $limitStart; + $this->limitStart = $limitStart; return $this; } @@ -259,7 +259,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getLimitCount() { - return $this->_limitCount; + return $this->limitCount; } /** @@ -271,7 +271,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setLimitCount($limitCount) { - $this->_limitCount = $limitCount; + $this->limitCount = $limitCount; return $this; } @@ -283,7 +283,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getFirstPage() { - return ceil(($this->_limitStart + 1) / $this->_limitCount); + return ceil(($this->limitStart + 1) / $this->limitCount); } /** @@ -293,7 +293,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getLastPage() { - return ceil($this->_totalRows / $this->_limitCount); + return ceil($this->totalRows / $this->limitCount); } /** @@ -303,7 +303,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getTotalRows() { - return $this->_totalRows; + return $this->totalRows; } /** @@ -315,7 +315,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setTotalRows($totalRows) { - $this->_totalRows = $totalRows; + $this->totalRows = $totalRows; return $this; } @@ -327,7 +327,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getFilterOn() { - return $this->_filterOn; + return $this->filterOn; } /** @@ -339,7 +339,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setFilterOn($filterOn) { - $this->_filterOn = $filterOn; + $this->filterOn = $filterOn; return $this; } @@ -353,7 +353,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setOnClickFunction($function) { - $this->_onClickFunction = $function; + $this->onClickFunction = $function; return $this; } @@ -367,7 +367,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface { $args = $this->parseArgs(); - return count($args) > 0 ? $this->_onClickFunction . '(' . implode(',', $args) . ')' : $this->_onClickFunction; + return count($args) > 0 ? $this->onClickFunction . '(' . implode(',', $args) . ')' : $this->onClickFunction; } /** @@ -377,7 +377,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface { $args = array(); - foreach ($this->_onClickArgs as $arg) { + foreach ($this->onClickArgs as $arg) { $args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg; } @@ -393,7 +393,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setOnClickArgs($args) { - $this->_onClickArgs[] = $args; + $this->onClickArgs[] = $args; return $this; } @@ -408,7 +408,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface $args = $this->parseArgs(); $args[] = $this->getFirst(); - return $this->_onClickFunction . '(' . implode(',', $args) . ')'; + return $this->onClickFunction . '(' . implode(',', $args) . ')'; } /** @@ -429,7 +429,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface $args = $this->parseArgs(); $args[] = $this->getLast(); - return $this->_onClickFunction . '(' . implode(',', $args) . ')'; + return $this->onClickFunction . '(' . implode(',', $args) . ')'; } /** @@ -437,7 +437,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getLast() { - return (($this->_totalRows % $this->_limitCount) == 0) ? $this->_totalRows - $this->_limitCount : floor($this->_totalRows / $this->_limitCount) * $this->_limitCount; + return (($this->totalRows % $this->limitCount) == 0) ? $this->totalRows - $this->limitCount : floor($this->totalRows / $this->limitCount) * $this->limitCount; } /** @@ -450,7 +450,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface $args = $this->parseArgs(); $args[] = $this->getNext(); - return $this->_onClickFunction . '(' . implode(',', $args) . ')'; + return $this->onClickFunction . '(' . implode(',', $args) . ')'; } /** @@ -458,7 +458,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getNext() { - return ($this->_limitStart + $this->_limitCount); + return ($this->limitStart + $this->limitCount); } /** @@ -471,7 +471,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface $args = $this->parseArgs(); $args[] = $this->getPrev(); - return $this->_onClickFunction . '(' . implode(',', $args) . ')'; + return $this->onClickFunction . '(' . implode(',', $args) . ')'; } /** @@ -479,7 +479,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getPrev() { - return ($this->_limitStart - $this->_limitCount); + return ($this->limitStart - $this->limitCount); } /** @@ -487,7 +487,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function getSourceAction() { - return $this->_sourceAction; + return $this->sourceAction; } /** @@ -497,7 +497,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface */ public function setSourceAction($sourceAction) { - $this->_sourceAction = $sourceAction; + $this->sourceAction = $sourceAction; return $this; } diff --git a/lib/SP/Html/DataGrid/DataGridSort.php b/lib/SP/Html/DataGrid/DataGridSort.php index dd29b6a9..1e541caa 100644 --- a/lib/SP/Html/DataGrid/DataGridSort.php +++ b/lib/SP/Html/DataGrid/DataGridSort.php @@ -38,34 +38,34 @@ final class DataGridSort implements DataGridSortInterface /** * @var int */ - private $_sortKey = 0; + private $sortKey = 0; /** * @var string */ - private $_title = ''; + private $title = ''; /** * @var string */ - private $_name = ''; + private $name = ''; /** * @var array */ - private $_class = array(); + private $class = array(); /** * @var IconInterface */ - private $_iconUp; + private $iconUp; /** * @var IconInterface */ - private $_iconDown; + private $iconDown; /** * @return int */ public function getSortKey() { - return $this->_sortKey; + return $this->sortKey; } /** @@ -75,7 +75,7 @@ final class DataGridSort implements DataGridSortInterface */ public function setSortKey($key) { - $this->_sortKey = $key; + $this->sortKey = $key; return $this; } @@ -85,7 +85,7 @@ final class DataGridSort implements DataGridSortInterface */ public function getTitle() { - return $this->_title; + return $this->title; } /** @@ -95,7 +95,7 @@ final class DataGridSort implements DataGridSortInterface */ public function setTitle($title) { - $this->_title = $title; + $this->title = $title; return $this; } @@ -105,7 +105,7 @@ final class DataGridSort implements DataGridSortInterface */ public function getName() { - return $this->_name; + return $this->name; } /** @@ -115,7 +115,7 @@ final class DataGridSort implements DataGridSortInterface */ public function setName($name) { - $this->_name = $name; + $this->name = $name; return $this; } @@ -125,7 +125,7 @@ final class DataGridSort implements DataGridSortInterface */ public function getClass() { - return implode(' ', $this->_class); + return implode(' ', $this->class); } /** @@ -135,7 +135,7 @@ final class DataGridSort implements DataGridSortInterface */ public function setClass($class) { - $this->_class[] = $class; + $this->class[] = $class; return $this; } @@ -145,7 +145,7 @@ final class DataGridSort implements DataGridSortInterface */ public function getIconUp() { - return $this->_iconUp; + return $this->iconUp; } /** @@ -155,7 +155,7 @@ final class DataGridSort implements DataGridSortInterface */ public function setIconUp(IconInterface $icon) { - $this->_iconUp = $icon; + $this->iconUp = $icon; return $this; } @@ -165,7 +165,7 @@ final class DataGridSort implements DataGridSortInterface */ public function getIconDown() { - return $this->_iconDown; + return $this->iconDown; } /** @@ -175,7 +175,7 @@ final class DataGridSort implements DataGridSortInterface */ public function setIconDown(IconInterface $icon) { - $this->_iconDown = $icon; + $this->iconDown = $icon; return $this; } diff --git a/lib/SP/Html/DataGrid/DataGridTab.php b/lib/SP/Html/DataGrid/DataGridTab.php index 9e0ac544..989a348c 100644 --- a/lib/SP/Html/DataGrid/DataGridTab.php +++ b/lib/SP/Html/DataGrid/DataGridTab.php @@ -38,14 +38,14 @@ final class DataGridTab extends DataGridBase * * @var string */ - private $_title = ''; + private $title = ''; /** * @return string */ public function getTitle() { - return $this->_title; + return $this->title; } /** @@ -55,7 +55,7 @@ final class DataGridTab extends DataGridBase */ public function setTitle($title) { - $this->_title = $title; + $this->title = $title; return $this; } diff --git a/lib/SP/Html/Minify.php b/lib/SP/Html/Minify.php index 78594467..e89dfe03 100644 --- a/lib/SP/Html/Minify.php +++ b/lib/SP/Html/Minify.php @@ -25,9 +25,7 @@ namespace SP\Html; use Klein\Klein; -use SP\Core\Exceptions\SPException; use SP\Http\Request; -use SP\Util\Util; defined('APP_ROOT') || die(); @@ -116,11 +114,9 @@ final class Minify // Obtener el recurso desde una URL if ($file['type'] === 'url') { - try { - $data .= '/* URL: ' . $file['name'] . ' */' . PHP_EOL . Util::getDataFromUrl($file['name']); - } catch (SPException $e) { - processException($e); - } + logger('URL:' . $file['name']); + +// $data .= '/* URL: ' . $file['name'] . ' */' . PHP_EOL . Util::getDataFromUrl($file['name']); } else { if ($file['min'] === true && $disableMinify === false) { $data .= '/* MINIFIED FILE: ' . $file['name'] . ' */' . PHP_EOL; diff --git a/lib/SP/Mvc/Controller/Validators/PasswordValidator.php b/lib/SP/Mvc/Controller/Validators/PasswordValidator.php index a70807ea..e1727581 100644 --- a/lib/SP/Mvc/Controller/Validators/PasswordValidator.php +++ b/lib/SP/Mvc/Controller/Validators/PasswordValidator.php @@ -32,7 +32,7 @@ use SP\DataModel\ItemPreset\Password; * * @package SP\Mvc\Controller */ -class PasswordValidator implements ValidatorInterface +final class PasswordValidator implements ValidatorInterface { /** * @var Password diff --git a/lib/SP/Mvc/Controller/Validators/Validator.php b/lib/SP/Mvc/Controller/Validators/Validator.php index 06b6f3fb..9a0a8f47 100644 --- a/lib/SP/Mvc/Controller/Validators/Validator.php +++ b/lib/SP/Mvc/Controller/Validators/Validator.php @@ -29,7 +29,7 @@ namespace SP\Mvc\Controller\Validators; * * @package SP\Util */ -class Validator +final class Validator { /** * @param string $string diff --git a/lib/SP/Mvc/View/Components/DataTab.php b/lib/SP/Mvc/View/Components/DataTab.php index 655c488a..137ed6b7 100644 --- a/lib/SP/Mvc/View/Components/DataTab.php +++ b/lib/SP/Mvc/View/Components/DataTab.php @@ -32,7 +32,7 @@ use SP\Mvc\View\Template; * * @package SP\Mvc\View\Components */ -class DataTab +final class DataTab { /** * @var string diff --git a/lib/SP/Mvc/View/Components/SelectItem.php b/lib/SP/Mvc/View/Components/SelectItem.php index 512d2dc7..8b965617 100644 --- a/lib/SP/Mvc/View/Components/SelectItem.php +++ b/lib/SP/Mvc/View/Components/SelectItem.php @@ -29,7 +29,7 @@ namespace SP\Mvc\View\Components; * * @package SP\Mvc\View\Components */ -class SelectItem +final class SelectItem { /** * @var int diff --git a/lib/SP/Mvc/View/Components/SelectItemAdapter.php b/lib/SP/Mvc/View/Components/SelectItemAdapter.php index dd39c9be..c0a5f472 100644 --- a/lib/SP/Mvc/View/Components/SelectItemAdapter.php +++ b/lib/SP/Mvc/View/Components/SelectItemAdapter.php @@ -33,7 +33,7 @@ use SP\Http\Json; * * @package SP\Mvc\View\Components */ -class SelectItemAdapter implements ItemAdapterInterface +final class SelectItemAdapter implements ItemAdapterInterface { /** * @var array diff --git a/lib/SP/Providers/Mail/MailProvider.php b/lib/SP/Providers/Mail/MailProvider.php index 38765a34..89cea7c8 100644 --- a/lib/SP/Providers/Mail/MailProvider.php +++ b/lib/SP/Providers/Mail/MailProvider.php @@ -26,8 +26,8 @@ namespace SP\Providers\Mail; use DI\Container; use PHPMailer\PHPMailer\PHPMailer; +use SP\Core\AppInfoInterface; use SP\Providers\Provider; -use SP\Util\Util; /** * Class MailProvider @@ -55,7 +55,7 @@ final class MailProvider extends Provider */ public function getMailer(MailParams $mailParams) { - $appName = Util::getAppInfo('appname'); + $appName = AppInfoInterface::APP_NAME; try { $this->mailer->SMTPAutoTLS = false; diff --git a/lib/SP/Services/Account/AccountAcl.php b/lib/SP/Services/Account/AccountAcl.php index cea354e0..7b4b23bf 100644 --- a/lib/SP/Services/Account/AccountAcl.php +++ b/lib/SP/Services/Account/AccountAcl.php @@ -31,7 +31,7 @@ use SP\Core\Acl\Acl; * * @package SP\Account */ -class AccountAcl +final class AccountAcl { /** * @var bool diff --git a/lib/SP/Services/Account/AccountPresetService.php b/lib/SP/Services/Account/AccountPresetService.php index 6557fb22..51fc0e2d 100644 --- a/lib/SP/Services/Account/AccountPresetService.php +++ b/lib/SP/Services/Account/AccountPresetService.php @@ -37,7 +37,7 @@ use SP\Services\ItemPreset\ItemPresetService; * * @package SP\Services\Account */ -class AccountPresetService +final class AccountPresetService { /** * @var ItemPresetService diff --git a/lib/SP/Services/Account/AccountRequest.php b/lib/SP/Services/Account/AccountRequest.php index bd1e899b..2d08b58c 100644 --- a/lib/SP/Services/Account/AccountRequest.php +++ b/lib/SP/Services/Account/AccountRequest.php @@ -29,7 +29,7 @@ namespace SP\Services\Account; * * @package SP\Account */ -class AccountRequest +final class AccountRequest { /** * @var int diff --git a/lib/SP/Services/Backup/FileBackupService.php b/lib/SP/Services/Backup/FileBackupService.php index 70678977..4b6490f3 100644 --- a/lib/SP/Services/Backup/FileBackupService.php +++ b/lib/SP/Services/Backup/FileBackupService.php @@ -25,6 +25,7 @@ namespace SP\Services\Backup; use SP\Config\ConfigData; +use SP\Core\AppInfoInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\SPException; @@ -36,7 +37,6 @@ use SP\Storage\Database\DatabaseUtil; use SP\Storage\Database\QueryData; use SP\Storage\File\FileHandler; use SP\Util\Checks; -use SP\Util\Util; defined('APP_ROOT') || die(); @@ -80,13 +80,11 @@ final class FileBackupService extends Service $this->checkBackupDir(); - $siteName = Util::getAppInfo('appname'); - // Generar hash unico para evitar descargas no permitidas $backupUniqueHash = sha1(uniqid('sysPassBackup', true)); - $this->backupFileApp = $this->path . DIRECTORY_SEPARATOR . $siteName . '-' . $backupUniqueHash . '.tar'; - $this->backupFileDb = $this->path . DIRECTORY_SEPARATOR . $siteName . '_db-' . $backupUniqueHash . '.sql'; + $this->backupFileApp = $this->path . DIRECTORY_SEPARATOR . AppInfoInterface::APP_NAME . '-' . $backupUniqueHash . '.tar'; + $this->backupFileDb = $this->path . DIRECTORY_SEPARATOR . AppInfoInterface::APP_NAME . '_db-' . $backupUniqueHash . '.sql'; try { $this->deleteOldBackups(); diff --git a/lib/SP/Services/Crypt/TemporaryMasterPassService.php b/lib/SP/Services/Crypt/TemporaryMasterPassService.php index 3739986a..c039fb32 100644 --- a/lib/SP/Services/Crypt/TemporaryMasterPassService.php +++ b/lib/SP/Services/Crypt/TemporaryMasterPassService.php @@ -24,6 +24,7 @@ namespace SP\Services\Crypt; +use SP\Core\AppInfoInterface; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Core\Events\Event; @@ -209,7 +210,7 @@ final class TemporaryMasterPassService extends Service private function getMessageForEmail($key) { $mailMessage = new MailMessage(); - $mailMessage->setTitle(sprintf(__('Clave Maestra %s'), Util::getAppInfo('appname'))); + $mailMessage->setTitle(sprintf(__('Clave Maestra %s'), AppInfoInterface::APP_NAME)); $mailMessage->addDescription(__('Se ha generado una nueva clave para el acceso a sysPass y se solicitará en el siguiente inicio.')); $mailMessage->addDescriptionLine(); $mailMessage->addDescription(sprintf(__('La nueva clave es: %s'), $key)); diff --git a/lib/SP/Services/Export/XmlExportService.php b/lib/SP/Services/Export/XmlExportService.php index 850d9a1a..35ad089b 100644 --- a/lib/SP/Services/Export/XmlExportService.php +++ b/lib/SP/Services/Export/XmlExportService.php @@ -28,6 +28,7 @@ use DOMXPath; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; +use SP\Core\AppInfoInterface; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Core\Events\Event; @@ -40,7 +41,6 @@ use SP\Services\Client\ClientService; use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\Tag\TagService; -use SP\Util\Util; use SP\Util\Version; defined('APP_ROOT') || die(); @@ -129,7 +129,7 @@ final class XmlExportService extends Service $this->configData->setExportHash($exportUniqueHash); $this->config->saveConfig($this->configData); - return $this->exportPath . DIRECTORY_SEPARATOR . Util::getAppInfo('appname') . '-' . $exportUniqueHash . '.xml'; + return $this->exportPath . DIRECTORY_SEPARATOR . AppInfoInterface::APP_NAME . '-' . $exportUniqueHash . '.xml'; } /** diff --git a/lib/SP/Services/Install/Installer.php b/lib/SP/Services/Install/Installer.php index 5e2839e5..df1a2d8e 100644 --- a/lib/SP/Services/Install/Installer.php +++ b/lib/SP/Services/Install/Installer.php @@ -57,7 +57,7 @@ final class Installer extends Service */ const VERSION = [3, 0, 0]; const VERSION_TEXT = '3.0-beta'; - const BUILD = 18093001; + const BUILD = 18100101; /** * @var DatabaseSetupInterface diff --git a/lib/SP/Services/ItemPreset/ItemPresetRequest.php b/lib/SP/Services/ItemPreset/ItemPresetRequest.php index 436930e2..8e0bc6f9 100644 --- a/lib/SP/Services/ItemPreset/ItemPresetRequest.php +++ b/lib/SP/Services/ItemPreset/ItemPresetRequest.php @@ -32,7 +32,7 @@ use SP\DataModel\ItemPresetData; * * @package SP\Services\ItemPreset */ -class ItemPresetRequest +final class ItemPresetRequest { /** * @var ItemPresetData diff --git a/lib/SP/Services/ItemPreset/ItemPresetService.php b/lib/SP/Services/ItemPreset/ItemPresetService.php index 7334c241..4aa9be4b 100644 --- a/lib/SP/Services/ItemPreset/ItemPresetService.php +++ b/lib/SP/Services/ItemPreset/ItemPresetService.php @@ -37,7 +37,7 @@ use SP\Storage\Database\QueryResult; * * @package SP\Services\Account */ -class ItemPresetService extends Service +final class ItemPresetService extends Service { /** * @var ItemPresetRepository diff --git a/lib/SP/Services/Mail/MailService.php b/lib/SP/Services/Mail/MailService.php index 52bd4a6b..d638a288 100644 --- a/lib/SP/Services/Mail/MailService.php +++ b/lib/SP/Services/Mail/MailService.php @@ -26,6 +26,7 @@ namespace SP\Services\Mail; use PHPMailer\PHPMailer\PHPMailer; use SP\Bootstrap; +use SP\Core\AppInfoInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Messages\MailMessage; @@ -35,7 +36,6 @@ use SP\Providers\Mail\MailProvider; use SP\Providers\Mail\MailProviderException; use SP\Services\Service; use SP\Services\ServiceException; -use SP\Util\Util; /** * Class MailService @@ -48,10 +48,6 @@ final class MailService extends Service * @var PHPMailer */ protected $mailer; - /** - * @var array - */ - private $appInfo; /** * Checks mail params by sending a test email @@ -100,7 +96,7 @@ final class MailService extends Service return [ '', '--', - sprintf('%s - %s', $this->appInfo['appname'], $this->appInfo['appdesc']), + sprintf('%s - %s', AppInfoInterface::APP_NAME, AppInfoInterface::APP_DESC), Html::anchorText(Bootstrap::$WEBURI) ]; } @@ -112,7 +108,7 @@ final class MailService extends Service */ protected function getSubjectForAction($action) { - return sprintf('%s - %s', $this->appInfo['appname'], $action); + return sprintf('%s - %s', AppInfoInterface::APP_NAME, $action); } /** @@ -189,8 +185,6 @@ final class MailService extends Service } else { throw new ServiceException(__u('Servicio de correo no disponible')); } - - $this->appInfo = Util::getAppInfo(); } /** diff --git a/lib/SP/Services/Upgrade/UpgradeAuthToken.php b/lib/SP/Services/Upgrade/UpgradeAuthToken.php index 64fcef61..75ee1bad 100644 --- a/lib/SP/Services/Upgrade/UpgradeAuthToken.php +++ b/lib/SP/Services/Upgrade/UpgradeAuthToken.php @@ -36,7 +36,7 @@ use SP\Services\Service; * * @package SP\Services\Upgrade */ -class UpgradeAuthToken extends Service +final class UpgradeAuthToken extends Service { /** * @var AuthTokenService diff --git a/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php b/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php index 76a5dbf2..6f8a6ec0 100644 --- a/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php +++ b/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php @@ -38,7 +38,7 @@ use SP\Storage\Database\QueryData; * * @package SP\Services\Upgrade */ -class UpgradeCustomFieldData extends Service +final class UpgradeCustomFieldData extends Service { /** * @var Database diff --git a/lib/SP/Util/Wiki/DokuWikiApi.php b/lib/SP/Services/Wiki/DokuWikiApi.php similarity index 97% rename from lib/SP/Util/Wiki/DokuWikiApi.php rename to lib/SP/Services/Wiki/DokuWikiApi.php index 1cbbd947..d5886484 100644 --- a/lib/SP/Util/Wiki/DokuWikiApi.php +++ b/lib/SP/Services/Wiki/DokuWikiApi.php @@ -22,19 +22,17 @@ * along with sysPass. If not, see . */ -namespace SP\Util\Wiki; +namespace SP\Services\Wiki; use SP\Core\Exceptions\SPException; -use SP\Core\SessionFactory; -use SP\Log\Log; -use SP\Log\LogLevel; defined('APP_ROOT') || die(); /** * Class DokuWikiApi para realizar consultas a la API de DokuWiki * - * @package SP\Util\Wiki + * @package SP\Services\Wiki + * @deprecated */ class DokuWikiApi extends DokuWikiApiBase { @@ -76,7 +74,6 @@ class DokuWikiApi extends DokuWikiApiBase $this->logException($e); throw $e; } catch (\InvalidArgumentException $e) { - Log::writeNewLog('DokuWiki API', $e->getMessage(), LogLevel::ERROR); throw new SPException($e->getMessage(), SPException::WARNING); } } diff --git a/lib/SP/Util/Wiki/DokuWikiApiBase.php b/lib/SP/Services/Wiki/DokuWikiApiBase.php similarity index 97% rename from lib/SP/Util/Wiki/DokuWikiApiBase.php rename to lib/SP/Services/Wiki/DokuWikiApiBase.php index 622aea53..ddf35606 100644 --- a/lib/SP/Util/Wiki/DokuWikiApiBase.php +++ b/lib/SP/Services/Wiki/DokuWikiApiBase.php @@ -22,10 +22,9 @@ * along with sysPass. If not, see . */ -namespace SP\Util\Wiki; +namespace SP\Services\Wiki; use DOMDocument; -use DOMException; use SP\Config\Config; use SP\Config\ConfigData; use SP\Core\Exceptions\SPException; @@ -35,7 +34,8 @@ use SP\Util\Util; /** * Class DokuWikiApiBase * - * @package SP\Util\Wiki + * @package SP\Services\Wiki + * @deprecated */ abstract class DokuWikiApiBase { @@ -130,7 +130,7 @@ abstract class DokuWikiApiBase $this->params = $this->xml->createElement('params'); $this->root->appendChild($this->params); - } catch (DOMException $e) { + } catch (\Exception $e) { throw new SPException($e->getMessage(), SPException::WARNING, __FUNCTION__); } } @@ -158,13 +158,15 @@ abstract class DokuWikiApiBase $xmlParam->appendChild($xmlValue); $this->params->appendChild($xmlParam); - } catch (DOMException $e) { + } catch (\Exception $e) { throw new SPException($e->getMessage(), SPException::WARNING, __FUNCTION__); } } /** * Enviar el XML a la wiki y devolver la respuesta + * + * @throws SPException */ protected function callWiki() { diff --git a/lib/SP/Util/Wiki/DokuWikiApiParse.php b/lib/SP/Services/Wiki/DokuWikiApiParse.php similarity index 93% rename from lib/SP/Util/Wiki/DokuWikiApiParse.php rename to lib/SP/Services/Wiki/DokuWikiApiParse.php index 2687bafd..6bec7aad 100644 --- a/lib/SP/Util/Wiki/DokuWikiApiParse.php +++ b/lib/SP/Services/Wiki/DokuWikiApiParse.php @@ -22,14 +22,15 @@ * along with sysPass. If not, see . */ -namespace SP\Util\Wiki; +namespace SP\Services\Wiki; use SP\Http\XMLRPCResponseParse; /** * Class DokuWikiApiParse para el parseo de las respuestas de DokuWiki * - * @package SP\Util\Wiki + * @package SP\Services\Wiki + * @deprecated */ class DokuWikiApiParse extends XMLRPCResponseParse { diff --git a/lib/SP/Util/Util.php b/lib/SP/Util/Util.php index b3e71584..7c5c9a88 100644 --- a/lib/SP/Util/Util.php +++ b/lib/SP/Util/Util.php @@ -26,10 +26,6 @@ namespace SP\Util; use Defuse\Crypto\Core; use Defuse\Crypto\Encoding; -use SP\Bootstrap; -use SP\Config\ConfigData; -use SP\Core\Exceptions\SPException; -use SP\Core\PhpExtensionChecker; defined('APP_ROOT') || die(); @@ -125,102 +121,6 @@ final class Util return Encoding::binToHex(Core::secureRandom($length)); } - /** - * Obtener datos desde una URL usando CURL - * - * @param string $url - * @param array $data - * @param bool|null $useCookie - * @param bool $weak - * - * @return bool|string - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \Psr\Container\ContainerExceptionInterface - * - * TODO: Use Guzzle - * - * @throws \SP\Core\Exceptions\CheckException - * @throws SPException - */ - public static function getDataFromUrl($url, array $data = null, $useCookie = false, $weak = false) - { - /** @var ConfigData $ConfigData */ - $ConfigData = Bootstrap::getContainer()->get(ConfigData::class); - - Bootstrap::getContainer()->get(PhpExtensionChecker::class)->checkCurlAvailable(true); - - $ch = curl_init($url); - - if ($ConfigData->isProxyEnabled()) { - curl_setopt($ch, CURLOPT_PROXY, $ConfigData->getProxyServer()); - curl_setopt($ch, CURLOPT_PROXYPORT, $ConfigData->getProxyPort()); - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - - $proxyUser = $ConfigData->getProxyUser(); - - if ($proxyUser) { - $proxyAuth = $proxyUser . ':' . $ConfigData->getProxyPass(); - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth); - } - } - - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLINFO_HEADER_OUT, true); - curl_setopt($ch, CURLOPT_USERAGENT, 'sysPass-App'); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($ch, CURLOPT_TIMEOUT, 60); - - if ($weak === true) { - // Trust SSL enabled server - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - } - - if (null !== $data) { - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_HTTPHEADER, $data['type']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data['data']); - } - - if ($useCookie) { - $cookie = self::getUserCookieFile(); - - if ($cookie) { - if (!SessionFactory::getCurlCookieSession()) { - curl_setopt($ch, CURLOPT_COOKIESESSION, true); - curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); - - SessionFactory::setCurlCookieSession(true); - } - - curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); - } - } - - $data = curl_exec($ch); - - $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - if ($data === false || $httpStatus !== 200) { - throw new SPException(curl_error($ch), SPException::WARNING); - } - - return $data; - } - - /** - * Devuelve el nombre de archivo a utilizar para las cookies del usuario - * - * @return string|false - */ - public static function getUserCookieFile() - { - $tempDir = self::getTempDir(); - - return $tempDir ? $tempDir . DIRECTORY_SEPARATOR . md5('syspass-' . SessionFactory::getUserData()->getLogin()) : false; - } - /** * Comprueba y devuelve un directorio temporal válido * @@ -253,35 +153,6 @@ final class Util return $checkDir($sysTmp); } - /** - * Devuelve información sobre la aplicación. - * - * @param string $index con la key a devolver - * - * @return array|string con las propiedades de la aplicación - */ - public static function getAppInfo($index = null) - { - $appinfo = [ - 'appname' => 'sysPass', - 'appdesc' => 'Systems Password Manager', - 'appalias' => 'SPM', - 'appwebsite' => 'https://www.syspass.org', - 'appblog' => 'https://www.cygnux.org', - 'appdoc' => 'https://doc.syspass.org', - 'appupdates' => 'https://api.github.com/repos/nuxsmin/sysPass/releases/latest', - 'appnotices' => 'https://api.github.com/repos/nuxsmin/sysPass/issues?milestone=none&state=open&labels=Notices', - 'apphelp' => 'https://github.com/nuxsmin/sysPass/issues', - 'appchangelog' => 'https://github.com/nuxsmin/sysPass/blob/master/CHANGELOG' - ]; - - if (null !== $index && isset($appinfo[$index])) { - return $appinfo[$index]; - } - - return $appinfo; - } - /** * Realiza el proceso de logout. * diff --git a/lib/SP/Util/Version.php b/lib/SP/Util/Version.php index 22bee5f0..72e19ba5 100644 --- a/lib/SP/Util/Version.php +++ b/lib/SP/Util/Version.php @@ -31,9 +31,8 @@ use SP\Services\Install\Installer; * * @package SP\Util */ -class Version +final class Version { - /** * Devolver versión normalizada en cadena * diff --git a/tests/res/config/config.xml b/tests/res/config/config.xml index 7b759de1..0131c0ac 100644 --- a/tests/res/config/config.xml +++ b/tests/res/config/config.xml @@ -9,11 +9,11 @@ 1 1 - 31886087e728255b01dbce0c08ff2e54b5b633e2 + 998778b76a94725b950613dbf4cc45a81acd0fc2 0 0 - 1538352842 - c82c662c26a397798f8bf984cf5492c890571974 + 1538433038 + ce2dd4ecc25c80c9a1fbdbaf4f932a1f6d1be7de @@ -32,7 +32,7 @@ 0 - aab488455bd1e70816a491b44b1be68f34e79618 + 5befe3b5fbc6188557ca44037ebaf5071842875a PDF JPG