Source for file Ethna_Plugin_Generator_Project.php
Documentation is available at Ethna_Plugin_Generator_Project.php
// vim: foldmethod=marker
* Ethna_Plugin_Generator_Project.php
* @author Masaki Fujimoto <fujimoto@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
// {{{ Ethna_Plugin_Generator_Project
* @author Masaki Fujimoto <fujimoto@php.net>
* @param string $id プロジェクトID
* @param string $basedir プロジェクトベースディレクトリ
* @param string $skeldir スケルトンディレクトリ。これが指定されると、そこにある
* ファイルが優先される。また、ETHNA_HOME/skel にないもの
* @param string $locale ロケール名
* (ロケール名は、ll_cc の形式。ll = 言語コード cc = 国コード)
* @param string $encoding プロジェクトで使用するエンコーディング
* @return bool true:成功 Ethna_Error:失敗
function generate($id, $basedir, $skeldir, $locale, $encoding)
array("app/action", 0755),
array("app/action_cli", 0755),
array("app/action_xmlrpc", 0755),
array("app/plugin", 0755),
array("app/plugin/Filter", 0755),
array("app/plugin/Validator", 0755),
array("app/plugin/Smarty", 0755),
array("locale/$locale", 0755),
array("locale/$locale/LC_MESSAGES", 0755),
array("template/$locale", 0755),
if (is_dir($basedir) ==
false) {
printf("creating directory ($basedir) [y/n]: ");
$fp =
fopen("php://stdin", "r");
if (mkdir($basedir, 0775) ==
false) {
foreach ($dir_list as $dir) {
$target =
"$basedir/$dir";
printf("%s already exists -> skipping...\n", $target);
if (mkdir($target, $mode) ==
false) {
printf("project sub directory created [%s]\n", $target);
if (chmod($target, $mode) ==
false) {
$macro['project_id'] =
ucfirst($id);
$macro['project_prefix'] =
$id;
$macro['locale'] =
$locale;
$macro['client_enc'] =
$encoding;
$macro['action_class'] =
'{$action_class}';
$macro['action_form'] =
'{$action_form}';
$macro['action_name'] =
'{$action_name}';
$macro['action_path'] =
'{$action_path}';
$macro['forward_name'] =
'{$forward_name}';
$macro['view_name'] =
'{$view_name}';
$macro['view_path'] =
'{$view_path}';
$user_macro =
$this->_getUserMacro();
?
"locale/$locale/ethna_sysmsg.ini"
:
'locale/ethna_sysmsg.default.ini';
$locale_file =>
"$basedir/locale/$locale/LC_MESSAGES/ethna_sysmsg.ini",
"www.index.php" =>
"$basedir/www/index.php",
"www.info.php" =>
"$basedir/www/info.php",
"www.unittest.php" =>
"$basedir/www/unittest.php",
"www.xmlrpc.php" =>
"$basedir/www/xmlrpc.php",
"www.css.ethna.css" =>
"$basedir/www/css/ethna.css",
"dot.ethna" =>
"$basedir/.ethna",
"app.controller.php" =>
sprintf("$basedir/app/%s_Controller.php", $macro['project_id']),
"app.error.php" =>
sprintf("$basedir/app/%s_Error.php", $macro['project_id']),
"app.actionclass.php" =>
sprintf("$basedir/app/%s_ActionClass.php", $macro['project_id']),
"app.actionform.php" =>
sprintf("$basedir/app/%s_ActionForm.php", $macro['project_id']),
"app.viewclass.php" =>
sprintf("$basedir/app/%s_ViewClass.php", $macro['project_id']),
"app.action.default.php" =>
"$basedir/app/action/Index.php",
"app.plugin.filter.default.php" =>
sprintf("$basedir/app/plugin/Filter/%s_Plugin_Filter_ExecutionTime.php", $macro['project_id']),
"app.view.default.php" =>
"$basedir/app/view/Index.php",
"app.unittest.php" =>
sprintf("$basedir/app/%s_UnitTestManager.php", $macro['project_id']),
"app.url_handler.php" =>
sprintf("$basedir/app/%s_UrlHandler.php", $macro['project_id']),
"etc.ini.php" =>
sprintf("$basedir/etc/%s-ini.php", $macro['project_prefix']),
"template.index.tpl" =>
sprintf("$basedir/template/$locale/index.tpl"),
"skel.action.php" =>
sprintf("$basedir/skel/skel.action.php"),
"skel.action_cli.php" =>
sprintf("$basedir/skel/skel.action_cli.php"),
"skel.action_test.php" =>
sprintf("$basedir/skel/skel.action_test.php"),
"skel.app_object.php" =>
sprintf("$basedir/skel/skel.app_object.php"),
"skel.entry_www.php" =>
sprintf("$basedir/skel/skel.entry_www.php"),
"skel.entry_cli.php" =>
sprintf("$basedir/skel/skel.entry_cli.php"),
"skel.view.php" =>
sprintf("$basedir/skel/skel.view.php"),
"skel.template.tpl" =>
sprintf("$basedir/skel/skel.template.tpl"),
"skel.view_test.php" =>
sprintf("$basedir/skel/skel.view_test.php"),
// also copy user defined skel file.
while (($file =
readdir($handle)) !==
false) {
$skelfile_maps[$file] =
sprintf("$basedir/skel/$file");
$real_r =
$this->_generate($realfile_maps, $macro, $skeldir);
// skelファイルにはエンコーディングマクロは適用しない
// skel.template.tpl は、add-[view|template]時に適用させるため。
unset
($default_macro['client_enc']);
$skel_r =
$this->_generate($skelfile_maps, $default_macro, $skeldir);
* @param string $maps スケルトン名と生成されるファイルの配列
* @param string $macro 適用マクロ
* @param string $skeldir スケルトンディレクトリ。これが指定されると、そこにある
* ファイルが優先される。また、ETHNA_HOME/skel にないもの
* @return bool true:成功 Ethna_Error:失敗
function _generate($maps, $macro, $skeldir)
foreach ($maps as $skel =>
$realfile) {
if (!empty($skeldir) &&
file_exists("$skeldir/$skel")) {
$skel =
"$skeldir/$skel";
if ($this->_generateFile($skel, $realfile, $macro) ==
false) {
Documentation generated on Fri, 11 Nov 2011 04:00:18 +0900 by phpDocumentor 1.4.3