本文整理汇总了PHP中Ethna类的典型用法代码示例。如果您正苦于以下问题:PHP Ethna类的具体用法?PHP Ethna怎么用?PHP Ethna使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ethna类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
/**
* 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;
}
示例2: perform
/**
* @access public
*/
function perform()
{
$args =& $this->_parseArgList();
if (Ethna::isError($args)) {
return $args;
}
$pear =& new Ethna_PearWrapper();
if (isset($args['pearopt'])) {
$pear->setPearOpt($args['pearopt']);
}
$target = isset($args['target']) ? $args['target'] : null;
$channel = isset($args['channel']) ? $args['channel'] : null;
$basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
$r =& $pear->init($target, $basedir, $channel);
if (Ethna::isError($r)) {
return $r;
}
$r =& $pear->doClearCache();
if (Ethna::isError($r)) {
return $r;
}
$r =& $pear->doChannelUpdate();
if (Ethna::isError($r)) {
return $r;
}
return true;
}
示例3: realpath
/**
* @access protected
*/
function &_perform($target, $target_name, $opt_list)
{
// basedir
if (isset($opt_list['basedir'])) {
$basedir = realpath(end($opt_list['basedir']));
} else {
$basedir = getcwd();
}
// skelfile
if (isset($opt_list['skelfile'])) {
$skelfile = end($opt_list['skelfile']);
} else {
$skelfile = null;
}
// gateway
if (isset($opt_list['gateway'])) {
$gateway = 'GATEWAY_' . strtoupper(end($opt_list['gateway']));
if (defined($gateway)) {
$gateway = constant($gateway);
} else {
return Ethna::raiseError('unknown gateway', 'usage');
}
} else {
$gateway = GATEWAY_WWW;
}
$r =& Ethna_Generator::generate($target, $basedir, $target_name, $skelfile, $gateway);
if (Ethna::isError($r)) {
printf("error occurred while generating skelton. please see also following error message(s)\n\n");
return $r;
}
$true = true;
return $true;
}
示例4: CommitTransaction
/**
* commitTransaction
* トランザクションを終了し、全ての変更をコミットする
*
* @return 成功時:true 失敗時:false
*/
public function CommitTransaction()
{
if (Ethna::isError($this->db->commit())) {
return false;
}
return true;
}
示例5: perform
/**
* show help
*
* @access public
*/
function perform()
{
$r = $this->_getopt();
if (Ethna::isError($r)) {
return $r;
}
list($opt_list, $arg_list) = $r;
// action_name
$handle_name = array_shift($arg_list);
if (!strlen($handle_name)) {
$handler_list = $this->eh->getHandlerList();
printf("usage: ethna [option] [command] [args...]\n\n");
printf("available options are as follows:\n\n");
printf(" -v, --version show version and exit\n");
printf("\navailable commands are as follows:\n\n");
foreach ($handler_list as $handler) {
printf(" %s\n", $handler->getId());
}
return true;
}
// getHandler
$handler = $this->eh->getHandler($handle_name);
if (Ethna::isError($handler) || $handler === false) {
// command not found
return Ethna::raiseError('command not found.', 'usage');
}
echo $handler->getDescription();
return true;
}
示例6: perform
/**
* ビューを出力する
*
* @param string $template テンプレート名
* @param bool $capture true ならば出力を表示せずに返す
*
* @access public
*/
function perform($template = null, $capture = false)
{
if ($template === null && $this->template === null) {
return Ethna::raiseWarning('template is not defined');
}
if ($template !== null) {
$this->template = $template;
}
if (!is_absolute_path($this->template)) {
$this->template = sprintf('%s%s', $this->template_dir, $this->template);
}
if (is_readable($this->template)) {
ob_start();
include $this->template;
$captured = ob_get_contents();
ob_end_clean();
if ($capture === true) {
return $captured;
} else {
echo $captured;
}
} else {
return Ethna::raiseWarning('template not found ' . $this->template);
}
}
示例7: _perform
/**
* @access protected
*/
function _perform($target)
{
$r =& $this->_getopt(array('basedir='));
if (Ethna::isError($r)) {
return $r;
}
list($opt_list, $arg_list) = $r;
// table_name
$table_name = array_shift($arg_list);
if ($table_name == null) {
return Ethna::raiseError('table name isn\'t set.', 'usage');
}
// basedir
if (isset($opt_list['basedir'])) {
$basedir = realpath(end($opt_list['basedir']));
} else {
$basedir = getcwd();
}
$r =& Ethna_Generator::generate($target, $basedir, $table_name);
if (Ethna::isError($r)) {
printf("error occurred while generating skelton. please see also following error message(s)\n\n");
return $r;
}
return true;
}
示例8: validate
/**
* 最小値のチェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
public function validate($name, $var, $params)
{
$true = true;
$type = $this->getFormType($name);
if (isset($params['min']) == false || $this->isEmpty($var, $type)) {
return $true;
}
switch ($type) {
case VAR_TYPE_INT:
if ($var < $params['min']) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input more than %d(int) to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_INT, array($params['min']));
}
break;
case VAR_TYPE_FLOAT:
if ($var < $params['min']) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input more than %f(float) to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_FLOAT, array($params['min']));
}
break;
case VAR_TYPE_DATETIME:
$t_min = strtotime($params['min']);
$t_var = strtotime($var);
if ($t_var < $t_min) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input datetime value %s or later to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_DATETIME, array($params['min']));
}
break;
case VAR_TYPE_FILE:
$st = stat($var['tmp_name']);
if ($st[7] < $params['min'] * 1024) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please specify file whose size is more than %d KB.');
}
return Ethna::raiseNotice($msg, E_FORM_MIN_FILE, array($params['min']));
}
break;
case VAR_TYPE_STRING:
$params['mbstrmin'] = $params['min'];
unset($params['min']);
$vld = $this->plugin->getPlugin('Validator', 'Mbstrmin');
return $vld->validate($name, $var, $params);
break;
}
return $true;
}
示例9: perform
/**
* @access public
*/
function perform()
{
$args =& $this->_parseArgList();
if (Ethna::isError($args)) {
return $args;
}
$pear =& new Ethna_PearWrapper();
if (isset($args['pearopt'])) {
$pear->setPearOpt($args['pearopt']);
}
if (isset($args['type']) && isset($args['name'])) {
$target = isset($args['target']) ? $args['target'] : null;
$channel = isset($args['channel']) ? $args['channel'] : null;
$basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
if ($target == 'master') {
$pkg_name = sprintf('Ethna_Plugin_%s_%s', $args['type'], $args['name']);
} else {
$pkg_name = sprintf('App_Plugin_%s_%s', $args['type'], $args['name']);
}
$r =& $pear->init($target, $basedir, $channel);
if (Ethna::isError($r)) {
return $r;
}
$r =& $pear->doInfo($pkg_name);
if (Ethna::isError($r)) {
return $r;
}
} else {
return Ethna::raiseError('invalid arguments', 'usage');
}
return true;
}
示例10: perform
/**
* 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;
}
示例11: test_cmd_option
function test_cmd_option()
{
// unrecognized option
$r = $this->proj->runCmd('add-template', array('-k'));
$this->assertTrue(Ethna::isError($r));
$this->assertEqual('unrecognized option -k', $r->getMessage());
// skel requires an argument
$r = $this->proj->runCmd('add-template', array('-s'));
$this->assertTrue(Ethna::isError($r));
$this->assertEqual('option -s requires an argument', $r->getMessage());
$r = $this->proj->runCmd('add-template', array('--skelfile'));
$this->assertTrue(Ethna::isError($r));
$this->assertEqual('option --skelfile requires an argument', $r->getMessage());
// locale requires an argument
$r = $this->proj->runCmd('add-template', array('-l'));
$this->assertTrue(Ethna::isError($r));
$this->assertEqual('option -l requires an argument', $r->getMessage());
$r = $this->proj->runCmd('add-template', array('--locale'));
$this->assertTrue(Ethna::isError($r));
$this->assertEqual('option --locale requires an argument', $r->getMessage());
// template name isn't set
$r = $this->proj->runCmd('add-template', array());
$this->assertTrue(Ethna::isError($r));
$this->assertEqual('template name isn\'t set.', $r->getMessage());
// invalid locale
$r = $this->proj->runCmd('add-template', array('-l', 'invalid::locale', 'test'));
$this->assertTrue(Ethna::isError($r));
$this->assertEqual('You specified locale, but invalid : invalid::locale', $r->getMessage());
// normal command exexute
$r = $this->proj->runCmd('add-template', array('-l', 'ja_JP', 'test'));
$this->assertFalse(Ethna::isError($r));
}
示例12: preforward
function preforward()
{
$item_manager = $this->backend->getManager('Item');
$filter = array('price' => new Ethna_AppSearchObject(0, OBJECT_CONDITION_GE));
$order = array('price' => OBJECT_SORT_DESC);
$offset = 0;
$count = 10;
$object_list_result = $item_manager->getObjectList('Item', $filter, $order, $offset, $count);
if (Ethna::isError($object_list_result)) {
$this->ae->addObject(null, $object_list_result);
return;
}
$item_list = array();
foreach ($object_list_result[1] as $item_object) {
if ($item_object->get('type') == ITEM_TYPE_BEER) {
$type_name = 'ビール';
} else {
if ($item_object->get('type') == ITEM_TYPE_SNACK) {
$type_name = 'お菓子';
}
}
$item_tmp = $item_object->getNameObject();
$item_tmp['type_name'] = $type_name;
$item_list[] = $item_tmp;
}
$this->af->setApp('item_list', $item_list);
$this->session->start();
// omajinai
$user_object = $this->backend->getObject('User', 'id', $this->session->get('id'));
if ($user_object->isValid()) {
$this->af->setApp('user', $user_object->getNameObject());
}
}
示例13: perform
/**
* 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;
}
示例14: Ethna_Error
/**
* 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);
}
示例15: func_get_args
/**
* スケルトンを削除する
*
* @access public
* @param string $type 生成する対象
* @param string $app_dir アプリケーションのディレクトリ
* (nullのときはアプリケーションを特定しない)
* @param mixed residue プラグインのremove()にそのまま渡す
* @static
*/
function &remove()
{
$arg_list = func_get_args();
$type = array_shift($arg_list);
$app_dir = array_shift($arg_list);
if ($app_dir === null) {
$ctl =& Ethna_Handle::getEthnaController();
} else {
$ctl =& Ethna_Handle::getAppController($app_dir);
}
if (Ethna::isError($ctl)) {
return $ctl;
}
$plugin_manager =& $ctl->getPlugin();
if (Ethna::isError($plugin_manager)) {
return $plugin_manager;
}
$generator =& $plugin_manager->getPlugin('Generator', $type);
if (Ethna::isError($generator)) {
return $generator;
}
// 引数はプラグイン依存とする
$ret = call_user_func_array(array(&$generator, 'remove'), $arg_list);
return $ret;
}