@@ -17,11 +17,59 @@ class editor extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
public function index($editFileName = '', $action = '')
|
||||
{
|
||||
$allModules = $this->editor->getModuleFiles();
|
||||
$this->view->tree = $this->editor->printTree($allModules);
|
||||
$this->view->tree = $this->editor->printTree($allModules);
|
||||
$editFileName = helper::safe64Decode($editFileName);
|
||||
$fileContent = '';
|
||||
if($editFileName and file_exists($editFileName))
|
||||
{
|
||||
if($action == 'edit')
|
||||
{
|
||||
$fileContent = file_get_contents($editFileName);
|
||||
}
|
||||
}
|
||||
$this->view->fileContent = $fileContent;
|
||||
$this->view->filePath = empty($fileContent) ? '' : $editFileName;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save file to extension.
|
||||
*
|
||||
* @param string $filePath
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function save($filePath = '')
|
||||
{
|
||||
if($filePath and $_POST)
|
||||
{
|
||||
$filePath = helper::safe64Decode($filePath);
|
||||
$this->editor->save($filePath);
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete extension file.
|
||||
*
|
||||
* @param string $filePath
|
||||
* @param string $confirm
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function delete($filePath = '', $confirm = 'no')
|
||||
{
|
||||
if($confirm == 'no')
|
||||
{
|
||||
die(js::confirm($this->lang->editor->deleteConfirm, inlink('delete', "filePath=$filePath&confirm=yes")));
|
||||
}
|
||||
$filePath = helper::safe64Decode($filePath);
|
||||
if(file_exists($filePath) and unlink($filePath)) die(js::reload('parent'));
|
||||
die(js::alert($this->lang->editor->noDelete));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+88
-4
@@ -34,21 +34,77 @@ class editorModel extends model
|
||||
$moduleFullFile = $moduleFullDir . '/' . $moduleFile;
|
||||
if($moduleFile == 'control.php' or $moduleFile == 'model.php')
|
||||
{
|
||||
$allModules[$moduleDir][$moduleFullFile] = $this->analysis($moduleFullFile);
|
||||
$allModules[$moduleFullDir][$moduleFullFile] = $this->analysis($moduleFullFile);
|
||||
}
|
||||
elseif($moduleFile == 'ext')
|
||||
{
|
||||
$allModules[$moduleFullDir][$moduleFullFile] = $this->getExtensionFiles($moduleFullFile);
|
||||
}
|
||||
elseif(is_dir($moduleFullFile))
|
||||
{
|
||||
foreach(glob($moduleFullFile . '/' . '*.php') as $fileName) $allModules[$moduleDir][$moduleFile][$fileName] = basename($fileName);
|
||||
foreach(glob($moduleFullFile . '/' . '*.php') as $fileName) $allModules[$moduleFullDir][$moduleFullFile][$fileName] = basename($fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
$allModules[$moduleDir][$moduleFullFile] = $moduleFile;
|
||||
$allModules[$moduleFullDir][$moduleFullFile] = $moduleFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $allModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension files.
|
||||
*
|
||||
* @param int $extPath
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getExtensionFiles($extPath)
|
||||
{
|
||||
$extensionList = array();
|
||||
$extensionDirs = scandir($extPath);
|
||||
foreach($extensionDirs as $extensionDir)
|
||||
{
|
||||
if($extensionDir == '.' or $extensionDir == '..' or $extensionDir == '.svn') continue;
|
||||
$extensionFullDir = $extPath . '/' . $extensionDir;
|
||||
if(is_dir($extensionFullDir))
|
||||
{
|
||||
$extensionList[$extensionFullDir] = array();
|
||||
/* extend of lang is more a grade of directroy. */
|
||||
if($extensionDir == 'lang')
|
||||
{
|
||||
$langDirs = scandir($extensionFullDir);
|
||||
foreach($langDirs as $langDir)
|
||||
{
|
||||
if($langDir == '.' or $langDir == '..' or $langDir == '.svn') continue;
|
||||
$langFullDir = $extensionFullDir . '/' . $langDir;
|
||||
$extensionList[$extensionFullDir][$langFullDir] = array();
|
||||
if(is_dir($langFullDir))
|
||||
{
|
||||
$langFiles = scandir($langFullDir);
|
||||
foreach($langFiles as $langFile)
|
||||
{
|
||||
if($langFile == '.' or $langFile == '..' or $langFile == '.svn') continue;
|
||||
$langFullFile = $langFullDir . '/' . $langFile;
|
||||
$extensionList[$extensionFullDir][$langFullDir][$langFullFile] = $langFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$extensionFiles = scandir($extensionFullDir);
|
||||
foreach($extensionFiles as $extensionFile)
|
||||
{
|
||||
if($extensionFile == '.' or $extensionFile == '..' or $extensionFile == '.svn') continue;
|
||||
$extensionFullFile = $extensionFullDir . '/' . $extensionFile;
|
||||
$extensionList[$extensionFullDir][$extensionFullFile] = $extensionFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $extensionList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysis methods of control and model.
|
||||
*
|
||||
@@ -95,11 +151,39 @@ class editorModel extends model
|
||||
}
|
||||
else
|
||||
{
|
||||
$tree .= $file . "\n";
|
||||
if(strpos($key, '/ext/') !== false)
|
||||
{
|
||||
$tree .= $file . html::a(inlink('index', "editFileName=" . helper::safe64Encode($key) . "&action=edit"), $this->lang->edit) . html::a(inlink('delete', 'path=' . helper::safe64Encode($key)), $this->lang->delete, 'hiddenwin') . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$tree .= $file . "\n";
|
||||
}
|
||||
}
|
||||
$tree .= "</li>\n";
|
||||
}
|
||||
$tree .= "</ul>\n";
|
||||
return $tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save file to extension.
|
||||
*
|
||||
* @param string $filePath
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function save($filePath)
|
||||
{
|
||||
$fileContent = $this->post->fileContent;
|
||||
if(get_magic_quotes_gpc()) $fileContent = stripslashes($fileContent);
|
||||
if(is_writable($filePath))
|
||||
{
|
||||
file_put_contents($filePath, $fileContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
die(js::alert($this->lang->editor->noWritable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,20 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/treeview.html.php';?>
|
||||
<table class='table-1'>
|
||||
<tr><td>
|
||||
<?php echo $tree;?>
|
||||
<br />
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width='300'>
|
||||
<?php echo $tree?>
|
||||
<br />
|
||||
</td>
|
||||
<td valign='top'>
|
||||
<span><?php if($filePath) printf($lang->editor->editFile,$filePath)?></span>
|
||||
<form method='post' target='hiddenwin' action='<?php echo inlink('save', "filePath=" . helper::safe64Encode($filePath))?>'>
|
||||
<?php echo html::textarea('fileContent', $fileContent, "class='area-1' rows=40")?>
|
||||
<br/>
|
||||
<?php echo html::submitButton()?>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user