*** features
+- ¥Ï¡¼¥É¥¿¥Ö -> ¥½¥Õ¥È¥¿¥Ö
- test runner¤ÎÄɲÃ
- [breaking B.C.] Ethna_Logger¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°
-- Ethna_LogWriter¤Î¥×¥é¥°¥¤¥ó²½
<?php
// vim: foldmethod=marker
/**
- * Ethna.php
+ * Ethna.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
/** Ethna depends on PEAR */
include_once('PEAR.php');
if (!defined('PATH_SEPARATOR')) {
- if (OS_WINDOWS) {
- /** include_path separator(Windows) */
- define('PATH_SEPARATOR', ';');
- } else {
- /** include_path separator(Unix) */
- define('PATH_SEPARATOR', ':');
- }
+ if (OS_WINDOWS) {
+ /** include_path separator(Windows) */
+ define('PATH_SEPARATOR', ';');
+ } else {
+ /** include_path separator(Unix) */
+ define('PATH_SEPARATOR', ':');
+ }
}
if (!defined('DIRECTORY_SEPARATOR')) {
- if (OS_WINDOWS) {
- /** directory separator(Windows) */
- define('DIRECTORY_SEPARATOR', '\\');
- } else {
- /** separator(Unix) */
- define('DIRECTORY_SEPARATOR', '/');
- }
+ if (OS_WINDOWS) {
+ /** directory separator(Windows) */
+ define('DIRECTORY_SEPARATOR', '\\');
+ } else {
+ /** separator(Unix) */
+ define('DIRECTORY_SEPARATOR', '/');
+ }
}
/** ¥Ð¡¼¥¸¥ç¥óÄêµÁ */
include_once(ETHNA_BASE . '/class/Renderer/Ethna_Renderer_Smarty.php');
if (extension_loaded('soap')) {
- include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_ActionForm.php');
- include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_Gateway.php');
- include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_GatewayGenerator.php');
- include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_Util.php');
- include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_WsdlGenerator.php');
+ include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_ActionForm.php');
+ include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_Gateway.php');
+ include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_GatewayGenerator.php');
+ include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_Util.php');
+ include_once(ETHNA_BASE . '/class/SOAP/Ethna_SOAP_WsdlGenerator.php');
}
/** ¥¯¥é¥¤¥¢¥ó¥È¸À¸ìÄêµÁ: ±Ñ¸ì */
define('E_PLUGIN_GENERAL', 197);
if (defined('E_STRICT') == false) {
- /** PHP 5¤È¤Î¸ß´¹ÊÝ»ýÄêµÁ */
- define('E_STRICT', 0);
+ /** PHP 5¤È¤Î¸ß´¹ÊÝ»ýÄêµÁ */
+ define('E_STRICT', 0);
}
/** Ethna¥°¥í¡¼¥Ð¥ëÊÑ¿ô: ¥¨¥é¡¼¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô */
// {{{ Ethna
/**
- * Ethna¥Õ¥ì¡¼¥à¥ï¡¼¥¯¥¯¥é¥¹
+ * Ethna¥Õ¥ì¡¼¥à¥ï¡¼¥¯¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna extends PEAR
{
- /**#@+
- * @access private
- */
-
- /**#@-*/
-
- /**
- * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë(¥¨¥é¡¼¥ì¥Ù¥ë:E_USER_ERROR)
- *
- * @access public
- * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- * @param int $code ¥¨¥é¡¼¥³¡¼¥É
- * @static
- */
- function &raiseError($message, $code = E_GENERAL)
- {
- $userinfo = null;
- if (func_num_args() > 2) {
- $userinfo = array_slice(func_get_args(), 2);
- if (count($userinfo) == 1 && is_array($userinfo[0])) {
- $userinfo = $userinfo[0];
- }
- }
- return PEAR::raiseError($message, $code, PEAR_ERROR_RETURN, E_USER_ERROR, $userinfo, 'Ethna_Error');
- }
-
- /**
- * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë(¥¨¥é¡¼¥ì¥Ù¥ë:E_USER_WARNING)
- *
- * @access public
- * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- * @param int $code ¥¨¥é¡¼¥³¡¼¥É
- * @static
- */
- function &raiseWarning($message, $code = E_GENERAL)
- {
- $userinfo = null;
- if (func_num_args() > 2) {
- $userinfo = array_slice(func_get_args(), 2);
- if (count($userinfo) == 1 && is_array($userinfo[0])) {
- $userinfo = $userinfo[0];
- }
- }
- return PEAR::raiseError($message, $code, PEAR_ERROR_RETURN, E_USER_WARNING, $userinfo, 'Ethna_Error');
- }
-
- /**
- * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë(¥¨¥é¡¼¥ì¥Ù¥ë:E_USER_NOTICE)
- *
- * @access public
- * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- * @param int $code ¥¨¥é¡¼¥³¡¼¥É
- * @static
- */
- function &raiseNotice($message, $code = E_GENERAL)
- {
- $userinfo = null;
- if (func_num_args() > 2) {
- $userinfo = array_slice(func_get_args(), 2);
- if (count($userinfo) == 1 && is_array($userinfo[0])) {
- $userinfo = $userinfo[0];
- }
- }
- return PEAR::raiseError($message, $code, PEAR_ERROR_RETURN, E_USER_NOTICE, $userinfo, 'Ethna_Error');
- }
-
- /**
- * ¥¨¥é¡¼È¯À¸»þ¤Î(¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤È¤·¤Æ¤Î)¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤òÀßÄꤹ¤ë
- *
- * @access public
- * @param mixed string:¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô̾ array:¥³¡¼¥ë¥Ð¥Ã¥¯¥¯¥é¥¹(̾|¥ª¥Ö¥¸¥§¥¯¥È)+¥á¥½¥Ã¥É̾
- * @static
- */
- function setErrorCallback($callback)
- {
- $GLOBALS['_Ethna_error_callback_list'][] = $callback;
- }
-
- /**
- * ¥¨¥é¡¼È¯À¸»þ¤Î½èÍý¤ò¹Ô¤¦(¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô/¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹)
- *
- * @access public
- * @param object Ethna_Error Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È
- * @static
- */
- function handleError(&$error)
- {
- for ($i = 0; $i < count($GLOBALS['_Ethna_error_callback_list']); $i++) {
- $callback =& $GLOBALS['_Ethna_error_callback_list'][$i];
- if (is_array($callback) == false) {
- call_user_func($callback, $error);
- } else if (is_object($callback[0])) {
- $object =& $callback[0];
- $method = $callback[1];
-
- // perform some more checks?
- $object->$method($error);
- } else {
- call_user_func($callback, $error);
- }
- }
- }
+ /**#@+
+ * @access private
+ */
+
+ /**#@-*/
+
+ /**
+ * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë(¥¨¥é¡¼¥ì¥Ù¥ë:E_USER_ERROR)
+ *
+ * @access public
+ * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ * @param int $code ¥¨¥é¡¼¥³¡¼¥É
+ * @static
+ */
+ function &raiseError($message, $code = E_GENERAL)
+ {
+ $userinfo = null;
+ if (func_num_args() > 2) {
+ $userinfo = array_slice(func_get_args(), 2);
+ if (count($userinfo) == 1 && is_array($userinfo[0])) {
+ $userinfo = $userinfo[0];
+ }
+ }
+ return PEAR::raiseError($message, $code, PEAR_ERROR_RETURN, E_USER_ERROR, $userinfo, 'Ethna_Error');
+ }
+
+ /**
+ * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë(¥¨¥é¡¼¥ì¥Ù¥ë:E_USER_WARNING)
+ *
+ * @access public
+ * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ * @param int $code ¥¨¥é¡¼¥³¡¼¥É
+ * @static
+ */
+ function &raiseWarning($message, $code = E_GENERAL)
+ {
+ $userinfo = null;
+ if (func_num_args() > 2) {
+ $userinfo = array_slice(func_get_args(), 2);
+ if (count($userinfo) == 1 && is_array($userinfo[0])) {
+ $userinfo = $userinfo[0];
+ }
+ }
+ return PEAR::raiseError($message, $code, PEAR_ERROR_RETURN, E_USER_WARNING, $userinfo, 'Ethna_Error');
+ }
+
+ /**
+ * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë(¥¨¥é¡¼¥ì¥Ù¥ë:E_USER_NOTICE)
+ *
+ * @access public
+ * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ * @param int $code ¥¨¥é¡¼¥³¡¼¥É
+ * @static
+ */
+ function &raiseNotice($message, $code = E_GENERAL)
+ {
+ $userinfo = null;
+ if (func_num_args() > 2) {
+ $userinfo = array_slice(func_get_args(), 2);
+ if (count($userinfo) == 1 && is_array($userinfo[0])) {
+ $userinfo = $userinfo[0];
+ }
+ }
+ return PEAR::raiseError($message, $code, PEAR_ERROR_RETURN, E_USER_NOTICE, $userinfo, 'Ethna_Error');
+ }
+
+ /**
+ * ¥¨¥é¡¼È¯À¸»þ¤Î(¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤È¤·¤Æ¤Î)¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤òÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param mixed string:¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô̾ array:¥³¡¼¥ë¥Ð¥Ã¥¯¥¯¥é¥¹(̾|¥ª¥Ö¥¸¥§¥¯¥È)+¥á¥½¥Ã¥É̾
+ * @static
+ */
+ function setErrorCallback($callback)
+ {
+ $GLOBALS['_Ethna_error_callback_list'][] = $callback;
+ }
+
+ /**
+ * ¥¨¥é¡¼È¯À¸»þ¤Î½èÍý¤ò¹Ô¤¦(¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô/¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹)
+ *
+ * @access public
+ * @param object Ethna_Error Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È
+ * @static
+ */
+ function handleError(&$error)
+ {
+ for ($i = 0; $i < count($GLOBALS['_Ethna_error_callback_list']); $i++) {
+ $callback =& $GLOBALS['_Ethna_error_callback_list'][$i];
+ if (is_array($callback) == false) {
+ call_user_func($callback, $error);
+ } else if (is_object($callback[0])) {
+ $object =& $callback[0];
+ $method = $callback[1];
+
+ // perform some more checks?
+ $object->$method($error);
+ } else {
+ call_user_func($callback, $error);
+ }
+ }
+ }
}
// }}}
?>
<?php
/**
- * ethna_handle.php
+ * ethna_handle.php
*
* Ethna Handle Gateway
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
while (ob_get_level()) {
ob_end_clean();
// setup path seprator
if (!defined('PATH_SEPARATOR')) {
- if (OS_WINDOWS) {
- /** include_path separator(Windows) */
- define('PATH_SEPARATOR', ';');
- } else {
- /** include_path separator(Unix) */
- define('PATH_SEPARATOR', ':');
- }
+ if (OS_WINDOWS) {
+ /** include_path separator(Windows) */
+ define('PATH_SEPARATOR', ';');
+ } else {
+ /** include_path separator(Unix) */
+ define('PATH_SEPARATOR', ':');
+ }
}
$base = dirname(dirname(dirname(__FILE__)));
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . "$base");
<?php
/**
- * ethna_make_package.php
+ * ethna_make_package.php
*
* package.xml generator for Ethna
*
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
include_once('PEAR.php');
include_once('Console/Getopt.php');
#!/bin/sh
#
-# ethna_make_package.sh
+# ethna_make_package.sh
#
-# ...:(
+# ...:(
#
-# $Id$
+# $Id$
#
tmpdir="/tmp/ethna"
if [ ! -d $tmpdir ]
then
- mkdir -p $tmpdir
+ mkdir -p $tmpdir
fi
if [ "$1" = "-b" ]
then
- beta=$1
+ beta=$1
fi
# chdir to basedir
<?php
// vim: foldmethod=marker
/**
- * Ethna_Action_Info.php
+ * Ethna_Action_Info.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Form_Info
/**
- * __ethna_info__¥Õ¥©¡¼¥à¤Î¼ÂÁõ
+ * __ethna_info__¥Õ¥©¡¼¥à¤Î¼ÂÁõ
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Form_Info extends Ethna_ActionForm
{
- /**
- * @access private
- * @var array ¥Õ¥©¡¼¥àÃÍÄêµÁ
- */
- var $form = array(
- );
+ /**
+ * @access private
+ * @var array ¥Õ¥©¡¼¥àÃÍÄêµÁ
+ */
+ var $form = array(
+ );
}
// }}}
// {{{ Ethna_Action_Info
/**
- * __ethna_info__¥¢¥¯¥·¥ç¥ó¤Î¼ÂÁõ
+ * __ethna_info__¥¢¥¯¥·¥ç¥ó¤Î¼ÂÁõ
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Action_Info extends Ethna_ActionClass
{
- /**
- * __ethna_info__¥¢¥¯¥·¥ç¥ó¤ÎÁ°½èÍý
- *
- * @access public
- * @return string ForwardÀè(Àµ¾ï½ªÎ»¤Ê¤énull)
- */
- function prepare()
- {
- return null;
- }
+ /**
+ * __ethna_info__¥¢¥¯¥·¥ç¥ó¤ÎÁ°½èÍý
+ *
+ * @access public
+ * @return string ForwardÀè(Àµ¾ï½ªÎ»¤Ê¤énull)
+ */
+ function prepare()
+ {
+ return null;
+ }
- /**
- * __ethna_info__¥¢¥¯¥·¥ç¥ó¤Î¼ÂÁõ
- *
- * @access public
- * @return string Á«°Ü̾
- */
- function perform()
- {
- return '__ethna_info__';
- }
+ /**
+ * __ethna_info__¥¢¥¯¥·¥ç¥ó¤Î¼ÂÁõ
+ *
+ * @access public
+ * @return string Á«°Ü̾
+ */
+ function perform()
+ {
+ return '__ethna_info__';
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * action_class.php
+ * action_class.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_CLI_ActionClass
/**
- * ¥³¥Þ¥ó¥É¥é¥¤¥óaction¼Â¹Ô¥¯¥é¥¹
+ * ¥³¥Þ¥ó¥É¥é¥¤¥óaction¼Â¹Ô¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
+ * @obsolete
*/
class Ethna_CLI_ActionClass extends Ethna_ActionClass
{
- /**
- * action½èÍý
- *
- * @access public
- */
- function Perform()
- {
- parent::Perform();
- $_SERVER['REMOTE_ADDR'] = "0.0.0.0";
- $_SERVER['HTTP_USER_AGENT'] = "";
- }
+ /**
+ * action½èÍý
+ *
+ * @access public
+ */
+ function Perform()
+ {
+ parent::Perform();
+ $_SERVER['REMOTE_ADDR'] = "0.0.0.0";
+ $_SERVER['HTTP_USER_AGENT'] = "";
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_DB_PEAR.php
+ * Ethna_DB_PEAR.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
include_once('DB.php');
// {{{ Ethna_DB_PEAR
/**
- * Ethna_DB¥¯¥é¥¹¤Î¼ÂÁõ(PEARÈÇ)
+ * Ethna_DB¥¯¥é¥¹¤Î¼ÂÁõ(PEARÈÇ)
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_DB_PEAR extends Ethna_DB
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var object DB PEAR DB¥ª¥Ö¥¸¥§¥¯¥È */
- var $db;
+ /** @var object DB PEAR DB¥ª¥Ö¥¸¥§¥¯¥È */
+ var $db;
- /** @var array ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó´ÉÍý¥¹¥¿¥Ã¥¯ */
- var $transaction = array();
+ /** @var array ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó´ÉÍý¥¹¥¿¥Ã¥¯ */
+ var $transaction = array();
- /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */
- var $logger;
+ /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */
+ var $logger;
- /** @var object Ethna_AppSQL SQL¥ª¥Ö¥¸¥§¥¯¥È */
- var $sql;
+ /** @var object Ethna_AppSQL SQL¥ª¥Ö¥¸¥§¥¯¥È */
+ var $sql;
- /** @var string DB¥¿¥¤¥×(mysql, pgsql...) */
- var $type;
+ /** @var string DB¥¿¥¤¥×(mysql, pgsql...) */
+ var $type;
- /** @var string DSN */
- var $dsn;
+ /** @var string DSN */
+ var $dsn;
- /** @var array DSN (DB::parseDSN()¤ÎÊÖ¤êÃÍ) */
- var $dsninfo;
+ /** @var array DSN (DB::parseDSN()¤ÎÊÖ¤êÃÍ) */
+ var $dsninfo;
- /** @var bool »ý³Àܳ¥Õ¥é¥° */
- var $persistent;
+ /** @var bool »ý³Àܳ¥Õ¥é¥° */
+ var $persistent;
- /**#@-*/
+ /**#@-*/
- // {{{ Ethna_DB¥¯¥é¥¹¤Î¼ÂÁõ
- /**
- * Ethna_DB_PEAR¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
- * @param string $dsn DSN
- * @param bool $persistent »ý³ÀܳÀßÄê
- */
- function Ethna_DB_PEAR(&$controller, $dsn, $persistent)
- {
+ // {{{ Ethna_DB¥¯¥é¥¹¤Î¼ÂÁõ
+ /**
+ * Ethna_DB_PEAR¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
+ * @param string $dsn DSN
+ * @param bool $persistent »ý³ÀܳÀßÄê
+ */
+ function Ethna_DB_PEAR(&$controller, $dsn, $persistent)
+ {
parent::Ethna_DB($controller, $dsn, $persistent);
- $this->db = null;
- $this->logger =& $controller->getLogger();
- $this->sql =& $controller->getSQL();
-
- $this->dsninfo = DB::parseDSN($dsn);
- $this->dsninfo['new_link'] = true;
- $this->type = $this->dsninfo['phptype'];
- }
-
- /**
- * DB¤ËÀܳ¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function connect()
- {
- $this->db =& DB::connect($this->dsninfo, $this->persistent);
- if (DB::isError($this->db)) {
- $error = Ethna::raiseError('DBÀܳ¥¨¥é¡¼: %s', E_DB_CONNECT, $this->db->getUserInfo());
- $error->addUserInfo($this->db);
- $this->db = null;
- return $error;
- }
-
- return 0;
- }
-
- /**
- * DBÀܳ¤òÀÚÃǤ¹¤ë
- *
- * @access public
- */
- function disconnect()
- {
- if ($this->isValid() == false) {
- return;
- }
- $this->db->disconnect();
- }
-
- /**
- * DBÀܳ¾õÂÖ¤òÊÖ¤¹
- *
- * @access public
- * @return bool true:Àµ¾ï false:¥¨¥é¡¼
- */
- function isValid()
- {
- if (is_null($this->db)
+ $this->db = null;
+ $this->logger =& $controller->getLogger();
+ $this->sql =& $controller->getSQL();
+
+ $this->dsninfo = DB::parseDSN($dsn);
+ $this->dsninfo['new_link'] = true;
+ $this->type = $this->dsninfo['phptype'];
+ }
+
+ /**
+ * DB¤ËÀܳ¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function connect()
+ {
+ $this->db =& DB::connect($this->dsninfo, $this->persistent);
+ if (DB::isError($this->db)) {
+ $error = Ethna::raiseError('DBÀܳ¥¨¥é¡¼: %s', E_DB_CONNECT, $this->db->getUserInfo());
+ $error->addUserInfo($this->db);
+ $this->db = null;
+ return $error;
+ }
+
+ return 0;
+ }
+
+ /**
+ * DBÀܳ¤òÀÚÃǤ¹¤ë
+ *
+ * @access public
+ */
+ function disconnect()
+ {
+ if ($this->isValid() == false) {
+ return;
+ }
+ $this->db->disconnect();
+ }
+
+ /**
+ * DBÀܳ¾õÂÖ¤òÊÖ¤¹
+ *
+ * @access public
+ * @return bool true:Àµ¾ï false:¥¨¥é¡¼
+ */
+ function isValid()
+ {
+ if (is_null($this->db)
|| is_resource($this->db->connection) == false) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function begin()
- {
- if (count($this->transaction) > 0) {
- $this->transaction[] = true;
- return 0;
- }
-
- $r = $this->query('BEGIN;');
- if (Ethna::isError($r)) {
- return $r;
- }
- $this->transaction[] = true;
-
- return 0;
- }
-
- /**
- * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÃæÃǤ¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function rollback()
- {
- if (count($this->transaction) == 0) {
- return 0;
- }
-
- // ¥í¡¼¥ë¥Ð¥Ã¥¯»þ¤Ï¥¹¥¿¥Ã¥¯¿ô¤Ë´Ø¤ï¤é¤º¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥¯¥ê¥¢¤¹¤ë
- $r = $this->query('ROLLBACK;');
- if (Ethna::isError($r)) {
- return $r;
- }
- $this->transaction = array();
-
- return 0;
- }
-
- /**
- * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function commit()
- {
- if (count($this->transaction) == 0) {
- return 0;
- } else if (count($this->transaction) > 1) {
- array_pop($this->transaction);
- return 0;
- }
-
- $r = $this->query('COMMIT;');
- if (Ethna::isError($r)) {
- return $r;
- }
- array_pop($this->transaction);
-
- return 0;
- }
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function begin()
+ {
+ if (count($this->transaction) > 0) {
+ $this->transaction[] = true;
+ return 0;
+ }
+
+ $r = $this->query('BEGIN;');
+ if (Ethna::isError($r)) {
+ return $r;
+ }
+ $this->transaction[] = true;
+
+ return 0;
+ }
+
+ /**
+ * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÃæÃǤ¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function rollback()
+ {
+ if (count($this->transaction) == 0) {
+ return 0;
+ }
+
+ // ¥í¡¼¥ë¥Ð¥Ã¥¯»þ¤Ï¥¹¥¿¥Ã¥¯¿ô¤Ë´Ø¤ï¤é¤º¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥¯¥ê¥¢¤¹¤ë
+ $r = $this->query('ROLLBACK;');
+ if (Ethna::isError($r)) {
+ return $r;
+ }
+ $this->transaction = array();
+
+ return 0;
+ }
+
+ /**
+ * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function commit()
+ {
+ if (count($this->transaction) == 0) {
+ return 0;
+ } else if (count($this->transaction) > 1) {
+ array_pop($this->transaction);
+ return 0;
+ }
+
+ $r = $this->query('COMMIT;');
+ if (Ethna::isError($r)) {
+ return $r;
+ }
+ array_pop($this->transaction);
+
+ return 0;
+ }
/**
* ¥Æ¡¼¥Ö¥ëÄêµÁ¾ðÊó¤ò¼èÆÀ¤¹¤ë
{
return $this->db->tableInfo($table);
}
- // }}}
-
- // {{{ Ethna_AppObjectÏ¢·È¤Î¤¿¤á¤Î¼ÂÁõ
- /**
- * DB¥¿¥¤¥×¤òÊÖ¤¹
- *
- * @access public
- * @return string DB¥¿¥¤¥×
- */
- function getType()
- {
- return $this->type;
- }
-
- /**
- * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë
- *
- * @access public
- * @param string $query SQLʸ
- * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
- */
- function &query($query)
- {
- return $this->_query($query);
- }
-
- /**
- * ľ¶á¤ÎINSERT¤Ë¤è¤ëID¤ò¼èÆÀ¤¹¤ë
- *
- * ÀܳÃæ¤ÎDB¤¬mysql¤Ê¤émysql_insert_id()¤ÎÃͤòÊÖ¤¹
- *
- * @access public
- * @return mixed int:ľ¶á¤ÎINSERT¤Ë¤è¤êÀ¸À®¤µ¤ì¤¿ID null:̤¥µ¥Ý¡¼¥È
- */
- function getInsertId()
- {
- if ($this->isValid() == false) {
- return null;
- } else if ($this->type == 'mysql') {
- return mysql_insert_id($this->db->connection);
- }
-
- return null;
- }
-
- /**
- * ľ¶á¤Î¥¯¥¨¥ê¤Ë¤è¤ë¹¹¿·¹Ô¿ô¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return int ¹¹¿·¹Ô¿ô
- */
- function affectedRows()
- {
- return $this->db->affectedRows();
- }
- // }}}
-
- // {{{ Ethna_DB_PEARÆȼ«¤Î¼ÂÁõ
- /**
- * SQLʸ»ØÄꥯ¥¨¥ê¤òȯ¹Ô¤¹¤ë
- *
- * @access public
- * @param string $sqlid SQL-ID(+°ú¿ô)
- * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
- */
- function &sqlquery($sqlid)
- {
- $args = func_get_args();
- array_shift($args);
- $query = $this->sql->get($sqlid, $args);
-
- return $this->_query($query);
- }
-
- /**
- * SQLʸ¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $sqlid SQL-ID
- * @return string SQLʸ
- */
- function sql($sqlid)
- {
- $args = func_get_args();
- array_shift($args);
- $query = $this->sql->get($sqlid, $args);
-
- return $query;
- }
-
- /**
- * ¥Æ¡¼¥Ö¥ë¤ò¥í¥Ã¥¯¤¹¤ë
- *
- * @access public
- * @param mixed ¥í¥Ã¥¯Âоݥơ¼¥Ö¥ë̾
- * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
- */
- function lock($tables)
- {
- $this->message = null;
-
- $sql = "";
- foreach (to_array($tables) as $table) {
- if ($sql != "") {
- $sql .= ", ";
- }
- $sql .= "$table WRITE";
- }
-
- return $this->query("LOCK TABLES $sql");
- }
-
- /**
- * ¥Æ¡¼¥Ö¥ë¤Î¥í¥Ã¥¯¤ò²òÊü¤¹¤ë
- *
- * @access public
- * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
- */
- function unlock()
- {
- $this->message = null;
- return $this->query("UNLOCK TABLES");
- }
-
- /**
- * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë
- *
- * @access private
- * @param string $query SQLʸ
- * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
- */
- function &_query($query)
- {
- $this->logger->log(LOG_DEBUG, "$query");
- $r =& $this->db->query($query);
- if (DB::isError($r)) {
- if ($r->getCode() == DB_ERROR_ALREADY_EXISTS) {
- $error = Ethna::raiseNotice('¥æ¥Ë¡¼¥¯À©Ì󥨥顼 SQL[%s]', E_DB_DUPENT, $query, $this->db->errorNative(), $r->getUserInfo());
- } else {
- $error = Ethna::raiseError('¥¯¥¨¥ê¥¨¥é¡¼ SQL[%s] CODE[%d] MESSAGE[%s]', E_DB_QUERY, $query, $this->db->errorNative(), $r->getUserInfo());
- }
- return $error;
- }
- return $r;
- }
- // }}}
+ // }}}
+
+ // {{{ Ethna_AppObjectÏ¢·È¤Î¤¿¤á¤Î¼ÂÁõ
+ /**
+ * DB¥¿¥¤¥×¤òÊÖ¤¹
+ *
+ * @access public
+ * @return string DB¥¿¥¤¥×
+ */
+ function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë
+ *
+ * @access public
+ * @param string $query SQLʸ
+ * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
+ */
+ function &query($query)
+ {
+ return $this->_query($query);
+ }
+
+ /**
+ * ľ¶á¤ÎINSERT¤Ë¤è¤ëID¤ò¼èÆÀ¤¹¤ë
+ *
+ * ÀܳÃæ¤ÎDB¤¬mysql¤Ê¤émysql_insert_id()¤ÎÃͤòÊÖ¤¹
+ *
+ * @access public
+ * @return mixed int:ľ¶á¤ÎINSERT¤Ë¤è¤êÀ¸À®¤µ¤ì¤¿ID null:̤¥µ¥Ý¡¼¥È
+ */
+ function getInsertId()
+ {
+ if ($this->isValid() == false) {
+ return null;
+ } else if ($this->type == 'mysql') {
+ return mysql_insert_id($this->db->connection);
+ }
+
+ return null;
+ }
+
+ /**
+ * ľ¶á¤Î¥¯¥¨¥ê¤Ë¤è¤ë¹¹¿·¹Ô¿ô¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return int ¹¹¿·¹Ô¿ô
+ */
+ function affectedRows()
+ {
+ return $this->db->affectedRows();
+ }
+ // }}}
+
+ // {{{ Ethna_DB_PEARÆȼ«¤Î¼ÂÁõ
+ /**
+ * SQLʸ»ØÄꥯ¥¨¥ê¤òȯ¹Ô¤¹¤ë
+ *
+ * @access public
+ * @param string $sqlid SQL-ID(+°ú¿ô)
+ * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
+ */
+ function &sqlquery($sqlid)
+ {
+ $args = func_get_args();
+ array_shift($args);
+ $query = $this->sql->get($sqlid, $args);
+
+ return $this->_query($query);
+ }
+
+ /**
+ * SQLʸ¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $sqlid SQL-ID
+ * @return string SQLʸ
+ */
+ function sql($sqlid)
+ {
+ $args = func_get_args();
+ array_shift($args);
+ $query = $this->sql->get($sqlid, $args);
+
+ return $query;
+ }
+
+ /**
+ * ¥Æ¡¼¥Ö¥ë¤ò¥í¥Ã¥¯¤¹¤ë
+ *
+ * @access public
+ * @param mixed ¥í¥Ã¥¯Âоݥơ¼¥Ö¥ë̾
+ * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
+ */
+ function lock($tables)
+ {
+ $this->message = null;
+
+ $sql = "";
+ foreach (to_array($tables) as $table) {
+ if ($sql != "") {
+ $sql .= ", ";
+ }
+ $sql .= "$table WRITE";
+ }
+
+ return $this->query("LOCK TABLES $sql");
+ }
+
+ /**
+ * ¥Æ¡¼¥Ö¥ë¤Î¥í¥Ã¥¯¤ò²òÊü¤¹¤ë
+ *
+ * @access public
+ * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
+ */
+ function unlock()
+ {
+ $this->message = null;
+ return $this->query("UNLOCK TABLES");
+ }
+
+ /**
+ * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë
+ *
+ * @access private
+ * @param string $query SQLʸ
+ * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼
+ */
+ function &_query($query)
+ {
+ $this->logger->log(LOG_DEBUG, "$query");
+ $r =& $this->db->query($query);
+ if (DB::isError($r)) {
+ if ($r->getCode() == DB_ERROR_ALREADY_EXISTS) {
+ $error = Ethna::raiseNotice('¥æ¥Ë¡¼¥¯À©Ì󥨥顼 SQL[%s]', E_DB_DUPENT, $query, $this->db->errorNative(), $r->getUserInfo());
+ } else {
+ $error = Ethna::raiseError('¥¯¥¨¥ê¥¨¥é¡¼ SQL[%s] CODE[%d] MESSAGE[%s]', E_DB_QUERY, $query, $this->db->errorNative(), $r->getUserInfo());
+ }
+ return $error;
+ }
+ return $r;
+ }
+ // }}}
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_ActionClass.php
+ * Ethna_ActionClass.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_ActionClass
/**
- * action¼Â¹Ô¥¯¥é¥¹
+ * action¼Â¹Ô¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_ActionClass
{
- /**#@+
- * @access private
- */
-
- /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
- var $backend;
-
- /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
- var $config;
-
- /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
- var $i18n;
-
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_error;
-
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $ae;
-
- /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_form;
-
- /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $af;
-
- /** @var object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È */
- var $session;
-
- /**#@-*/
-
- /**
- * Ethna_ActionClass¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Backend $backend backend¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_ActionClass(&$backend)
- {
- $c =& $backend->getController();
- $this->backend =& $backend;
- $this->config =& $this->backend->getConfig();
- $this->i18n =& $this->backend->getI18N();
-
- $this->action_error =& $this->backend->getActionError();
- $this->ae =& $this->action_error;
-
- $this->action_form =& $this->backend->getActionForm();
- $this->af =& $this->action_form;
-
- $this->session =& $this->backend->getSession();
-
- // Ethna_AppManager¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
- $manager_list = $c->getManagerList();
- foreach ($manager_list as $k => $v) {
- $this->$k =& $backend->getManager($v);
- }
- }
-
- /**
- * ¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¤Îǧ¾Ú½èÍý¤ò¹Ô¤¦
- *
- * @access public
- * @return string Á«°Ü̾(null¤Ê¤éÀµ¾ï½ªÎ», false¤Ê¤é½èÍý½ªÎ»)
- */
- function authenticate()
- {
- return null;
- }
-
- /**
- * ¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¤Î½èÍý(¥Õ¥©¡¼¥àÃÍ¥Á¥§¥Ã¥¯Åù)¤ò¹Ô¤¦
- *
- * @access public
- * @return string Á«°Ü̾(null¤Ê¤éÀµ¾ï½ªÎ», false¤Ê¤é½èÍý½ªÎ»)
- */
- function prepare()
- {
- return null;
- }
-
- /**
- * ¥¢¥¯¥·¥ç¥ó¼Â¹Ô
- *
- * @access public
- * @return string Á«°Ü̾(null¤Ê¤éÁ«°Ü¤Ï¹Ô¤ï¤Ê¤¤)
- */
- function perform()
- {
- return null;
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
+ var $backend;
+
+ /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
+ var $config;
+
+ /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
+ var $i18n;
+
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_error;
+
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $ae;
+
+ /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_form;
+
+ /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $af;
+
+ /** @var object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È */
+ var $session;
+
+ /**#@-*/
+
+ /**
+ * Ethna_ActionClass¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Backend $backend backend¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_ActionClass(&$backend)
+ {
+ $c =& $backend->getController();
+ $this->backend =& $backend;
+ $this->config =& $this->backend->getConfig();
+ $this->i18n =& $this->backend->getI18N();
+
+ $this->action_error =& $this->backend->getActionError();
+ $this->ae =& $this->action_error;
+
+ $this->action_form =& $this->backend->getActionForm();
+ $this->af =& $this->action_form;
+
+ $this->session =& $this->backend->getSession();
+
+ // Ethna_AppManager¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
+ $manager_list = $c->getManagerList();
+ foreach ($manager_list as $k => $v) {
+ $this->$k =& $backend->getManager($v);
+ }
+ }
+
+ /**
+ * ¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¤Îǧ¾Ú½èÍý¤ò¹Ô¤¦
+ *
+ * @access public
+ * @return string Á«°Ü̾(null¤Ê¤éÀµ¾ï½ªÎ», false¤Ê¤é½èÍý½ªÎ»)
+ */
+ function authenticate()
+ {
+ return null;
+ }
+
+ /**
+ * ¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¤Î½èÍý(¥Õ¥©¡¼¥àÃÍ¥Á¥§¥Ã¥¯Åù)¤ò¹Ô¤¦
+ *
+ * @access public
+ * @return string Á«°Ü̾(null¤Ê¤éÀµ¾ï½ªÎ», false¤Ê¤é½èÍý½ªÎ»)
+ */
+ function prepare()
+ {
+ return null;
+ }
+
+ /**
+ * ¥¢¥¯¥·¥ç¥ó¼Â¹Ô
+ *
+ * @access public
+ * @return string Á«°Ü̾(null¤Ê¤éÁ«°Ü¤Ï¹Ô¤ï¤Ê¤¤)
+ */
+ function perform()
+ {
+ return null;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_ActionError.php
+ * Ethna_ActionError.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
include_once(ETHNA_BASE . '/class/Ethna_Error.php');
// {{{ Ethna_ActionError
/**
- * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¨¥é¡¼´ÉÍý¥¯¥é¥¹
+ * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¨¥é¡¼´ÉÍý¥¯¥é¥¹
*
- * @access public
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @package Ethna
+ * @access public
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @package Ethna
*/
class Ethna_ActionError
{
- /**#@+
- * @access private
- */
-
- /** @var array ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î°ìÍ÷ */
- var $error_list = array();
-
- /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_form = null;
-
- /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */
- var $logger = null;
- /**#@-*/
-
- /**
- * Ethna_ActionError¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- */
- function Ethna_ActionError()
- {
- }
-
- /**
- * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®/Äɲ乤ë
- *
- * @access public
- * @param string $name ¥¨¥é¡¼¤ÎȯÀ¸¤·¤¿¥Õ¥©¡¼¥à¹àÌÜ̾(ÉÔÍפʤénull)
- * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- * @param int $code ¥¨¥é¡¼¥³¡¼¥É
- */
- function add($name, $message, $code = null)
- {
- if (func_num_args() > 3) {
- $userinfo = array_slice(func_get_args(), 3);
- $error =& Ethna::raiseNotice($message, $code, $userinfo);
- } else {
- $error =& Ethna::raiseNotice($message, $code);
- }
- $this->addObject($name, $error);
- }
-
- /**
- * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÄɲ乤ë
- *
- * @access public
- * @param string $name ¥¨¥é¡¼¤ËÂбþ¤¹¤ë¥Õ¥©¡¼¥à¹àÌÜ̾(ÉÔÍפʤénull)
- * @param object Ethna_Error $error ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È
- */
- function addObject($name, &$error)
- {
- $elt = array();
- $elt['name'] = $name;
- $elt['object'] =& $error;
- $this->error_list[] = $elt;
-
- // ¥í¥°½ÐÎÏ(ÊäÂ)
- $af =& $this->_getActionForm();
- $logger =& $this->_getLogger();
- $logger->log(LOG_NOTICE, '{form} -> [%s]', $this->action_form->getName($name));
- }
-
- /**
- * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô¤òÊÖ¤¹
- *
- * @access public
- * @return int ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô
- */
- function count()
- {
- return count($this->error_list);
- }
-
- /**
- * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô¤òÊÖ¤¹(count()¥á¥½¥Ã¥É¤Î¥¨¥¤¥ê¥¢¥¹)
- *
- * @access public
- * @return int ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô
- */
- function length()
- {
- return count($this->error_list);
- }
-
- /**
- * ÅÐÏ¿¤µ¤ì¤¿¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤òÁ´¤Æºï½ü¤¹¤ë
- *
- * @access public
- */
- function clear()
- {
- $this->error_list = array();
- }
-
- /**
- * »ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤ˥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
- *
- * @access public
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
- * @return bool true:¥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë false:¥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤
- */
- function isError($name)
- {
- foreach ($this->error_list as $error) {
- if (strcasecmp($error['name'], $name) == 0) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * »ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤËÂбþ¤¹¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
- *
- * @access public
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
- * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸(¥¨¥é¡¼¤¬Ìµ¤¤¾ì¹ç¤Ïnull)
- */
- function getMessage($name)
- {
- foreach ($this->error_list as $error) {
- if (strcasecmp($error['name'], $name) == 0) {
- return $this->_getMessage($error);
- }
- }
- return null;
- }
-
- /**
- * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤òÇÛÎó¤Ë¤·¤ÆÊÖ¤¹
- *
- * @access public
- * @return array ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇÛÎó
- */
- function getErrorList()
- {
- return $this->error_list;
- }
-
- /**
- * ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÇÛÎó¤Ë¤·¤ÆÊÖ¤¹
- *
- * @access public
- * @return array ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ÎÇÛÎó
- */
- function getMessageList()
- {
- $message_list = array();
-
- foreach ($this->error_list as $error) {
- $message_list[] = $this->_getMessage($error);
- }
- return $message_list;
- }
-
- /**
- * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @param array ¥¨¥é¡¼¥¨¥ó¥È¥ê
- * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- */
- function _getMessage(&$error)
- {
- $af =& $this->_getActionForm();
- $form_name = $af->getName($error['name']);
- return str_replace("{form}", $form_name, $error['object']->getMessage());
- }
-
- /**
- * Ethna_ActionForm¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return object Ethna_ActionForm
- */
- function &_getActionForm()
- {
- if (is_null($this->action_form)) {
- $controller =& Ethna_Controller::getInstance();
- $this->action_form =& $controller->getActionForm();
- }
- return $this->action_form;
- }
-
- /**
- * Ethna_Logger¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return object Ethna_Logger
- */
- function &_getLogger()
- {
- if (is_null($this->logger)) {
- $controller =& Ethna_Controller::getInstance();
- $this->logger =& $controller->getLogger();
- }
- return $this->logger;
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var array ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î°ìÍ÷ */
+ var $error_list = array();
+
+ /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_form = null;
+
+ /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */
+ var $logger = null;
+ /**#@-*/
+
+ /**
+ * Ethna_ActionError¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ */
+ function Ethna_ActionError()
+ {
+ }
+
+ /**
+ * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®/Äɲ乤ë
+ *
+ * @access public
+ * @param string $name ¥¨¥é¡¼¤ÎȯÀ¸¤·¤¿¥Õ¥©¡¼¥à¹àÌÜ̾(ÉÔÍפʤénull)
+ * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ * @param int $code ¥¨¥é¡¼¥³¡¼¥É
+ */
+ function add($name, $message, $code = null)
+ {
+ if (func_num_args() > 3) {
+ $userinfo = array_slice(func_get_args(), 3);
+ $error =& Ethna::raiseNotice($message, $code, $userinfo);
+ } else {
+ $error =& Ethna::raiseNotice($message, $code);
+ }
+ $this->addObject($name, $error);
+ }
+
+ /**
+ * Ethna_Error¥ª¥Ö¥¸¥§¥¯¥È¤òÄɲ乤ë
+ *
+ * @access public
+ * @param string $name ¥¨¥é¡¼¤ËÂбþ¤¹¤ë¥Õ¥©¡¼¥à¹àÌÜ̾(ÉÔÍפʤénull)
+ * @param object Ethna_Error $error ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function addObject($name, &$error)
+ {
+ $elt = array();
+ $elt['name'] = $name;
+ $elt['object'] =& $error;
+ $this->error_list[] = $elt;
+
+ // ¥í¥°½ÐÎÏ(ÊäÂ)
+ $af =& $this->_getActionForm();
+ $logger =& $this->_getLogger();
+ $logger->log(LOG_NOTICE, '{form} -> [%s]', $this->action_form->getName($name));
+ }
+
+ /**
+ * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô¤òÊÖ¤¹
+ *
+ * @access public
+ * @return int ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô
+ */
+ function count()
+ {
+ return count($this->error_list);
+ }
+
+ /**
+ * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô¤òÊÖ¤¹(count()¥á¥½¥Ã¥É¤Î¥¨¥¤¥ê¥¢¥¹)
+ *
+ * @access public
+ * @return int ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤Î¿ô
+ */
+ function length()
+ {
+ return count($this->error_list);
+ }
+
+ /**
+ * ÅÐÏ¿¤µ¤ì¤¿¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤òÁ´¤Æºï½ü¤¹¤ë
+ *
+ * @access public
+ */
+ function clear()
+ {
+ $this->error_list = array();
+ }
+
+ /**
+ * »ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤ˥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @return bool true:¥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë false:¥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤
+ */
+ function isError($name)
+ {
+ foreach ($this->error_list as $error) {
+ if (strcasecmp($error['name'], $name) == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * »ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤËÂбþ¤¹¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸(¥¨¥é¡¼¤¬Ìµ¤¤¾ì¹ç¤Ïnull)
+ */
+ function getMessage($name)
+ {
+ foreach ($this->error_list as $error) {
+ if (strcasecmp($error['name'], $name) == 0) {
+ return $this->_getMessage($error);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤òÇÛÎó¤Ë¤·¤ÆÊÖ¤¹
+ *
+ * @access public
+ * @return array ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇÛÎó
+ */
+ function getErrorList()
+ {
+ return $this->error_list;
+ }
+
+ /**
+ * ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÇÛÎó¤Ë¤·¤ÆÊÖ¤¹
+ *
+ * @access public
+ * @return array ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ÎÇÛÎó
+ */
+ function getMessageList()
+ {
+ $message_list = array();
+
+ foreach ($this->error_list as $error) {
+ $message_list[] = $this->_getMessage($error);
+ }
+ return $message_list;
+ }
+
+ /**
+ * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @param array ¥¨¥é¡¼¥¨¥ó¥È¥ê
+ * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ */
+ function _getMessage(&$error)
+ {
+ $af =& $this->_getActionForm();
+ $form_name = $af->getName($error['name']);
+ return str_replace("{form}", $form_name, $error['object']->getMessage());
+ }
+
+ /**
+ * Ethna_ActionForm¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return object Ethna_ActionForm
+ */
+ function &_getActionForm()
+ {
+ if (is_null($this->action_form)) {
+ $controller =& Ethna_Controller::getInstance();
+ $this->action_form =& $controller->getActionForm();
+ }
+ return $this->action_form;
+ }
+
+ /**
+ * Ethna_Logger¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return object Ethna_Logger
+ */
+ function &_getLogger()
+ {
+ if (is_null($this->logger)) {
+ $controller =& Ethna_Controller::getInstance();
+ $this->logger =& $controller->getLogger();
+ }
+ return $this->logger;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_AppManager.php
+ * Ethna_AppManager.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
/** ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È¾õÂÖ: »ÈÍѲÄǽ */
// {{{ Ethna_AppManager
/**
- * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Þ¥Í¡¼¥¸¥ã¤Î¥Ù¡¼¥¹¥¯¥é¥¹
+ * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Þ¥Í¡¼¥¸¥ã¤Î¥Ù¡¼¥¹¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_AppManager
{
- /**#@+
- * @access private
- */
-
- /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
- var $backend;
-
- /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
- var $config;
-
- /** @var object Ethna_DB DB¥ª¥Ö¥¸¥§¥¯¥È */
- var $db;
-
- /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
- var $i18n;
-
- /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_form;
-
- /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $af;
-
- /** @var object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È */
- var $session;
-
- /**#@-*/
-
- /**
- * Ethna_AppManager¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Backend &$backend backend¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_AppManager(&$backend)
- {
- // ´ðËÜ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
- $this->backend =& $backend;
- $this->config = $backend->getConfig();
- $this->i18n =& $backend->getI18N();
- $this->action_form =& $backend->getActionForm();
- $this->af =& $this->action_form;
- $this->session =& $backend->getSession();
-
- $db_list = $backend->getDBList();
- if (Ethna::isError($db_list) == false) {
- foreach ($db_list as $elt) {
- $varname = $elt['varname'];
- $this->$varname =& $elt['db'];
- }
- }
- }
-
- /**
- * °À¤Î°ìÍ÷¤òÊÖ¤¹
- *
- * @access public
- * @param string $attr_name °À¤Î̾Á°(ÊÑ¿ô̾)
- * @return array °ÀÃÍ°ìÍ÷
- */
- function getAttrList($attr_name)
- {
- $varname = $attr_name . "_list";
- return $this->$varname;
- }
-
- /**
- * °À¤Îɽ¼¨Ì¾¤òÊÖ¤¹
- *
- * @access public
- * @param string $attr_name °À¤Î̾Á°(ÊÑ¿ô̾)
- * @param mixed $id °ÀID
- * @return string °À¤Îɽ¼¨Ì¾
- */
- function getAttrName($attr_name, $id)
- {
- $varname = $attr_name . "_list";
- if (is_array($this->$varname) == false) {
- return null;
- }
- $list =& $this->$varname;
- if (isset($list[$id]) == false) {
- return null;
- }
- return $list[$id]['name'];
- }
-
- /**
- * °À¤Îɽ¼¨Ì¾(¾ÜºÙ)¤òÊÖ¤¹
- *
- * @access public
- * @param string $attr_name °À¤Î̾Á°(ÊÑ¿ô̾)
- * @param mixed $id °ÀID
- * @return string °À¤Î¾ÜºÙɽ¼¨Ì¾
- */
- function getAttrLongName($attr_name, $id)
- {
- $varname = $attr_name . "_list";
- if (is_array($this->$varname) == false) {
- return null;
- }
- $list =& $this->$varname;
- if (isset($list[$id]['long_name']) == false) {
- return null;
- }
-
- return $list[$id]['long_name'];
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥È¤Î°ìÍ÷¤òÊÖ¤¹
- *
- * @access public
- * @param string $class Ethna_AppObject¤Î·Ñ¾µ¥¯¥é¥¹Ì¾
- * @param array $filter ¸¡º÷¾ò·ï
- * @param array $order ¸¡º÷·ë²Ì¥½¡¼¥È¾ò·ï
- * @param int $offset ¸¡º÷·ë²Ì¼èÆÀ¥ª¥Õ¥»¥Ã¥È
- * @param int $count ¸¡º÷·ë²Ì¼èÆÀ¿ô
- * @return mixed array(0 => ¸¡º÷¾ò·ï¤Ë¥Þ¥Ã¥Á¤·¤¿·ï¿ô, 1 => $offset, $count¤Ë¤è¤ê»ØÄꤵ¤ì¤¿·ï¿ô¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID°ìÍ÷) Ethna_Error:¥¨¥é¡¼
- * @todo ¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹Âкö(1¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀêÍ¥á¥â¥ê¤¬Â¿¤¤¾ì¹ç)
- */
- function getObjectList($class, $filter = null, $order = null, $offset = null, $count = null)
- {
- global $_ETHNA_APP_MANAGER_OL_CACHE;
-
- $object_list = array();
- $class_name = sprintf("%s_%s", $this->backend->getAppId(), $class);
-
- // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
- $cache_class = strtolower($class_name);
- if (is_array($_ETHNA_APP_MANAGER_OL_CACHE) == false || array_key_exists($cache_class, $_ETHNA_APP_MANAGER_OL_CACHE) == false) {
- $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class] = array();
- }
- $cache_key = serialize(array($filter, $order, $offset, $count));
- if (array_key_exists($cache_key, $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class])) {
- list($length, $prop_list) = $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class][$cache_key];
- } else {
- // ¥¥ã¥Ã¥·¥å¹¹¿·
- $tmp =& new $class_name($this->backend);
- list($length, $prop_list) = $tmp->searchProp(null, $filter, $order, $offset, $count);
- $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class][$cache_key] = array($length, $prop_list);
- }
-
- foreach ($prop_list as $prop) {
- $object =& new $class_name($this->backend, null, null, $prop);
- $object_list[] = $object;
- }
-
- return array($length, $object_list);
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥È¥×¥í¥Ñ¥Æ¥£¤Î°ìÍ÷¤òÊÖ¤¹
- *
- * getObjectList()¥á¥½¥Ã¥É¤Ï¾ò·ï¤Ë¥Þ¥Ã¥Á¤¹¤ëID¤ò¸µ¤ËEthna_AppObject¤òÀ¸À®¤¹¤ë
- * ¤¿¤á¥³¥¹¥È¤¬¤«¤«¤ë¡£¤³¤Á¤é¤Ï¥×¥í¥Ñ¥Æ¥£¤Î¤ß¤òSELECT¤¹¤ë¤Î¤ÇÄ㥳¥¹¥È¤Ç¥Ç¡¼¥¿
- * ¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬²Äǽ¡£
- *
- * @access public
- * @param string $class Ethna_AppObject¤Î·Ñ¾µ¥¯¥é¥¹Ì¾
- * @param array $keys ¼èÆÀ¤¹¤ë¥×¥í¥Ñ¥Æ¥£°ìÍ÷(null¤Ê¤éÁ´¤Æ)
- * @param array $filter ¸¡º÷¾ò·ï
- * @param array $order ¸¡º÷·ë²Ì¥½¡¼¥È¾ò·ï
- * @param int $offset ¸¡º÷·ë²Ì¼èÆÀ¥ª¥Õ¥»¥Ã¥È
- * @param int $count ¸¡º÷·ë²Ì¼èÆÀ¿ô
- * @return mixed array(0 => ¸¡º÷¾ò·ï¤Ë¥Þ¥Ã¥Á¤·¤¿·ï¿ô, 1 => $offset, $count¤Ë¤è¤ê»ØÄꤵ¤ì¤¿·ï¿ô¤Î¥×¥í¥Ñ¥Æ¥£°ìÍ÷) Ethna_Error:¥¨¥é¡¼
- */
- function getObjectPropList($class, $keys = null, $filter = null, $order = null, $offset = null, $count = null)
- {
- global $_ETHNA_APP_MANAGER_OPL_CACHE;
-
- $prop_list = array();
- $class_name = sprintf("%s_%s", $this->backend->getAppId(), $class);
-
- // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
- $cache_class = strtolower($class_name);
- if (is_array($_ETHNA_APP_MANAGER_OPL_CACHE) == false || array_key_exists($cache_class, $_ETHNA_APP_MANAGER_OPL_CACHE) == false) {
- $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class] = array();
- }
- $cache_key = serialize(array($filter, $order, $offset, $count));
- if (array_key_exists($cache_key, $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class])) {
- // skip
- } else {
- // ¥¥ã¥Ã¥·¥å¹¹¿·
- $tmp =& new $class_name($this->backend);
- $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class][$cache_key] = $tmp->searchProp($keys, $filter, $order, $offset, $count);
- }
-
- return $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class][$cache_key];
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥È¥×¥í¥Ñ¥Æ¥£¤òÊÖ¤¹
- *
- * getObjectPropList()¥á¥½¥Ã¥É¤Î´Ê°×ÈǤǡ¢$filter¤Ë¤è¤ê·ë²Ì¤¬1¥¨¥ó¥È¥ê¤Ë
- * À©¸Â¤µ¤ì¤ë¾ì¹ç(¥×¥é¥¤¥Þ¥ê¥¡¼¤Ç¤Î¸¡º÷Åù)¤ËÍøÍѤ¹¤ë
- *
- * @access public
- * @param string $class Ethna_AppObject¤Î·Ñ¾µ¥¯¥é¥¹Ì¾
- * @param array $keys ¼èÆÀ¤¹¤ë¥×¥í¥Ñ¥Æ¥£°ìÍ÷
- * @param array $filter ¸¡º÷¾ò·ï
- * @return mixed array:¥×¥í¥Ñ¥Æ¥£°ìÍ÷ null:¥¨¥ó¥È¥ê¤Ê¤· Ethna_Error:¥¨¥é¡¼
- */
- function getObjectProp($class, $keys = null, $filter = null)
- {
- global $_ETHNA_APP_MANAGER_OP_CACHE;
-
- $prop_list = array();
- $class_name = sprintf("%s_%s", $this->backend->getAppId(), $class);
-
- // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
- $cache_class = strtolower($class_name);
- if (is_array($_ETHNA_APP_MANAGER_OP_CACHE) == false || array_key_exists($cache_class, $_ETHNA_APP_MANAGER_OP_CACHE) == false) {
- $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class] = array();
- }
- $cache_key = serialize(array($filter));
- if (array_key_exists($cache_key, $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class])) {
- // skip
- } else {
- // ¥¥ã¥Ã¥·¥å¹¹¿·
- $tmp =& new $class_name($this->backend);
- list(, $prop) = $tmp->searchProp($keys, $filter);
- $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class][$cache_key] = count($prop) > 0 ? $prop[0] : null;
- }
-
- return $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class][$cache_key];
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
+ var $backend;
+
+ /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
+ var $config;
+
+ /** @var object Ethna_DB DB¥ª¥Ö¥¸¥§¥¯¥È */
+ var $db;
+
+ /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
+ var $i18n;
+
+ /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_form;
+
+ /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $af;
+
+ /** @var object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È */
+ var $session;
+
+ /**#@-*/
+
+ /**
+ * Ethna_AppManager¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Backend &$backend backend¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_AppManager(&$backend)
+ {
+ // ´ðËÜ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
+ $this->backend =& $backend;
+ $this->config = $backend->getConfig();
+ $this->i18n =& $backend->getI18N();
+ $this->action_form =& $backend->getActionForm();
+ $this->af =& $this->action_form;
+ $this->session =& $backend->getSession();
+
+ $db_list = $backend->getDBList();
+ if (Ethna::isError($db_list) == false) {
+ foreach ($db_list as $elt) {
+ $varname = $elt['varname'];
+ $this->$varname =& $elt['db'];
+ }
+ }
+ }
+
+ /**
+ * °À¤Î°ìÍ÷¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $attr_name °À¤Î̾Á°(ÊÑ¿ô̾)
+ * @return array °ÀÃÍ°ìÍ÷
+ */
+ function getAttrList($attr_name)
+ {
+ $varname = $attr_name . "_list";
+ return $this->$varname;
+ }
+
+ /**
+ * °À¤Îɽ¼¨Ì¾¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $attr_name °À¤Î̾Á°(ÊÑ¿ô̾)
+ * @param mixed $id °ÀID
+ * @return string °À¤Îɽ¼¨Ì¾
+ */
+ function getAttrName($attr_name, $id)
+ {
+ $varname = $attr_name . "_list";
+ if (is_array($this->$varname) == false) {
+ return null;
+ }
+ $list =& $this->$varname;
+ if (isset($list[$id]) == false) {
+ return null;
+ }
+ return $list[$id]['name'];
+ }
+
+ /**
+ * °À¤Îɽ¼¨Ì¾(¾ÜºÙ)¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $attr_name °À¤Î̾Á°(ÊÑ¿ô̾)
+ * @param mixed $id °ÀID
+ * @return string °À¤Î¾ÜºÙɽ¼¨Ì¾
+ */
+ function getAttrLongName($attr_name, $id)
+ {
+ $varname = $attr_name . "_list";
+ if (is_array($this->$varname) == false) {
+ return null;
+ }
+ $list =& $this->$varname;
+ if (isset($list[$id]['long_name']) == false) {
+ return null;
+ }
+
+ return $list[$id]['long_name'];
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥È¤Î°ìÍ÷¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $class Ethna_AppObject¤Î·Ñ¾µ¥¯¥é¥¹Ì¾
+ * @param array $filter ¸¡º÷¾ò·ï
+ * @param array $order ¸¡º÷·ë²Ì¥½¡¼¥È¾ò·ï
+ * @param int $offset ¸¡º÷·ë²Ì¼èÆÀ¥ª¥Õ¥»¥Ã¥È
+ * @param int $count ¸¡º÷·ë²Ì¼èÆÀ¿ô
+ * @return mixed array(0 => ¸¡º÷¾ò·ï¤Ë¥Þ¥Ã¥Á¤·¤¿·ï¿ô, 1 => $offset, $count¤Ë¤è¤ê»ØÄꤵ¤ì¤¿·ï¿ô¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID°ìÍ÷) Ethna_Error:¥¨¥é¡¼
+ * @todo ¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹Âкö(1¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀêÍ¥á¥â¥ê¤¬Â¿¤¤¾ì¹ç)
+ */
+ function getObjectList($class, $filter = null, $order = null, $offset = null, $count = null)
+ {
+ global $_ETHNA_APP_MANAGER_OL_CACHE;
+
+ $object_list = array();
+ $class_name = sprintf("%s_%s", $this->backend->getAppId(), $class);
+
+ // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
+ $cache_class = strtolower($class_name);
+ if (is_array($_ETHNA_APP_MANAGER_OL_CACHE) == false || array_key_exists($cache_class, $_ETHNA_APP_MANAGER_OL_CACHE) == false) {
+ $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class] = array();
+ }
+ $cache_key = serialize(array($filter, $order, $offset, $count));
+ if (array_key_exists($cache_key, $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class])) {
+ list($length, $prop_list) = $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class][$cache_key];
+ } else {
+ // ¥¥ã¥Ã¥·¥å¹¹¿·
+ $tmp =& new $class_name($this->backend);
+ list($length, $prop_list) = $tmp->searchProp(null, $filter, $order, $offset, $count);
+ $_ETHNA_APP_MANAGER_OL_CACHE[$cache_class][$cache_key] = array($length, $prop_list);
+ }
+
+ foreach ($prop_list as $prop) {
+ $object =& new $class_name($this->backend, null, null, $prop);
+ $object_list[] = $object;
+ }
+
+ return array($length, $object_list);
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥È¥×¥í¥Ñ¥Æ¥£¤Î°ìÍ÷¤òÊÖ¤¹
+ *
+ * getObjectList()¥á¥½¥Ã¥É¤Ï¾ò·ï¤Ë¥Þ¥Ã¥Á¤¹¤ëID¤ò¸µ¤ËEthna_AppObject¤òÀ¸À®¤¹¤ë
+ * ¤¿¤á¥³¥¹¥È¤¬¤«¤«¤ë¡£¤³¤Á¤é¤Ï¥×¥í¥Ñ¥Æ¥£¤Î¤ß¤òSELECT¤¹¤ë¤Î¤ÇÄ㥳¥¹¥È¤Ç¥Ç¡¼¥¿
+ * ¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬²Äǽ¡£
+ *
+ * @access public
+ * @param string $class Ethna_AppObject¤Î·Ñ¾µ¥¯¥é¥¹Ì¾
+ * @param array $keys ¼èÆÀ¤¹¤ë¥×¥í¥Ñ¥Æ¥£°ìÍ÷(null¤Ê¤éÁ´¤Æ)
+ * @param array $filter ¸¡º÷¾ò·ï
+ * @param array $order ¸¡º÷·ë²Ì¥½¡¼¥È¾ò·ï
+ * @param int $offset ¸¡º÷·ë²Ì¼èÆÀ¥ª¥Õ¥»¥Ã¥È
+ * @param int $count ¸¡º÷·ë²Ì¼èÆÀ¿ô
+ * @return mixed array(0 => ¸¡º÷¾ò·ï¤Ë¥Þ¥Ã¥Á¤·¤¿·ï¿ô, 1 => $offset, $count¤Ë¤è¤ê»ØÄꤵ¤ì¤¿·ï¿ô¤Î¥×¥í¥Ñ¥Æ¥£°ìÍ÷) Ethna_Error:¥¨¥é¡¼
+ */
+ function getObjectPropList($class, $keys = null, $filter = null, $order = null, $offset = null, $count = null)
+ {
+ global $_ETHNA_APP_MANAGER_OPL_CACHE;
+
+ $prop_list = array();
+ $class_name = sprintf("%s_%s", $this->backend->getAppId(), $class);
+
+ // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
+ $cache_class = strtolower($class_name);
+ if (is_array($_ETHNA_APP_MANAGER_OPL_CACHE) == false || array_key_exists($cache_class, $_ETHNA_APP_MANAGER_OPL_CACHE) == false) {
+ $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class] = array();
+ }
+ $cache_key = serialize(array($filter, $order, $offset, $count));
+ if (array_key_exists($cache_key, $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class])) {
+ // skip
+ } else {
+ // ¥¥ã¥Ã¥·¥å¹¹¿·
+ $tmp =& new $class_name($this->backend);
+ $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class][$cache_key] = $tmp->searchProp($keys, $filter, $order, $offset, $count);
+ }
+
+ return $_ETHNA_APP_MANAGER_OPL_CACHE[$cache_class][$cache_key];
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥È¥×¥í¥Ñ¥Æ¥£¤òÊÖ¤¹
+ *
+ * getObjectPropList()¥á¥½¥Ã¥É¤Î´Ê°×ÈǤǡ¢$filter¤Ë¤è¤ê·ë²Ì¤¬1¥¨¥ó¥È¥ê¤Ë
+ * À©¸Â¤µ¤ì¤ë¾ì¹ç(¥×¥é¥¤¥Þ¥ê¥¡¼¤Ç¤Î¸¡º÷Åù)¤ËÍøÍѤ¹¤ë
+ *
+ * @access public
+ * @param string $class Ethna_AppObject¤Î·Ñ¾µ¥¯¥é¥¹Ì¾
+ * @param array $keys ¼èÆÀ¤¹¤ë¥×¥í¥Ñ¥Æ¥£°ìÍ÷
+ * @param array $filter ¸¡º÷¾ò·ï
+ * @return mixed array:¥×¥í¥Ñ¥Æ¥£°ìÍ÷ null:¥¨¥ó¥È¥ê¤Ê¤· Ethna_Error:¥¨¥é¡¼
+ */
+ function getObjectProp($class, $keys = null, $filter = null)
+ {
+ global $_ETHNA_APP_MANAGER_OP_CACHE;
+
+ $prop_list = array();
+ $class_name = sprintf("%s_%s", $this->backend->getAppId(), $class);
+
+ // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
+ $cache_class = strtolower($class_name);
+ if (is_array($_ETHNA_APP_MANAGER_OP_CACHE) == false || array_key_exists($cache_class, $_ETHNA_APP_MANAGER_OP_CACHE) == false) {
+ $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class] = array();
+ }
+ $cache_key = serialize(array($filter));
+ if (array_key_exists($cache_key, $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class])) {
+ // skip
+ } else {
+ // ¥¥ã¥Ã¥·¥å¹¹¿·
+ $tmp =& new $class_name($this->backend);
+ list(, $prop) = $tmp->searchProp($keys, $filter);
+ $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class][$cache_key] = count($prop) > 0 ? $prop[0] : null;
+ }
+
+ return $_ETHNA_APP_MANAGER_OP_CACHE[$cache_class][$cache_key];
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_AppSQL.php
+ * Ethna_AppSQL.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_AppSQL
/**
- * ¥¢¥×¥ê¥±¡¼¥·¥ç¥óSQL¥Ù¡¼¥¹¥¯¥é¥¹
+ * ¥¢¥×¥ê¥±¡¼¥·¥ç¥óSQL¥Ù¡¼¥¹¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_AppSQL
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_AppSQL¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Controller &$controller controller¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_AppSQL(&$controller)
- {
- $this->controller =& $controller;
- }
+ /**
+ * Ethna_AppSQL¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Controller &$controller controller¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_AppSQL(&$controller)
+ {
+ $this->controller =& $controller;
+ }
- /**
- * ŬÀڤ˥¨¥¹¥±¡¼¥×¤µ¤ì¤¿SQLʸ¤òÊÖ¤¹
- *
- * @access public
- * @param string $sqlfunc SQLʸ¼ïÊÌ̾
- * @param array $args °ú¿ô°ìÍ÷
- * @return string ¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿SQLʸ
- */
- function get($sqlid, $args)
- {
- Ethna_AppSQL::escapeSQL($args);
+ /**
+ * ŬÀڤ˥¨¥¹¥±¡¼¥×¤µ¤ì¤¿SQLʸ¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $sqlfunc SQLʸ¼ïÊÌ̾
+ * @param array $args °ú¿ô°ìÍ÷
+ * @return string ¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿SQLʸ
+ */
+ function get($sqlid, $args)
+ {
+ Ethna_AppSQL::escapeSQL($args);
- return call_user_func_array(array(&$this, $sqlid), $args);
- }
+ return call_user_func_array(array(&$this, $sqlid), $args);
+ }
- /**
- * SQL°ú¿ô¤ò¥¨¥¹¥±¡¼¥×¤¹¤ë
- *
- * @access public
- * @param mixed &$var ¥¨¥¹¥±¡¼¥×¤¹¤ëÃÍ
- * @static
- */
- function escapeSQL(&$var)
- {
- if (!is_array($var)) {
- if (is_null($var)) {
- $var = 'NULL';
- } else {
- $var ='\'' . addslashes($var) . '\'';
- }
- return;
- }
- foreach (array_keys($var) as $key) {
- Ethna_AppSQL::escapeSQL($var[$key]);
- }
- }
+ /**
+ * SQL°ú¿ô¤ò¥¨¥¹¥±¡¼¥×¤¹¤ë
+ *
+ * @access public
+ * @param mixed &$var ¥¨¥¹¥±¡¼¥×¤¹¤ëÃÍ
+ * @static
+ */
+ function escapeSQL(&$var)
+ {
+ if (!is_array($var)) {
+ if (is_null($var)) {
+ $var = 'NULL';
+ } else {
+ $var ='\'' . addslashes($var) . '\'';
+ }
+ return;
+ }
+ foreach (array_keys($var) as $key) {
+ Ethna_AppSQL::escapeSQL($var[$key]);
+ }
+ }
- /**
- * escapeSQL¤Ç¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿Ê¸»úÎó¤òunescape¤¹¤ë
- *
- * @access public
- * @param mixed &$var ¥¨¥¹¥±¡¼¥×¤òÉüµ¢¤¹¤ëÃÍ
- * @static
- */
- function unescapeSQL(&$var)
- {
- if (!is_array($var)) {
- if ($var == 'NULL') {
- return;
- }
- $var = substr($var, 1, strlen($var)-2);
- $var = stripslashes($var);
- return;
- }
- foreach (array_keys($var) as $key) {
- Ethna_AppSQL::unescapeSQL($var[$key]);
- }
- }
+ /**
+ * escapeSQL¤Ç¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿Ê¸»úÎó¤òunescape¤¹¤ë
+ *
+ * @access public
+ * @param mixed &$var ¥¨¥¹¥±¡¼¥×¤òÉüµ¢¤¹¤ëÃÍ
+ * @static
+ */
+ function unescapeSQL(&$var)
+ {
+ if (!is_array($var)) {
+ if ($var == 'NULL') {
+ return;
+ }
+ $var = substr($var, 1, strlen($var)-2);
+ $var = stripslashes($var);
+ return;
+ }
+ foreach (array_keys($var) as $key) {
+ Ethna_AppSQL::unescapeSQL($var[$key]);
+ }
+ }
- /**
- * WHERE¾ò·ïʸ¤òÀ¸À®¤¹¤ë
- *
- * @access public
- * @param string $field ¸¡º÷ÂоݤΥե£¡¼¥ë¥É
- * @param string $value ¸¡º÷ÃÍ
- * @param int $condition ¸¡º÷¾ò·ï(OBJECT_CONDITION_NE,...)
- * @return string ¸¡º÷¾ò·ïʸ
- * @static
- */
- function getCondition($field, $value, $condition = OBJECT_CONDITION_EQ)
- {
- switch ($condition) {
- case OBJECT_CONDITION_EQ:
- $op = "="; break;
- case OBJECT_CONDITION_NE:
- $op = "!="; break;
- case OBJECT_CONDITION_LIKE:
- $op = "LIKE"; break;
- case OBJECT_CONDITION_GT:
- $op = ">"; break;
- case OBJECT_CONDITION_LT:
- $op = "<"; break;
- case OBJECT_CONDITION_GE:
- $op = ">="; break;
- case OBJECT_CONDITION_LE:
- $op = "<="; break;
- }
+ /**
+ * WHERE¾ò·ïʸ¤òÀ¸À®¤¹¤ë
+ *
+ * @access public
+ * @param string $field ¸¡º÷ÂоݤΥե£¡¼¥ë¥É
+ * @param string $value ¸¡º÷ÃÍ
+ * @param int $condition ¸¡º÷¾ò·ï(OBJECT_CONDITION_NE,...)
+ * @return string ¸¡º÷¾ò·ïʸ
+ * @static
+ */
+ function getCondition($field, $value, $condition = OBJECT_CONDITION_EQ)
+ {
+ switch ($condition) {
+ case OBJECT_CONDITION_EQ:
+ $op = "="; break;
+ case OBJECT_CONDITION_NE:
+ $op = "!="; break;
+ case OBJECT_CONDITION_LIKE:
+ $op = "LIKE"; break;
+ case OBJECT_CONDITION_GT:
+ $op = ">"; break;
+ case OBJECT_CONDITION_LT:
+ $op = "<"; break;
+ case OBJECT_CONDITION_GE:
+ $op = ">="; break;
+ case OBJECT_CONDITION_LE:
+ $op = "<="; break;
+ }
- // default operand
- $operand = $value;
+ // default operand
+ $operand = $value;
- if (is_array($value)) {
- if (count($value) > 0) {
- switch ($condition) {
- case OBJECT_CONDITION_EQ:
- $op = "IN"; break;
- case OBJECT_CONDITION_NE:
- $op = "NOT IN"; break;
- }
- $operand = sprintf("(%s)", implode(',', $value));
- } else {
- // always be false
- $op = "=";
- $operand = "NULL";
- }
- } else {
- if ($value == 'NULL') {
- switch ($condition) {
- case OBJECT_CONDITION_EQ:
- $op = "IS"; break;
- case OBJECT_CONDITION_NE:
- $op = "IS NOT"; break;
- }
- }
- if ($condition == OBJECT_CONDITION_LIKE) {
- Ethna_AppSQL::unescapeSQL($value);
- $value = '%' . str_replace('%', '\\%', $value) . '%';
- Ethna_AppSQL::escapeSQL($value);
- $operand = $value;
- }
- }
- return "$field $op $operand";
- }
+ if (is_array($value)) {
+ if (count($value) > 0) {
+ switch ($condition) {
+ case OBJECT_CONDITION_EQ:
+ $op = "IN"; break;
+ case OBJECT_CONDITION_NE:
+ $op = "NOT IN"; break;
+ }
+ $operand = sprintf("(%s)", implode(',', $value));
+ } else {
+ // always be false
+ $op = "=";
+ $operand = "NULL";
+ }
+ } else {
+ if ($value == 'NULL') {
+ switch ($condition) {
+ case OBJECT_CONDITION_EQ:
+ $op = "IS"; break;
+ case OBJECT_CONDITION_NE:
+ $op = "IS NOT"; break;
+ }
+ }
+ if ($condition == OBJECT_CONDITION_LIKE) {
+ Ethna_AppSQL::unescapeSQL($value);
+ $value = '%' . str_replace('%', '\\%', $value) . '%';
+ Ethna_AppSQL::escapeSQL($value);
+ $operand = $value;
+ }
+ }
+ return "$field $op $operand";
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_AppSearchObject.php
+ * Ethna_AppSearchObject.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
/** ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È¸¡º÷¾ò·ï: != */
// {{{ Ethna_AppSearchObject
/**
- * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È¸¡º÷¾ò·ï¥¯¥é¥¹
+ * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È¸¡º÷¾ò·ï¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_AppSearchObject
{
- /**#@+
- * @access private
- */
-
- /** @var string ¸¡º÷ÃÍ */
- var $value;
-
- /** @var int ¸¡º÷¾ò·ï */
- var $condition;
-
- /**
- * @var array Äɲø¡º÷¾ò·ï¤òÊÝ»ý¤·¤¿Ethna_AppSearchObject¤Î°ìÍ÷
- */
- var $object_list = array();
-
- /**#@-*/
-
-
- /**
- * Ethna_AppSearchObject¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param string $value ¸¡º÷ÃÍ
- * @param int $condition ¸¡º÷¾ò·ï(OBJECT_CONDITION_NE,...)
- */
- function Ethna_AppSearchObject($value, $condition)
- {
- $this->value = $value;
- $this->condition = $condition;
- }
-
- /**
- * ¸¡º÷¾ò·ï¤òOR/AND¤ÇÄɲ乤ë
- *
- * @access public
- * @param string $name ¸¡º÷Âоݥ«¥é¥à̾
- * @param object Ethna_AppSearchObject $search_object Äɲ乤븡º÷¾ò·ï
- * @param int $condition Äɲþò·ï(OR/AND)
- */
- function addObject($name, $search_object, $condition)
- {
- $tmp = array();
- $tmp['name'] = $name;
- $tmp['object'] =& $search_object;
- $tmp['condition'] = $condition;
- $this->object_list[] = $tmp;
- }
-
- /**
- * »ØÄꤵ¤ì¤¿¥Õ¥£¡¼¥ë¥É¤¬¸¡º÷ÂоݤȤʤäƤ¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
- *
- * @access public
- */
- function isTarget($field)
- {
- foreach ($this->object_list as $object) {
- if ($object['name'] == $field) {
- return true;
- }
- if (is_object($object['object'])) {
- $r = $object['object']->isTarget($field);
- if ($r) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * ¸¡º÷¾ò·ïSQLʸ¤òÊÖ¤¹
- *
- * @access public
- * @param string ¸¡º÷Âоݥ«¥é¥à̾
- * @return SQLʸ
- */
- function toString($column)
- {
- $condition = "(";
- $tmp_value = $this->value;
- Ethna_AppSQL::escapeSQL($tmp_value);
- $condition .= Ethna_AppSQL::getCondition("$column", $tmp_value, $this->condition);
-
- foreach ($this->object_list as $elt) {
- if ($elt['condition'] == OBJECT_CONDITION_OR) {
- $condition .= " OR ";
- } else {
- $condition .= " AND ";
- }
- $condition .= $elt['object']->toString($elt['name']);
- }
-
- return $condition . ")";
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var string ¸¡º÷ÃÍ */
+ var $value;
+
+ /** @var int ¸¡º÷¾ò·ï */
+ var $condition;
+
+ /**
+ * @var array Äɲø¡º÷¾ò·ï¤òÊÝ»ý¤·¤¿Ethna_AppSearchObject¤Î°ìÍ÷
+ */
+ var $object_list = array();
+
+ /**#@-*/
+
+
+ /**
+ * Ethna_AppSearchObject¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param string $value ¸¡º÷ÃÍ
+ * @param int $condition ¸¡º÷¾ò·ï(OBJECT_CONDITION_NE,...)
+ */
+ function Ethna_AppSearchObject($value, $condition)
+ {
+ $this->value = $value;
+ $this->condition = $condition;
+ }
+
+ /**
+ * ¸¡º÷¾ò·ï¤òOR/AND¤ÇÄɲ乤ë
+ *
+ * @access public
+ * @param string $name ¸¡º÷Âоݥ«¥é¥à̾
+ * @param object Ethna_AppSearchObject $search_object Äɲ乤븡º÷¾ò·ï
+ * @param int $condition Äɲþò·ï(OR/AND)
+ */
+ function addObject($name, $search_object, $condition)
+ {
+ $tmp = array();
+ $tmp['name'] = $name;
+ $tmp['object'] =& $search_object;
+ $tmp['condition'] = $condition;
+ $this->object_list[] = $tmp;
+ }
+
+ /**
+ * »ØÄꤵ¤ì¤¿¥Õ¥£¡¼¥ë¥É¤¬¸¡º÷ÂоݤȤʤäƤ¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
+ *
+ * @access public
+ */
+ function isTarget($field)
+ {
+ foreach ($this->object_list as $object) {
+ if ($object['name'] == $field) {
+ return true;
+ }
+ if (is_object($object['object'])) {
+ $r = $object['object']->isTarget($field);
+ if ($r) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * ¸¡º÷¾ò·ïSQLʸ¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string ¸¡º÷Âоݥ«¥é¥à̾
+ * @return SQLʸ
+ */
+ function toString($column)
+ {
+ $condition = "(";
+ $tmp_value = $this->value;
+ Ethna_AppSQL::escapeSQL($tmp_value);
+ $condition .= Ethna_AppSQL::getCondition("$column", $tmp_value, $this->condition);
+
+ foreach ($this->object_list as $elt) {
+ if ($elt['condition'] == OBJECT_CONDITION_OR) {
+ $condition .= " OR ";
+ } else {
+ $condition .= " AND ";
+ }
+ $condition .= $elt['object']->toString($elt['name']);
+ }
+
+ return $condition . ")";
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker tabstop=4 shiftwidth=4 autoindent
/**
- * Ethna_CacheManager.php
+ * Ethna_CacheManager.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
+ * @author Masaki Fujimoto <fujimoto@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @package Ethna
- * @version $Id$
+ * @version $Id$
*/
/**
- * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹
+ * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_CacheManager
{
- /**
- * Ethna_CacheMaanger¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $type ¥¥ã¥Ã¥·¥å¥¿¥¤¥×('localfile', 'memcache'...)
- * @return object Ethna_CacheMaanger Ethna_CacheManager¥ª¥Ö¥¸¥§¥¯¥È
- */
- function &getInstance($type)
- {
+ /**
+ * Ethna_CacheMaanger¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $type ¥¥ã¥Ã¥·¥å¥¿¥¤¥×('localfile', 'memcache'...)
+ * @return object Ethna_CacheMaanger Ethna_CacheManager¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function &getInstance($type)
+ {
$controller =& Ethna_Controller::getInstance();
$plugin =& $controller->getPlugin();
$cache_manager =& $plugin->getPlugin('Cachemanager', ucfirst($type));
return $cache_manager;
- }
+ }
}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_ClassFactory.php
+ * Ethna_ClassFactory.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_ClassFactory
/**
- * Ethna¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥²¡¼¥È¥¦¥§¥¤
+ * Ethna¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥²¡¼¥È¥¦¥§¥¤
*
- * DI¥³¥ó¥Æ¥Ê¤«¡¢¤È¤¤¤¦¤³¤È¤â¹Í¤¨¤Þ¤·¤¿¤¬Ethna¤Ç¤Ï¤³¤ÎÄøÅÙ¤Îñ½ã¤Ê¤â¤Î¤Ë
- * α¤á¤Æ¤ª¤¤Þ¤¹¡£¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥ì¥Ù¥ëDI¤·¤¿¤¤¾ì¹ç¤Ï¥Õ¥£¥ë¥¿¥Á¥§¥¤¥ó¤ò
- * »È¤Ã¤Æ¼Â¸½¤¹¤ë¤³¤È¤â½ÐÍè¤Þ¤¹¡£
+ * DI¥³¥ó¥Æ¥Ê¤«¡¢¤È¤¤¤¦¤³¤È¤â¹Í¤¨¤Þ¤·¤¿¤¬Ethna¤Ç¤Ï¤³¤ÎÄøÅÙ¤Îñ½ã¤Ê¤â¤Î¤Ë
+ * α¤á¤Æ¤ª¤¤Þ¤¹¡£¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥ì¥Ù¥ëDI¤·¤¿¤¤¾ì¹ç¤Ï¥Õ¥£¥ë¥¿¥Á¥§¥¤¥ó¤ò
+ * »È¤Ã¤Æ¼Â¸½¤¹¤ë¤³¤È¤â½ÐÍè¤Þ¤¹¡£
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_ClassFactory
{
- /**#@+
- * @access private
- */
-
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
-
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $ctl;
-
- /** @var array ¥¯¥é¥¹ÄêµÁ */
- var $class = array();
-
- /** @var array À¸À®ºÑ¤ß¥ª¥Ö¥¸¥§¥¯¥È¥¥ã¥Ã¥·¥å */
- var $object = array();
-
- /**#@-*/
-
-
- /**
- * Ethna_ClassFactory¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Controller &$controller controller¥ª¥Ö¥¸¥§¥¯¥È
- * @param array $class ¥¯¥é¥¹ÄêµÁ
- */
- function Ethna_ClassFactory(&$controller, $class)
- {
- $this->controller =& $controller;
- $this->ctl =& $controller;
- $this->class = $class;
- }
-
- /**
- * ¥¯¥é¥¹¥¡¼¤ËÂбþ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹
- *
- * @access public
- * @param string $key ¥¯¥é¥¹¥¡¼
- * @param bool $weak ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ì¤À¸À®¤Î¾ì¹ç¤Î¶¯À©À¸À®¥Õ¥é¥°(default: false)
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &getObject($key, $weak = false)
- {
- if (isset($this->class[$key]) == false) {
- return null;
- }
- $class_name = $this->class[$key];
- if (isset($this->object[$key]) && is_object($this->object[$key])) {
- return $this->object[$key];
- }
-
- $method = sprintf('_getObject_%s', ucfirst($key));
- if (method_exists($this, $method)) {
- $obj =& $this->$method($class_name);
- } else {
- $obj =& new $class_name();
- }
- $this->object[$key] =& $obj;
-
- return $obj;
- }
-
- /**
- * ¥¯¥é¥¹¥¡¼¤ËÂбþ¤¹¤ë¥¯¥é¥¹Ì¾¤òÊÖ¤¹
- *
- * @access public
- * @param string $key ¥¯¥é¥¹¥¡¼
- * @return string ¥¯¥é¥¹Ì¾
- */
- function getObjectName($key)
- {
- if (isset($this->class[$key]) == false) {
- return null;
- }
-
- return $this->class[$key];
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(backend)
- *
- * @access protected
- * @param string $class_name ¥¯¥é¥¹Ì¾
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &_getObject_Backend($class_name)
- {
- $_ret_object =& new $class_name($this->ctl);
- return $_ret_object;
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(config)
- *
- * @access protected
- * @param string $class_name ¥¯¥é¥¹Ì¾
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &_getObject_Config($class_name)
- {
- $_ret_object =& new $class_name($this->ctl);
- return $_ret_object;
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(i18n)
- *
- * @access protected
- * @param string $class_name ¥¯¥é¥¹Ì¾
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &_getObject_I18n($class_name)
- {
- $_ret_object =& new $class_name($this->ctl->getDirectory('locale'), $this->ctl->getAppId());
- return $_ret_object;
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(logger)
- *
- * @access protected
- * @param string $class_name ¥¯¥é¥¹Ì¾
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &_getObject_Logger($class_name)
- {
- $_ret_object =& new $class_name($this->ctl);
- return $_ret_object;
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(plugin)
- *
- * @access protected
- * @param string $class_name ¥¯¥é¥¹Ì¾
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &_getObject_Plugin($class_name)
- {
- $_ret_object =& new $class_name($this->ctl);
- return $_ret_object;
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(session)
- *
- * @access protected
- * @param string $class_name ¥¯¥é¥¹Ì¾
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &_getObject_Session($class_name)
- {
- $_ret_object =& new $class_name($this->ctl->getAppId(), $this->ctl->getDirectory('tmp'), $this->ctl->getLogger());
- return $_ret_object;
- }
-
- /**
- * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(sql)
- *
- * @access protected
- * @param string $class_name ¥¯¥é¥¹Ì¾
- * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
- */
- function &_getObject_Sql($class_name)
- {
- $_ret_object =& new $class_name($this->ctl);
- return $_ret_object;
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
+
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $ctl;
+
+ /** @var array ¥¯¥é¥¹ÄêµÁ */
+ var $class = array();
+
+ /** @var array À¸À®ºÑ¤ß¥ª¥Ö¥¸¥§¥¯¥È¥¥ã¥Ã¥·¥å */
+ var $object = array();
+
+ /**#@-*/
+
+
+ /**
+ * Ethna_ClassFactory¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Controller &$controller controller¥ª¥Ö¥¸¥§¥¯¥È
+ * @param array $class ¥¯¥é¥¹ÄêµÁ
+ */
+ function Ethna_ClassFactory(&$controller, $class)
+ {
+ $this->controller =& $controller;
+ $this->ctl =& $controller;
+ $this->class = $class;
+ }
+
+ /**
+ * ¥¯¥é¥¹¥¡¼¤ËÂбþ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $key ¥¯¥é¥¹¥¡¼
+ * @param bool $weak ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ì¤À¸À®¤Î¾ì¹ç¤Î¶¯À©À¸À®¥Õ¥é¥°(default: false)
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &getObject($key, $weak = false)
+ {
+ if (isset($this->class[$key]) == false) {
+ return null;
+ }
+ $class_name = $this->class[$key];
+ if (isset($this->object[$key]) && is_object($this->object[$key])) {
+ return $this->object[$key];
+ }
+
+ $method = sprintf('_getObject_%s', ucfirst($key));
+ if (method_exists($this, $method)) {
+ $obj =& $this->$method($class_name);
+ } else {
+ $obj =& new $class_name();
+ }
+ $this->object[$key] =& $obj;
+
+ return $obj;
+ }
+
+ /**
+ * ¥¯¥é¥¹¥¡¼¤ËÂбþ¤¹¤ë¥¯¥é¥¹Ì¾¤òÊÖ¤¹
+ *
+ * @access public
+ * @param string $key ¥¯¥é¥¹¥¡¼
+ * @return string ¥¯¥é¥¹Ì¾
+ */
+ function getObjectName($key)
+ {
+ if (isset($this->class[$key]) == false) {
+ return null;
+ }
+
+ return $this->class[$key];
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(backend)
+ *
+ * @access protected
+ * @param string $class_name ¥¯¥é¥¹Ì¾
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &_getObject_Backend($class_name)
+ {
+ $_ret_object =& new $class_name($this->ctl);
+ return $_ret_object;
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(config)
+ *
+ * @access protected
+ * @param string $class_name ¥¯¥é¥¹Ì¾
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &_getObject_Config($class_name)
+ {
+ $_ret_object =& new $class_name($this->ctl);
+ return $_ret_object;
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(i18n)
+ *
+ * @access protected
+ * @param string $class_name ¥¯¥é¥¹Ì¾
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &_getObject_I18n($class_name)
+ {
+ $_ret_object =& new $class_name($this->ctl->getDirectory('locale'), $this->ctl->getAppId());
+ return $_ret_object;
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(logger)
+ *
+ * @access protected
+ * @param string $class_name ¥¯¥é¥¹Ì¾
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &_getObject_Logger($class_name)
+ {
+ $_ret_object =& new $class_name($this->ctl);
+ return $_ret_object;
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(plugin)
+ *
+ * @access protected
+ * @param string $class_name ¥¯¥é¥¹Ì¾
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &_getObject_Plugin($class_name)
+ {
+ $_ret_object =& new $class_name($this->ctl);
+ return $_ret_object;
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(session)
+ *
+ * @access protected
+ * @param string $class_name ¥¯¥é¥¹Ì¾
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &_getObject_Session($class_name)
+ {
+ $_ret_object =& new $class_name($this->ctl->getAppId(), $this->ctl->getDirectory('tmp'), $this->ctl->getLogger());
+ return $_ret_object;
+ }
+
+ /**
+ * ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥á¥½¥Ã¥É(sql)
+ *
+ * @access protected
+ * @param string $class_name ¥¯¥é¥¹Ì¾
+ * @return object À¸À®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È(¥¨¥é¡¼¤Ê¤énull)
+ */
+ function &_getObject_Sql($class_name)
+ {
+ $_ret_object =& new $class_name($this->ctl);
+ return $_ret_object;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Config.php
+ * Ethna_Config.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Config
/**
- * ÀßÄꥯ¥é¥¹
+ * ÀßÄꥯ¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Config
{
- /**#@+
- * @access private
- */
-
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
-
- /** @var array ÀßÄêÆâÍÆ */
- var $config = null;
-
- /**#@-*/
-
-
- /**
- * Ethna_Config¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Controller &$controller controller¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_Config(&$controller)
- {
- $this->controller =& $controller;
-
- // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß
- $r = $this->_getConfig();
- if (Ethna::isError($r)) {
- // ¤³¤Î»þÅÀ¤Ç¤ÏloggingÅù¤Ï½ÐÍè¤Ê¤¤(Logger¥ª¥Ö¥¸¥§¥¯¥È¤¬À¸À®¤µ¤ì¤Æ¤¤¤Ê¤¤)
- $fp = fopen("php://stderr", "r");
- fputs($fp, sprintf("error occured while reading config file(s) [%s]\n"), $r->getInfo(0));
- fclose($fp);
- $this->controller->fatal();
- }
- }
-
- /**
- * ÀßÄêÃͤؤΥ¢¥¯¥»¥µ(R)
- *
- * @access public
- * @param string $key ÀßÄê¹àÌÜ̾
- * @return string ÀßÄêÃÍ
- */
- function get($key)
- {
- if (isset($this->config[$key]) == false) {
- return null;
- }
- return $this->config[$key];
- }
-
- /**
- * ÀßÄêÃͤؤΥ¢¥¯¥»¥µ(W)
- *
- * @access public
- * @param string $key ÀßÄê¹àÌÜ̾
- * @param string $value ÀßÄêÃÍ
- */
- function set($key, $value)
- {
- $this->config[$key] = $value;
- }
-
- /**
- * ÀßÄê¥Õ¥¡¥¤¥ë¤ò¹¹¿·¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function update()
- {
- return $this->_setConfig();
- }
-
- /**
- * ÀßÄê¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à
- *
- * @access private
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function _getConfig()
- {
- $config = array();
- $file = $this->_getConfigFile();
- if (file_exists($file)) {
- $lh = Ethna_Util::lockFile($file, 'r');
- if (Ethna::isError($lh)) {
- return $lh;
- }
-
- include($file);
-
- Ethna_Util::unlockFile($lh);
- }
-
- // ¥Ç¥Õ¥©¥ë¥ÈÃÍÀßÄê
- if (isset($_SERVER['HTTP_HOST']) && isset($config['url']) == false) {
- $config['url'] = sprintf("http://%s", $_SERVER['HTTP_HOST']);
- }
- if (isset($config['dsn']) == false) {
- $config['dsn'] = "";
- }
- if (isset($config['log_facility']) == false) {
- $config['log_facility'] = "";
- }
- if (isset($config['log_level']) == false) {
- $config['log_level'] = "";
- }
- if (isset($config['log_option']) == false) {
- $config['log_option'] = "";
- }
-
- $this->config = $config;
-
- return 0;
- }
-
- /**
- * ÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤à
- *
- * @access private
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function _setConfig()
- {
- $file = $this->_getConfigFile();
-
- $lh = Ethna_Util::lockFile($file, 'w');
- if (Ethna::isError($lh)) {
- return $lh;
- }
-
- $fp = fopen($file, 'w');
- if ($fp == null) {
- return Ethna::raiseError(E_APP_WRITE, "¥Õ¥¡¥¤¥ë½ñ¤¹þ¤ß¥¨¥é¡¼[%s]", $file);
- }
- fwrite($fp, "<?php\n");
- fwrite($fp, sprintf("/*\n * %s\n *\n * update: %s\n */\n", basename($file), strftime('%Y/%m/%d %H:%M:%S')));
- fwrite($fp, "\$config = array(\n");
- foreach ($this->config as $key => $value) {
- $this->_setConfigValue($fp, $key, $value, 0);
- }
- fwrite($fp, ");\n?>\n");
- fclose($fp);
-
- Ethna_Util::unlockFile($lh);
-
- return 0;
- }
-
- /**
- * ÀßÄê¥Õ¥¡¥¤¥ë¤ËÀßÄêÃͤò½ñ¤¹þ¤à
- *
- * @access private
- */
- function _setConfigValue($fp, $key, $value, $level)
- {
- fputs($fp, sprintf("%s'%s' => ", str_repeat("\t", $level+1), $key));
- if (is_array($value)) {
- fputs($fp, sprintf("array(\n"));
- foreach ($value as $k => $v) {
- $this->_setConfigValue($fp, $k, $v, $level+1);
- }
- fputs($fp, sprintf("%s),\n", str_repeat("\t", $level+1)));
- } else {
- fputs($fp, sprintf("'%s',\n", $value));
- }
- }
-
- /**
- * ÀßÄê¥Õ¥¡¥¤¥ë̾¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string ÀßÄê¥Õ¥¡¥¤¥ë¤Ø¤Î¥Õ¥ë¥Ñ¥¹Ì¾
- */
- function _getConfigFile()
- {
- return $this->controller->getDirectory('etc') . '/' . strtolower($this->controller->getAppId()) . '-ini.php';
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
+
+ /** @var array ÀßÄêÆâÍÆ */
+ var $config = null;
+
+ /**#@-*/
+
+
+ /**
+ * Ethna_Config¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Controller &$controller controller¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_Config(&$controller)
+ {
+ $this->controller =& $controller;
+
+ // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß
+ $r = $this->_getConfig();
+ if (Ethna::isError($r)) {
+ // ¤³¤Î»þÅÀ¤Ç¤ÏloggingÅù¤Ï½ÐÍè¤Ê¤¤(Logger¥ª¥Ö¥¸¥§¥¯¥È¤¬À¸À®¤µ¤ì¤Æ¤¤¤Ê¤¤)
+ $fp = fopen("php://stderr", "r");
+ fputs($fp, sprintf("error occured while reading config file(s) [%s]\n"), $r->getInfo(0));
+ fclose($fp);
+ $this->controller->fatal();
+ }
+ }
+
+ /**
+ * ÀßÄêÃͤؤΥ¢¥¯¥»¥µ(R)
+ *
+ * @access public
+ * @param string $key ÀßÄê¹àÌÜ̾
+ * @return string ÀßÄêÃÍ
+ */
+ function get($key)
+ {
+ if (isset($this->config[$key]) == false) {
+ return null;
+ }
+ return $this->config[$key];
+ }
+
+ /**
+ * ÀßÄêÃͤؤΥ¢¥¯¥»¥µ(W)
+ *
+ * @access public
+ * @param string $key ÀßÄê¹àÌÜ̾
+ * @param string $value ÀßÄêÃÍ
+ */
+ function set($key, $value)
+ {
+ $this->config[$key] = $value;
+ }
+
+ /**
+ * ÀßÄê¥Õ¥¡¥¤¥ë¤ò¹¹¿·¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function update()
+ {
+ return $this->_setConfig();
+ }
+
+ /**
+ * ÀßÄê¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à
+ *
+ * @access private
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function _getConfig()
+ {
+ $config = array();
+ $file = $this->_getConfigFile();
+ if (file_exists($file)) {
+ $lh = Ethna_Util::lockFile($file, 'r');
+ if (Ethna::isError($lh)) {
+ return $lh;
+ }
+
+ include($file);
+
+ Ethna_Util::unlockFile($lh);
+ }
+
+ // ¥Ç¥Õ¥©¥ë¥ÈÃÍÀßÄê
+ if (isset($_SERVER['HTTP_HOST']) && isset($config['url']) == false) {
+ $config['url'] = sprintf("http://%s", $_SERVER['HTTP_HOST']);
+ }
+ if (isset($config['dsn']) == false) {
+ $config['dsn'] = "";
+ }
+ if (isset($config['log_facility']) == false) {
+ $config['log_facility'] = "";
+ }
+ if (isset($config['log_level']) == false) {
+ $config['log_level'] = "";
+ }
+ if (isset($config['log_option']) == false) {
+ $config['log_option'] = "";
+ }
+
+ $this->config = $config;
+
+ return 0;
+ }
+
+ /**
+ * ÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤à
+ *
+ * @access private
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function _setConfig()
+ {
+ $file = $this->_getConfigFile();
+
+ $lh = Ethna_Util::lockFile($file, 'w');
+ if (Ethna::isError($lh)) {
+ return $lh;
+ }
+
+ $fp = fopen($file, 'w');
+ if ($fp == null) {
+ return Ethna::raiseError(E_APP_WRITE, "¥Õ¥¡¥¤¥ë½ñ¤¹þ¤ß¥¨¥é¡¼[%s]", $file);
+ }
+ fwrite($fp, "<?php\n");
+ fwrite($fp, sprintf("/*\n * %s\n *\n * update: %s\n */\n", basename($file), strftime('%Y/%m/%d %H:%M:%S')));
+ fwrite($fp, "\$config = array(\n");
+ foreach ($this->config as $key => $value) {
+ $this->_setConfigValue($fp, $key, $value, 0);
+ }
+ fwrite($fp, ");\n?>\n");
+ fclose($fp);
+
+ Ethna_Util::unlockFile($lh);
+
+ return 0;
+ }
+
+ /**
+ * ÀßÄê¥Õ¥¡¥¤¥ë¤ËÀßÄêÃͤò½ñ¤¹þ¤à
+ *
+ * @access private
+ */
+ function _setConfigValue($fp, $key, $value, $level)
+ {
+ fputs($fp, sprintf("%s'%s' => ", str_repeat("\t", $level+1), $key));
+ if (is_array($value)) {
+ fputs($fp, sprintf("array(\n"));
+ foreach ($value as $k => $v) {
+ $this->_setConfigValue($fp, $k, $v, $level+1);
+ }
+ fputs($fp, sprintf("%s),\n", str_repeat("\t", $level+1)));
+ } else {
+ fputs($fp, sprintf("'%s',\n", $value));
+ }
+ }
+
+ /**
+ * ÀßÄê¥Õ¥¡¥¤¥ë̾¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string ÀßÄê¥Õ¥¡¥¤¥ë¤Ø¤Î¥Õ¥ë¥Ñ¥¹Ì¾
+ */
+ function _getConfigFile()
+ {
+ return $this->controller->getDirectory('etc') . '/' . strtolower($this->controller->getAppId()) . '-ini.php';
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_DB.php
+ * Ethna_DB.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_DB
/**
- * EthnaÍÑDBÃê¾Ý¥¯¥é¥¹
+ * EthnaÍÑDBÃê¾Ý¥¯¥é¥¹
*
- * Ethna¤Î¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤ÇDB¥ª¥Ö¥¸¥§¥¯¥È¤ò°·¤¦¤¿¤á¤ÎÃê¾Ý¥¯¥é¥¹
- * (¤Î¤Ä¤â¤ê...¤¢¤¡¤¹¤Ð¤é¤·¤PHP 4)
+ * Ethna¤Î¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤ÇDB¥ª¥Ö¥¸¥§¥¯¥È¤ò°·¤¦¤¿¤á¤ÎÃê¾Ý¥¯¥é¥¹
+ * (¤Î¤Ä¤â¤ê...¤¢¤¡¤¹¤Ð¤é¤·¤PHP 4)
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_DB
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var object DB DB¥ª¥Ö¥¸¥§¥¯¥È */
- var $db;
+ /** @var object DB DB¥ª¥Ö¥¸¥§¥¯¥È */
+ var $db;
- /** @var array ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó´ÉÍý¥¹¥¿¥Ã¥¯ */
- var $transaction = array();
+ /** @var array ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó´ÉÍý¥¹¥¿¥Ã¥¯ */
+ var $transaction = array();
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_DB¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
- * @param string $dsn DSN
- * @param bool $persistent »ý³ÀܳÀßÄê
- */
- function Ethna_DB(&$controller, $dsn, $persistent)
- {
- $this->dsn = $dsn;
- $this->persistent = $persistent;
- }
+ /**
+ * Ethna_DB¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
+ * @param string $dsn DSN
+ * @param bool $persistent »ý³ÀܳÀßÄê
+ */
+ function Ethna_DB(&$controller, $dsn, $persistent)
+ {
+ $this->dsn = $dsn;
+ $this->persistent = $persistent;
+ }
- /**
- * DB¤ËÀܳ¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function connect()
- {
- }
+ /**
+ * DB¤ËÀܳ¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function connect()
+ {
+ }
- /**
- * DBÀܳ¤òÀÚÃǤ¹¤ë
- *
- * @access public
- */
- function disconnect()
- {
- }
+ /**
+ * DBÀܳ¤òÀÚÃǤ¹¤ë
+ *
+ * @access public
+ */
+ function disconnect()
+ {
+ }
- /**
- * DBÀܳ¾õÂÖ¤òÊÖ¤¹
- *
- * @access public
- * @return bool true:Àµ¾ï(ÀܳºÑ¤ß) false:¥¨¥é¡¼/̤Àܳ
- */
- function isValid()
- {
- }
+ /**
+ * DBÀܳ¾õÂÖ¤òÊÖ¤¹
+ *
+ * @access public
+ * @return bool true:Àµ¾ï(ÀܳºÑ¤ß) false:¥¨¥é¡¼/̤Àܳ
+ */
+ function isValid()
+ {
+ }
- /**
- * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function begin()
- {
- }
+ /**
+ * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function begin()
+ {
+ }
- /**
- * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÃæÃǤ¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function rollback()
- {
- }
+ /**
+ * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÃæÃǤ¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function rollback()
+ {
+ }
- /**
- * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function commit()
- {
- }
+ /**
+ * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function commit()
+ {
+ }
/**
* ¥Æ¡¼¥Ö¥ëÄêµÁ¾ðÊó¤ò¼èÆÀ¤¹¤ë
<?php
// vim: foldmethod=marker
/**
- * Ethna_Error.php
+ * Ethna_Error.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Error
/**
- * ¥¨¥é¡¼¥¯¥é¥¹
+ * ¥¨¥é¡¼¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Error extends PEAR_Error
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
- var $i18n;
+ /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
+ var $i18n;
- /** @var object Ethna_Logger logger¥ª¥Ö¥¸¥§¥¯¥È */
- var $logger;
+ /** @var object Ethna_Logger logger¥ª¥Ö¥¸¥§¥¯¥È */
+ var $logger;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_Error¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param int $level ¥¨¥é¡¼¥ì¥Ù¥ë
- * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- * @param int $code ¥¨¥é¡¼¥³¡¼¥É
- * @param array $userinfo ¥¨¥é¡¼ÄɲþðÊó(¥¨¥é¡¼¥³¡¼¥É°Ê¹ß¤ÎÁ´¤Æ¤Î°ú¿ô)
- */
- function Ethna_Error($message = null, $code = null, $mode = null, $options = null)
- {
- $controller =& Ethna_Controller::getInstance();
+ /**
+ * Ethna_Error¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param int $level ¥¨¥é¡¼¥ì¥Ù¥ë
+ * @param string $message ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ * @param int $code ¥¨¥é¡¼¥³¡¼¥É
+ * @param array $userinfo ¥¨¥é¡¼ÄɲþðÊó(¥¨¥é¡¼¥³¡¼¥É°Ê¹ß¤ÎÁ´¤Æ¤Î°ú¿ô)
+ */
+ function Ethna_Error($message = null, $code = null, $mode = null, $options = null)
+ {
+ $controller =& Ethna_Controller::getInstance();
if ($controller !== null) {
$this->i18n =& $controller->getI18N();
}
- // $options°Ê¹ß¤Î°ú¿ô->$userinfo
- if (func_num_args() > 4) {
- $userinfo = array_slice(func_get_args(), 4);
- if (count($userinfo) == 1) {
- if (is_array($userinfo[0])) {
- $userinfo = $userinfo[0];
- } else if (is_null($userinfo[0])) {
- $userinfo = array();
- }
- }
- } else {
- $userinfo = array();
- }
+ // $options°Ê¹ß¤Î°ú¿ô->$userinfo
+ if (func_num_args() > 4) {
+ $userinfo = array_slice(func_get_args(), 4);
+ if (count($userinfo) == 1) {
+ if (is_array($userinfo[0])) {
+ $userinfo = $userinfo[0];
+ } else if (is_null($userinfo[0])) {
+ $userinfo = array();
+ }
+ }
+ } else {
+ $userinfo = array();
+ }
- // ¥á¥Ã¥»¡¼¥¸ÊäÀµ½èÍý
- if (is_null($message)) {
- // $code¤«¤é¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
- $message = $controller->getErrorMessage($code);
- if (is_null($message)) {
- $message = 'unkown error';
- }
- }
+ // ¥á¥Ã¥»¡¼¥¸ÊäÀµ½èÍý
+ if (is_null($message)) {
+ // $code¤«¤é¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
+ $message = $controller->getErrorMessage($code);
+ if (is_null($message)) {
+ $message = 'unkown error';
+ }
+ }
- parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
+ parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
- // Ethna¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î¥¨¥é¡¼¥Ï¥ó¥É¥é(PEAR_Error¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤È¤Ï°Û¤Ê¤ë)
- Ethna::handleError($this);
- }
+ // Ethna¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î¥¨¥é¡¼¥Ï¥ó¥É¥é(PEAR_Error¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤È¤Ï°Û¤Ê¤ë)
+ Ethna::handleError($this);
+ }
- /**
- * level¤Ø¤Î¥¢¥¯¥»¥µ(R)
- *
- * @access public
- * @return int ¥¨¥é¡¼¥ì¥Ù¥ë
- */
- function getLevel()
- {
- return $this->level;
- }
+ /**
+ * level¤Ø¤Î¥¢¥¯¥»¥µ(R)
+ *
+ * @access public
+ * @return int ¥¨¥é¡¼¥ì¥Ù¥ë
+ */
+ function getLevel()
+ {
+ return $this->level;
+ }
- /**
- * message¤Ø¤Î¥¢¥¯¥»¥µ(R)
- *
- * PEAR_Error::getMessage()¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ°Ê²¼¤Î½èÍý¤ò¹Ô¤¦
- * - ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Îi18n½èÍý
- * - $userinfo¤È¤·¤ÆÅϤµ¤ì¤¿¥Ç¡¼¥¿¤Ë¤è¤ëvsprintf()½èÍý
- *
- * @access public
- * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- */
- function getMessage()
- {
+ /**
+ * message¤Ø¤Î¥¢¥¯¥»¥µ(R)
+ *
+ * PEAR_Error::getMessage()¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ°Ê²¼¤Î½èÍý¤ò¹Ô¤¦
+ * - ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Îi18n½èÍý
+ * - $userinfo¤È¤·¤ÆÅϤµ¤ì¤¿¥Ç¡¼¥¿¤Ë¤è¤ëvsprintf()½èÍý
+ *
+ * @access public
+ * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ */
+ function getMessage()
+ {
$tmp_message = $this->i18n ? $this->i18n->get($this->message) : $this->message;
- $tmp_userinfo = to_array($this->userinfo);
- $tmp_message_arg_list = array();
- for ($i = 0; $i < count($tmp_userinfo); $i++) {
+ $tmp_userinfo = to_array($this->userinfo);
+ $tmp_message_arg_list = array();
+ for ($i = 0; $i < count($tmp_userinfo); $i++) {
$tmp_message_arg_list[] = $this->i18n ? $this->i18n->get($tmp_userinfo[$i]) : $tmp_userinfo[$i];
- }
- return vsprintf($tmp_message, $tmp_message_arg_list);
- }
+ }
+ return vsprintf($tmp_message, $tmp_message_arg_list);
+ }
- /**
- * ¥¨¥é¡¼ÄɲþðÊó¤Ø¤Î¥¢¥¯¥»¥µ(R)
- *
- * PEAR_Error::getUserInfo()¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ¡¢ÇÛÎó¤Î¸Ä¡¹¤Î
- * ¥¨¥ó¥È¥ê¤Ø¤Î¥¢¥¯¥»¥¹¤ò¥µ¥Ý¡¼¥È
- *
- * @access public
- * @param int $n ¥¨¥é¡¼ÄɲþðÊó¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹(¾Êά²Ä)
- * @return mixed message°ú¿ô
- */
- function getUserInfo($n = null)
- {
- if (is_null($n)) {
- return $this->userinfo;
- }
+ /**
+ * ¥¨¥é¡¼ÄɲþðÊó¤Ø¤Î¥¢¥¯¥»¥µ(R)
+ *
+ * PEAR_Error::getUserInfo()¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ¡¢ÇÛÎó¤Î¸Ä¡¹¤Î
+ * ¥¨¥ó¥È¥ê¤Ø¤Î¥¢¥¯¥»¥¹¤ò¥µ¥Ý¡¼¥È
+ *
+ * @access public
+ * @param int $n ¥¨¥é¡¼ÄɲþðÊó¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹(¾Êά²Ä)
+ * @return mixed message°ú¿ô
+ */
+ function getUserInfo($n = null)
+ {
+ if (is_null($n)) {
+ return $this->userinfo;
+ }
- if (isset($this->userinfo[$n])) {
- return $this->userinfo[$n];
- } else {
- return null;
- }
- }
+ if (isset($this->userinfo[$n])) {
+ return $this->userinfo[$n];
+ } else {
+ return null;
+ }
+ }
- /**
- * ¥¨¥é¡¼ÄɲþðÊó¤Ø¤Î¥¢¥¯¥»¥µ(W)
- *
- * PEAR_Error::addUserInfo()¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É
- *
- * @access public
- * @param string $info Äɲ乤륨¥é¡¼¾ðÊó
- */
- function addUserInfo($info)
- {
- $this->userinfo[] = $info;
- }
+ /**
+ * ¥¨¥é¡¼ÄɲþðÊó¤Ø¤Î¥¢¥¯¥»¥µ(W)
+ *
+ * PEAR_Error::addUserInfo()¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É
+ *
+ * @access public
+ * @param string $info Äɲ乤륨¥é¡¼¾ðÊó
+ */
+ function addUserInfo($info)
+ {
+ $this->userinfo[] = $info;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Filter.php
+ * Ethna_Filter.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Filter
/**
- * ¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î¥Õ¥£¥ë¥¿´ðÄ쥯¥é¥¹
+ * ¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î¥Õ¥£¥ë¥¿´ðÄ쥯¥é¥¹
*
- * Mojavi¤Î¿¿»÷¤Ç¤¹¡Ê¤¤Ã¤Ñ¤ê¡Ë¡£¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¤Ë³Æ¼ï½èÍý¤ò¹Ô¤¦¤³¤È¤¬
- * ½ÐÍè¤Þ¤¹¡£
+ * Mojavi¤Î¿¿»÷¤Ç¤¹¡Ê¤¤Ã¤Ñ¤ê¡Ë¡£¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¤Ë³Æ¼ï½èÍý¤ò¹Ô¤¦¤³¤È¤¬
+ * ½ÐÍè¤Þ¤¹¡£
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
* @obsolete
*/
class Ethna_Filter
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È($controller¤Î¾Êά·Á) */
- var $ctl;
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È($controller¤Î¾Êά·Á) */
+ var $ctl;
- /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
- var $config;
+ /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
+ var $config;
- /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */
- var $logger;
+ /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */
+ var $logger;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_Filter¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_Filter(&$controller)
- {
- // ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
- $this->controller =& $controller;
- $this->ctl =& $this->controller;
+ /**
+ * Ethna_Filter¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_Filter(&$controller)
+ {
+ // ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
+ $this->controller =& $controller;
+ $this->ctl =& $this->controller;
- $this->config =& $controller->getConfig();
- $this->logger =& $this->controller->getLogger();
- }
+ $this->config =& $controller->getConfig();
+ $this->logger =& $this->controller->getLogger();
+ }
- /**
- * ¼Â¹ÔÁ°¥Õ¥£¥ë¥¿
- *
- * @access public
- * @return Ethna_Error:¼Â¹ÔÃæ»ß any:Àµ¾ï½ªÎ»
- */
- function preFilter()
- {
- }
+ /**
+ * ¼Â¹ÔÁ°¥Õ¥£¥ë¥¿
+ *
+ * @access public
+ * @return Ethna_Error:¼Â¹ÔÃæ»ß any:Àµ¾ï½ªÎ»
+ */
+ function preFilter()
+ {
+ }
- /**
- * ¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¥Õ¥£¥ë¥¿
- *
- * @access public
- * @param string $action_name ¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾
- * @return string null:Àµ¾ï½ªÎ» (string):¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾¤òÊѹ¹
- */
- function preActionFilter($action_name)
- {
- return null;
- }
+ /**
+ * ¥¢¥¯¥·¥ç¥ó¼Â¹ÔÁ°¥Õ¥£¥ë¥¿
+ *
+ * @access public
+ * @param string $action_name ¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾
+ * @return string null:Àµ¾ï½ªÎ» (string):¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾¤òÊѹ¹
+ */
+ function preActionFilter($action_name)
+ {
+ return null;
+ }
- /**
- * ¥¢¥¯¥·¥ç¥ó¼Â¹Ô¸å¥Õ¥£¥ë¥¿
- *
- * @access public
- * @param string $action_name ¼Â¹Ô¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾
- * @param string $forward_name ¼Â¹Ô¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤«¤é¤ÎÌá¤êÃÍ
- * @return string null:Àµ¾ï½ªÎ» (string):Á«°Ü̾¤òÊѹ¹
- */
- function postActionFilter($action_name, $forward_name)
- {
- return null;
- }
+ /**
+ * ¥¢¥¯¥·¥ç¥ó¼Â¹Ô¸å¥Õ¥£¥ë¥¿
+ *
+ * @access public
+ * @param string $action_name ¼Â¹Ô¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾
+ * @param string $forward_name ¼Â¹Ô¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤«¤é¤ÎÌá¤êÃÍ
+ * @return string null:Àµ¾ï½ªÎ» (string):Á«°Ü̾¤òÊѹ¹
+ */
+ function postActionFilter($action_name, $forward_name)
+ {
+ return null;
+ }
- /**
- * ¼Â¹Ô¸å¥Õ¥£¥ë¥¿
- *
- * @access public
- * @return Ethna_Error:¼Â¹ÔÃæ»ß any:Àµ¾ï½ªÎ»
- */
- function postFilter()
- {
- }
+ /**
+ * ¼Â¹Ô¸å¥Õ¥£¥ë¥¿
+ *
+ * @access public
+ * @return Ethna_Error:¼Â¹ÔÃæ»ß any:Àµ¾ï½ªÎ»
+ */
+ function postFilter()
+ {
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Handle.php
+ * Ethna_Handle.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Handle
/**
* Manager class of Ethna (Command Line) Handlers
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_I18N.php
+ * Ethna_I18N.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_I18N
/**
- * i18n´ØÏ¢¤Î½èÍý¤ò¹Ô¤¦¥¯¥é¥¹
+ * i18n´ØÏ¢¤Î½èÍý¤ò¹Ô¤¦¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_I18N
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var bool gettext¥Õ¥é¥° */
- var $have_gettext;
+ /** @var bool gettext¥Õ¥é¥° */
+ var $have_gettext;
- /** @var string ¥í¥±¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê */
- var $locale_dir;
+ /** @var string ¥í¥±¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê */
+ var $locale_dir;
- /** @var string ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID */
- var $appid;
+ /** @var string ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID */
+ var $appid;
- /** @var string ¥·¥¹¥Æ¥à¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° */
- var $systemencoding;
+ /** @var string ¥·¥¹¥Æ¥à¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° */
+ var $systemencoding;
- /** @var string ¥¯¥é¥¤¥¢¥ó¥È¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° */
- var $clientencoding;
+ /** @var string ¥¯¥é¥¤¥¢¥ó¥È¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° */
+ var $clientencoding;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_I18N¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param string $locale_dir ¥í¥±¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê
- * @param string $appid ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID
- */
- function Ethna_I18N($locale_dir, $appid)
- {
- $this->locale_dir = $locale_dir;
- $this->appid = strtoupper($appid);
- $this->have_gettext = extension_loaded("gettext") ? true : false;
+ /**
+ * Ethna_I18N¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param string $locale_dir ¥í¥±¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê
+ * @param string $appid ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID
+ */
+ function Ethna_I18N($locale_dir, $appid)
+ {
+ $this->locale_dir = $locale_dir;
+ $this->appid = strtoupper($appid);
+ $this->have_gettext = extension_loaded("gettext") ? true : false;
- $this->setLanguage(LANG_JA);
- }
+ $this->setLanguage(LANG_JA);
+ }
- /**
- * ¥í¥±¡¼¥ë¤òÀßÄꤹ¤ë
- *
- * @access public
- * @param string $language ¸À¸ìÄêµÁ
- * @param string $systemencoding ¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
- * @param string $clientencoding ¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
- * @return string ¸À¸ì¤ËÂбþ¤·¤ÆÀßÄꤵ¤ì¤¿¥í¥±¡¼¥ë̾
- */
- function setLanguage($language, $systemencoding = null, $clientencoding = null)
- {
- switch ($language) {
- case LANG_EN:
- $locale = "en_US";
- break;
- case LANG_JA:
- $locale = "ja_JP";
- break;
- default:
- $locale = "ja_JP";
- break;
- }
- setlocale(LC_ALL, $locale);
- if ($this->have_gettext) {
- bindtextdomain($this->appid, $this->locale_dir);
- textdomain($this->appid);
- }
+ /**
+ * ¥í¥±¡¼¥ë¤òÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param string $language ¸À¸ìÄêµÁ
+ * @param string $systemencoding ¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
+ * @param string $clientencoding ¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
+ * @return string ¸À¸ì¤ËÂбþ¤·¤ÆÀßÄꤵ¤ì¤¿¥í¥±¡¼¥ë̾
+ */
+ function setLanguage($language, $systemencoding = null, $clientencoding = null)
+ {
+ switch ($language) {
+ case LANG_EN:
+ $locale = "en_US";
+ break;
+ case LANG_JA:
+ $locale = "ja_JP";
+ break;
+ default:
+ $locale = "ja_JP";
+ break;
+ }
+ setlocale(LC_ALL, $locale);
+ if ($this->have_gettext) {
+ bindtextdomain($this->appid, $this->locale_dir);
+ textdomain($this->appid);
+ }
- $this->systemencoding = $systemencoding;
- $this->clientencoding = $clientencoding;
+ $this->systemencoding = $systemencoding;
+ $this->clientencoding = $clientencoding;
- return $locale;
- }
+ return $locale;
+ }
- /**
- * ¥á¥Ã¥»¡¼¥¸¥«¥¿¥í¥°¤«¤é¥í¥±¡¼¥ë¤ËŬ¹ç¤¹¤ë¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $message ¥á¥Ã¥»¡¼¥¸
- * @return string ¥í¥±¡¼¥ë¤ËŬ¹ç¤¹¤ë¥á¥Ã¥»¡¼¥¸
- */
- function get($message)
- {
- if ($this->have_gettext) {
- return gettext($message);
- } else {
- return $message;
- }
- }
+ /**
+ * ¥á¥Ã¥»¡¼¥¸¥«¥¿¥í¥°¤«¤é¥í¥±¡¼¥ë¤ËŬ¹ç¤¹¤ë¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $message ¥á¥Ã¥»¡¼¥¸
+ * @return string ¥í¥±¡¼¥ë¤ËŬ¹ç¤¹¤ë¥á¥Ã¥»¡¼¥¸
+ */
+ function get($message)
+ {
+ if ($this->have_gettext) {
+ return gettext($message);
+ } else {
+ return $message;
+ }
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_InfoManager.php
+ * Ethna_InfoManager.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_InfoManager
/**
- * Ethna¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹
+ * Ethna¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_InfoManager extends Ethna_AppManager
{
- /**#@+
- * @access private
- */
-
- /** @var object Ethna_Controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È */
- var $ctl;
-
- /** @var object Ethna_ClassFactory ¥¯¥é¥¹¥Õ¥¡¥¯¥È¥ê¥ª¥Ö¥¸¥§¥¯¥È */
- var $class_factory;
-
- /** @var array ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È²òÀÏ·ë²Ì¥¥ã¥Ã¥·¥å¥Õ¥¡¥¤¥ë */
- var $cache_class_list_file;
-
- /** @var array ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È²òÀÏ·ë²Ì¥¥ã¥Ã¥·¥å */
- var $cache_class_list;
-
- /** @var array [°À]DB¥¿¥¤¥×°ìÍ÷ */
- var $db_type_list = array(
- DB_TYPE_RW => array('name' => 'DB_TYPE_RW'),
- DB_TYPE_RO => array('name' => 'DB_TYPE_RO'),
- DB_TYPE_MISC => array('name' => 'DB_TYPE_MISC'),
- );
-
- /** @var array [°À]¥Õ¥©¡¼¥à·¿°ìÍ÷ */
- var $form_type_list = array(
- FORM_TYPE_TEXT => array('name' => '¥Æ¥¥¹¥È¥Ü¥Ã¥¯¥¹'),
- FORM_TYPE_PASSWORD => array('name' => '¥Ñ¥¹¥ï¡¼¥É'),
- FORM_TYPE_TEXTAREA => array('name' => '¥Æ¥¥¹¥È¥¨¥ê¥¢'),
- FORM_TYPE_SELECT => array('name' => '¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹'),
- FORM_TYPE_RADIO => array('name' => '¥é¥¸¥ª¥Ü¥¿¥ó'),
- FORM_TYPE_CHECKBOX => array('name' => '¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹'),
- FORM_TYPE_SUBMIT => array('name' => '¥Õ¥©¡¼¥àÁ÷¿®¥Ü¥¿¥ó'),
- FORM_TYPE_FILE => array('name' => '¥Õ¥¡¥¤¥ë'),
- );
-
- /** @var array [°À]ÊÑ¿ô·¿°ìÍ÷ */
- var $var_type_list = array(
- VAR_TYPE_INT => array('name' => 'À°¿ô'),
- VAR_TYPE_FLOAT => array('name' => 'ÉâÆ°¾®¿ôÅÀ¿ô'),
- VAR_TYPE_STRING => array('name' => 'ʸ»úÎó'),
- VAR_TYPE_DATETIME => array('name' => 'ÆüÉÕ'),
- VAR_TYPE_BOOLEAN => array('name' => '¿¿µ¶ÃÍ'),
- VAR_TYPE_FILE => array('name' => '¥Õ¥¡¥¤¥ë'),
- );
-
- /**#@-*/
-
- /**
- * Ethna_InfoManager¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Backend &$backend Ethna_Backend¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_InfoManager(&$backend)
- {
- parent::Ethna_AppManager($backend);
- $this->ctl =& Ethna_Controller::getInstance();
- $this->class_factory =& $this->ctl->getClassFactory();
-
- // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È²òÀÏ·ë²Ì¥¥ã¥Ã¥·¥å¼èÆÀ
- $this->cache_class_list_file = sprintf('%s/ethna_info_class_list', $this->ctl->getDirectory('tmp'));
- if (file_exists($this->cache_class_list_file) && filesize($this->cache_class_list_file) > 0) {
- $fp = fopen($this->cache_class_list_file, 'r');
- $s = fread($fp, filesize($this->cache_class_list_file));
- fclose($fp);
- $this->cache_class_list = unserialize($s);
- }
- }
-
- /**
- * ÄêµÁºÑ¤ß¥¢¥¯¥·¥ç¥ó°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return array ¥¢¥¯¥·¥ç¥ó°ìÍ÷
- */
- function getActionList()
- {
- $r = array();
-
- // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
- $class_list = $this->_analyzeActionList();
-
- // ¥¢¥¯¥·¥ç¥óÄêµÁ¥¨¥ó¥È¥ê°ìÍ÷
- list($manifest_action_list, $manifest_class_list) = $this->_getActionList_Manifest($class_list);
-
- // ¥¢¥¯¥·¥ç¥óÄêµÁ¾Êά¥¨¥ó¥È¥ê°ìÍ÷
- $implicit_action_list = $this->_getActionList_Implicit($class_list, $manifest_action_list, $manifest_class_list);
-
- $r = array_merge($manifest_action_list, $implicit_action_list);
- ksort($r);
-
- // ¥¢¥¯¥·¥ç¥óÄêµÁ¾ðÊóÊä´°
- $r = $this->_addActionList($r);
-
- return $r;
- }
-
- /**
- * ÄêµÁºÑ¤ßÁ«°ÜÀè°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return array Á«°ÜÀè°ìÍ÷
- */
- function getForwardList()
- {
- $r = array();
-
- // ¥Æ¥ó¥×¥ì¡¼¥È/¥Ó¥å¡¼¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
- $forward_list = $this->_analyzeForwardList();
-
- // ¥Ó¥å¡¼ÄêµÁ¥¨¥ó¥È¥ê°ìÍ÷
- $manifest_forward_list = $this->_getForwardList_Manifest($forward_list);
-
- // ¥Ó¥å¡¼ÄêµÁ¾Êά¥¨¥ó¥È¥ê°ìÍ÷
- $implicit_forward_list = $this->_getForwardList_Implicit($forward_list, $manifest_forward_list);
-
- $r = array_merge($manifest_forward_list, $implicit_forward_list);
- ksort($r);
-
- return $r;
- }
-
- /**
- * ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
- *
- * @access private
- * @param string $action_dir ²òÀÏÂоݤΥǥ£¥ì¥¯¥È¥ê
- * @return array ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹ÄêµÁ°ìÍ÷
- */
- function _analyzeActionList($action_dir = null)
- {
- $r = array();
- $cache_update = false;
-
- if (is_null($action_dir)) {
- $cache_update = true;
- $action_dir = $this->ctl->getActiondir();
- }
- $prefix_len = strlen($this->ctl->getActiondir());
-
- $child_dir_list = array();
-
- $dh = opendir($action_dir);
- if ($dh == false) {
- return;
- }
-
- $ext = $this->ctl->getExt('php');
- while (($file = readdir($dh)) !== false) {
- if ($file == "." || $file == "..") {
- continue;
- }
- $file = $action_dir . $file;
-
- if (is_dir($file)) {
- $child_dir_list[] = $file;
- continue;
- }
-
- if (preg_match("/\.$ext\$/", $file) == 0) {
- continue;
- }
-
- $key = substr($file, $prefix_len);
-
- // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
- include_once($file);
- if ($this->cache_class_list[$key]['.mtime'] >= filemtime($file)) {
- $class_list = $this->cache_class_list[$key];
- } else {
- $class_list = $this->_analyzeActionScript($file);
- }
- if (is_null($class_list) == false) {
- $r[$key] = $class_list;
- }
- }
-
- closedir($dh);
-
- foreach ($child_dir_list as $child_dir) {
- $tmp = $this->_analyzeActionList($child_dir . "/");
- $r = array_merge($r, $tmp);
- }
-
- if ($cache_update) {
- // ¥¥ã¥Ã¥·¥å¥Õ¥¡¥¤¥ë¹¹¿·
- $fp = fopen($this->cache_class_list_file, 'w');
- fwrite($fp, serialize($r));
- fclose($fp);
- }
-
- return $r;
- }
-
- /**
- * ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
- *
- * @access private
- * @param string $script ¥Õ¥¡¥¤¥ë̾
- * @return array ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹ÄêµÁ°ìÍ÷
- */
- function _analyzeActionScript($script)
- {
- $class_list = array();
- $class_list['.mtime'] = filemtime($script);
-
- $source = "";
- $fp = fopen($script, 'r');
- if ($fp == false) {
- return null;
- }
- while (feof($fp) == false) {
- $source .= fgets($fp, 8192);
- }
- fclose($fp);
-
- // ¥È¡¼¥¯¥ó¤Ëʬ³ä¤·¤Æ¥¯¥é¥¹ÄêµÁ¾ðÊó¤ò¼èÆÀ
- $token_list = token_get_all($source);
- $state = 'T_OUT';
- $nest = 0;
- $current = null;
- for ($i = 0; $i < count($token_list); $i++) {
- $token = $token_list[$i];
-
- if (is_string($token)) {
- if ($token == '{') {
- $nest++;
- } else if ($token == '}') {
- $nest--;
- if ($state == 'T_PREPARE' || $state == 'T_PERFORM') {
- if ($nest == $method_nest) {
- $state = 'T_ACTION_CLASS';
- }
- } else if ($nest == 0) {
- $state = 'T_OUT';
- }
- }
- continue;
- }
-
- if ($token[0] == T_CLASS) {
- // ¥¯¥é¥¹ÄêµÁ³«»Ï
- $i += 2;
- $class_name = $token_list[$i][1]; // should be T_STRING
- if ($this->_isSubclassOf($class_name, 'Ethna_ActionClass')) {
- $state = 'T_ACTION_CLASS';
- $current = $class_name;
- $class_list[$current] = array('type' => 'action_class');
- } else if ($this->_isSubclassOf($class_name, 'Ethna_ActionForm')) {
- $state = 'T_ACTION_FORM';
- $current = $class_name;
- $class_list[$current] = array('type' => 'action_form');
- }
- $nest = 0; // for safe
- } else if ($token[0] == T_COMMENT && strncmp($token[1], "/**", 3) == 0 && is_array($token_list[$i+2]) && $token_list[$i+2][0] == T_CLASS) {
- // DocComment for class
- } else if ($state == 'T_ACTION_CLASS' && $token[0] == T_FUNCTION) {
- $i += 2;
- $method_name = $token_list[$i][1];
- if (strcasecmp($method_name, 'prepare') == 0) {
- $state = 'T_PREPARE';
- $method_nest = $nest;
- } else if (strcasecmp($method_name, 'perform') == 0) {
- $state = 'T_PERFORM';
- $method_nest = $nest;
- }
- } else if (($state == 'T_PREPARE' || $state == 'T_PERFORM') && $token[0] == T_RETURN) {
- $s = "";
- $n = 2;
- while ($token_list[$i+$n] !== ";") {
- $s .= is_string($token_list[$i+$n]) ? $token_list[$i+$n] : $token_list[$i+$n][1];
- $n++;
- }
- $key = $state == 'T_PREPARE' ? 'prepare' : 'perform';
- $class_list[$current]['return'][$key][] = $s;
- }
- }
-
- if (count($class_list) == 0) {
- return null;
- }
- return $class_list;
- }
-
- /**
- * »ØÄꤵ¤ì¤¿¥¯¥é¥¹Ì¾¤ò·Ñ¾µ¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
- *
- * @access private
- * @param string $class_name ¥Á¥§¥Ã¥¯ÂоݤΥ¯¥é¥¹Ì¾
- * @param string $parent_name ¿Æ¥¯¥é¥¹Ì¾
- * @return bool true:·Ñ¾µ¤·¤Æ¤¤¤ë false:¤¤¤Ê¤¤
- */
- function _isSubclassOf($class_name, $parent_name)
- {
- while ($tmp = get_parent_class($class_name)) {
- if (strcasecmp($tmp, $parent_name) == 0) {
- return true;
- }
- $class_name = $tmp;
- }
- return false;
- }
-
- /**
- * ¥³¥ó¥È¥í¡¼¥é¤ËÌÀ¼¨Åª¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¢¥¯¥·¥ç¥ó°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @param array ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¯¥é¥¹°ìÍ÷
- * @return array array(¥¢¥¯¥·¥ç¥ó°ìÍ÷, ¥¯¥é¥¹°ìÍ÷)
- */
- function _getActionList_Manifest($class_list)
- {
- $manifest_action_list = array();
- $manifest_class_list = array();
- foreach ($this->ctl->action as $action_name => $action) {
- if ($action_name == '__ethna_info__') {
- continue;
- }
- $action = $this->ctl->_getAction($action_name);
-
- $elt = array();
- // _analyzeActionList()¤Ç¼èÆÀ¤·¤¿¥¯¥é¥¹ÄêµÁ¥Ç¡¼¥¿¤«¤éÂбþ´Ø·¸¤ò¼èÆÀ
- foreach ($class_list as $file => $elts) {
- foreach ($elts as $class_name => $def) {
- if ($def['type'] == 'action_class' && strcasecmp($class_name, $action['class_name']) == 0) {
- $elt['action_class'] = $class_name;
- $elt['action_class_file'] = $file;
- $elt['action_class_info'] = $def;
- } else if ($def['type'] == 'action_form' && strcasecmp($class_name, $action['form_name']) == 0) {
- $elt['action_form'] = $class_name;
- $elt['action_form_file'] = $file;
- $elt['action_form_info'] = $def;
- }
- }
- }
-
- // ̤ÄêµÁ¥Á¥§¥Ã¥¯
- if (isset($elt['action_class']) == false) {
- $elt['action_class'] = $action['class_name'];
- if (class_exists($action['class_name']) == false) {
- $elt['action_class_info'] = array('undef' => true);
- }
- }
- if (isset($elt['action_form']) == false && $action['form_name'] != 'Ethna_ActionForm') {
- $elt['action_form'] = $action['form_name'];
- if (class_exists($action['form_name']) == false) {
- $elt['action_form_info'] = array('undef' => true);
- }
- }
- $manifest_action_list[$action_name] = $elt;
- $manifest_class_list[] = strtolower($elt['action_class']);
- }
-
- return array($manifest_action_list, $manifest_class_list);
- }
-
- /**
- * °ÅÌÛ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¢¥¯¥·¥ç¥ó°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @param array $class_list ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¯¥é¥¹°ìÍ÷
- * @param array $manifest_action_list ÌÀ¼¨Åª¤ËÄêµÁºÑ¤ß¤Î¥¢¥¯¥·¥ç¥ó°ìÍ÷
- * @param array $manifest_class_list ÌÀ¼¨Åª¤ËÄêµÁºÑ¤ß¤Î¥¯¥é¥¹°ìÍ÷
- * @return array array:¥¢¥¯¥·¥ç¥ó°ìÍ÷
- */
- function _getActionList_Implicit($class_list, $manifest_action_list, $manifest_class_list)
- {
- $implicit_action_list = array();
-
- foreach ($class_list as $file => $elts) {
- foreach ($elts as $class_name => $def) {
- if (in_array(strtolower($class_name), $manifest_class_list)) {
- continue;
- }
-
- // ¥¯¥é¥¹Ì¾¤«¤é¥¢¥¯¥·¥ç¥ó̾¤ò¼èÆÀ
- if ($def['type'] == 'action_class') {
- $action_name = $this->ctl->actionClassToName($class_name);
- if (array_key_exists($action_name, $manifest_action_list)) {
- continue;
- }
- $implicit_action_list[$action_name]['action_class'] = $class_name;
- $implicit_action_list[$action_name]['action_class_file'] = $file;
- $implicit_action_list[$action_name]['action_class_info'] = $def;
- } else if ($def['type'] == 'action_form') {
- $action_name = $this->ctl->actionFormToName($class_name);
- if (array_key_exists($action_name, $manifest_action_list)) {
- continue;
- }
- $implicit_action_list[$action_name]['action_form'] = $class_name;
- $implicit_action_list[$action_name]['action_form_file'] = $file;
- $implicit_action_list[$action_name]['action_form_info'] = $def;
- } else {
- continue;
- }
- }
- }
-
- return $implicit_action_list;
- }
-
- /**
- * ¥¢¥¯¥·¥ç¥óÄêµÁ°ìÍ÷¤òÊä´°¤¹¤ë
- *
- * @access private
- * @param array $action_list ¼èÆÀ¤·¤¿¥¢¥¯¥·¥ç¥ó°ìÍ÷
- * @return array ½¤Àµ¸å¤Î¥¢¥¯¥·¥ç¥ó°ìÍ÷
- */
- function _addActionList($action_list)
- {
- foreach ($action_list as $action_name => $action) {
- // ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¤Ë¥Õ¥©¡¼¥àÄêµÁ¾ðÊó¤òÄɲÃ
- $form_name = $action['action_form'];
- if (class_exists($form_name) == false) {
- continue;
- }
- $af =& new $form_name($this->ctl);
-
- $form = array();
- foreach ($af->getDef() as $name => $def) {
- $form[$name]['required'] = $def['required'] ? 'true' : 'false';
- foreach (array('name', 'max', 'min', 'regexp', 'custom') as $key) {
- $form[$name][$key] = $def[$key];
- }
- $form[$name]['filter'] = str_replace(",", "\n", $def['filter']);
- $form[$name]['form_type'] = $this->getAttrName('form_type', $def['form_type']);
- $form[$name]['type_is_array'] = is_array($def['type']);
- $form[$name]['type'] = $this->getAttrName('var_type', is_array($def['type']) ? $def['type'][0] : $def['type']);
- }
- $action['action_form_info']['form'] = $form;
- $action_list[$action_name] = $action;
- }
-
- return $action_list;
- }
-
- /**
- * ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥Æ¥ó¥×¥ì¡¼¥È¤ò²òÀϤ¹¤ë
- *
- * @access private
- * @param string $action_dir ²òÀÏÂоݤΥǥ£¥ì¥¯¥È¥ê
- * @return array Á«°ÜÄêµÁ°ìÍ÷
- */
- function _analyzeForwardList($template_dir = null)
- {
- $r = array();
-
- if (is_null($template_dir)) {
- $template_dir = $this->ctl->getTemplatedir();
- }
- $prefix_len = strlen($this->ctl->getTemplatedir());
-
- $child_dir_list = array();
-
- $dh = opendir($template_dir);
- if ($dh == false) {
- return;
- }
-
- $ext = $this->ctl->getExt('tpl');
- while (($file = readdir($dh)) !== false) {
- if ($file == "." || $file == "..") {
- continue;
- }
- $file = $template_dir . '/' . $file;
-
- if (is_dir($file)) {
- $child_dir_list[] = $file;
- continue;
- }
-
- if (preg_match("/\.$ext\$/", $file) == 0) {
- continue;
- }
-
- $tpl = substr($file, $prefix_len);
- $r[] = $this->ctl->forwardPathToName($tpl);
- }
-
- closedir($dh);
-
- foreach ($child_dir_list as $child_dir) {
- $tmp = $this->_analyzeForwardList($child_dir);
- $r = array_merge($r, $tmp);
- }
-
- return $r;
- }
-
- /**
- * ¥³¥ó¥È¥í¡¼¥é¤ËÌÀ¼¨Åª¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ëÁ«°ÜÀè°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return array ¥Ó¥å¡¼°ìÍ÷
- */
- function _getForwardList_Manifest()
- {
- $manifest_forward_list = array();
- foreach ($this->ctl->forward as $forward_name => $forward) {
- if ($forward_name == '__ethna_info__') {
- continue;
- }
-
- $elt = array();
- $elt['template_file'] = $this->ctl->_getForwardPath($forward_name);
- if (file_exists(sprintf("%s/%s", $this->ctl->getTemplatedir(), $elt['template_file'])) == false) {
- $elt['template_file_info'] = array('undef' => true);
- }
-
- $elt['view_class'] = $this->ctl->getViewClassName($forward_name);
- if ($elt['view_class'] == 'Ethna_ViewClass') {
- $elt['view_class'] = null;
- } else if (class_exists($elt['view_class']) == false) {
- $elt['view_class_info'] = array('undef' => true);
- }
-
- if (isset($forward['view_path']) && $forward['view_path']) {
- $elt['view_path'] = $forward['view_path'];
- } else if ($this->_isSubclassOf($elt['view_class'], 'Ethna_ViewClass')) {
- $elt['view_class_file'] = $this->ctl->getDefaultViewPath($forward_name);
- } else {
- foreach ($this->cache_class_list as $file => $elts) {
- foreach ($elts as $name => $def) {
- if (strcasecmp($elt['view_class'], $name) == 0) {
- $elt['view_class_file'] = $file;
- break 2;
- }
- }
- }
- }
-
- $manifest_forward_list[$forward_name] = $elt;
- }
-
- return $manifest_forward_list;
- }
-
- /**
- * °ÅÌÛ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥Ó¥å¡¼°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @param array $forward_list ÄêµÁ¤µ¤ì¤Æ¤¤¤ëÁ«°Ü̾°ìÍ÷
- * @param array $manifest_forward_list ÌÀ¼¨Åª¤ËÄêµÁºÑ¤ß¤Î¥Ó¥å¡¼°ìÍ÷
- * @return array array:¥Ó¥å¡¼°ìÍ÷
- */
- function _getForwardList_Implicit($forward_list, $manifest_forward_list)
- {
- $implicit_forward_list = array();
- $manifest_forward_name_list = array_keys($manifest_forward_list);
-
- foreach ($forward_list as $forward_name) {
- if (in_array($forward_name, $manifest_forward_name_list)) {
- continue;
- }
-
- $elt = array();
- $elt['template_file'] = $this->ctl->_getForwardPath($forward_name);
- $elt['view_class'] = $this->ctl->getViewClassName($forward_name);
- if ($elt['view_class'] == 'Ethna_ViewClass') {
- $elt['view_class'] = null;
- } else if (class_exists($elt['view_class']) == false) {
- $elt['view_class'] = null;
- } else {
- $elt['view_class_file'] = $this->ctl->getDefaultViewPath($forward_name);
- }
-
- $implicit_forward_list[$forward_name] = $elt;
- }
-
- return $implicit_forward_list;
- }
-
- /**
- * Ethna¤ÎÀßÄê°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return array ÀßÄê°ìÍ÷¤ò³ÊǼ¤·¤¿ÇÛÎó
- * @todo respect access controll
- */
- function getConfiguration()
- {
- $r = array();
-
- // core
- $elts = array();
- $elts['¥¢¥×¥ê¥±¡¼¥·¥ç¥óID'] = $this->ctl->getAppId();
- $elts['¥¢¥×¥ê¥±¡¼¥·¥ç¥óURL'] = $this->ctl->getURL();
- $elts['Ethna¥Ð¡¼¥¸¥ç¥ó'] = ETHNA_VERSION;
- $elts['Ethna¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê'] = ETHNA_BASE;
- $r['Core'] = $elts;
-
- // class
- $elts = array();
- $elts['¥Ð¥Ã¥¯¥¨¥ó¥É'] = $this->class_factory->getObjectName('backend');
- $elts['¥¯¥é¥¹¥Õ¥¡¥¯¥È¥ê'] = $this->class_factory->getObjectName('class');
- $elts['ÀßÄê'] = $this->class_factory->getObjectName('config');
- $elts['DB'] = $this->class_factory->getObjectName('db');
- $elts['¥¨¥é¡¼'] = $this->class_factory->getObjectName('error');
- $elts['¥Õ¥©¡¼¥à'] = $this->class_factory->getObjectName('form');
- $elts['¥í¥°'] = $this->class_factory->getObjectName('logger');
- $elts['i18n'] = $this->class_factory->getObjectName('i18n');
- $elts['¥×¥é¥°¥¤¥ó'] = $this->class_factory->getObjectName('plugin');
- $elts['¥»¥Ã¥·¥ç¥ó'] = $this->class_factory->getObjectName('session');
- $elts['SQL'] = $this->class_factory->getObjectName('sql');
- $elts['¥Ó¥å¡¼'] = $this->class_factory->getObjectName('view');
- $r['¥¯¥é¥¹'] = $elts;
-
- // DB
- $elts = array();
- $db_list = array();
- foreach ($this->ctl->db as $key => $db) {
- if ($key == "") {
- $tmp = '$db';
- } else {
- $tmp = sprintf('$db_%s', $key);
- }
- $elts[$tmp] = $this->getAttrName('db_type', $db);
- $db_list[$key] = $tmp;
- }
- $r['DB¥¿¥¤¥×'] = $elts;
-
- // DSN
- $elts = array();
- foreach ($db_list as $key => $name) {
- $config_key = "dsn";
- if ($key != "") {
- $config_key .= "_$key";
- }
- $dsn = $this->config->get($config_key);
- if ($dsn) {
- $elts[$name] = implode("\n", to_array($dsn));
- }
- }
- $r['DSN'] = $elts;
-
- // directory
- $elts = array();
- $elts['¥¢¥×¥ê¥±¡¼¥·¥ç¥ó'] = $this->ctl->getBasedir();
- $elts['¥¢¥¯¥·¥ç¥ó'] = $this->ctl->getActiondir();
- $elts['¥Ó¥å¡¼'] = $this->ctl->getViewdir();
- $elts['¥Õ¥£¥ë¥¿'] = $this->ctl->getDirectory('filter');
- $elts['¥×¥é¥°¥¤¥ó'] = $this->ctl->getDirectory('plugin');
- $elts['¥Æ¥ó¥×¥ì¡¼¥È'] = $this->ctl->getTemplatedir();
- $elts['¥Æ¥ó¥×¥ì¡¼¥È¥¥ã¥Ã¥·¥å'] = $this->ctl->getDirectory('template_c');
- $elts['Smarty¥×¥é¥°¥¤¥ó'] = implode(',', $this->ctl->getDirectory('plugins'));
- $elts['ÀßÄê¥Õ¥¡¥¤¥ë'] = $this->ctl->getDirectory('etc');
- $elts['¥í¥±¡¼¥ë'] = $this->ctl->getDirectory('locale');
- $elts['¥í¥°'] = $this->ctl->getDirectory('log');
- $elts['°ì»þ¥Õ¥¡¥¤¥ë'] = $this->ctl->getDirectory('tmp');
- $r['¥Ç¥£¥ì¥¯¥È¥ê'] = $elts;
-
- // ext
- $elts = array();
- $elts['¥Æ¥ó¥×¥ì¡¼¥È'] = $this->ctl->getExt('tpl');
- $elts['PHP¥¹¥¯¥ê¥×¥È'] = $this->ctl->getExt('php');
- $r['³ÈÄ¥»Ò'] = $elts;
-
- // filter
- $elts = array();
- $n = 1;
- foreach ($this->ctl->filter as $filter) {
- $key = sprintf("¥Õ¥£¥ë¥¿(%d)", $n);
- if (class_exists($filter)) {
- $elts[$key] = $filter;
- $n++;
- }
- }
- $r['¥Õ¥£¥ë¥¿'] = $elts;
-
- // plugin
+ /**#@+
+ * @access private
+ */
+
+ /** @var object Ethna_Controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È */
+ var $ctl;
+
+ /** @var object Ethna_ClassFactory ¥¯¥é¥¹¥Õ¥¡¥¯¥È¥ê¥ª¥Ö¥¸¥§¥¯¥È */
+ var $class_factory;
+
+ /** @var array ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È²òÀÏ·ë²Ì¥¥ã¥Ã¥·¥å¥Õ¥¡¥¤¥ë */
+ var $cache_class_list_file;
+
+ /** @var array ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È²òÀÏ·ë²Ì¥¥ã¥Ã¥·¥å */
+ var $cache_class_list;
+
+ /** @var array [°À]DB¥¿¥¤¥×°ìÍ÷ */
+ var $db_type_list = array(
+ DB_TYPE_RW => array('name' => 'DB_TYPE_RW'),
+ DB_TYPE_RO => array('name' => 'DB_TYPE_RO'),
+ DB_TYPE_MISC => array('name' => 'DB_TYPE_MISC'),
+ );
+
+ /** @var array [°À]¥Õ¥©¡¼¥à·¿°ìÍ÷ */
+ var $form_type_list = array(
+ FORM_TYPE_TEXT => array('name' => '¥Æ¥¥¹¥È¥Ü¥Ã¥¯¥¹'),
+ FORM_TYPE_PASSWORD => array('name' => '¥Ñ¥¹¥ï¡¼¥É'),
+ FORM_TYPE_TEXTAREA => array('name' => '¥Æ¥¥¹¥È¥¨¥ê¥¢'),
+ FORM_TYPE_SELECT => array('name' => '¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹'),
+ FORM_TYPE_RADIO => array('name' => '¥é¥¸¥ª¥Ü¥¿¥ó'),
+ FORM_TYPE_CHECKBOX => array('name' => '¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹'),
+ FORM_TYPE_SUBMIT => array('name' => '¥Õ¥©¡¼¥àÁ÷¿®¥Ü¥¿¥ó'),
+ FORM_TYPE_FILE => array('name' => '¥Õ¥¡¥¤¥ë'),
+ );
+
+ /** @var array [°À]ÊÑ¿ô·¿°ìÍ÷ */
+ var $var_type_list = array(
+ VAR_TYPE_INT => array('name' => 'À°¿ô'),
+ VAR_TYPE_FLOAT => array('name' => 'ÉâÆ°¾®¿ôÅÀ¿ô'),
+ VAR_TYPE_STRING => array('name' => 'ʸ»úÎó'),
+ VAR_TYPE_DATETIME => array('name' => 'ÆüÉÕ'),
+ VAR_TYPE_BOOLEAN => array('name' => '¿¿µ¶ÃÍ'),
+ VAR_TYPE_FILE => array('name' => '¥Õ¥¡¥¤¥ë'),
+ );
+
+ /**#@-*/
+
+ /**
+ * Ethna_InfoManager¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Backend &$backend Ethna_Backend¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_InfoManager(&$backend)
+ {
+ parent::Ethna_AppManager($backend);
+ $this->ctl =& Ethna_Controller::getInstance();
+ $this->class_factory =& $this->ctl->getClassFactory();
+
+ // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È²òÀÏ·ë²Ì¥¥ã¥Ã¥·¥å¼èÆÀ
+ $this->cache_class_list_file = sprintf('%s/ethna_info_class_list', $this->ctl->getDirectory('tmp'));
+ if (file_exists($this->cache_class_list_file) && filesize($this->cache_class_list_file) > 0) {
+ $fp = fopen($this->cache_class_list_file, 'r');
+ $s = fread($fp, filesize($this->cache_class_list_file));
+ fclose($fp);
+ $this->cache_class_list = unserialize($s);
+ }
+ }
+
+ /**
+ * ÄêµÁºÑ¤ß¥¢¥¯¥·¥ç¥ó°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return array ¥¢¥¯¥·¥ç¥ó°ìÍ÷
+ */
+ function getActionList()
+ {
+ $r = array();
+
+ // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
+ $class_list = $this->_analyzeActionList();
+
+ // ¥¢¥¯¥·¥ç¥óÄêµÁ¥¨¥ó¥È¥ê°ìÍ÷
+ list($manifest_action_list, $manifest_class_list) = $this->_getActionList_Manifest($class_list);
+
+ // ¥¢¥¯¥·¥ç¥óÄêµÁ¾Êά¥¨¥ó¥È¥ê°ìÍ÷
+ $implicit_action_list = $this->_getActionList_Implicit($class_list, $manifest_action_list, $manifest_class_list);
+
+ $r = array_merge($manifest_action_list, $implicit_action_list);
+ ksort($r);
+
+ // ¥¢¥¯¥·¥ç¥óÄêµÁ¾ðÊóÊä´°
+ $r = $this->_addActionList($r);
+
+ return $r;
+ }
+
+ /**
+ * ÄêµÁºÑ¤ßÁ«°ÜÀè°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return array Á«°ÜÀè°ìÍ÷
+ */
+ function getForwardList()
+ {
+ $r = array();
+
+ // ¥Æ¥ó¥×¥ì¡¼¥È/¥Ó¥å¡¼¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
+ $forward_list = $this->_analyzeForwardList();
+
+ // ¥Ó¥å¡¼ÄêµÁ¥¨¥ó¥È¥ê°ìÍ÷
+ $manifest_forward_list = $this->_getForwardList_Manifest($forward_list);
+
+ // ¥Ó¥å¡¼ÄêµÁ¾Êά¥¨¥ó¥È¥ê°ìÍ÷
+ $implicit_forward_list = $this->_getForwardList_Implicit($forward_list, $manifest_forward_list);
+
+ $r = array_merge($manifest_forward_list, $implicit_forward_list);
+ ksort($r);
+
+ return $r;
+ }
+
+ /**
+ * ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
+ *
+ * @access private
+ * @param string $action_dir ²òÀÏÂоݤΥǥ£¥ì¥¯¥È¥ê
+ * @return array ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹ÄêµÁ°ìÍ÷
+ */
+ function _analyzeActionList($action_dir = null)
+ {
+ $r = array();
+ $cache_update = false;
+
+ if (is_null($action_dir)) {
+ $cache_update = true;
+ $action_dir = $this->ctl->getActiondir();
+ }
+ $prefix_len = strlen($this->ctl->getActiondir());
+
+ $child_dir_list = array();
+
+ $dh = opendir($action_dir);
+ if ($dh == false) {
+ return;
+ }
+
+ $ext = $this->ctl->getExt('php');
+ while (($file = readdir($dh)) !== false) {
+ if ($file == "." || $file == "..") {
+ continue;
+ }
+ $file = $action_dir . $file;
+
+ if (is_dir($file)) {
+ $child_dir_list[] = $file;
+ continue;
+ }
+
+ if (preg_match("/\.$ext\$/", $file) == 0) {
+ continue;
+ }
+
+ $key = substr($file, $prefix_len);
+
+ // ¥¥ã¥Ã¥·¥å¥Á¥§¥Ã¥¯
+ include_once($file);
+ if ($this->cache_class_list[$key]['.mtime'] >= filemtime($file)) {
+ $class_list = $this->cache_class_list[$key];
+ } else {
+ $class_list = $this->_analyzeActionScript($file);
+ }
+ if (is_null($class_list) == false) {
+ $r[$key] = $class_list;
+ }
+ }
+
+ closedir($dh);
+
+ foreach ($child_dir_list as $child_dir) {
+ $tmp = $this->_analyzeActionList($child_dir . "/");
+ $r = array_merge($r, $tmp);
+ }
+
+ if ($cache_update) {
+ // ¥¥ã¥Ã¥·¥å¥Õ¥¡¥¤¥ë¹¹¿·
+ $fp = fopen($this->cache_class_list_file, 'w');
+ fwrite($fp, serialize($r));
+ fclose($fp);
+ }
+
+ return $r;
+ }
+
+ /**
+ * ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò²òÀϤ¹¤ë
+ *
+ * @access private
+ * @param string $script ¥Õ¥¡¥¤¥ë̾
+ * @return array ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹ÄêµÁ°ìÍ÷
+ */
+ function _analyzeActionScript($script)
+ {
+ $class_list = array();
+ $class_list['.mtime'] = filemtime($script);
+
+ $source = "";
+ $fp = fopen($script, 'r');
+ if ($fp == false) {
+ return null;
+ }
+ while (feof($fp) == false) {
+ $source .= fgets($fp, 8192);
+ }
+ fclose($fp);
+
+ // ¥È¡¼¥¯¥ó¤Ëʬ³ä¤·¤Æ¥¯¥é¥¹ÄêµÁ¾ðÊó¤ò¼èÆÀ
+ $token_list = token_get_all($source);
+ $state = 'T_OUT';
+ $nest = 0;
+ $current = null;
+ for ($i = 0; $i < count($token_list); $i++) {
+ $token = $token_list[$i];
+
+ if (is_string($token)) {
+ if ($token == '{') {
+ $nest++;
+ } else if ($token == '}') {
+ $nest--;
+ if ($state == 'T_PREPARE' || $state == 'T_PERFORM') {
+ if ($nest == $method_nest) {
+ $state = 'T_ACTION_CLASS';
+ }
+ } else if ($nest == 0) {
+ $state = 'T_OUT';
+ }
+ }
+ continue;
+ }
+
+ if ($token[0] == T_CLASS) {
+ // ¥¯¥é¥¹ÄêµÁ³«»Ï
+ $i += 2;
+ $class_name = $token_list[$i][1]; // should be T_STRING
+ if ($this->_isSubclassOf($class_name, 'Ethna_ActionClass')) {
+ $state = 'T_ACTION_CLASS';
+ $current = $class_name;
+ $class_list[$current] = array('type' => 'action_class');
+ } else if ($this->_isSubclassOf($class_name, 'Ethna_ActionForm')) {
+ $state = 'T_ACTION_FORM';
+ $current = $class_name;
+ $class_list[$current] = array('type' => 'action_form');
+ }
+ $nest = 0; // for safe
+ } else if ($token[0] == T_COMMENT && strncmp($token[1], "/**", 3) == 0 && is_array($token_list[$i+2]) && $token_list[$i+2][0] == T_CLASS) {
+ // DocComment for class
+ } else if ($state == 'T_ACTION_CLASS' && $token[0] == T_FUNCTION) {
+ $i += 2;
+ $method_name = $token_list[$i][1];
+ if (strcasecmp($method_name, 'prepare') == 0) {
+ $state = 'T_PREPARE';
+ $method_nest = $nest;
+ } else if (strcasecmp($method_name, 'perform') == 0) {
+ $state = 'T_PERFORM';
+ $method_nest = $nest;
+ }
+ } else if (($state == 'T_PREPARE' || $state == 'T_PERFORM') && $token[0] == T_RETURN) {
+ $s = "";
+ $n = 2;
+ while ($token_list[$i+$n] !== ";") {
+ $s .= is_string($token_list[$i+$n]) ? $token_list[$i+$n] : $token_list[$i+$n][1];
+ $n++;
+ }
+ $key = $state == 'T_PREPARE' ? 'prepare' : 'perform';
+ $class_list[$current]['return'][$key][] = $s;
+ }
+ }
+
+ if (count($class_list) == 0) {
+ return null;
+ }
+ return $class_list;
+ }
+
+ /**
+ * »ØÄꤵ¤ì¤¿¥¯¥é¥¹Ì¾¤ò·Ñ¾µ¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
+ *
+ * @access private
+ * @param string $class_name ¥Á¥§¥Ã¥¯ÂоݤΥ¯¥é¥¹Ì¾
+ * @param string $parent_name ¿Æ¥¯¥é¥¹Ì¾
+ * @return bool true:·Ñ¾µ¤·¤Æ¤¤¤ë false:¤¤¤Ê¤¤
+ */
+ function _isSubclassOf($class_name, $parent_name)
+ {
+ while ($tmp = get_parent_class($class_name)) {
+ if (strcasecmp($tmp, $parent_name) == 0) {
+ return true;
+ }
+ $class_name = $tmp;
+ }
+ return false;
+ }
+
+ /**
+ * ¥³¥ó¥È¥í¡¼¥é¤ËÌÀ¼¨Åª¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¢¥¯¥·¥ç¥ó°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @param array ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¯¥é¥¹°ìÍ÷
+ * @return array array(¥¢¥¯¥·¥ç¥ó°ìÍ÷, ¥¯¥é¥¹°ìÍ÷)
+ */
+ function _getActionList_Manifest($class_list)
+ {
+ $manifest_action_list = array();
+ $manifest_class_list = array();
+ foreach ($this->ctl->action as $action_name => $action) {
+ if ($action_name == '__ethna_info__') {
+ continue;
+ }
+ $action = $this->ctl->_getAction($action_name);
+
+ $elt = array();
+ // _analyzeActionList()¤Ç¼èÆÀ¤·¤¿¥¯¥é¥¹ÄêµÁ¥Ç¡¼¥¿¤«¤éÂбþ´Ø·¸¤ò¼èÆÀ
+ foreach ($class_list as $file => $elts) {
+ foreach ($elts as $class_name => $def) {
+ if ($def['type'] == 'action_class' && strcasecmp($class_name, $action['class_name']) == 0) {
+ $elt['action_class'] = $class_name;
+ $elt['action_class_file'] = $file;
+ $elt['action_class_info'] = $def;
+ } else if ($def['type'] == 'action_form' && strcasecmp($class_name, $action['form_name']) == 0) {
+ $elt['action_form'] = $class_name;
+ $elt['action_form_file'] = $file;
+ $elt['action_form_info'] = $def;
+ }
+ }
+ }
+
+ // ̤ÄêµÁ¥Á¥§¥Ã¥¯
+ if (isset($elt['action_class']) == false) {
+ $elt['action_class'] = $action['class_name'];
+ if (class_exists($action['class_name']) == false) {
+ $elt['action_class_info'] = array('undef' => true);
+ }
+ }
+ if (isset($elt['action_form']) == false && $action['form_name'] != 'Ethna_ActionForm') {
+ $elt['action_form'] = $action['form_name'];
+ if (class_exists($action['form_name']) == false) {
+ $elt['action_form_info'] = array('undef' => true);
+ }
+ }
+ $manifest_action_list[$action_name] = $elt;
+ $manifest_class_list[] = strtolower($elt['action_class']);
+ }
+
+ return array($manifest_action_list, $manifest_class_list);
+ }
+
+ /**
+ * °ÅÌÛ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¢¥¯¥·¥ç¥ó°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @param array $class_list ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¯¥é¥¹°ìÍ÷
+ * @param array $manifest_action_list ÌÀ¼¨Åª¤ËÄêµÁºÑ¤ß¤Î¥¢¥¯¥·¥ç¥ó°ìÍ÷
+ * @param array $manifest_class_list ÌÀ¼¨Åª¤ËÄêµÁºÑ¤ß¤Î¥¯¥é¥¹°ìÍ÷
+ * @return array array:¥¢¥¯¥·¥ç¥ó°ìÍ÷
+ */
+ function _getActionList_Implicit($class_list, $manifest_action_list, $manifest_class_list)
+ {
+ $implicit_action_list = array();
+
+ foreach ($class_list as $file => $elts) {
+ foreach ($elts as $class_name => $def) {
+ if (in_array(strtolower($class_name), $manifest_class_list)) {
+ continue;
+ }
+
+ // ¥¯¥é¥¹Ì¾¤«¤é¥¢¥¯¥·¥ç¥ó̾¤ò¼èÆÀ
+ if ($def['type'] == 'action_class') {
+ $action_name = $this->ctl->actionClassToName($class_name);
+ if (array_key_exists($action_name, $manifest_action_list)) {
+ continue;
+ }
+ $implicit_action_list[$action_name]['action_class'] = $class_name;
+ $implicit_action_list[$action_name]['action_class_file'] = $file;
+ $implicit_action_list[$action_name]['action_class_info'] = $def;
+ } else if ($def['type'] == 'action_form') {
+ $action_name = $this->ctl->actionFormToName($class_name);
+ if (array_key_exists($action_name, $manifest_action_list)) {
+ continue;
+ }
+ $implicit_action_list[$action_name]['action_form'] = $class_name;
+ $implicit_action_list[$action_name]['action_form_file'] = $file;
+ $implicit_action_list[$action_name]['action_form_info'] = $def;
+ } else {
+ continue;
+ }
+ }
+ }
+
+ return $implicit_action_list;
+ }
+
+ /**
+ * ¥¢¥¯¥·¥ç¥óÄêµÁ°ìÍ÷¤òÊä´°¤¹¤ë
+ *
+ * @access private
+ * @param array $action_list ¼èÆÀ¤·¤¿¥¢¥¯¥·¥ç¥ó°ìÍ÷
+ * @return array ½¤Àµ¸å¤Î¥¢¥¯¥·¥ç¥ó°ìÍ÷
+ */
+ function _addActionList($action_list)
+ {
+ foreach ($action_list as $action_name => $action) {
+ // ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¤Ë¥Õ¥©¡¼¥àÄêµÁ¾ðÊó¤òÄɲÃ
+ $form_name = $action['action_form'];
+ if (class_exists($form_name) == false) {
+ continue;
+ }
+ $af =& new $form_name($this->ctl);
+
+ $form = array();
+ foreach ($af->getDef() as $name => $def) {
+ $form[$name]['required'] = $def['required'] ? 'true' : 'false';
+ foreach (array('name', 'max', 'min', 'regexp', 'custom') as $key) {
+ $form[$name][$key] = $def[$key];
+ }
+ $form[$name]['filter'] = str_replace(",", "\n", $def['filter']);
+ $form[$name]['form_type'] = $this->getAttrName('form_type', $def['form_type']);
+ $form[$name]['type_is_array'] = is_array($def['type']);
+ $form[$name]['type'] = $this->getAttrName('var_type', is_array($def['type']) ? $def['type'][0] : $def['type']);
+ }
+ $action['action_form_info']['form'] = $form;
+ $action_list[$action_name] = $action;
+ }
+
+ return $action_list;
+ }
+
+ /**
+ * ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥Æ¥ó¥×¥ì¡¼¥È¤ò²òÀϤ¹¤ë
+ *
+ * @access private
+ * @param string $action_dir ²òÀÏÂоݤΥǥ£¥ì¥¯¥È¥ê
+ * @return array Á«°ÜÄêµÁ°ìÍ÷
+ */
+ function _analyzeForwardList($template_dir = null)
+ {
+ $r = array();
+
+ if (is_null($template_dir)) {
+ $template_dir = $this->ctl->getTemplatedir();
+ }
+ $prefix_len = strlen($this->ctl->getTemplatedir());
+
+ $child_dir_list = array();
+
+ $dh = opendir($template_dir);
+ if ($dh == false) {
+ return;
+ }
+
+ $ext = $this->ctl->getExt('tpl');
+ while (($file = readdir($dh)) !== false) {
+ if ($file == "." || $file == "..") {
+ continue;
+ }
+ $file = $template_dir . '/' . $file;
+
+ if (is_dir($file)) {
+ $child_dir_list[] = $file;
+ continue;
+ }
+
+ if (preg_match("/\.$ext\$/", $file) == 0) {
+ continue;
+ }
+
+ $tpl = substr($file, $prefix_len);
+ $r[] = $this->ctl->forwardPathToName($tpl);
+ }
+
+ closedir($dh);
+
+ foreach ($child_dir_list as $child_dir) {
+ $tmp = $this->_analyzeForwardList($child_dir);
+ $r = array_merge($r, $tmp);
+ }
+
+ return $r;
+ }
+
+ /**
+ * ¥³¥ó¥È¥í¡¼¥é¤ËÌÀ¼¨Åª¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ëÁ«°ÜÀè°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return array ¥Ó¥å¡¼°ìÍ÷
+ */
+ function _getForwardList_Manifest()
+ {
+ $manifest_forward_list = array();
+ foreach ($this->ctl->forward as $forward_name => $forward) {
+ if ($forward_name == '__ethna_info__') {
+ continue;
+ }
+
+ $elt = array();
+ $elt['template_file'] = $this->ctl->_getForwardPath($forward_name);
+ if (file_exists(sprintf("%s/%s", $this->ctl->getTemplatedir(), $elt['template_file'])) == false) {
+ $elt['template_file_info'] = array('undef' => true);
+ }
+
+ $elt['view_class'] = $this->ctl->getViewClassName($forward_name);
+ if ($elt['view_class'] == 'Ethna_ViewClass') {
+ $elt['view_class'] = null;
+ } else if (class_exists($elt['view_class']) == false) {
+ $elt['view_class_info'] = array('undef' => true);
+ }
+
+ if (isset($forward['view_path']) && $forward['view_path']) {
+ $elt['view_path'] = $forward['view_path'];
+ } else if ($this->_isSubclassOf($elt['view_class'], 'Ethna_ViewClass')) {
+ $elt['view_class_file'] = $this->ctl->getDefaultViewPath($forward_name);
+ } else {
+ foreach ($this->cache_class_list as $file => $elts) {
+ foreach ($elts as $name => $def) {
+ if (strcasecmp($elt['view_class'], $name) == 0) {
+ $elt['view_class_file'] = $file;
+ break 2;
+ }
+ }
+ }
+ }
+
+ $manifest_forward_list[$forward_name] = $elt;
+ }
+
+ return $manifest_forward_list;
+ }
+
+ /**
+ * °ÅÌÛ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥Ó¥å¡¼°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @param array $forward_list ÄêµÁ¤µ¤ì¤Æ¤¤¤ëÁ«°Ü̾°ìÍ÷
+ * @param array $manifest_forward_list ÌÀ¼¨Åª¤ËÄêµÁºÑ¤ß¤Î¥Ó¥å¡¼°ìÍ÷
+ * @return array array:¥Ó¥å¡¼°ìÍ÷
+ */
+ function _getForwardList_Implicit($forward_list, $manifest_forward_list)
+ {
+ $implicit_forward_list = array();
+ $manifest_forward_name_list = array_keys($manifest_forward_list);
+
+ foreach ($forward_list as $forward_name) {
+ if (in_array($forward_name, $manifest_forward_name_list)) {
+ continue;
+ }
+
+ $elt = array();
+ $elt['template_file'] = $this->ctl->_getForwardPath($forward_name);
+ $elt['view_class'] = $this->ctl->getViewClassName($forward_name);
+ if ($elt['view_class'] == 'Ethna_ViewClass') {
+ $elt['view_class'] = null;
+ } else if (class_exists($elt['view_class']) == false) {
+ $elt['view_class'] = null;
+ } else {
+ $elt['view_class_file'] = $this->ctl->getDefaultViewPath($forward_name);
+ }
+
+ $implicit_forward_list[$forward_name] = $elt;
+ }
+
+ return $implicit_forward_list;
+ }
+
+ /**
+ * Ethna¤ÎÀßÄê°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return array ÀßÄê°ìÍ÷¤ò³ÊǼ¤·¤¿ÇÛÎó
+ * @todo respect access controll
+ */
+ function getConfiguration()
+ {
+ $r = array();
+
+ // core
+ $elts = array();
+ $elts['¥¢¥×¥ê¥±¡¼¥·¥ç¥óID'] = $this->ctl->getAppId();
+ $elts['¥¢¥×¥ê¥±¡¼¥·¥ç¥óURL'] = $this->ctl->getURL();
+ $elts['Ethna¥Ð¡¼¥¸¥ç¥ó'] = ETHNA_VERSION;
+ $elts['Ethna¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê'] = ETHNA_BASE;
+ $r['Core'] = $elts;
+
+ // class
+ $elts = array();
+ $elts['¥Ð¥Ã¥¯¥¨¥ó¥É'] = $this->class_factory->getObjectName('backend');
+ $elts['¥¯¥é¥¹¥Õ¥¡¥¯¥È¥ê'] = $this->class_factory->getObjectName('class');
+ $elts['ÀßÄê'] = $this->class_factory->getObjectName('config');
+ $elts['DB'] = $this->class_factory->getObjectName('db');
+ $elts['¥¨¥é¡¼'] = $this->class_factory->getObjectName('error');
+ $elts['¥Õ¥©¡¼¥à'] = $this->class_factory->getObjectName('form');
+ $elts['¥í¥°'] = $this->class_factory->getObjectName('logger');
+ $elts['i18n'] = $this->class_factory->getObjectName('i18n');
+ $elts['¥×¥é¥°¥¤¥ó'] = $this->class_factory->getObjectName('plugin');
+ $elts['¥»¥Ã¥·¥ç¥ó'] = $this->class_factory->getObjectName('session');
+ $elts['SQL'] = $this->class_factory->getObjectName('sql');
+ $elts['¥Ó¥å¡¼'] = $this->class_factory->getObjectName('view');
+ $r['¥¯¥é¥¹'] = $elts;
+
+ // DB
+ $elts = array();
+ $db_list = array();
+ foreach ($this->ctl->db as $key => $db) {
+ if ($key == "") {
+ $tmp = '$db';
+ } else {
+ $tmp = sprintf('$db_%s', $key);
+ }
+ $elts[$tmp] = $this->getAttrName('db_type', $db);
+ $db_list[$key] = $tmp;
+ }
+ $r['DB¥¿¥¤¥×'] = $elts;
+
+ // DSN
+ $elts = array();
+ foreach ($db_list as $key => $name) {
+ $config_key = "dsn";
+ if ($key != "") {
+ $config_key .= "_$key";
+ }
+ $dsn = $this->config->get($config_key);
+ if ($dsn) {
+ $elts[$name] = implode("\n", to_array($dsn));
+ }
+ }
+ $r['DSN'] = $elts;
+
+ // directory
+ $elts = array();
+ $elts['¥¢¥×¥ê¥±¡¼¥·¥ç¥ó'] = $this->ctl->getBasedir();
+ $elts['¥¢¥¯¥·¥ç¥ó'] = $this->ctl->getActiondir();
+ $elts['¥Ó¥å¡¼'] = $this->ctl->getViewdir();
+ $elts['¥Õ¥£¥ë¥¿'] = $this->ctl->getDirectory('filter');
+ $elts['¥×¥é¥°¥¤¥ó'] = $this->ctl->getDirectory('plugin');
+ $elts['¥Æ¥ó¥×¥ì¡¼¥È'] = $this->ctl->getTemplatedir();
+ $elts['¥Æ¥ó¥×¥ì¡¼¥È¥¥ã¥Ã¥·¥å'] = $this->ctl->getDirectory('template_c');
+ $elts['Smarty¥×¥é¥°¥¤¥ó'] = implode(',', $this->ctl->getDirectory('plugins'));
+ $elts['ÀßÄê¥Õ¥¡¥¤¥ë'] = $this->ctl->getDirectory('etc');
+ $elts['¥í¥±¡¼¥ë'] = $this->ctl->getDirectory('locale');
+ $elts['¥í¥°'] = $this->ctl->getDirectory('log');
+ $elts['°ì»þ¥Õ¥¡¥¤¥ë'] = $this->ctl->getDirectory('tmp');
+ $r['¥Ç¥£¥ì¥¯¥È¥ê'] = $elts;
+
+ // ext
+ $elts = array();
+ $elts['¥Æ¥ó¥×¥ì¡¼¥È'] = $this->ctl->getExt('tpl');
+ $elts['PHP¥¹¥¯¥ê¥×¥È'] = $this->ctl->getExt('php');
+ $r['³ÈÄ¥»Ò'] = $elts;
+
+ // filter
+ $elts = array();
+ $n = 1;
+ foreach ($this->ctl->filter as $filter) {
+ $key = sprintf("¥Õ¥£¥ë¥¿(%d)", $n);
+ if (class_exists($filter)) {
+ $elts[$key] = $filter;
+ $n++;
+ }
+ }
+ $r['¥Õ¥£¥ë¥¿'] = $elts;
+
+ // plugin
// XXX: ¼ê½ñ¤¤ò¤Ê¤ó¤È¤«¤¹¤ë
$plugin_type_list = array(
'Cachemanager',
$r["¥×¥é¥°¥¤¥ó ({$type})"] = $elts;
}
- // manager
- $elts = array();
- foreach ($this->ctl->getManagerList() as $key => $manager) {
- $name = sprintf('$%s', $key);
- $elts[$name] = $this->ctl->getManagerClassName($manager);
- }
- $r['¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Þ¥Í¡¼¥¸¥ã'] = $elts;
+ // manager
+ $elts = array();
+ foreach ($this->ctl->getManagerList() as $key => $manager) {
+ $name = sprintf('$%s', $key);
+ $elts[$name] = $this->ctl->getManagerClassName($manager);
+ }
+ $r['¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Þ¥Í¡¼¥¸¥ã'] = $elts;
- return $r;
- }
+ return $r;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Logger.php
+ * Ethna_Logger.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
/**
- * ³ÈÄ¥¥í¥°¥×¥í¥Ñ¥Æ¥£: ¥Õ¥¡¥¤¥ë½ÐÎÏ
+ * ³ÈÄ¥¥í¥°¥×¥í¥Ñ¥Æ¥£: ¥Õ¥¡¥¤¥ë½ÐÎÏ
*/
define('LOG_FILE', 1 << 16);
/**
- * ³ÈÄ¥¥í¥°¥×¥í¥Ñ¥Æ¥£: ɸ½à½ÐÎÏ
+ * ³ÈÄ¥¥í¥°¥×¥í¥Ñ¥Æ¥£: ɸ½à½ÐÎÏ
*/
define('LOG_ECHO', 1 << 17);
// {{{ ethna_error_handler
/**
- * ¥¨¥é¡¼¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô
+ * ¥¨¥é¡¼¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô
*
- * @param int $errno ¥¨¥é¡¼¥ì¥Ù¥ë
- * @param string $errstr ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
- * @param string $errfile ¥¨¥é¡¼È¯À¸²Õ½ê¤Î¥Õ¥¡¥¤¥ë̾
- * @param string $errline ¥¨¥é¡¼È¯À¸²Õ½ê¤Î¹ÔÈÖ¹æ
+ * @param int $errno ¥¨¥é¡¼¥ì¥Ù¥ë
+ * @param string $errstr ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
+ * @param string $errfile ¥¨¥é¡¼È¯À¸²Õ½ê¤Î¥Õ¥¡¥¤¥ë̾
+ * @param string $errline ¥¨¥é¡¼È¯À¸²Õ½ê¤Î¹ÔÈÖ¹æ
*/
function ethna_error_handler($errno, $errstr, $errfile, $errline)
{
- if ($errno == E_STRICT) {
- // E_STRICT¤Ïɽ¼¨¤·¤Ê¤¤
- return E_STRICT;
- }
-
- list($level, $name) = Ethna_Logger::errorLevelToLogLevel($errno);
- switch ($errno) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- $php_errno = 'Fatal error'; break;
- case E_WARNING:
- case E_CORE_WARNING:
- case E_COMPILE_WARNING:
- case E_USER_WARNING:
- $php_errno = 'Warning'; break;
- case E_PARSE:
- $php_errno = 'Parse error'; break;
- case E_NOTICE:
- case E_USER_NOTICE:
- $php_errno = 'Notice'; break;
- default:
- $php_errno = 'Unknown error'; break;
- }
-
- $php_errstr = sprintf('PHP %s: %s in %s on line %d', $php_errno, $errstr, $errfile, $errline);
- if (ini_get('log_errors') && (error_reporting() & $errno)) {
- $locale = setlocale(LC_TIME, 0);
- setlocale(LC_TIME, 'C');
- error_log($php_errstr, 0);
- setlocale(LC_TIME, $locale);
- }
-
- $c =& Ethna_Controller::getInstance();
- $logger =& $c->getLogger();
- $logger->log($level, sprintf("[PHP] %s: %s in %s on line %d", $name, $errstr, $errfile, $errline));
-
- $facility = $logger->getLogFacility();
+ if ($errno == E_STRICT) {
+ // E_STRICT¤Ïɽ¼¨¤·¤Ê¤¤
+ return E_STRICT;
+ }
+
+ list($level, $name) = Ethna_Logger::errorLevelToLogLevel($errno);
+ switch ($errno) {
+ case E_ERROR:
+ case E_CORE_ERROR:
+ case E_COMPILE_ERROR:
+ case E_USER_ERROR:
+ $php_errno = 'Fatal error'; break;
+ case E_WARNING:
+ case E_CORE_WARNING:
+ case E_COMPILE_WARNING:
+ case E_USER_WARNING:
+ $php_errno = 'Warning'; break;
+ case E_PARSE:
+ $php_errno = 'Parse error'; break;
+ case E_NOTICE:
+ case E_USER_NOTICE:
+ $php_errno = 'Notice'; break;
+ default:
+ $php_errno = 'Unknown error'; break;
+ }
+
+ $php_errstr = sprintf('PHP %s: %s in %s on line %d', $php_errno, $errstr, $errfile, $errline);
+ if (ini_get('log_errors') && (error_reporting() & $errno)) {
+ $locale = setlocale(LC_TIME, 0);
+ setlocale(LC_TIME, 'C');
+ error_log($php_errstr, 0);
+ setlocale(LC_TIME, $locale);
+ }
+
+ $c =& Ethna_Controller::getInstance();
+ $logger =& $c->getLogger();
+ $logger->log($level, sprintf("[PHP] %s: %s in %s on line %d", $name, $errstr, $errfile, $errline));
+
+ $facility = $logger->getLogFacility();
$has_echo = false;
if ((is_array($facility) && in_array(LOG_ECHO, $facility)) || (is_array($facility) == false && $facility == LOG_ECHO)) {
$has_echo = true;
}
- if ($has_echo == false && ini_get('display_errors') && (error_reporting() & $errno)) {
- if ($c->getGateway() != GATEWAY_WWW) {
- $format = "%s: %s in %s on line %d\n";
- } else {
- $format = "<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n";
- }
- printf($format, $php_errno, $errstr, $errfile, $errline);
- }
+ if ($has_echo == false && ini_get('display_errors') && (error_reporting() & $errno)) {
+ if ($c->getGateway() != GATEWAY_WWW) {
+ $format = "%s: %s in %s on line %d\n";
+ } else {
+ $format = "<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n";
+ }
+ printf($format, $php_errno, $errstr, $errfile, $errline);
+ }
}
// }}}
// {{{ Ethna_Logger
/**
- * ¥í¥°´ÉÍý¥¯¥é¥¹
+ * ¥í¥°´ÉÍý¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Logger extends Ethna_AppManager
{
- /**#@+
- * @access private
- */
-
- /** @var array ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£°ìÍ÷ */
- var $log_facility_list = array(
- 'auth' => array('name' => 'LOG_AUTH'),
- 'cron' => array('name' => 'LOG_CRON'),
- 'daemon' => array('name' => 'LOG_DAEMON'),
- 'kern' => array('name' => 'LOG_KERN'),
- 'lpr' => array('name' => 'LOG_LPR'),
- 'mail' => array('name' => 'LOG_MAIL'),
- 'news' => array('name' => 'LOG_NEWS'),
- 'syslog' => array('name' => 'LOG_SYSLOG'),
- 'user' => array('name' => 'LOG_USER'),
- 'uucp' => array('name' => 'LOG_UUCP'),
- 'file' => array('name' => 'LOG_FILE'),
- 'echo' => array('name' => 'LOG_ECHO'),
- );
-
- /** @var array ¥í¥°¥ì¥Ù¥ë°ìÍ÷ */
- var $log_level_list = array(
+ /**#@+
+ * @access private
+ */
+
+ /** @var array ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£°ìÍ÷ */
+ var $log_facility_list = array(
+ 'auth' => array('name' => 'LOG_AUTH'),
+ 'cron' => array('name' => 'LOG_CRON'),
+ 'daemon' => array('name' => 'LOG_DAEMON'),
+ 'kern' => array('name' => 'LOG_KERN'),
+ 'lpr' => array('name' => 'LOG_LPR'),
+ 'mail' => array('name' => 'LOG_MAIL'),
+ 'news' => array('name' => 'LOG_NEWS'),
+ 'syslog' => array('name' => 'LOG_SYSLOG'),
+ 'user' => array('name' => 'LOG_USER'),
+ 'uucp' => array('name' => 'LOG_UUCP'),
+ 'file' => array('name' => 'LOG_FILE'),
+ 'echo' => array('name' => 'LOG_ECHO'),
+ );
+
+ /** @var array ¥í¥°¥ì¥Ù¥ë°ìÍ÷ */
+ var $log_level_list = array(
'emerg' => array('name' => 'LOG_EMERG', 'value' => 7),
'alert' => array('name' => 'LOG_ALERT', 'value' => 6),
'crit' => array('name' => 'LOG_CRIT', 'value' => 5),
'notice' => array('name' => 'LOG_NOTICE', 'value' => 2),
'info' => array('name' => 'LOG_INFO', 'value' => 1),
'debug' => array('name' => 'LOG_DEBUG', 'value' => 0),
- );
+ );
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
/** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È($controller¤Î¾Êά·Á) */
var $ctl;
- /** @var array ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£ */
- var $facility = array();
+ /** @var array ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£ */
+ var $facility = array();
- /** @var array ¥í¥°¥ì¥Ù¥ë */
- var $level = array();
+ /** @var array ¥í¥°¥ì¥Ù¥ë */
+ var $level = array();
- /** @var array ¥í¥°¥ª¥×¥·¥ç¥ó */
- var $option = array();
+ /** @var array ¥í¥°¥ª¥×¥·¥ç¥ó */
+ var $option = array();
- /** @var array ¥á¥Ã¥»¡¼¥¸¥Õ¥£¥ë¥¿(½ÐÎÏ) */
- var $message_filter_do = array();
+ /** @var array ¥á¥Ã¥»¡¼¥¸¥Õ¥£¥ë¥¿(½ÐÎÏ) */
+ var $message_filter_do = array();
- /** @var array ¥á¥Ã¥»¡¼¥¸¥Õ¥£¥ë¥¿(̵»ë) */
- var $message_filter_ignore = array();
+ /** @var array ¥á¥Ã¥»¡¼¥¸¥Õ¥£¥ë¥¿(̵»ë) */
+ var $message_filter_ignore = array();
- /** @var int ¥¢¥é¡¼¥È¥ì¥Ù¥ë */
- var $alert_level;
+ /** @var int ¥¢¥é¡¼¥È¥ì¥Ù¥ë */
+ var $alert_level;
- /** @var string ¥¢¥é¡¼¥È¥á¡¼¥ë¥¢¥É¥ì¥¹ */
- var $alert_mailaddress;
+ /** @var string ¥¢¥é¡¼¥È¥á¡¼¥ë¥¢¥É¥ì¥¹ */
+ var $alert_mailaddress;
- /** @var array Ethna_LogWriter ¥í¥°½ÐÎÏ¥ª¥Ö¥¸¥§¥¯¥È */
- var $writer;
+ /** @var array Ethna_LogWriter ¥í¥°½ÐÎÏ¥ª¥Ö¥¸¥§¥¯¥È */
+ var $writer;
- /** @var bool ¥í¥°½ÐÎϳ«»Ï¥Õ¥é¥° */
- var $is_begin = false;
+ /** @var bool ¥í¥°½ÐÎϳ«»Ï¥Õ¥é¥° */
+ var $is_begin = false;
- /** @var array ¥í¥°¥¹¥¿¥Ã¥¯(begin()Á°¤Ëlog()¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¤Î¥¹¥¿¥Ã¥¯) */
- var $log_stack = array();
+ /** @var array ¥í¥°¥¹¥¿¥Ã¥¯(begin()Á°¤Ëlog()¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¤Î¥¹¥¿¥Ã¥¯) */
+ var $log_stack = array();
- /**#@-*/
-
- /**
- * Ethna_Logger¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Controller $controller controller¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_Logger(&$controller)
- {
- $this->controller =& $controller;
+ /**#@-*/
+
+ /**
+ * Ethna_Logger¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Controller $controller controller¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_Logger(&$controller)
+ {
+ $this->controller =& $controller;
$this->ctl =& $this->controller;
- $config =& $controller->getConfig();
+ $config =& $controller->getConfig();
// ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£¥Æ¡¼¥Ö¥ëÊä´°(LOCAL0¡ÁLOCAL8)
- for ($i = 0; $i < 8; $i++) {
- if (defined("LOG_LOCAL$i")) {
- $this->log_facility_list["local$i"] = array('name' => "LOG_LOCAL$i");
- }
- }
+ for ($i = 0; $i < 8; $i++) {
+ if (defined("LOG_LOCAL$i")) {
+ $this->log_facility_list["local$i"] = array('name' => "LOG_LOCAL$i");
+ }
+ }
- // ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£
+ // ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£
$this->facility = $this->_parseLogFacility($config->get('log_facility'));
foreach ($this->facility as $f) {
}
// ¥¢¥é¡¼¥È¥ª¥×¥·¥ç¥ó
- $this->alert_level = $this->_parseLogLevel($config->get('log_alert_level'));
- $this->alert_mailaddress = preg_split('/\s*,\s*/', $config->get('log_alert_mailaddress'));
-
- set_error_handler("ethna_error_handler");
- }
-
- /**
- * ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return mixed ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(¥Õ¥¡¥·¥ê¥Æ¥£¤¬1¤Ä°Ê²¼¤Ê¤éscalar¡¢2¤Ä°Ê¾å¤Ê¤éÇÛÎó¤òÊÖ¤¹ for B.C.)
- */
- function getLogFacility()
- {
+ $this->alert_level = $this->_parseLogLevel($config->get('log_alert_level'));
+ $this->alert_mailaddress = preg_split('/\s*,\s*/', $config->get('log_alert_mailaddress'));
+
+ set_error_handler("ethna_error_handler");
+ }
+
+ /**
+ * ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return mixed ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(¥Õ¥¡¥·¥ê¥Æ¥£¤¬1¤Ä°Ê²¼¤Ê¤éscalar¡¢2¤Ä°Ê¾å¤Ê¤éÇÛÎó¤òÊÖ¤¹ for B.C.)
+ */
+ function getLogFacility()
+ {
if (is_array($this->facility)) {
if (count($this->facility) == 0) {
return null;
return $this->facility[0];
}
}
- return $this->facility;
- }
-
- /**
- * PHP¥¨¥é¡¼¥ì¥Ù¥ë¤ò¥í¥°¥ì¥Ù¥ë¤ËÊÑ´¹¤¹¤ë
- *
- * @access public
- * @param int $errno PHP¥¨¥é¡¼¥ì¥Ù¥ë
- * @return array ¥í¥°¥ì¥Ù¥ë(LOG_NOTICE,...), ¥¨¥é¡¼¥ì¥Ù¥ëɽ¼¨Ì¾("E_NOTICE"...)
- * @static
- */
- function errorLevelToLogLevel($errno)
- {
- switch ($errno) {
- case E_ERROR: $code = "E_ERROR"; $level = LOG_ERR; break;
- case E_WARNING: $code = "E_WARNING"; $level = LOG_WARNING; break;
- case E_PARSE: $code = "E_PARSE"; $level = LOG_CRIT; break;
- case E_NOTICE: $code = "E_NOTICE"; $level = LOG_NOTICE; break;
- case E_USER_ERROR: $code = "E_USER_ERROR"; $level = LOG_ERR; break;
- case E_USER_WARNING: $code = "E_USER_WARNING"; $level = LOG_WARNING; break;
- case E_USER_NOTICE: $code = "E_USER_NOTICE"; $level = LOG_NOTICE; break;
- case E_STRICT: $code = "E_STRING"; $level = LOG_NOTICE; return;
- default: $code = "E_UNKNOWN"; $level = LOG_DEBUG; break;
- }
- return array($level, $code);
- }
-
- /**
- * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
- *
- * @access public
- */
- function begin()
- {
- // LogWriter¥¯¥é¥¹¤ÎÀ¸À®
+ return $this->facility;
+ }
+
+ /**
+ * PHP¥¨¥é¡¼¥ì¥Ù¥ë¤ò¥í¥°¥ì¥Ù¥ë¤ËÊÑ´¹¤¹¤ë
+ *
+ * @access public
+ * @param int $errno PHP¥¨¥é¡¼¥ì¥Ù¥ë
+ * @return array ¥í¥°¥ì¥Ù¥ë(LOG_NOTICE,...), ¥¨¥é¡¼¥ì¥Ù¥ëɽ¼¨Ì¾("E_NOTICE"...)
+ * @static
+ */
+ function errorLevelToLogLevel($errno)
+ {
+ switch ($errno) {
+ case E_ERROR: $code = "E_ERROR"; $level = LOG_ERR; break;
+ case E_WARNING: $code = "E_WARNING"; $level = LOG_WARNING; break;
+ case E_PARSE: $code = "E_PARSE"; $level = LOG_CRIT; break;
+ case E_NOTICE: $code = "E_NOTICE"; $level = LOG_NOTICE; break;
+ case E_USER_ERROR: $code = "E_USER_ERROR"; $level = LOG_ERR; break;
+ case E_USER_WARNING: $code = "E_USER_WARNING"; $level = LOG_WARNING; break;
+ case E_USER_NOTICE: $code = "E_USER_NOTICE"; $level = LOG_NOTICE; break;
+ case E_STRICT: $code = "E_STRING"; $level = LOG_NOTICE; return;
+ default: $code = "E_UNKNOWN"; $level = LOG_DEBUG; break;
+ }
+ return array($level, $code);
+ }
+
+ /**
+ * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
+ *
+ * @access public
+ */
+ function begin()
+ {
+ // LogWriter¥¯¥é¥¹¤ÎÀ¸À®
foreach ($this->facility as $f) {
$this->writer[$f] =& $this->_getLogWriter($this->option[$f], $f);
if (Ethna::isError($this->writer[$f])) {
$this->log($log[0], $log[1]);
}
}
- }
-
- /**
- * ¥í¥°¤ò½ÐÎϤ¹¤ë
- *
- * @access public
- * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
- * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
- */
- function log($level, $message)
- {
+ }
+
+ /**
+ * ¥í¥°¤ò½ÐÎϤ¹¤ë
+ *
+ * @access public
+ * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
+ * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
+ */
+ function log($level, $message)
+ {
if ($this->is_begin == false) {
$args = func_get_args();
if (count($args) > 2) {
$output = $writer->log($level, $message);
}
- // ¥¢¥é¡¼¥È½èÍý
- if ($this->_evalLevelMask($this->alert_level, $level) == false) {
- if (count($this->alert_mailaddress) > 0) {
- $this->_alert($output);
- }
- }
- }
-
- /**
- * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
- *
- * @access public
- */
- function end()
- {
+ // ¥¢¥é¡¼¥È½èÍý
+ if ($this->_evalLevelMask($this->alert_level, $level) == false) {
+ if (count($this->alert_mailaddress) > 0) {
+ $this->_alert($output);
+ }
+ }
+ }
+
+ /**
+ * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
+ *
+ * @access public
+ */
+ function end()
+ {
foreach ($this->writer as $writer) {
$writer->end();
}
$this->is_begin = false;
- }
-
- /**
- * LogWriter¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
- *
- * @access protected
- * @param array $option ¥í¥°¥ª¥×¥·¥ç¥ó
- * @param string $facility ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£
- * @return object LogWriter LogWriter¥ª¥Ö¥¸¥§¥¯¥È
- */
- function &_getLogWriter($option, $facility = null)
- {
+ }
+
+ /**
+ * LogWriter¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access protected
+ * @param array $option ¥í¥°¥ª¥×¥·¥ç¥ó
+ * @param string $facility ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£
+ * @return object LogWriter LogWriter¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function &_getLogWriter($option, $facility = null)
+ {
if ($facility == null) {
$facility = $this->getLogFacility();
if (is_array($facility)) {
}
}
- if (is_null($facility)) {
- $plugin = "default";
+ if (is_null($facility)) {
+ $plugin = "default";
} else if (isset($this->log_facility_list[$facility])) {
if ($facility == "file" || $facility == "echo") {
$plugin = $facility;
- } else {
- $plugin = "syslog";
- }
- } else {
+ } else {
+ $plugin = "syslog";
+ }
+ } else {
$plugin = $facility;
- }
+ }
$plugin_manager =& $this->controller->getPlugin();
$plugin_object = $plugin_manager->getPlugin('Logwriter', ucfirst(strtolower($plugin)));
$plugin_object->setOption($option);
return $plugin_object;
- }
-
- /**
- * ¥í¥°¥ª¥×¥·¥ç¥ó(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)¤ò²òÀϤ¹¤ë
- *
- * @access private
- * @param string $string ¥í¥°¥ª¥×¥·¥ç¥ó(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)
- * @return array ²òÀϤµ¤ì¤¿ÀßÄê¥Õ¥¡¥¤¥ëÃÍ(¥¢¥é¡¼¥ÈÄÌÃΥ᡼¥ë¥¢¥É¥ì¥¹, ¥¢¥é¡¼¥ÈÂÐ¾Ý¥í¥°¥ì¥Ù¥ë, ¥í¥°¥ª¥×¥·¥ç¥ó)
- */
- function _parseLogOption($string)
- {
+ }
+
+ /**
+ * ¥í¥°¥ª¥×¥·¥ç¥ó(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)¤ò²òÀϤ¹¤ë
+ *
+ * @access private
+ * @param string $string ¥í¥°¥ª¥×¥·¥ç¥ó(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)
+ * @return array ²òÀϤµ¤ì¤¿ÀßÄê¥Õ¥¡¥¤¥ëÃÍ(¥¢¥é¡¼¥ÈÄÌÃΥ᡼¥ë¥¢¥É¥ì¥¹, ¥¢¥é¡¼¥ÈÂÐ¾Ý¥í¥°¥ì¥Ù¥ë, ¥í¥°¥ª¥×¥·¥ç¥ó)
+ */
+ function _parseLogOption($string)
+ {
if (is_null($string)) {
return null;
}
$option = array();
- $elts = preg_split('/\s*,\s*/', $string);
- foreach ($elts as $elt) {
+ $elts = preg_split('/\s*,\s*/', $string);
+ foreach ($elts as $elt) {
if (preg_match('/^(.*?)\s*:\s*(.*)/', $elt, $match)) {
$option[$match[1]] = $match[2];
} else {
$option[$elt] = true;
}
- }
-
- return $option;
- }
-
- /**
- * ¥¢¥é¡¼¥È¥á¡¼¥ë¤òÁ÷¿®¤¹¤ë
- *
- * @access protected
- * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸
- * @return int 0:Àµ¾ï½ªÎ»
- */
- function _alert($message)
- {
- restore_error_handler();
-
- // ¥Ø¥Ã¥À
- $header = "Mime-Version: 1.0\n";
- $header .= "Content-Type: text/plain; charset=ISO-2022-JP\n";
+ }
+
+ return $option;
+ }
+
+ /**
+ * ¥¢¥é¡¼¥È¥á¡¼¥ë¤òÁ÷¿®¤¹¤ë
+ *
+ * @access protected
+ * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸
+ * @return int 0:Àµ¾ï½ªÎ»
+ */
+ function _alert($message)
+ {
+ restore_error_handler();
+
+ // ¥Ø¥Ã¥À
+ $header = "Mime-Version: 1.0\n";
+ $header .= "Content-Type: text/plain; charset=ISO-2022-JP\n";
$header .= "X-Alert: " . $this->controller->getAppId();
$subject = sprintf("[%s] alert (%s%s)\n", $this->controller->getAppId(), substr($message, 0, 12), strlen($message) > 12 ? "..." : "");
-
- // ËÜʸ
- $mail = sprintf("--- [log message] ---\n%s\n\n", $message);
- if (function_exists("debug_backtrace")) {
- $bt = debug_backtrace();
- $mail .= sprintf("--- [backtrace] ---\n%s\n", Ethna_Util::FormatBacktrace($bt));
- }
-
- foreach ($this->alert_mailaddress as $mailaddress) {
- mail($mailaddress, $subject, mb_convert_encoding($mail, "ISO-2022-JP"), $header);
- }
-
- set_error_handler("ethna_error_handler");
-
- return 0;
- }
-
- /**
- * ¥í¥°¥á¥Ã¥»¡¼¥¸¤Î¥Þ¥¹¥¯¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
- *
- * @access private
+
+ // ËÜʸ
+ $mail = sprintf("--- [log message] ---\n%s\n\n", $message);
+ if (function_exists("debug_backtrace")) {
+ $bt = debug_backtrace();
+ $mail .= sprintf("--- [backtrace] ---\n%s\n", Ethna_Util::FormatBacktrace($bt));
+ }
+
+ foreach ($this->alert_mailaddress as $mailaddress) {
+ mail($mailaddress, $subject, mb_convert_encoding($mail, "ISO-2022-JP"), $header);
+ }
+
+ set_error_handler("ethna_error_handler");
+
+ return 0;
+ }
+
+ /**
+ * ¥í¥°¥á¥Ã¥»¡¼¥¸¤Î¥Þ¥¹¥¯¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
+ *
+ * @access private
* @param string $filter ¥Õ¥£¥ë¥¿
- * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸
- * @return mixed true:match, null:skip
- */
- function _evalMessageMask($filter, $message)
- {
+ * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸
+ * @return mixed true:match, null:skip
+ */
+ function _evalMessageMask($filter, $message)
+ {
$regexp = sprintf("/%s/", $filter);
if ($filter && preg_match($regexp, $message)) {
return true;
}
- return null;
- }
-
- /**
- * ¥í¥°¥ì¥Ù¥ë¤Î¥Þ¥¹¥¯¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
- *
- * @access private
- * @param int $src ¥í¥°¥ì¥Ù¥ë¥Þ¥¹¥¯
- * @param int $dst ¥í¥°¥ì¥Ù¥ë
- * @return bool true:ïçÃͰʲ¼ false:ïçÃͰʾå
- */
- function _evalLevelMask($src, $dst)
- {
+ return null;
+ }
+
+ /**
+ * ¥í¥°¥ì¥Ù¥ë¤Î¥Þ¥¹¥¯¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
+ *
+ * @access private
+ * @param int $src ¥í¥°¥ì¥Ù¥ë¥Þ¥¹¥¯
+ * @param int $dst ¥í¥°¥ì¥Ù¥ë
+ * @return bool true:ïçÃͰʲ¼ false:ïçÃͰʾå
+ */
+ function _evalLevelMask($src, $dst)
+ {
static $log_level_table = null;
if (is_null($log_level_table)) {
}
}
- // ÃΤé¤Ê¤¤¥ì¥Ù¥ë¤Ê¤é½ÐÎϤ·¤Ê¤¤
- if (isset($log_level_table[$src]) == false || isset($log_level_table[$dst]) == false) {
- return true;
- }
-
- if ($log_level_table[$dst] >= $log_level_table[$src]) {
- return false;
- }
-
- return true;
- }
-
- /**
- * ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)¤ò²òÀϤ¹¤ë
- *
- * @access private
- * @param string $facility ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)
- * @return array ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(LOG_LOCAL0, LOG_FILE...)¤ò³ÊǼ¤·¤¿ÇÛÎó
- */
- function _parseLogFacility($facility)
- {
+ // ÃΤé¤Ê¤¤¥ì¥Ù¥ë¤Ê¤é½ÐÎϤ·¤Ê¤¤
+ if (isset($log_level_table[$src]) == false || isset($log_level_table[$dst]) == false) {
+ return true;
+ }
+
+ if ($log_level_table[$dst] >= $log_level_table[$src]) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)¤ò²òÀϤ¹¤ë
+ *
+ * @access private
+ * @param string $facility ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)
+ * @return array ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£(LOG_LOCAL0, LOG_FILE...)¤ò³ÊǼ¤·¤¿ÇÛÎó
+ */
+ function _parseLogFacility($facility)
+ {
$facility_list = preg_split('/\s*,\s*/', $facility);
if (is_array($facility_list) == false) {
// no way
}
return $facility_list;
- }
-
- /**
- * ¥í¥°¥ì¥Ù¥ë(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)¤ò²òÀϤ¹¤ë
- *
- * @access private
- * @param string $level ¥í¥°¥ì¥Ù¥ë(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)
- * @return int ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
- */
- function _parseLogLevel($level)
- {
+ }
+
+ /**
+ * ¥í¥°¥ì¥Ù¥ë(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)¤ò²òÀϤ¹¤ë
+ *
+ * @access private
+ * @param string $level ¥í¥°¥ì¥Ù¥ë(ÀßÄê¥Õ¥¡¥¤¥ëÃÍ)
+ * @return int ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
+ */
+ function _parseLogLevel($level)
+ {
if (isset($this->log_level_list[strtolower($level)]) == false) {
- return null;
- }
+ return null;
+ }
$constant_name = $this->log_level_list[strtolower($level)]['name'];
return constant($constant_name);
- }
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Renderer.php
+ * Ethna_Renderer.php
*
- * @author Kazuhiro Hosoi <hosoi@gree.co.jp>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Kazuhiro Hosoi <hosoi@gree.co.jp>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Renderer
/**
- * ¥ì¥ó¥À¥é¥¯¥é¥¹¡ÊMojavi¤Î¤Þ¤Í¡Ë
+ * ¥ì¥ó¥À¥é¥¯¥é¥¹¡ÊMojavi¤Î¤Þ¤Í¡Ë
*
- * @author Kazuhiro Hosoi <hosoi@gree.co.jp>
- * @access public
- * @package Ethna
+ * @author Kazuhiro Hosoi <hosoi@gree.co.jp>
+ * @access public
+ * @package Ethna
*/
class Ethna_Renderer
{
*/
function setPlugin($name, $type, $plugin)
{
- $this->plugin_registry[$type][$name] = $plugin;
+ $this->plugin_registry[$type][$name] = $plugin;
}
}
// }}}
<?php
/**
- * Ethna_SmartyPlugin.php
+ * Ethna_SmartyPlugin.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
/**
- * smarty modifier:number_format()
+ * smarty modifier:number_format()
*
- * number_format()´Ø¿ô¤Îwrapper
+ * number_format()´Ø¿ô¤Îwrapper
*
- * sample:
- * <code>
- * {"12345"|number_format}
- * </code>
- * <code>
- * 12,345
- * </code>
+ * sample:
+ * <code>
+ * {"12345"|number_format}
+ * </code>
+ * <code>
+ * 12,345
+ * </code>
*
- * @param string $string ¥Õ¥©¡¼¥Þ¥Ã¥ÈÂоÝʸ»úÎó
- * @return string ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó
+ * @param string $string ¥Õ¥©¡¼¥Þ¥Ã¥ÈÂоÝʸ»úÎó
+ * @return string ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó
*/
function smarty_modifier_number_format($string)
{
- if ($string === "" || $string == null) {
- return "";
- }
- return number_format($string);
+ if ($string === "" || $string == null) {
+ return "";
+ }
+ return number_format($string);
}
/**
- * smarty modifier:strftime()
+ * smarty modifier:strftime()
*
- * strftime()´Ø¿ô¤Îwrapper
+ * strftime()´Ø¿ô¤Îwrapper
*
- * sample:
- * <code>
- * {"2004/01/01 01:01:01"|strftime:"%Yǯ%m·î%dÆü"}
- * </code>
- * <code>
- * 2004ǯ01·î01Æü
- * </code>
+ * sample:
+ * <code>
+ * {"2004/01/01 01:01:01"|strftime:"%Yǯ%m·î%dÆü"}
+ * </code>
+ * <code>
+ * 2004ǯ01·î01Æü
+ * </code>
*
- * @param string $string ¥Õ¥©¡¼¥Þ¥Ã¥ÈÂоÝʸ»úÎó
- * @param string $format ½ñ¼°»ØÄêʸ»úÎó(strftime()´Ø¿ô»²¾È)
- * @return string ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó
+ * @param string $string ¥Õ¥©¡¼¥Þ¥Ã¥ÈÂоÝʸ»úÎó
+ * @param string $format ½ñ¼°»ØÄêʸ»úÎó(strftime()´Ø¿ô»²¾È)
+ * @return string ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó
*/
function smarty_modifier_strftime($string, $format)
{
- if ($string === "" || $string == null) {
- return "";
- }
- return strftime($format, strtotime($string));
+ if ($string === "" || $string == null) {
+ return "";
+ }
+ return strftime($format, strtotime($string));
}
/**
- * smarty modifier:count()
+ * smarty modifier:count()
*
- * count()´Ø¿ô¤Îwrapper
+ * count()´Ø¿ô¤Îwrapper
*
- * sample:
- * <code>
- * $smarty->assign("array", array(1, 2, 3));
+ * sample:
+ * <code>
+ * $smarty->assign("array", array(1, 2, 3));
*
- * {$array|@count}
- * </code>
- * <code>
- * 3
- * </code>
+ * {$array|@count}
+ * </code>
+ * <code>
+ * 3
+ * </code>
*
- * @param array $array ÂоݤȤʤëÇÛÎó
- * @return int ÇÛÎó¤ÎÍ×ÁÇ¿ô
+ * @param array $array ÂоݤȤʤëÇÛÎó
+ * @return int ÇÛÎó¤ÎÍ×ÁÇ¿ô
*/
function smarty_modifier_count($array)
{
- return count($array);
+ return count($array);
}
/**
- * smarty modifier:join()
+ * smarty modifier:join()
*
- * join()´Ø¿ô¤Îwrapper
+ * join()´Ø¿ô¤Îwrapper
*
- * sample:
- * <code>
- * $smarty->assign("array", array(1, 2, 3));
+ * sample:
+ * <code>
+ * $smarty->assign("array", array(1, 2, 3));
*
- * {$array|@join:":"}
- * </code>
- * <code>
- * 1:2:3
- * </code>
+ * {$array|@join:":"}
+ * </code>
+ * <code>
+ * 1:2:3
+ * </code>
*
- * @param array $array joinÂоݤÎÇÛÎó
- * @param string $glue Ï¢·ëʸ»úÎó
- * @return string Ï¢·ë¸å¤Îʸ»úÎó
+ * @param array $array joinÂоݤÎÇÛÎó
+ * @param string $glue Ï¢·ëʸ»úÎó
+ * @return string Ï¢·ë¸å¤Îʸ»úÎó
*/
function smarty_modifier_join($array, $glue)
{
- if (is_array($array) == false) {
- return $array;
- }
- return implode($glue, $array);
+ if (is_array($array) == false) {
+ return $array;
+ }
+ return implode($glue, $array);
}
/**
- * smarty modifier:filter()
- *
- * »ØÄꤵ¤ì¤¿Ï¢ÁÛÇÛÎó¤Î¤¦¤Á$key¤Ç»ØÄꤵ¤ì¤¿Í×ÁǤΤߤòÇÛÎó¤ËºÆ¹½À®¤¹¤ë
- *
- * sample:
- * <code>
- * $smarty->assign("array", array(
- * array("foo" => 1, "bar" => 4),
- * array("foo" => 2, "bar" => 5),
- * array("foo" => 3, "bar" => 6),
- * ));
- *
- * {$array|@filter:"foo"|@join:","}
- * </code>
- * <code>
- * 1,2,3
- * </code>
- *
- * @param array $array filterÂоݤȤʤëÇÛÎó
- * @param string $key È´¤½Ð¤·¤ÆÇÛÎó¤ò¹½À®¤¹¤ëÏ¢ÁÛÇÛÎó¤Î¥¡¼
- * @return array ºÆ¹½À®¤µ¤ì¤¿ÇÛÎó
+ * smarty modifier:filter()
+ *
+ * »ØÄꤵ¤ì¤¿Ï¢ÁÛÇÛÎó¤Î¤¦¤Á$key¤Ç»ØÄꤵ¤ì¤¿Í×ÁǤΤߤòÇÛÎó¤ËºÆ¹½À®¤¹¤ë
+ *
+ * sample:
+ * <code>
+ * $smarty->assign("array", array(
+ * array("foo" => 1, "bar" => 4),
+ * array("foo" => 2, "bar" => 5),
+ * array("foo" => 3, "bar" => 6),
+ * ));
+ *
+ * {$array|@filter:"foo"|@join:","}
+ * </code>
+ * <code>
+ * 1,2,3
+ * </code>
+ *
+ * @param array $array filterÂоݤȤʤëÇÛÎó
+ * @param string $key È´¤½Ð¤·¤ÆÇÛÎó¤ò¹½À®¤¹¤ëÏ¢ÁÛÇÛÎó¤Î¥¡¼
+ * @return array ºÆ¹½À®¤µ¤ì¤¿ÇÛÎó
*/
function smarty_modifier_filter($array, $key)
{
- if (is_array($array) == false) {
- return $array;
- }
- $tmp = array();
- foreach ($array as $v) {
- if (isset($v[$key]) == false) {
- continue;
- }
- $tmp[] = $v[$key];
- }
- return $tmp;
+ if (is_array($array) == false) {
+ return $array;
+ }
+ $tmp = array();
+ foreach ($array as $v) {
+ if (isset($v[$key]) == false) {
+ continue;
+ }
+ $tmp[] = $v[$key];
+ }
+ return $tmp;
}
/**
- * smarty modifier:unique()
- *
- * unique()´Ø¿ô¤Îwrapper
- *
- * sample:
- * <code>
- * $smarty->assign("array1", array("a", "a", "b", "a", "b", "c"));
- * $smarty->assign("array2", array(
- * array("foo" => 1, "bar" => 4),
- * array("foo" => 1, "bar" => 4),
- * array("foo" => 1, "bar" => 4),
- * array("foo" => 2, "bar" => 5),
- * array("foo" => 3, "bar" => 6),
- * array("foo" => 2, "bar" => 5),
- * ));
- *
- * {$array1|@unique}
- * {$array2|@unique:"foo"}
- * </code>
- * <code>
- * abc
- * 123
- * </code>
- *
- * @param array $array ½èÍýÂоݤȤʤëÇÛÎó
- * @param key $key ½èÍýÂоݤȤʤ륡¼(null¤Ê¤éÇÛÎóÍ×ÁÇ)
- * @return array ºÆ¹½À®¤µ¤ì¤¿ÇÛÎó
+ * smarty modifier:unique()
+ *
+ * unique()´Ø¿ô¤Îwrapper
+ *
+ * sample:
+ * <code>
+ * $smarty->assign("array1", array("a", "a", "b", "a", "b", "c"));
+ * $smarty->assign("array2", array(
+ * array("foo" => 1, "bar" => 4),
+ * array("foo" => 1, "bar" => 4),
+ * array("foo" => 1, "bar" => 4),
+ * array("foo" => 2, "bar" => 5),
+ * array("foo" => 3, "bar" => 6),
+ * array("foo" => 2, "bar" => 5),
+ * ));
+ *
+ * {$array1|@unique}
+ * {$array2|@unique:"foo"}
+ * </code>
+ * <code>
+ * abc
+ * 123
+ * </code>
+ *
+ * @param array $array ½èÍýÂоݤȤʤëÇÛÎó
+ * @param key $key ½èÍýÂоݤȤʤ륡¼(null¤Ê¤éÇÛÎóÍ×ÁÇ)
+ * @return array ºÆ¹½À®¤µ¤ì¤¿ÇÛÎó
*/
function smarty_modifier_unique($array, $key = null)
{
- if (is_array($array) == false) {
- return $array;
- }
- if ($key != null) {
- $tmp = array();
- foreach ($array as $v) {
- if (isset($v[$key]) == false) {
- continue;
- }
- $tmp[$v[$key]] = $v;
- }
- return $tmp;
- } else {
- return array_unique($array);
- }
+ if (is_array($array) == false) {
+ return $array;
+ }
+ if ($key != null) {
+ $tmp = array();
+ foreach ($array as $v) {
+ if (isset($v[$key]) == false) {
+ continue;
+ }
+ $tmp[$v[$key]] = $v;
+ }
+ return $tmp;
+ } else {
+ return array_unique($array);
+ }
}
/**
- * smarty modifier:ʸ»úÎó¤Îwordwrap½èÍý
- *
- * [¸½ºßEUC-JPÂбþ¤ÏEUC-JP¤Î¤ßÂбþ]
- *
- * sample:
- * <code>
- * {"¤¢¤¤¤¦a¤¨a¤ªa¤«¤aaa¤¯¤±¤³"|wordrap_i18n:8}
- * </code>
- * <code>
- * ¤¢¤¤¤¦a
- * ¤¨a¤ªa¤«
- * ¤aaa¤¯
- * ¤±¤³
- * </code>
- *
- * @param string $string wordwrap¤¹¤ëʸ»úÎó
- * @param string $break ²þ¹Ôʸ»ú
- * @param int $width wordwrapÉý(Ⱦ³Ñ$widthʸ»ú¤Çwordwrap¤¹¤ë)
- * @param int $indent ¥¤¥ó¥Ç¥ó¥ÈÉý(Ⱦ³Ñ$indentʸ»ú)
- * @return string wordwrap½èÍý¤µ¤ì¤¿Ê¸»úÎó
+ * smarty modifier:ʸ»úÎó¤Îwordwrap½èÍý
+ *
+ * [¸½ºßEUC-JPÂбþ¤ÏEUC-JP¤Î¤ßÂбþ]
+ *
+ * sample:
+ * <code>
+ * {"¤¢¤¤¤¦a¤¨a¤ªa¤«¤aaa¤¯¤±¤³"|wordrap_i18n:8}
+ * </code>
+ * <code>
+ * ¤¢¤¤¤¦a
+ * ¤¨a¤ªa¤«
+ * ¤aaa¤¯
+ * ¤±¤³
+ * </code>
+ *
+ * @param string $string wordwrap¤¹¤ëʸ»úÎó
+ * @param string $break ²þ¹Ôʸ»ú
+ * @param int $width wordwrapÉý(Ⱦ³Ñ$widthʸ»ú¤Çwordwrap¤¹¤ë)
+ * @param int $indent ¥¤¥ó¥Ç¥ó¥ÈÉý(Ⱦ³Ñ$indentʸ»ú)
+ * @return string wordwrap½èÍý¤µ¤ì¤¿Ê¸»úÎó
*/
function smarty_modifier_wordwrap_i18n($string, $width, $break = "\n", $indent = 0)
{
- $r = "";
- $i = "$break" . str_repeat(" ", $indent);
- $tmp = $string;
- do {
- $n = strpos($tmp, $break);
- if ($n !== false && $n < $width) {
- $s = substr($tmp, 0, $n);
- $r .= $s . $i;
- $tmp = substr($tmp, strlen($s) + strlen($break));
- continue;
- }
-
- $s = mb_strimwidth($tmp, 0, $width, "", "EUC-JP");
-
- // EUC-JP¤Î¤ßÂбþ
- $n = strlen($s);
- if ($n >= $width && $tmp{$n} != "" && $tmp{$n} != " ") {
- while ((ord($s{$n-1}) & 0x80) == 0) {
- if ($s{$n-1} == " " || $n == 0) {
- break;
- }
- $n--;
- }
- }
- $s = substr($s, 0, $n);
-
- $r .= $s . $i;
- $tmp = substr($tmp, strlen($s));
- } while (strlen($s) > 0);
-
- $r = preg_replace('/\s+$/', '', $r);
-
- return $r;
+ $r = "";
+ $i = "$break" . str_repeat(" ", $indent);
+ $tmp = $string;
+ do {
+ $n = strpos($tmp, $break);
+ if ($n !== false && $n < $width) {
+ $s = substr($tmp, 0, $n);
+ $r .= $s . $i;
+ $tmp = substr($tmp, strlen($s) + strlen($break));
+ continue;
+ }
+
+ $s = mb_strimwidth($tmp, 0, $width, "", "EUC-JP");
+
+ // EUC-JP¤Î¤ßÂбþ
+ $n = strlen($s);
+ if ($n >= $width && $tmp{$n} != "" && $tmp{$n} != " ") {
+ while ((ord($s{$n-1}) & 0x80) == 0) {
+ if ($s{$n-1} == " " || $n == 0) {
+ break;
+ }
+ $n--;
+ }
+ }
+ $s = substr($s, 0, $n);
+
+ $r .= $s . $i;
+ $tmp = substr($tmp, strlen($s));
+ } while (strlen($s) > 0);
+
+ $r = preg_replace('/\s+$/', '', $r);
+
+ return $r;
}
/**
- * smarty modifier:ʸ»úÎóÀÚ¤êµÍ¤á½èÍý(i18nÂбþ)
- *
- * sample:
- * <code>
- * {"ÆüËܸì¤Ç¤¹"|truncate_i18n:5:"..."}
- * </code>
- * <code>
- * ÆüËÜ...
- * </code>
- *
- * @param int $len ºÇÂçʸ»úÉý
- * @param string $postfix ËöÈø¤ËÉղ乤ëʸ»úÎó
+ * smarty modifier:ʸ»úÎóÀÚ¤êµÍ¤á½èÍý(i18nÂбþ)
+ *
+ * sample:
+ * <code>
+ * {"ÆüËܸì¤Ç¤¹"|truncate_i18n:5:"..."}
+ * </code>
+ * <code>
+ * ÆüËÜ...
+ * </code>
+ *
+ * @param int $len ºÇÂçʸ»úÉý
+ * @param string $postfix ËöÈø¤ËÉղ乤ëʸ»úÎó
*/
function smarty_modifier_truncate_i18n($string, $len = 80, $postfix = "...")
{
- return mb_strimwidth($string, 0, $len, $postfix);
+ return mb_strimwidth($string, 0, $len, $postfix);
}
/**
- * smarty modifier:i18n¥Õ¥£¥ë¥¿
- *
- * sample:
- * <code>
- * {"english"|i18n}
- * </code>
- * <code>
- * ±Ñ¸ì
- * </code>
- *
- * @param string $string i18n½èÍýÂоݤÎʸ»úÎó
- * @return string ¥í¥±¡¼¥ë¤ËÂбþ¤·¤¿¥á¥Ã¥»¡¼¥¸
+ * smarty modifier:i18n¥Õ¥£¥ë¥¿
+ *
+ * sample:
+ * <code>
+ * {"english"|i18n}
+ * </code>
+ * <code>
+ * ±Ñ¸ì
+ * </code>
+ *
+ * @param string $string i18n½èÍýÂоݤÎʸ»úÎó
+ * @return string ¥í¥±¡¼¥ë¤ËÂбþ¤·¤¿¥á¥Ã¥»¡¼¥¸
*/
function smarty_modifier_i18n($string)
{
- $c =& Ethna_Controller::getInstance();
+ $c =& Ethna_Controller::getInstance();
- $i18n =& $c->getI18N();
+ $i18n =& $c->getI18N();
- return $i18n->get($string);
+ return $i18n->get($string);
}
/**
- * smarty modifier:¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹ÍÑ¥Õ¥£¥ë¥¿
- *
- * sample:
- * <code>
- * <input type="checkbox" name="test" {""|checkbox}>
- * <input type="checkbox" name="test" {"1"|checkbox}>
- * </code>
- * <code>
- * <input type="checkbox" name="test">
- * <input type="checkbox" name="test" checkbox>
- * </code>
- *
- * @param string $string ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
- * @return string $string¤¬¶õʸ»úÎ󤢤뤤¤Ï0°Ê³°¤Î¾ì¹ç¤Ï"checked"
+ * smarty modifier:¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹ÍÑ¥Õ¥£¥ë¥¿
+ *
+ * sample:
+ * <code>
+ * <input type="checkbox" name="test" {""|checkbox}>
+ * <input type="checkbox" name="test" {"1"|checkbox}>
+ * </code>
+ * <code>
+ * <input type="checkbox" name="test">
+ * <input type="checkbox" name="test" checkbox>
+ * </code>
+ *
+ * @param string $string ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
+ * @return string $string¤¬¶õʸ»úÎ󤢤뤤¤Ï0°Ê³°¤Î¾ì¹ç¤Ï"checked"
*/
function smarty_modifier_checkbox($string)
{
- if ($string != "" && $string != 0) {
- return "checked";
- }
+ if ($string != "" && $string != 0) {
+ return "checked";
+ }
}
/**
- * smarty modifier:¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ¥Õ¥£¥ë¥¿
- *
- * ñ½ã¤Ê¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤Î¾ì¹ç¤Ïsmarty´Ø¿ô"select"¤òÍøÍѤ¹¤ë¤³¤È¤Ç
- * ¥¿¥°¤ò¾Êά²Äǽ
- *
- * sample:
- * <code>
- * $smarty->assign("form", 1);
- *
- * <option value="1" {$form|select:"1"}>foo</option>
- * <option value="2" {$form|select:"2"}>bar</option>
- * </code>
- * <code>
- * <option value="1" selected>foo</option>
- * <option value="2" >bar</option>
- * </code>
- *
- * @param string $string ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
- * @param string $value <option>¥¿¥°¤Ë»ØÄꤵ¤ì¤Æ¤¤¤ëÃÍ
- * @return string $string¤¬$value¤Ë¥Þ¥Ã¥Á¤¹¤ë¾ì¹ç¤Ï"selected"
+ * smarty modifier:¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ¥Õ¥£¥ë¥¿
+ *
+ * ñ½ã¤Ê¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤Î¾ì¹ç¤Ïsmarty´Ø¿ô"select"¤òÍøÍѤ¹¤ë¤³¤È¤Ç
+ * ¥¿¥°¤ò¾Êά²Äǽ
+ *
+ * sample:
+ * <code>
+ * $smarty->assign("form", 1);
+ *
+ * <option value="1" {$form|select:"1"}>foo</option>
+ * <option value="2" {$form|select:"2"}>bar</option>
+ * </code>
+ * <code>
+ * <option value="1" selected>foo</option>
+ * <option value="2" >bar</option>
+ * </code>
+ *
+ * @param string $string ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
+ * @param string $value <option>¥¿¥°¤Ë»ØÄꤵ¤ì¤Æ¤¤¤ëÃÍ
+ * @return string $string¤¬$value¤Ë¥Þ¥Ã¥Á¤¹¤ë¾ì¹ç¤Ï"selected"
*/
function smarty_modifier_select($string, $value)
{
- if ($string == $value) {
- print 'selected="true"';
- }
+ if ($string == $value) {
+ print 'selected="true"';
+ }
}
/**
- * smarty modifier:¥Õ¥©¡¼¥àÃͽÐÎÏ¥Õ¥£¥ë¥¿
- *
- * ¥Õ¥©¡¼¥à̾¤òÊÑ¿ô¤Ç»ØÄꤷ¤Æ¥Õ¥©¡¼¥àÃͤò¼èÆÀ¤·¤¿¤¤¾ì¹ç¤Ë»ÈÍѤ¹¤ë
- *
- * sample:
- * <code>
- * $this->af->set('foo', 'bar);
- * $smarty->assign('key', 'foo');
- * {$key|form_value}
- * </code>
- * <code>
- * bar
- * </code>
- *
- * @param string $string ¥Õ¥©¡¼¥à¹àÌÜ̾
- * @return string ¥Õ¥©¡¼¥àÃÍ
+ * smarty modifier:¥Õ¥©¡¼¥àÃͽÐÎÏ¥Õ¥£¥ë¥¿
+ *
+ * ¥Õ¥©¡¼¥à̾¤òÊÑ¿ô¤Ç»ØÄꤷ¤Æ¥Õ¥©¡¼¥àÃͤò¼èÆÀ¤·¤¿¤¤¾ì¹ç¤Ë»ÈÍѤ¹¤ë
+ *
+ * sample:
+ * <code>
+ * $this->af->set('foo', 'bar);
+ * $smarty->assign('key', 'foo');
+ * {$key|form_value}
+ * </code>
+ * <code>
+ * bar
+ * </code>
+ *
+ * @param string $string ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @return string ¥Õ¥©¡¼¥àÃÍ
*/
function smarty_modifier_form_value($string)
{
- $c =& Ethna_Controller::getInstance();
- $af =& $c->getActionForm();
+ $c =& Ethna_Controller::getInstance();
+ $af =& $c->getActionForm();
- $elts = explode(".", $string);
- $r = $af->get($elts[0]);
- for ($i = 1; $i < count($elts); $i++) {
- $r = $r[$elts[$i]];
- }
+ $elts = explode(".", $string);
+ $r = $af->get($elts[0]);
+ for ($i = 1; $i < count($elts); $i++) {
+ $r = $r[$elts[$i]];
+ }
- return htmlspecialchars($r, ENT_QUOTES);
+ return htmlspecialchars($r, ENT_QUOTES);
}
/**
- * smarty function:»ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤǥ¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
+ * smarty function:»ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤǥ¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
*
- * sample:
- * <code>
+ * sample:
+ * <code>
* {if is_error('name')}
* ¥¨¥é¡¼
* {/if}
- * </code>
+ * </code>
*
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
*/
function smarty_function_is_error($params, &$smarty)
{
- $c =& Ethna_Controller::getInstance();
+ $c =& Ethna_Controller::getInstance();
- extract($params);
+ extract($params);
- $action_error =& $c->getActionError();
+ $action_error =& $c->getActionError();
- return $action_error->isError($name);
+ return $action_error->isError($name);
}
/**
- * smarty function:»ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤËÂбþ¤¹¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ¹¤ë
+ * smarty function:»ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤËÂбþ¤¹¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ¹¤ë
*
- * sample:
- * <code>
- * <input type="text" name="foo">{message name="foo"}
- * </code>
- * <code>
- * <input type="text" name="foo">foo¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤
- * </code>
+ * sample:
+ * <code>
+ * <input type="text" name="foo">{message name="foo"}
+ * </code>
+ * <code>
+ * <input type="text" name="foo">foo¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤
+ * </code>
*
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
*/
function smarty_function_message($params, &$smarty)
{
- $c =& Ethna_Controller::getInstance();
+ $c =& Ethna_Controller::getInstance();
- extract($params);
+ extract($params);
- $action_error =& $c->getActionError();
+ $action_error =& $c->getActionError();
- print htmlspecialchars($action_error->getMessage($name));
+ print htmlspecialchars($action_error->getMessage($name));
}
/**
- * smarty function:¥æ¥Ë¡¼¥¯ID¤òÀ¸À®¤¹¤ë(double post¥Á¥§¥Ã¥¯ÍÑ)
- *
- * sample:
- * <code>
- * {uniqid}
- * </code>
- * <code>
- * <input type="hidden" name="uniqid" value="a0f24f75e...e48864d3e">
- * </code>
- *
- * @param string $type ɽ¼¨¥¿¥¤¥×("get" or "post"¡Ý¥Ç¥Õ¥©¥ë¥È="post")
- * @see isDuplicatePost
+ * smarty function:¥æ¥Ë¡¼¥¯ID¤òÀ¸À®¤¹¤ë(double post¥Á¥§¥Ã¥¯ÍÑ)
+ *
+ * sample:
+ * <code>
+ * {uniqid}
+ * </code>
+ * <code>
+ * <input type="hidden" name="uniqid" value="a0f24f75e...e48864d3e">
+ * </code>
+ *
+ * @param string $type ɽ¼¨¥¿¥¤¥×("get" or "post"¡Ý¥Ç¥Õ¥©¥ë¥È="post")
+ * @see isDuplicatePost
*/
function smarty_function_uniqid($params, &$smarty)
{
- extract($params);
-
- $uniqid = Ethna_Util::getRandom();
- if (isset($type) && $type == 'get') {
- print "uniqid=$uniqid";
- } else {
- print "<input type=\"hidden\" name=\"uniqid\" value=\"$uniqid\" />\n";
- }
+ extract($params);
+
+ $uniqid = Ethna_Util::getRandom();
+ if (isset($type) && $type == 'get') {
+ print "uniqid=$uniqid";
+ } else {
+ print "<input type=\"hidden\" name=\"uniqid\" value=\"$uniqid\" />\n";
+ }
}
/**
- * smarty function:¥»¥ì¥¯¥È¥Õ¥£¡¼¥ë¥ÉÀ¸À®
+ * smarty function:¥»¥ì¥¯¥È¥Õ¥£¡¼¥ë¥ÉÀ¸À®
*
- * @param array $list ÁªÂò»è°ìÍ÷
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
- * @param string $value ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
- * @param string $empty ¶õ¥¨¥ó¥È¥ê(¡Ö---ÁªÂò¤·¤Æ²¼¤µ¤¤---¡×Åù)
+ * @param array $list ÁªÂò»è°ìÍ÷
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @param string $value ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
+ * @param string $empty ¶õ¥¨¥ó¥È¥ê(¡Ö---ÁªÂò¤·¤Æ²¼¤µ¤¤---¡×Åù)
*/
function smarty_function_select($params, &$smarty)
{
- extract($params);
-
- print "<select name=\"$name\">\n";
- if ($empty) {
- printf("<option value=\"\">%s</option>\n", $empty);
- }
- foreach ($list as $id => $elt) {
- printf("<option value=\"%s\" %s>%s</option>\n", $id, $id == $value ? 'selected="true"' : '', $elt['name']);
- }
- print "</select>\n";
+ extract($params);
+
+ print "<select name=\"$name\">\n";
+ if ($empty) {
+ printf("<option value=\"\">%s</option>\n", $empty);
+ }
+ foreach ($list as $id => $elt) {
+ printf("<option value=\"%s\" %s>%s</option>\n", $id, $id == $value ? 'selected="true"' : '', $elt['name']);
+ }
+ print "</select>\n";
}
/**
- * smarty function:¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¥Õ¥£¥ë¥¿´Ø¿ô(ÇÛÎóÂбþ)
+ * smarty function:¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¥Õ¥£¥ë¥¿´Ø¿ô(ÇÛÎóÂбþ)
*
- * @param string $form ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
- * @param string $key ɾ²ÁÂоݤÎÇÛÎ󥤥ó¥Ç¥Ã¥¯¥¹
- * @param string $value ɾ²ÁÃÍ
+ * @param string $form ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ËÅϤµ¤ì¤¿¥Õ¥©¡¼¥àÃÍ
+ * @param string $key ɾ²ÁÂоݤÎÇÛÎ󥤥ó¥Ç¥Ã¥¯¥¹
+ * @param string $value ɾ²ÁÃÍ
*/
function smarty_function_checkbox_list($params, &$smarty)
{
- extract($params);
-
- if (isset($key) == false) {
- $key = null;
- }
- if (isset($value) == false) {
- $value = null;
- }
- if (isset($checked) == false) {
- $checked = "checked";
- }
-
- if (is_null($key) == false) {
- if (isset($form[$key])) {
- if (is_null($value)) {
- print $checked;
- } else {
- if (strcmp($form[$key], $value) == 0) {
- print $checked;
- }
- }
- }
- } else if (is_null($value) == false) {
- if (is_array($form)) {
- if (in_array($value, $form)) {
- print $checked;
- }
- } else {
- if (strcmp($value, $form) == 0) {
- print $checked;
- }
- }
- }
+ extract($params);
+
+ if (isset($key) == false) {
+ $key = null;
+ }
+ if (isset($value) == false) {
+ $value = null;
+ }
+ if (isset($checked) == false) {
+ $checked = "checked";
+ }
+
+ if (is_null($key) == false) {
+ if (isset($form[$key])) {
+ if (is_null($value)) {
+ print $checked;
+ } else {
+ if (strcmp($form[$key], $value) == 0) {
+ print $checked;
+ }
+ }
+ }
+ } else if (is_null($value) == false) {
+ if (is_array($form)) {
+ if (in_array($value, $form)) {
+ print $checked;
+ }
+ } else {
+ if (strcmp($value, $form) == 0) {
+ print $checked;
+ }
+ }
+ }
}
/**
- * smarty function:¥Õ¥©¡¼¥àɽ¼¨Ì¾À¸À®
+ * smarty function:¥Õ¥©¡¼¥àɽ¼¨Ì¾À¸À®
*
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
*/
function smarty_function_form_name($params, &$smarty)
{
$name = $params['name'];
unset($params['name']);
- $c =& Ethna_Controller::getInstance();
+ $c =& Ethna_Controller::getInstance();
$view =& $c->getView();
if ($view === null) {
return null;
}
/**
- * smarty function:¥Õ¥©¡¼¥à¥¿¥°À¸À®
+ * smarty function:¥Õ¥©¡¼¥à¥¿¥°À¸À®
*
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
*/
function smarty_function_form_input($params, &$smarty)
{
$name = $params['name'];
unset($params['name']);
- $c =& Ethna_Controller::getInstance();
+ $c =& Ethna_Controller::getInstance();
$view =& $c->getView();
if ($view === null) {
return null;
}
/**
- * smarty block:¥Õ¥©¡¼¥à¥¿¥°½ÐÎϥץ饰¥¤¥ó
+ * smarty block:¥Õ¥©¡¼¥à¥¿¥°½ÐÎϥץ饰¥¤¥ó
*/
function smarty_block_form($params, $content, &$smarty, &$repeat)
{
- extract($params);
+ extract($params);
$s = "";
if ($repeat) {
<?php
// vim: foldmethod=marker
/**
- * Ethna_Util.php
+ * Ethna_Util.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ to_array
/**
- * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: ¥¹¥«¥é¡¼ÃͤòÍ×ÁÇ¿ô1¤ÎÇÛÎó¤È¤·¤ÆÊÖ¤¹
+ * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: ¥¹¥«¥é¡¼ÃͤòÍ×ÁÇ¿ô1¤ÎÇÛÎó¤È¤·¤ÆÊÖ¤¹
*
- * @param mixed $v ÇÛÎó¤È¤·¤Æ°·¤¦ÃÍ
- * @return array ÇÛÎó¤ËÊÑ´¹¤µ¤ì¤¿ÃÍ
+ * @param mixed $v ÇÛÎó¤È¤·¤Æ°·¤¦ÃÍ
+ * @return array ÇÛÎó¤ËÊÑ´¹¤µ¤ì¤¿ÃÍ
*/
function to_array($v)
{
- if (is_array($v)) {
- return $v;
- } else {
- return array($v);
- }
+ if (is_array($v)) {
+ return $v;
+ } else {
+ return array($v);
+ }
}
// }}}
// {{{ is_error
/**
- * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: »ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤ˥¨¥é¡¼¤¬¤¢¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
+ * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: »ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¹àÌܤ˥¨¥é¡¼¤¬¤¢¤ë¤«¤É¤¦¤«¤òÊÖ¤¹
*
- * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
- * @return bool true:¥¨¥é¡¼Í¤ê false:¥¨¥é¡¼Ìµ¤·
+ * @param string $name ¥Õ¥©¡¼¥à¹àÌÜ̾
+ * @return bool true:¥¨¥é¡¼Í¤ê false:¥¨¥é¡¼Ìµ¤·
*/
function is_error($name)
{
- $c =& Ethna_Controller::getInstance();
+ $c =& Ethna_Controller::getInstance();
- $action_error =& $c->getActionError();
+ $action_error =& $c->getActionError();
- return $action_error->isError($name);
+ return $action_error->isError($name);
}
// }}}
// {{{ file_exists_ex
/**
- * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: include_path¤ò¸¡º÷¤·¤Ä¤Äfile_exists()¤¹¤ë
+ * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: include_path¤ò¸¡º÷¤·¤Ä¤Äfile_exists()¤¹¤ë
*
- * @param string $path ¥Õ¥¡¥¤¥ë̾
- * @param bool $use_include_path include_path¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤«¤É¤¦¤«
- * @return bool true:ͤê false:̵¤·
+ * @param string $path ¥Õ¥¡¥¤¥ë̾
+ * @param bool $use_include_path include_path¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤«¤É¤¦¤«
+ * @return bool true:ͤê false:̵¤·
*/
function file_exists_ex($path, $use_include_path = true)
{
// {{{ is_absolute_path
/**
- * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: ÀäÂХѥ¹¤«¤É¤¦¤«¤òÊÖ¤¹
+ * ¥°¥í¡¼¥Ð¥ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô: ÀäÂХѥ¹¤«¤É¤¦¤«¤òÊÖ¤¹
*
- * @param string $path ¥Õ¥¡¥¤¥ë̾
- * @return bool true:ÀäÂÐ false:ÁêÂÐ
+ * @param string $path ¥Õ¥¡¥¤¥ë̾
+ * @return bool true:ÀäÂÐ false:ÁêÂÐ
*/
function is_absolute_path($path)
{
// {{{ Ethna_Util
/**
- * ¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥¯¥é¥¹
+ * ¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Util
{
- /**
- * POST¤Î¥æ¥Ë¡¼¥¯¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
- *
- * @access public
- * @return bool true:2²óÌܰʹߤÎPOST false:1²óÌܤÎPOST
- */
- function isDuplicatePost()
- {
- $c =& Ethna_Controller::getInstance();
-
- // use raw post data
- if (isset($_POST['uniqid'])) {
- $uniqid = $_POST['uniqid'];
- } else if (isset($_GET['uniqid'])) {
- $uniqid = $_GET['uniqid'];
- } else {
- return false;
- }
-
- // purge old files
- Ethna_Util::purgeTmp("uniqid_", 60*60*1);
-
- $filename = sprintf("%s/uniqid_%s_%s", $c->getDirectory('tmp'), $_SERVER['REMOTE_ADDR'], $uniqid);
- if (file_exists($filename) == false) {
- touch($filename);
- return false;
- }
-
- $st = stat($filename);
- if ($st[9] + 60*60*1 < time()) {
- // too old
- return false;
- }
-
- return true;
- }
-
- /**
- * POST¤Î¥æ¥Ë¡¼¥¯¥Á¥§¥Ã¥¯¥Õ¥é¥°¤ò¥¯¥ê¥¢¤¹¤ë
- *
- * @access public
- * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
- */
- function clearDuplicatePost()
- {
- $c =& Ethna_Controller::getInstance();
-
- // use raw post data
- if (isset($_POST['uniqid'])) {
- $uniqid = $_POST['uniqid'];
- } else {
- return 0;
- }
-
- $filename = sprintf("%s/uniqid_%s_%s", $c->getDirectory('tmp'), $_SERVER['REMOTE_ADDR'], $uniqid);
- if (file_exists($filename)) {
- if (unlink($filename) == false) {
- return Ethna::raiseWarning(E_APP_WRITE, $filename);
- }
- }
-
- return 0;
- }
-
- /**
- * ¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬Àµ¤·¤¤¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë
- *
- * @access public
- * @param string $mailaddress ¥Á¥§¥Ã¥¯¤¹¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹
- * @return bool true: Àµ¤·¤¤¥á¡¼¥ë¥¢¥É¥ì¥¹ false: ÉÔÀµ¤Ê·Á¼°
- */
- function checkMailAddress($mailaddress)
- {
- if (preg_match('/^([a-z0-9_]|\-|\.|\+)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,6}$/i', $mailaddress)) {
- return true;
- }
- return false;
- }
-
- /**
- * CSV·Á¼°¤Îʸ»úÎó¤òÇÛÎó¤Ëʬ³ä¤¹¤ë
- *
- * @access public
- * @param string $csv CSV·Á¼°¤Îʸ»úÎó(1¹Ôʬ)
- * @param string $delimiter ¥Õ¥£¡¼¥ë¥É¤Î¶èÀÚ¤êʸ»ú
- * @return mixed (array):ʬ³ä·ë²Ì Ethna_Error:¥¨¥é¡¼(¹Ô·Ñ³)
- */
- function explodeCSV($csv, $delimiter = ",")
- {
- $space_list = '';
- foreach (array(" ", "\t", "\r", "\n") as $c) {
- if ($c != $delimiter) {
- $space_list .= $c;
- }
- }
-
- $line_end = "";
- if (preg_match("/([$space_list]+)\$/sS", $csv, $match)) {
- $line_end = $match[1];
- }
- $csv = substr($csv, 0, strlen($csv)-strlen($line_end));
- $csv .= ' ';
-
- $field = '';
- $retval = array();
-
- $index = 0;
- $csv_len = strlen($csv);
- do {
- // 1. skip leading spaces
- if (preg_match("/^([$space_list]+)/sS", substr($csv, $index), $match)) {
- $index += strlen($match[1]);
- }
- if ($index >= $csv_len) {
- break;
- }
-
- // 2. read field
- if ($csv{$index} == '"') {
- // 2A. handle quote delimited field
- $index++;
- while ($index < $csv_len) {
- if ($csv{$index} == '"') {
- // handle double quote
- if ($csv{$index+1} == '"') {
- $field .= $csv{$index};
- $index += 2;
- } else {
- // must be end of string
- while ($csv{$index} != $delimiter && $index < $csv_len) {
- $index++;
- }
- if ($csv{$index} == $delimiter) {
- $index++;
- }
- break;
- }
- } else {
- // normal character
- if (preg_match("/^([^\"]*)/S", substr($csv, $index), $match)) {
- $field .= $match[1];
- $index += strlen($match[1]);
- }
-
- if ($index == $csv_len) {
- $field = substr($field, 0, strlen($field)-1);
- $field .= $line_end;
-
- // request one more line
- return Ethna::raiseNotice(E_UTIL_CSV_CONTINUE);
- }
- }
- }
- } else {
- // 2B. handle non-quoted field
- if (preg_match("/^([^$delimiter]*)/S", substr($csv, $index), $match)) {
- $field .= $match[1];
- $index += strlen($match[1]);
- }
-
- // remove trailing spaces
- $field = preg_replace("/[$space_list]+\$/S", '', $field);
- if ($csv{$index} == $delimiter) {
- $index++;
- }
- }
- $retval[] = $field;
- $field = '';
- } while ($index < $csv_len);
-
- return $retval;
- }
-
- /**
- * CSV¥¨¥¹¥±¡¼¥×½èÍý¤ò¹Ô¤¦
- *
- * @access public
- * @param string $csv ¥¨¥¹¥±¡¼¥×ÂоݤÎʸ»úÎó(CSV¤Î³ÆÍ×ÁÇ)
- * @param bool $escape_nl ²þ¹Ôʸ»ú(\r/\n)¤Î¥¨¥¹¥±¡¼¥×¥Õ¥é¥°
- * @return string CSV¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿Ê¸»úÎó
- */
- function escapeCSV($csv, $escape_nl = false)
- {
- if (preg_match('/[,"\r\n]/', $csv)) {
- if ($escape_nl) {
- $csv = preg_replace('/\r/', "\\r", $csv);
- $csv = preg_replace('/\n/', "\\n", $csv);
- }
- $csv = preg_replace('/"/', "\"\"", $csv);
- $csv = "\"$csv\"";
- }
-
- return $csv;
- }
-
- /**
- * ÇÛÎó¤ÎÍ×ÁǤòÁ´¤ÆHTML¥¨¥¹¥±¡¼¥×¤·¤ÆÊÖ¤¹
- *
- * @access public
- * @param array $target HTML¥¨¥¹¥±¡¼¥×ÂоݤȤʤëÇÛÎó
- * @return array ¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿ÇÛÎó
- */
- function escapeHtml($target)
- {
- $r = array();
- Ethna_Util::_escapeHtml($target, $r);
- return $r;
- }
-
- /**
- * ÇÛÎó¤ÎÍ×ÁǤòÁ´¤ÆHTML¥¨¥¹¥±¡¼¥×¤·¤ÆÊÖ¤¹
- *
- * @access public
- * @param mixed $vars HTML¥¨¥¹¥±¡¼¥×ÂоݤȤʤëÇÛÎó
- * @param mixed $retval HTML¥¨¥¹¥±¡¼¥×ÂоݤȤʤë»ÒÍ×ÁÇ
- */
- function _escapeHtml(&$vars, &$retval)
- {
- foreach (array_keys($vars) as $name) {
- if (is_array($vars[$name])) {
- $retval[$name] = array();
- Ethna_Util::_escapeHtml($vars[$name], $retval[$name]);
- } else if (!is_object($vars[$name])) {
- $retval[$name] = htmlspecialchars($vars[$name], ENT_QUOTES);
- }
- }
- }
-
- /**
- * ʸ»úÎó¤òMIME¥¨¥ó¥³¡¼¥É¤¹¤ë
- *
- * @access public
- * @param string $string MIME¥¨¥ó¥³¡¼¥É¤¹¤ëʸ»úÎó
- * @return ¥¨¥ó¥³¡¼¥ÉºÑ¤ß¤Îʸ»úÎó
- */
- function encode_MIME($string)
- {
- $pos = 0;
- $split = 36;
- $_string = "";
- while ($pos < mb_strlen($string))
- {
- $tmp = mb_strimwidth($string, $pos, $split, "");
- $pos += mb_strlen($tmp);
- $_string .= (($_string)? ' ' : '') . mb_encode_mimeheader($tmp, 'ISO-2022-JP');
- }
- return $_string;
- }
-
- /**
- * GoogleÉ÷¥ê¥ó¥¯¥ê¥¹¥È¤òÊÖ¤¹
- *
- * @access public
- * @param int $total ¸¡º÷Áí·ï¿ô
- * @param int $offset ɽ¼¨¥ª¥Õ¥»¥Ã¥È
- * @param int $count ɽ¼¨·ï¿ô
- * @return array ¥ê¥ó¥¯¾ðÊó¤ò³ÊǼ¤·¤¿ÇÛÎó
- */
- function getDirectLinkList($total, $offset, $count)
- {
- $direct_link_list = array();
-
- if ($total == 0) {
- return array();
- }
-
- // backwards
- $current = $offset - $count;
- while ($current > 0) {
- array_unshift($direct_link_list, $current);
- $current -= $count;
- }
- if ($offset != 0 && $current <= 0) {
- array_unshift($direct_link_list, 0);
- }
-
- // current
- $backward_count = count($direct_link_list);
- array_push($direct_link_list, $offset);
-
- // forwards
- $current = $offset + $count;
- for ($i = 0; $i < 10; $i++) {
- if ($current >= $total) {
- break;
- }
- array_push($direct_link_list, $current);
- $current += $count;
- }
- $forward_count = count($direct_link_list) - $backward_count - 1;
-
- $backward_count -= 4;
- if ($forward_count < 5) {
- $backward_count -= 5 - $forward_count;
- }
- if ($backward_count < 0) {
- $backward_count = 0;
- }
-
- // add index
- $n = 1;
- $r = array();
- foreach ($direct_link_list as $direct_link) {
- $v = array('offset' => $direct_link, 'index' => $n);
- $r[] = $v;
- $n++;
- }
-
- return array_splice($r, $backward_count, 10);
- }
-
- /**
- * ¸µ¹æÀ©¤Ç¤Îǯ¤òÊÖ¤¹
- *
- * @access public
- * @param int $t unix time
- * @return string ¸µ¹æ(ÉÔÌÀ¤Ê¾ì¹ç¤Ïnull)
- */
- function getEra($t)
- {
- $tm = localtime($t, true);
- $year = $tm['tm_year'] + 1900;
-
- if ($year >= 1989) {
- return array('Ê¿À®', $year - 1988);
- } else if ($year >= 1926) {
- return array('¾¼ÏÂ', $year - 1925);
- }
-
- return null;
- }
-
- /**
- * getimagesize()¤ÎÊÖ¤¹¥¤¥á¡¼¥¸¥¿¥¤¥×¤ËÂбþ¤¹¤ë³ÈÄ¥»Ò¤òÊÖ¤¹
- *
- * @access public
- * @param int $type getimagesize()´Ø¿ô¤ÎÊÖ¤¹¥¤¥á¡¼¥¸¥¿¥¤¥×
- * @return string $type¤ËÂбþ¤¹¤ë³ÈÄ¥»Ò
- */
- function getImageExtName($type)
- {
- $ext_list = array(
- 1 => 'gif',
- 2 => 'jpg',
- 3 => 'png',
- 4 => 'swf',
- 5 => 'psd',
- 6 => 'bmp',
- 7 => 'tiff',
- 8 => 'tiff',
- 9 => 'jpc',
- 10 => 'jp2',
- 11 => 'jpx',
- 12 => 'jb2',
- 13 => 'swc',
- 14 => 'iff',
- 15 => 'wbmp',
- 16 => 'xbm',
- );
-
- return @$ext_list[$type];
- }
-
- /**
- * ¥é¥ó¥À¥à¤Ê¥Ï¥Ã¥·¥åÃͤòÀ¸À®¤¹¤ë
- *
- * ·è¤·¤Æ¹â®¤Ç¤Ï¤Ê¤¤¤Î¤ÇÍðÍѤÏÈò¤±¤ë¤³¤È
- *
- * @access public
- * @param int $length ¥Ï¥Ã¥·¥åÃͤÎŤµ(¡Á64)
- * @return string ¥Ï¥Ã¥·¥åÃÍ
- */
- function getRandom($length = 64)
- {
- static $srand = false;
-
- if ($srand == false) {
- list($usec, $sec) = explode(' ', microtime());
- mt_srand((float) $sec + ((float) $usec * 100000) + getmypid());
- $srand = true;
- }
-
- $value = "";
- for ($i = 0; $i < 2; $i++) {
- // for Linux
- if (file_exists('/proc/net/dev')) {
- $rx = $tx = 0;
- $fp = fopen('/proc/net/dev', 'r');
- if ($fp != null) {
- $header = true;
- while (feof($fp) === false) {
- $s = fgets($fp, 4096);
- if ($header) {
- $header = false;
- continue;
- }
- $v = preg_split('/[:\s]+/', $s);
- if (is_array($v) && count($v) > 10) {
- $rx += $v[2];
- $tx += $v[10];
- }
- }
- }
- $platform_value = $rx . $tx . mt_rand() . getmypid();
- } else {
- $platform_value = mt_rand() . getmypid();
- }
- $now = strftime('%Y%m%d %T');
- $time = gettimeofday();
- $v = $now . $time['usec'] . $platform_value . mt_rand(0, time());
- $value .= md5($v);
- }
-
- if ($length < 64) {
- $value = substr($value, 0, $length);
- }
- return $value;
- }
-
- /**
- * 1¼¡¸µÇÛÎó¤òm x n¤ËºÆ¹½À®¤¹¤ë
- *
- * @access public
- * @param array $array ½èÍýÂоݤÎ1¼¡¸µÇÛÎó
- * @param int $m ¼´¤ÎÍ×ÁÇ¿ô
- * @param int $order $m¤òX¼´¤È¸«Ðö¤¹¤«Y¼´¤È¸«Ðö¤¹¤«(0:X¼´ 1:Y¼´)
- * @return array m x n¤ËºÆ¹½À®¤µ¤ì¤¿ÇÛÎó
- */
- function get2dArray($array, $m, $order)
- {
- $r = array();
-
- $n = intval(count($array) / $m);
- if ((count($array) % $m) > 0) {
- $n++;
- }
- for ($i = 0; $i < $n; $i++) {
- $elts = array();
- for ($j = 0; $j < $m; $j++) {
- if ($order == 0) {
- // ²£Ê¤Ó(²£¡§$mÎó ½Ä¡§ÌµÀ©¸Â)
- $key = $i*$m+$j;
- } else {
- // ½ÄʤÓ(²£¡§ÌµÀ©¸Â ½Ä¡§$m¹Ô)
- $key = $i+$n*$j;
- }
- if (array_key_exists($key, $array) == false) {
- $array[$key] = null;
- }
- $elts[] = $array[$key];
- }
- $r[] = $elts;
- }
-
- return $r;
- }
-
- /**
- * ¥Ñ¥¹Ì¾¤¬ÀäÂХѥ¹¤«¤É¤¦¤«¤òÊÖ¤¹
- *
- * port from File in PEAR (for BC)
- *
- * @access public
- * @param string $path
- * @return bool true:ÀäÂХѥ¹ false:ÁêÂХѥ¹
- */
- function isAbsolute($path)
- {
+ /**
+ * POST¤Î¥æ¥Ë¡¼¥¯¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
+ *
+ * @access public
+ * @return bool true:2²óÌܰʹߤÎPOST false:1²óÌܤÎPOST
+ */
+ function isDuplicatePost()
+ {
+ $c =& Ethna_Controller::getInstance();
+
+ // use raw post data
+ if (isset($_POST['uniqid'])) {
+ $uniqid = $_POST['uniqid'];
+ } else if (isset($_GET['uniqid'])) {
+ $uniqid = $_GET['uniqid'];
+ } else {
+ return false;
+ }
+
+ // purge old files
+ Ethna_Util::purgeTmp("uniqid_", 60*60*1);
+
+ $filename = sprintf("%s/uniqid_%s_%s", $c->getDirectory('tmp'), $_SERVER['REMOTE_ADDR'], $uniqid);
+ if (file_exists($filename) == false) {
+ touch($filename);
+ return false;
+ }
+
+ $st = stat($filename);
+ if ($st[9] + 60*60*1 < time()) {
+ // too old
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * POST¤Î¥æ¥Ë¡¼¥¯¥Á¥§¥Ã¥¯¥Õ¥é¥°¤ò¥¯¥ê¥¢¤¹¤ë
+ *
+ * @access public
+ * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+ */
+ function clearDuplicatePost()
+ {
+ $c =& Ethna_Controller::getInstance();
+
+ // use raw post data
+ if (isset($_POST['uniqid'])) {
+ $uniqid = $_POST['uniqid'];
+ } else {
+ return 0;
+ }
+
+ $filename = sprintf("%s/uniqid_%s_%s", $c->getDirectory('tmp'), $_SERVER['REMOTE_ADDR'], $uniqid);
+ if (file_exists($filename)) {
+ if (unlink($filename) == false) {
+ return Ethna::raiseWarning(E_APP_WRITE, $filename);
+ }
+ }
+
+ return 0;
+ }
+
+ /**
+ * ¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬Àµ¤·¤¤¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë
+ *
+ * @access public
+ * @param string $mailaddress ¥Á¥§¥Ã¥¯¤¹¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹
+ * @return bool true: Àµ¤·¤¤¥á¡¼¥ë¥¢¥É¥ì¥¹ false: ÉÔÀµ¤Ê·Á¼°
+ */
+ function checkMailAddress($mailaddress)
+ {
+ if (preg_match('/^([a-z0-9_]|\-|\.|\+)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,6}$/i', $mailaddress)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * CSV·Á¼°¤Îʸ»úÎó¤òÇÛÎó¤Ëʬ³ä¤¹¤ë
+ *
+ * @access public
+ * @param string $csv CSV·Á¼°¤Îʸ»úÎó(1¹Ôʬ)
+ * @param string $delimiter ¥Õ¥£¡¼¥ë¥É¤Î¶èÀÚ¤êʸ»ú
+ * @return mixed (array):ʬ³ä·ë²Ì Ethna_Error:¥¨¥é¡¼(¹Ô·Ñ³)
+ */
+ function explodeCSV($csv, $delimiter = ",")
+ {
+ $space_list = '';
+ foreach (array(" ", "\t", "\r", "\n") as $c) {
+ if ($c != $delimiter) {
+ $space_list .= $c;
+ }
+ }
+
+ $line_end = "";
+ if (preg_match("/([$space_list]+)\$/sS", $csv, $match)) {
+ $line_end = $match[1];
+ }
+ $csv = substr($csv, 0, strlen($csv)-strlen($line_end));
+ $csv .= ' ';
+
+ $field = '';
+ $retval = array();
+
+ $index = 0;
+ $csv_len = strlen($csv);
+ do {
+ // 1. skip leading spaces
+ if (preg_match("/^([$space_list]+)/sS", substr($csv, $index), $match)) {
+ $index += strlen($match[1]);
+ }
+ if ($index >= $csv_len) {
+ break;
+ }
+
+ // 2. read field
+ if ($csv{$index} == '"') {
+ // 2A. handle quote delimited field
+ $index++;
+ while ($index < $csv_len) {
+ if ($csv{$index} == '"') {
+ // handle double quote
+ if ($csv{$index+1} == '"') {
+ $field .= $csv{$index};
+ $index += 2;
+ } else {
+ // must be end of string
+ while ($csv{$index} != $delimiter && $index < $csv_len) {
+ $index++;
+ }
+ if ($csv{$index} == $delimiter) {
+ $index++;
+ }
+ break;
+ }
+ } else {
+ // normal character
+ if (preg_match("/^([^\"]*)/S", substr($csv, $index), $match)) {
+ $field .= $match[1];
+ $index += strlen($match[1]);
+ }
+
+ if ($index == $csv_len) {
+ $field = substr($field, 0, strlen($field)-1);
+ $field .= $line_end;
+
+ // request one more line
+ return Ethna::raiseNotice(E_UTIL_CSV_CONTINUE);
+ }
+ }
+ }
+ } else {
+ // 2B. handle non-quoted field
+ if (preg_match("/^([^$delimiter]*)/S", substr($csv, $index), $match)) {
+ $field .= $match[1];
+ $index += strlen($match[1]);
+ }
+
+ // remove trailing spaces
+ $field = preg_replace("/[$space_list]+\$/S", '', $field);
+ if ($csv{$index} == $delimiter) {
+ $index++;
+ }
+ }
+ $retval[] = $field;
+ $field = '';
+ } while ($index < $csv_len);
+
+ return $retval;
+ }
+
+ /**
+ * CSV¥¨¥¹¥±¡¼¥×½èÍý¤ò¹Ô¤¦
+ *
+ * @access public
+ * @param string $csv ¥¨¥¹¥±¡¼¥×ÂоݤÎʸ»úÎó(CSV¤Î³ÆÍ×ÁÇ)
+ * @param bool $escape_nl ²þ¹Ôʸ»ú(\r/\n)¤Î¥¨¥¹¥±¡¼¥×¥Õ¥é¥°
+ * @return string CSV¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿Ê¸»úÎó
+ */
+ function escapeCSV($csv, $escape_nl = false)
+ {
+ if (preg_match('/[,"\r\n]/', $csv)) {
+ if ($escape_nl) {
+ $csv = preg_replace('/\r/', "\\r", $csv);
+ $csv = preg_replace('/\n/', "\\n", $csv);
+ }
+ $csv = preg_replace('/"/', "\"\"", $csv);
+ $csv = "\"$csv\"";
+ }
+
+ return $csv;
+ }
+
+ /**
+ * ÇÛÎó¤ÎÍ×ÁǤòÁ´¤ÆHTML¥¨¥¹¥±¡¼¥×¤·¤ÆÊÖ¤¹
+ *
+ * @access public
+ * @param array $target HTML¥¨¥¹¥±¡¼¥×ÂоݤȤʤëÇÛÎó
+ * @return array ¥¨¥¹¥±¡¼¥×¤µ¤ì¤¿ÇÛÎó
+ */
+ function escapeHtml($target)
+ {
+ $r = array();
+ Ethna_Util::_escapeHtml($target, $r);
+ return $r;
+ }
+
+ /**
+ * ÇÛÎó¤ÎÍ×ÁǤòÁ´¤ÆHTML¥¨¥¹¥±¡¼¥×¤·¤ÆÊÖ¤¹
+ *
+ * @access public
+ * @param mixed $vars HTML¥¨¥¹¥±¡¼¥×ÂоݤȤʤëÇÛÎó
+ * @param mixed $retval HTML¥¨¥¹¥±¡¼¥×ÂоݤȤʤë»ÒÍ×ÁÇ
+ */
+ function _escapeHtml(&$vars, &$retval)
+ {
+ foreach (array_keys($vars) as $name) {
+ if (is_array($vars[$name])) {
+ $retval[$name] = array();
+ Ethna_Util::_escapeHtml($vars[$name], $retval[$name]);
+ } else if (!is_object($vars[$name])) {
+ $retval[$name] = htmlspecialchars($vars[$name], ENT_QUOTES);
+ }
+ }
+ }
+
+ /**
+ * ʸ»úÎó¤òMIME¥¨¥ó¥³¡¼¥É¤¹¤ë
+ *
+ * @access public
+ * @param string $string MIME¥¨¥ó¥³¡¼¥É¤¹¤ëʸ»úÎó
+ * @return ¥¨¥ó¥³¡¼¥ÉºÑ¤ß¤Îʸ»úÎó
+ */
+ function encode_MIME($string)
+ {
+ $pos = 0;
+ $split = 36;
+ $_string = "";
+ while ($pos < mb_strlen($string))
+ {
+ $tmp = mb_strimwidth($string, $pos, $split, "");
+ $pos += mb_strlen($tmp);
+ $_string .= (($_string)? ' ' : '') . mb_encode_mimeheader($tmp, 'ISO-2022-JP');
+ }
+ return $_string;
+ }
+
+ /**
+ * GoogleÉ÷¥ê¥ó¥¯¥ê¥¹¥È¤òÊÖ¤¹
+ *
+ * @access public
+ * @param int $total ¸¡º÷Áí·ï¿ô
+ * @param int $offset ɽ¼¨¥ª¥Õ¥»¥Ã¥È
+ * @param int $count ɽ¼¨·ï¿ô
+ * @return array ¥ê¥ó¥¯¾ðÊó¤ò³ÊǼ¤·¤¿ÇÛÎó
+ */
+ function getDirectLinkList($total, $offset, $count)
+ {
+ $direct_link_list = array();
+
+ if ($total == 0) {
+ return array();
+ }
+
+ // backwards
+ $current = $offset - $count;
+ while ($current > 0) {
+ array_unshift($direct_link_list, $current);
+ $current -= $count;
+ }
+ if ($offset != 0 && $current <= 0) {
+ array_unshift($direct_link_list, 0);
+ }
+
+ // current
+ $backward_count = count($direct_link_list);
+ array_push($direct_link_list, $offset);
+
+ // forwards
+ $current = $offset + $count;
+ for ($i = 0; $i < 10; $i++) {
+ if ($current >= $total) {
+ break;
+ }
+ array_push($direct_link_list, $current);
+ $current += $count;
+ }
+ $forward_count = count($direct_link_list) - $backward_count - 1;
+
+ $backward_count -= 4;
+ if ($forward_count < 5) {
+ $backward_count -= 5 - $forward_count;
+ }
+ if ($backward_count < 0) {
+ $backward_count = 0;
+ }
+
+ // add index
+ $n = 1;
+ $r = array();
+ foreach ($direct_link_list as $direct_link) {
+ $v = array('offset' => $direct_link, 'index' => $n);
+ $r[] = $v;
+ $n++;
+ }
+
+ return array_splice($r, $backward_count, 10);
+ }
+
+ /**
+ * ¸µ¹æÀ©¤Ç¤Îǯ¤òÊÖ¤¹
+ *
+ * @access public
+ * @param int $t unix time
+ * @return string ¸µ¹æ(ÉÔÌÀ¤Ê¾ì¹ç¤Ïnull)
+ */
+ function getEra($t)
+ {
+ $tm = localtime($t, true);
+ $year = $tm['tm_year'] + 1900;
+
+ if ($year >= 1989) {
+ return array('Ê¿À®', $year - 1988);
+ } else if ($year >= 1926) {
+ return array('¾¼ÏÂ', $year - 1925);
+ }
+
+ return null;
+ }
+
+ /**
+ * getimagesize()¤ÎÊÖ¤¹¥¤¥á¡¼¥¸¥¿¥¤¥×¤ËÂбþ¤¹¤ë³ÈÄ¥»Ò¤òÊÖ¤¹
+ *
+ * @access public
+ * @param int $type getimagesize()´Ø¿ô¤ÎÊÖ¤¹¥¤¥á¡¼¥¸¥¿¥¤¥×
+ * @return string $type¤ËÂбþ¤¹¤ë³ÈÄ¥»Ò
+ */
+ function getImageExtName($type)
+ {
+ $ext_list = array(
+ 1 => 'gif',
+ 2 => 'jpg',
+ 3 => 'png',
+ 4 => 'swf',
+ 5 => 'psd',
+ 6 => 'bmp',
+ 7 => 'tiff',
+ 8 => 'tiff',
+ 9 => 'jpc',
+ 10 => 'jp2',
+ 11 => 'jpx',
+ 12 => 'jb2',
+ 13 => 'swc',
+ 14 => 'iff',
+ 15 => 'wbmp',
+ 16 => 'xbm',
+ );
+
+ return @$ext_list[$type];
+ }
+
+ /**
+ * ¥é¥ó¥À¥à¤Ê¥Ï¥Ã¥·¥åÃͤòÀ¸À®¤¹¤ë
+ *
+ * ·è¤·¤Æ¹â®¤Ç¤Ï¤Ê¤¤¤Î¤ÇÍðÍѤÏÈò¤±¤ë¤³¤È
+ *
+ * @access public
+ * @param int $length ¥Ï¥Ã¥·¥åÃͤÎŤµ(¡Á64)
+ * @return string ¥Ï¥Ã¥·¥åÃÍ
+ */
+ function getRandom($length = 64)
+ {
+ static $srand = false;
+
+ if ($srand == false) {
+ list($usec, $sec) = explode(' ', microtime());
+ mt_srand((float) $sec + ((float) $usec * 100000) + getmypid());
+ $srand = true;
+ }
+
+ $value = "";
+ for ($i = 0; $i < 2; $i++) {
+ // for Linux
+ if (file_exists('/proc/net/dev')) {
+ $rx = $tx = 0;
+ $fp = fopen('/proc/net/dev', 'r');
+ if ($fp != null) {
+ $header = true;
+ while (feof($fp) === false) {
+ $s = fgets($fp, 4096);
+ if ($header) {
+ $header = false;
+ continue;
+ }
+ $v = preg_split('/[:\s]+/', $s);
+ if (is_array($v) && count($v) > 10) {
+ $rx += $v[2];
+ $tx += $v[10];
+ }
+ }
+ }
+ $platform_value = $rx . $tx . mt_rand() . getmypid();
+ } else {
+ $platform_value = mt_rand() . getmypid();
+ }
+ $now = strftime('%Y%m%d %T');
+ $time = gettimeofday();
+ $v = $now . $time['usec'] . $platform_value . mt_rand(0, time());
+ $value .= md5($v);
+ }
+
+ if ($length < 64) {
+ $value = substr($value, 0, $length);
+ }
+ return $value;
+ }
+
+ /**
+ * 1¼¡¸µÇÛÎó¤òm x n¤ËºÆ¹½À®¤¹¤ë
+ *
+ * @access public
+ * @param array $array ½èÍýÂоݤÎ1¼¡¸µÇÛÎó
+ * @param int $m ¼´¤ÎÍ×ÁÇ¿ô
+ * @param int $order $m¤òX¼´¤È¸«Ðö¤¹¤«Y¼´¤È¸«Ðö¤¹¤«(0:X¼´ 1:Y¼´)
+ * @return array m x n¤ËºÆ¹½À®¤µ¤ì¤¿ÇÛÎó
+ */
+ function get2dArray($array, $m, $order)
+ {
+ $r = array();
+
+ $n = intval(count($array) / $m);
+ if ((count($array) % $m) > 0) {
+ $n++;
+ }
+ for ($i = 0; $i < $n; $i++) {
+ $elts = array();
+ for ($j = 0; $j < $m; $j++) {
+ if ($order == 0) {
+ // ²£Ê¤Ó(²£¡§$mÎó ½Ä¡§ÌµÀ©¸Â)
+ $key = $i*$m+$j;
+ } else {
+ // ½ÄʤÓ(²£¡§ÌµÀ©¸Â ½Ä¡§$m¹Ô)
+ $key = $i+$n*$j;
+ }
+ if (array_key_exists($key, $array) == false) {
+ $array[$key] = null;
+ }
+ $elts[] = $array[$key];
+ }
+ $r[] = $elts;
+ }
+
+ return $r;
+ }
+
+ /**
+ * ¥Ñ¥¹Ì¾¤¬ÀäÂХѥ¹¤«¤É¤¦¤«¤òÊÖ¤¹
+ *
+ * port from File in PEAR (for BC)
+ *
+ * @access public
+ * @param string $path
+ * @return bool true:ÀäÂХѥ¹ false:ÁêÂХѥ¹
+ */
+ function isAbsolute($path)
+ {
if (preg_match("/\.\./", $path)) {
return false;
}
}
return false;
- }
-
- /**
- * ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë
- *
- * @access public
- * @param string $prefix ¥Õ¥¡¥¤¥ë¤Î¥×¥ì¥Õ¥£¥¯¥¹
- * @param int $timeout ºï½üÂоÝïçÃÍ(ÉáÝ60*60*1¤Ê¤é1»þ´Ö)
- */
- function purgeTmp($prefix, $timeout)
- {
- $c =& Ethna_Controller::getInstance();
-
- $dh = opendir($c->getDirectory('tmp'));
- if ($dh) {
- while (($file = readdir($dh)) !== false) {
- if (strncmp($file, $prefix, strlen($prefix)) == 0) {
- $f = $c->getDirectory('tmp') . "/" . $file;
- $st = @stat($f);
- if ($st[9] + $timeout < time()) {
- unlink($f);
- }
- }
- }
- closedir($dh);
- }
- }
-
- /**
- * ¥Õ¥¡¥¤¥ë¤ò¥í¥Ã¥¯¤¹¤ë
- *
- * @access public
- * @param string $file ¥í¥Ã¥¯¤¹¤ë¥Õ¥¡¥¤¥ë̾
- * @param int $mode ¥í¥Ã¥¯¥â¡¼¥É('r', 'rw')
- * @param int $timeout ¥í¥Ã¥¯ÂÔ¤Á¥¿¥¤¥à¥¢¥¦¥È(ÉáÝ0¤Ê¤é̵¸Â)
- * @return int ¥í¥Ã¥¯¥Ï¥ó¥É¥ë(false¤Ê¤é¥¨¥é¡¼)
- */
- function lockFile($file, $mode, $timeout = 0)
- {
- $lh = @fopen($file, 'r');
- if ($lh == null) {
- return false;
- }
-
- $lock_mode = $mode == 'r' ? LOCK_SH : LOCK_EX;
-
- for ($i = 0; $i < $timeout || $timeout == 0; $i++) {
- $r = flock($lh, $lock_mode | LOCK_NB);
- if ($r == true) {
- break;
- }
- sleep(1);
- }
- if ($timeout > 0 && $i == $timeout) {
- // timed out
- return false;
- }
+ }
+
+ /**
+ * ¥Æ¥ó¥Ý¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë
+ *
+ * @access public
+ * @param string $prefix ¥Õ¥¡¥¤¥ë¤Î¥×¥ì¥Õ¥£¥¯¥¹
+ * @param int $timeout ºï½üÂоÝïçÃÍ(ÉáÝ60*60*1¤Ê¤é1»þ´Ö)
+ */
+ function purgeTmp($prefix, $timeout)
+ {
+ $c =& Ethna_Controller::getInstance();
+
+ $dh = opendir($c->getDirectory('tmp'));
+ if ($dh) {
+ while (($file = readdir($dh)) !== false) {
+ if (strncmp($file, $prefix, strlen($prefix)) == 0) {
+ $f = $c->getDirectory('tmp') . "/" . $file;
+ $st = @stat($f);
+ if ($st[9] + $timeout < time()) {
+ unlink($f);
+ }
+ }
+ }
+ closedir($dh);
+ }
+ }
+
+ /**
+ * ¥Õ¥¡¥¤¥ë¤ò¥í¥Ã¥¯¤¹¤ë
+ *
+ * @access public
+ * @param string $file ¥í¥Ã¥¯¤¹¤ë¥Õ¥¡¥¤¥ë̾
+ * @param int $mode ¥í¥Ã¥¯¥â¡¼¥É('r', 'rw')
+ * @param int $timeout ¥í¥Ã¥¯ÂÔ¤Á¥¿¥¤¥à¥¢¥¦¥È(ÉáÝ0¤Ê¤é̵¸Â)
+ * @return int ¥í¥Ã¥¯¥Ï¥ó¥É¥ë(false¤Ê¤é¥¨¥é¡¼)
+ */
+ function lockFile($file, $mode, $timeout = 0)
+ {
+ $lh = @fopen($file, 'r');
+ if ($lh == null) {
+ return false;
+ }
+
+ $lock_mode = $mode == 'r' ? LOCK_SH : LOCK_EX;
+
+ for ($i = 0; $i < $timeout || $timeout == 0; $i++) {
+ $r = flock($lh, $lock_mode | LOCK_NB);
+ if ($r == true) {
+ break;
+ }
+ sleep(1);
+ }
+ if ($timeout > 0 && $i == $timeout) {
+ // timed out
+ return false;
+ }
- return $lh;
- }
-
- /**
- * ¥Õ¥¡¥¤¥ë¤Î¥í¥Ã¥¯¤ò²ò½ü¤¹¤ë
- *
- * @access public
- * @param int $lh ¥í¥Ã¥¯¥Ï¥ó¥É¥ë
- */
- function unlockFile($lh)
- {
- fclose($lh);
- }
-
- /**
- * ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤ò¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤ÆÊÖ¤¹
- *
- * @access public
- * @param array $bt debug_backtrace()´Ø¿ô¤Ç¼èÆÀ¤·¤¿¥Ð¥Ã¥¯¥È¥ì¡¼¥¹
- * @return string ʸ»úÎó¤Ë¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤¿¥Ð¥Ã¥¯¥È¥ì¡¼¥¹
- */
- function formatBacktrace($bt)
- {
- $r = "";
- $i = 0;
- foreach ($bt as $elt) {
- $r .= sprintf("[%02d] %s:%d:%s.%s\n", $i, $elt['file'], $elt['line'], isset($elt['class']) ? $elt['class'] : 'global', $elt['function']);
- $i++;
-
- if (isset($elt['args']) == false || is_array($elt['args']) == false) {
- continue;
- }
-
- // °ú¿ô¤Î¥À¥ó¥×
- foreach ($elt['args'] as $arg) {
- $r .= Ethna_Util::_formatBacktrace($arg);
- }
- }
-
- return $r;
- }
-
- /**
- * ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹°ú¿ô¤ò¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤ÆÊÖ¤¹
- *
- * @access private
- * @param string $arg ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤Î°ú¿ô
- * @param int $level ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤Î¥Í¥¹¥È¥ì¥Ù¥ë
- * @param int $wrap ²þ¹Ô¥Õ¥é¥°
- * @return string ʸ»úÎó¤Ë¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤¿¥Ð¥Ã¥¯¥È¥ì¡¼¥¹
- */
- function _formatBacktrace($arg, $level = 0, $wrap = true)
- {
- $pad = str_repeat(" ", $level);
- if (is_array($arg)) {
- $r = sprintf(" %s[array] => (\n", $pad);
- if ($level+1 > 4) {
- $r .= sprintf(" %s *too deep*\n", $pad);
- } else {
- foreach ($arg as $key => $elt) {
- $r .= Ethna_Util::_formatBacktrace($key, $level, false);
- $r .= " => \n";
- $r .= Ethna_Util::_formatBacktrace($elt, $level+1);
- }
- }
- $r .= sprintf(" %s)\n", $pad);
- } else if (is_object($arg)) {
- $r = sprintf(" %s[object]%s%s", $pad, get_class($arg), $wrap ? "\n" : "");
- } else {
- $r = sprintf(" %s[%s]%s%s", $pad, gettype($arg), $arg, $wrap ? "\n" : "");
- }
-
- return $r;
- }
+ return $lh;
+ }
+
+ /**
+ * ¥Õ¥¡¥¤¥ë¤Î¥í¥Ã¥¯¤ò²ò½ü¤¹¤ë
+ *
+ * @access public
+ * @param int $lh ¥í¥Ã¥¯¥Ï¥ó¥É¥ë
+ */
+ function unlockFile($lh)
+ {
+ fclose($lh);
+ }
+
+ /**
+ * ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤ò¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤ÆÊÖ¤¹
+ *
+ * @access public
+ * @param array $bt debug_backtrace()´Ø¿ô¤Ç¼èÆÀ¤·¤¿¥Ð¥Ã¥¯¥È¥ì¡¼¥¹
+ * @return string ʸ»úÎó¤Ë¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤¿¥Ð¥Ã¥¯¥È¥ì¡¼¥¹
+ */
+ function formatBacktrace($bt)
+ {
+ $r = "";
+ $i = 0;
+ foreach ($bt as $elt) {
+ $r .= sprintf("[%02d] %s:%d:%s.%s\n", $i, $elt['file'], $elt['line'], isset($elt['class']) ? $elt['class'] : 'global', $elt['function']);
+ $i++;
+
+ if (isset($elt['args']) == false || is_array($elt['args']) == false) {
+ continue;
+ }
+
+ // °ú¿ô¤Î¥À¥ó¥×
+ foreach ($elt['args'] as $arg) {
+ $r .= Ethna_Util::_formatBacktrace($arg);
+ }
+ }
+
+ return $r;
+ }
+
+ /**
+ * ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹°ú¿ô¤ò¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤ÆÊÖ¤¹
+ *
+ * @access private
+ * @param string $arg ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤Î°ú¿ô
+ * @param int $level ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤Î¥Í¥¹¥È¥ì¥Ù¥ë
+ * @param int $wrap ²þ¹Ô¥Õ¥é¥°
+ * @return string ʸ»úÎó¤Ë¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤¿¥Ð¥Ã¥¯¥È¥ì¡¼¥¹
+ */
+ function _formatBacktrace($arg, $level = 0, $wrap = true)
+ {
+ $pad = str_repeat(" ", $level);
+ if (is_array($arg)) {
+ $r = sprintf(" %s[array] => (\n", $pad);
+ if ($level+1 > 4) {
+ $r .= sprintf(" %s *too deep*\n", $pad);
+ } else {
+ foreach ($arg as $key => $elt) {
+ $r .= Ethna_Util::_formatBacktrace($key, $level, false);
+ $r .= " => \n";
+ $r .= Ethna_Util::_formatBacktrace($elt, $level+1);
+ }
+ }
+ $r .= sprintf(" %s)\n", $pad);
+ } else if (is_object($arg)) {
+ $r = sprintf(" %s[object]%s%s", $pad, get_class($arg), $wrap ? "\n" : "");
+ } else {
+ $r = sprintf(" %s[%s]%s%s", $pad, gettype($arg), $arg, $wrap ? "\n" : "");
+ }
+
+ return $r;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_ViewClass.php
+ * Ethna_ViewClass.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_ViewClass
/**
- * view¥¯¥é¥¹
+ * view¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_ViewClass
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
- var $backend;
+ /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
+ var $backend;
- /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
- var $config;
+ /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
+ var $config;
- /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
- var $i18n;
+ /** @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È */
+ var $i18n;
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_error;
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_error;
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $ae;
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $ae;
- /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_form;
+ /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_form;
- /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $af;
+ /** @var object Ethna_ActionForm ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $af;
- /** @var array ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(helper) */
- var $helper_action_form = array();
+ /** @var array ¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È(helper) */
+ var $helper_action_form = array();
- /** @var object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È */
- var $session;
+ /** @var object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È */
+ var $session;
- /** @var string Á«°Ü̾ */
- var $forward_name;
+ /** @var string Á«°Ü̾ */
+ var $forward_name;
- /** @var string Á«°ÜÀè¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë̾ */
- var $forward_path;
+ /** @var string Á«°ÜÀè¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë̾ */
+ var $forward_path;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_ViewClass¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_Backend $backend backend¥ª¥Ö¥¸¥§¥¯¥È
- * @param string $forward_name ¥Ó¥å¡¼¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤Æ¤¤¤ëÁ«°Ü̾
- * @param string $forward_path ¥Ó¥å¡¼¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë̾
- */
- function Ethna_ViewClass(&$backend, $forward_name, $forward_path)
- {
- $c =& $backend->getController();
- $this->backend =& $backend;
- $this->config =& $this->backend->getConfig();
- $this->i18n =& $this->backend->getI18N();
+ /**
+ * Ethna_ViewClass¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_Backend $backend backend¥ª¥Ö¥¸¥§¥¯¥È
+ * @param string $forward_name ¥Ó¥å¡¼¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤Æ¤¤¤ëÁ«°Ü̾
+ * @param string $forward_path ¥Ó¥å¡¼¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë̾
+ */
+ function Ethna_ViewClass(&$backend, $forward_name, $forward_path)
+ {
+ $c =& $backend->getController();
+ $this->backend =& $backend;
+ $this->config =& $this->backend->getConfig();
+ $this->i18n =& $this->backend->getI18N();
- $this->action_error =& $this->backend->getActionError();
- $this->ae =& $this->action_error;
+ $this->action_error =& $this->backend->getActionError();
+ $this->ae =& $this->action_error;
- $this->action_form =& $this->backend->getActionForm();
- $this->af =& $this->action_form;
+ $this->action_form =& $this->backend->getActionForm();
+ $this->af =& $this->action_form;
- $this->session =& $this->backend->getSession();
+ $this->session =& $this->backend->getSession();
- // Ethna_AppManager¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
- $manager_list = $c->getManagerList();
- foreach ($manager_list as $k => $v) {
- $this->$k =& $backend->getManager($v);
- }
+ // Ethna_AppManager¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê
+ $manager_list = $c->getManagerList();
+ foreach ($manager_list as $k => $v) {
+ $this->$k =& $backend->getManager($v);
+ }
- $this->forward_name = $forward_name;
- $this->forward_path = $forward_path;
+ $this->forward_name = $forward_name;
+ $this->forward_path = $forward_path;
foreach ($this->helper_action_form as $key => $value) {
if (is_object($value)) {
}
$this->helper_action_form[$key] =& $this->_getHelperActionForm($key);
}
- }
-
- /**
- * ²èÌÌɽ¼¨Á°½èÍý
- *
- * ¥Æ¥ó¥×¥ì¡¼¥È¤ËÀßÄꤹ¤ëÃͤǥ³¥ó¥Æ¥¥¹¥È¤Ë°Í¸¤·¤Ê¤¤¤â¤Î¤Ï
- * ¤³¤³¤ÇÀßÄꤹ¤ë(Îã:¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹Åù)
- *
- * @access public
- */
- function preforward()
- {
- }
-
- /**
- * Á«°Ü̾¤ËÂбþ¤¹¤ë²èÌ̤ò½ÐÎϤ¹¤ë
- *
- * Æüì¤Ê²èÌ̤òɽ¼¨¤¹¤ë¾ì¹ç¤ò½ü¤¤¤ÆÆä˥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ëɬÍפÏ̵¤¤
- * (preforward()¤Î¤ß¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ì¤ÐÎɤ¤)
- *
- * @access public
- */
- function forward()
- {
- $engine =& $this->_getTemplateEngine();
- $this->_setDefault($engine);
- $engine->perform($this->forward_path);
- }
+ }
+
+ /**
+ * ²èÌÌɽ¼¨Á°½èÍý
+ *
+ * ¥Æ¥ó¥×¥ì¡¼¥È¤ËÀßÄꤹ¤ëÃͤǥ³¥ó¥Æ¥¥¹¥È¤Ë°Í¸¤·¤Ê¤¤¤â¤Î¤Ï
+ * ¤³¤³¤ÇÀßÄꤹ¤ë(Îã:¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹Åù)
+ *
+ * @access public
+ */
+ function preforward()
+ {
+ }
+
+ /**
+ * Á«°Ü̾¤ËÂбþ¤¹¤ë²èÌ̤ò½ÐÎϤ¹¤ë
+ *
+ * Æüì¤Ê²èÌ̤òɽ¼¨¤¹¤ë¾ì¹ç¤ò½ü¤¤¤ÆÆä˥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ëɬÍפÏ̵¤¤
+ * (preforward()¤Î¤ß¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ì¤ÐÎɤ¤)
+ *
+ * @access public
+ */
+ function forward()
+ {
+ $engine =& $this->_getTemplateEngine();
+ $this->_setDefault($engine);
+ $engine->perform($this->forward_path);
+ }
/**
* helper¥¢¥¯¥·¥ç¥ó¥Õ¥©¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÀßÄꤹ¤ë
return $r;
}
- /**
- * Smarty¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
- *
- * @access protected
- * @return object Smarty Smarty¥ª¥Ö¥¸¥§¥¯¥È
- */
- function &_getTemplateEngine()
- {
- $c =& $this->backend->getController();
- $renderer =& $c->getTemplateEngine();
-
- $form_array =& $this->af->getArray();
- $app_array =& $this->af->getAppArray();
- $app_ne_array =& $this->af->getAppNEArray();
- $renderer->setPropByRef('form', $form_array);
- $renderer->setPropByRef('app', $app_array);
- $renderer->setPropByRef('app_ne', $app_ne_array);
- $message_list = Ethna_Util::escapeHtml($this->ae->getMessageList());
- $renderer->setPropByRef('errors', $message_list);
- if (isset($_SESSION)) {
- $tmp_session = Ethna_Util::escapeHtml($_SESSION);
- $renderer->setPropByRef('session', $tmp_session);
- }
- $renderer->setProp('script', basename($_SERVER['PHP_SELF']));
- $renderer->setProp('request_uri', htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES));
-
- return $renderer;
- }
-
- /**
- * ¶¦ÄÌÃͤòÀßÄꤹ¤ë
- *
- * @access protected
- * @param object ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó
- */
- function _setDefault(&$engine)
- {
- }
+ /**
+ * Smarty¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access protected
+ * @return object Smarty Smarty¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function &_getTemplateEngine()
+ {
+ $c =& $this->backend->getController();
+ $renderer =& $c->getTemplateEngine();
+
+ $form_array =& $this->af->getArray();
+ $app_array =& $this->af->getAppArray();
+ $app_ne_array =& $this->af->getAppNEArray();
+ $renderer->setPropByRef('form', $form_array);
+ $renderer->setPropByRef('app', $app_array);
+ $renderer->setPropByRef('app_ne', $app_ne_array);
+ $message_list = Ethna_Util::escapeHtml($this->ae->getMessageList());
+ $renderer->setPropByRef('errors', $message_list);
+ if (isset($_SESSION)) {
+ $tmp_session = Ethna_Util::escapeHtml($_SESSION);
+ $renderer->setPropByRef('session', $tmp_session);
+ }
+ $renderer->setProp('script', basename($_SERVER['PHP_SELF']));
+ $renderer->setProp('request_uri', htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES));
+
+ return $renderer;
+ }
+
+ /**
+ * ¶¦ÄÌÃͤòÀßÄꤹ¤ë
+ *
+ * @access protected
+ * @param object ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó
+ */
+ function _setDefault(&$engine)
+ {
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker tabstop=4 shiftwidth=4 autoindent
/**
- * Ethna_Plugin_Cachemanager_Localfile.php
+ * Ethna_Plugin_Cachemanager_Localfile.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
+ * @author Masaki Fujimoto <fujimoto@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @package Ethna
- * @version $Id$
+ * @version $Id$
*/
/**
- * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹(¥í¡¼¥«¥ë¥Õ¥¡¥¤¥ë¥¥ã¥Ã¥·¥åÈÇ)
+ * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹(¥í¡¼¥«¥ë¥Õ¥¡¥¤¥ë¥¥ã¥Ã¥·¥åÈÇ)
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Cachemanager_Localfile extends Ethna_Plugin_Cachemanager
{
- /**#@+ @access private */
+ /**#@+ @access private */
- /**#@-*/
+ /**#@-*/
- /**
- * ¥¥ã¥Ã¥·¥å¤ËÀßÄꤵ¤ì¤¿Ãͤò¼èÆÀ¤¹¤ë
- *
- * ¥¥ã¥Ã¥·¥å¤ËÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¥ã¥Ã¥·¥åÃÍ
- * ¤¬Ìá¤êÃͤȤʤ롣¥¥ã¥Ã¥·¥å¤ËÃͤ¬Ìµ¤¤¾ì¹ç¤älifetime
- * ¤ò²á¤®¤Æ¤¤¤ë¾ì¹ç¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏPEAR_Error
- * ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ìá¤êÃͤȤʤ롣
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return array ¥¥ã¥Ã¥·¥åÃÍ
- */
- function get($key, $lifetime = null, $namespace = null)
- {
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
- $cache_file = $this->_getCacheFile($namespace, $key);
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ËÀßÄꤵ¤ì¤¿Ãͤò¼èÆÀ¤¹¤ë
+ *
+ * ¥¥ã¥Ã¥·¥å¤ËÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¥ã¥Ã¥·¥åÃÍ
+ * ¤¬Ìá¤êÃͤȤʤ롣¥¥ã¥Ã¥·¥å¤ËÃͤ¬Ìµ¤¤¾ì¹ç¤älifetime
+ * ¤ò²á¤®¤Æ¤¤¤ë¾ì¹ç¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏPEAR_Error
+ * ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ìá¤êÃͤȤʤ롣
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return array ¥¥ã¥Ã¥·¥åÃÍ
+ */
+ function get($key, $lifetime = null, $namespace = null)
+ {
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ $cache_file = $this->_getCacheFile($namespace, $key);
- // ¥é¥¤¥Õ¥¿¥¤¥à¥Á¥§¥Ã¥¯
- clearstatcache();
- $st = @stat($cache_file);
- if ($st == false) {
- return PEAR::raiseError('fopen failed', E_CACHE_NO_VALUE);
- }
- if (is_null($lifetime) == false) {
- if (($st[9]+$lifetime) < time()) {
- return PEAR::raiseError('fopen failed', E_CACHE_EXPIRED);
- }
- }
+ // ¥é¥¤¥Õ¥¿¥¤¥à¥Á¥§¥Ã¥¯
+ clearstatcache();
+ $st = @stat($cache_file);
+ if ($st == false) {
+ return PEAR::raiseError('fopen failed', E_CACHE_NO_VALUE);
+ }
+ if (is_null($lifetime) == false) {
+ if (($st[9]+$lifetime) < time()) {
+ return PEAR::raiseError('fopen failed', E_CACHE_EXPIRED);
+ }
+ }
- $fp = fopen($cache_file, "r");
- if ($fp == false) {
- return PEAR::raiseError('fopen failed', E_CACHE_NO_VALUE);
- }
- // ¥í¥Ã¥¯
- $timeout = 3;
- while ($timeout > 0) {
- $r = flock($fp, LOCK_EX|LOCK_NB);
- if ($r) {
- break;
- }
- $timeout--;
- sleep(1);
- }
- if ($timeout <= 0) {
- fclose($fp);
- return PEAR::raiseError('fopen failed', E_CACHE_GENERAL);
- }
+ $fp = fopen($cache_file, "r");
+ if ($fp == false) {
+ return PEAR::raiseError('fopen failed', E_CACHE_NO_VALUE);
+ }
+ // ¥í¥Ã¥¯
+ $timeout = 3;
+ while ($timeout > 0) {
+ $r = flock($fp, LOCK_EX|LOCK_NB);
+ if ($r) {
+ break;
+ }
+ $timeout--;
+ sleep(1);
+ }
+ if ($timeout <= 0) {
+ fclose($fp);
+ return PEAR::raiseError('fopen failed', E_CACHE_GENERAL);
+ }
- $n = 0;
- while ($st[7] == 0) {
- clearstatcache();
- $st = @stat($cache_file);
- usleep(1000*1);
- $n++;
- if ($n > 5) {
- break;
- }
- }
+ $n = 0;
+ while ($st[7] == 0) {
+ clearstatcache();
+ $st = @stat($cache_file);
+ usleep(1000*1);
+ $n++;
+ if ($n > 5) {
+ break;
+ }
+ }
- if ($st == false || $n > 5) {
- fclose($fp);
- return PEAR::raiseError('stat failed', E_CACHE_NO_VALUE);
- }
- $value = fread($fp, $st[7]);
- fclose($fp);
+ if ($st == false || $n > 5) {
+ fclose($fp);
+ return PEAR::raiseError('stat failed', E_CACHE_NO_VALUE);
+ }
+ $value = fread($fp, $st[7]);
+ fclose($fp);
- return unserialize($value);
- }
+ return unserialize($value);
+ }
- /**
- * ¥¥ã¥Ã¥·¥å¤ÎºÇ½ª¹¹¿·Æü»þ¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return int ºÇ½ª¹¹¿·Æü»þ(unixtime)
- */
- function getLastModified($key, $namespace = null)
- {
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
- $cache_file = $this->_getCacheFile($namespace, $key);
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ÎºÇ½ª¹¹¿·Æü»þ¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return int ºÇ½ª¹¹¿·Æü»þ(unixtime)
+ */
+ function getLastModified($key, $namespace = null)
+ {
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ $cache_file = $this->_getCacheFile($namespace, $key);
- clearstatcache();
- $st = @stat($cache_file);
- if ($st == false) {
- return PEAR::raiseError('fopen failed', E_CACHE_NO_VALUE);
- }
- return $st[9];
- }
+ clearstatcache();
+ $st = @stat($cache_file);
+ if ($st == false) {
+ return PEAR::raiseError('fopen failed', E_CACHE_NO_VALUE);
+ }
+ return $st[9];
+ }
- /**
- * Ãͤ¬¥¥ã¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function isCached($key, $lifetime = null, $namespace = null)
- {
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
- $cache_file = $this->_getCacheFile($namespace, $key);
+ /**
+ * Ãͤ¬¥¥ã¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function isCached($key, $lifetime = null, $namespace = null)
+ {
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ $cache_file = $this->_getCacheFile($namespace, $key);
- // ¥é¥¤¥Õ¥¿¥¤¥à¥Á¥§¥Ã¥¯
- clearstatcache();
- $st = @stat($cache_file);
- if ($st == false) {
- return false;
- }
- if (is_null($lifetime) == false) {
- if (($st[9]+$lifetime) < time()) {
- return false;
- }
- }
+ // ¥é¥¤¥Õ¥¿¥¤¥à¥Á¥§¥Ã¥¯
+ clearstatcache();
+ $st = @stat($cache_file);
+ if ($st == false) {
+ return false;
+ }
+ if (is_null($lifetime) == false) {
+ if (($st[9]+$lifetime) < time()) {
+ return false;
+ }
+ }
- return true;
- }
+ return true;
+ }
- /**
- * ¥¥ã¥Ã¥·¥å¤ËÃͤòÀßÄꤹ¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param mixed $value ¥¥ã¥Ã¥·¥åÃÍ
- * @param int $timestamp ¥¥ã¥Ã¥·¥åºÇ½ª¹¹¿·»þ¹ï(unixtime)
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function set($key, $value, $timestamp = null, $namespace = null)
- {
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
- $dir = $this->_getCacheDir($namespace, $key);
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ËÃͤòÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param mixed $value ¥¥ã¥Ã¥·¥åÃÍ
+ * @param int $timestamp ¥¥ã¥Ã¥·¥åºÇ½ª¹¹¿·»þ¹ï(unixtime)
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function set($key, $value, $timestamp = null, $namespace = null)
+ {
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ $dir = $this->_getCacheDir($namespace, $key);
- // ¥¥ã¥Ã¥·¥å¥Ç¥£¥ì¥¯¥È¥ê¥Á¥§¥Ã¥¯
- $dir_list = array();
- $tmp = $dir;
- while (is_dir($tmp) == false) {
- array_unshift($dir_list, $tmp);
- $tmp = dirname($tmp);
- }
- foreach ($dir_list as $tmp) {
- $r = @mkdir($tmp);
- if ($r == false && is_dir($tmp) == false) {
- $message = sprintf('mkdir(%s) failed', $tmp);
- trigger_error($message, E_USER_WARNING);
- }
- $this->_chmod($tmp, 0777);
- }
+ // ¥¥ã¥Ã¥·¥å¥Ç¥£¥ì¥¯¥È¥ê¥Á¥§¥Ã¥¯
+ $dir_list = array();
+ $tmp = $dir;
+ while (is_dir($tmp) == false) {
+ array_unshift($dir_list, $tmp);
+ $tmp = dirname($tmp);
+ }
+ foreach ($dir_list as $tmp) {
+ $r = @mkdir($tmp);
+ if ($r == false && is_dir($tmp) == false) {
+ $message = sprintf('mkdir(%s) failed', $tmp);
+ trigger_error($message, E_USER_WARNING);
+ }
+ $this->_chmod($tmp, 0777);
+ }
- $cache_file = $this->_getCacheFile($namespace, $key);
- $fp = fopen($cache_file, "a+");
- if ($fp == false) {
- return PEAR::raiseError('fopen failed', E_CACHE_GENERAL);
- }
+ $cache_file = $this->_getCacheFile($namespace, $key);
+ $fp = fopen($cache_file, "a+");
+ if ($fp == false) {
+ return PEAR::raiseError('fopen failed', E_CACHE_GENERAL);
+ }
- // ¥í¥Ã¥¯
- $timeout = 3;
- while ($timeout > 0) {
- $r = flock($fp, LOCK_EX|LOCK_NB);
- if ($r) {
- break;
- }
- $timeout--;
- sleep(1);
- }
- if ($timeout <= 0) {
- fclose($fp);
- return PEAR::raiseError('fopen failed', E_CACHE_GENERAL);
- }
- rewind($fp);
- ftruncate($fp, 0);
- fwrite($fp, serialize($value));
- fclose($fp);
- $this->_chmod($cache_file, 0666);
+ // ¥í¥Ã¥¯
+ $timeout = 3;
+ while ($timeout > 0) {
+ $r = flock($fp, LOCK_EX|LOCK_NB);
+ if ($r) {
+ break;
+ }
+ $timeout--;
+ sleep(1);
+ }
+ if ($timeout <= 0) {
+ fclose($fp);
+ return PEAR::raiseError('fopen failed', E_CACHE_GENERAL);
+ }
+ rewind($fp);
+ ftruncate($fp, 0);
+ fwrite($fp, serialize($value));
+ fclose($fp);
+ $this->_chmod($cache_file, 0666);
- if (is_null($timestamp)) {
- // this could suppress warning
- touch($cache_file);
- } else {
- touch($cache_file, $timestamp);
- }
+ if (is_null($timestamp)) {
+ // this could suppress warning
+ touch($cache_file);
+ } else {
+ touch($cache_file, $timestamp);
+ }
- return 0;
- }
+ return 0;
+ }
- /**
- * ¥¥ã¥Ã¥·¥åÃͤòºï½ü¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function clear($key, $namespace = null)
- {
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
- $cache_file = $this->_getCacheFile($namespace, $key);
+ /**
+ * ¥¥ã¥Ã¥·¥åÃͤòºï½ü¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function clear($key, $namespace = null)
+ {
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ $cache_file = $this->_getCacheFile($namespace, $key);
- if (file_exists($cache_file)) {
- unlink($cache_file);
- }
- }
+ if (file_exists($cache_file)) {
+ unlink($cache_file);
+ }
+ }
- /**
- * ¥¥ã¥Ã¥·¥åÂоݥǥ£¥ì¥¯¥È¥ê¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- */
- function _getCacheDir($namespace, $key)
- {
- $len = strlen($key);
- // intentionally avoid using -2 or -4
- $dir1 = substr($key, $len-4, 2);
- if ($len-4 < 0 || strlen($dir1) < 2) {
- $dir1 = "__dir1";
- }
- $dir2 = substr($key, $len-2, 2);
- if ($len-2 < 0 || strlen($dir2) < 2) {
- $dir2 = "__dir2";
- }
+ /**
+ * ¥¥ã¥Ã¥·¥åÂоݥǥ£¥ì¥¯¥È¥ê¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ */
+ function _getCacheDir($namespace, $key)
+ {
+ $len = strlen($key);
+ // intentionally avoid using -2 or -4
+ $dir1 = substr($key, $len-4, 2);
+ if ($len-4 < 0 || strlen($dir1) < 2) {
+ $dir1 = "__dir1";
+ }
+ $dir2 = substr($key, $len-2, 2);
+ if ($len-2 < 0 || strlen($dir2) < 2) {
+ $dir2 = "__dir2";
+ }
$map = $this->config->get('cachemanager_localfile');
- $tmp_key = $namespace . "::" . $key;
- // PHP°Í¸:)
- $dir = "default";
+ $tmp_key = $namespace . "::" . $key;
+ // PHP°Í¸:)
+ $dir = "default";
if (is_array($map)) {
foreach ($map as $key => $value) {
}
}
}
-
+
return sprintf("%s/cache/%s/cache_%s/%s/%s", $this->backend->getTmpdir(), $dir, $this->_escape($namespace), $this->_escape($dir1), $this->_escape($dir2));
- }
+ }
- /**
- * ¥¥ã¥Ã¥·¥å¥Õ¥¡¥¤¥ë¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- */
- function _getCacheFile($namespace, $key)
- {
- return sprintf("%s/%s", $this->_getCacheDir($namespace, $key), $this->_escape($key));
- }
+ /**
+ * ¥¥ã¥Ã¥·¥å¥Õ¥¡¥¤¥ë¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ */
+ function _getCacheFile($namespace, $key)
+ {
+ return sprintf("%s/%s", $this->_getCacheDir($namespace, $key), $this->_escape($key));
+ }
- /**
- * ¥¡¼¤ò¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥àÍѤ˥¨¥¹¥±¡¼¥×¤¹¤ë
- *
- * @access private
- */
- function _escape($string)
- {
- return preg_replace('/([^0-9A-Za-z_])/e', "sprintf('%%%02X', ord('\$1'))", $string);
- }
+ /**
+ * ¥¡¼¤ò¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥àÍѤ˥¨¥¹¥±¡¼¥×¤¹¤ë
+ *
+ * @access private
+ */
+ function _escape($string)
+ {
+ return preg_replace('/([^0-9A-Za-z_])/e', "sprintf('%%%02X', ord('\$1'))", $string);
+ }
- /**
- * ¥Õ¥¡¥¤¥ë¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤òÊѹ¹¤¹¤ë
- *
- * @access private
- */
- function _chmod($file, $mode)
- {
- $st = stat($file);
- if (($st[2] & 0777) == $mode) {
- return true;
- }
- return chmod($file, $mode);
- }
+ /**
+ * ¥Õ¥¡¥¤¥ë¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤òÊѹ¹¤¹¤ë
+ *
+ * @access private
+ */
+ function _chmod($file, $mode)
+ {
+ $st = stat($file);
+ if (($st[2] & 0777) == $mode) {
+ return true;
+ }
+ return chmod($file, $mode);
+ }
}
?>
<?php
// vim: foldmethod=marker tabstop=4 shiftwidth=4 autoindent
/**
- * Ethna_Plugin_Cachemanager_Memcache.php
+ * Ethna_Plugin_Cachemanager_Memcache.php
*
- * - Point Cut¤·¤¿¤¤¤È»×¤Ã¤¿¡ª
- * - ¥¥ã¥Ã¥·¥å¥¡¼¤Ë¤Ï250ʸ»ú¤Þ¤Ç¤·¤«»ÈÍѤǤ¤Ê¤¤¤Î¤ÇÃí°Õ¤·¤Æ²¼¤µ¤¤
+ * - Point Cut¤·¤¿¤¤¤È»×¤Ã¤¿¡ª
+ * - ¥¥ã¥Ã¥·¥å¥¡¼¤Ë¤Ï250ʸ»ú¤Þ¤Ç¤·¤«»ÈÍѤǤ¤Ê¤¤¤Î¤ÇÃí°Õ¤·¤Æ²¼¤µ¤¤
*
- * TODO:
- * - ¥Í¡¼¥à¥¹¥Ú¡¼¥¹/¥¥ã¥Ã¥·¥å¥¡¼Ä¹¤Î¥¨¥é¡¼¥Ï¥ó¥É¥ê¥ó¥°
+ * TODO:
+ * - ¥Í¡¼¥à¥¹¥Ú¡¼¥¹/¥¥ã¥Ã¥·¥å¥¡¼Ä¹¤Î¥¨¥é¡¼¥Ï¥ó¥É¥ê¥ó¥°
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @package Ethna
+ * @version $Id$
*/
/**
- * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹(memcacheÈÇ)
+ * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹(memcacheÈÇ)
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Cachemanager_Memcache extends Ethna_Plugin_Cachemanager
{
- /**#@+ @access private */
+ /**#@+ @access private */
- /** @var object MemCache MemCache¥ª¥Ö¥¸¥§¥¯¥È */
- var $memcache = null;
+ /** @var object MemCache MemCache¥ª¥Ö¥¸¥§¥¯¥È */
+ var $memcache = null;
- /** @var bool °µ½Ì¥Õ¥é¥° */
- var $compress = true;
+ /** @var bool °µ½Ì¥Õ¥é¥° */
+ var $compress = true;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_Plugin_Cachemanager_Memcache¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- */
- function Ethna_Plugin_Cachemanager_Memcache()
- {
+ /**
+ * Ethna_Plugin_Cachemanager_Memcache¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ */
+ function Ethna_Plugin_Cachemanager_Memcache()
+ {
parent::Ethna_Plugin_Cachemanager();
- $this->memcache_pool = array();
- }
+ $this->memcache_pool = array();
+ }
/**
* memcache¥¥ã¥Ã¥·¥å¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¡¢¼èÆÀ¤¹¤ë
*
* @access protected
*/
- function _getMemcache($cache_key, $namespace = null)
- {
+ function _getMemcache($cache_key, $namespace = null)
+ {
$retry = $this->config->get('memcache_retry');
if ($retry == "") {
$retry = 3;
if ($timeout == "") {
$timeout = 3;
}
- $r = false;
+ $r = false;
- list($host, $port) = $this->_getMemcacheInfo($cache_key, $namespace);
- if (isset($this->memcache_pool["$host:$port"])) {
- // activate
- $this->memcache = $this->memcache_pool["$host:$port"];
- return $this->memcache;
- }
- $this->memcache_pool["$host:$port"] =& new MemCache();
+ list($host, $port) = $this->_getMemcacheInfo($cache_key, $namespace);
+ if (isset($this->memcache_pool["$host:$port"])) {
+ // activate
+ $this->memcache = $this->memcache_pool["$host:$port"];
+ return $this->memcache;
+ }
+ $this->memcache_pool["$host:$port"] =& new MemCache();
- while ($retry > 0) {
+ while ($retry > 0) {
if ($this->config->get('memcache_use_connect')) {
- $r = $this->memcache_pool["$host:$port"]->connect($host, $port, $timeout);
- } else {
- $r = $this->memcache_pool["$host:$port"]->pconnect($host, $port, $timeout);
- }
- if ($r) {
- break;
- }
- sleep(1);
- $retry--;
- }
- if ($r == false) {
- trigger_error("memcache: connection failed");
- $this->memcache_pool["$host:$port"] = null;
- }
-
- $this->memcache = $this->memcache_pool["$host:$port"];
- return $this->memcache;
- }
+ $r = $this->memcache_pool["$host:$port"]->connect($host, $port, $timeout);
+ } else {
+ $r = $this->memcache_pool["$host:$port"]->pconnect($host, $port, $timeout);
+ }
+ if ($r) {
+ break;
+ }
+ sleep(1);
+ $retry--;
+ }
+ if ($r == false) {
+ trigger_error("memcache: connection failed");
+ $this->memcache_pool["$host:$port"] = null;
+ }
+
+ $this->memcache = $this->memcache_pool["$host:$port"];
+ return $this->memcache;
+ }
/**
* memcacheÀܳ¾ðÊó¤ò¼èÆÀ¤¹¤ë
*
* @access protected
*/
- function _getMemcacheInfo($cache_key, $namespace)
- {
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ function _getMemcacheInfo($cache_key, $namespace)
+ {
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
$memcache_info = $this->config->get('memcache');
$default_memcache_host = $this->config->get('memcache_host');
if ($default_memcache_port == "") {
$default_memcache_port = 11211;
}
- if ($memcache_info == null || isset($memcache_info[$namespace]) == false) {
+ if ($memcache_info == null || isset($memcache_info[$namespace]) == false) {
return array($default_memcache_host, $default_memcache_port);
- }
+ }
- // namespace/cache_key¤ÇÀܳÀè¤ò·èÄê
+ // namespace/cache_key¤ÇÀܳÀè¤ò·èÄê
$n = count($memcache_info[$namespace]);
// TODO: make this pluggable
11211,
);
- // for safe
+ // for safe
return array($default_memcache_host, $default_memcache_port);
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¤ËÀßÄꤵ¤ì¤¿Ãͤò¼èÆÀ¤¹¤ë
- *
- * ¥¥ã¥Ã¥·¥å¤ËÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¥ã¥Ã¥·¥åÃÍ
- * ¤¬Ìá¤êÃͤȤʤ롣¥¥ã¥Ã¥·¥å¤ËÃͤ¬Ìµ¤¤¾ì¹ç¤älifetime
- * ¤ò²á¤®¤Æ¤¤¤ë¾ì¹ç¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏPEAR_Error
- * ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ìá¤êÃͤȤʤ롣
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return array ¥¥ã¥Ã¥·¥åÃÍ
- */
- function get($key, $lifetime = null, $namespace = null)
- {
- $this->_getMemcache($key, $namespace);
- if ($this->memcache == null) {
- return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
- }
-
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
-
- $cache_key = $this->_getCacheKey($namespace, $key);
- if ($cache_key == null) {
- return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
- }
-
- $value = $this->memcache->get($cache_key);
- if ($value == null) {
- return PEAR::raiseError('no such cache', E_CACHE_NO_VALUE);
- }
- $time = $value['time'];
- $data = $value['data'];
-
- // ¥é¥¤¥Õ¥¿¥¤¥à¥Á¥§¥Ã¥¯
- if (is_null($lifetime) == false) {
- if (($time+$lifetime) < time()) {
- return PEAR::raiseError('lifetime expired', E_CACHE_EXPIRED);
- }
- }
-
- return $data;
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¤ÎºÇ½ª¹¹¿·Æü»þ¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return int ºÇ½ª¹¹¿·Æü»þ(unixtime)
- */
- function getLastModified($key, $namespace = null)
- {
- $this->_getMemcache($key, $namespace);
- if ($this->memcache == null) {
- return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
- }
-
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
-
- $cache_key = $this->_getCacheKey($namespace, $key);
- if ($cache_key == null) {
- return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
- }
-
- $value = $this->memcache->get($cache_key);
-
- return $value['time'];
- }
-
- /**
- * Ãͤ¬¥¥ã¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function isCached($key, $lifetime = null, $namespace = null)
- {
- $r = $this->get($key, $lifetime, $namespace);
-
- return PEAR::isError($r) ? false: true;
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¤ËÃͤòÀßÄꤹ¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param mixed $value ¥¥ã¥Ã¥·¥åÃÍ
- * @param int $timestamp ¥¥ã¥Ã¥·¥åºÇ½ª¹¹¿·»þ¹ï(unixtime)
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function set($key, $value, $timestamp = null, $namespace = null)
- {
- $this->_getMemcache($key, $namespace);
- if ($this->memcache == null) {
- return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
- }
-
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
-
- $cache_key = $this->_getCacheKey($namespace, $key);
- if ($cache_key == null) {
- return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
- }
-
- $time = $timestamp ? $timestamp : time();
- $this->memcache->set($cache_key, array('time' => $time, 'data' => $value), $this->compress ? MEMCACHE_COMPRESSED : null);
- }
-
- /**
- * ¥¥ã¥Ã¥·¥åÃͤòºï½ü¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function clear($key, $namespace = null)
- {
- $this->_getMemcache($key, $namespace);
- if ($this->memcache == null) {
- return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
- }
-
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
-
- $cache_key = $this->_getCacheKey($namespace, $key);
- if ($cache_key == null) {
- return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
- }
-
- $this->memcache->delete($cache_key, -1);
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤ò¥í¥Ã¥¯¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $timeout ¥í¥Ã¥¯¥¿¥¤¥à¥¢¥¦¥È
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return bool true:À®¸ù false:¼ºÇÔ
- */
- function lock($key, $timeout = 5, $namespace = null)
- {
- $this->_getMemcache($key, $namespace);
- if ($this->memcache == null) {
- return PEAR::raiseError('memcache server not available', E_CACHE_LOCK_ERROR);
- }
-
- // ¥í¥Ã¥¯ÍÑ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤òÍøÍѤ¹¤ë
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
- $cache_key = "lock::" . $this->_getCacheKey($namespace, $key);
- $lock_lifetime = 30;
-
- do {
- $r = $this->memcache->add($cache_key, true, false, $lock_lifetime);
- if ($r != false) {
- break;
- }
- sleep(1);
- $timeout--;
- } while ($timeout > 0);
-
- if ($r == false) {
- return PEAR::raiseError('lock timeout', E_CACHE_LOCK_TIMEOUT);
- }
-
- return true;
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤Î¥í¥Ã¥¯¤ò²ò½ü¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return bool true:À®¸ù false:¼ºÇÔ
- */
- function unlock($key, $namespace = null)
- {
- $this->_getMemcache($key, $namespace);
- if ($this->memcache == null) {
- return PEAR::raiseError('memcache server not available', E_CACHE_LOCK_ERROR);
- }
-
- $namespace = is_null($namespace) ? $this->namespace : $namespace;
- $cache_key = "lock::" . $this->_getCacheKey($namespace, $key);
-
- $this->memcache->delete($cache_key, -1);
- }
-
- /**
- * ¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤«¤é¥¥ã¥Ã¥·¥å¥¡¼¤òÀ¸À®¤¹¤ë
- *
- * @access private
- */
- function _getCacheKey($namespace, $key)
- {
- // ¾¯¤·Íð˽¤À¤±¤É...
- $key = str_replace(":", "_", $key);
- $cache_key = $namespace . "::" . $key;
- if (strlen($cache_key) > 250) {
- return null;
- }
- return $cache_key;
- }
-
- /**
- * °µ½Ì¥Õ¥é¥°¤òΩ¤Æ¤ë
- *
- * MySQL¤Ê¤É¤¤¤¯¤Ä¤«¤Î»Ò¥¯¥é¥¹¤Ç͸ú
- *
- * @access public
- * @param bool $flag ¥Õ¥é¥°
- */
- function setCompress($flag) {
- $this->compress = $flag;
- }
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ËÀßÄꤵ¤ì¤¿Ãͤò¼èÆÀ¤¹¤ë
+ *
+ * ¥¥ã¥Ã¥·¥å¤ËÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¥ã¥Ã¥·¥åÃÍ
+ * ¤¬Ìá¤êÃͤȤʤ롣¥¥ã¥Ã¥·¥å¤ËÃͤ¬Ìµ¤¤¾ì¹ç¤älifetime
+ * ¤ò²á¤®¤Æ¤¤¤ë¾ì¹ç¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏPEAR_Error
+ * ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ìá¤êÃͤȤʤ롣
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return array ¥¥ã¥Ã¥·¥åÃÍ
+ */
+ function get($key, $lifetime = null, $namespace = null)
+ {
+ $this->_getMemcache($key, $namespace);
+ if ($this->memcache == null) {
+ return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
+ }
+
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+
+ $cache_key = $this->_getCacheKey($namespace, $key);
+ if ($cache_key == null) {
+ return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
+ }
+
+ $value = $this->memcache->get($cache_key);
+ if ($value == null) {
+ return PEAR::raiseError('no such cache', E_CACHE_NO_VALUE);
+ }
+ $time = $value['time'];
+ $data = $value['data'];
+
+ // ¥é¥¤¥Õ¥¿¥¤¥à¥Á¥§¥Ã¥¯
+ if (is_null($lifetime) == false) {
+ if (($time+$lifetime) < time()) {
+ return PEAR::raiseError('lifetime expired', E_CACHE_EXPIRED);
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ÎºÇ½ª¹¹¿·Æü»þ¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return int ºÇ½ª¹¹¿·Æü»þ(unixtime)
+ */
+ function getLastModified($key, $namespace = null)
+ {
+ $this->_getMemcache($key, $namespace);
+ if ($this->memcache == null) {
+ return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
+ }
+
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+
+ $cache_key = $this->_getCacheKey($namespace, $key);
+ if ($cache_key == null) {
+ return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
+ }
+
+ $value = $this->memcache->get($cache_key);
+
+ return $value['time'];
+ }
+
+ /**
+ * Ãͤ¬¥¥ã¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function isCached($key, $lifetime = null, $namespace = null)
+ {
+ $r = $this->get($key, $lifetime, $namespace);
+
+ return PEAR::isError($r) ? false: true;
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ËÃͤòÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param mixed $value ¥¥ã¥Ã¥·¥åÃÍ
+ * @param int $timestamp ¥¥ã¥Ã¥·¥åºÇ½ª¹¹¿·»þ¹ï(unixtime)
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function set($key, $value, $timestamp = null, $namespace = null)
+ {
+ $this->_getMemcache($key, $namespace);
+ if ($this->memcache == null) {
+ return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
+ }
+
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+
+ $cache_key = $this->_getCacheKey($namespace, $key);
+ if ($cache_key == null) {
+ return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
+ }
+
+ $time = $timestamp ? $timestamp : time();
+ $this->memcache->set($cache_key, array('time' => $time, 'data' => $value), $this->compress ? MEMCACHE_COMPRESSED : null);
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥åÃͤòºï½ü¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function clear($key, $namespace = null)
+ {
+ $this->_getMemcache($key, $namespace);
+ if ($this->memcache == null) {
+ return PEAR::raiseError('memcache server not available', E_CACHE_NO_VALUE);
+ }
+
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+
+ $cache_key = $this->_getCacheKey($namespace, $key);
+ if ($cache_key == null) {
+ return PEAR::raiseError('invalid cache key (too long?)', E_CACHE_NO_VALUE);
+ }
+
+ $this->memcache->delete($cache_key, -1);
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤ò¥í¥Ã¥¯¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $timeout ¥í¥Ã¥¯¥¿¥¤¥à¥¢¥¦¥È
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return bool true:À®¸ù false:¼ºÇÔ
+ */
+ function lock($key, $timeout = 5, $namespace = null)
+ {
+ $this->_getMemcache($key, $namespace);
+ if ($this->memcache == null) {
+ return PEAR::raiseError('memcache server not available', E_CACHE_LOCK_ERROR);
+ }
+
+ // ¥í¥Ã¥¯ÍÑ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤òÍøÍѤ¹¤ë
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ $cache_key = "lock::" . $this->_getCacheKey($namespace, $key);
+ $lock_lifetime = 30;
+
+ do {
+ $r = $this->memcache->add($cache_key, true, false, $lock_lifetime);
+ if ($r != false) {
+ break;
+ }
+ sleep(1);
+ $timeout--;
+ } while ($timeout > 0);
+
+ if ($r == false) {
+ return PEAR::raiseError('lock timeout', E_CACHE_LOCK_TIMEOUT);
+ }
+
+ return true;
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤Î¥í¥Ã¥¯¤ò²ò½ü¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return bool true:À®¸ù false:¼ºÇÔ
+ */
+ function unlock($key, $namespace = null)
+ {
+ $this->_getMemcache($key, $namespace);
+ if ($this->memcache == null) {
+ return PEAR::raiseError('memcache server not available', E_CACHE_LOCK_ERROR);
+ }
+
+ $namespace = is_null($namespace) ? $this->namespace : $namespace;
+ $cache_key = "lock::" . $this->_getCacheKey($namespace, $key);
+
+ $this->memcache->delete($cache_key, -1);
+ }
+
+ /**
+ * ¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤«¤é¥¥ã¥Ã¥·¥å¥¡¼¤òÀ¸À®¤¹¤ë
+ *
+ * @access private
+ */
+ function _getCacheKey($namespace, $key)
+ {
+ // ¾¯¤·Íð˽¤À¤±¤É...
+ $key = str_replace(":", "_", $key);
+ $cache_key = $namespace . "::" . $key;
+ if (strlen($cache_key) > 250) {
+ return null;
+ }
+ return $cache_key;
+ }
+
+ /**
+ * °µ½Ì¥Õ¥é¥°¤òΩ¤Æ¤ë
+ *
+ * MySQL¤Ê¤É¤¤¤¯¤Ä¤«¤Î»Ò¥¯¥é¥¹¤Ç͸ú
+ *
+ * @access public
+ * @param bool $flag ¥Õ¥é¥°
+ */
+ function setCompress($flag) {
+ $this->compress = $flag;
+ }
}
?>
<?php
// vim: foldmethod=marker tabstop=4 shiftwidth=4 autoindent
/**
- * Ethna_Plugin_Cachemanager.php
+ * Ethna_Plugin_Cachemanager.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
+ * @author Masaki Fujimoto <fujimoto@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @package Ethna
- * @version $Id$
+ * @version $Id$
*/
/**
- * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥×¥é¥°¥¤¥ó¥¯¥é¥¹
+ * ¥¥ã¥Ã¥·¥å¥Þ¥Í¡¼¥¸¥ã¥×¥é¥°¥¤¥ó¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Cachemanager
{
- /**#@+ @access private */
+ /**#@+ @access private */
- /** @var string ¸½ºß¤Î¥Í¡¼¥à¥¹¥Ú¡¼¥¹ */
- var $namespace = '';
+ /** @var string ¸½ºß¤Î¥Í¡¼¥à¥¹¥Ú¡¼¥¹ */
+ var $namespace = '';
- /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
- var $backend;
+ /** @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È */
+ var $backend;
- /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
- var $config;
+ /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
+ var $config;
- /**#@-*/
+ /**#@-*/
/**
* Ethna_Plugin_Cachemanager¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
$this->config =& $this->controller->getConfig();
}
- /**
- * ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return string ¸½ºß¤Î¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function getNamespace($namespace)
- {
- return $this->namespace;
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤òÀßÄꤹ¤ë
- *
- * @access public
- * @param string $namespace ¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function setNamespace($namespace)
- {
- $this->namespace = $namespace;
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¤ËÀßÄꤵ¤ì¤¿Ãͤò¼èÆÀ¤¹¤ë
- *
- * ¥¥ã¥Ã¥·¥å¤ËÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¥ã¥Ã¥·¥åÃÍ
- * ¤¬Ìá¤êÃͤȤʤ롣¥¥ã¥Ã¥·¥å¤ËÃͤ¬Ìµ¤¤¾ì¹ç¤älifetime
- * ¤ò²á¤®¤Æ¤¤¤ë¾ì¹ç¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏPEAR_Error
- * ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ìá¤êÃͤȤʤ롣
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return mixed ¥¥ã¥Ã¥·¥åÃÍ
- */
- function get($key, $lifetime = null, $namespace = null)
- {
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¤ÎºÇ½ª¹¹¿·Æü»þ¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return int ºÇ½ª¹¹¿·Æü»þ(unixtime)
- */
- function getLastModified($key, $namespace = null)
- {
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¤ËÃͤòÀßÄꤹ¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param mixed $value ¥¥ã¥Ã¥·¥åÃÍ
- * @param int $timestamp ¥¥ã¥Ã¥·¥åºÇ½ª¹¹¿·»þ¹ï(unixtime)
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function set($key, $value, $timestamp = null, $namespace = null)
- {
- }
-
- /**
- * Ãͤ¬¥¥ã¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function isCached($key, $timestamp = null, $namespace = null)
- {
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¤«¤éÃͤòºï½ü¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function clear($key, $namespace = null)
- {
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤ò¥í¥Ã¥¯¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param int $timeout ¥í¥Ã¥¯¥¿¥¤¥à¥¢¥¦¥È
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return bool true:À®¸ù false:¼ºÇÔ
- */
- function lock($key, $timeout = 5, $namespace = null)
- {
- return false;
- }
-
- /**
- * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤Î¥í¥Ã¥¯¤ò²ò½ü¤¹¤ë
- *
- * @access public
- * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
- * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- * @return bool true:À®¸ù false:¼ºÇÔ
- */
- function unlock($key, $namespace = null)
- {
- return false;
- }
-
- /**
- * °µ½Ì¥Õ¥é¥°¤òΩ¤Æ¤ë
- *
- * MySQL¤Ê¤É¤¤¤¯¤Ä¤«¤Î»Ò¥¯¥é¥¹¤Ç͸ú
- *
- * @access public
- * @param bool $flag ¥Õ¥é¥°
- */
- function setCompress($flag) {
- return false;
- }
+ /**
+ * ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return string ¸½ºß¤Î¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function getNamespace($namespace)
+ {
+ return $this->namespace;
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤òÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param string $namespace ¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function setNamespace($namespace)
+ {
+ $this->namespace = $namespace;
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ËÀßÄꤵ¤ì¤¿Ãͤò¼èÆÀ¤¹¤ë
+ *
+ * ¥¥ã¥Ã¥·¥å¤ËÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¥ã¥Ã¥·¥åÃÍ
+ * ¤¬Ìá¤êÃͤȤʤ롣¥¥ã¥Ã¥·¥å¤ËÃͤ¬Ìµ¤¤¾ì¹ç¤älifetime
+ * ¤ò²á¤®¤Æ¤¤¤ë¾ì¹ç¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏPEAR_Error
+ * ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ìá¤êÃͤȤʤ롣
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return mixed ¥¥ã¥Ã¥·¥åÃÍ
+ */
+ function get($key, $lifetime = null, $namespace = null)
+ {
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ÎºÇ½ª¹¹¿·Æü»þ¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return int ºÇ½ª¹¹¿·Æü»þ(unixtime)
+ */
+ function getLastModified($key, $namespace = null)
+ {
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¤ËÃͤòÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param mixed $value ¥¥ã¥Ã¥·¥åÃÍ
+ * @param int $timestamp ¥¥ã¥Ã¥·¥åºÇ½ª¹¹¿·»þ¹ï(unixtime)
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function set($key, $value, $timestamp = null, $namespace = null)
+ {
+ }
+
+ /**
+ * Ãͤ¬¥¥ã¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $lifetime ¥¥ã¥Ã¥·¥å͸ú´ü´Ö
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function isCached($key, $timestamp = null, $namespace = null)
+ {
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¤«¤éÃͤòºï½ü¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function clear($key, $namespace = null)
+ {
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤ò¥í¥Ã¥¯¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param int $timeout ¥í¥Ã¥¯¥¿¥¤¥à¥¢¥¦¥È
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return bool true:À®¸ù false:¼ºÇÔ
+ */
+ function lock($key, $timeout = 5, $namespace = null)
+ {
+ return false;
+ }
+
+ /**
+ * ¥¥ã¥Ã¥·¥å¥Ç¡¼¥¿¤Î¥í¥Ã¥¯¤ò²ò½ü¤¹¤ë
+ *
+ * @access public
+ * @param string $key ¥¥ã¥Ã¥·¥å¥¡¼
+ * @param string $namespace ¥¥ã¥Ã¥·¥å¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ * @return bool true:À®¸ù false:¼ºÇÔ
+ */
+ function unlock($key, $namespace = null)
+ {
+ return false;
+ }
+
+ /**
+ * °µ½Ì¥Õ¥é¥°¤òΩ¤Æ¤ë
+ *
+ * MySQL¤Ê¤É¤¤¤¯¤Ä¤«¤Î»Ò¥¯¥é¥¹¤Ç͸ú
+ *
+ * @access public
+ * @param bool $flag ¥Õ¥é¥°
+ */
+ function setCompress($flag) {
+ return false;
+ }
}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Logwriter.php
+ * Ethna_Plugin_Logwriter.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Logwriter
/**
- * ¥í¥°½ÐÎÏ´ðÄ쥯¥é¥¹
+ * ¥í¥°½ÐÎÏ´ðÄ쥯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Logwriter
{
- /**#@+
- * @access private
- */
-
- /** @var string ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó */
- var $ident;
-
- /** @var int ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£ */
- var $facility;
-
- /** @var int ¥í¥°¥ª¥×¥·¥ç¥ó */
- var $option;
-
- /** @var bool ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤¬¼èÆÀ²Äǽ¤«¤É¤¦¤« */
- var $have_backtrace;
-
- /** @var array ¥í¥°¥ì¥Ù¥ë̾¥Æ¡¼¥Ö¥ë */
- var $level_name_table = array(
- LOG_EMERG => 'EMERG',
- LOG_ALERT => 'ALERT',
- LOG_CRIT => 'CRIT',
- LOG_ERR => 'ERR',
- LOG_WARNING => 'WARNING',
- LOG_NOTICE => 'NOTICE',
- LOG_INFO => 'INFO',
- LOG_DEBUG => 'DEBUG',
- );
-
- /**#@-*/
-
- /**
- * Ethna_Plugin_Logwriter¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param string $log_ident ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó(¥×¥í¥»¥¹Ì¾Åù)
- * @param int $log_facility ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£
- * @param string $log_file ¥í¥°½ÐÎÏÀè¥Õ¥¡¥¤¥ë̾(LOG_FILE¥ª¥×¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î¤ß)
- * @param int $log_option ¥í¥°¥ª¥×¥·¥ç¥ó(LOG_FILE,LOG_FUNCTION...)
- */
- function Ethna_Plugin_Logwriter()
- {
- }
-
- /**
- * ¥í¥°¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë
- *
- * @access public
- * @param int $option ¥í¥°¥ª¥×¥·¥ç¥ó(LOG_FILE,LOG_FUNCTION...)
- */
- function setOption($option)
- {
- $this->ident = $option['ident'];
- $this->facility = $option['facility'];
- $this->option = $option;
- $this->have_backtrace = function_exists('debug_backtrace');
- }
-
- /**
- * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
- *
- * @access public
- */
- function begin()
- {
- }
-
- /**
- * ¥í¥°¤ò½ÐÎϤ¹¤ë
- *
- * @access public
- * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
- * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
- */
- function log($level, $message)
- {
- }
-
- /**
- * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
- *
- * @access public
- */
- function end()
- {
- }
-
- /**
- * ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return string ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó
- */
- function getIdent()
- {
- return $this->ident;
- }
-
- /**
- * ¥í¥°¥ì¥Ù¥ë¤òɽ¼¨Ê¸»úÎó¤ËÊÑ´¹¤¹¤ë
- *
- * @access private
- * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG,LOG_NOTICE...)
- * @return string ¥í¥°¥ì¥Ù¥ëɽ¼¨Ê¸»úÎó(LOG_DEBUG¢ª"DEBUG")
- */
- function _getLogLevelName($level)
- {
- if (isset($this->level_name_table[$level]) == false) {
- return null;
- }
- return $this->level_name_table[$level];
- }
-
- /**
- * ¥í¥°½ÐÎϲսê¤Î¾ðÊó(´Ø¿ô̾/¥Õ¥¡¥¤¥ë̾Åù)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return array ¥í¥°½ÐÎϲսê¤Î¾ðÊó
- */
- function _getBacktrace()
- {
- $skip_method_list = array(
- array('ethna', 'raise.*'),
- array(null, 'raiseerror'),
- array(null, 'handleerror'),
- array('ethna_logger', null),
- array('ethna_plugin_logwriter*', null),
- array('ethna_error', null),
- array('ethna_apperror', null),
- array('ethna_actionerror', null),
- array('ethna_backend', 'log'),
- array(null, 'ethna_error_handler'),
- array(null, 'trigger_error'),
- );
-
- if ($this->have_backtrace == false) {
- return null;
- }
-
- $bt = debug_backtrace();
- $i = 0;
- while ($i < count($bt)) {
- if (isset($bt[$i]['class']) == false) {
- $bt[$i]['class'] = null;
- }
- $skip = false;
-
- // ¥á¥½¥Ã¥É¥¹¥¥Ã¥×½èÍý
- foreach ($skip_method_list as $method) {
- $class = $function = true;
- if ($method[0] != null) {
- $class = preg_match("/$method[0]/i", $bt[$i]['class']);
- }
- if ($method[1] != null) {
- $function = preg_match("/$method[1]/i", $bt[$i]['function']);
- }
- if ($class && $function) {
- $skip = true;
- break;
- }
- }
-
- if ($skip) {
- $i++;
- } else {
- break;
- }
- }
-
- $c =& Ethna_Controller::getInstance();
- $basedir = $c->getBasedir();
-
- $function = sprintf("%s.%s", isset($bt[$i]['class']) ? $bt[$i]['class'] : 'global', $bt[$i]['function']);
-
- $file = $bt[$i]['file'];
- if (strncmp($file, $basedir, strlen($basedir)) == 0) {
- $file = substr($file, strlen($basedir));
- }
- if (strncmp($file, ETHNA_BASE, strlen(ETHNA_BASE)) == 0) {
- $file = preg_replace('#^/+#', '', substr($file, strlen(ETHNA_BASE)));
- }
- $line = $bt[$i]['line'];
- return array('function' => $function, 'pos' => sprintf('%s:%s', $file, $line));
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var string ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó */
+ var $ident;
+
+ /** @var int ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£ */
+ var $facility;
+
+ /** @var int ¥í¥°¥ª¥×¥·¥ç¥ó */
+ var $option;
+
+ /** @var bool ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤¬¼èÆÀ²Äǽ¤«¤É¤¦¤« */
+ var $have_backtrace;
+
+ /** @var array ¥í¥°¥ì¥Ù¥ë̾¥Æ¡¼¥Ö¥ë */
+ var $level_name_table = array(
+ LOG_EMERG => 'EMERG',
+ LOG_ALERT => 'ALERT',
+ LOG_CRIT => 'CRIT',
+ LOG_ERR => 'ERR',
+ LOG_WARNING => 'WARNING',
+ LOG_NOTICE => 'NOTICE',
+ LOG_INFO => 'INFO',
+ LOG_DEBUG => 'DEBUG',
+ );
+
+ /**#@-*/
+
+ /**
+ * Ethna_Plugin_Logwriter¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param string $log_ident ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó(¥×¥í¥»¥¹Ì¾Åù)
+ * @param int $log_facility ¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£
+ * @param string $log_file ¥í¥°½ÐÎÏÀè¥Õ¥¡¥¤¥ë̾(LOG_FILE¥ª¥×¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î¤ß)
+ * @param int $log_option ¥í¥°¥ª¥×¥·¥ç¥ó(LOG_FILE,LOG_FUNCTION...)
+ */
+ function Ethna_Plugin_Logwriter()
+ {
+ }
+
+ /**
+ * ¥í¥°¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param int $option ¥í¥°¥ª¥×¥·¥ç¥ó(LOG_FILE,LOG_FUNCTION...)
+ */
+ function setOption($option)
+ {
+ $this->ident = $option['ident'];
+ $this->facility = $option['facility'];
+ $this->option = $option;
+ $this->have_backtrace = function_exists('debug_backtrace');
+ }
+
+ /**
+ * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
+ *
+ * @access public
+ */
+ function begin()
+ {
+ }
+
+ /**
+ * ¥í¥°¤ò½ÐÎϤ¹¤ë
+ *
+ * @access public
+ * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
+ * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
+ */
+ function log($level, $message)
+ {
+ }
+
+ /**
+ * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
+ *
+ * @access public
+ */
+ function end()
+ {
+ }
+
+ /**
+ * ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return string ¥í¥°¥¢¥¤¥Ç¥ó¥Æ¥£¥Æ¥£Ê¸»úÎó
+ */
+ function getIdent()
+ {
+ return $this->ident;
+ }
+
+ /**
+ * ¥í¥°¥ì¥Ù¥ë¤òɽ¼¨Ê¸»úÎó¤ËÊÑ´¹¤¹¤ë
+ *
+ * @access private
+ * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG,LOG_NOTICE...)
+ * @return string ¥í¥°¥ì¥Ù¥ëɽ¼¨Ê¸»úÎó(LOG_DEBUG¢ª"DEBUG")
+ */
+ function _getLogLevelName($level)
+ {
+ if (isset($this->level_name_table[$level]) == false) {
+ return null;
+ }
+ return $this->level_name_table[$level];
+ }
+
+ /**
+ * ¥í¥°½ÐÎϲսê¤Î¾ðÊó(´Ø¿ô̾/¥Õ¥¡¥¤¥ë̾Åù)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return array ¥í¥°½ÐÎϲսê¤Î¾ðÊó
+ */
+ function _getBacktrace()
+ {
+ $skip_method_list = array(
+ array('ethna', 'raise.*'),
+ array(null, 'raiseerror'),
+ array(null, 'handleerror'),
+ array('ethna_logger', null),
+ array('ethna_plugin_logwriter*', null),
+ array('ethna_error', null),
+ array('ethna_apperror', null),
+ array('ethna_actionerror', null),
+ array('ethna_backend', 'log'),
+ array(null, 'ethna_error_handler'),
+ array(null, 'trigger_error'),
+ );
+
+ if ($this->have_backtrace == false) {
+ return null;
+ }
+
+ $bt = debug_backtrace();
+ $i = 0;
+ while ($i < count($bt)) {
+ if (isset($bt[$i]['class']) == false) {
+ $bt[$i]['class'] = null;
+ }
+ $skip = false;
+
+ // ¥á¥½¥Ã¥É¥¹¥¥Ã¥×½èÍý
+ foreach ($skip_method_list as $method) {
+ $class = $function = true;
+ if ($method[0] != null) {
+ $class = preg_match("/$method[0]/i", $bt[$i]['class']);
+ }
+ if ($method[1] != null) {
+ $function = preg_match("/$method[1]/i", $bt[$i]['function']);
+ }
+ if ($class && $function) {
+ $skip = true;
+ break;
+ }
+ }
+
+ if ($skip) {
+ $i++;
+ } else {
+ break;
+ }
+ }
+
+ $c =& Ethna_Controller::getInstance();
+ $basedir = $c->getBasedir();
+
+ $function = sprintf("%s.%s", isset($bt[$i]['class']) ? $bt[$i]['class'] : 'global', $bt[$i]['function']);
+
+ $file = $bt[$i]['file'];
+ if (strncmp($file, $basedir, strlen($basedir)) == 0) {
+ $file = substr($file, strlen($basedir));
+ }
+ if (strncmp($file, ETHNA_BASE, strlen(ETHNA_BASE)) == 0) {
+ $file = preg_replace('#^/+#', '', substr($file, strlen(ETHNA_BASE)));
+ }
+ $line = $bt[$i]['line'];
+ return array('function' => $function, 'pos' => sprintf('%s:%s', $file, $line));
+ }
}
// }}}
?>
* @param mixed $var ¥Õ¥©¡¼¥à¤ÎÃÍ
* @param array $params ¥×¥é¥°¥¤¥ó¤Î¥Ñ¥é¥á¡¼¥¿
*/
- function &validate($name, $var, $params)
+ function &validate($name, $var, $params)
{
die('override!');
}
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Handle_AddAction.php
+ * Ethna_Plugin_Handle_AddAction.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Handle_AddAction
/**
* add-action handler
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddAction extends Ethna_Plugin_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Handle_AddActionCli.php
+ * Ethna_Plugin_Handle_AddActionCli.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
include_once(ETHNA_BASE . '/class/Plugin/Handle/Ethna_Plugin_Handle_AddAction.php');
/**
* add-action handler
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddActionCli extends Ethna_Plugin_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Handle_AddActionXmlrpc.php
+ * Ethna_Plugin_Handle_AddActionXmlrpc.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
include_once(ETHNA_BASE . '/class/Plugin/Handle/Ethna_Plugin_Handle_AddAction.php');
/**
* add-action handler
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddActionXmlrpc extends Ethna_Plugin_Handle
{
<?php
/**
- * Ethna_Plugin_Handle_AddAppManager.php
+ * Ethna_Plugin_Handle_AddAppManager.php
*
- * @author nozzzzz <nozzzzz@gmail.com>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author nozzzzz <nozzzzz@gmail.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Handle_AddAppManager
/**
* add-app-manager handler
*
- * @author nozzzzz <nozzzzz@gmail.com>
- * @access public
- * @package Ethna
+ * @author nozzzzz <nozzzzz@gmail.com>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddAppManager extends Ethna_Plugin_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Handle_AddAppObject.php
+ * Ethna_Plugin_Handle_AddAppObject.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Handle_AddAppObject
/**
* add-app-object handler
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddAppObject extends Ethna_Plugin_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Handle_AddProject.php
+ * Ethna_Plugin_Handle_AddProject.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Handle_AddProject
/**
* add-project handler
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddProject extends Ethna_Plugin_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Handle_AddTemplate.php
+ * Ethna_Plugin_Handle_AddTemplate.php
*
- * @author nnno <nnno@nnno.jp>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
+ * @author nnno <nnno@nnno.jp>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
*/
// {{{ Ethna_Plugin_Handle_AddTemplate
/**
* add-template handler
*
- * @author nnno <nnno@nnno.jp>
- * @access public
- * @package Ethna
+ * @author nnno <nnno@nnno.jp>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddTemplate extends Ethna_Plugin_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Handle_AddView.php
+ * Ethna_Plugin_Handle_AddView.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Handle_AddView
/**
* add-view handler
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Handle_AddView extends Ethna_Plugin_Handle
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Logwriter_Default.php
+ * Ethna_Plugin_Logwriter_Default.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Logwriter_Default
/**
- * ¥í¥°½ÐÎÏ´ðÄ쥯¥é¥¹
+ * ¥í¥°½ÐÎÏ´ðÄ쥯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Logwriter_Default extends Ethna_Plugin_Logwriter
{
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Logwriter_Echo.php
+ * Ethna_Plugin_Logwriter_Echo.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Logwriter_Echo
/**
- * ¥í¥°½ÐÎÏ´ðÄ쥯¥é¥¹
+ * ¥í¥°½ÐÎÏ´ðÄ쥯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Logwriter_Echo extends Ethna_Plugin_Logwriter
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /**#@-*/
+ /**#@-*/
- /**
- * ¥í¥°¤ò½ÐÎϤ¹¤ë
- *
- * @access public
- * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
- * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
- */
- function log($level, $message)
- {
- $c =& Ethna_Controller::getInstance();
+ /**
+ * ¥í¥°¤ò½ÐÎϤ¹¤ë
+ *
+ * @access public
+ * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
+ * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
+ */
+ function log($level, $message)
+ {
+ $c =& Ethna_Controller::getInstance();
- $prefix = $this->ident;
- if (array_key_exists("pid", $this->option)) {
- $prefix .= sprintf('[%d]', getmypid());
- }
- $prefix .= sprintf($c->getGateway() != GATEWAY_WWW ? '(%s): ' : '(<b>%s</b>): ',
- $this->_getLogLevelName($level)
- );
+ $prefix = $this->ident;
+ if (array_key_exists("pid", $this->option)) {
+ $prefix .= sprintf('[%d]', getmypid());
+ }
+ $prefix .= sprintf($c->getGateway() != GATEWAY_WWW ? '(%s): ' : '(<b>%s</b>): ',
+ $this->_getLogLevelName($level)
+ );
if (array_key_exists("function", $this->option) ||
array_key_exists("pos", $this->option)) {
- $tmp = "";
- $bt = $this->_getBacktrace();
+ $tmp = "";
+ $bt = $this->_getBacktrace();
if ($bt && array_key_exists("function", $this->option) && $bt['function']) {
- $tmp .= $bt['function'];
- }
+ $tmp .= $bt['function'];
+ }
if ($bt && array_key_exists("pos", $this->option) && $bt['pos']) {
- $tmp .= $tmp ? sprintf('(%s)', $bt['pos']) : $bt['pos'];
- }
- if ($tmp) {
- $prefix .= $tmp . ": ";
- }
- }
+ $tmp .= $tmp ? sprintf('(%s)', $bt['pos']) : $bt['pos'];
+ }
+ if ($tmp) {
+ $prefix .= $tmp . ": ";
+ }
+ }
- printf($prefix . $message . "%s\n", $c->getGateway() != GATEWAY_WWW ? "" : "<br />");
+ printf($prefix . $message . "%s\n", $c->getGateway() != GATEWAY_WWW ? "" : "<br />");
- return $prefix . $message;
- }
+ return $prefix . $message;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Logwriter_File.php
+ * Ethna_Plugin_Logwriter_File.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Logwriter_File
/**
- * ¥í¥°½ÐÎÏ¥¯¥é¥¹(File)
+ * ¥í¥°½ÐÎÏ¥¯¥é¥¹(File)
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Logwriter_File extends Ethna_Plugin_Logwriter
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var int ¥í¥°¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë */
- var $fp;
+ /** @var int ¥í¥°¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë */
+ var $fp;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_Plugin_Logwriter_File¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- */
- function Ethna_Plugin_Logwriter_File()
- {
- $this->fp = null;
- }
+ /**
+ * Ethna_Plugin_Logwriter_File¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ */
+ function Ethna_Plugin_Logwriter_File()
+ {
+ $this->fp = null;
+ }
- /**
- * ¥í¥°¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë
- *
- * @access public
- * @param int $option ¥í¥°¥ª¥×¥·¥ç¥ó(LOG_FILE,LOG_FUNCTION...)
- */
- function setOption($option)
- {
- parent::setOption($option);
+ /**
+ * ¥í¥°¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë
+ *
+ * @access public
+ * @param int $option ¥í¥°¥ª¥×¥·¥ç¥ó(LOG_FILE,LOG_FUNCTION...)
+ */
+ function setOption($option)
+ {
+ parent::setOption($option);
if (isset($option['file'])) {
$this->file = $option['file'];
} else {
$this->file = $this->_getLogFile();
}
- }
+ }
- /**
- * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
- *
- * @access public
- */
- function begin()
- {
- $this->fp = fopen($this->file, 'a');
- }
+ /**
+ * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
+ *
+ * @access public
+ */
+ function begin()
+ {
+ $this->fp = fopen($this->file, 'a');
+ }
- /**
- * ¥í¥°¤ò½ÐÎϤ¹¤ë
- *
- * @access public
- * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
- * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
- */
- function log($level, $message)
- {
- if ($this->fp == null) {
- return;
- }
+ /**
+ * ¥í¥°¤ò½ÐÎϤ¹¤ë
+ *
+ * @access public
+ * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
+ * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
+ */
+ function log($level, $message)
+ {
+ if ($this->fp == null) {
+ return;
+ }
- $prefix = strftime('%Y/%m/%d %H:%M:%S ') . $this->ident;
- if (array_key_exists("pid", $this->option)) {
- $prefix .= sprintf('[%d]', getmypid());
- }
- $prefix .= sprintf('(%s): ', $this->_getLogLevelName($level));
- if (array_key_exists("function", $this->option) ||
+ $prefix = strftime('%Y/%m/%d %H:%M:%S ') . $this->ident;
+ if (array_key_exists("pid", $this->option)) {
+ $prefix .= sprintf('[%d]', getmypid());
+ }
+ $prefix .= sprintf('(%s): ', $this->_getLogLevelName($level));
+ if (array_key_exists("function", $this->option) ||
array_key_exists("pos", $this->option)) {
- $tmp = "";
- $bt = $this->_getBacktrace();
- if ($bt && array_key_exists("function", $this->option) && $bt['function']) {
- $tmp .= $bt['function'];
- }
- if ($bt && array_key_exists("pos", $this->option) && $bt['pos']) {
- $tmp .= $tmp ? sprintf('(%s)', $bt['pos']) : $bt['pos'];
- }
- if ($tmp) {
- $prefix .= $tmp . ": ";
- }
- }
- fwrite($this->fp, $prefix . $message . "\n");
+ $tmp = "";
+ $bt = $this->_getBacktrace();
+ if ($bt && array_key_exists("function", $this->option) && $bt['function']) {
+ $tmp .= $bt['function'];
+ }
+ if ($bt && array_key_exists("pos", $this->option) && $bt['pos']) {
+ $tmp .= $tmp ? sprintf('(%s)', $bt['pos']) : $bt['pos'];
+ }
+ if ($tmp) {
+ $prefix .= $tmp . ": ";
+ }
+ }
+ fwrite($this->fp, $prefix . $message . "\n");
- return $prefix . $message;
- }
+ return $prefix . $message;
+ }
- /**
- * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
- *
- * @access public
- */
- function end()
- {
- if ($this->fp) {
- fclose($this->fp);
- $this->fp = null;
- }
- }
+ /**
+ * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
+ *
+ * @access public
+ */
+ function end()
+ {
+ if ($this->fp) {
+ fclose($this->fp);
+ $this->fp = null;
+ }
+ }
- /**
- * ¥í¥°¥Õ¥¡¥¤¥ë¤Î½ñ¤½Ð¤·Àè¤ò¼èÆÀ¤¹¤ë(¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£¤Ë
- * LOG_FILE¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î¤ß͸ú)
- *
- * ¥í¥°¥Õ¥¡¥¤¥ë¤Î½ñ¤½Ð¤·Àè¤òÊѹ¹¤·¤¿¤¤¾ì¹ç¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò
- * ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Þ¤¹
- *
- * @access protected
- * @return string ¥í¥°¥Õ¥¡¥¤¥ë¤Î½ñ¤½Ð¤·Àè
- */
- function _getLogFile()
- {
+ /**
+ * ¥í¥°¥Õ¥¡¥¤¥ë¤Î½ñ¤½Ð¤·Àè¤ò¼èÆÀ¤¹¤ë(¥í¥°¥Õ¥¡¥·¥ê¥Æ¥£¤Ë
+ * LOG_FILE¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î¤ß͸ú)
+ *
+ * ¥í¥°¥Õ¥¡¥¤¥ë¤Î½ñ¤½Ð¤·Àè¤òÊѹ¹¤·¤¿¤¤¾ì¹ç¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò
+ * ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Þ¤¹
+ *
+ * @access protected
+ * @return string ¥í¥°¥Õ¥¡¥¤¥ë¤Î½ñ¤½Ð¤·Àè
+ */
+ function _getLogFile()
+ {
$controller =& Ethna_Controller::getInstance();
if (array_key_exists("dir", $this->option)) {
$dir = $this->option['dir'];
} else {
- $dir = $controller->getDirectory('log');
+ $dir = $controller->getDirectory('log');
}
- return sprintf('%s/%s.log',
- $dir,
- strtolower($controller->getAppid())
- );
- }
+ return sprintf('%s/%s.log',
+ $dir,
+ strtolower($controller->getAppid())
+ );
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Logwriter_Syslog.php
+ * Ethna_Plugin_Logwriter_Syslog.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Logwriter_Syslog
/**
- * ¥í¥°½ÐÎÏ¥¯¥é¥¹(Syslog)
+ * ¥í¥°½ÐÎÏ¥¯¥é¥¹(Syslog)
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_Plugin_Logwriter_Syslog extends Ethna_Plugin_Logwriter
{
- /**
- * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
- *
- * @access public
- */
- function begin()
- {
- // syslogÍÑ¥ª¥×¥·¥ç¥ó¤Î¤ß¤ò»ØÄê
+ /**
+ * ¥í¥°½ÐÎϤò³«»Ï¤¹¤ë
+ *
+ * @access public
+ */
+ function begin()
+ {
+ // syslogÍÑ¥ª¥×¥·¥ç¥ó¤Î¤ß¤ò»ØÄê
if (array_key_exists("pid", $this->option)) {
$option = $this->option & (LOG_PID);
}
- openlog($this->ident, $option, $this->facility);
- }
+ openlog($this->ident, $option, $this->facility);
+ }
- /**
- * ¥í¥°¤ò½ÐÎϤ¹¤ë
- *
- * @access public
- * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
- * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
- */
- function log($level, $message)
- {
- $prefix = sprintf('%s: ', $this->_getLogLevelName($level));
+ /**
+ * ¥í¥°¤ò½ÐÎϤ¹¤ë
+ *
+ * @access public
+ * @param int $level ¥í¥°¥ì¥Ù¥ë(LOG_DEBUG, LOG_NOTICE...)
+ * @param string $message ¥í¥°¥á¥Ã¥»¡¼¥¸(+°ú¿ô)
+ */
+ function log($level, $message)
+ {
+ $prefix = sprintf('%s: ', $this->_getLogLevelName($level));
if (array_key_exists("function", $this->option) ||
array_key_exists("pos", $this->option)) {
- $tmp = "";
- $bt = $this->_getBacktrace();
- if ($bt && array_key_exists("function", $this->option) && $bt['function']) {
- $tmp .= $bt['function'];
- }
- if ($bt && array_key_exists("pos", $this->option) && $bt['pos']) {
- $tmp .= $tmp ? sprintf('(%s)', $bt['pos']) : $bt['pos'];
- }
- if ($tmp) {
- $prefix .= $tmp . ": ";
- }
- }
- syslog($level, $prefix . $message);
+ $tmp = "";
+ $bt = $this->_getBacktrace();
+ if ($bt && array_key_exists("function", $this->option) && $bt['function']) {
+ $tmp .= $bt['function'];
+ }
+ if ($bt && array_key_exists("pos", $this->option) && $bt['pos']) {
+ $tmp .= $tmp ? sprintf('(%s)', $bt['pos']) : $bt['pos'];
+ }
+ if ($tmp) {
+ $prefix .= $tmp . ": ";
+ }
+ }
+ syslog($level, $prefix . $message);
- return $prefix . $message;
- }
+ return $prefix . $message;
+ }
- /**
- * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
- *
- * @access public
- */
- function end()
- {
- closelog();
- }
+ /**
+ * ¥í¥°½ÐÎϤò½ªÎ»¤¹¤ë
+ *
+ * @access public
+ */
+ function end()
+ {
+ closelog();
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Validator_Custom.php
+ * Ethna_Plugin_Validator_Custom.php
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Validator_Custom
/**
- * custom¥Ð¥ê¥Ç¡¼¥¿¤Î¥é¥Ã¥Ñ¡¼¥×¥é¥°¥¤¥ó
+ * custom¥Ð¥ê¥Ç¡¼¥¿¤Î¥é¥Ã¥Ñ¡¼¥×¥é¥°¥¤¥ó
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
* @access public
* @param mixed $var ¥Õ¥©¡¼¥à¤ÎÃÍ
* @param array $params ¥×¥é¥°¥¤¥ó¤Î¥Ñ¥é¥á¡¼¥¿
*/
- function &validate($name, $var, $params)
- {
+ function &validate($name, $var, $params)
+ {
$true = true;
$method_list = preg_split('/\s*,\s*/', $params['custom'], -1, PREG_SPLIT_NO_EMPTY);
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Validator_File.php
+ * Ethna_Plugin_Validator_File.php
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// UPLOAD_ERR_* ¤¬Ì¤ÄêµÁ¤Î¾ì¹ç
// {{{ Ethna_Plugin_Validator_File
/**
- * ¥Õ¥¡¥¤¥ë¥Á¥§¥Ã¥¯¥×¥é¥°¥¤¥ó
+ * ¥Õ¥¡¥¤¥ë¥Á¥§¥Ã¥¯¥×¥é¥°¥¤¥ó
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
* @access public
* @param mixed $var ¥Õ¥©¡¼¥à¤ÎÃÍ
* @param array $params ¥×¥é¥°¥¤¥ó¤Î¥Ñ¥é¥á¡¼¥¿
*/
- function &validate($name, $var, $params)
- {
+ function &validate($name, $var, $params)
+ {
$true = true;
if ($this->getFormType($name) != VAR_TYPE_FILE) {
return $true;
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Validator_Max.php
+ * Ethna_Plugin_Validator_Max.php
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Validator_Max
/**
- * ºÇÂçÃÍ¥Á¥§¥Ã¥¯¥×¥é¥°¥¤¥ó
+ * ºÇÂçÃÍ¥Á¥§¥Ã¥¯¥×¥é¥°¥¤¥ó
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
* @access public
* @param mixed $var ¥Õ¥©¡¼¥à¤ÎÃÍ
* @param array $params ¥×¥é¥°¥¤¥ó¤Î¥Ñ¥é¥á¡¼¥¿
*/
- function &validate($name, $var, $params)
- {
+ function &validate($name, $var, $params)
+ {
$true = true;
$type = $this->getFormType($name);
if (isset($params['max']) == false || $this->isEmpty($var, $type)) {
* @param mixed $var ¥Õ¥©¡¼¥à¤ÎÃÍ
* @param array $params ¥×¥é¥°¥¤¥ó¤Î¥Ñ¥é¥á¡¼¥¿
*/
- function &validate($name, $var, $params)
- {
+ function &validate($name, $var, $params)
+ {
$true = true;
$type = $this->getFormType($name);
if (isset($params['regex']) == false
* @param mixed $var ¥Õ¥©¡¼¥à¤ÎÃÍ
* @param array $params ¥×¥é¥°¥¤¥ó¤Î¥Ñ¥é¥á¡¼¥¿
*/
- function &validate($name, $var, $params)
- {
+ function &validate($name, $var, $params)
+ {
$true = true;
if (isset($params['required']) && $params['required'] == false) {
return $true;
<?php
// vim: foldmethod=marker
/**
- * Ethna_Plugin_Validator_Type.php
+ * Ethna_Plugin_Validator_Type.php
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_Plugin_Validator_Type
/**
- * ¥¿¥¤¥×¥Á¥§¥Ã¥¯¥×¥é¥°¥¤¥ó
+ * ¥¿¥¤¥×¥Á¥§¥Ã¥¯¥×¥é¥°¥¤¥ó
*
* @author ICHII Takashi <ichii386@schweetheart.jp>
* @access public
* @param mixed $var ¥Õ¥©¡¼¥à¤ÎÃÍ
* @param array $params ¥×¥é¥°¥¤¥ó¤Î¥Ñ¥é¥á¡¼¥¿
*/
- function &validate($name, $var, $params)
- {
+ function &validate($name, $var, $params)
+ {
$true = true;
$type = $params['type'];
if ($type == VAR_TYPE_FILE || $this->isEmpty($var, $type)) {
$this->setPlugin('form_input','function','smarty_function_form_input');
// default blocks
- $this->setPlugin('form','block','smarty_block_form');
+ $this->setPlugin('form','block','smarty_block_form');
}
/**
// ¥Õ¥£¥ë¥¿¤Ï̾Á°¤Ê¤·¤ÇÅÐÏ¿
if ($type == 'prefilter' || $type == 'postfilter' || $type == 'outputfilter') {
- parent::setPlugin($name,$type,$plugin);
+ parent::setPlugin($name,$type,$plugin);
$this->engine->$register_method($plugin);
return;
}
<?php
// vim: foldmethod=marker
/**
- * Ethna_SOAP_ActionForm.php
+ * Ethna_SOAP_ActionForm.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_SOAP_ActionForm
/**
- * SOAP¥Õ¥©¡¼¥à¥¯¥é¥¹
+ * SOAP¥Õ¥©¡¼¥à¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_SOAP_ActionForm extends Ethna_ActionForm
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var array °ú¿ôÄêµÁ */
- var $arg = array();
+ /** @var array °ú¿ôÄêµÁ */
+ var $arg = array();
- /** @var array Ìá¤êÃÍÄêµÁ */
- var $retval = array();
+ /** @var array Ìá¤êÃÍÄêµÁ */
+ var $retval = array();
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_SOAP_ActionForm¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- * @param object Ethna_ActionError $action_error ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È
- */
- function Ethna_SOAP_ActionForm(&$action_error)
- {
- $this->form =& $this->arg;
+ /**
+ * Ethna_SOAP_ActionForm¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ * @param object Ethna_ActionError $action_error ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È
+ */
+ function Ethna_SOAP_ActionForm(&$action_error)
+ {
+ $this->form =& $this->arg;
- parent::Ethna_ActionForm($action_error);
- }
+ parent::Ethna_ActionForm($action_error);
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_SOAP_Gateway.php
+ * Ethna_SOAP_Gateway.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_SOAP_Gateway
/**
- * SOAP¥²¡¼¥È¥¦¥§¥¤¤Î´ðÄ쥯¥é¥¹
+ * SOAP¥²¡¼¥È¥¦¥§¥¤¤Î´ðÄ쥯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_SOAP_Gateway
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
- /**#@-*/
+ /**#@-*/
- /**
- * Ethna_SOAP_Gateway¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- */
- function Ethna_SOAP_Gateway()
- {
- $this->controller =& Ethna_Controller::getInstance();
- }
+ /**
+ * Ethna_SOAP_Gateway¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ */
+ function Ethna_SOAP_Gateway()
+ {
+ $this->controller =& Ethna_Controller::getInstance();
+ }
- /**
- * SOAP¥¢¥¯¥·¥ç¥ó¤ò¼Â¹Ô¤¹¤ë
- *
- * @access public
- */
- function dispatch()
- {
- $this->controller->trigger();
- }
+ /**
+ * SOAP¥¢¥¯¥·¥ç¥ó¤ò¼Â¹Ô¤¹¤ë
+ *
+ * @access public
+ */
+ function dispatch()
+ {
+ $this->controller->trigger();
+ }
- /**
- * ¥¢¥×¥ê¥±¡¼¥·¥ç¥óÀßÄêÃÍ°ìÍ÷¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return array ¥¢¥×¥ê¥±¡¼¥·¥ç¥óÀßÄêÃÍ°ìÍ÷
- */
- function &getApp()
- {
- $action_form =& $this->controller->getActionForm();
- return $action_form->app_vars;
- }
+ /**
+ * ¥¢¥×¥ê¥±¡¼¥·¥ç¥óÀßÄêÃÍ°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return array ¥¢¥×¥ê¥±¡¼¥·¥ç¥óÀßÄêÃÍ°ìÍ÷
+ */
+ function &getApp()
+ {
+ $action_form =& $this->controller->getActionForm();
+ return $action_form->app_vars;
+ }
- /**
- * ¥¨¥é¡¼¥³¡¼¥É¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return int ¥¨¥é¡¼¥³¡¼¥É(null¤Ê¤é¥¨¥é¡¼Ìµ¤·)
- */
- function getErrorCode()
- {
- $action_error =& $this->controller->getActionError();
- if ($action_error->count() == 0) {
- return null;
- }
-
- // ºÇ½é¤Î1¤Ä¤òÊÖ¤¹
- $error_list = $action_error->getErrorList();
- $error =& $error_list[0];
+ /**
+ * ¥¨¥é¡¼¥³¡¼¥É¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return int ¥¨¥é¡¼¥³¡¼¥É(null¤Ê¤é¥¨¥é¡¼Ìµ¤·)
+ */
+ function getErrorCode()
+ {
+ $action_error =& $this->controller->getActionError();
+ if ($action_error->count() == 0) {
+ return null;
+ }
+
+ // ºÇ½é¤Î1¤Ä¤òÊÖ¤¹
+ $error_list = $action_error->getErrorList();
+ $error =& $error_list[0];
- return $error->getCode();
- }
+ return $error->getCode();
+ }
- /**
- * ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸(null¤Ê¤é¥¨¥é¡¼Ìµ¤·)
- */
- function getErrorMessage()
- {
- $action_error =& $this->controller->getActionError();
- if ($action_error->count() == 0) {
- return null;
- }
+ /**
+ * ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return string ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸(null¤Ê¤é¥¨¥é¡¼Ìµ¤·)
+ */
+ function getErrorMessage()
+ {
+ $action_error =& $this->controller->getActionError();
+ if ($action_error->count() == 0) {
+ return null;
+ }
- // ºÇ½é¤Î1¤Ä¤òÊÖ¤¹
- $message_list = $action_error->getMessageList();
- $message = $message_list[0];
+ // ºÇ½é¤Î1¤Ä¤òÊÖ¤¹
+ $message_list = $action_error->getMessageList();
+ $message = $message_list[0];
- return $message;
- }
+ return $message;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_SOAP_GatewayGenerator.php
+ * Ethna_SOAP_GatewayGenerator.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_SOAP_GatewayGenerator
/**
- * »ØÄꤵ¤ì¤¿¥³¥ó¥È¥í¡¼¥é¤ËÂбþ¤¹¤ë¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É¤òÀ¸À®¤¹¤ë¥¯¥é¥¹
+ * »ØÄꤵ¤ì¤¿¥³¥ó¥È¥í¡¼¥é¤ËÂбþ¤¹¤ë¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É¤òÀ¸À®¤¹¤ë¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_SOAP_GatewayGenerator
{
- /**#@+
- * @access private
- */
-
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
-
- /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
- var $config;
-
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_error;
-
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $ae;
-
- /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É */
- var $gateway;
-
- /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¼±ÊÌ̾ */
- var $name;
-
- /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥Í¡¼¥à¥¹¥Ú¡¼¥¹ */
- var $namespace;
-
- /**#@-*/
-
- /**
- * Ethna_SOAP_GatewayGenerator¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- *
- * @access public
- */
- function Ethna_SOAP_GatewayGenerator()
- {
- $this->controller =& Ethna_Controller::getInstance();
- $this->config =& $this->controller->getConfig();
- $this->action_error = null;
- $this->ae =& $this->action_error;
- $this->gateway = "";
- $this->name = $this->controller->getAppId();
- $this->namespace = $this->_getNameSpace();
- }
-
- /**
- * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É¤òÀ¸À®¤¹¤ë
- *
- * @access public
- * @return string ¥²¡¼¥È¥¦¥§¥¯¥é¥¹¥³¡¼¥É
- */
- function generate()
- {
- $prev_type = $this->controller->getClientType();
- $this->controller->setClientType(CLIENT_TYPE_SOAP);
-
- $this->gateway .= $this->_getHeader();
- $this->gateway .= $this->_getEntry();
- $this->gateway .= $this->_getFooter();
-
- $this->controller->setClientType($prev_type);
-
- return $this->gateway;
- }
-
- /**
- * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¤Î¥¯¥é¥¹Ì¾¤ò¼èÆÀ¤¹¤ë
- *
- * @access public
- * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¤Î¥¯¥é¥¹Ì¾
- */
- function getClassName()
- {
- return sprintf("Ethna_SOAP_%sGateway", $this->name);
- }
-
- /**
- * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Ø¥Ã¥ÀÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Ø¥Ã¥ÀÉôʬ)
- */
- function _getHeader()
- {
- $header = sprintf("class Ethna_SOAP_%sGateway extends Ethna_SOAP_Gateway {\n", $this->name);
-
- return $header;
- }
-
- /**
- * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥á¥½¥Ã¥É¥¨¥ó¥È¥êÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥á¥½¥Ã¥É¥¨¥ó¥È¥êÉôʬ)
- */
- function _getEntry()
- {
- $entry = "";
- foreach ($this->controller->soap_action as $k => $v) {
- $action_form_name = $this->controller->getActionFormName($k);
- $form =& new $action_form_name($this->controller);
- $arg_list = array_keys($form->form);
-
- $entry .= " function $k(";
- for ($i = 0; $i < count($arg_list); $i++) {
- if ($i > 0) {
- $entry .= ", ";
- }
- $entry .= "\$" . $arg_list[$i];
- }
- $entry .= ") {\n";
-
- $entry .= " \$_SERVER['REQUEST_METHOD'] = 'post';\n";
- $entry .= " \$_POST['action_$k'] = 'dummy';\n";
- foreach ($arg_list as $arg) {
- $entry .= " \$_POST['$arg'] = \$$arg;\n";
- }
-
- $entry .= " \$this->dispatch();\n";
-
- $entry .= " \$app =& \$this->getApp();\n";
- $entry .= " \$errorcode = \$this->getErrorCode();\n";
- $entry .= " \$errormessage = \$this->getErrorMessage();\n";
- $entry .= " \$retval = array();\n";
- foreach ($form->retval as $k => $v) {
- $entry .= " \$retval['$k'] = \$app['$k'];\n";
- }
- $entry .= " \$retval['errorcode'] = \$errorcode;\n";
- $entry .= " \$retval['errormessage'] = \$errormessage;\n";
-
- $entry .= " return \$retval;\n";
- $entry .= " }\n";
- }
- return $entry;
- }
-
- /**
- * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Õ¥Ã¥¿Éôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Õ¥Ã¥¿Éôʬ)
- */
- function _getFooter()
- {
- $footer = "}\n";
-
- return $footer;
- }
-
- /**
- * ¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string ¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function _getNameSpace()
- {
- return sprintf("%s/%s", $this->config->get('url'), $this->name);
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
+
+ /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
+ var $config;
+
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_error;
+
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $ae;
+
+ /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É */
+ var $gateway;
+
+ /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¼±ÊÌ̾ */
+ var $name;
+
+ /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥Í¡¼¥à¥¹¥Ú¡¼¥¹ */
+ var $namespace;
+
+ /**#@-*/
+
+ /**
+ * Ethna_SOAP_GatewayGenerator¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ * @access public
+ */
+ function Ethna_SOAP_GatewayGenerator()
+ {
+ $this->controller =& Ethna_Controller::getInstance();
+ $this->config =& $this->controller->getConfig();
+ $this->action_error = null;
+ $this->ae =& $this->action_error;
+ $this->gateway = "";
+ $this->name = $this->controller->getAppId();
+ $this->namespace = $this->_getNameSpace();
+ }
+
+ /**
+ * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É¤òÀ¸À®¤¹¤ë
+ *
+ * @access public
+ * @return string ¥²¡¼¥È¥¦¥§¥¯¥é¥¹¥³¡¼¥É
+ */
+ function generate()
+ {
+ $prev_type = $this->controller->getClientType();
+ $this->controller->setClientType(CLIENT_TYPE_SOAP);
+
+ $this->gateway .= $this->_getHeader();
+ $this->gateway .= $this->_getEntry();
+ $this->gateway .= $this->_getFooter();
+
+ $this->controller->setClientType($prev_type);
+
+ return $this->gateway;
+ }
+
+ /**
+ * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¤Î¥¯¥é¥¹Ì¾¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access public
+ * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¤Î¥¯¥é¥¹Ì¾
+ */
+ function getClassName()
+ {
+ return sprintf("Ethna_SOAP_%sGateway", $this->name);
+ }
+
+ /**
+ * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Ø¥Ã¥ÀÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Ø¥Ã¥ÀÉôʬ)
+ */
+ function _getHeader()
+ {
+ $header = sprintf("class Ethna_SOAP_%sGateway extends Ethna_SOAP_Gateway {\n", $this->name);
+
+ return $header;
+ }
+
+ /**
+ * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥á¥½¥Ã¥É¥¨¥ó¥È¥êÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥á¥½¥Ã¥É¥¨¥ó¥È¥êÉôʬ)
+ */
+ function _getEntry()
+ {
+ $entry = "";
+ foreach ($this->controller->soap_action as $k => $v) {
+ $action_form_name = $this->controller->getActionFormName($k);
+ $form =& new $action_form_name($this->controller);
+ $arg_list = array_keys($form->form);
+
+ $entry .= " function $k(";
+ for ($i = 0; $i < count($arg_list); $i++) {
+ if ($i > 0) {
+ $entry .= ", ";
+ }
+ $entry .= "\$" . $arg_list[$i];
+ }
+ $entry .= ") {\n";
+
+ $entry .= " \$_SERVER['REQUEST_METHOD'] = 'post';\n";
+ $entry .= " \$_POST['action_$k'] = 'dummy';\n";
+ foreach ($arg_list as $arg) {
+ $entry .= " \$_POST['$arg'] = \$$arg;\n";
+ }
+
+ $entry .= " \$this->dispatch();\n";
+
+ $entry .= " \$app =& \$this->getApp();\n";
+ $entry .= " \$errorcode = \$this->getErrorCode();\n";
+ $entry .= " \$errormessage = \$this->getErrorMessage();\n";
+ $entry .= " \$retval = array();\n";
+ foreach ($form->retval as $k => $v) {
+ $entry .= " \$retval['$k'] = \$app['$k'];\n";
+ }
+ $entry .= " \$retval['errorcode'] = \$errorcode;\n";
+ $entry .= " \$retval['errormessage'] = \$errormessage;\n";
+
+ $entry .= " return \$retval;\n";
+ $entry .= " }\n";
+ }
+ return $entry;
+ }
+
+ /**
+ * ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Õ¥Ã¥¿Éôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É(¥Õ¥Ã¥¿Éôʬ)
+ */
+ function _getFooter()
+ {
+ $footer = "}\n";
+
+ return $footer;
+ }
+
+ /**
+ * ¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string ¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function _getNameSpace()
+ {
+ return sprintf("%s/%s", $this->config->get('url'), $this->name);
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_SOAP_Util.php
+ * Ethna_SOAP_Util.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_SOAP_Util
/**
- * SOAP¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥¯¥é¥¹
+ * SOAP¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_SOAP_Util
{
- /**
- * ·¿ÄêµÁ¤¬¥ª¥Ö¥¸¥§¥¯¥È·¿¤ÎÇÛÎ󤫤ɤ¦¤«¤òÊÖ¤¹
- *
- * @access public
- * @param array $def ·¿ÄêµÁ
- * @return bool true:¥ª¥Ö¥¸¥§¥¯¥È·¿ÇÛÎó false:¤½¤ì°Ê³°¤Î·¿
- * @static
- */
- function isArrayOfObject($def)
- {
- if (is_array($def) == false) {
- return false;
- }
- $keys = array_keys($def);
- if (count($keys) == 1 && is_array($def[$keys[0]])) {
- return true;
- }
- return false;
- }
+ /**
+ * ·¿ÄêµÁ¤¬¥ª¥Ö¥¸¥§¥¯¥È·¿¤ÎÇÛÎ󤫤ɤ¦¤«¤òÊÖ¤¹
+ *
+ * @access public
+ * @param array $def ·¿ÄêµÁ
+ * @return bool true:¥ª¥Ö¥¸¥§¥¯¥È·¿ÇÛÎó false:¤½¤ì°Ê³°¤Î·¿
+ * @static
+ */
+ function isArrayOfObject($def)
+ {
+ if (is_array($def) == false) {
+ return false;
+ }
+ $keys = array_keys($def);
+ if (count($keys) == 1 && is_array($def[$keys[0]])) {
+ return true;
+ }
+ return false;
+ }
- /**
- * ·¿ÄêµÁ¤¬¥¹¥«¥é¡¼ÃͤÎÇÛÎ󤫤ɤ¦¤«¤òÊÖ¤¹
- *
- * @access public
- * @param array $def ·¿ÄêµÁ
- * @return bool true:¥¹¥«¥é¡¼·¿ÇÛÎó false:¤½¤ì°Ê³°¤Î·¿
- * @static
- */
- function isArrayOfScalar($def)
- {
- if (is_array($def) == false) {
- return false;
- }
- $keys = array_keys($def);
- if (count($keys) == 1 && is_array($def[$keys[0]]) == false) {
- return true;
- }
- }
+ /**
+ * ·¿ÄêµÁ¤¬¥¹¥«¥é¡¼ÃͤÎÇÛÎ󤫤ɤ¦¤«¤òÊÖ¤¹
+ *
+ * @access public
+ * @param array $def ·¿ÄêµÁ
+ * @return bool true:¥¹¥«¥é¡¼·¿ÇÛÎó false:¤½¤ì°Ê³°¤Î·¿
+ * @static
+ */
+ function isArrayOfScalar($def)
+ {
+ if (is_array($def) == false) {
+ return false;
+ }
+ $keys = array_keys($def);
+ if (count($keys) == 1 && is_array($def[$keys[0]]) == false) {
+ return true;
+ }
+ }
- /**
- * ¥¹¥«¥é¡¼Ãͤη¿Ì¾¤òÊÖ¤¹
- *
- * @access public
- * @param array $def ·¿ÄêµÁ
- * @return string ·¿Ì¾
- * @static
- */
- function getScalarTypeName($def)
- {
- $name = null;
- switch ($def) {
- case VAR_TYPE_STRING:
- $name = "string";
- break;
- case VAR_TYPE_INT:
- $name = "int";
- break;
- case VAR_TYPE_FLOAT:
- $name = "float";
- break;
- case VAR_TYPE_DATETIME:
- $name = "datetime";
- break;
- case VAR_TYPE_BOOLEAN:
- $name = "boolean";
- break;
- }
- return $name;
- }
+ /**
+ * ¥¹¥«¥é¡¼Ãͤη¿Ì¾¤òÊÖ¤¹
+ *
+ * @access public
+ * @param array $def ·¿ÄêµÁ
+ * @return string ·¿Ì¾
+ * @static
+ */
+ function getScalarTypeName($def)
+ {
+ $name = null;
+ switch ($def) {
+ case VAR_TYPE_STRING:
+ $name = "string";
+ break;
+ case VAR_TYPE_INT:
+ $name = "int";
+ break;
+ case VAR_TYPE_FLOAT:
+ $name = "float";
+ break;
+ case VAR_TYPE_DATETIME:
+ $name = "datetime";
+ break;
+ case VAR_TYPE_BOOLEAN:
+ $name = "boolean";
+ break;
+ }
+ return $name;
+ }
- /**
- * ÇÛÎó¤Î·¿Ì¾¤òÊÖ¤¹
- *
- * @access public
- * @param array $def ·¿ÄêµÁ
- * @return string ·¿Ì¾
- * @static
- */
- function getArrayTypeName($def)
- {
- $name = null;
- switch ($def) {
- case VAR_TYPE_STRING:
- $name = "ArrayOfString";
- break;
- case VAR_TYPE_INT:
- $name = "ArrayOfInt";
- break;
- case VAR_TYPE_FLOAT:
- $name = "ArrayOfFloat";
- break;
- case VAR_TYPE_DATETIME:
- $name = "ArrayOfDatetime";
- break;
- case VAR_TYPE_BOOLEAN:
- $name = "ArrayOfBoolean";
- break;
- }
- return $name;
- }
+ /**
+ * ÇÛÎó¤Î·¿Ì¾¤òÊÖ¤¹
+ *
+ * @access public
+ * @param array $def ·¿ÄêµÁ
+ * @return string ·¿Ì¾
+ * @static
+ */
+ function getArrayTypeName($def)
+ {
+ $name = null;
+ switch ($def) {
+ case VAR_TYPE_STRING:
+ $name = "ArrayOfString";
+ break;
+ case VAR_TYPE_INT:
+ $name = "ArrayOfInt";
+ break;
+ case VAR_TYPE_FLOAT:
+ $name = "ArrayOfFloat";
+ break;
+ case VAR_TYPE_DATETIME:
+ $name = "ArrayOfDatetime";
+ break;
+ case VAR_TYPE_BOOLEAN:
+ $name = "ArrayOfBoolean";
+ break;
+ }
+ return $name;
+ }
- /**
- * Ìá¤êÃÍ·¿ÄêµÁ¤òÀµµ¬²½¤¹¤ë
- *
- * @access public
- * @param array $retval Ìá¤êÃÍ·¿ÄêµÁ
- * @static
- */
- function fixRetval(&$retval)
- {
- $retval['errorcode'] = VAR_TYPE_INT;
- $retval['errormessage'] = VAR_TYPE_STRING;
- }
+ /**
+ * Ìá¤êÃÍ·¿ÄêµÁ¤òÀµµ¬²½¤¹¤ë
+ *
+ * @access public
+ * @param array $retval Ìá¤êÃÍ·¿ÄêµÁ
+ * @static
+ */
+ function fixRetval(&$retval)
+ {
+ $retval['errorcode'] = VAR_TYPE_INT;
+ $retval['errormessage'] = VAR_TYPE_STRING;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_SOAP_WsdlGenerator.php
+ * Ethna_SOAP_WsdlGenerator.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_SOAP_WsdlGenerator
/**
- * »ØÄꤵ¤ì¤¿¥³¥ó¥È¥í¡¼¥é¤ËÂбþ¤¹¤ëWSDL¤òÀ¸À®¤¹¤ë¥¯¥é¥¹
+ * »ØÄꤵ¤ì¤¿¥³¥ó¥È¥í¡¼¥é¤ËÂбþ¤¹¤ëWSDL¤òÀ¸À®¤¹¤ë¥¯¥é¥¹
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_SOAP_WsdlGenerator
{
- /**#@+
- * @access private
- */
-
- /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
- var $controller;
-
- /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
- var $config;
-
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
- var $action_error;
-
- /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
- var $ae;
-
- /** @var string WSDL */
- var $wsdl;
-
- /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É */
- var $gateway;
-
- /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¼±ÊÌ̾ */
- var $name;
-
- /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥Í¡¼¥à¥¹¥Ú¡¼¥¹ */
- var $namespace;
-
- /**#@-*/
-
- /**
- * Ethna_SOAP_WsdlGenerator¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
- */
- function Ethna_SOAP_WsdlGenerator($gateway)
- {
- $this->controller =& Ethna_Controller::getInstance();
- $this->config =& $this->controller->getConfig();
- $this->action_error = null;
- $this->ae =& $this->action_error;
- $this->wsdl = "";
- $this->name = $this->controller->getAppId();
- $this->namespace = $this->_getNameSpace();
- $this->gateway = $gateway;
- }
-
- /**
- * WSDL¤òÀ¸À®¤¹¤ë
- *
- * @access public
- * @return string WSDL
- */
- function generate()
- {
- $current_type = $this->controller->getClientType();
- $this->controller->setClientType(CLIENT_TYPE_SOAP);
-
- $this->wsdl .= $this->_getHeader();
- $this->wsdl .= $this->_getTypes();
- $this->wsdl .= $this->_getMessage();
- $this->wsdl .= $this->_getPortType();
- $this->wsdl .= $this->_getBinding();
- $this->wsdl .= $this->_getService();
- $this->wsdl .= $this->_getFooter();
-
- $this->controller->setClientType($current_type);
-
- return $this->wsdl;
- }
-
- /**
- * WSDL(¥Ø¥Ã¥ÀÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string WSDL(¥Ø¥Ã¥ÀÉôʬ)
- */
- function _getHeader()
- {
- $header = <<< EOD
+ /**#@+
+ * @access private
+ */
+
+ /** @var object Ethna_Controller controller¥ª¥Ö¥¸¥§¥¯¥È */
+ var $controller;
+
+ /** @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È */
+ var $config;
+
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È */
+ var $action_error;
+
+ /** @var object Ethna_ActionError ¥¢¥¯¥·¥ç¥ó¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È(¾Êά·Á) */
+ var $ae;
+
+ /** @var string WSDL */
+ var $wsdl;
+
+ /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥³¡¼¥É */
+ var $gateway;
+
+ /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¼±ÊÌ̾ */
+ var $name;
+
+ /** @var string ¥²¡¼¥È¥¦¥§¥¤¥¯¥é¥¹¥Í¡¼¥à¥¹¥Ú¡¼¥¹ */
+ var $namespace;
+
+ /**#@-*/
+
+ /**
+ * Ethna_SOAP_WsdlGenerator¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
+ */
+ function Ethna_SOAP_WsdlGenerator($gateway)
+ {
+ $this->controller =& Ethna_Controller::getInstance();
+ $this->config =& $this->controller->getConfig();
+ $this->action_error = null;
+ $this->ae =& $this->action_error;
+ $this->wsdl = "";
+ $this->name = $this->controller->getAppId();
+ $this->namespace = $this->_getNameSpace();
+ $this->gateway = $gateway;
+ }
+
+ /**
+ * WSDL¤òÀ¸À®¤¹¤ë
+ *
+ * @access public
+ * @return string WSDL
+ */
+ function generate()
+ {
+ $current_type = $this->controller->getClientType();
+ $this->controller->setClientType(CLIENT_TYPE_SOAP);
+
+ $this->wsdl .= $this->_getHeader();
+ $this->wsdl .= $this->_getTypes();
+ $this->wsdl .= $this->_getMessage();
+ $this->wsdl .= $this->_getPortType();
+ $this->wsdl .= $this->_getBinding();
+ $this->wsdl .= $this->_getService();
+ $this->wsdl .= $this->_getFooter();
+
+ $this->controller->setClientType($current_type);
+
+ return $this->wsdl;
+ }
+
+ /**
+ * WSDL(¥Ø¥Ã¥ÀÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string WSDL(¥Ø¥Ã¥ÀÉôʬ)
+ */
+ function _getHeader()
+ {
+ $header = <<< EOD
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:s="http://www.w3.org/2001/XMLSchema"
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
- xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
- xmlns:tns="%s"
- targetNamespace="%s"
- name="%s"
- xmlns="http://schemas.xmlsoap.org/wsdl/">\n\n
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:s="http://www.w3.org/2001/XMLSchema"
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:tns="%s"
+ targetNamespace="%s"
+ name="%s"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">\n\n
EOD;
- return sprintf($header, $this->namespace, $this->namespace, $this->name);
- }
-
- /**
- * WSDL(·¿ÄêµÁÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string WSDL(·¿ÄêµÁÉôʬ)
- */
- function _getTypes()
- {
- $types = sprintf(" <types>\n <s:schema targetNamespace=\"%s\">\n", $this->namespace);
-
- // ´ðËÜ·¿
- $types .= <<< EOD
+ return sprintf($header, $this->namespace, $this->namespace, $this->name);
+ }
+
+ /**
+ * WSDL(·¿ÄêµÁÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string WSDL(·¿ÄêµÁÉôʬ)
+ */
+ function _getTypes()
+ {
+ $types = sprintf(" <types>\n <s:schema targetNamespace=\"%s\">\n", $this->namespace);
+
+ // ´ðËÜ·¿
+ $types .= <<< EOD
<s:complexType name="ArrayOfInt">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
</s:sequence>
</s:complexType>\n
EOD;
-
- // ¥¢¥¯¥·¥ç¥ó¸ÇÍ
- foreach ($this->controller->soap_action as $k => $v) {
- $action_form_name = $this->controller->getActionFormName($k);
- $form =& new $action_form_name($this->controller);
- if ($form->retval == null) {
- continue;
- }
-
- // ¥Ç¥Õ¥©¥ë¥È¥¨¥ó¥È¥ê¤òÄɲÃ
- Ethna_SOAP_Util::fixRetval($form->retval);
-
- // ¥·¥ê¥¢¥é¥¤¥º
- $retval_name = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($k)) . "Result";
- $types .= $this->_serializeTypes($form->retval, $retval_name);
- }
-
- return $types . " </s:schema>\n </types>\n\n";
- }
-
- /**
- * WSDL(MessageÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string WSDL(MessageÉôʬ)
- * @todo respect access controlls
- */
- function _getMessage()
- {
- $n = 1;
- $message = "";
- foreach ($this->controller->soap_action as $k => $v) {
- $message .= $this->_serializeMessage($k, $n);
- $n++;
- }
-
- return $message . "\n";
- }
-
- /**
- * WSDL(PortTypeÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string WSDL(PortTypeÉôʬ)
- */
- function _getPortType()
- {
- $port_type = sprintf(" <portType name=\"%sSoap\">\n", $this->name);
-
- $n = 1;
- foreach ($this->controller->soap_action as $k => $v) {
- $port_type .= $this->_serializePortType($k, $n);
- $n++;
- }
-
- $port_type .= " </portType>\n\n";
-
- return $port_type;
- }
-
- /**
- * WSDL(BindingÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string WSDL(BindingÉôʬ)
- */
- function _getBinding()
- {
- $namespace = "urn:" . $this->name;
- $binding = " <binding name=\"" . $this->name . "Soap\" type=\"tns:" . $this->name . "Soap\">\n";
- $binding .= " <soap:binding style=\"rpc\" transport=\"http://schemas.xmlsoap.org/soap/http\" />\n";
-
- $n = 1;
- foreach ($this->controller->soap_action as $k => $v) {
- $binding .= " <operation name=\"$k\">\n";
- $binding .= " <soap:operation soapAction=\"$k\" style=\"rpc\" />\n";
- $binding .= " <input name=\"${k}${n}SoapIn\">\n";
- $binding .= " <soap:body use=\"encoded\" namespace=\"$namespace\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n";
- $binding .= " </input>\n";
- $binding .= " <output name=\"${k}${n}SoapOut\">\n";
- $binding .= " <soap:body use=\"encoded\" namespace=\"$namespace\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n";
- $binding .= " </output>\n";
- $binding .= " </operation>\n";
- $n++;
- }
- $binding .= " </binding>\n";
-
- return $binding;
- }
-
- /**
- * WSDL(ServiceÉôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string WSDL(ServiceÉôʬ)
- */
- function _getService()
- {
- $name = $this->name;
- $gateway= $this->gateway;
- $service = " <service name=\"$name\">\n";
- $service .= " <port name=\"${name}Soap\" binding=\"tns:${name}Soap\">\n";
- $service .= " <soap:address location=\"$gateway\" />\n";
- $service .= " </port>\n";
- $service .= " </service>\n";
-
- return $service;
- }
-
- /**
- * WSDL(¥Õ¥Ã¥¿Éôʬ)¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string WSDL(¥Õ¥Ã¥¿Éôʬ)
- */
- function _getFooter()
- {
- return "</definitions>\n";
- }
-
- /**
- * ¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @return string ¥Í¡¼¥à¥¹¥Ú¡¼¥¹
- */
- function _getNameSpace()
- {
- return sprintf("%s/%s", $this->config->get('url'), $this->name);
- }
-
- /**
- * ·¿¤Î¥·¥ê¥¢¥é¥¤¥º
- *
- * @access private
- * @param array $def ·¿ÄêµÁ
- * @param string $name ÊÑ¿ô̾
- * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿·¿ÄêµÁ
- */
- function _serializeTypes($def, $name)
- {
- if (is_array($def) == false) {
- // nothing to do
- return;
- }
-
- $types = $this->__serializeTypes($def, $name);
-
- foreach ($def as $k => $v) {
- if (is_array($def[$k]) == false || Ethna_SOAP_Util::isArrayOfScalar($def[$k])) {
- continue;
- }
- $types .= $this->_serializeTypes($def[$k], $k);
- }
-
- return $types;
- }
-
- /**
- * ·¿¤Î¥·¥ê¥¢¥é¥¤¥º(¥¨¥ì¥á¥ó¥ÈÂбþ)
- *
- * @access private
- * @param array $def ·¿ÄêµÁ
- * @param string $name ÊÑ¿ô̾
- * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿·¿ÄêµÁ(³ÆÍ×ÁÇ)
- */
- function __serializeTypes($def, $name)
- {
- $keys = array_keys($def);
-
- if (Ethna_SOAP_Util::isArrayOfObject($def)) {
- $array_name = sprintf("ArrayOf%s", $keys[0]);
- $name = $keys[0];
- $types = " <s:complexType name=\"$array_name\">\n";
- $types .= " <s:complexContent mixed=\"false\">\n";
- $types .= " <s:restriction base=\"soapenc:Array\">\n";
- $types .= " <s:attribute d7p1:arrayType=\"tns:$name" . "[]" . "\" " .
- "ref=\"soapenc:arrayType\" xmlns:d7p1=\"http://schemas.xmlsoap.org/wsdl/\" />\n";
- $types .= " </s:restriction>\n";
- $types .= " </s:complexContent>\n";
- $types .= " </s:complexType>\n";
- return $types;
- }
-
- $types = " <s:complexType name=\"$name\">\n";
- $types .= " <s:sequence>\n";
- foreach ($keys as $key) {
- if (is_array($def[$key])) {
- $inner_keys = array_keys($def[$key]);
- if (is_array($def[$key][$inner_keys[0]])) {
- $inner_name = sprintf("ArrayOf%s", $inner_keys[0]);
- $types .= " <s:element name=\"$key\" type=\"tns:$inner_name\" />\n";
- } else {
- $type_name = "tns:" . Ethna_SOAP_Util::getArrayTypeName($def[$key][$inner_keys[0]]);
- $types .= " <s:element name=\"$key\" type=\"$type_name\" />\n";
- }
- } else {
- $type_name = Ethna_SOAP_Util::getScalarTypeName($def[$key]);
- $types .= " <s:element name=\"$key\" type=\"s:$type_name\" />\n";
- }
- }
- $types .= " </s:sequence>\n";
- $types .= " </s:complexType>\n";
-
- return $types;
- }
-
- /**
- * Message¤Î¥·¥ê¥¢¥é¥¤¥º
- *
- * @access private
- * @param string $name message̾
- * @param int $serno messageÏ¢ÈÖ
- * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿message
- */
- function _serializeMessage($name, $serno)
- {
- $action_form_name = $this->controller->getActionFormName($name);
- $form =& new $action_form_name($this->controller);
-
- /* SoapIn */
- $message = " <message name=\"${name}${serno}SoapIn\">\n";
- $keys = array();
- if (is_array($form->form)) {
- $keys = array_keys($form->form);
- }
- foreach ($keys as $key) {
- $type_id =& $form->form[$key]['type'];
- if (is_array($type_id)) {
- $type_keys = array_keys($type_id);
- $type = "tns:" . Ethna_SOAP_Util::getArrayTypeName($type_id[$type_keys[0]]);
- } else {
- $type = "s:" . Ethna_SOAP_Util::getScalarTypeName($type_id);
- }
- $message .= " <part name=\"$key\" type=\"$type\" />\n";
- }
- $message .= " </message>\n";
-
- /* SoapOut */
- $message .= " <message name=\"${name}${serno}SoapOut\">\n";
- if ($form->retval == null) {
- $type = "tns:Result";
- } else {
- $type = "tns:${name}Result";
- }
- $message .= " <part name=\"result\" type=\"$type\" />\n";
- $message .= " </message>\n";
-
- return $message;
- }
-
- /**
- * PortType¤Î¥·¥ê¥¢¥é¥¤¥º
- *
- * @access private
- * @param string $name porttype̾
- * @param int $serno porttypeÏ¢ÈÖ
- * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿porttype
- */
- function _serializePortType($name, $serno)
- {
- $action_form_name = $this->controller->getActionFormName($name);
- $form =& new $action_form_name($this->controller);
-
- $args = null;
- if (is_array($form->form)) {
- $args = implode(' ', array_keys($form->form));
- }
-
- $port_type = " <operation name=\"$name\" parameterOrder=\"$args\">\n";
- $port_type .= " <input name=\"${name}${serno}SoapIn\" message=\"tns:${name}${serno}SoapIn\" />\n";
- $port_type .= " <output name=\"${name}${serno}SoapOut\" message=\"tns:${name}${serno}SoapOut\" />\n";
- $port_type .= " </operation>\n";
-
- return $port_type;
- }
+
+ // ¥¢¥¯¥·¥ç¥ó¸ÇÍ
+ foreach ($this->controller->soap_action as $k => $v) {
+ $action_form_name = $this->controller->getActionFormName($k);
+ $form =& new $action_form_name($this->controller);
+ if ($form->retval == null) {
+ continue;
+ }
+
+ // ¥Ç¥Õ¥©¥ë¥È¥¨¥ó¥È¥ê¤òÄɲÃ
+ Ethna_SOAP_Util::fixRetval($form->retval);
+
+ // ¥·¥ê¥¢¥é¥¤¥º
+ $retval_name = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($k)) . "Result";
+ $types .= $this->_serializeTypes($form->retval, $retval_name);
+ }
+
+ return $types . " </s:schema>\n </types>\n\n";
+ }
+
+ /**
+ * WSDL(MessageÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string WSDL(MessageÉôʬ)
+ * @todo respect access controlls
+ */
+ function _getMessage()
+ {
+ $n = 1;
+ $message = "";
+ foreach ($this->controller->soap_action as $k => $v) {
+ $message .= $this->_serializeMessage($k, $n);
+ $n++;
+ }
+
+ return $message . "\n";
+ }
+
+ /**
+ * WSDL(PortTypeÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string WSDL(PortTypeÉôʬ)
+ */
+ function _getPortType()
+ {
+ $port_type = sprintf(" <portType name=\"%sSoap\">\n", $this->name);
+
+ $n = 1;
+ foreach ($this->controller->soap_action as $k => $v) {
+ $port_type .= $this->_serializePortType($k, $n);
+ $n++;
+ }
+
+ $port_type .= " </portType>\n\n";
+
+ return $port_type;
+ }
+
+ /**
+ * WSDL(BindingÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string WSDL(BindingÉôʬ)
+ */
+ function _getBinding()
+ {
+ $namespace = "urn:" . $this->name;
+ $binding = " <binding name=\"" . $this->name . "Soap\" type=\"tns:" . $this->name . "Soap\">\n";
+ $binding .= " <soap:binding style=\"rpc\" transport=\"http://schemas.xmlsoap.org/soap/http\" />\n";
+
+ $n = 1;
+ foreach ($this->controller->soap_action as $k => $v) {
+ $binding .= " <operation name=\"$k\">\n";
+ $binding .= " <soap:operation soapAction=\"$k\" style=\"rpc\" />\n";
+ $binding .= " <input name=\"${k}${n}SoapIn\">\n";
+ $binding .= " <soap:body use=\"encoded\" namespace=\"$namespace\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n";
+ $binding .= " </input>\n";
+ $binding .= " <output name=\"${k}${n}SoapOut\">\n";
+ $binding .= " <soap:body use=\"encoded\" namespace=\"$namespace\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n";
+ $binding .= " </output>\n";
+ $binding .= " </operation>\n";
+ $n++;
+ }
+ $binding .= " </binding>\n";
+
+ return $binding;
+ }
+
+ /**
+ * WSDL(ServiceÉôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string WSDL(ServiceÉôʬ)
+ */
+ function _getService()
+ {
+ $name = $this->name;
+ $gateway= $this->gateway;
+ $service = " <service name=\"$name\">\n";
+ $service .= " <port name=\"${name}Soap\" binding=\"tns:${name}Soap\">\n";
+ $service .= " <soap:address location=\"$gateway\" />\n";
+ $service .= " </port>\n";
+ $service .= " </service>\n";
+
+ return $service;
+ }
+
+ /**
+ * WSDL(¥Õ¥Ã¥¿Éôʬ)¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string WSDL(¥Õ¥Ã¥¿Éôʬ)
+ */
+ function _getFooter()
+ {
+ return "</definitions>\n";
+ }
+
+ /**
+ * ¥Í¡¼¥à¥¹¥Ú¡¼¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @return string ¥Í¡¼¥à¥¹¥Ú¡¼¥¹
+ */
+ function _getNameSpace()
+ {
+ return sprintf("%s/%s", $this->config->get('url'), $this->name);
+ }
+
+ /**
+ * ·¿¤Î¥·¥ê¥¢¥é¥¤¥º
+ *
+ * @access private
+ * @param array $def ·¿ÄêµÁ
+ * @param string $name ÊÑ¿ô̾
+ * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿·¿ÄêµÁ
+ */
+ function _serializeTypes($def, $name)
+ {
+ if (is_array($def) == false) {
+ // nothing to do
+ return;
+ }
+
+ $types = $this->__serializeTypes($def, $name);
+
+ foreach ($def as $k => $v) {
+ if (is_array($def[$k]) == false || Ethna_SOAP_Util::isArrayOfScalar($def[$k])) {
+ continue;
+ }
+ $types .= $this->_serializeTypes($def[$k], $k);
+ }
+
+ return $types;
+ }
+
+ /**
+ * ·¿¤Î¥·¥ê¥¢¥é¥¤¥º(¥¨¥ì¥á¥ó¥ÈÂбþ)
+ *
+ * @access private
+ * @param array $def ·¿ÄêµÁ
+ * @param string $name ÊÑ¿ô̾
+ * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿·¿ÄêµÁ(³ÆÍ×ÁÇ)
+ */
+ function __serializeTypes($def, $name)
+ {
+ $keys = array_keys($def);
+
+ if (Ethna_SOAP_Util::isArrayOfObject($def)) {
+ $array_name = sprintf("ArrayOf%s", $keys[0]);
+ $name = $keys[0];
+ $types = " <s:complexType name=\"$array_name\">\n";
+ $types .= " <s:complexContent mixed=\"false\">\n";
+ $types .= " <s:restriction base=\"soapenc:Array\">\n";
+ $types .= " <s:attribute d7p1:arrayType=\"tns:$name" . "[]" . "\" " .
+ "ref=\"soapenc:arrayType\" xmlns:d7p1=\"http://schemas.xmlsoap.org/wsdl/\" />\n";
+ $types .= " </s:restriction>\n";
+ $types .= " </s:complexContent>\n";
+ $types .= " </s:complexType>\n";
+ return $types;
+ }
+
+ $types = " <s:complexType name=\"$name\">\n";
+ $types .= " <s:sequence>\n";
+ foreach ($keys as $key) {
+ if (is_array($def[$key])) {
+ $inner_keys = array_keys($def[$key]);
+ if (is_array($def[$key][$inner_keys[0]])) {
+ $inner_name = sprintf("ArrayOf%s", $inner_keys[0]);
+ $types .= " <s:element name=\"$key\" type=\"tns:$inner_name\" />\n";
+ } else {
+ $type_name = "tns:" . Ethna_SOAP_Util::getArrayTypeName($def[$key][$inner_keys[0]]);
+ $types .= " <s:element name=\"$key\" type=\"$type_name\" />\n";
+ }
+ } else {
+ $type_name = Ethna_SOAP_Util::getScalarTypeName($def[$key]);
+ $types .= " <s:element name=\"$key\" type=\"s:$type_name\" />\n";
+ }
+ }
+ $types .= " </s:sequence>\n";
+ $types .= " </s:complexType>\n";
+
+ return $types;
+ }
+
+ /**
+ * Message¤Î¥·¥ê¥¢¥é¥¤¥º
+ *
+ * @access private
+ * @param string $name message̾
+ * @param int $serno messageÏ¢ÈÖ
+ * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿message
+ */
+ function _serializeMessage($name, $serno)
+ {
+ $action_form_name = $this->controller->getActionFormName($name);
+ $form =& new $action_form_name($this->controller);
+
+ /* SoapIn */
+ $message = " <message name=\"${name}${serno}SoapIn\">\n";
+ $keys = array();
+ if (is_array($form->form)) {
+ $keys = array_keys($form->form);
+ }
+ foreach ($keys as $key) {
+ $type_id =& $form->form[$key]['type'];
+ if (is_array($type_id)) {
+ $type_keys = array_keys($type_id);
+ $type = "tns:" . Ethna_SOAP_Util::getArrayTypeName($type_id[$type_keys[0]]);
+ } else {
+ $type = "s:" . Ethna_SOAP_Util::getScalarTypeName($type_id);
+ }
+ $message .= " <part name=\"$key\" type=\"$type\" />\n";
+ }
+ $message .= " </message>\n";
+
+ /* SoapOut */
+ $message .= " <message name=\"${name}${serno}SoapOut\">\n";
+ if ($form->retval == null) {
+ $type = "tns:Result";
+ } else {
+ $type = "tns:${name}Result";
+ }
+ $message .= " <part name=\"result\" type=\"$type\" />\n";
+ $message .= " </message>\n";
+
+ return $message;
+ }
+
+ /**
+ * PortType¤Î¥·¥ê¥¢¥é¥¤¥º
+ *
+ * @access private
+ * @param string $name porttype̾
+ * @param int $serno porttypeÏ¢ÈÖ
+ * @return string ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿porttype
+ */
+ function _serializePortType($name, $serno)
+ {
+ $action_form_name = $this->controller->getActionFormName($name);
+ $form =& new $action_form_name($this->controller);
+
+ $args = null;
+ if (is_array($form->form)) {
+ $args = implode(' ', array_keys($form->form));
+ }
+
+ $port_type = " <operation name=\"$name\" parameterOrder=\"$args\">\n";
+ $port_type .= " <input name=\"${name}${serno}SoapIn\" message=\"tns:${name}${serno}SoapIn\" />\n";
+ $port_type .= " <output name=\"${name}${serno}SoapOut\" message=\"tns:${name}${serno}SoapOut\" />\n";
+ $port_type .= " </operation>\n";
+
+ return $port_type;
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_View_Info.php
+ * Ethna_View_Info.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_View_Info
/**
- * __ethna_info__¥Ó¥å¡¼¤Î¼ÂÁõ
+ * __ethna_info__¥Ó¥å¡¼¤Î¼ÂÁõ
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_View_Info extends Ethna_ViewClass
{
- /**#@+
- * @access private
- */
+ /**#@+
+ * @access private
+ */
- /**#@-*/
+ /**#@-*/
- /**
- * Á«°ÜÁ°½èÍý
- *
- * @access public
- */
- function preforward()
- {
- $ctl =& Ethna_Controller::getInstance();
- $em =& new Ethna_InfoManager($this->backend);
+ /**
+ * Á«°ÜÁ°½èÍý
+ *
+ * @access public
+ */
+ function preforward()
+ {
+ $ctl =& Ethna_Controller::getInstance();
+ $em =& new Ethna_InfoManager($this->backend);
- // cores
- $this->af->setApp('app_id', $ctl->getAppId());
- $this->af->setApp('ethna_version', ETHNA_VERSION);
+ // cores
+ $this->af->setApp('app_id', $ctl->getAppId());
+ $this->af->setApp('ethna_version', ETHNA_VERSION);
- // actions
- $this->af->setApp('action_list', $em->getActionList());
+ // actions
+ $this->af->setApp('action_list', $em->getActionList());
- // views
- $this->af->setApp('forward_list', $em->getForwardList());
+ // views
+ $this->af->setApp('forward_list', $em->getForwardList());
- // configuration
- $this->af->setApp('configuration', $em->getConfiguration());
- }
+ // configuration
+ $this->af->setApp('configuration', $em->getConfiguration());
+ }
}
// }}}
?>
<?php
// vim: foldmethod=marker
/**
- * Ethna_View_List.php
+ * Ethna_View_List.php
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @package Ethna
- * @version $Id$
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
+ * @package Ethna
+ * @version $Id$
*/
// {{{ Ethna_View_List
/**
- * ¥ê¥¹¥È¥Ó¥å¡¼´ðÄ쥯¥é¥¹¤Î¼ÂÁõ
+ * ¥ê¥¹¥È¥Ó¥å¡¼´ðÄ쥯¥é¥¹¤Î¼ÂÁõ
*
- * @author Masaki Fujimoto <fujimoto@php.net>
- * @access public
- * @package Ethna
+ * @author Masaki Fujimoto <fujimoto@php.net>
+ * @access public
+ * @package Ethna
*/
class Ethna_View_List extends Ethna_ViewClass
{
- /**#@+
- * @access private
- */
-
- /** @var int ɽ¼¨³«»Ï¥ª¥Õ¥»¥Ã¥È */
- var $offset = 0;
-
- /** @var int ɽ¼¨·ï¿ô */
- var $count = 25;
-
- /** @var array ¸¡º÷ÂоݹàÌÜ°ìÍ÷ */
- var $search_list = array();
-
- /** @var string ¸¡º÷¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹Ì¾ */
- var $manager_name = null;
-
- /** @var string ɽ¼¨Âоݥ¯¥é¥¹Ì¾ */
- var $class_name = null;
-
- /**#@-*/
-
- /**
- * Á«°ÜÁ°½èÍý
- *
- * @access public
- */
- function preforward()
- {
- // ɽ¼¨¥ª¥Õ¥»¥Ã¥È/·ï¿ôÀßÄê
- $this->offset = $this->af->get('offset');
- if ($this->offset == "") {
- $this->offset = 0;
- }
- if (intval($this->af->get('count')) > 0) {
- $this->count = intval($this->af->get('count'));
- }
-
- // ¸¡º÷¾ò·ï
- $filter = array();
- $sort = array();
- foreach ($this->search_list as $key) {
- if ($this->af->get("s_$key") != "") {
- $filter[$key] = $this->af->get("s_$key");
- }
- if ($this->af->get("sort") == $key) {
- $order = $this->af->get("order") == "desc" ? OBJECT_SORT_DESC : OBJECT_SORT_ASC;
- $sort = array(
- $key => $order,
- );
- }
- }
-
- // ɽ¼¨¹àÌÜ°ìÍ÷
- $manager_name = $this->manager_name;
- for ($i = 0; $i < 2; $i++) {
- list($total, $obj_list) = $this->$manager_name->getObjectList($this->class_name, $filter, $sort, $this->offset, $this->count);
- if (count($obj_list) == 0 && $this->offset >= $total) {
- $this->offset = 0;
- continue;
- }
- break;
- }
-
- $r = array();
- foreach ($obj_list as $obj) {
- $value = $obj->getNameObject();
- $value = $this->_fixNameObject($value, $obj);
- $r[] = $value;
- }
- $list_name = sprintf("%s_list", strtolower(preg_replace('/(.)([A-Z])/', '\\1_\\2', $this->class_name)));
- $this->af->setApp($list_name, $r);
-
- // ¥Ê¥Ó¥²¡¼¥·¥ç¥ó
- $this->af->setApp('nav', $this->_getNavigation($total, $obj_list));
- $this->af->setAppNE('query', $this->_getQueryParameter());
-
- // ¸¡º÷¥ª¥×¥·¥ç¥ó
- $this->_setQueryOption();
- }
-
- /**
- * ɽ¼¨¹àÌܤò½¤Àµ¤¹¤ë
- *
- * @access protected
- */
- function _fixNameObject($value, $obj)
- {
- return $value;
- }
-
- /**
- * ¥Ê¥Ó¥²¡¼¥·¥ç¥ó¾ðÊó¤ò¼èÆÀ¤¹¤ë
- *
- * @access private
- * @param int $total ¸¡º÷Áí·ï¿ô
- * @param array $list ¸¡º÷·ë²Ì
- * @return array ¥Ê¥Ó¥²¡¼¥·¥ç¥ó¾ðÊó¤ò³ÊǼ¤·¤¿ÇÛÎó
- */
- function _getNavigation($total, &$list)
- {
- $nav = array();
- $nav['offset'] = $this->offset;
- $nav['from'] = $this->offset + 1;
- if ($total == 0) {
- $nav['from'] = 0;
- }
- $nav['to'] = $this->offset + count($list);
- $nav['total'] = $total;
- if ($this->offset > 0) {
- $prev_offset = $this->offset - $this->count;
- if ($prev_offset < 0) {
- $prev_offset = 0;
- }
- $nav['prev_offset'] = $prev_offset;
- }
- if ($this->offset + $this->count < $total) {
- $next_offset = $this->offset + count($list);
- $nav['next_offset'] = $next_offset;
- }
- $nav['direct_link_list'] = Ethna_Util::getDirectLinkList($total, $this->offset, $this->count);
-
- return $nav;
- }
-
- /**
- * ¸¡º÷¹àÌܤòÀ¸À®¤¹¤ë
- *
- * @access protected
- */
- function _setQueryOption()
- {
- }
-
- /**
- * ¸¡º÷ÆâÍƤò³ÊǼ¤·¤¿GET°ú¿ô¤òÀ¸À®¤¹¤ë
- *
- * @access private
- * @param array $search_list ¸¡º÷ÂоݰìÍ÷
- * @return string ¸¡º÷ÆâÍƤò³ÊǼ¤·¤¿GET°ú¿ô
- */
- function _getQueryParameter()
- {
- $query = "";
-
- foreach ($this->search_list as $key) {
- $value = $this->af->get("s_$key");
- if (is_array($value)) {
- foreach ($value as $v) {
- $query .= "&s_$key" . "[]=" . urlencode($v);
- }
- } else {
- $query .= "&s_$key=" . urlencode($value);
- }
- }
-
- return $query;
- }
+ /**#@+
+ * @access private
+ */
+
+ /** @var int ɽ¼¨³«»Ï¥ª¥Õ¥»¥Ã¥È */
+ var $offset = 0;
+
+ /** @var int ɽ¼¨·ï¿ô */
+ var $count = 25;
+
+ /** @var array ¸¡º÷ÂоݹàÌÜ°ìÍ÷ */
+ var $search_list = array();
+
+ /** @var string ¸¡º÷¥Þ¥Í¡¼¥¸¥ã¥¯¥é¥¹Ì¾ */
+ var $manager_name = null;
+
+ /** @var string ɽ¼¨Âоݥ¯¥é¥¹Ì¾ */
+ var $class_name = null;
+
+ /**#@-*/
+
+ /**
+ * Á«°ÜÁ°½èÍý
+ *
+ * @access public
+ */
+ function preforward()
+ {
+ // ɽ¼¨¥ª¥Õ¥»¥Ã¥È/·ï¿ôÀßÄê
+ $this->offset = $this->af->get('offset');
+ if ($this->offset == "") {
+ $this->offset = 0;
+ }
+ if (intval($this->af->get('count')) > 0) {
+ $this->count = intval($this->af->get('count'));
+ }
+
+ // ¸¡º÷¾ò·ï
+ $filter = array();
+ $sort = array();
+ foreach ($this->search_list as $key) {
+ if ($this->af->get("s_$key") != "") {
+ $filter[$key] = $this->af->get("s_$key");
+ }
+ if ($this->af->get("sort") == $key) {
+ $order = $this->af->get("order") == "desc" ? OBJECT_SORT_DESC : OBJECT_SORT_ASC;
+ $sort = array(
+ $key => $order,
+ );
+ }
+ }
+
+ // ɽ¼¨¹àÌÜ°ìÍ÷
+ $manager_name = $this->manager_name;
+ for ($i = 0; $i < 2; $i++) {
+ list($total, $obj_list) = $this->$manager_name->getObjectList($this->class_name, $filter, $sort, $this->offset, $this->count);
+ if (count($obj_list) == 0 && $this->offset >= $total) {
+ $this->offset = 0;
+ continue;
+ }
+ break;
+ }
+
+ $r = array();
+ foreach ($obj_list as $obj) {
+ $value = $obj->getNameObject();
+ $value = $this->_fixNameObject($value, $obj);
+ $r[] = $value;
+ }
+ $list_name = sprintf("%s_list", strtolower(preg_replace('/(.)([A-Z])/', '\\1_\\2', $this->class_name)));
+ $this->af->setApp($list_name, $r);
+
+ // ¥Ê¥Ó¥²¡¼¥·¥ç¥ó
+ $this->af->setApp('nav', $this->_getNavigation($total, $obj_list));
+ $this->af->setAppNE('query', $this->_getQueryParameter());
+
+ // ¸¡º÷¥ª¥×¥·¥ç¥ó
+ $this->_setQueryOption();
+ }
+
+ /**
+ * ɽ¼¨¹àÌܤò½¤Àµ¤¹¤ë
+ *
+ * @access protected
+ */
+ function _fixNameObject($value, $obj)
+ {
+ return $value;
+ }
+
+ /**
+ * ¥Ê¥Ó¥²¡¼¥·¥ç¥ó¾ðÊó¤ò¼èÆÀ¤¹¤ë
+ *
+ * @access private
+ * @param int $total ¸¡º÷Áí·ï¿ô
+ * @param array $list ¸¡º÷·ë²Ì
+ * @return array ¥Ê¥Ó¥²¡¼¥·¥ç¥ó¾ðÊó¤ò³ÊǼ¤·¤¿ÇÛÎó
+ */
+ function _getNavigation($total, &$list)
+ {
+ $nav = array();
+ $nav['offset'] = $this->offset;
+ $nav['from'] = $this->offset + 1;
+ if ($total == 0) {
+ $nav['from'] = 0;
+ }
+ $nav['to'] = $this->offset + count($list);
+ $nav['total'] = $total;
+ if ($this->offset > 0) {
+ $prev_offset = $this->offset - $this->count;
+ if ($prev_offset < 0) {
+ $prev_offset = 0;
+ }
+ $nav['prev_offset'] = $prev_offset;
+ }
+ if ($this->offset + $this->count < $total) {
+ $next_offset = $this->offset + count($list);
+ $nav['next_offset'] = $next_offset;
+ }
+ $nav['direct_link_list'] = Ethna_Util::getDirectLinkList($total, $this->offset, $this->count);
+
+ return $nav;
+ }
+
+ /**
+ * ¸¡º÷¹àÌܤòÀ¸À®¤¹¤ë
+ *
+ * @access protected
+ */
+ function _setQueryOption()
+ {
+ }
+
+ /**
+ * ¸¡º÷ÆâÍƤò³ÊǼ¤·¤¿GET°ú¿ô¤òÀ¸À®¤¹¤ë
+ *
+ * @access private
+ * @param array $search_list ¸¡º÷ÂоݰìÍ÷
+ * @return string ¸¡º÷ÆâÍƤò³ÊǼ¤·¤¿GET°ú¿ô
+ */
+ function _getQueryParameter()
+ {
+ $query = "";
+
+ foreach ($this->search_list as $key) {
+ $value = $this->af->get("s_$key");
+ if (is_array($value)) {
+ foreach ($value as $v) {
+ $query .= "&s_$key" . "[]=" . urlencode($v);
+ }
+ } else {
+ $query .= "&s_$key=" . urlencode($value);
+ }
+ }
+
+ return $query;
+ }
}
// }}}
?>