svnno****@sourc*****
svnno****@sourc*****
2010年 1月 1日 (金) 21:11:16 JST
Revision: 758 http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=758 Author: rsk Date: 2010-01-01 21:11:16 +0900 (Fri, 01 Jan 2010) Log Message: ----------- expack: - P2KeyValueStore ã¯ã©ã¹ã«ä¿åãããã¼ã¿ã¿ã¤ãã æå®ããå®æ°ã追å ã - P2KeyValueStore_SJIS ã¯ã©ã¹ã P2KeyValueStore_ShiftJIS ã«ãªãã¼ã ã Modified Paths: -------------- p2ex/trunk/lib/P2Client.php p2ex/trunk/lib/P2KeyValueStore.php Added Paths: ----------- p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php Removed Paths: ------------- p2ex/trunk/lib/P2KeyValueStore/SJIS.php -------------- next part -------------- Modified: p2ex/trunk/lib/P2Client.php =================================================================== --- p2ex/trunk/lib/P2Client.php 2010-01-01 11:06:33 UTC (rev 757) +++ p2ex/trunk/lib/P2Client.php 2010-01-01 12:11:16 UTC (rev 758) @@ -111,7 +111,8 @@ { try { $cookieSavePath = $cookieSaveDir . DIRECTORY_SEPARATOR . self::COOKIE_STORE_NAME; - $cookieStore = P2KeyValueStore::getStore($cookieSavePath, 'Serializing'); + $cookieStore = P2KeyValueStore::getStore($cookieSavePath, + P2KeyValueStore::KVS_SERIALIZING); } catch (Exception $e) { throw new P2Exception(get_class($e) . ': ' . $e->getMessage()); } Deleted: p2ex/trunk/lib/P2KeyValueStore/SJIS.php =================================================================== --- p2ex/trunk/lib/P2KeyValueStore/SJIS.php 2010-01-01 11:06:33 UTC (rev 757) +++ p2ex/trunk/lib/P2KeyValueStore/SJIS.php 2010-01-01 12:11:16 UTC (rev 758) @@ -1,108 +0,0 @@ -<?php -require_once dirname(__FILE__) . '/../P2KeyValueStore.php'; - -// {{{ P2KeyValueStore_SJIS - -/** - * Shift_JIS̶ñðUTF-8ÉÏ·µÄi±»·é - */ -class P2KeyValueStore_SJIS extends P2KeyValueStore -{ - // {{{ _encode() - - /** - * Shift_JIS (CP932) ̶ñðUTF-8ÉÏ··é - * - * @param string $str - * @return string - */ - private function _encode($str) - { - return mb_convert_encoding($str, 'UTF-8', 'CP932'); - } - - // }}} - // {{{ _decode() - - /** - * UTF-8̶ñðShift_JIS (CP932) ÉÏ··é - * - * @param string $str - * @return string - */ - private function _decode($str) - { - return mb_convert_encoding($str, 'CP932', 'UTF-8'); - } - - // }}} - // {{{ _encodeKey() - - /** - * L[ðGR[h·é - * - * @param string $key - * @return string - */ - protected function _encodeKey($key) - { - return $this->_encode($key); - } - - // }}} - // {{{ _decodeKey() - - /** - * L[ðfR[h·é - * - * @param string $key - * @return string - */ - protected function _decodeKey($key) - { - return $this->_decode($key); - } - - // }}} - // {{{ _encodeValue() - - /** - * lðGR[h·é - * - * @param string $value - * @return string - */ - protected function _encodeValue($value) - { - return $this->_encode($value); - } - - // }}} - // {{{ _decodeValue() - - /** - * lðfR[h·é - * - * @param string $value - * @return string - */ - protected function _decodeValue($value) - { - return $this->_decode($value); - } - - // }}} -} - -// }}} - -/* - * Local Variables: - * mode: php - * coding: cp932 - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ -// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: Copied: p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php (from rev 757, p2ex/trunk/lib/P2KeyValueStore/SJIS.php) =================================================================== --- p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php (rev 0) +++ p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php 2010-01-01 12:11:16 UTC (rev 758) @@ -0,0 +1,108 @@ +<?php +require_once dirname(__FILE__) . '/../P2KeyValueStore.php'; + +// {{{ P2KeyValueStore_ShiftJIS + +/** + * Shift_JIS̶ñðUTF-8ÉÏ·µÄi±»·é + */ +class P2KeyValueStore_ShiftJIS extends P2KeyValueStore +{ + // {{{ _encode() + + /** + * Shift_JIS (CP932) ̶ñðUTF-8ÉÏ··é + * + * @param string $str + * @return string + */ + private function _encode($str) + { + return mb_convert_encoding($str, 'UTF-8', 'CP932'); + } + + // }}} + // {{{ _decode() + + /** + * UTF-8̶ñðShift_JIS (CP932) ÉÏ··é + * + * @param string $str + * @return string + */ + private function _decode($str) + { + return mb_convert_encoding($str, 'CP932', 'UTF-8'); + } + + // }}} + // {{{ _encodeKey() + + /** + * L[ðGR[h·é + * + * @param string $key + * @return string + */ + protected function _encodeKey($key) + { + return $this->_encode($key); + } + + // }}} + // {{{ _decodeKey() + + /** + * L[ðfR[h·é + * + * @param string $key + * @return string + */ + protected function _decodeKey($key) + { + return $this->_decode($key); + } + + // }}} + // {{{ _encodeValue() + + /** + * lðGR[h·é + * + * @param string $value + * @return string + */ + protected function _encodeValue($value) + { + return $this->_encode($value); + } + + // }}} + // {{{ _decodeValue() + + /** + * lðfR[h·é + * + * @param string $value + * @return string + */ + protected function _decodeValue($value) + { + return $this->_decode($value); + } + + // }}} +} + +// }}} + +/* + * Local Variables: + * mode: php + * coding: cp932 + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ +// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: Modified: p2ex/trunk/lib/P2KeyValueStore.php =================================================================== --- p2ex/trunk/lib/P2KeyValueStore.php 2010-01-01 11:06:33 UTC (rev 757) +++ p2ex/trunk/lib/P2KeyValueStore.php 2010-01-01 12:11:16 UTC (rev 758) @@ -34,6 +34,12 @@ const Q_CLEAN = 'DELETE FROM $__table'; const Q_GC = 'DELETE FROM $__table WHERE mtime < :expires'; + const KVS_DEFAULT = 'default'; + const KVS_BINARY = 'Binary'; + const KVS_COMPRESSING = 'Compressing'; + const KVS_SHIFTJS = 'ShiftJIS'; + const KVS_SERIALIZING = 'Serializing'; + // }}} // {{{ staric private properties @@ -80,7 +86,7 @@ * @return P2KeyValueStore * @throws InvalidArgumentException, UnexpectedValueException, RuntimeException, PDOException */ - static public function getStore($fileName, $type = 'default', &$openedPath = null) + static public function getStore($fileName, $type = self::KVS_DEFAULT, &$openedPath = null) { // øÌ^ð`FbN if (!is_string($fileName)) { @@ -91,7 +97,7 @@ } // NX¼ð`FbN - if ($type == 'default') { + if ($type == self::KVS_DEFAULT) { $className = 'P2KeyValueStore'; } else { $className = 'P2KeyValueStore_' . $type;