本文整理汇总了PHP中Ethna_Util类的典型用法代码示例。如果您正苦于以下问题:PHP Ethna_Util类的具体用法?PHP Ethna_Util怎么用?PHP Ethna_Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ethna_Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: array
/**
* テンプレートのスケルトンを生成する
*
* @access public
* @param string $forward_name テンプレート名
* @param string $skelton スケルトンファイル名
* @return true|Ethna_Error true:成功 Ethna_Error:失敗
*/
function &generate($forward_name, $skelton = null)
{
$tpl_dir = $this->ctl->getTemplatedir();
if ($tpl_dir[strlen($tpl_dir) - 1] != '/') {
$tpl_dir .= '/';
}
$tpl_path = $this->ctl->getDefaultForwardPath($forward_name);
// entity
$entity = $tpl_dir . $tpl_path;
Ethna_Util::mkdir(dirname($entity), 0755);
// skelton
if ($skelton === null) {
$skelton = 'skel.template.tpl';
}
// macro
$macro = array();
// add '_' for tpl and no user macro for tpl
$macro['_project_id'] = $this->ctl->getAppId();
// generate
if (file_exists($entity)) {
printf("file [%s] already exists -> skip\n", $entity);
} else {
if ($this->_generateFile($skelton, $entity, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $entity);
} else {
printf("template file(s) successfully created [%s]\n", $entity);
}
}
$true = true;
return $true;
}
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:39,代码来源:Ethna_Plugin_Generator_Template.php
示例2: array
/**
* ビューのスケルトンを生成する
*
* @access public
* @param string $forward_name ビュー名
* @param string $skelton スケルトンファイル名
* @return true|Ethna_Error true:成功 Ethna_Error:失敗
*/
function &generate($forward_name, $skelton = null, $gateway = GATEWAY_WWW)
{
$view_dir = $this->ctl->getViewdir();
$view_class = $this->ctl->getDefaultViewClass($forward_name, $gateway);
$view_path = $this->ctl->getDefaultViewPath($forward_name);
// entity
$entity = $view_dir . $view_path;
Ethna_Util::mkdir(dirname($entity), 0755);
// skelton
if ($skelton === null) {
$skelton = 'skel.view.php';
}
// macro
$macro = array();
$macro['project_id'] = $this->ctl->getAppId();
$macro['forward_name'] = $forward_name;
$macro['view_class'] = $view_class;
$macro['view_path'] = $view_path;
// user macro
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
// generate
if (file_exists($entity)) {
printf("file [%s] already exists -> skip\n", $entity);
} else {
if ($this->_generateFile($skelton, $entity, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $entity);
} else {
printf("view script(s) successfully created [%s]\n", $entity);
}
}
$true = true;
return $true;
}
开发者ID:weiweiabc109,项目名称:test_project1,代码行数:42,代码来源:Ethna_Plugin_Generator_View.php
示例3: ucfirst
/**
* ScaffoldSmartyPlugin を生成する
*
* @access public
*/
function &generate()
{
$app_dir = $this->ctl->getDirectory('app');
$app_path = ucfirst($this->ctl->getAppId()) . '_ScaffoldSmartyPlugin.php';
$macro = array();
$macro['project_id'] = $this->ctl->getAppId();
$macro['file_path'] = $app_path;
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
// ファイル生成
$filePath = "{$app_dir}/{$app_path}";
Ethna_Util::mkdir(dirname($filePath), 0755);
$skelton = "skel.scaffold-smartyPlugin.php";
if (file_exists($filePath)) {
printf("file [%s] already exists -> skip\n", $filePath);
} else {
if ($this->_generateFile($skelton, $filePath, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $filePath);
} else {
printf("action script(s) successfully created [%s]\n", $filePath);
}
}
$true = true;
return $true;
}
开发者ID:bobpp,项目名称:php-Ethna-Ethcaffold,代码行数:30,代码来源:Ethna_Plugin_Generator_ScaffoldSmartyPlugin.php
示例4: __construct
/**
* Constructor for Ethna_Renderer_Smarty3
*
* @access public
*/
public function __construct($controller)
{
parent::__construct($controller);
// get renderer config
$smarty_config = isset($this->config['smarty3']) ? $this->config['smarty3'] : array();
$this->loadEngine($smarty_config);
$this->engine = new Smarty();
// Configurerd by controller
$template_dir = $controller->getTemplatedir();
$compile_dir = $controller->getDirectory('template_c');
$this->setTemplateDir($template_dir);
$this->compile_dir = $compile_dir;
$this->engine->template_dir = $template_dir;
$this->engine->compile_dir = $compile_dir;
$this->engine->compile_id = md5($this->template_dir);
if (isset($smarty_config['left_delimiter'])) {
$this->engine->left_delimiter = $smarty_config['left_delimiter'];
}
if (isset($smarty_config['right_delimiter'])) {
$this->engine->right_delimiter = $smarty_config['right_delimiter'];
}
// make compile dir
if (is_dir($this->engine->compile_dir) === false) {
Ethna_Util::mkdir($this->engine->compile_dir, 0755);
}
$this->engine->inheritance = true;
$this->engine->plugins_dir = array_merge($controller->getDirectory('plugins'), array(ETHNA_BASE . '/class/Plugin/Smarty', SMARTY_DIR . 'plugins'));
}
开发者ID:riaf,项目名称:pastit,代码行数:33,代码来源:Smarty3.php
示例5: __construct
/**
* Ethna_Renderer_Smartyクラスのコンストラクタ
*
* @access public
*/
public function __construct($controller)
{
parent::__construct($controller);
$this->engine = new Smarty();
// ディレクトリ関連は Controllerによって実行時に設定
// TODO: iniファイルによって上書き可にするかは要検討
$template_dir = $controller->getTemplatedir();
$compile_dir = $controller->getDirectory('template_c');
$this->setTemplateDir($template_dir);
$this->compile_dir = $compile_dir;
$this->engine->template_dir = $this->template_dir;
$this->engine->compile_dir = $this->compile_dir;
$this->engine->compile_id = md5($this->template_dir);
// デリミタは Ethna_Config を見る
$smarty_config = isset($this->config['smarty']) ? $this->config['smarty'] : array();
if (array_key_exists('left_delimiter', $smarty_config)) {
$this->engine->left_delimiter = $smarty_config['left_delimiter'];
}
if (array_key_exists('right_delimiter', $smarty_config)) {
$this->engine->right_delimiter = $smarty_config['right_delimiter'];
}
// コンパイルディレクトリは必須なので一応がんばってみる
if (is_dir($this->engine->compile_dir) === false) {
Ethna_Util::mkdir($this->engine->compile_dir, 0755);
}
$this->engine->plugins_dir = array_merge($controller->getDirectory('plugins'), array(ETHNA_BASE . '/class/Plugin/Smarty', SMARTY_DIR . 'plugins'));
}
开发者ID:riaf,项目名称:ethna,代码行数:32,代码来源:Smarty.php
示例6: generate
/**
* テンプレートのスケルトンを生成する
*
* @access public
* @param string $forward_name テンプレート名
* @param string $skelton スケルトンファイル名
* @param string $locale ロケール名
* @param string $encoding エンコーディング
* @return true|Ethna_Error true:成功 Ethna_Error:失敗
*/
function generate($forward_name, $skelton = null, $locale, $encoding)
{
// ロケールが指定された場合は、それを優先する
if (!empty($locale)) {
$this->ctl->setLocale($locale);
}
// ロケール名がディレクトリに含まれていない場合は、
// ディレクトリがないためなのでそれを補正
$tpl_dir = $this->ctl->getTemplatedir();
$tpl_path = $this->ctl->getDefaultForwardPath($forward_name);
// entity
$entity = $tpl_dir . '/' . $tpl_path;
Ethna_Util::mkdir(dirname($entity), 0755);
// skelton
if ($skelton === null) {
$skelton = 'skel.template.tpl';
}
// macro
$macro = array();
// add '_' for tpl and no user macro for tpl
$macro['_project_id'] = $this->ctl->getAppId();
$macro['client_enc'] = $encoding;
// generate
if (file_exists($entity)) {
printf("file [%s] already exists -> skip\n", $entity);
} else {
if ($this->_generateFile($skelton, $entity, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $entity);
} else {
printf("template file(s) successfully created [%s]\n", $entity);
}
}
$true = true;
return $true;
}
开发者ID:hiroki-ta,项目名称:my.project,代码行数:45,代码来源:Template.php
示例7: generate
/**
* アプリケーションオブジェクトのスケルトンを生成する
*
* @access public
* @param string $table_name テーブル名
* @return bool true:成功 false:失敗
*/
function generate($table_name)
{
$table_id = preg_replace_callback('/_(.)/', function (array $matches) {
return strtoupper($matches[1]);
}, ucfirst($table_name));
$app_dir = $this->ctl->getDirectory('app');
$app_path = ucfirst($this->ctl->getAppId()) . '_' . $table_id . '.php';
$macro = array();
$macro['project_id'] = $this->ctl->getAppId();
$macro['app_path'] = $app_path;
$macro['app_object'] = ucfirst($this->ctl->getAppId()) . '_' . $table_id;
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
$path = "{$app_dir}/{$app_path}";
Ethna_Util::mkdir(dirname($path), 0755);
if (file_exists($path)) {
printf("file [%s] already exists -> skip\n", $path);
} else {
if ($this->_generateFile("skel.app_object.php", $path, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $path);
} else {
printf("app-object script(s) successfully created [%s]\n", $path);
}
}
}
开发者ID:ethna,项目名称:ethna-generator,代码行数:32,代码来源:AppObject.php
示例8: array
/**
* ScaffoldActionForm を生成する
*
* @access public
* @param $model string テーブル名
* @param $modelDefine array モデル定義
* @param $formDef array フォーム定義
*/
function &generate($model, $modelDefine, $formDef)
{
$table_id = $this->_getTableId($model);
$project_id = $this->ctl->getAppId();
$dir = $this->ctl->getDirectory('action_form');
if ($dir == null) {
$dir = $this->ctl->getDirectory('app') . "/action_form/";
}
$file = "{$project_id}_{$table_id}_ActionForm.php";
// Macro
$macro = array();
$macro['model'] = $model;
$macro['modelName'] = $table_id;
$macro['modelUName'] = strtoupper($table_id);
$macro['project_id'] = $project_id;
$macro['column_name_file'] = $this->_getColumnNamePath($table_id);
$macro['form_define'] = $this->_getActionFormDefine($formDef);
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
$skelton = "skel.scaffold-actionform.php";
// ファイル生成
$path = "{$dir}{$file}";
Ethna_Util::mkdir(dirname($path), 0755);
if (file_exists($path)) {
printf("file [%s] already exists -> skip\n", $path);
} else {
if ($this->_generateFile($skelton, $path, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $path);
} else {
printf("action script(s) successfully created [%s]\n", $path);
}
}
$true = true;
return $true;
}
开发者ID:bobpp,项目名称:php-Ethna-Ethcaffold,代码行数:43,代码来源:Ethna_Plugin_Generator_ScaffoldActionForm.php
示例9: ucfirst
/**
* ScaffoldAppObject を生成する
*
* @access public
* @param $table_name string テーブル名
*/
function &generate($table_name)
{
$table_id = $this->_getTableId($table_name);
$app_dir = $this->ctl->getDirectory('app');
$app_path = ucfirst($this->ctl->getAppId()) . '_' . $table_id . '.php';
$baseClass_path = ucfirst($this->ctl->getAppId()) . '_AppBase_AppObject.php';
// マクロ
$macro = array();
$macro['model'] = $table_name;
$macro['modelName'] = $table_id;
$macro['modelUName'] = strtoupper($table_id);
$macro['project_id'] = $this->ctl->getAppId();
$macro['app_path'] = $app_path;
$macro['app_object'] = ucfirst($this->ctl->getAppId()) . '_' . $table_id;
$macro['column_name_file'] = $this->_getColumnNamePath($table_id);
$macro['base_class_file'] = $baseClass_path;
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
// ファイル生成
$path = "{$app_dir}/{$app_path}";
Ethna_Util::mkdir(dirname($path), 0755);
if (file_exists($path)) {
printf("file [%s] already exists -> skip\n", $path);
} else {
if ($this->_generateFile("skel.scaffold-appobject.php", $path, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $path);
} else {
printf("app-object script(s) successfully created [%s]\n", $path);
}
}
$true = true;
return $true;
}
开发者ID:bobpp,项目名称:php-Ethna-Ethcaffold,代码行数:39,代码来源:Ethna_Plugin_Generator_ScaffoldAppObject.php
示例10: __construct
/**
* Ethna_Renderer_Smartyクラスのコンストラクタ
*
* @access public
*/
public function __construct($controller)
{
parent::__construct($controller);
// get renderer config
$smarty_config = $this->config;
// load template engine
$this->loadEngine($smarty_config);
$this->engine = new Smarty();
// ディレクトリ関連は Controllerによって実行時に設定
$template_dir = $controller->getTemplatedir();
$compile_dir = $controller->getDirectory('template_c');
$this->setTemplateDir($template_dir);
$this->compile_dir = $compile_dir;
$this->engine->template_dir = $this->template_dir;
$this->engine->compile_dir = $this->compile_dir;
$this->engine->compile_id = md5($this->template_dir);
// delimiter setting
$this->engine->left_delimiter = $smarty_config['left_delimiter'];
$this->engine->right_delimiter = $smarty_config['right_delimiter'];
// コンパイルディレクトリは必須なので一応がんばってみる
if (is_dir($this->engine->compile_dir) === false) {
Ethna_Util::mkdir($this->engine->compile_dir, 0755);
}
$this->engine->plugins_dir = array_merge($controller->getDirectory('plugins'), array(ETHNA_BASE . '/class/Plugin/Smarty', SMARTY_DIR . 'plugins'));
}
开发者ID:hiroki-ta,项目名称:my.project,代码行数:30,代码来源:Smarty.php
示例11: testCachemanagerLocalfile
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());
}
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:59,代码来源:Ethna_Plugin_Cachemanager_Localfile_Test.php
示例12: array
/**
* ScaffoldTemplates を生成する
*
* @access public
* @param string $baseAction ベースのアクション名
* @param string $model モデル名
* @param array $modelDefine モデル定義
* @param string $idDefine 主キー名
* @param array $formDef フォーム定義
*/
function &generate($baseAction, $model, $modelDefine, $idDefine, $formDef)
{
// Template Directory
$tpl_dir = $this->ctl->getTemplatedir();
if ($tpl_dir[strlen($tpl_dir) - 1] != '/') {
$tpl_dir .= '/';
}
$table_id = $this->_getTableId($model);
// Generating Templates
$templates = array('list' => array('title' => sprintf("Listing {model_name model='%s'}", $table_id), 'template' => 'list', 'headerTag' => $this->_getListHeaderTags($modelDefine, $table_id), 'mainTag' => $this->_getListMainTags($modelDefine, $table_id)), 'read' => array('title' => sprintf("Show {model_name model='%s'}", $table_id), 'template' => 'item', 'itemTag' => $this->_getItemMainTag($modelDefine, $table_id)), 'form_create' => array('title' => sprintf("New {model_name model='%s'}", $table_id), 'template' => 'form', 'formTag' => $this->_getFormMainTag($formDef, null, array($idDefine)), 'action' => $this->_getFullAction($baseAction, 'create_do')), 'form_update' => array('title' => sprintf("Editing {model_name model='%s'}", $table_id), 'template' => 'form', 'formTag' => $this->_getFormMainTag($formDef, null, array($idDefine)), 'action' => $this->_getFullAction($baseAction, 'update_do')), 'delete' => array('title' => sprintf("Are you sure?", $model), 'template' => 'delete', 'itemTag' => $this->_getItemMainTag($modelDefine, $table_id)), '_errorbox' => array('_fileName' => '_errorMessages.tpl.html', 'template' => 'errorMessages'), '_noticebox' => array('_fileName' => '_noticeMessages.tpl.html', 'template' => 'noticeMessages'));
// Create BoxFilePath
foreach ($templates as $name => $value) {
if ($name[0] == '_') {
$tpl_path = $this->ctl->getDefaultForwardPath($this->_getFullAction($baseAction, 'test'));
$path = explode("/", $tpl_path);
$path[count($path) - 1] = $value['_fileName'];
$templates[$name]['path'] = implode("/", $path);
}
}
// Project OverAll Macro
$projMacro = array();
$projMacro['listAction'] = $this->_getFullAction($baseAction, 'index');
$projMacro['readAction'] = $this->_getFullAction($baseAction, 'read');
$projMacro['createAction'] = $this->_getFullAction($baseAction, 'create');
$projMacro['createDoAction'] = $this->_getFullAction($baseAction, 'create_do');
$projMacro['updateAction'] = $this->_getFullAction($baseAction, 'update');
$projMacro['updateDoAction'] = $this->_getFullAction($baseAction, 'update_do');
$projMacro['deleteAction'] = $this->_getFullAction($baseAction, 'delete');
$projMacro['deleteDoAction'] = $this->_getFullAction($baseAction, 'delete_do');
$projMacro['errorBoxFile'] = $templates['_errorbox']['path'];
$projMacro['noticeBoxFile'] = $templates['_noticebox']['path'];
$projMacro['model'] = $model;
$projMacro['modelName'] = ucfirst($table_id);
$projMacro['modelPK'] = $idDefine;
$projMacro['project_id'] = $this->ctl->getAppId();
foreach ($templates as $name => $value) {
$tpl_path = $this->ctl->getDefaultForwardPath($this->_getFullAction($baseAction, $name));
// FormBox TemplateFile.
if (isset($value['path'])) {
$tpl_path = $value['path'];
}
$macro = array_merge($value, $projMacro);
// ファイル生成
Ethna_Util::mkdir(dirname("{$tpl_dir}/{$tpl_path}"), 0755);
$skel = "skel.scaffold-template-{$value['template']}.tpl";
if (file_exists("{$tpl_dir}{$tpl_path}")) {
printf("file [%s] already exists -> skip\n", "{$tpl_dir}{$tpl_path}");
} else {
if ($this->_generateFile($skel, "{$tpl_dir}{$tpl_path}", $macro) == false) {
printf("[warning] file creation failed [%s]\n", "{$tpl_dir}{$tpl_path}");
} else {
printf("template file(s) successfully created [%s]\n", "{$tpl_dir}{$tpl_path}");
}
}
}
$true = true;
return $true;
}
开发者ID:bobpp,项目名称:php-Ethna-Ethcaffold,代码行数:68,代码来源:Ethna_Plugin_Generator_ScaffoldTemplates.php
示例13: smarty_function_uniqid
/**
* 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)
{
$uniqid = Ethna_Util::getRandom();
if (isset($params['type']) && $params['type'] == 'get') {
return "uniqid={$uniqid}";
} else {
return "<input type=\"hidden\" name=\"uniqid\" value=\"{$uniqid}\" />\n";
}
}
开发者ID:weiweiabc109,项目名称:test_project1,代码行数:23,代码来源:function.uniqid.php
示例14: array
/**
* ScaffoldViews を生成する
*
* @access public
* @param $baseAction string ベースのアクション名
* @param $model string モデル名
* @param $modelDefine array モデル定義
* @param $formDef array フォーム定義
*/
function &generate($baseAction, $model, $modelDefine, $idDefine, $formDef)
{
$table_id = $this->_getTableId($model);
$columnName_path = $this->_getColumnNamePath($table_id);
// Viewを生成
$views = array("list" => array('helper' => $this->_getFullAction($baseAction, 'create_do')), "read" => array('helper' => $this->_getFullAction($baseAction, 'create_do')), "form_create" => array('helper' => $this->_getFullAction($baseAction, 'create_do')), "form_update" => array('helper' => $this->_getFullAction($baseAction, 'update_do')), "delete" => array('helper' => $this->_getFullAction($baseAction, 'create_do')));
foreach ($views as $name => $value) {
$forward_name = $this->_getFullAction($baseAction, $name);
$view_dir = $this->ctl->getViewdir();
$view_class = $this->ctl->getDefaultViewClass($forward_name, false);
$view_path = $this->ctl->getDefaultViewPath($forward_name, false);
$macro = $value;
$macro['model'] = $model;
$macro['modelName'] = ucfirst($table_id);
$macro['modelUName'] = strtoupper($table_id);
$macro['modelPK'] = $idDefine;
$macro['project_id'] = $this->ctl->getAppId();
$macro['forward_name'] = $forward_name;
$macro['view_class'] = $view_class;
$macro['view_path'] = $view_path;
$macro['column_name_file'] = $columnName_path;
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
Ethna_Util::mkdir(dirname("{$view_dir}/{$view_path}"), 0755);
if ($name == 'list') {
$skelton = 'skel.scaffold-view-list.php';
} else {
if ($name == 'delete') {
$skelton = 'skel.scaffold-view-delete.php';
} else {
if ($name == 'read') {
$skelton = 'skel.scaffold-view-item.php';
} else {
if ($name == 'form_create') {
$skelton = 'skel.scaffold-view-formCreate.php';
} else {
if ($name == 'form_update') {
$skelton = 'skel.scaffold-view-formUpdate.php';
}
}
}
}
}
if (file_exists("{$view_dir}{$view_path}")) {
printf("file [%s] already exists -> skip\n", "{$view_dir}{$view_path}");
} else {
if ($this->_generateFile($skelton, "{$view_dir}{$view_path}", $macro) == false) {
printf("[warning] file creation failed [%s]\n", "{$view_dir}{$view_path}");
} else {
printf("view script(s) successfully created [%s]\n", "{$view_dir}{$view_path}");
}
}
}
$true = true;
return $true;
}
开发者ID:bobpp,项目名称:php-Ethna-Ethcaffold,代码行数:65,代码来源:Ethna_Plugin_Generator_ScaffoldViews.php
示例15: testIsAbsolute
function testIsAbsolute()
{
$absolute_paths = array('/root', '/home/user/giza');
$invalid_params = array('', false, true, '0x1');
foreach ($absolute_paths as $path) {
$this->assertTrue(Ethna_Util::isAbsolute($path));
}
foreach ($invalid_params as $path) {
$this->assertFalse(Ethna_Util::isAbsolute($path));
}
}
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:11,代码来源:Ethna_Util_Test.php
示例16: preforward
/**
* preprocess before forwarding.
*
* @access public
*/
function preforward()
{
parent::preforward();
$cookie_path = str_replace(rtrim($_SERVER['DOCUMENT_ROOT'], '/'), '', $this->af->get('xoops_root_path'));
!$cookie_path and $cookie_path = '/';
$xoops_url = sprintf('http://%s%s', $_SERVER['SERVER_NAME'], $cookie_path);
$this->af->setApp('xoops_cookie_path', $cookie_path);
$this->af->setApp('xoops_url', $xoops_url);
$this->af->setApp('prefix', Ethna_Util::getRandom(6));
$this->af->setApp('salt', Ethna_Util::getRandom(8));
}
开发者ID:hiro1173,项目名称:legacy,代码行数:16,代码来源:Copyfile.php
示例17: perform
function perform()
{
if (!is_writable($this->config->get('data_dir'))) {
$this->ae->add('error', $this->config->get('data_dir') . 'に書き込み権限がありません');
return 'error';
}
$fl =& $this->backend->getManager('FileList');
$file_list =& $fl->scandir($this->config->get('data_dir'));
$files = count($file_list);
if ($files === 0) {
$id = 1;
} else {
if ($files >= $this->config->get('project_limit')) {
$this->ae->add('error', 'これ以上フォームを追加できません');
return 'project';
}
list($id) = sscanf($file_list[0], '%03d.cgi');
++$id;
}
$data_file = sprintf('%03d.cgi', $id);
$data_file_path = $this->config->get('data_dir') . $data_file;
$name = $this->af->get('name');
$file = $this->af->get('file');
if ($file === '') {
$file = Ethna_Util::getRandom(6);
}
if ($file !== basename($file, $this->config->get('mobile_suffix'))) {
$this->ae->add('error', $this->config->get('mobile_suffix') . 'は予約語につき変更して下さい');
return 'project';
}
$file_p = $this->config->get('publish_dir') . $file . '.php';
$file_m = $this->config->get('publish_dir') . $file . $this->config->get('mobile_suffix') . '.php';
if (is_file($file_p) || is_file($file_m)) {
$this->ae->add('error', $file . 'は使用中につき変更して下さい');
return 'project';
}
$data =& $this->backend->getManager('Data');
$data->load($data_file_path);
$data->set('file', $file);
$data->set('name', $name);
$data->set('mailto', '');
$data->set('body', '先にテンプレートを作成して下さい。');
$data->set('receipt', '先にテンプレートを作成して下さい。');
$data->set('attr', array());
if (!$data->write()) {
$this->ae->add('error', $data_file_path . 'に書き込めませんでした');
return 'error';
}
array_unshift($file_list, $data_file);
$this->af->clearFormVars();
return 'project';
}
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:52,代码来源:ProjectAdd.php
示例18: checkMailAddressInvalid
/**
* @test
*/
public function checkMailAddressInvalid()
{
// @がない
$this->assertFalse(Ethna_Util::checkMailAddress('hogefuga.net'));
// @の前に文字がない
$this->assertFalse(Ethna_Util::checkMailAddress('@hogefuga.net'));
// @の後に文字がない
$this->assertFalse(Ethna_Util::checkMailAddress('hogefuga.net@'));
// 先頭文字が許されていない
$this->assertFalse(Ethna_Util::checkMailAddress('%[email protected]'));
// 末尾文字が不正
$this->assertFalse(Ethna_Util::checkMailAddress('[email protected].'));
}
开发者ID:khsk,项目名称:ethnam,代码行数:16,代码来源:UtilTest.php
示例19: generate
/**
* アクションのスケルトンを生成する
*
* @access public
* @param string $action_name アクション名
* @param string $skelton スケルトンファイル名
* @param int $gateway ゲートウェイ
* @return true|Ethna_Error true:成功 Ethna_Error:失敗
*/
function generate($action_name, $skelton = null, $gateway = GATEWAY_WWW)
{
$action_dir = $this->ctl->getActiondir($gateway);
$action_class = $this->ctl->getDefaultActionClass($action_name, $gateway);
$action_form = $this->ctl->getDefaultFormClass($action_name, $gateway);
$action_path = $this->ctl->getDefaultActionPath($action_name);
// entity
$entity = $action_dir . $action_path;
Ethna_Util::mkdir(dirname($entity), 0755);
// skelton
if ($skelton === null) {
switch ($gateway) {
case GATEWAY_WWW:
$skelton = "skel.action.php";
break;
case GATEWAY_CLI:
$skelton = "skel.action_cli.php";
break;
case GATEWAY_XMLRPC:
$skelton = "skel.action_xmlrpc.php";
break;
default:
$err = Ethna::raiseError('unknown gateway.');
return $err;
}
}
// macro
$macro = array();
$macro['project_id'] = $this->ctl->getAppId();
$macro['action_name'] = $action_name;
$macro['action_class'] = $action_class;
$macro['action_form'] = $action_form;
$macro['action_path'] = $action_path;
// user macro
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
// generate
if (file_exists($entity)) {
printf("file [%s] already exists -> skip\n", $entity);
} else {
if ($this->_generateFile($skelton, $entity, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $entity);
} else {
printf("action script(s) successfully created [%s]\n", $entity);
}
}
$true = true;
return $true;
}
开发者ID:hiroki-ta,项目名称:my.project,代码行数:58,代码来源:Action.php
示例20: setCSRF
/**
* 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;
}
开发者ID:BackupTheBerlios,项目名称:delphinus-svn,代码行数:22,代码来源:Aero_Util.php
注:本文中的Ethna_Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论