示例#1
0
 /**
  *  Ethna_UnitTestManagerのコンストラクタ
  *
  *  @access public
  *  @param  object  Ethna_Backend   &$backend   Ethna_Backendオブジェクト
  */
 public function __construct($backend)
 {
     parent::__construct($backend);
     $this->ctl = Ethna_Controller::getInstance();
     $this->class_factory = $this->ctl->getClassFactory();
     $this->testcase = array_merge($this->testcase, $this->_getTestCaseList());
 }
 /**
  *	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();
     }
     // メッセージ補正処理
     if (is_null($message)) {
         // $codeからメッセージを取得する
         $message = $controller->getErrorMessage($code);
         if (is_null($message)) {
             $message = 'unkown error';
         }
     }
     parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
     // Ethnaフレームワークのエラーハンドラ(PEAR_Errorのコールバックとは異なる)
     Ethna::handleError($this);
 }
/**
 *  smarty function:フォーム表示名生成
 *
 *  @param  string  $name   フォーム項目名
 */
function smarty_function_form_name($params, &$smarty)
{
    // name
    if (isset($params['name'])) {
        $name = $params['name'];
        unset($params['name']);
    } else {
        return null;
    }
    // view object
    $c =& Ethna_Controller::getInstance();
    $view =& $c->getView();
    if ($view === null) {
        return null;
    }
    // action
    $action = null;
    if (isset($params['action'])) {
        $action = $params['action'];
        unset($params['action']);
    } else {
        for ($i = count($smarty->_tag_stack); $i >= 0; --$i) {
            if ($smarty->_tag_stack[$i][0] === 'form') {
                if (isset($smarty->_tag_stack[$i][1]['ethna_action'])) {
                    $action = $smarty->_tag_stack[$i][1]['ethna_action'];
                }
                break;
            }
        }
    }
    if ($action !== null) {
        $view->addActionFormHelper($action);
    }
    return $view->getFormName($name, $action, $params);
}
示例#4
0
 /**
  *  Cachemaanger プラグインのインスタンスを取得する
  *
  *  @param  string  $type   キャッシュタイプ('localfile', 'memcache'...)
  *  @return object  Ethna_Plugin_CacheMaanger   Cachemanager プラグインのインスタンス
  *  @access public
  */
 public static function getInstance($type)
 {
     $controller = Ethna_Controller::getInstance();
     $plugin = $controller->getPlugin();
     $cache_manager = $plugin->getPlugin('Cachemanager', ucfirst($type));
     return $cache_manager;
 }
示例#5
0
/**
 *  smarty modifier:文字列のwordwrap処理
 *
 *  sample:
 *  <code>
 *  {"あいうaえaおaかきaaaくけこ"|wordwrap_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)
{
    $ctl = Ethna_Controller::getInstance();
    $client_enc = $ctl->getClientEncoding();
    //    いわゆる半角を単位にしてwrapする位置を測るため、いったん
    //    EUC_JP に変換する
    $euc_string = mb_convert_encoding($string, 'EUC_JP', $client_enc);
    $r = "";
    $i = "{$break}" . str_repeat(" ", $indent);
    $tmp = $euc_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');
        $tmp = substr($tmp, strlen($s));
        $r .= $s . (strlen($tmp) > 0 ? $i : '');
    } while (strlen($tmp) > 0);
    //    最後に、クライアントエンコーディングに変換
    $r = mb_convert_encoding($r, $client_enc, 'EUC_JP');
    return $r;
}
示例#6
0
文件: Echo.php 项目: t-f-m/ethna
 /**
  *  ログを出力する
  *
  *  @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));
     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 . ": ";
         }
     }
     $br = $c->getGateway() != GATEWAY_WWW ? "" : "<br />";
     echo $prefix . $message . $br . "\n";
     return $prefix . $message;
 }
 /**
  *  Cachemaanger プラグインのインスタンスを取得する
  *
  *  @param  string  $type   キャッシュタイプ('localfile', 'memcache'...)
  *  @return object  Ethna_Plugin_CacheMaanger   Cachemanager プラグインのインスタンス
  *  @access public
  */
 function &getInstance($type)
 {
     $controller =& Ethna_Controller::getInstance();
     $plugin =& $controller->getPlugin();
     $cache_manager =& $plugin->getPlugin('Cachemanager', ucfirst($type));
     return $cache_manager;
 }
 function setUp()
 {
     $ctl = Ethna_Controller::getInstance();
     $plugin = $ctl->getPlugin();
     $this->vld = $plugin->getPlugin('Validator', 'Strmax');
     $this->ctl = $ctl;
 }
 /**
  *  Ethna_UnitTestManagerのコンストラクタ
  *
  *  @access public
  *  @param  object  Ethna_Backend   &$backend   Ethna_Backendオブジェクト
  */
 function Ethna_UnitTestManager(&$backend)
 {
     parent::Ethna_AppManager($backend);
     $this->ctl =& Ethna_Controller::getInstance();
     $this->class_factory =& $this->ctl->getClassFactory();
     $this->testcase = array_merge($this->testcase, $this->_getTestCaseList());
 }
示例#10
0
/**
 *  smarty modifier:i18nフィルタ
 *
 *  sample:
 *  <code>
 *  {"you have %d apples"|i18n:$n}
 *  </code>
 *  <code>
 *  あなたはリンゴを3つ持っています。
 *  </code>
 *
 *  @param  string  $string i18n処理対象の文字列
 *  @param  mixed   $val    任意のパラメータ
 *  @return string  ロケールに対応したメッセージ
 */
function smarty_modifier_i18n($string, $arg1 = null)
{
    $c = Ethna_Controller::getInstance();
    $i18n = $c->getI18N();
    $msg = $i18n->get($string);
    return sprintf($msg, $arg1);
}
 /**
  *  遷移前処理
  *
  *  @access public
  */
 function preforward()
 {
     // タイムアウトしないように変更
     $max_execution_time = ini_get('max_execution_time');
     set_time_limit(0);
     if (!headers_sent()) {
         // キャッシュしない
         header("Expires: Thu, 01 Jan 1970 00:00:00 GMT");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s \\G\\M\\T"));
         header("Cache-Control: no-store, no-cache, must-revalidate");
         header("Cache-Control: post-check=0, pre-check=0", false);
         header("Pragma: no-cache");
     }
     $ctl =& Ethna_Controller::getInstance();
     // cores
     $this->af->setApp('app_id', $ctl->getAppId());
     $this->af->setApp('ethna_version', ETHNA_VERSION);
     // include
     $inc = sprintf("%s/%s_UnitTestManager.php", $ctl->getDirectory('app'), $ctl->getAppId());
     @(include_once "{$inc}");
     // run
     $r = sprintf("%s_UnitTestManager", $ctl->getAppId());
     $ut =& new $r($this->backend);
     list($report, $result) = $ut->run();
     // result
     $this->af->setApp('report', $report);
     $this->af->setApp('result', $result);
     // タイムアウトを元に戻す
     set_time_limit($max_execution_time);
 }
 function testCachemanagerLocalfile()
 {
     $ctl =& Ethna_Controller::getInstance();
     $plugin =& $ctl->getPlugin();
     $cm = $plugin->getPlugin('Cachemanager', 'Localfile');
     // 文字列のキャッシュ
     $string_key = 'string_key';
     $string_value = "cache\ncontent";
     $cm->set($string_key, $string_value, mktime(0, 0, 0, 7, 1, 2000));
     $cache_string = $cm->get($string_key);
     $this->assertTrue($cm->isCached($string_key));
     $this->assertEqual(mktime(0, 0, 0, 7, 1, 2000), $cm->getLastModified($string_key));
     $this->assertTrue($string_value, $cache_string);
     // 整数のキャッシュ + namespace
     $int_key = 'int_key';
     $int_value = 777;
     $namespace = 'test';
     $cm->set($int_key, $int_value, mktime(0, 0, 0, 7, 1, 2000), $namespace);
     $cache_int = $cm->get($int_key, mktime(0, 0, 0, 7, 1, 2000), $namespace);
     $this->assertTrue($cm->isCached($int_key, mktime(0, 0, 0, 7, 1, 2000), $namespace));
     $this->assertTrue($int_value, $cache_int);
     // オブジェクトのキャッシュ
     $object_key = 'object_key';
     $object_value =& $cm;
     $cm->set($object_key, $object_value);
     $this->assertTrue($cm->isCached($object_key));
     // キャッシュされたインスタンス
     $cache_object = $cm->get($object_key);
     $this->assertTrue($string_value, $cache_object->get($string_key));
     // キャッシュのクリアをテスト
     $cm->clear($object_key);
     $this->assertFalse($cm->isCached($object_key));
     // キャッシュされていないのに呼び出そうとした場合
     $nocache_key = 'nocache_key';
     $cm->clear($nocache_key);
     $pear_error = $cm->get($nocache_key);
     $this->assertEqual(E_CACHE_NO_VALUE, $pear_error->getCode());
     $this->assertEqual('fopen failed', $pear_error->getMessage());
     // ファイルに読み込み権限がない場合
     Ethna_Util::chmod($cm->_getCacheFile(null, $string_key), 0222);
     $pear_error = $cm->get($string_key);
     $this->assertEqual(E_CACHE_NO_VALUE, $pear_error->getCode());
     $this->assertEqual('fopen failed', $pear_error->getMessage());
     Ethna_Util::chmod($cm->_getCacheFile(null, $string_key), 0666);
     // lifetime切れの場合
     $pear_error = $cm->get($string_key, 1);
     $this->assertEqual(E_CACHE_EXPIRED, $pear_error->getCode());
     $this->assertEqual('fopen failed', $pear_error->getMessage());
     // ディレクトリ名と同じファイルがあってディレクトリが作成できない場合
     $tmp_key = 'tmpkey';
     $tmp_dirname = $cm->_getCacheDir(null, $tmp_key);
     Ethna_Util::mkdir(dirname($tmp_dirname), 0777);
     $tmp_file = fopen($tmp_dirname, 'w');
     fclose($tmp_file);
     $pear_error = $cm->set($tmp_key, $string_value);
     $this->assertEqual(E_USER_WARNING, $pear_error->getCode());
     $this->assertEqual("mkdir({$tmp_dirname}) failed", $pear_error->getMessage());
     $this->rm($cm->backend->getTmpdir());
 }
示例#13
0
/**
 *  smarty block:フォームタグ出力プラグイン
 */
function smarty_block_form($params, $content, &$smarty, &$repeat)
{
    if ($repeat) {
        // {form}: ブロック内部に進む前の処理
        // default
        if (isset($params['default']) === false) {
            // 指定なしのときは $form を使う
            $c = Ethna_Controller::getInstance();
            $af = $c->getActionForm();
            // c.f. http://smarty.php.net/manual/en/plugins.block.functions.php
            $smarty->_tag_stack[count($smarty->_tag_stack) - 1][1]['default'] = $af->getArray(false);
        }
        // 動的フォームヘルパを呼ぶ
        if (isset($params['ethna_action'])) {
            $ethna_action = $params['ethna_action'];
            $c = Ethna_Controller::getInstance();
            $view = $c->getView();
            $view->addActionFormHelper($ethna_action, true);
        }
        // ここで返す値は出力されない
        return '';
    } else {
        // {/form}: ブロック全体を出力
        $c = Ethna_Controller::getInstance();
        $view = $c->getView();
        if ($view === null) {
            return null;
        }
        // ethna_action
        if (isset($params['ethna_action'])) {
            $ethna_action = $params['ethna_action'];
            unset($params['ethna_action']);
            $view->addActionFormHelper($ethna_action);
            $hidden = $c->getActionRequest($ethna_action, 'hidden');
            $content = $hidden . $content;
            //デバグ用に、送信先のアクション名を表示する
            //超絶便利。これのおかげて開発効率だいぶあがった。
            if ($c->getConfig()->get('showFormActionName')) {
                echo "[" . $ethna_action . "]";
            }
        }
        // enctype の略称対応
        if (isset($params['enctype'])) {
            if ($params['enctype'] == 'file' || $params['enctype'] == 'multipart') {
                $params['enctype'] = 'multipart/form-data';
            } else {
                if ($params['enctype'] == 'url') {
                    $params['enctype'] = 'application/x-www-form-urlencoded';
                }
            }
        }
        // defaultはもう不要
        if (isset($params['default'])) {
            unset($params['default']);
        }
        // $contentを囲む<form>ブロック全体を出力
        return $view->getFormBlock($content, $params);
    }
}
示例#14
0
 function testMakeInstance()
 {
     $ctl = Ethna_Controller::getInstance();
     $plugin = $ctl->getPlugin();
     $this->csrf = $plugin->getPlugin('Csrf', 'Session');
     $this->assertTrue(is_object($this->csrf), 'getPlugin failed');
     $this->csrf->session = new Ethna_Session_Dummy($ctl, $ctl->appid);
 }
 function setUp()
 {
     $ctl = Ethna_Controller::getInstance();
     $plugin = $ctl->getPlugin();
     $config = $ctl->getConfig();
     $config->set('plugin', array('cachemanager' => array('memcache' => array('host' => 'localhost', 'port' => 11211, 'use_pconnect' => false, 'retry' => 4, 'timeout' => 5, 'info' => array('namespace1' => array(0 => array('host' => 'cache1.example.com', 'port' => 11211), 1 => array('host' => 'cache2.example.com', 'port' => 11211)))))));
     $this->cm = $plugin->getPlugin('Cachemanager', 'Memcache');
 }
 function setUp()
 {
     $ctl = Ethna_Controller::getInstance();
     $this->ctl = $ctl;
     $config = $ctl->getConfig();
     $config->set('plugin', array('cachemanager' => array('localfile' => array('test::int_key' => 'miyazakiaoi'))));
     $plugin = $ctl->getPlugin();
     $this->cm = $plugin->getPlugin('Cachemanager', 'Localfile');
 }
示例#17
0
文件: I18NTest.php 项目: t-f-m/ethna
 public function setUp()
 {
     $this->controller = new Ethna_Controller_Dummy();
     $this->form = new Ethna_ActionForm_Dummy($this->controller);
     $this->controller->setActionForm($this->form);
     $this->ae = new Ethna_ActionError();
     $ctl = Ethna_Controller::getInstance();
     $this->i18n = $ctl->getI18N();
 }
示例#18
0
/**
 *  smarty function:フォームのsubmitボタン生成
 *
 *  @param  string  $submit   フォーム項目名
 */
function smarty_function_form_submit($params, &$smarty)
{
    $c = Ethna_Controller::getInstance();
    $view = $c->getView();
    if ($view === null) {
        return null;
    }
    return $view->getFormSubmit($params);
}
示例#19
0
 /**
  *  Ethna_SOAP_GatewayGeneratorクラスのコンストラクタ
  *
  *  @access public
  */
 public function __construct()
 {
     $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();
 }
 /**
  *  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();
 }
示例#21
0
/**
 *  smarty function:フォームタグ生成
 *
 *  @param  string  $name   フォーム項目名
 */
function smarty_function_form_input($params, &$smarty)
{
    // name
    if (isset($params['name'])) {
        $name = $params['name'];
        unset($params['name']);
    } else {
        return null;
    }
    // view object
    $c = Ethna_Controller::getInstance();
    $view = $c->getView();
    if ($view === null) {
        return null;
    }
    // 現在の{form_input}を囲むform blockがあればパラメータを取得しておく
    $block_params = null;
    for ($i = count($smarty->_tag_stack); $i >= 0; --$i) {
        if ($smarty->_tag_stack[$i][0] === 'form') {
            $block_params = $smarty->_tag_stack[$i][1];
            break;
        }
    }
    // action
    $action = null;
    if (isset($params['action'])) {
        $action = $params['action'];
        unset($params['action']);
    } else {
        if (isset($block_params['ethna_action'])) {
            $action = $block_params['ethna_action'];
        }
    }
    if ($action !== null) {
        $view->addActionFormHelper($action, true);
    }
    // default
    if (isset($params['default'])) {
        // {form_input default=...}が指定されていればそのまま
    } else {
        if (isset($block_params['default'])) {
            // 外側の {form default=...} ブロック
            if (isset($block_params['default'][$name])) {
                $params['default'] = $block_params['default'][$name];
            }
        }
    }
    // 現在のアクションで受け取ったフォーム値
    $af = $c->getActionForm();
    $val = $af->get($name);
    if ($val !== null) {
        $params['default'] = $val;
    }
    return $view->getFormInput($name, $action, $params);
}
示例#22
0
/**
 *  smarty function:フォームのsubmitボタン生成
 *
 *  @param  string  $submit   フォーム項目名
 */
function smarty_function_form_submit($params, &$smarty)
{
    $c = Ethna_Controller::getInstance();
    $view = $c->getView();
    if ($view === null) {
        return null;
    }
    //ここでi18n変換をかます
    $params['value'] = _et($params['value']);
    return $view->getFormSubmit($params);
}
/**
 *  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();
    $elts = explode(".", $string);
    $r = $af->get($elts[0]);
    for ($i = 1; $i < count($elts); $i++) {
        $r = $r[$elts[$i]];
    }
    return htmlspecialchars($r, ENT_QUOTES);
}
/**
 *  smarty modifier:文字列切り詰め処理(i18n対応)
 *
 *  sample:
 *  <code>
 *  {"日本語です"|truncate_i18n:7:"..."}
 *  </code>
 *  <code>
 *  日本...
 *  </code>
 *
 *  @param  int     $len        最大文字幅
 *  @param  string  $postfix    末尾に付加する文字列
 */
function smarty_modifier_truncate_i18n($string, $len = 80, $postfix = "...")
{
    $ctl =& Ethna_Controller::getInstance();
    $client_enc = $ctl->getClientEncoding();
    //    いわゆる半角を単位にしてwrapする位置を測るため、いったん
    //    EUC_JP に変換する
    $euc_string = mb_convert_encoding($string, 'EUC_JP', $client_enc);
    $r = mb_strimwidth($euc_string, 0, $len, $postfix, 'EUC_JP');
    //    最後に、クライアントエンコーディングに変換
    $r = mb_convert_encoding($r, $client_enc, 'EUC_JP');
    return $r;
}
/**
 *	エラーコールバック関数
 *
 *	@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 ($facility != LOG_ECHO && ini_get('display_errors') && error_reporting() & $errno) {
        if ($c->getCLI()) {
            $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_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
  */
 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);
     // actions
     $this->af->setApp('action_list', $em->getActionList());
     // views
     $this->af->setApp('forward_list', $em->getForwardList());
     // configuration
     $this->af->setApp('configuration', $em->getConfiguration());
 }
 /**
  *	CRCFIDの初期化と設定を行う。セッション開始されてなければならない
  *
  *	@access	public
  *	@access	public
  *	@return	bool	true:成功 false:失敗
  */
 function setCSRF()
 {
     $c =& Ethna_Controller::getInstance();
     $session = $c->getSession();
     if (!$session->isStart(true)) {
         return false;
     }
     if (is_Null($session->get('__CSRF__'))) {
         $session->set('__CSRF__', Ethna_Util::getRandom());
     }
     $csrfid = $session->get('__CSRF__');
     $form = $c->getActionForm();
     $form->setApp('csrfid', $csrfid);
     return true;
 }
示例#29
0
/**
 *  smarty function:指定されたフォーム項目に対応するエラーメッセージを出力する
 *
 *  sample:
 *  <code>
 *  <input type="text" name="foo">{message name="foo"}
 *  </code>
 *  <code>
 *  <input type="text" name="foo">fooを入力してください
 *  </code>
 *
 *  @param  string  $name   フォーム項目名
 */
function smarty_function_message($params, &$smarty)
{
    if (isset($params['name']) === false) {
        return '';
    }
    $c = Ethna_Controller::getInstance();
    $action_error = $c->getActionError();
    $message = $action_error->getMessage($params['name']);
    if ($message === null) {
        return '';
    }
    $id = isset($params['id']) ? $params['id'] : str_replace("_", "-", "ethna-error-" . $params['name']);
    $class = isset($params['class']) ? $params['class'] : "ethna-error";
    return sprintf('<span class="%s" id="%s">%s</span>', $class, $id, htmlspecialchars($message, null, $c->getClientEncoding()));
}
示例#30
0
文件: I18N.php 项目: ethna/ethna-i18n
 /**
  *  Ethna_I18Nクラスのコンストラクタ
  *
  *  @access public
  *  @param  string  $locale_dir プロジェクトのロケールディレクトリ
  *  @param  string  $appid      アプリケーションID
  */
 public function __construct($locale_dir, $appid)
 {
     $this->locale_dir = $locale_dir;
     $this->appid = $appid;
     $this->ctl = Ethna_Controller::getInstance();
     $config = $this->ctl->getConfig();
     $this->logger = $this->ctl->getLogger();
     $this->use_gettext = $config->get('use_gettext') ? true : false;
     //    gettext load check.
     if ($this->use_gettext === true && !extension_loaded("gettext")) {
         $this->logger->log(LOG_WARNING, "You specify to use gettext in {$appid}/etc/{$appid}-ini.php, " . "but gettext extension was not installed !!!");
     }
     $this->messages = false;
     //  not initialized yet.
 }