+ add install module.

This commit is contained in:
wangchunsheng
2009-12-31 09:56:30 +00:00
parent 7259499a4d
commit 13e97ac367
9 changed files with 510 additions and 0 deletions
+39
View File
@@ -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();
}
}
}
+74
View File
@@ -0,0 +1,74 @@
<?php
/**
* The install module zh-cn file of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package install
* @version $Id$
* @link http://www.zentao.cn
*/
$lang->install->common = '安装';
$lang->install->welcome = '欢迎使用禅道项目管理软件!';
$lang->install->desc = <<<EOT
禅道项目管理软件(ZenTaoPMS)是一款国产的,基于LGPL协议,开源免费的项目管理软件,它集产品管理、项目管理、测试管理于一体,同时还包含了事务管理、组织管理等诸多功能,是中小型企业项目管理的首选。
禅道项目管理软件使用PHP + MySQL开发,基于自主的PHP开发框架──ZenTaoPHP而成。第三方开发者或者企业可以非常方便的开发插件或者进行定制。
EOT;
$lang->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 = '<p>需要创建目录%s。<br /> linux下面命令为:<br /> mkdir -p %s</p>';
$lang->install->chmod = '需要修改目录 "%s" 的权限。<br />linux下面命令为:<br />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 = '建表使用的前缀';
+101
View File
@@ -0,0 +1,101 @@
<?php
/**
* The model file of install module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package install
* @version $Id$
* @link http://www.zentao.cn
*/
?>
<?php
class installModel extends model
{
/* 获得PHP版本。*/
public function getPhpVersion()
{
return PHP_VERSION;
}
/* 检查PHP版本是否符合要求。*/
public function checkPHP()
{
return $result = version_compare(PHP_VERSION, '5.2.0') >= 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), '/') . '/';
}
}
+17
View File
@@ -0,0 +1,17 @@
<script language='Javascript'>var needPing = false;</script>
<div class='yui-d0'>
<iframe frameborder='0' name='hiddenwin' id='hiddenwin' class='<?php $config->debug ? print("debugwin") : print('hiddenwin')?>'></iframe>
</div>
<div id='footer' class='yui-d0 yui-t7'>
<div class='yui-g'>
<div class='yui-g first' id='crumbs'></div>
<div class='yui-g'>
<div class='yui-u first'> </div>
<div class='yui-u a-right'>
<span id='poweredby'>powered by <a href='http://www.zentao.cn' target='_blank'>ZenTaoPMS</a> (<?php echo $config->version;?>)</span>
</div>
</div>
</div>
</div>
</body>
</html>
+24
View File
@@ -0,0 +1,24 @@
<?php
$clientTheme = $this->app->getClientTheme();
$webRoot = $this->app->getWebRoot();
$jsRoot = $webRoot . "js/";
$themeRoot = $webRoot . "theme/";
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dli'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title><?php echo $header->title;?></title>
<?php echo js::exportConfigVars();?>
<script src="<?php echo $jsRoot;?>jquery/lib.js" type="text/javascript"></script>
<script src="<?php echo $jsRoot;?>my.js" type="text/javascript"></script>
<link rel='stylesheet' href='<?php echo $clientTheme . 'yui.css';?>' type='text/css' media='screen' />
<link rel='stylesheet' href='<?php echo $clientTheme . 'style.css';?>' type='text/css' media='screen' />
<style>
.ok{background:green; color:white}
.fail{background:red; color:white}
caption, th, td {padding:10px; font-size:16px}
</style>
<script type="text/javascript">loadFixedCSS();</script>
</head>
<body style='margin-top:50px'>
+32
View File
@@ -0,0 +1,32 @@
<?php
/**
* The html template file of index method of install module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package ZenTaoMS
* @version $Id$
*/
?>
<?php include './header.html.php';?>
<div class='yui-d0'>
<table align='center' class='table-6'>
<caption><?php echo $lang->install->welcome;?></caption>
<tr><td><?php echo nl2br($lang->install->desc);?></td></tr>
<tr><td><h3 class='a-center'><?php echo html::a($this->createLink('install', 'step1'), $lang->install->start);?></h3></td></tr>
</table>
</div>
<?php include './footer.html.php';?>
+100
View File
@@ -0,0 +1,100 @@
<?php
/**
* The html template file of step1 method of install module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package ZenTaoMS
* @version $Id$
*/
?>
<?php include './header.html.php';?>
<div class='yui-d0'>
<table align='center' class='table-6 a-center'>
<caption><?php echo $lang->install->checking;?></caption>
<tr>
<th class='w-p20'><?php echo $lang->install->checkItem;?></th>
<th class='w-p25'><?php echo $lang->install->current?></th>
<th class='w-p15'><?php echo $lang->install->result?></th>
<th><?php echo $lang->install->action?></th>
</tr>
<tr>
<th><?php echo $lang->install->phpVersion;?></th>
<td><?php echo $phpVersion;?></td>
<td class='<?php echo $phpResult;?>'><?php echo $lang->install->$phpResult;?></td>
<td class='a-left f-12px'><?php if($phpResult == 'fail') echo $lang->install->phpFail;?></td>
</tr>
<tr>
<th><?php echo $lang->install->pdo;?></th>
<td><?php $pdoResult ? printf($lang->install->loaded) : printf($lang->install->unloaded);?></td>
<td class='<?php echo $pdoResult;?>'><?php echo $lang->install->$pdoResult;?></td>
<td class='a-left f-12px'><?php if($pdoResult == 'fail') echo $lang->install->pdoFail;?></td>
</tr>
<tr>
<th><?php echo $lang->install->pdoMySQL;?></th>
<td><?php $pdoMySQLResult ? printf($lang->install->loaded) : printf($lang->install->unloaded);?></td>
<td class='<?php echo $pdoMySQLResult;?>'><?php echo $lang->install->$pdoMySQLResult;?></td>
<td class='a-left f-12px'><?php if($pdoMySQLResult == 'fail') echo $lang->install->pdoMySQLFail;?></td>
</tr>
<tr>
<th><?php echo $lang->install->tmpRoot;?></th>
<td>
<?php
$tmpRootInfo['exists'] ? print($lang->install->exists) : print($lang->install->notExists);
$tmpRootInfo['writable'] ? print($lang->install->writable) : print($lang->install->notWritable);
?>
</td>
<td class='<?php echo $tmpRootResult;?>'><?php echo $lang->install->$tmpRootResult;?></td>
<td class='a-left f-12px'>
<?php
if(!$tmpRootInfo['exists']) printf($lang->install->mkdir, $tmpRootInfo['path'], $tmpRootInfo['path']);
if(!$tmpRootInfo['writable']) printf($lang->install->chmod, $tmpRootInfo['path'], $tmpRootInfo['path']);
?>
</td>
</tr>
<tr>
<th><?php echo $lang->install->dataRoot;?></th>
<td>
<?php
$dataRootInfo['exists'] ? print($lang->install->exists) : print($lang->install->notExists);
$dataRootInfo['writable'] ? print($lang->install->writable) : print($lang->install->notWritable);
?>
</td>
<td class='<?php echo $dataRootResult;?>'><?php echo $lang->install->$dataRootResult;?></td>
<td class='a-left f-12px'>
<?php
if(!$dataRootInfo['exists']) printf($lang->install->mkdir, $dataRootInfo['path'], $dataRootInfo['path']);
if(!$dataRootInfo['writable']) printf($lang->install->chmod, $dataRootInfo['path'], $dataRootInfo['path']);
?>
</td>
</tr>
<tr>
<td colspan='4'>
<?php
if($phpResult == 'ok' and $pdoResult == 'ok' and $pdoMySQLResult == 'ok' and $tmpRootResult == 'ok' and $dataRootResult == 'ok')
{
echo html::a($this->createLink('install', 'step2'), $lang->install->next);
}
else
{
echo html::a($this->createLink('install', 'step1'), $lang->install->reload);
}
?>
</td>
</tr>
</table>
</div>
<?php include './footer.html.php';?>
+67
View File
@@ -0,0 +1,67 @@
<?php
/**
* The html template file of step2 method of install module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package ZenTaoMS
* @version $Id$
*/
?>
<?php include './header.html.php';?>
<div class='yui-d0'>
<form method='post' action='<?php echo $this->createLink('install', 'step3');?>'>
<table align='center' class='table-6'>
<caption><?php echo $lang->install->setConfig;?></caption>
<tr>
<th class='w-p20'><?php echo $lang->install->key;?></th>
<th><?php echo $lang->install->value?></th>
</tr>
<tr>
<th><?php echo $lang->install->webRoot;?></th>
<td><?php echo html::input('webRoot', $webRoot);?></td>
</tr>
<tr>
<th><?php echo $lang->install->requestType;?></th>
<td><?php echo html::radio('requestType', $lang->install->requestTypes, 'GET');?></td>
</tr>
<tr>
<th><?php echo $lang->install->dbHost;?></th>
<td><?php echo html::input('dbHost', 'localhost');?></td>
</tr>
<tr>
<th><?php echo $lang->install->dbUser;?></th>
<td><?php echo html::input('dbUser', 'root');?></td>
</tr>
<tr>
<th><?php echo $lang->install->dbPassword;?></th>
<td><?php echo html::input('dbPassword');?></td>
</tr>
<tr>
<th><?php echo $lang->install->dbName;?></th>
<td><?php echo html::input('dbName', 'zentao');?></td>
</tr>
<tr>
<th><?php echo $lang->install->dbPrefix;?></th>
<td><?php echo html::input('dbPrefix', 'zt_');?></td>
</tr>
<tr>
<td colspan='2' class='a-center'><?php echo html::submitButton();?></td>
</tr>
</table>
</form>
</div>
<?php include './footer.html.php';?>
+56
View File
@@ -0,0 +1,56 @@
<?php
/**
* The html template file of step3 method of install module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package ZenTaoMS
* @version $Id$
*/
?>
<?php include './header.html.php';?>
<?php
$configContent = <<<EOT
<?php
\$config->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;
?>
<div class='yui-d0'>
<table class='table-6' align='center'>
<caption><?php echo $lang->install->saveConfig;?></caption>
<tr>
<td class='a-center'><?php echo html::textArea('config', $configContent, "rows='15' class='area-1 f-12px'");?></td>
</tr>
<tr>
<td>
<?php
printf($lang->install->save2File, $this->app->getConfigRoot() . 'my.php');
echo html::a($this->createLink('install', 'step4'), $lang->install->next);
?>
</td>
</tr>
</table>
</div>
<?php include './footer.html.php';?>