issue layout copy feature add

layout file upload bug fix


git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.1@10864 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-07-11 01:41:07 +00:00
parent 997aae1884
commit 484111e9c1
8 changed files with 164 additions and 5 deletions

View file

@ -16,6 +16,7 @@
<action name="dispLayoutAdminInsert" type="view" menu_name="installedLayout" />
<action name="dispLayoutAdminModify" type="view" menu_name="installedLayout" />
<action name="dispLayoutAdminEdit" type="view" menu_name="installedLayout" />
<action name="dispLayoutAdminCopyLayout" type="view" />
<action name="dispLayoutPreview" type="view" />
@ -32,6 +33,7 @@
<action name="procLayoutAdminUserValueInsert" type="controller" standalone="true" />
<action name="procLayoutAdminUserLayoutExport" type="controller" standalone="true" />
<action name="procLayoutAdminUserLayoutImport" type="controller" standalone="true" ruleset="userLayoutImport" />
<action name="procLayoutAdminCopyLayout" type="controller" standalone="true" />
</actions>
<menus>

View file

@ -24,7 +24,10 @@
<value xml:lang="es"><![CDATA[Editar el Diseño]]></value>
<value xml:lang="tr"><![CDATA[Yerleşim Düzeni Düzenle]]></value>
<value xml:lang="vi"><![CDATA[Sửa giao diện]]></value>
</item>
<item name="cmd_layout_copy">
<value xml:lang="ko"><![CDATA[레이아웃 복사]]></value>
<value xml:lang="en"><![CDATA[Copy Layout]]></value>
</item>
<item name="layout_name">
<value xml:lang="ko"><![CDATA[레이아웃 이름]]></value>
@ -1068,4 +1071,12 @@
<value xml:lang="zh-TW"><![CDATA[從"已安裝版面"中建立新版面。 確認版面路徑是否上傳正確及修改版面相關設定。]]></value>
</item>
</item>
<item name="msg_empty_origin_layout">
<value xml:lang="ko"><![CDATA[원본 Layout이 없습니다.]]></value>
<value xml:lang="en"><![CDATA[Original layout is not exist]]></value>
</item>
<item name="msg_empty_target_layout">
<value xml:lang="ko"><![CDATA[복사할 Layout이 지정되어 있지 않습니다.]]></value>
<value xml:lang="en"><![CDATA[Target layout is not assigned]]></value>
</item>
</lang>

View file

@ -605,6 +605,116 @@
$this->setRedirectUrl(Context::get('error_return_url'));
}
/**
* layout copy
* @return void
*/
function procLayoutAdminCopyLayout()
{
$sourceArgs = Context::getRequestVars();
if($sourceArgs->layout == 'faceoff')
{
return $this->stop('not supported');
}
if(!$sourceArgs->layout_srl)
{
return $this->stop('msg_empty_origin_layout');
}
if(!is_array($sourceArgs->title) || count($sourceArgs->title) == 0)
{
return $this->stop('msg_empty_target_layout');
}
$oLayoutModel = &getModel('layout');
$layout = $oLayoutModel->getLayout($sourceArgs->layout_srl);
// Get information to create a layout
$args->site_srl = (int)$layout->site_srl;
$args->layout = $layout->layout;
$args->layout_type = $layout->type;
if(!$args->layout_type) $args->layout_type = "P";
$oDB = &DB::getInstance();
$oDB->begin();
if(is_array($sourceArgs->title))
{
foreach($sourceArgs->title AS $key=>$value)
{
$args->layout_srl = getNextSequence();
$args->title = $value;
// Insert into the DB
$output = $this->insertLayout($args);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
// initiate if it is faceoff layout
$this->initLayout($args->layout_srl, $args->layout);
// update layout info
$args->extra_vars = $layout->extra_var;
$output = $this->updateLayout($args);
if (!$output->toBool())
{
$oDB->rollback();
return $output;
}
$this->_copyLayoutFile($layout->layout_srl, $args->layout_srl);
}
}
$oDB->commit();
$this->setMessage('success_registed');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
global $lang;
htmlHeader();
alertScript($lang->success_registed);
reload(true);
closePopupScript();
htmlFooter();
Context::close();
exit;
}
}
/**
* Layout file copy
* @param $sourceLayoutSrl origin layout number
* @param $targetLayoutSrl origin layout number
* @return void
*/
function _copyLayoutFile($sourceLayoutSrl, $targetLayoutSrl)
{
$oLayoutModel = &getModel('layout');
$sourceLayoutPath = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($sourceLayoutSrl));
$targetLayoutPath = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($targetLayoutSrl));
$sourceImagePath = $oLayoutModel->getUserLayoutImagePath($sourceLayoutSrl);
$targetImagePath = $oLayoutModel->getUserLayoutImagePath($targetLayoutSrl);
FileHandler::makeDir($targetimagePath);
$sourceFileList = $oLayoutModel->getUserLayoutFileList($sourceLayoutSrl);
foreach($sourceFileList as $key => $file)
{
if(is_readable($sourceLayoutPath.$file))
{
FileHandler::copyFile($sourceLayoutPath.$file, $targetLayoutPath.$file);
}
}
/*$sourceImageFiles = FileHandler::readDir($sourceImagePath);
if(is_array($sourceImageFiles))
{
}*/
}
/**
* import layout
* @param int $layout_srl

View file

@ -457,5 +457,19 @@
$this->setTemplateFile('layout_image_list');
}
/**
* Copy layout instance
* @return void
*/
function dispLayoutAdminCopyLayout(){
$layoutSrl = Context::get('layout_srl');
$oLayoutModel = &getModel('layout');
$layout = $oLayoutModel->getLayout($layoutSrl);
Context::set('layout', $layout);
$this->setTemplateFile('copy_layout');
}
}
?>

View file

@ -4,7 +4,7 @@
<rule name="imageExtension" type="regex" test="/\.(gif|jpg|jpeg|gif|png|swf|flv)$/i" />
</customrules>
<fields>
<field name="user_layout_image" required="true" rule="imageExtension" />
<field name="user_layout_image['name']" required="true" rule="imageExtension" />
<field name="layout_srl" required="true" rule="number" />
</fields>
</ruleset>

View file

@ -49,6 +49,17 @@ function deleteFile(layout_srl,filename){
});
}
function addLayoutCopyInputbox()
{
var html = '<tr>';
html += '<td><input type="text" name="title[]" size="50" /></td>';
html += '<td><span class="btn"><input type="button" value="'+addLang+'" onclick="addLayoutCopyInputbox()" /></span></td>';
html += '</tr>';
var it = jQuery('#inputTable');
it.append(html);
}
(function($){
/* preview layout */
@ -78,4 +89,4 @@ validator.cast('ADD_CALLBACK', ['update_layout_code', function(form) {
return false;
}]);
})(jQuery);
})(jQuery);

View file

@ -15,6 +15,7 @@
<th scope="col" class="nowr">{$lang->regdate}</th>
<th scope="col" class="nowr">{$lang->cmd_layout_management}</th>
<th scope="col" class="nowr">{$lang->cmd_layout_edit}</th>
<th scope="col" class="nowr">{$lang->cmd_copy}</th>
<th scope="col" class="nowr">{$lang->cmd_delete}</th>
</tr>
</thead>
@ -25,6 +26,7 @@
<td class="nowr">{zdate($layout->regdate, "Y-m-d")}</td>
<td class="nowr"><a href="{getUrl('act', 'dispLayoutAdminModify', 'layout_srl', $layout->layout_srl)}">{$lang->cmd_layout_management}</a></td>
<td class="nowr"><a href="{getUrl('act', 'dispLayoutAdminEdit', 'layout_srl', $layout->layout_srl)}">{$lang->cmd_layout_edit}</a></td>
<td class="nowr"><a href="{getUrl('', 'module', 'layout', 'act', 'dispLayoutAdminCopyLayout', 'layout_srl', $layout->layout_srl)}" onclick="popopen(this.href);return false;" title="{$lang->cmd_copy}">{$lang->cmd_copy}</a></td>
<td class="nowr">
<form class="layout_delete_form" ruleset="deleteLayout" action="./" method="post">
<input type="hidden" name="module" value="layout" />