From 8524dae2dfe49293a078fdebb95a858afc3eef1a Mon Sep 17 00:00:00 2001 From: RikaFujiwara Date: Mon, 14 Dec 2020 02:45:25 +0000 Subject: [PATCH 1/4] =?UTF-8?q?fix=20:=20getAliveCondition=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E8=BF=BD=E5=8A=A0=EF=BC=88CleanUp=E3=83=97=E3=83=A9?= =?UTF-8?q?=E3=82=B0=E3=82=A4=E3=83=B3=E5=81=B4=E3=81=AE=E5=AF=BE=E5=BF=9C?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CleanUpプラグインがコンテンツの活性状態を確認する特別関数の用意 --- Model/QuizPage.php | 29 +++++++++++++++++++++++++++++ Model/QuizQuestion.php | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/Model/QuizPage.php b/Model/QuizPage.php index 715976a..af32d99 100644 --- a/Model/QuizPage.php +++ b/Model/QuizPage.php @@ -330,4 +330,33 @@ public function deleteQuizPage($quizId) { } return true; } + +/** + * getAliveCondition + * 現在使用中状態であるか判断する。CleanUpプラグインで使用 + * + * @param array $key + * @return array + */ + public function getAliveCondition($key) { + return array( + 'conditions' => array( + 'QuizPage.key' => $key, + 'OR' => array( + 'Quiz.is_active' => true, + 'Quiz.is_latest' => true, + ), + ), + 'joins' => array( + array( + 'table' => 'quizzes', + 'alias' => 'Quiz', + 'type' => 'INNER', + 'conditions' => array( + 'QuizPage.quiz_id = Quiz.id' + ) + ) + ) + ); + } } diff --git a/Model/QuizQuestion.php b/Model/QuizQuestion.php index 70bf0ff..b90b934 100644 --- a/Model/QuizQuestion.php +++ b/Model/QuizQuestion.php @@ -389,4 +389,41 @@ public function deleteQuizQuestion($quizPageId) { } return true; } + +/** + * getAliveCondition + * 現在使用中状態であるか判断する。CleanUpプラグインで使用 + * + * @param array $key + * @return array + */ + public function getAliveCondition($key) { + return array( + 'conditions' => array( + 'QuizQuestion.key' => $key, + 'OR' => array( + 'Quiz.is_active' => true, + 'Quiz.is_latest' => true, + ), + ), + 'joins' => array( + array( + 'table' => 'quiz_pages', + 'alias' => 'QuizPage', + 'type' => 'INNER', + 'conditions' => array( + $this->alias . '.quiz_page_id = QuizPage.id' + ) + ), + array( + 'table' => 'quizzes', + 'alias' => 'Quiz', + 'type' => 'INNER', + 'conditions' => array( + 'QuizPage.quiz_id = Quiz.id' + ) + ) + ) + ); + } } From 15b6373997f8439745dcee6af55f6d5fc22ecc40 Mon Sep 17 00:00:00 2001 From: RikaFujiwara Date: Mon, 14 Dec 2020 02:51:51 +0000 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E6=B5=81=E7=94=A8=E5=85=83=E3=81=AE?= =?UTF-8?q?=E3=82=A2=E3=83=B3=E3=82=B1=E3=83=BC=E3=83=88=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E3=81=97CleanUp=E3=82=92=E5=AE=9F=E8=A1=8C=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=A8=E6=B5=81=E7=94=A8=E5=85=88=E3=81=AE=E3=82=A2?= =?UTF-8?q?=E3=83=B3=E3=82=B1=E3=83=BC=E3=83=88=E3=81=A7=E7=94=BB=E5=83=8F?= =?UTF-8?q?=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA=E3=81=8F?= =?UTF-8?q?=E3=81=AA=E3=82=8B=20#1608?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/NetCommons3/NetCommons3/issues/1608 --- Model/ActionQuizAdd.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Model/ActionQuizAdd.php b/Model/ActionQuizAdd.php index 5b488ee..9cebbf2 100644 --- a/Model/ActionQuizAdd.php +++ b/Model/ActionQuizAdd.php @@ -249,7 +249,44 @@ protected function _getQuizCloneById($quizId) { )); // ID値のみクリア $this->clearQuizId($quiz); + // Wysiwygエディタ内のファイルの複製処理 + $quiz = $this->_copyWysiwygFiles($quiz); + return $quiz; + } +/** + * _copyWysiwygFiles + * + * 引数で指定された小テストの中を分析し、 + * ウィジウィグに設定されているファイルは複製を作ります + * + * @param array $quiz 小テストデータ + * @return array $quiz 複製を作り終えた小テストデータ + */ + protected function _copyWysiwygFiles($quiz) { + $wysiswyg = new WysiwygZip(); + $flatQuiz = Hash::flatten($quiz); + foreach ($flatQuiz as $key => &$value) { + $model = null; + if (strpos($key, 'QuizQuestion.') !== false) { + $model = $this->QuizQuestion; + } elseif (strpos($key, 'QuizPage.') !== false) { + $model = $this->QuizPage; + } elseif (strpos($key, 'Quiz.') !== false) { + $model = $this->Quiz; + } + if (!$model) { + continue; + } + $columnName = substr($key, strrpos($key, '.') + 1); + if ($model->hasField($columnName)) { + if ($model->getColumnType($columnName) == 'text') { + $wysiswygZipFile = $wysiswyg->createWysiwygZip($value); + $value = $wysiswyg->getFromWysiwygZip($wysiswygZipFile); + } + } + } + $quiz = Hash::expand($flatQuiz); return $quiz; } From 9010bcd59cc8f047a8a5b26c8113abce9b239d2e Mon Sep 17 00:00:00 2001 From: RikaFujiwara Date: Tue, 15 Dec 2020 06:53:45 +0000 Subject: [PATCH 3/4] =?UTF-8?q?style:=20phpcs=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/QuizPage.php | 2 +- Model/QuizQuestion.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/QuizPage.php b/Model/QuizPage.php index af32d99..a96934f 100644 --- a/Model/QuizPage.php +++ b/Model/QuizPage.php @@ -335,7 +335,7 @@ public function deleteQuizPage($quizId) { * getAliveCondition * 現在使用中状態であるか判断する。CleanUpプラグインで使用 * - * @param array $key + * @param array $key 判断対象のデータのキー * @return array */ public function getAliveCondition($key) { diff --git a/Model/QuizQuestion.php b/Model/QuizQuestion.php index b90b934..dab02d1 100644 --- a/Model/QuizQuestion.php +++ b/Model/QuizQuestion.php @@ -394,7 +394,7 @@ public function deleteQuizQuestion($quizPageId) { * getAliveCondition * 現在使用中状態であるか判断する。CleanUpプラグインで使用 * - * @param array $key + * @param array $key 判断対象のデータのキー * @return array */ public function getAliveCondition($key) { From 2952aa671da0fc7fc78a6aee0ffb4760d64ce2f5 Mon Sep 17 00:00:00 2001 From: RikaFujiwara Date: Tue, 15 Dec 2020 09:08:55 +0000 Subject: [PATCH 4/4] =?UTF-8?q?style:=20phpmd=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/ActionQuizAdd.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Model/ActionQuizAdd.php b/Model/ActionQuizAdd.php index 9cebbf2..ad7f0f8 100644 --- a/Model/ActionQuizAdd.php +++ b/Model/ActionQuizAdd.php @@ -268,13 +268,7 @@ protected function _copyWysiwygFiles($quiz) { $flatQuiz = Hash::flatten($quiz); foreach ($flatQuiz as $key => &$value) { $model = null; - if (strpos($key, 'QuizQuestion.') !== false) { - $model = $this->QuizQuestion; - } elseif (strpos($key, 'QuizPage.') !== false) { - $model = $this->QuizPage; - } elseif (strpos($key, 'Quiz.') !== false) { - $model = $this->Quiz; - } + $model = $this->__getModelFromDataName($key); if (!$model) { continue; } @@ -373,13 +367,7 @@ protected function _getQuizzes($folderPath, $quizzes, $importKey) { $flatQuiz = Hash::flatten($q); foreach ($flatQuiz as $key => &$value) { $model = null; - if (strpos($key, 'QuizQuestion.') !== false) { - $model = $this->QuizQuestion; - } elseif (strpos($key, 'QuizPage.') !== false) { - $model = $this->QuizPage; - } elseif (strpos($key, 'Quiz.') !== false) { - $model = $this->Quiz; - } + $model = $this->__getModelFromDataName($key); if (!$model) { continue; } @@ -401,7 +389,24 @@ protected function _getQuizzes($folderPath, $quizzes, $importKey) { } return $quizzes; } - +/** + * __getModelFromDataName + * + * @param string $keyName データフィールド名の頭の部分(モデル名) + * @return Model + */ + private function __getModelFromDataName($keyName) { + if (strpos($keyName, 'QuizQuestion.') !== false) { + $model = $this->QuizQuestion; + } elseif (strpos($keyName, 'QuizPage.') !== false) { + $model = $this->QuizPage; + } elseif (strpos($keyName, 'Quiz.') !== false) { + $model = $this->Quiz; + } else { + $model = false; + } + return $model; + } /** * __checkFingerPrint *