示例#1
0
文件: Session.php 项目: t-f-m/ethna
 /**
  *  Ethna_Sessionクラスのコンストラクタ
  *
  *  @access public
  *  @param  string  $appid      アプリケーションID(セッション名として使用)
  *  @param  string  $save_dir   セッションデータを保存するディレクトリ
  */
 public function __construct($ctl, $appid)
 {
     $this->ctl = $ctl;
     $this->logger = $this->ctl->getLogger();
     $config = $this->ctl->getConfig()->get('session');
     if ($config) {
         $this->config = array_merge($this->config, $config);
     }
     $this->session_save_dir = $this->config['path'];
     if (($dir = $this->ctl->getDirectory($this->config['path'])) !== null) {
         $this->session_save_dir = $dir;
     }
     $this->session_name = $appid . $this->config['suffix'];
     // set session handler
     ini_set('session.save_handler', $this->config['handler']);
     session_save_path($this->session_save_dir);
     session_name($this->session_name);
     session_cache_limiter($this->config['cache_limiter']);
     session_cache_expire($this->config['cache_expire']);
     $this->session_start = false;
     if (isset($_SERVER['REQUEST_METHOD']) == false) {
         return;
     }
     if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0) {
         $http_vars = $_POST;
     } else {
         $http_vars = $_GET;
     }
     if (array_key_exists($this->session_name, $http_vars) && $http_vars[$this->session_name] != null) {
         $_COOKIE[$this->session_name] = $http_vars[$this->session_name];
     }
 }
示例#2
0
文件: Filter.php 项目: t-f-m/ethna
 /**
  *  Ethna_Filterのコンストラクタ
  *
  *  @access public
  *  @param  object  Ethna_Controller    &$controller    コントローラオブジェクト
  */
 public function __construct(&$controller)
 {
     // オブジェクトの設定
     $this->controller = $controller;
     $this->ctl = $this->controller;
     $this->config = $controller->getConfig();
     $this->logger = $this->controller->getLogger();
 }
 function setUp()
 {
     $ctl = new Ethna_Controller();
     $ctl->setClientEncoding('EUC-JP');
     $ctl->setActionForm(new Ethna_ActionForm($ctl));
     $this->local_ctl = $ctl;
     $plugin = $ctl->getPlugin();
     $this->vld = $plugin->getPlugin('Validator', 'Strmincompat');
 }
 /**
  *  check arguments
  *
  *  @access private
  */
 function _validateArgList()
 {
     $arg_list = array();
     if (count($this->arg_list) < 1) {
         return Ethna::raiseError('too few argments', 'usage');
     } else {
         if (count($this->arg_list) > 2) {
             return Ethna::raiseError('too many argments', 'usage');
         } else {
             if (count($this->arg_list) == 1) {
                 $arg_list[] = $this->arg_list[0];
                 $arg_list[] = getcwd();
             } else {
                 $arg_list = $this->arg_list;
             }
         }
     }
     $r = Ethna_Controller::checkAppId($arg_list[0]);
     if (Ethna::isError($r)) {
         return $r;
     }
     if (is_dir($arg_list[1]) == false) {
         return Ethna::raiseError("no such directory [{$arg_list[1]}]");
     }
     return $arg_list;
 }
示例#5
0
 /**
  *  add action entry point
  *
  *  @access public
  */
 function perform()
 {
     $r = $this->_getopt(array('basedir=', 'skelfile=', 'gateway='));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // action_name
     $action_name = array_shift($arg_list);
     if ($action_name == null) {
         return Ethna::raiseError('action name isn\'t set.', 'usage');
     }
     $r = Ethna_Controller::checkActionName($action_name);
     if (Ethna::isError($r)) {
         return $r;
     }
     // add entry point
     $ret = $this->_perform('EntryPoint', $action_name, $opt_list);
     if (Ethna::isError($ret) || $ret === false) {
         return $ret;
     }
     // add action (no effects if already exists.)
     $ret = $this->_perform('Action', $action_name, $opt_list);
     if (Ethna::isError($ret) || $ret === false) {
         return $ret;
     }
     return true;
 }
 /**
  *	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);
 }
示例#7
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;
 }
 /**
  *  遷移前処理
  *
  *  @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);
 }
示例#9
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;
 }
 /**
  *  add view
  *
  *  @access public
  */
 function perform()
 {
     $r =& $this->_getopt(array('basedir=', 'skelfile=', 'template'));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // view_name
     $view_name = array_shift($arg_list);
     if ($view_name == null) {
         return Ethna::raiseError('view name isn\'t set.', 'usage');
     }
     $r =& Ethna_Controller::checkViewName($view_name);
     if (Ethna::isError($r)) {
         return $r;
     }
     // add view
     $ret =& $this->_perform('View', $view_name, $opt_list);
     if (Ethna::isError($ret) || $ret === false) {
         return $ret;
     }
     // add template
     if (isset($opt_list['template'])) {
         $ret =& $this->_perform('Template', $view_name, $opt_list);
         if (Ethna::isError($ret) || $ret === false) {
             return $ret;
         }
     }
     return true;
 }
示例#11
0
 /**
  * (non-PHPdoc)
  * @see class/Ethna_Controller#_getActionName_Form()
  */
 function _getActionName_Form()
 {
     if (isset($_SERVER['REQUEST_METHOD']) == false) {
         return null;
     }
     if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0) {
         $http_vars =& $_POST;
     } else {
         $http_vars =& $_GET;
     }
     foreach ($http_vars as $name => $value) {
         if ($value == "" || strncmp($name, 'action_', 7) != 0) {
             continue;
         }
         // オリジナル方式 http://hostname/?action_action_name
         return parent::_getActionName_Form();
     }
     // かっこいい http://hostname/action/name/ 方式
     if (!empty($_SERVER['REDIRECT_URL'])) {
         $redirect_url = $_SERVER['REDIRECT_URL'];
         $action_name = str_replace('/', '_', $redirect_url);
         return trim($action_name, '_');
     }
     // まあ悪くはない http://hostname/?action=action_name 方式
     if (array_key_exists('action', $http_vars)) {
         return $http_vars['action'];
     }
 }
 function setUp()
 {
     $ctl = Ethna_Controller::getInstance();
     $plugin = $ctl->getPlugin();
     $this->vld = $plugin->getPlugin('Validator', 'Strmax');
     $this->ctl = $ctl;
 }
 /**
  *  add action
  *
  *  @access public
  */
 function perform()
 {
     //
     //  '-w[with-unittest]' and '-u[unittestskel]' option
     //  are not intuisive, but I dare to define them because
     //  -t and -s option are reserved by add-[action|view] handle
     //  and Ethna_Getopt cannot interpret two-character option.
     //
     $r = $this->_getopt(array('basedir=', 'skelfile=', 'gateway=', 'with-unittest', 'unittestskel='));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // action_name
     $action_name = array_shift($arg_list);
     if ($action_name == null) {
         return Ethna::raiseError('action name isn\'t set.', 'usage');
     }
     $r =& Ethna_Controller::checkActionName($action_name);
     if (Ethna::isError($r)) {
         return $r;
     }
     $ret =& $this->_perform('Action', $action_name, $opt_list);
     return $ret;
 }
示例#14
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);
}
示例#15
0
文件: Renderer.php 项目: t-f-m/ethna
 /**
  *  Ethna_Rendererクラスのコンストラクタ
  *
  *  @access public
  */
 public function __construct($controller)
 {
     $this->controller = $controller;
     $this->ctl = $this->controller;
     $this->engine = null;
     $this->template = null;
     $this->prop = array();
     $this->plugin_registry = array();
     $template_dir = $controller->getTemplatedir();
     $this->template_dir = $template_dir;
     // load configuration
     $config = $this->ctl->getConfig();
     $renderer_config = $config->get('renderer');
     $this->config = $this->mergeConfig($this->config_default, isset($renderer_config[$this->getName()]) ? $renderer_config[$this->getName()] : array());
     $this->logger = $this->controller->getBackend()->getLogger();
 }
示例#16
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());
 }
示例#17
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;
}
 /**
  *  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());
 }
 /**
  *  add project:)
  *
  *  @access public
  */
 function perform()
 {
     $r = $this->_getopt(array('basedir='));
     if (Ethna::isError($r)) {
         return $r;
     }
     list($opt_list, $arg_list) = $r;
     // app_id
     $app_id = array_shift($arg_list);
     if ($app_id == null) {
         return Ethna::raiseError('project id isn\'t set.', 'usage');
     }
     $r = Ethna_Controller::checkAppId($app_id);
     if (Ethna::isError($r)) {
         return $r;
     }
     // basedir
     if (isset($opt_list['basedir'])) {
         $basedir = realpath(end($opt_list['basedir']));
     } else {
         $basedir = getcwd();
     }
     $r = Ethna_Generator::generate('Project', null, $app_id, $basedir);
     if (Ethna::isError($r)) {
         printf("error occurred while generating skelton. please see also error messages given above\n\n");
         return $r;
     }
     printf("\nproject skelton for [%s] is successfully generated at [%s]\n\n", $app_id, $basedir);
     return true;
 }
/**
 *  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);
}
 /**
  *  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 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());
 }
示例#23
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);
    }
}
 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');
 }
示例#25
0
 public function testSetGet()
 {
     $controller = $this->controller->reveal();
     $action_form = new Ethna_Mock_ActionForm($controller);
     $this->assertNull($action_form->get("name"), "action form should return correct value");
     $action_form->set("name", "chobie");
     $this->assertEquals("chobie", $action_form->get("name"), "action form should return correct value");
 }
示例#26
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();
     $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');
 }
示例#28
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);
}
示例#29
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();
 }
示例#30
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();
 }