diff --git a/plugins/baser-core/src/Middleware/BcCacheDispatcher.php b/__assets/plugins/baser-core/src/Middleware/BcCacheDispatcher.php similarity index 97% rename from plugins/baser-core/src/Middleware/BcCacheDispatcher.php rename to __assets/plugins/baser-core/src/Middleware/BcCacheDispatcher.php index 7c7afbc0d9..80802af9c6 100644 --- a/plugins/baser-core/src/Middleware/BcCacheDispatcher.php +++ b/__assets/plugins/baser-core/src/Middleware/BcCacheDispatcher.php @@ -9,8 +9,10 @@ * @license https://basercms.net/license/index.html MIT License */ -namespace BaserCore\Middleware; +namespace Middleware; +use BaserCore\Middleware\Configure; +use BaserCore\Middleware\View; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; diff --git a/plugins/baser-core/src/Command/ComposerCommand.php b/plugins/baser-core/src/Command/ComposerCommand.php index 6386c9629b..e981d808be 100644 --- a/plugins/baser-core/src/Command/ComposerCommand.php +++ b/plugins/baser-core/src/Command/ComposerCommand.php @@ -28,6 +28,8 @@ class ComposerCommand extends Command * * @param \Cake\Console\ConsoleOptionParser $parser * @return \Cake\Console\ConsoleOptionParser + * @checked + * @noTodo */ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): \Cake\Console\ConsoleOptionParser { @@ -49,6 +51,8 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): * @param Arguments $args * @param ConsoleIo $io * @return int|void|null + * @checked + * @noTodo */ public function execute(Arguments $args, ConsoleIo $io) { diff --git a/plugins/baser-core/src/Command/CreateReleaseCommand.php b/plugins/baser-core/src/Command/CreateReleaseCommand.php index c781310ab1..164ae29cde 100644 --- a/plugins/baser-core/src/Command/CreateReleaseCommand.php +++ b/plugins/baser-core/src/Command/CreateReleaseCommand.php @@ -33,6 +33,8 @@ class CreateReleaseCommand extends Command * * @param \Cake\Console\ConsoleOptionParser $parser * @return \Cake\Console\ConsoleOptionParser + * @checked + * @noTodo */ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): \Cake\Console\ConsoleOptionParser { @@ -50,6 +52,8 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): * @param Arguments $args * @param ConsoleIo $io * @return int|void|null + * @checked + * @noTodo */ public function execute(Arguments $args, ConsoleIo $io) { @@ -89,6 +93,8 @@ public function execute(Arguments $args, ConsoleIo $io) * composer.json を配布用にセットアップする * * @param string $packagePath + * @checked + * @noTodo */ public function setupComposer(string $packagePath) { @@ -108,6 +114,8 @@ public function setupComposer(string $packagePath) * パッケージを GitHub よりクローンする * * @param string $packagePath + * @checked + * @noTodo */ public function clonePackage(string $packagePath, string $branch) { @@ -122,6 +130,8 @@ public function clonePackage(string $packagePath, string $branch) * * インストール時、 composer で vendor に配置するため * @param string $packagePath + * @checked + * @noTodo */ public function deletePlugins(string $packagePath) { @@ -139,6 +149,8 @@ public function deletePlugins(string $packagePath) * Zip ファイルに固める * * @param string $packagePath + * @checked + * @noTodo */ public function createZip(string $packagePath) { @@ -154,6 +166,8 @@ public function createZip(string $packagePath) * 配布用に不要なファイルを削除する * * @param string $packagePath + * @checked + * @noTodo */ public function deleteExcludeFiles(string $packagePath) { diff --git a/plugins/baser-core/src/Command/SetupInstallCommand.php b/plugins/baser-core/src/Command/SetupInstallCommand.php index eeefb094c1..40e972a283 100644 --- a/plugins/baser-core/src/Command/SetupInstallCommand.php +++ b/plugins/baser-core/src/Command/SetupInstallCommand.php @@ -35,6 +35,8 @@ class SetupInstallCommand extends Command * @param Arguments $args * @param ConsoleIo $io * @return int|void|null + * @checked + * @noTodo */ public function execute(Arguments $args, ConsoleIo $io) { diff --git a/plugins/baser-core/src/Command/SetupTestCommand.php b/plugins/baser-core/src/Command/SetupTestCommand.php index 7b36131b98..682c27b4c4 100644 --- a/plugins/baser-core/src/Command/SetupTestCommand.php +++ b/plugins/baser-core/src/Command/SetupTestCommand.php @@ -34,6 +34,8 @@ class SetupTestCommand extends Command * @param Arguments $args * @param ConsoleIo $io * @return int|void|null + * @checked + * @noTodo */ public function execute(Arguments $args, ConsoleIo $io) { diff --git a/plugins/baser-core/src/Command/UpdateCommand.php b/plugins/baser-core/src/Command/UpdateCommand.php index 84c2dc2b96..2d7dd34c1d 100644 --- a/plugins/baser-core/src/Command/UpdateCommand.php +++ b/plugins/baser-core/src/Command/UpdateCommand.php @@ -37,6 +37,8 @@ class UpdateCommand extends Command * * @param \Cake\Console\ConsoleOptionParser $parser * @return \Cake\Console\ConsoleOptionParser + * @checked + * @noTodo */ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): \Cake\Console\ConsoleOptionParser { @@ -53,6 +55,8 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): * @param Arguments $args * @param ConsoleIo $io * @return int|void|null + * @checked + * @noTodo */ public function execute(Arguments $args, ConsoleIo $io) { diff --git a/plugins/baser-core/src/Controller/Admin/BcAdminAppController.php b/plugins/baser-core/src/Controller/Admin/BcAdminAppController.php index e473aa4935..e9aefeba3d 100644 --- a/plugins/baser-core/src/Controller/Admin/BcAdminAppController.php +++ b/plugins/baser-core/src/Controller/Admin/BcAdminAppController.php @@ -62,6 +62,8 @@ public function initialize(): void * Before Filter * @param EventInterface $event * @return Response|void|null + * @checked + * @noTodo */ public function beforeFilter(EventInterface $event) { @@ -109,6 +111,8 @@ public function beforeRender(EventInterface $event): void * 初回アクセスメッセージ用のフラグを更新する * * @return void + * @checked + * @noTodo */ private function __updateFirstAccess() { diff --git a/plugins/baser-core/src/Controller/Api/Admin/BcAdminApiController.php b/plugins/baser-core/src/Controller/Api/Admin/BcAdminApiController.php index 402d9c02ba..e15b64c099 100644 --- a/plugins/baser-core/src/Controller/Api/Admin/BcAdminApiController.php +++ b/plugins/baser-core/src/Controller/Api/Admin/BcAdminApiController.php @@ -112,6 +112,8 @@ public function isAdminApiEnabled() * ない場合は、 true を返却する * * @return bool + * @noTodo + * @checked */ public function isAvailableUser(): bool { diff --git a/plugins/baser-core/src/Controller/Api/Admin/ContentsController.php b/plugins/baser-core/src/Controller/Api/Admin/ContentsController.php index 7478174c74..f8ade3d48d 100644 --- a/plugins/baser-core/src/Controller/Api/Admin/ContentsController.php +++ b/plugins/baser-core/src/Controller/Api/Admin/ContentsController.php @@ -119,6 +119,8 @@ public function index(ContentsServiceInterface $service) * * @param ContentsService $service * @return void + * @checked + * @noTodo */ public function index_trash(ContentsServiceInterface $service) { diff --git a/plugins/baser-core/src/Controller/Api/Admin/JwksController.php b/plugins/baser-core/src/Controller/Api/Admin/JwksController.php index 5b1e2c2af8..8db33f1e8c 100644 --- a/plugins/baser-core/src/Controller/Api/Admin/JwksController.php +++ b/plugins/baser-core/src/Controller/Api/Admin/JwksController.php @@ -25,6 +25,8 @@ class JwksController extends BcAdminApiController /** * Initialize + * @checked + * @noTodo */ public function initialize(): void { @@ -37,6 +39,8 @@ public function initialize(): void * * # PHPでの検証コード例 * JWT::decode($jwt, JWK::parseKeySet($keys), [Configure::read('Jwt.algorithm')]) + * @checked + * @noTodo */ public function index() { diff --git a/plugins/baser-core/src/Controller/Api/Admin/PluginsController.php b/plugins/baser-core/src/Controller/Api/Admin/PluginsController.php index 72d4713a12..a281ede698 100644 --- a/plugins/baser-core/src/Controller/Api/Admin/PluginsController.php +++ b/plugins/baser-core/src/Controller/Api/Admin/PluginsController.php @@ -368,6 +368,8 @@ public function batch(PluginsServiceInterface $service) * 取得可能なコアのバージョン情報を取得 * * @param PluginsServiceInterface $service + * @checked + * @noTodo */ public function get_available_core_version_info(PluginsServiceInterface $service) { diff --git a/plugins/baser-core/src/Controller/Api/Admin/SiteConfigsController.php b/plugins/baser-core/src/Controller/Api/Admin/SiteConfigsController.php index 29d4d36083..cd915e09a0 100644 --- a/plugins/baser-core/src/Controller/Api/Admin/SiteConfigsController.php +++ b/plugins/baser-core/src/Controller/Api/Admin/SiteConfigsController.php @@ -42,6 +42,8 @@ public function view(SiteConfigsServiceInterface $service) { /** * システム基本設定を編集する * @param SiteConfigsServiceInterface $service + * @checked + * @noTodo */ public function edit(SiteConfigsServiceInterface $service) { diff --git a/plugins/baser-core/src/Controller/Api/Admin/ThemesController.php b/plugins/baser-core/src/Controller/Api/Admin/ThemesController.php index f6dab7c94b..bc7d0ce76a 100644 --- a/plugins/baser-core/src/Controller/Api/Admin/ThemesController.php +++ b/plugins/baser-core/src/Controller/Api/Admin/ThemesController.php @@ -165,6 +165,7 @@ public function copy(ThemesServiceInterface $service, $theme) * [API] テーマの初期データを読み込むAPIを実装 * @param ThemesServiceInterface $service * @noTodo + * @checked */ public function load_default_data(ThemesServiceInterface $service) { diff --git a/plugins/baser-core/src/Controller/AppController.php b/plugins/baser-core/src/Controller/AppController.php index ee41fbf07a..cec02db8f7 100644 --- a/plugins/baser-core/src/Controller/AppController.php +++ b/plugins/baser-core/src/Controller/AppController.php @@ -194,6 +194,8 @@ public function beforeFilter(EventInterface $event) * 現在アクセスしているURLについて権限があるかどうかを確認する。 * * @return bool + * @noTodo + * @checked */ private function checkPermission() { diff --git a/plugins/baser-core/src/Controller/BcAppController.php b/plugins/baser-core/src/Controller/BcAppController.php index 5883d05eda..36159dc980 100644 --- a/plugins/baser-core/src/Controller/BcAppController.php +++ b/plugins/baser-core/src/Controller/BcAppController.php @@ -11,15 +11,8 @@ namespace BaserCore\Controller; -use BaserCore\Event\BcShortCodeEventListener; -use BaserCore\Service\SiteConfigsService; -use BaserCore\Service\SiteConfigsServiceInterface; use BaserCore\Utility\BcContainerTrait; -use BaserCore\Utility\BcSiteConfig; -use Cake\Core\Exception\Exception; use Cake\Event\EventInterface; -use Cake\Http\Exception\NotFoundException; -use Cake\Http\Response; use BaserCore\Utility\BcUtil; use BaserCore\Service\DblogsServiceInterface; use Cake\Core\Configure; @@ -212,454 +205,6 @@ private function __loadDataToView() $this->set('currentUserAuthPrefixes', $currentUserAuthPrefixes); } - /** - * CakePHPのバージョンを取得する - * - * @return string Baserバージョン - */ - protected function getCakeVersion() - { - $versionFile = new File(CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'VERSION.txt'); - $versionData = $versionFile->read(); - $lines = explode("\n", $versionData); - $version = null; - foreach($lines as $line) { - if (preg_match('/^([0-9.]+)$/', $line, $matches)) { - $version = $matches[1]; - break; - } - } - if (!$version) { - return false; - } - return $version; - } - - /** - * メールを送信する - * - * @param string $to 送信先アドレス - * @param string $title タイトル - * @param mixed $body 本文 - * @param array $options オプション - * - bool agentTemplate : テンプレートの配置場所についてサイト名をサブフォルダとして利用するかどうか(初期値:true) - * @return bool 送信結果 - */ - public function sendMail($to, $title = '', $body = '', $options = []) - { - $dbg = debug_backtrace(); - if (!empty($dbg[1]['function']) && $dbg[1]['function'] === 'invokeArgs') { - $this->notFound(); - } - $options = array_merge([ - 'agentTemplate' => true, - 'template' => 'default' - ], $options); - - // EVENT PluginName.ControllerName.beforeSendEmail - $event = $this->dispatchLayerEvent('beforeSendMail', [ - 'options' => $options - ]); - if ($event !== false) { - $this->request = $this->request->withParsedBody($event->getResult() === true? $event->getData('data') : $event->getResult()); - if (!empty($event->getData('options'))) { - $options = $event->getData('options'); - } - } - - if (BcSiteConfig::get('smtp_host')) { - $transport = 'Smtp'; - $host = BcSiteConfig::get('smtp_host'); - $port = (BcSiteConfig::get('smtp_port'))? BcSiteConfig::get('smtp_port') : 25; - $username = (BcSiteConfig::get('smtp_user'))? BcSiteConfig::get('smtp_user') : null; - $password = (BcSiteConfig::get('smtp_password'))? BcSiteConfig::get('smtp_password') : null; - $tls = BcSiteConfig::get('smtp_tls') && (BcSiteConfig::get('smtp_tls') == 1); - } else { - $transport = 'Mail'; - $host = 'localhost'; - $port = 25; - $username = null; - $password = null; - $tls = null; - } - - $config = [ - 'transport' => $transport, - 'host' => $host, - 'port' => $port, - 'username' => $username, - 'password' => $password, - 'tls' => $tls - ]; - - /** - * CakeEmailでは、return-path の正しい設定のためには additionalParameters を設定する必要がある - * @url http://norm-nois.com/blog/archives/2865 - */ - if (!BcSiteConfig::get('mail_additional_parameters')) { - $config = Hash::merge($config, ['additionalParameters' => BcSiteConfig::get('mail_additional_parameters')]); - } - if (!empty($options['additionalParameters'])) { - $config = Hash::merge($config, ['additionalParameters' => $options['additionalParameters']]); - } - $cakeEmail = new CakeEmail($config); - - //$format - if (!empty($options['format'])) { - $cakeEmail->emailFormat($options['format']); - } else { - $cakeEmail->emailFormat('text'); - } - - //bcc 'mail@example.com,mail2@example.com' - if (!empty($options['bcc'])) { - // 文字列の場合 - $bcc = []; - if (is_string($options['bcc'])) { - if (strpos($options['bcc'], ',') !== false) { - $bcc = explode(',', $options['bcc']); - } else { - $bcc[] = $options['bcc']; - } - // 配列の場合 - } elseif (is_array($options['bcc'])) { - $bcc = $options['bcc']; - } - foreach($bcc as $val) { - if (Validation::email(trim($val))) { - $cakeEmail->addBcc(trim($val)); - } - } - unset($bcc); - } - - //cc 'mail@example.com,mail2@example.com' - if (!empty($options['cc'])) { - // 文字列の場合 - $cc = []; - if (is_string($options['cc'])) { - if (strpos($options['cc'], ',') !== false) { - $cc = explode(',', $options['cc']); - } else { - $cc[] = $options['cc']; - } - // 配列の場合 - } elseif (is_array($options['cc'])) { - $cc = $options['cc']; - } - foreach($cc as $val) { - if (Validation::email(trim($val))) { - $cakeEmail->addCc($val); - } - } - unset($cc); - } - - $toAddress = null; - try { - // to 送信先アドレス (最初の1人がTOで残りがBCC) - if (strpos($to, ',') !== false) { - $_to = explode(',', $to); - $i = 0; - if (count($_to) >= 1) { - foreach($_to as $val) { - if ($i == 0) { - $cakeEmail->addTo($val); - $toAddress = $val; - } else { - $cakeEmail->addBcc($val); - } - ++$i; - } - } - } else { - $cakeEmail->addTo($to); - } - } catch (Exception $e) { - $this->BcMessage->setError($e->getMessage() . ' ' . __d('baser_core', '送信先のメールアドレスが不正です。')); - return false; - } - - // 件名 - $cakeEmail->subject($title); - - //From - $from = ''; - if (!empty($options['from'])) { - $from = $options['from']; - } else { - if (BcSiteConfig::get('email')) { - $from = BcSiteConfig::get('email'); - if (strpos($from, ',') !== false) { - $from = explode(',', $from); - } - } else { - $from = $toAddress; - } - } - - if (!empty($options['fromName'])) { - $fromName = $options['fromName']; - } else { - if (!empty(BcSiteConfig::get('formal_name'))) { - $fromName = BcSiteConfig::get('formal_name'); - } else { - $fromName = Configure::read('BcApp.title'); - } - } - - try { - $cakeEmail->from($from, $fromName); - } catch (Exception $e) { - $this->BcMessage->setError($e->getMessage() . ' ' . __d('baser_core', '送信元のメールアドレスが不正です。')); - return false; - } - - //Reply-To - if (!empty($options['replyTo'])) { - $replyTo = $options['replyTo']; - } else { - $replyTo = $from; - } - $cakeEmail->replyTo($replyTo); - - //Return-Path - if (!empty($options['returnPath'])) { - $returnPath = $options['returnPath']; - $cakeEmail->returnPath($returnPath); - } - - //$sender - if (!empty($options['sender'])) { - $cakeEmail->sender($options['sender']); - } - - //$theme - if ($this->theme) { - $cakeEmail->theme($this->theme); - } - if (!empty($options['theme'])) { - $cakeEmail->theme($options['theme']); - } - - //viewRender (利用するviewクラスを設定する) - $cakeEmail->viewRender('BcApp'); - - //template - if (!empty($options['template'])) { - - $subDir = $plugin = ''; - // インストール時にSiteは参照できない - if ($options['agentTemplate'] && !empty($this->request->getAttribute('currentSite')->name)) { - $subDir = $this->request->getAttribute('currentSite')->name; - } - - [$plugin, $template] = pluginSplit($options['template']); - - if ($subDir) { - $template = "{$subDir}/{$template}"; - } - - if (!empty($plugin)) { - $template = "{$plugin}.{$template}"; - } - - if (!empty($options['layout'])) { - $cakeEmail->template($template, $options['layout']); - } else { - $cakeEmail->template($template); - } - $content = ''; - if (is_array($body)) { - $cakeEmail->viewVars($body); - } else { - $cakeEmail->viewVars(['body' => $body]); - } - } else { - $content = $body; - } - - // $attachments tmp file path - $attachments = []; - if (!empty($options['attachments'])) { - if (!is_array($options['attachments'])) { - $attachments = [$options['attachments']]; - } else { - $attachments = $options['attachments']; - } - } - $cakeEmail->attachments($attachments); - - try { - $cakeEmail->send($content); - return true; - } catch (Exception $e) { - $this->log($e->getMessage()); - return false; - } - } - - /** - * Select Text 用の条件を生成する - * - * @param string $fieldName フィールド名 - * @param mixed $values 値 - * @param array $options オプション - * @return array - */ - protected function convertSelectTextCondition($fieldName, $values, $options = []) - { - $_options = ['type' => 'string', 'conditionType' => 'or']; - $options = am($_options, $options); - $conditions = []; - - if ($options['type'] === 'string' && !is_array($values)) { - $values = explode(',', str_replace('\'', '', $values)); - } - if (!empty($values) && is_array($values)) { - foreach($values as $value) { - $conditions[$options['conditionType']][] = [$fieldName . ' LIKE' => "%'" . $value . "'%"]; - } - } - return $conditions; - } - - /** - * BETWEEN 条件を生成 - * - * @param string $fieldName フィールド名 - * @param mixed $value 値 - * @return array - */ - protected function convertBetweenCondition($fieldName, $value) - { - if (strpos($value, '-') === false) { - return false; - } - [$start, $end] = explode('-', $value); - if (!$start) { - $conditions[$fieldName . ' <='] = $end; - } elseif (!$end) { - $conditions[$fieldName . ' >='] = $start; - } else { - $conditions[$fieldName . ' BETWEEN ? AND ?'] = [$start, $end]; - } - return $conditions; - } - - /** - * ランダムなパスワード文字列を生成する - * - * @param int $len 文字列の長さ - * @return string パスワード - */ - protected function generatePassword($len = 8) - { - srand((double)microtime() * 1000000); - $seed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - $password = ""; - while($len--) { - $pos = rand(0, 61); - $password .= $seed[$pos]; - } - return $password; - } - - /** - * 認証完了後処理 - * - * @param array $user 認証されたユーザー情報 - * @return bool - */ - public function isAuthorized($user) - { - - if (!isset($user['UserGroup']['auth_prefix'])) { - return true; - } - $authPrefix = explode(',', $user['UserGroup']['auth_prefix']); - if (!empty($this->request->getParam('prefix'))) { - $currentPrefix = $this->request->getParam('prefix'); - } else { - $currentPrefix = 'front'; - } - return (in_array($currentPrefix, $authPrefix)); - - } - - /** - * リクエストされた画面に対しての認証用ユーザーモデルを取得する - * - * @return mixed string Or false - */ - protected function getUserModel() - { - if (!isset($this->BcAuth)) { - return false; - } - if (!isset($this->BcAuth->authenticate['Form']['userModel'])) { - return false; - } - - return $this->BcAuth->authenticate['Form']['userModel']; - } - - /** - * Calls a controller's method from any location. - * - * @param mixed $url String or array-based url. - * @param array $extra if array includes the key "return" it sets the AutoRender to true. - * @return mixed Boolean true or false on success/failure, or contents - * of rendered action if 'return' is set in $extra. - */ - public function requestAction($url, $extra = []) - { - // >>> CUSTOMIZE ADD 2011/12/16 ryuring - // 管理システムやプラグインでのURLの生成が CakePHP の標準仕様と違っていたので調整 - // >>> CUSTOMIZE MODIFY 2012/1/28 ryuring - // 配列でないURLの場合に、間違った値に書きなおされていたので配列チェックを追加 - if (is_array($url)) { - if ((!isset($url['admin']) && $this->request->getParam('prefix') === "Admin") || !empty($url['admin'])) { - $url['prefix'] = 'admin'; - } - if (!isset($url['plugin']) && !empty($this->request->getParam('plugin'))) { - $url['plugin'] = $this->request->getParam('plugin'); - } - } - // <<< - return parent::requestAction($url, $extra); - } - - /** - * Internally redirects one action to another. Examples: - * - * setAction('another_action'); - * setAction('action_with_parameters', $parameter1); - * - * @param string $action The new action to be redirected to - * @return mixed Returns the return value of the called action - */ - public function setAction(string $action, ...$args) - { - // CUSTOMIZE ADD 2012/04/22 ryuring - // >>> - $_action = $this->request->getParam('action'); - // <<< - - $this->request->withParam('action', $action); - $args = func_get_args(); - unset($args[0]); - - // CUSTOMIZE MODIFY 2012/04/22 ryuring - // >>> - //return call_user_func_array(array($this, $action), $args); - // --- - $return = call_user_func_array([$this, $action], $args); - $this->request->withParam('action', $_action); - return $return; - // <<< - } - /** * Ajax用のエラーを出力する * @@ -690,19 +235,6 @@ public function ajaxError($errorNo = 500, $message = '') return; } - /** - * リクエストメソッドとトークンをチェックする - * - * - GETでのアクセスの場合 not found - * - トークンが送信されていない場合 not found - */ - protected function _checkSubmitToken() - { - if (strtoupper($_SERVER['REQUEST_METHOD']) === 'GET' || empty($_POST['_Token']['key']) && empty($_POST['data']['_Token']['key'])) { - throw new NotFoundException(); - } - } - /** * データベースログを記録する * diff --git a/plugins/baser-core/src/Controller/MaintenanceController.php b/plugins/baser-core/src/Controller/MaintenanceController.php index 1753d45c28..6c4df6e568 100644 --- a/plugins/baser-core/src/Controller/MaintenanceController.php +++ b/plugins/baser-core/src/Controller/MaintenanceController.php @@ -19,6 +19,8 @@ class MaintenanceController extends BcFrontAppController /** * メンテナンス中ページを表示する + * @checked + * @noTodo */ public function index() { diff --git a/plugins/baser-core/src/Controller/UploadsController.php b/plugins/baser-core/src/Controller/UploadsController.php index 6d8f4b78f4..cd0e7f8370 100644 --- a/plugins/baser-core/src/Controller/UploadsController.php +++ b/plugins/baser-core/src/Controller/UploadsController.php @@ -29,6 +29,8 @@ class UploadsController extends AppController * セッションに保存した一時ファイルを出力する * @param string $name * @return \Cake\Http\Response + * @checked + * @noTodo */ public function tmp() { diff --git a/plugins/baser-core/src/Database/Migration/BcMigration.php b/plugins/baser-core/src/Database/Migration/BcMigration.php index 5857b7a83a..92c7e7c03c 100644 --- a/plugins/baser-core/src/Database/Migration/BcMigration.php +++ b/plugins/baser-core/src/Database/Migration/BcMigration.php @@ -14,6 +14,9 @@ use BaserCore\Utility\BcUtil; use Migrations\AbstractMigration; use Migrations\Table; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * BcMigration @@ -29,6 +32,8 @@ class BcMigration extends AbstractMigration * @param string $tableName Table Name * @param array $options Options * @return \Migrations\Table + * @checked + * @noTodo */ public function table(string $tableName, array $options = []): Table { diff --git a/plugins/baser-core/src/Database/Migration/BcSeed.php b/plugins/baser-core/src/Database/Migration/BcSeed.php index d1ac8141e6..b119e3a633 100644 --- a/plugins/baser-core/src/Database/Migration/BcSeed.php +++ b/plugins/baser-core/src/Database/Migration/BcSeed.php @@ -14,6 +14,9 @@ use BaserCore\Utility\BcUtil; use Migrations\AbstractSeed; use Phinx\Db\Table; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * BcSeed @@ -29,6 +32,8 @@ class BcSeed extends AbstractSeed * @param string $tableName * @param array $options * @return Table + * @checked + * @noTodo */ public function table(string $tableName, array $options = []): Table { diff --git a/plugins/baser-core/src/Database/Schema/BcSchema.php b/plugins/baser-core/src/Database/Schema/BcSchema.php index ab6532e2b8..9921acb628 100644 --- a/plugins/baser-core/src/Database/Schema/BcSchema.php +++ b/plugins/baser-core/src/Database/Schema/BcSchema.php @@ -64,6 +64,8 @@ public function __construct(string $table = '', array $columns = []) * テーブルをセットする * * @param string $table + * @checked + * @noTodo */ public function setTable(string $table) { diff --git a/plugins/baser-core/src/Error/BcFormFailedException.php b/plugins/baser-core/src/Error/BcFormFailedException.php index f15430c659..e8eb4784d0 100644 --- a/plugins/baser-core/src/Error/BcFormFailedException.php +++ b/plugins/baser-core/src/Error/BcFormFailedException.php @@ -40,6 +40,8 @@ class BcFormFailedException extends CakeException { * @param array|string $message * @param int|null $code * @param \Throwable|null $previous + * @checked + * @noTodo */ public function __construct(ValidatorAwareInterface $form, $message, ?int $code = null, ?Throwable $previous = null) { @@ -61,6 +63,8 @@ public function __construct(ValidatorAwareInterface $form, $message, ?int $code * フォームを取得する * * @return ValidatorAwareInterface + * @checked + * @noTodo */ public function getForm(): ValidatorAwareInterface { diff --git a/plugins/baser-core/src/Event/BcEventDispatcher.php b/plugins/baser-core/src/Event/BcEventDispatcher.php index 3f4655c05e..4007b637f1 100644 --- a/plugins/baser-core/src/Event/BcEventDispatcher.php +++ b/plugins/baser-core/src/Event/BcEventDispatcher.php @@ -40,6 +40,8 @@ class BcEventDispatcher * @param array $data * @param array $options * @return boolean|Event + * @checked + * @noTodo */ public static function dispatch($name, $subject, $data = [], $options = []) { diff --git a/plugins/baser-core/src/Event/BcEventListener.php b/plugins/baser-core/src/Event/BcEventListener.php index c345e172c7..f82fe28bc6 100644 --- a/plugins/baser-core/src/Event/BcEventListener.php +++ b/plugins/baser-core/src/Event/BcEventListener.php @@ -58,6 +58,8 @@ class BcEventListener implements EventListenerInterface /** * コンストラクタ + * @checked + * @noTodo */ public function __construct() { @@ -70,6 +72,8 @@ public function __construct() * implementedEvents * * @return array + * @checked + * @noTodo */ public function implementedEvents(): array { @@ -106,6 +110,8 @@ public function implementedEvents(): array * @param string $action アクションを特定する為の文字列 * @param bool $isContainController コントローラー名を含むかどうか(初期値:true) * @return bool + * @checked + * @noTodo */ public function isAction($action, $isContainController = true) { @@ -121,6 +127,8 @@ public function isAction($action, $isContainController = true) * * @param bool $isContainController コントローラー名を含むかどうか(初期値:true) * @return string + * @checked + * @noTodo */ public function getAction($isContainController = true) { diff --git a/plugins/baser-core/src/Event/BcShortCodeEventListener.php b/plugins/baser-core/src/Event/BcShortCodeEventListener.php index c6ebdbd280..a97f975872 100644 --- a/plugins/baser-core/src/Event/BcShortCodeEventListener.php +++ b/plugins/baser-core/src/Event/BcShortCodeEventListener.php @@ -29,6 +29,8 @@ class BcShortCodeEventListener implements EventListenerInterface * Implemented Events * * @return array + * @checked + * @noTodo */ public function implementedEvents(): array { @@ -41,6 +43,9 @@ public function implementedEvents(): array * After Render * * @param Event $event + * @return void + * @checked + * @noTodo */ public function afterRender(Event $event) { @@ -53,6 +58,9 @@ public function afterRender(Event $event) * ショートコードを実行する * * @param View $View + * @return void + * @checked + * @noTodo */ protected function _execShortCode(View $view) { diff --git a/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php b/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php index b6085af25d..52190c70e7 100644 --- a/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php +++ b/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php @@ -29,12 +29,14 @@ class PrefixOrmResolver extends OrmResolver implements ResolverInterface * @param array $conditions * @param string $type * @return array|EntityInterface|null + * @checked + * @noTodo */ public function find(array $conditions, $type = self::TYPE_AND) { $prefix = ''; - foreach ($conditions as $field => $value) { - if($field === 'id') { + foreach($conditions as $field => $value) { + if ($field === 'id') { [$prefix, $value] = explode('_', $value); $conditions[$field] = $value; } @@ -48,7 +50,7 @@ public function find(array $conditions, $type = self::TYPE_AND) $query = $table->query(); $finders = (array)$this->_config['finder']; - foreach ($finders as $finder => $options) { + foreach($finders as $finder => $options) { if (is_string($options)) { $query->find($options, ['prefix' => $prefix]); } else { @@ -57,7 +59,7 @@ public function find(array $conditions, $type = self::TYPE_AND) } $where = []; - foreach ($conditions as $field => $value) { + foreach($conditions as $field => $value) { $field = $table->aliasField($field); if (is_array($value)) { $field = $field . ' IN'; @@ -67,4 +69,5 @@ public function find(array $conditions, $type = self::TYPE_AND) return $query->where([$type => $where])->first(); } + } diff --git a/plugins/baser-core/src/Mailer/BcMailer.php b/plugins/baser-core/src/Mailer/BcMailer.php index 71ef7818b6..e12a713187 100644 --- a/plugins/baser-core/src/Mailer/BcMailer.php +++ b/plugins/baser-core/src/Mailer/BcMailer.php @@ -22,7 +22,7 @@ /** * Class BcMailer -*/ + */ class BcMailer extends Mailer { @@ -43,6 +43,8 @@ class BcMailer extends Mailer * Constructor * * @param null $config + * @checked + * @noTodo */ public function __construct($config = null) { @@ -61,6 +63,8 @@ public function __construct($config = null) /** * Emailのトランスポート設定を行う * @return void + * @checked + * @noTodo */ public function setEmailTransport() { @@ -96,6 +100,8 @@ public function setEmailTransport() * プラグイン名取得 * * @return string + * @checked + * @noTodo */ public function getPlugin(): ?string { @@ -108,10 +114,13 @@ public function getPlugin(): ?string * @param string $content Content. * @return array * @psalm-return array{headers: string, message: string} + * @checked + * @noTodo */ public function deliver(string $content = '') { $this->dispatchLayerEvent('beforeDeliver'); return parent::deliver($content); } + } diff --git a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php index e9e31e5047..8d3d34caf7 100644 --- a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php +++ b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php @@ -8,6 +8,7 @@ * @since 5.0.0 * @license https://basercms.net/license/index.html MIT License */ + namespace BaserCore\Model\Behavior; use ArrayObject; @@ -43,7 +44,7 @@ class BcContentsBehavior extends Behavior /** * initialize - * @param array $config + * @param array $config * @return void * @checked * @noTodo @@ -54,15 +55,15 @@ public function initialize(array $config): void $this->table = $this->table(); $prefix = $this->table->getConnection()->config()['prefix']; $type = preg_replace('/^' . $prefix . '/', '', $this->table->getTable()); - if (!$this->table-> __isset('Contents')) { + if (!$this->table->__isset('Contents')) { $this->table->hasOne('Contents', ['className' => 'BaserCore.Contents']) - ->setForeignKey('entity_id') - ->setDependent(false) - ->setJoinType('INNER') - ->setConditions([ - 'Contents.type' => Inflector::classify($type), - 'Contents.alias_id IS' => null, - ]); + ->setForeignKey('entity_id') + ->setDependent(false) + ->setJoinType('INNER') + ->setConditions([ + 'Contents.type' => Inflector::classify($type), + 'Contents.alias_id IS' => null, + ]); } $this->Contents = $this->table->getAssociation('Contents'); } @@ -81,7 +82,7 @@ public function initialize(array $config): void */ public function afterMarshal(EventInterface $event, EntityInterface $entity, ArrayObject $data, ArrayObject $options) { - if($options['validate']) { + if ($options['validate']) { if (!isset($data['content'])) { $entity->setError('content', ['_required' => __d('baser_core', '関連するコンテンツがありません')]); } else { @@ -132,26 +133,4 @@ public function afterDelete(EventInterface $event, EntityInterface $entity, Arra } } - /** - * 公開されたコンテンツを取得する - * - * @param Model $model - * @param string $type - * @param array $query - * @return array|null - */ - public function findPublished(Model $model, $type = 'first', $query = []) - { - $conditionAllowPublish = $model->Content->getConditionAllowPublish(); - if (!empty($query['conditions'])) { - $query['conditions'] = array_merge( - $conditionAllowPublish, - $query['conditions'] - ); - } else { - $query['conditions'] = $conditionAllowPublish; - } - return $model->find($type, $query); - } - } diff --git a/plugins/baser-core/src/Model/Behavior/BcUploadBehavior.php b/plugins/baser-core/src/Model/Behavior/BcUploadBehavior.php index f89b32f631..41d394703b 100755 --- a/plugins/baser-core/src/Model/Behavior/BcUploadBehavior.php +++ b/plugins/baser-core/src/Model/Behavior/BcUploadBehavior.php @@ -139,6 +139,8 @@ public function beforeMarshal(EventInterface $event, ArrayObject $data) * @param EventInterface $event * @param EntityInterface $entity * @param ArrayObject $options + * @checked + * @noTodo */ public function afterMarshal(EventInterface $event, EntityInterface $entity, ArrayObject $options) { diff --git a/plugins/baser-core/src/Model/Entity/Permission.php b/plugins/baser-core/src/Model/Entity/Permission.php index c957087d77..b1c61389d4 100644 --- a/plugins/baser-core/src/Model/Entity/Permission.php +++ b/plugins/baser-core/src/Model/Entity/Permission.php @@ -16,6 +16,9 @@ use Cake\I18n\FrozenTime; use Cake\ORM\Entity; use Cake\ORM\TableRegistry; +use BaserCore\Annotation\UnitTest; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; /** * Class Permission @@ -59,15 +62,17 @@ class Permission extends Entity * アクセスルールグループタイプを取得 * * @return string|null + * @checked + * @noTodo */ protected function _getPermissionGroupType() { - if($this->permission_group_id) { + if ($this->permission_group_id) { $permissionGroupsTable = TableRegistry::getTableLocator()->get('BaserCore.PermissionGroups'); $entity = $permissionGroupsTable->find()->where(['id' => $this->permission_group_id])->first(); return $entity->type; } return isset($this->_fields['permission_group_type'])? $this->_fields['permission_group_type'] : null; } + } -?> diff --git a/plugins/baser-core/src/Model/Entity/Plugin.php b/plugins/baser-core/src/Model/Entity/Plugin.php index bb70b47cd2..02dfad0af7 100644 --- a/plugins/baser-core/src/Model/Entity/Plugin.php +++ b/plugins/baser-core/src/Model/Entity/Plugin.php @@ -16,6 +16,9 @@ use Cake\Core\Configure; use Cake\I18n\FrozenTime; use Cake\ORM\Entity; +use BaserCore\Annotation\UnitTest; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; /** * Class Plugin @@ -59,36 +62,67 @@ class Plugin extends Entity 'screenshot' => true ]; - public function isPlugin() + /** + * プラグインかどうか判定する + * @return bool + * @checked + * @noTodo + */ + public function isPlugin(): bool { return $this->hasType(['CorePlugin', 'Plugin']); } + /** + * コアプラグインかどうか判定する + * @return bool + * @checked + * @noTodo + */ public function isCorePlugin() { return ( - $this->hasType(['CorePlugin', 'Plugin'] && - in_array($this->name, Configure::read('BcApp.corePlugins'))) + $this->hasType(['CorePlugin', 'Plugin']) && + in_array($this->name, Configure::read('BcApp.corePlugins')) ); } + /** + * テーマかどうか判定する + * @return bool + * @checked + * @noTodo + */ public function isTheme() { return $this->hasType(['Theme']); } - public function isAdminTheme() + /** + * 管理画面用テーマかどうか判定する + * @return bool + * @checked + * @noTodo + */ + public function isAdminTheme(): bool { return $this->hasType(['AdminTheme']); } - public function hasType($types) + /** + * 指定したタイプを持っているかどうか判定する + * @param $types + * @return bool + * @checked + * @noTodo + */ + public function hasType(array|string $types): bool { $type = $this->type; - if(!$type) return false; - if(!is_array($type)) $type = [$type]; + if (!$type) return false; + if (!is_array($type)) $type = [$type]; foreach($type as $value) { - if(in_array($value, $types)) return true; + if (in_array($value, $types)) return true; } return false; } diff --git a/plugins/baser-core/src/Model/Entity/User.php b/plugins/baser-core/src/Model/Entity/User.php index 116aaf7c35..5cab089453 100644 --- a/plugins/baser-core/src/Model/Entity/User.php +++ b/plugins/baser-core/src/Model/Entity/User.php @@ -95,6 +95,8 @@ public function isAdmin() * スーパーユーザーかどうか判定する * * @return bool + * @checked + * @noTodo */ public function isSuper(): bool { @@ -107,6 +109,8 @@ public function isSuper(): bool * 利用可能条件 * - 自身がスーパーユーザーで対象がスーパーユーザーでない場合 * - 自身がシステム管理ユーザーで対象がシステム管理ユーザーでない場合 + * @checked + * @noTodo */ public function isAddableToAdminGroup(): bool { @@ -122,10 +126,12 @@ public function isAddableToAdminGroup(): bool * - 自身がシステム管理ユーザーで対象がシステム管理ユーザーでない場合 * @param EntityInterface|User $targetUser * @return bool + * @checked + * @noTodo */ public function isEnableLoginAgent(EntityInterface $targetUser): bool { - if(!$targetUser->status) return false; + if (!$targetUser->status) return false; return (($this->isSuper() && !$targetUser->isSuper()) || ($this->isAdmin() && !$targetUser->isAdmin())); } @@ -138,6 +144,8 @@ public function isEnableLoginAgent(EntityInterface $targetUser): bool * - 自身がシステム管理ユーザーで対象がシステム管理ユーザーでない場合 * @param EntityInterface|User $targetUser * @return bool + * @checked + * @noTodo */ public function isDeletableUser(EntityInterface $targetUser): bool { @@ -155,11 +163,13 @@ public function isDeletableUser(EntityInterface $targetUser): bool * * @param EntityInterface|User $targetUser * @return bool + * @checked + * @noTodo */ public function isEditableUser(EntityInterface $targetUser): bool { - if($this->isSuper()) return true; - if($this->id === $targetUser->id) return true; + if ($this->isSuper()) return true; + if ($this->id === $targetUser->id) return true; return !$targetUser->isAdmin(); } @@ -182,9 +192,9 @@ public function getDisplayName() if (!empty($this->real_name_2)) { $userName[] = $this->real_name_2; } - if(count($userName) > 1) { + if (count($userName) > 1) { return implode(' ', $userName); - } elseif(count($userName) === 1) { + } elseif (count($userName) === 1) { return $userName[0]; } else { return 'undefined'; diff --git a/plugins/baser-core/src/Model/Entity/UserGroup.php b/plugins/baser-core/src/Model/Entity/UserGroup.php index d840d0fddd..28bbe6a07e 100644 --- a/plugins/baser-core/src/Model/Entity/UserGroup.php +++ b/plugins/baser-core/src/Model/Entity/UserGroup.php @@ -48,6 +48,8 @@ class UserGroup extends Entity * 管理グループかどうか判定 * * @return bool + * @checked + * @noTodo */ public function isAdmin(): bool { @@ -76,7 +78,7 @@ public function isAuthPrefixAvailabled(string $prefix): bool */ public function getAuthPrefixArray(): array { - if($this->auth_prefix) { + if ($this->auth_prefix) { return explode(',', $this->auth_prefix); } else { return []; @@ -92,7 +94,7 @@ public function getAuthPrefixArray(): array */ public function getAuthPrefixSettingsArray(): array { - if($this->auth_prefix_settings) { + if ($this->auth_prefix_settings) { return json_decode($this->auth_prefix_settings, true); } else { return []; @@ -110,7 +112,7 @@ public function getAuthPrefixSettingsArray(): array public function getAuthPrefixSettings(string $prefix): array { $settings = $this->getAuthPrefixSettingsArray(); - if(isset($settings[$prefix])) { + if (isset($settings[$prefix])) { return $settings[$prefix]; } else { return []; @@ -129,7 +131,7 @@ public function getAuthPrefixSettings(string $prefix): array public function getAuthPrefixSetting(string $prefix, string $name): string { $settings = $this->getAuthPrefixSettings($prefix); - if(isset($settings[$name])) { + if (isset($settings[$name])) { return $settings[$name]; } else { return ''; diff --git a/plugins/baser-core/src/Model/Table/AppTable.php b/plugins/baser-core/src/Model/Table/AppTable.php index 14b750e3c8..a33e4900ee 100755 --- a/plugins/baser-core/src/Model/Table/AppTable.php +++ b/plugins/baser-core/src/Model/Table/AppTable.php @@ -105,7 +105,7 @@ public function getTable(): string */ public function belongsToMany(string $associated, array $options = []): BelongsToMany { - if(isset($options['joinTable'])) { + if (isset($options['joinTable'])) { $options['joinTable'] = $this->addPrefix($options['joinTable']); } return parent::belongsToMany($associated, $options); @@ -131,7 +131,7 @@ public function belongsToMany(string $associated, array $options = []): BelongsT public function addPrefix($table) { $prefix = BcUtil::getCurrentDbConfig()['prefix']; - if(!preg_match('/^' . $prefix . '/', $table)) { + if (!preg_match('/^' . $prefix . '/', $table)) { return $prefix . $table; } return $table; diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php index e54ba472d4..3a4d40acaa 100644 --- a/plugins/baser-core/src/Model/Table/ContentsTable.php +++ b/plugins/baser-core/src/Model/Table/ContentsTable.php @@ -36,8 +36,16 @@ */ class ContentsTable extends AppTable { + + /** + * Trait + */ use SoftDeleteTrait; + /** + * 論理削除フィールド名 + * @var string + */ protected $softDeleteField = 'deleted_date'; /** @@ -333,9 +341,9 @@ public function beforeMarshal(EventInterface $event, ArrayObject $content, Array if ($user) $content['author_id'] = $user['id']; } } else { - if (isset($content['name'])) { - $content['name'] = BcUtil::urlencode(mb_substr($content['name'], 0, 230, 'UTF-8')); - } + if (isset($content['name'])) { + $content['name'] = BcUtil::urlencode(mb_substr($content['name'], 0, 230, 'UTF-8')); + } if (!empty($content['self_publish_begin'])) { $content['self_publish_begin'] = new FrozenTime($content['self_publish_begin']); } @@ -981,7 +989,7 @@ protected function updateSystemData($content) if ($site->alias) { $prefix = $site->alias; } - if($prefix) { + if ($prefix) { $url = preg_replace('/^\/' . preg_quote($prefix, '/') . '\//', '/', $content->url); } $mainSitePrefix = $this->Sites->getPrefix($site->main_site_id); diff --git a/plugins/baser-core/src/Model/Validation/BcValidation.php b/plugins/baser-core/src/Model/Validation/BcValidation.php index f32e673a4c..7cd160082c 100644 --- a/plugins/baser-core/src/Model/Validation/BcValidation.php +++ b/plugins/baser-core/src/Model/Validation/BcValidation.php @@ -72,7 +72,7 @@ public static function alphaNumericPlus($value, $context = null) */ public static function alphaNumericDashUnderscore($value) { - return (bool) preg_match('|^[0-9a-zA-Z_-]*$|', $value); + return (bool)preg_match('|^[0-9a-zA-Z_-]*$|', $value); } /** @@ -224,8 +224,8 @@ public static function fileCheck($value, $size) return false; case 4: // UPLOAD_ERR_NO_FILE - Log::error(__d('baser_core', 'CODE: {0} ファイルがアップロードされませんでした。', $fileErrorCode)); - break; + Log::error(__d('baser_core', 'CODE: {0} ファイルがアップロードされませんでした。', $fileErrorCode)); + break; case 6: // UPLOAD_ERR_NO_TMP_DIR Log::error(__d('baser_core', 'CODE: {0} 一時書込み用のフォルダがありません。テンポラリフォルダの書込み権限を見直してください。', $fileErrorCode)); @@ -267,29 +267,29 @@ public static function fileCheck($value, $size) * @noTodo * @unitTest */ - public static function fileExt($file, $exts) - { - if (!is_array($exts)) { - $exts = explode(',', $exts); - } - - // FILES形式のチェック - if (!empty($file['name'])) { - $ext = BcUtil::decodeContent($file['type'], $file['name']); - if (!in_array($ext, $exts)) { - return false; - } - } - - // 更新時の文字列チェック - if (!empty($file) && is_string($file)) { - $ext = pathinfo($file, PATHINFO_EXTENSION); - if (!in_array($ext, $exts)) { - return false; - } - } - return true; - } + public static function fileExt($file, $exts) + { + if (!is_array($exts)) { + $exts = explode(',', $exts); + } + + // FILES形式のチェック + if (!empty($file['name'])) { + $ext = BcUtil::decodeContent($file['type'], $file['name']); + if (!in_array($ext, $exts)) { + return false; + } + } + + // 更新時の文字列チェック + if (!empty($file) && is_string($file)) { + $ext = pathinfo($file, PATHINFO_EXTENSION); + if (!in_array($ext, $exts)) { + return false; + } + } + return true; + } /** * ファイルが送信されたかチェックするバリデーション @@ -493,20 +493,20 @@ public static function checkDateAfterThan($fieldValue, $target, $context) */ public static function containsScript($value) { - if(!$value) return true; - $events = ['onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', - 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup', 'onload', 'onunload', - 'onfocus', 'onblur', 'onsubmit', 'onreset', 'onselect', 'onchange']; + if (!$value) return true; + $events = ['onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', + 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup', 'onload', 'onunload', + 'onfocus', 'onblur', 'onsubmit', 'onreset', 'onselect', 'onchange']; if (BcUtil::isAdminUser() || Configure::read('BcApp.allowedPhpOtherThanAdmins')) { return true; } if (preg_match('/(<\?=|<\?php|]+?(' . implode('|', $events) . ')\s*=[^<>]*?>/i', $value)) { + if (preg_match('/<[^>]+?(' . implode('|', $events) . ')\s*=[^<>]*?>/i', $value)) { return false; } - if (preg_match('/href\s*=\s*[^>]*?javascript\s*?:/i', $value)) { + if (preg_match('/href\s*=\s*[^>]*?javascript\s*?:/i', $value)) { return false; } return true; @@ -525,7 +525,7 @@ public static function containsScript($value) * 半角と全角のスペースを許容しない場合はvaliadtionのrule設定で空の文字列を渡す * 'rule' => ['checkKatakana', ''] */ - public static function checkKatakana($value, $addAllow = '\s ') : bool + public static function checkKatakana($value, $addAllow = '\s '): bool { if (!is_string($addAllow)) { $addAllow = '\s '; @@ -534,7 +534,7 @@ public static function checkKatakana($value, $addAllow = '\s ') : bool if ($value === '') { return true; } - if(preg_match("/^[ァ-ヾ" . $addAllow . "]+$/u", $value)){ + if (preg_match("/^[ァ-ヾ" . $addAllow . "]+$/u", $value)) { return true; } return false; @@ -554,7 +554,7 @@ public static function checkKatakana($value, $addAllow = '\s ') : bool * 'rule' => ['checkHiragana', ''] * */ - public static function checkHiragana($value, $addAllow = '\s ー') : bool + public static function checkHiragana($value, $addAllow = '\s ー'): bool { if (!is_string($addAllow)) { $addAllow = '\s ー'; @@ -563,7 +563,7 @@ public static function checkHiragana($value, $addAllow = '\s ー') : bool if ($value === '') { return true; } - if(preg_match("/^[ぁ-ゞ" . $addAllow . "]+$/u", $value)){ + if (preg_match("/^[ぁ-ゞ" . $addAllow . "]+$/u", $value)) { return true; } return false; @@ -574,10 +574,12 @@ public static function checkHiragana($value, $addAllow = '\s ー') : bool * * @param $value * @return bool + * @checked + * @noTodo */ public static function reserved($value): bool { - if(in_array($value, Configure::read('BcApp.reservedWords'))) { + if (in_array($value, Configure::read('BcApp.reservedWords'))) { return false; } return true; diff --git a/plugins/baser-core/src/Model/Validation/SiteConfigValidation.php b/plugins/baser-core/src/Model/Validation/SiteConfigValidation.php index 0ddec8d701..374a781b2f 100644 --- a/plugins/baser-core/src/Model/Validation/SiteConfigValidation.php +++ b/plugins/baser-core/src/Model/Validation/SiteConfigValidation.php @@ -26,6 +26,8 @@ class SiteConfigValidation extends Validation * SSL用のURLが設定されているかチェックする * @param mixed $check * @return boolean + * @checked + * @noTodo */ public static function sslUrlExists($adminSsl, $context) { diff --git a/plugins/baser-core/src/Routing/Route/BcContentsRoute.php b/plugins/baser-core/src/Routing/Route/BcContentsRoute.php index 892a200749..209630ff6b 100644 --- a/plugins/baser-core/src/Routing/Route/BcContentsRoute.php +++ b/plugins/baser-core/src/Routing/Route/BcContentsRoute.php @@ -139,6 +139,8 @@ public function parse($url, $method): ?array * @param $type * @param $entityId * @return mixed false|array + * @checked + * @noTodo */ public function getParams($requestUrl, $entryUrl, $plugin, $type, $entityId, $alias) { @@ -356,6 +358,8 @@ public function match($url, $context = []): string * @param array $params パラメーター * @param bool $useAction アクションを判定に入れるかどうか * @return bool|string + * @checked + * @noTodo */ protected function _getContentTypeByParams($params, $useAction = true) { diff --git a/plugins/baser-core/src/Service/Admin/DashboardAdminService.php b/plugins/baser-core/src/Service/Admin/DashboardAdminService.php index fc31e04ce4..03ff16a51d 100644 --- a/plugins/baser-core/src/Service/Admin/DashboardAdminService.php +++ b/plugins/baser-core/src/Service/Admin/DashboardAdminService.php @@ -52,6 +52,8 @@ public function getViewVarsForIndex(int $logNum): array /** * パネルを取得する * @return array + * @checked + * @noTodo */ public function getPanels() { diff --git a/plugins/baser-core/src/Service/Admin/PermissionsAdminService.php b/plugins/baser-core/src/Service/Admin/PermissionsAdminService.php index b046f26341..cb7f7d175b 100644 --- a/plugins/baser-core/src/Service/Admin/PermissionsAdminService.php +++ b/plugins/baser-core/src/Service/Admin/PermissionsAdminService.php @@ -37,10 +37,11 @@ class PermissionsAdminService extends PermissionsService implements PermissionsA * @param ServerRequest $request * @param int $userGroupId * @return array + * @checked + * @noTodo */ public function getViewVarsForIndex(ServerRequest $request, int $userGroupId) { - $userGroupsService = $this->getService(UserGroupsServiceInterface::class); /** @var PermissionGroupsService $permissionGroupsService */ $permissionGroupsService = $this->getService(PermissionGroupsServiceInterface::class); if($userGroupId) { @@ -62,6 +63,8 @@ public function getViewVarsForIndex(ServerRequest $request, int $userGroupId) * @param int $userGroupId * @param EntityInterface $entity * @return array + * @checked + * @noTodo */ public function getViewVarsForAdd(int $userGroupId, EntityInterface $entity) { @@ -85,6 +88,8 @@ public function getViewVarsForAdd(int $userGroupId, EntityInterface $entity) * @param int $userGroupId * @param EntityInterface $entity * @return array + * @checked + * @noTodo */ public function getViewVarsForEdit(int $userGroupId, EntityInterface $entity) { diff --git a/plugins/baser-core/src/Service/Admin/PluginsAdminService.php b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php index ae652a9a1d..ac15db5881 100644 --- a/plugins/baser-core/src/Service/Admin/PluginsAdminService.php +++ b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php @@ -102,6 +102,12 @@ public function getViewVarsForUpdate(EntityInterface $entity): array ]; } + /** + * CLI版PHPのパスを取得する + * @return mixed|string + * @checked + * @noTodo + */ public function whichPhp() { exec('which php', $out, $code); @@ -117,6 +123,8 @@ public function whichPhp() * @param string $availableVersion * @param int|false $scriptNum * @return bool + * @checked + * @noTodo */ public function isRequireUpdate(string $programVersion, ?string $dbVersion, ?string $availableVersion, $scriptNum) { diff --git a/plugins/baser-core/src/Service/BcCaptchaService.php b/plugins/baser-core/src/Service/BcCaptchaService.php index 69601d633a..fab9aa7ba7 100644 --- a/plugins/baser-core/src/Service/BcCaptchaService.php +++ b/plugins/baser-core/src/Service/BcCaptchaService.php @@ -13,6 +13,9 @@ use Cake\Http\ServerRequest; use KCAPTCHA; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * Class BcCaptchaService @@ -24,6 +27,8 @@ class BcCaptchaService implements BcCaptchaServiceInterface * キャプチャ画象を表示する * * @return void + * @checked + * @noTodo */ public function render(ServerRequest $request, string $token): void { @@ -38,6 +43,8 @@ public function render(ServerRequest $request, string $token): void * * @param string $value フォームから送信された文字列 * @return bool + * @checked + * @noTodo */ public function check(ServerRequest $request, string $token, string $value): bool { diff --git a/plugins/baser-core/src/Service/BcDatabaseService.php b/plugins/baser-core/src/Service/BcDatabaseService.php index bf7c706c6b..7eebe228bc 100644 --- a/plugins/baser-core/src/Service/BcDatabaseService.php +++ b/plugins/baser-core/src/Service/BcDatabaseService.php @@ -68,6 +68,8 @@ class BcDatabaseService implements BcDatabaseServiceInterface /** * Constructor + * @checked + * @noTodo */ public function __construct() { @@ -159,6 +161,8 @@ public function addColumn( * @param string $tableName * @param string $columnName * @return bool + * @checked + * @noTodo */ public function columnExists(string $tableName, string $columnName) { @@ -215,6 +219,8 @@ public function renameColumn( * @param string $tableName * @param array $columns * @return bool + * @checked + * @noTodo * @unitTest */ public function createTable(string $tableName, array $columns = []) @@ -240,6 +246,8 @@ public function createTable(string $tableName, array $columns = []) * @param string $oldTableName * @param string $newTableName * @return bool + * @checked + * @noTodo */ public function renameTable(string $oldTableName, string $newTableName) { @@ -275,6 +283,8 @@ public function tableExists(string $tableName): bool * * @param string $tableName * @return bool + * @checked + * @noTodo * @unitTest */ public function dropTable(string $tableName) @@ -631,6 +641,8 @@ public function initMessageTables(): bool /** * データベースシーケンスをアップデートする + * @checked + * @noTodo */ public function updateSequence() { @@ -648,6 +660,8 @@ public function updateSequence() /** * シーケンスを取得する + * @checked + * @noTodo */ public function getSequence($table, $field = 'id') { @@ -968,7 +982,7 @@ public function clearAppTableList(): void * @param array $options * - `path` : スキーマファイルの生成場所 * @return string|false スキーマファイルの内容 - * @unitTest + * @checked * @noTodo * @unitTest */ diff --git a/plugins/baser-core/src/Service/BcOfficialApiService.php b/plugins/baser-core/src/Service/BcOfficialApiService.php index 0e4b55a0fc..34d16119d0 100644 --- a/plugins/baser-core/src/Service/BcOfficialApiService.php +++ b/plugins/baser-core/src/Service/BcOfficialApiService.php @@ -11,11 +11,13 @@ namespace BaserCore\Service; -use BaserCore\Error\BcException; use Cake\Cache\Cache; use Cake\Core\Configure; use Cake\Http\Client; use Cake\Utility\Xml; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * interface BcOfficialApiService @@ -28,6 +30,8 @@ class BcOfficialApiService implements BcOfficialApiServiceInterface * * @param string $rssName * @return array|mixed + * @checked + * @noTodo */ public function getRss(string $rssName): array { diff --git a/plugins/baser-core/src/Service/PagesService.php b/plugins/baser-core/src/Service/PagesService.php index f11e1d016f..74a02bfa30 100644 --- a/plugins/baser-core/src/Service/PagesService.php +++ b/plugins/baser-core/src/Service/PagesService.php @@ -210,6 +210,8 @@ public function getIndex(array $queryParams = []): Query * @param Query $query * @param array $options * @return Query + * @checked + * @noTodo */ protected function createIndexConditions(Query $query, $options = []) { diff --git a/plugins/baser-core/src/Service/PermissionGroupsService.php b/plugins/baser-core/src/Service/PermissionGroupsService.php index e9239ce454..f89e904c83 100644 --- a/plugins/baser-core/src/Service/PermissionGroupsService.php +++ b/plugins/baser-core/src/Service/PermissionGroupsService.php @@ -83,6 +83,8 @@ public function get(int $id, int $userGroupId = null) * 初期データを取得 * * @return EntityInterface + * @checked + * @noTodo */ public function getNew(string $prefix) { @@ -97,6 +99,8 @@ public function getNew(string $prefix) * @param EntityInterface $entity * @param array $postData * @return EntityInterface + * @checked + * @noTodo */ public function create(array $postData) { @@ -125,9 +129,6 @@ public function update(EntityInterface $entity, array $postData) * * @param int $userGroupId * @param array $queryParams - * @noTodo - * @unitTest - * @checked * @return Query * @notodo * @unitTest @@ -162,6 +163,8 @@ public function getIndex(int $userGroupId, array $queryParams): Query * アクセスグループを削除する * * @param int $id + * @checked + * @noTodo */ public function delete(int $id): bool { @@ -225,6 +228,8 @@ public function buildByUserGroup(int $userGroupId) * * @param int $userGroupId * @return bool + * @checked + * @noTodo */ public function rebuildByUserGroup(int $userGroupId) { @@ -447,6 +452,8 @@ public function getControlSource(string $field, array $options = []): array * アクセスグループを利用可能なユーザーグループの最小のIDを取得する * * @return false|mixed + * @checked + * @noTodo */ public function getAvailableMinUserGroupId() { diff --git a/plugins/baser-core/src/Service/PermissionsService.php b/plugins/baser-core/src/Service/PermissionsService.php index 2c78a3d33a..6633c6994d 100644 --- a/plugins/baser-core/src/Service/PermissionsService.php +++ b/plugins/baser-core/src/Service/PermissionsService.php @@ -507,6 +507,9 @@ private function checkGroup( * @param string $method * @param array $groupPermission * @return bool + * @checked + * @noTodo + * @unitTest */ public function isAuthorized(int $permissionType, string $url, string $method, array $groupPermission) { diff --git a/plugins/baser-core/src/Service/PluginsService.php b/plugins/baser-core/src/Service/PluginsService.php index 5cd8643a8d..76486700eb 100644 --- a/plugins/baser-core/src/Service/PluginsService.php +++ b/plugins/baser-core/src/Service/PluginsService.php @@ -279,6 +279,8 @@ public function update($pluginName, $connection = 'default'): ?bool * @param string $currentVersion * @param string $targetVersion * @param string $connection + * @checked + * @noTodo */ public function updateCore(string $currentVersion, string $targetVersion, string $php, $connection = 'default') { @@ -676,6 +678,8 @@ public function add(array $postData) * @return array * - `latest`: 最新バージョン * - `versions`: 取得可能なコアのバージョンリスト + * @checked + * @noTodo */ public function getAvailableCoreVersionInfo() { @@ -741,6 +745,8 @@ public function getAvailableCoreVersionInfo() * 利用可能なコアの最新のバーションを取得 * * @return bool|mixed|string + * @checked + * @noTodo */ public function getAvailableCoreVersion() { @@ -752,6 +758,8 @@ public function getAvailableCoreVersion() * 利用可能なコアのバージョン群を取得 * * @return array|mixed + * @checked + * @noTodo */ public function isAvailableCoreUpdates() { diff --git a/plugins/baser-core/src/Service/SiteConfigsService.php b/plugins/baser-core/src/Service/SiteConfigsService.php index d9ec6ece1f..d37b4f6bce 100644 --- a/plugins/baser-core/src/Service/SiteConfigsService.php +++ b/plugins/baser-core/src/Service/SiteConfigsService.php @@ -274,6 +274,8 @@ public function clearCache() * @param string $body * @return void * @throws \Throwable + * @checked + * @noTodo */ public function sendTestMail(array $postData, string $email, string $subject, string $body) { diff --git a/plugins/baser-core/src/TestSuite/BcTestCase.php b/plugins/baser-core/src/TestSuite/BcTestCase.php index 9266b64efa..3a213a1ded 100644 --- a/plugins/baser-core/src/TestSuite/BcTestCase.php +++ b/plugins/baser-core/src/TestSuite/BcTestCase.php @@ -208,6 +208,8 @@ public function setUp(): void /** * クラスメソッド名を取得する + * @checked + * @noTodo */ public function classMethod() { diff --git a/plugins/baser-core/src/Utility/BcAbstractDetector.php b/plugins/baser-core/src/Utility/BcAbstractDetector.php index 81bd28f178..e5ca109bcc 100644 --- a/plugins/baser-core/src/Utility/BcAbstractDetector.php +++ b/plugins/baser-core/src/Utility/BcAbstractDetector.php @@ -12,6 +12,9 @@ namespace BaserCore\Utility; use Cake\Core\Configure; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * Class BcAbstractDetector @@ -57,6 +60,8 @@ abstract class BcAbstractDetector * * @param string $name 名前 * @param array $config 設定の配列 + * @checked + * @noTodo */ public function __construct($name, array $config) { @@ -70,6 +75,8 @@ public function __construct($name, array $config) * * @param string $name 名前 * @return BcAbstractDetector|null + * @checked + * @noTodo */ public static function find($name) { @@ -84,6 +91,8 @@ public static function find($name) * 設定ファイルに存在する全てのインスタンスを返す * * @return BcAbstractDetector[] + * @checked + * @noTodo */ public static function findAll() { @@ -105,6 +114,8 @@ public static function findAll() * 現在の環境の判定キーの値に合致するインスタンスを返す * * @return BcAbstractDetector|null + * @checked + * @noTodo */ public static function findCurrent() { @@ -121,6 +132,9 @@ public static function findCurrent() * デフォルトの設定値を取得 * * @return array + * @checked + * @noTodo + * @unitTest */ abstract protected function _getDefaultConfig(); @@ -129,6 +143,9 @@ abstract protected function _getDefaultConfig(); * * @param array $config 設定の配列 * @return void + * @checked + * @noTodo + * @unitTest */ abstract protected function _setConfig(array $config); @@ -136,6 +153,9 @@ abstract protected function _setConfig(array $config); * キーがキーワードを含むかどうかを判定 * * @return bool + * @checked + * @noTodo + * @unitTest */ abstract public function isMatchDecisionKey(); diff --git a/plugins/baser-core/src/Utility/BcComposer.php b/plugins/baser-core/src/Utility/BcComposer.php index fbafc153d6..ea19a2185d 100644 --- a/plugins/baser-core/src/Utility/BcComposer.php +++ b/plugins/baser-core/src/Utility/BcComposer.php @@ -19,7 +19,8 @@ /** * BcComposer */ -class BcComposer { +class BcComposer +{ /** * cd コマンド @@ -54,6 +55,8 @@ class BcComposer { * * @param string $php * @throws Exception + * @checked + * @noTodo */ public static function setup(string $php = '') { @@ -73,12 +76,14 @@ public static function setup(string $php = '') * Composer がインストールされているかチェックする * * @throws Exception + * @checked + * @noTodo */ public static function checkComposer() { - if(!file_exists(self::$composerDir . 'composer.phar')) { + if (!file_exists(self::$composerDir . 'composer.phar')) { $result = self::installComposer(); - if(!file_exists(self::$composerDir . 'composer.phar')) { + if (!file_exists(self::$composerDir . 'composer.phar')) { throw new Exception(__d('baser_core', 'composer がインストールできません。{0}', implode("\n", $result['out']))); } self::selfUpdate(); @@ -89,6 +94,8 @@ public static function checkComposer() * 環境チェック * * @throws Exception + * @checked + * @noTodo */ public static function checkEnv() { @@ -108,7 +115,7 @@ public static function checkEnv() if (!is_writable(ROOT . DS . 'logs')) { $error = __d('baser_core', '/logs に書き込み権限がありません。書き込み権限を与えてください。'); } - if($error) { + if ($error) { throw new Exception(implode('\n', $error)); } } @@ -150,6 +157,8 @@ public static function require(string $package, string $version) * composer install 実行 * * @return array + * @checked + * @noTodo */ public static function install() { @@ -160,6 +169,8 @@ public static function install() * composer self-update 実行 * * @return array + * @checked + * @noTodo */ public static function selfUpdate() { @@ -171,6 +182,8 @@ public static function selfUpdate() * * @param string $command * @return array + * @checked + * @noTodo */ public static function execCommand(string $command) { @@ -187,10 +200,12 @@ public static function execCommand(string $command) * * @param string $command * @return string + * @checked + * @noTodo */ public static function createCommand(string $command) { - return self::$cd . ' ' . self::$export . ' echo y | ' . self::$php . ' ' . self::$composerDir . 'composer.phar ' . $command . ' 2>&1'; + return self::$cd . ' ' . self::$export . ' echo y | ' . self::$php . ' ' . self::$composerDir . 'composer.phar ' . $command . ' 2>&1'; } } diff --git a/plugins/baser-core/src/Utility/BcEvent.php b/plugins/baser-core/src/Utility/BcEvent.php index 4ef58969c6..0b0871eeaa 100644 --- a/plugins/baser-core/src/Utility/BcEvent.php +++ b/plugins/baser-core/src/Utility/BcEvent.php @@ -27,6 +27,8 @@ class BcEvent * * @param string $plugin * @param int $priority + * @checked + * @noTodo */ public static function registerPluginEvent(string $plugin, int $priority = 100) { diff --git a/plugins/baser-core/src/Utility/BcFileUploader.php b/plugins/baser-core/src/Utility/BcFileUploader.php index 32ab4611bb..47be3ecccc 100644 --- a/plugins/baser-core/src/Utility/BcFileUploader.php +++ b/plugins/baser-core/src/Utility/BcFileUploader.php @@ -1163,6 +1163,8 @@ public function resetUploaded() * ファイルアップロード対象のデータを元に戻す * * @param EntityInterface $entity + * @checked + * @noTodo */ public function rollbackFile(EntityInterface $entity) { diff --git a/plugins/baser-core/src/Utility/BcGmaps.php b/plugins/baser-core/src/Utility/BcGmaps.php index f3d5ff8c19..803ce157d4 100644 --- a/plugins/baser-core/src/Utility/BcGmaps.php +++ b/plugins/baser-core/src/Utility/BcGmaps.php @@ -17,6 +17,9 @@ use Cake\Http\Client\Exception\NetworkException; use Cake\Utility\Exception\XmlException; use Cake\Utility\Xml; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * Class BcGmaps @@ -54,6 +57,8 @@ class BcGmaps * * @param string $apiKey * @return void + * @checked + * @noTodo */ public function __construct($apiKey) { @@ -68,6 +73,8 @@ public function __construct($apiKey) * * @param string $address * @return array|null + * @checked + * @noTodo */ public function getLocation($address) { diff --git a/plugins/baser-core/src/Utility/BcLang.php b/plugins/baser-core/src/Utility/BcLang.php index e5b86219a5..842018982f 100644 --- a/plugins/baser-core/src/Utility/BcLang.php +++ b/plugins/baser-core/src/Utility/BcLang.php @@ -11,6 +11,10 @@ namespace BaserCore\Utility; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; + /** * Class BcLang * @@ -37,6 +41,8 @@ class BcLang extends BcAbstractDetector * * @param array $config 設定の配列 * @return void + * @checked + * @noTodo */ protected function _setConfig(array $config) { @@ -47,6 +53,8 @@ protected function _setConfig(array $config) * デフォルトの設定値を取得 * * @return array + * @checked + * @noTodo */ protected function _getDefaultConfig() { @@ -59,6 +67,8 @@ protected function _getDefaultConfig() * 判定用正規表現を取得 * * @return string + * @checked + * @noTodo */ public function getDetectorRegex() { @@ -70,6 +80,8 @@ public function getDetectorRegex() * キーワードを含むかどうかを判定 * * @return bool + * @checked + * @noTodo */ public function isMatchDecisionKey() { @@ -85,6 +97,8 @@ public function isMatchDecisionKey() * * @param $acceptLanguage * @return array|string + * @checked + * @noTodo */ static public function parseLang($acceptLanguage) { @@ -107,4 +121,5 @@ static public function parseLang($acceptLanguage) } return $langs[0]; } + } diff --git a/plugins/baser-core/src/Utility/BcSiteConfig.php b/plugins/baser-core/src/Utility/BcSiteConfig.php index 3dc003235c..e01cd0f7a2 100644 --- a/plugins/baser-core/src/Utility/BcSiteConfig.php +++ b/plugins/baser-core/src/Utility/BcSiteConfig.php @@ -8,9 +8,13 @@ * @since 5.0.0 * @license https://basercms.net/license/index.html MIT License */ + namespace BaserCore\Utility; use BaserCore\Service\SiteConfigsServiceInterface; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * BcSiteConfig @@ -23,6 +27,8 @@ class BcSiteConfig * * @param string $key * @return mixed + * @checked + * @noTodo */ public static function get($key) { diff --git a/plugins/baser-core/src/Utility/BcText.php b/plugins/baser-core/src/Utility/BcText.php index 61fdd78682..254745c12a 100644 --- a/plugins/baser-core/src/Utility/BcText.php +++ b/plugins/baser-core/src/Utility/BcText.php @@ -11,29 +11,36 @@ namespace BaserCore\Utility; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; + /** * Class BcText */ class BcText { - /** - * 文字列よりスクリプトタグを除去する - * - * @param string $value - * @return string - */ - public static function stripScriptTag($value) - { - $allows = [ - 'a', 'abbr', 'address', 'area', 'b', 'blockquote', 'body', 'br', 'button', 'caption', 'cite', 'code', - 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'fieldset', 'form', 'h1', 'h2', 'h3', - 'h4', 'h5', 'h6', 'hr', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', - 'map', 'meta', 'noscript', 'object', 'ol', 'optgroup', 'option', 'p', 'pre', 'q', 'samp', 'select', - 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', - 'title', 'tr', 'ul', 'var', 'style' - ]; - return strip_tags($value, '<' . implode('><', $allows) . '>'); - } + /** + * 文字列よりスクリプトタグを除去する + * + * @param string $value + * @return string + * @checked + * @noTodo + * @unitTest + */ + public static function stripScriptTag($value) + { + $allows = [ + 'a', 'abbr', 'address', 'area', 'b', 'blockquote', 'body', 'br', 'button', 'caption', 'cite', 'code', + 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'fieldset', 'form', 'h1', 'h2', 'h3', + 'h4', 'h5', 'h6', 'hr', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', + 'map', 'meta', 'noscript', 'object', 'ol', 'optgroup', 'option', 'p', 'pre', 'q', 'samp', 'select', + 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', + 'title', 'tr', 'ul', 'var', 'style' + ]; + return strip_tags($value, '<' . implode('><', $allows) . '>'); + } } diff --git a/plugins/baser-core/src/Utility/BcUpdateLog.php b/plugins/baser-core/src/Utility/BcUpdateLog.php index 8cff52311d..c019d19013 100644 --- a/plugins/baser-core/src/Utility/BcUpdateLog.php +++ b/plugins/baser-core/src/Utility/BcUpdateLog.php @@ -64,7 +64,7 @@ public static function get() */ public static function save() { - if(self::$message) { + if (self::$message) { foreach(self::$message as $value) { Log::write(LogLevel::INFO, $value, 'update'); } @@ -74,6 +74,8 @@ public static function save() /** * 一時領域のアップデートメッセージを削除する + * @checked + * @noTodo */ public static function clear() { diff --git a/plugins/baser-core/src/Utility/BcUtil.php b/plugins/baser-core/src/Utility/BcUtil.php index 4d2c944857..3d5d56841e 100644 --- a/plugins/baser-core/src/Utility/BcUtil.php +++ b/plugins/baser-core/src/Utility/BcUtil.php @@ -139,7 +139,7 @@ public static function loginUser() $prefix = BcUtil::getRequestPrefix($request); $authenticator = $request->getAttribute('authentication'); - if($authenticator) { + if ($authenticator) { /** @var Result $result */ $result = $authenticator->getResult(); if (!empty($result) && $result->isValid()) { @@ -147,7 +147,7 @@ public static function loginUser() $user = $result->getData(); if (is_null($user->user_groups)) { $userModel = Configure::read("BcPrefixAuth.{$prefix}.userModel"); - if($userModel === 'BaserCore.Users') { + if ($userModel === 'BaserCore.Users') { $userTable = TableRegistry::getTableLocator()->get('BaserCore.Users'); $user = $userTable->get($user->id, ['contain' => ['UserGroups']]); } @@ -157,7 +157,7 @@ public static function loginUser() } $user = false; - if($prefix === 'Front') { + if ($prefix === 'Front') { $user = BcUtil::loginUserFromSession($prefix); if (!$user) { $users = self::getLoggedInUsers(false); @@ -180,11 +180,11 @@ public static function getLoggedInUsers($assoc = true) { $users = []; $prefixSettings = array_reverse(Configure::read('BcPrefixAuth')); - foreacH($prefixSettings as $key => $prefixSetting) { - if(!empty($prefixSetting['disabled'])) continue; + foreach($prefixSettings as $key => $prefixSetting) { + if (!empty($prefixSetting['disabled'])) continue; $user = BcUtil::loginUserFromSession($key); - if($user) { - if($assoc) { + if ($user) { + if ($assoc) { $users[$key] = $user; } else { $users[] = $user; @@ -694,10 +694,10 @@ public static function unserialize($value) $value = @unserialize(base64_decode($value)); // 下位互換のため、しばらくの間、失敗した場合の再変換を行う v.3.0.2 if ($value === false) { - $value = @unserialize($_value); - if($value === false) { - return ''; - } + $value = @unserialize($_value); + if ($value === false) { + return ''; + } } return $value; } @@ -812,6 +812,8 @@ public static function getTemplatePath(string $plugin): string * * @param $siteId * @return []|array + * @checked + * @noTodo */ public static function getFrontTemplatePaths($siteId, $plugin) { @@ -920,6 +922,8 @@ public static function getAdminThemeList() * サブドメインを取得する * * @return string + * @checked + * @noTodo */ public static function getSubDomain($host = null) { @@ -998,6 +1002,8 @@ public static function getCurrentDomain() * * @param $pluginName * @return string|false + * @checked + * @noTodo */ public static function getPluginPath($pluginName): string { @@ -1017,6 +1023,8 @@ public static function getPluginPath($pluginName): string * プラグインのディレクトリ名を取得する * @param $pluginName * @return false|mixed + * @checked + * @noTodo */ public static function getPluginDir($pluginName) { @@ -1146,6 +1154,8 @@ public static function topLevelUrl($lastSlash = true) * 現在のビューディレクトリのパスを取得する * * @return string + * @checked + * @noTodo */ public static function getViewPath() { @@ -1178,13 +1188,13 @@ public static function getCurrentTheme() if (is_null($request)) $site = null; - else{ + else { /** @var Site $site */ $site = $request->getAttribute('currentSite'); } if ($site) { - if($site->theme) { + if ($site->theme) { return $site->theme; } else { $sitesService = BcContainer::get()->get(SitesServiceInterface::class); @@ -1908,8 +1918,8 @@ public static function getAuthPrefixList() { $authPrefixes = []; foreach(Configure::read('BcPrefixAuth') as $key => $authPrefix) { - if($key === 'Api') continue; - if(!empty($authPrefix['disabled'])) continue; + if ($key === 'Api') continue; + if (!empty($authPrefix['disabled'])) continue; $authPrefixes[$key] = $authPrefix['name']; } return $authPrefixes; diff --git a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php index 725d02aa85..ff59dd2824 100644 --- a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php +++ b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php @@ -193,7 +193,7 @@ public function testAfterDelete() { $entity = $this->table->get(10); $entity->content = $this->contentService->getTrash(16); - $event = $this->table->dispatchEvent('Model.afterDelete', [ + $this->table->dispatchEvent('Model.afterDelete', [ 'entity' => $entity, 'options' => new ArrayObject(), ]); @@ -201,12 +201,4 @@ public function testAfterDelete() } - /** - * 公開されたコンテンツを取得する - */ - public function testFindPublished() - { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - } - }