diff --git a/module/install/control.php b/module/install/control.php index 41eede303e..260b1b9856 100644 --- a/module/install/control.php +++ b/module/install/control.php @@ -26,5 +26,44 @@ class install extends control /* 安装程序首页。*/ public function index() { + $this->view->header->title = $this->lang->install->welcome; + $this->display(); + } + + /* 第一步: 系统检查。*/ + public function step1() + { + $this->view->header->title = $this->lang->install->checking; + $this->view->phpVersion = $this->install->getPhpVersion(); + $this->view->phpResult = $this->install->checkPHP(); + $this->view->pdoResult = $this->install->checkPDO(); + $this->view->pdoMySQLResult = $this->install->checkPDOMySQL(); + $this->view->tmpRootInfo = $this->install->getTmpRoot(); + $this->view->tmpRootResult = $this->install->checkTmpRoot(); + $this->view->dataRootInfo = $this->install->getDataRoot(); + $this->view->dataRootResult = $this->install->checkDataRoot(); + $this->view->iniInfo = $this->install->getIniInfo(); + $this->display(); + } + + /* 第二步:配置表单。*/ + public function step2() + { + $this->view->header->title = $this->lang->install->setConfig; + $this->view->webRoot = $this->install->getWebRoot(); + $this->display(); + } + + /* 生成配置文件。*/ + public function step3() + { + if(!empty($_POST)) + { + $this->view = (object)$_POST; + $this->view->lang = $this->lang; + $this->view->config = $this->config; + $this->view->header->title = $this->lang->install->saveConfig; + $this->display(); + } } } diff --git a/module/install/lang/zh-cn.php b/module/install/lang/zh-cn.php new file mode 100644 index 0000000000..7b39c1e371 --- /dev/null +++ b/module/install/lang/zh-cn.php @@ -0,0 +1,74 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package install + * @version $Id$ + * @link http://www.zentao.cn + */ +$lang->install->common = '安装'; +$lang->install->welcome = '欢迎使用禅道项目管理软件!'; +$lang->install->desc = <<install->start = '开始安装'; +$lang->install->next = '下一步'; +$lang->install->reload = '刷新'; +$lang->install->checking = '系统检查'; +$lang->install->setConfig = '生成配置文件'; +$lang->install->saveConfig = '保存配置文件'; +$lang->install->settingDB = '设置数据库'; +$lang->install->save2File = '拷贝上面文本框中的内容,将其保存到"%s"中。'; +$lang->install->ok = '检查通过(√)'; +$lang->install->fail = '检查失败(×)'; +$lang->install->loaded = '已加载'; +$lang->install->unloaded = '未加载'; +$lang->install->exists = '目录存在 '; +$lang->install->notExists = '目录不存在 '; +$lang->install->writable = '目录可写 '; +$lang->install->notWritable= '目录不可写 '; +$lang->install->checkItem = '检查项'; +$lang->install->current = '当前配置'; +$lang->install->result = '检查结果'; +$lang->install->action = '如何修改'; +$lang->install->key = '配置项'; +$lang->install->value = '值'; + +$lang->install->phpVersion = 'PHP版本'; +$lang->install->phpFail = 'PHP版本必须大于5.2.0'; + +$lang->install->pdo = 'PDO扩展'; +$lang->install->pdoFail = '修改PHP配置文件,加载PDO扩展。'; +$lang->install->pdoMySQL = 'PDO_MySQL扩展'; +$lang->install->pdoMySQLFail = '修改PHP配置文件,加载pdo_mysql扩展。'; +$lang->install->tmpRoot = '临时文件目录'; +$lang->install->dataRoot = '上传文件目录'; +$lang->install->mkdir = '

需要创建目录%s。
linux下面命令为:
mkdir -p %s

'; +$lang->install->chmod = '需要修改目录 "%s" 的权限。
linux下面命令为:
chmod o=rwx -R %s'; + +$lang->install->webRoot = 'PMS所在网站目录'; +$lang->install->requestType = 'URL方式'; +$lang->install->requestTypes['GET'] = '普通方式'; +$lang->install->requestTypes['PATH_INFO'] = '静态友好方式'; +$lang->install->dbHost = '数据库服务器'; +$lang->install->dbUser = '数据库用户名'; +$lang->install->dbPassword = '数据库密码'; +$lang->install->dbName = 'PMS使用的库'; +$lang->install->dbPrefix = '建表使用的前缀'; diff --git a/module/install/model.php b/module/install/model.php new file mode 100644 index 0000000000..c6d7074f54 --- /dev/null +++ b/module/install/model.php @@ -0,0 +1,101 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package install + * @version $Id$ + * @link http://www.zentao.cn + */ +?> += 0 ? 'ok' : 'fail'; + } + + /* 检查PDO扩展是否载入。*/ + public function checkPDO() + { + return $result = extension_loaded('pdo') ? 'ok' : 'fail'; + } + + /* 检查PDO_MySQL扩展是否载入。*/ + public function checkPDOMySQL() + { + return $result = extension_loaded('pdo_mysql') ? 'ok' : 'fail'; + } + + /* 获得tmpRoot目录的信息。*/ + public function getTmpRoot() + { + $result['path'] = $this->app->getTmpRoot(); + $result['exists'] = is_dir($result['path']); + $result['writable']= is_writable($result['path']); + return $result; + } + + /* 检查tmpRoot目录权限。*/ + public function checkTmpRoot() + { + $tmpRoot = $this->app->getTmpRoot(); + return $result = (is_dir($tmpRoot) and is_writable($tmpRoot)) ? 'ok' : 'fail'; + } + + /* 获得DataRoot目录的信息。*/ + public function getDataRoot() + { + $result['path'] = $this->app->getAppRoot() . 'www' . $this->app->getPathFix() . 'data'; + $result['exists'] = is_dir($result['path']); + $result['writable']= is_writable($result['path']); + return $result; + } + + /* 检查dataRoot目录权限。*/ + public function checkDataRoot() + { + $dataRoot = $this->app->getAppRoot() . 'www' . $this->app->getPathFix() . 'data'; + return $result = (is_dir($dataRoot) and is_writable($dataRoot)) ? 'ok' : 'fail'; + } + + /* 获得INI文件的信息。*/ + public function getIniInfo() + { + $iniInfo = ''; + ob_start(); + phpinfo(1); + $lines = explode("\n", strip_tags(ob_get_contents())); + ob_end_clean(); + foreach($lines as $line) if(strpos($line, 'ini') !== false) $iniInfo .= $line . "\n"; + return $iniInfo; + } + + /* 获得webRoot的地址。*/ + public function getWebRoot() + { + return rtrim(pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME), '/') . '/'; + } +} diff --git a/module/install/view/footer.html.php b/module/install/view/footer.html.php new file mode 100644 index 0000000000..fe663d81c7 --- /dev/null +++ b/module/install/view/footer.html.php @@ -0,0 +1,17 @@ + +
+ +
+ + + diff --git a/module/install/view/header.html.php b/module/install/view/header.html.php new file mode 100644 index 0000000000..eecb5efc19 --- /dev/null +++ b/module/install/view/header.html.php @@ -0,0 +1,24 @@ +app->getClientTheme(); +$webRoot = $this->app->getWebRoot(); +$jsRoot = $webRoot . "js/"; +$themeRoot = $webRoot . "theme/"; +?> + + + + + <?php echo $header->title;?> + + + +' type='text/css' media='screen' /> +' type='text/css' media='screen' /> + + + + diff --git a/module/install/view/index.html.php b/module/install/view/index.html.php new file mode 100644 index 0000000000..1cdf62735b --- /dev/null +++ b/module/install/view/index.html.php @@ -0,0 +1,32 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package ZenTaoMS + * @version $Id$ + */ +?> + +
+ + + + +
install->welcome;?>
install->desc);?>

createLink('install', 'step1'), $lang->install->start);?>

+
+ diff --git a/module/install/view/step1.html.php b/module/install/view/step1.html.php new file mode 100644 index 0000000000..62c7f43a08 --- /dev/null +++ b/module/install/view/step1.html.php @@ -0,0 +1,100 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package ZenTaoMS + * @version $Id$ + */ +?> + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
install->checking;?>
install->checkItem;?>install->current?>install->result?>install->action?>
install->phpVersion;?>install->$phpResult;?>install->phpFail;?>
install->pdo;?>install->loaded) : printf($lang->install->unloaded);?>install->$pdoResult;?>install->pdoFail;?>
install->pdoMySQL;?>install->loaded) : printf($lang->install->unloaded);?>install->$pdoMySQLResult;?>install->pdoMySQLFail;?>
install->tmpRoot;?> + install->exists) : print($lang->install->notExists); + $tmpRootInfo['writable'] ? print($lang->install->writable) : print($lang->install->notWritable); + ?> + install->$tmpRootResult;?> + install->mkdir, $tmpRootInfo['path'], $tmpRootInfo['path']); + if(!$tmpRootInfo['writable']) printf($lang->install->chmod, $tmpRootInfo['path'], $tmpRootInfo['path']); + ?> +
install->dataRoot;?> + install->exists) : print($lang->install->notExists); + $dataRootInfo['writable'] ? print($lang->install->writable) : print($lang->install->notWritable); + ?> + install->$dataRootResult;?> + install->mkdir, $dataRootInfo['path'], $dataRootInfo['path']); + if(!$dataRootInfo['writable']) printf($lang->install->chmod, $dataRootInfo['path'], $dataRootInfo['path']); + ?> +
+ createLink('install', 'step2'), $lang->install->next); + } + else + { + echo html::a($this->createLink('install', 'step1'), $lang->install->reload); + } + ?> +
+
+ diff --git a/module/install/view/step2.html.php b/module/install/view/step2.html.php new file mode 100644 index 0000000000..8befef7499 --- /dev/null +++ b/module/install/view/step2.html.php @@ -0,0 +1,67 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package ZenTaoMS + * @version $Id$ + */ +?> + +
+
'> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
install->setConfig;?>
install->key;?>install->value?>
install->webRoot;?>
install->requestType;?>install->requestTypes, 'GET');?>
install->dbHost;?>
install->dbUser;?>
install->dbPassword;?>
install->dbName;?>
install->dbPrefix;?>
+
+
+ diff --git a/module/install/view/step3.html.php b/module/install/view/step3.html.php new file mode 100644 index 0000000000..a89dc6cc78 --- /dev/null +++ b/module/install/view/step3.html.php @@ -0,0 +1,56 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package ZenTaoMS + * @version $Id$ + */ +?> + +installed = true; //标志是否已经安装。 +\$config->debug = true; //是否打开debug功能。 +\$config->webRoot = '$webRoot'; //web网站的根目录。 +\$config->requestType = '$requestType'; //如何获取当前请求的信息,可选值:PATH_INFO|GET +\$config->db->host = '$dbHost'; //mysql主机。 +\$config->db->port = '3306'; //mysql主机端口号。 +\$config->db->name = '$dbName'; //数据库名称。 +\$config->db->user = '$dbUser'; //数据库用户名。 +\$config->db->password = '$dbPassword'; //密码。 +\$config->db->prefix = '$dbPrefix'; //表前缀。 +EOT; +?> +
+ + + + + + + + +
install->saveConfig;?>
+ install->save2File, $this->app->getConfigRoot() . 'my.php'); + echo html::a($this->createLink('install', 'step4'), $lang->install->next); + ?> +
+
+