+ fix task #468.

This commit is contained in:
wangyidong
2011-07-01 02:44:40 +00:00
parent f181e8bb57
commit b32b6a2830
6 changed files with 146 additions and 39 deletions
+31 -4
View File
@@ -49,8 +49,12 @@ class editor extends control
{
$okUrl = $this->editor->getExtendLink($filePath, 'extendControl', 'yes');
$cancelUrl = $this->editor->getExtendLink($filePath, 'extendControl', 'no');
if(!$isExtends) die(js::confirm($this->lang->editor->extendConfirm, $okUrl, $cencelUrl));
$fileContent = $this->editor->extendControl($filePath);
if(!$isExtends) die(js::confirm($this->lang->editor->extendConfirm, $okUrl, $cancelUrl));
$fileContent = $this->editor->extendControl($filePath, $isExtends);
}
elseif($action == 'newPage')
{
$fileContent = $this->editor->newControl($filePath);
}
}
$this->view->fileContent = $fileContent;
@@ -59,6 +63,29 @@ class editor extends control
$this->display();
}
/**
* Set Page name.
*
* @param string $filePath
* @access public
* @return void
*/
public function newPage($filePath)
{
$filePath = helper::safe64Decode($filePath);
if($_POST)
{
$saveFilePath = $this->editor->getSavePath($filePath, 'newMethod');
$extendLink = $this->editor->getExtendLink($saveFilePath, 'newPage');
if(file_exists($saveFilePath) and !$this->post->override) die(js::confirm($this->lang->editor->repeatPage, $extendLink, '', 'parent'));
die(js::locate($extendLink, 'parent'));
}
$allModules = $this->editor->getModuleFiles();
$this->view->tree = $this->editor->printTree($allModules);
$this->view->filePath = $filePath;
$this->display();
}
/**
* Save file to extension.
*
@@ -71,8 +98,8 @@ class editor extends control
if($filePath and $_POST)
{
$filePath = helper::safe64Decode($filePath);
if($action != 'edit') $filePath = $this->editor->getSavePath($filePath, $action);
if($action != 'edit' and file_exists($filePath) and !$this->post->override) die(js::error($this->lang->editor->repeatFile));
if($action != 'edit' and $action != 'newPage') $filePath = $this->editor->getSavePath($filePath, $action);
if($action != 'edit' and $action != 'newPage' and file_exists($filePath) and !$this->post->override) die(js::error($this->lang->editor->repeatFile));
$this->editor->save($filePath);
die(js::locate(inlink('index', "filePath=" . helper::safe64Encode($filePath) . "&action=edit"), 'parent'));
}
+9 -5
View File
@@ -4,23 +4,27 @@ $lang->editor->extend = 'Extend';
$lang->editor->newLang = 'New language';
$lang->editor->newConfig = 'New config';
$lang->editor->newHook = 'New hook';
$lang->editor->newExtend = 'Nwe extend';
$lang->editor->newExtend = 'New extend';
$lang->editor->newPage = 'New page';
$lang->editor->override = 'override';
$lang->editor->edit = 'Edit extend';
$lang->editor->filePath = "File Path:";
$lang->editor->fileName = "Extend file name:";
$lang->editor->fileContent = "File content";
$lang->editor->overrideFile = "Override File";
$lang->editor->isOverride = "Is override";
$lang->editor->sourceFile = 'Source file:';
$lang->editor->fileName = "File name:";
$lang->editor->fileContent = "File content:";
$lang->editor->overrideFile = "Repeat file:";
$lang->editor->isOverride = "Override";
$lang->editor->exampleHook = "For example:***.html.hook.php";
$lang->editor->exampleJs = "For example:***.js";
$lang->editor->exampleCss = "For example:***.css";
$lang->editor->examplePHP = "For example:***.php";
$lang->editor->pageName = "Page Name:";
$lang->editor->deleteConfirm = 'Are you sure?';
$lang->editor->extendConfirm = 'Would you reuse the code.';
$lang->editor->repeatFile = 'File name repeat';
$lang->editor->repeatPage = 'This page has extisted. Is override?';
$lang->editor->notWritable = "Can't writable, maybe no power. please try chmod 777 -R ";
$lang->editor->notDelete = "Can't delete, please check power!";
+7 -3
View File
@@ -5,22 +5,26 @@ $lang->editor->newLang = '新增语言';
$lang->editor->newConfig = '新增配置';
$lang->editor->newHook = '新增钩子';
$lang->editor->newExtend = '新增扩展';
$lang->editor->newPage = '新增页面';
$lang->editor->override = '覆盖';
$lang->editor->edit = '编辑扩展';
$lang->editor->filePath = "文件路径:";
$lang->editor->fileName = "扩展文件名:";
$lang->editor->sourceFile = '源文件:';
$lang->editor->fileName = "文件名:";
$lang->editor->fileContent = "文件内容:";
$lang->editor->overrideFile = "覆盖文件";
$lang->editor->isOverride = "是否覆盖";
$lang->editor->overrideFile = "重复文件:";
$lang->editor->isOverride = "覆盖";
$lang->editor->exampleHook = "例如:***.html.hook.php";
$lang->editor->exampleJs = "例如:***.js";
$lang->editor->exampleCss = "例如:***.css";
$lang->editor->examplePHP = "例如:***.php";
$lang->editor->pageName = "页面名称:";
$lang->editor->deleteConfirm = '是否要删除?';
$lang->editor->extendConfirm = '是否要重用原来代码?';
$lang->editor->repeatFile = '文件名重复';
$lang->editor->repeatPage = '已经有此页面。是否覆盖?';
$lang->editor->notWritable = "无法写入,可能没有权限。请尝试执行 chmod 777 -R ";
$lang->editor->notDelete = '无法删除,请检查权限!';
+38 -8
View File
@@ -193,12 +193,16 @@ class editorModel extends model
}
else
{
$tree .= $fileName . html::a($this->getExtendLink($filePath, "newExtend"), $this->lang->editor->newExtend);
$tree .= "$fileName " . html::a($this->getExtendLink($filePath, "newExtend"), $this->lang->editor->newExtend);
}
}
elseif($fileName == 'model.php' or $fileName == 'control.php')
elseif($fileName == 'model.php')
{
$tree .= $fileName . html::a($this->getExtendLink($filePath, 'newMethod'), $this->lang->editor->newMethod);
$tree .= "$fileName " . html::a($this->getExtendLink($filePath, 'newMethod'), $this->lang->editor->newMethod);
}
elseif($fileName == 'control.php')
{
$tree .= "$fileName " . html::a(inlink('newPage', "filePath=" . helper::safe64Encode($filePath)), $this->lang->editor->newPage);
}
else
{
@@ -220,11 +224,11 @@ class editorModel extends model
$tree = '';
if(strpos($filePath, '/ext/') !== false)
{
$tree .= $file . html::a($this->getExtendLink($filePath, "edit"), $this->lang->edit) . html::a(inlink('delete', 'path=' . helper::safe64Encode($filePath)), $this->lang->delete, 'hiddenwin') . "\n";
$tree .= "$file " . html::a($this->getExtendLink($filePath, "edit"), $this->lang->edit) . html::a(inlink('delete', 'path=' . helper::safe64Encode($filePath)), $this->lang->delete, 'hiddenwin') . "\n";
}
elseif(basename(dirname($filePath))== 'view')
{
$tree .= $file . html::a($this->getExtendLink($filePath, "override"), $this->lang->editor->override) . html::a($this->getExtendLink($filePath, "newHook"), $this->lang->editor->newHook) . "\n";
$tree .= "$file " . html::a($this->getExtendLink($filePath, "override"), $this->lang->editor->override) . html::a($this->getExtendLink($filePath, "newHook"), $this->lang->editor->newHook) . "\n";
}
else
{
@@ -232,7 +236,7 @@ class editorModel extends model
$action = 'extendOther';
if($parentDir == 'control.php') $action = 'extendControl';
if($parentDir == 'model.php') $action = 'extendModel';
$tree .= $file . html::a($this->getExtendLink($filePath, $action), $this->lang->editor->extend);
$tree .= "$file " . html::a($this->getExtendLink($filePath, $action), $this->lang->editor->extend);
if($parentDir == 'lang') $tree .= html::a($this->getExtendLink($filePath, "new" . str_replace('-', '_', basename($filePath, '.php'))), $this->lang->editor->newLang);
if(basename($filePath) == 'config.php') $tree .= html::a($this->getExtendLink($filePath, "newConfig"), $this->lang->editor->newConfig);
}
@@ -305,7 +309,7 @@ EOD;
* @access public
* @return string
*/
public function extendControl($filePath)
public function extendControl($filePath, $isExtends)
{
$className = basename(dirname(dirname($filePath)));
$methodName = basename($filePath);
@@ -313,6 +317,7 @@ EOD;
{
$methodParam = $this->getParam($className, $methodName);
return $fileContent = <<<EOD
<?php
include '../../control.php';
class my$className extends $className
{
@@ -327,14 +332,39 @@ EOD;
{
$methodCode = $this->getMethodCode($className, $methodName);
return $fileContent = <<<EOD
<?php
class $className extends control
{
$methodCode
$methodcode
}
EOD;
}
}
/**
* Add a control method.
*
* @param string $filePath
* @access public
* @return string
*/
public function newControl($filePath)
{
$className = strstr($filePath, '/module/');
$className = substr($className, 0, strpos($className, '/', 9));
$className = basename($className);
$methodName = basename($filePath, '.php');
return $fileContent = <<<EOD
<?php
class $className extends control
{
public function $methodName()
{
}
}
EOD;
}
/**
* Get method's parameters.
*
+17 -19
View File
@@ -1,11 +1,11 @@
<?php
/**
* The dir view file of dir module of ZenTaoPMS.
* The editor view file of dir module of ZenTaoPMS.
*
* @copyright Copyright 2009-2011 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @copyright Copyright 2009-2011 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package dir
* @package editor
* @version $Id$
* @link http://www.zentao.net
*/
@@ -29,29 +29,27 @@
</caption>
<?php if($filePath):?>
<tr>
<td><?php echo $lang->editor->filePath?></td>
<th><?php echo $lang->editor->filePath?></th>
<td><?php echo $filePath?></td>
</tr>
<?php endif?>
<?php $rows = 40?>
<?php if(!empty($showContent)):?>
<tr>
<td class='w-80px'><?php echo $lang->editor->fileContent?></td>
<th><?php echo $lang->editor->sourceFile?></th>
<td><?php echo "<pre>$showContent</pre>"?></td>
</tr>
<?php $rows = 20?>
<?php endif?>
<tr>
<th class='w-80px'><?php echo $lang->editor->fileContent?></th>
<td>
<?php if(isset($showContent))
{
echo "<pre>$showContent</pre>";
$rows = 20;
}
else
{
$rows = 40;
}
?>
<?php echo html::textarea('fileContent', $fileContent, "class='area-1' rows=$rows")?>
</td>
</tr>
<?php if($action and $action != 'edit' and $action != 'extendControl' and $action != 'override'):?>
<?php if($action and $action != 'edit' and $action != 'newPage' and $action != 'override'):?>
<tr>
<td><?php echo $lang->editor->fileName?></td>
<th><?php echo $lang->editor->fileName?></th>
<td>
<?php
echo html::input('fileName', '', "class=text-5");
@@ -75,9 +73,9 @@
</td>
</tr>
<?php endif;?>
<?php if($action and $action != 'edit'):?>
<?php if($action and $action != 'edit' and $action != 'newPage'):?>
<tr>
<td><?php echo $lang->editor->overrideFile?></td>
<th><?php echo $lang->editor->overrideFile?></th>
<td><input type='checkbox' name='override' id='override' /> <?php echo $lang->editor->isOverride?></td>
</tr>
<?php endif;?>
+44
View File
@@ -0,0 +1,44 @@
<?php
/**
* The editor view file of dir module of ZenTaoPMS.
*
* @copyright Copyright 2009-2011 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package editor
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/treeview.html.php';?>
<table class='table-1'>
<tr>
<td width='300' valign='top'>
<?php echo $tree?>
<br />
</td>
<td valign='top'>
<form method='post' target='hiddenwin'>
<table class='table-1'>
<caption><?php echo $lang->editor->newPage?></caption>
<tr>
<th class='w-70px'><?php echo $lang->editor->filePath?></th>
<td><?php echo $filePath?></td>
</tr>
<tr>
<th><?php echo $lang->editor->pageName?></th>
<td>
<?php
echo html::input('fileName', '', "class=text-5");
echo $lang->editor->examplePHP;
?>
</td>
</tr>
<tr><td colspan='2' align='center'><?php echo html::submitButton()?><td></tr>
</table>
</form>
</td>
</tr>
</table>
<?php include '../../common/view/footer.html.php';?>