diff --git a/README.md b/README.md index a63acf6..7dbef9c 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,6 @@ Configure::write('debug', WASA_DEBUG_LEVEL); Change log ---------- -* I added "\WasaCache" class feature to decrease disc access. -* I repaired "\WasaAppController" class. -* I created "\WasaAppModel" class for model validation. +* I added "\WasaAppModel::__construct()" class method. +* I repaired "\WasaCache::__write()" class method. +* I repaired "\WasaBootstrap030200FormHelper" class. diff --git a/app/Lib/Wasa/Cache/WasaCache.php b/app/Lib/Wasa/Cache/WasaCache.php index 53e32fd..f5730d1 100644 --- a/app/Lib/Wasa/Cache/WasaCache.php +++ b/app/Lib/Wasa/Cache/WasaCache.php @@ -110,7 +110,7 @@ private static function __read($key) // Reads the cache without lock. $array = \Cache::read($key, self::SETTING_NAME); // If this is not array. - if (!\is_array($array)) { + if (!is_array($array)) { // Returns an empty array. return array (); } @@ -156,8 +156,16 @@ private static function __write($key, $nativeArray, $array) if ($array !== $nativeArray) { // Locks the cache. \Cache::set(array ('lock' => true), self::SETTING_NAME); - // Writes to the cache. - $result = \Cache::write($key, $array, self::SETTING_NAME); + $result = true; + $currentArray = \Cache::read($key, self::SETTING_NAME); + if (!\is_array($currentArray)) { + $currentArray = array (); + } + // If other process has not written. + if ($currentArray === $nativeArray) { + // Writes to the cache. + $result = \Cache::write($key, $array, self::SETTING_NAME); + } // Unlocks the cache. \Cache::set(array ('lock' => false), self::SETTING_NAME); if (WASA_DEBUG_LEVEL && $result === false) { diff --git a/app/Lib/Wasa/Model/WasaAppModel.php b/app/Lib/Wasa/Model/WasaAppModel.php index 652cf8b..5ff920f 100644 --- a/app/Lib/Wasa/Model/WasaAppModel.php +++ b/app/Lib/Wasa/Model/WasaAppModel.php @@ -43,6 +43,7 @@ */ \App::uses('AppModel', 'Model'); \App::uses('WasaAppController', 'Wasa/Controller'); +\App::uses('WasaCache', 'Wasa/Cache'); /** * Wasa's Application Model. * @@ -56,6 +57,16 @@ class WasaAppModel extends \AppModel { + /** + * Sets "$validate" property for model validation. + */ + function __construct() + { + $this->validate = $this->_getModelValidation(); + + parent::__construct(); + } + /** * Gets the model validation. * diff --git a/app/Lib/Wasa/View/Helper/WasaBootstrap030200FormHelper.php b/app/Lib/Wasa/View/Helper/WasaBootstrap030200FormHelper.php index c4fa9ce..3b9f1c3 100644 --- a/app/Lib/Wasa/View/Helper/WasaBootstrap030200FormHelper.php +++ b/app/Lib/Wasa/View/Helper/WasaBootstrap030200FormHelper.php @@ -41,8 +41,7 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause * @link https://github.com/hidenori-wasa/_CakePHP0204Lib/ */ -use \WasaBootstrap030200FormHelper as WBFH; // This is this file scope and priority is high. -use \WasaCache as WC; +use \WasaCache as WC; // This is this file scope and priority is high. \App::uses('WasaCache', 'Wasa/Cache'); /** @@ -266,14 +265,14 @@ static function displayTelForJP($params) for ($count = 0;; $count++) { $fieldName = $fieldNames[$count]; // エラーの場合、入力フォームをエラー色にする - echo ''; + echo ''; // 電話番号テキストボックス echo $telHTML[$count]; echo ''; if ($count === 2) { break; } - echo ''; + echo ''; } echo ''; @@ -330,7 +329,7 @@ static function displayCheckboxes($params) array ( 'type' => 'checkbox', 'value' => $value, - 'style' => WBFH::INLINE_BLOCK_STYLE, + 'style' => self::INLINE_BLOCK_STYLE, ) ); preg_match('`'; if ($labelLocation === 'front') { // Displays the front label. - echo '' . $label . ''; + echo '' . $label . ''; // Displays checkbox and keeps input value. echo $checkboxElement; } else { // Displays checkbox and keeps input value. echo $checkboxElement; // Displays the rear label. - echo '' . $label . ''; + echo '' . $label . ''; } echo ''; } @@ -381,7 +380,7 @@ static function displayRadioButtons($params) $fieldName, // array ( 'type' => 'radio', - 'style' => WBFH::INLINE_BLOCK_STYLE, + 'style' => self::INLINE_BLOCK_STYLE, 'options' => $values2, 'legend' => false, 'label' => false @@ -410,14 +409,14 @@ static function displayRadioButtons($params) echo ''; } @@ -474,31 +473,31 @@ static function displayDateForJP($params) // 画面サイズがエキストラスモール以外の場合のレイアウト echo '