diff --git a/modules/layout/lang/lang.xml b/modules/layout/lang/lang.xml
index 0baaac8cd..a760babe9 100644
--- a/modules/layout/lang/lang.xml
+++ b/modules/layout/lang/lang.xml
@@ -24,7 +24,10 @@
-
+
+ -
+
+
-
@@ -1068,4 +1071,12 @@
+ -
+
+
+
+ -
+
+
+
diff --git a/modules/layout/layout.admin.controller.php b/modules/layout/layout.admin.controller.php
index 9a81c5ffe..f2f8ceb53 100644
--- a/modules/layout/layout.admin.controller.php
+++ b/modules/layout/layout.admin.controller.php
@@ -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
diff --git a/modules/layout/layout.admin.view.php b/modules/layout/layout.admin.view.php
index 836a2b1c9..5b1acccdd 100644
--- a/modules/layout/layout.admin.view.php
+++ b/modules/layout/layout.admin.view.php
@@ -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');
+ }
}
?>
diff --git a/modules/layout/ruleset/imageUpload.xml b/modules/layout/ruleset/imageUpload.xml
index e00d16354..0c7e5501a 100644
--- a/modules/layout/ruleset/imageUpload.xml
+++ b/modules/layout/ruleset/imageUpload.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/modules/layout/tpl/js/layout_admin.js b/modules/layout/tpl/js/layout_admin.js
index ebcad63e5..c58e59d74 100644
--- a/modules/layout/tpl/js/layout_admin.js
+++ b/modules/layout/tpl/js/layout_admin.js
@@ -49,6 +49,17 @@ function deleteFile(layout_srl,filename){
});
}
+function addLayoutCopyInputbox()
+{
+ var html = '';
+ html += ' | ';
+ html += ' | ';
+ html += '
';
+
+ 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);
\ No newline at end of file
+})(jQuery);
diff --git a/modules/layout/tpl/layout_instance_list.html b/modules/layout/tpl/layout_instance_list.html
index 920f0793b..e62bfcd5d 100644
--- a/modules/layout/tpl/layout_instance_list.html
+++ b/modules/layout/tpl/layout_instance_list.html
@@ -15,6 +15,7 @@
{$lang->regdate} |
{$lang->cmd_layout_management} |
{$lang->cmd_layout_edit} |
+ {$lang->cmd_copy} |
{$lang->cmd_delete} |
@@ -25,6 +26,7 @@
{zdate($layout->regdate, "Y-m-d")} |
{$lang->cmd_layout_management} |
{$lang->cmd_layout_edit} |
+ {$lang->cmd_copy} |
|