30 $args->site_srl = (int)$site_module_info->site_srl;
35 if(!
$args->layout_type)
$args->layout_type =
"P";
73 if($oLayoutModel->useDefaultLayout($layout_name))
108 $layout_info = $oLayoutModel->getLayout(
$args->layout_srl);
110 if($layout_info->menu)
112 $menus = get_object_vars($layout_info->menu);
116 foreach($menus as $menu_id => $val)
119 if(!$menu_srl)
continue;
126 $tmpArgs =
new stdClass;
127 $tmpArgs->url = $start_module->mid;
128 $tmpArgs->site_srl = 0;
135 $menu_srl =
$output->data->menu_srl;
138 $output = $oMenuAdminModel->getMenu($menu_srl);
140 $menu_srl_list[] = $menu_srl;
141 $menu_name_list[$menu_srl] =
$output->title;
146 if($apply_layout==
'Y' || $apply_mobile_view==
'Y')
148 $menu_args =
new stdClass();
149 $menu_args->menu_srl = $menu_srl;
150 $menu_args->site_srl = $layout_info->site_srl;
155 for($i=0;$i<count(
$output->data);$i++)
157 $modules[] =
$output->data[$i]->module_srl;
162 $update_args =
new stdClass();
163 $update_args->module_srls = implode(
',',$modules);
164 if($apply_layout ==
"Y")
166 $update_args->layout_srl =
$args->layout_srl;
168 if($layout_info->layout_type ==
"M")
172 $update_args->use_mobile =
"Y";
182 if($oCacheHandler->isSupport())
184 $oCacheHandler->invalidateGroupKey(
'site_and_module');
192 $tmpDir = sprintf(
'./files/attach/images/%s/tmp',
$args->layout_srl);
194 if($layout_info->extra_var)
196 foreach($layout_info->extra_var as $name => $vars)
198 if($vars->type!=
'image')
continue;
201 if($vars->value == $fileName)
213 $pathInfo = pathinfo($fileName);
214 $tmpFileName = sprintf(
'%s/tmp/%s', $pathInfo[
'dirname'], $pathInfo[
'basename']);
226 $layout_config =
new stdClass();
227 $layout_config->header_script =
Context::get(
'header_script');
249 $context->setRequestMethod(
'JSON');
250 $this->setMessage(
'success');
279 $this->setRedirectUrl(
Context::get(
'error_return_url'));
294 $layoutInfo = $oLayoutModel->getLayout(
$layout_srl);
297 $layoutList = $oLayoutModel->getLayoutInstanceList($layoutInfo->site_srl, $layoutInfo->layout_type, $layoutInfo->layout, array(
'layout_srl',
'layout'));
298 if(count($layoutList) <= 1)
301 $path = $layoutInfo->path;
303 $oAutoinstallModel =
getModel(
'autoinstall');
304 $packageSrl = $oAutoinstallModel->getPackageSrlByPath($path);
309 $output = $oAutoinstallAdminController->uninstallPackageByPackageSrl($packageSrl);
313 $output = $oAutoinstallAdminController->uninstallPackageByPath($path);
324 $path = $oLayoutModel->getUserLayoutPath(
$layout_srl);
327 $layout_file = $oLayoutModel->getUserLayoutHtml(
$layout_srl);
330 $args =
new stdClass();
346 if ($mode ==
'reset')
348 return $this->procLayoutAdminCodeReset();
354 $is_post = ($_SERVER[
'REQUEST_METHOD'] ==
'POST');
358 return new BaseObject(-1,
'msg_invalid_request');
362 $layout_file = $oLayoutModel->getUserLayoutHtml(
$layout_srl);
365 $layout_css_file = $oLayoutModel->getUserLayoutCss(
$layout_srl);
368 $this->setRedirectUrl(
Context::get(
'error_return_url'));
369 $this->setMessage(
'success_updated');
383 $layout_file = $oLayoutModel->getUserLayoutHtml(
$layout_srl);
389 if($oLayoutModel->useDefaultLayout($info->layout))
392 $faceoff_css = $oLayoutModel->getUserLayoutFaceOffCss(
$layout_srl);
397 $this->setMessage(
'success_reset');
398 $this->setRedirectUrl(
Context::get(
'error_return_url'));
411 if(!is_uploaded_file($image[
'tmp_name'])) exit();
414 $this->setTemplatePath($this->module_path.
'tpl');
415 $this->setTemplateFile(
"top_refresh.html");
417 $this->setRedirectUrl(
Context::get(
'error_return_url'));
429 $path = $oLayoutModel->getUserLayoutImagePath(
$layout_srl);
432 $filename = strtolower($source[
'name']);
433 if($filename != urlencode($filename))
435 $ext = substr(strrchr($filename,
'.'),1);
436 $filename = sprintf(
'%s.%s', md5($filename), $ext);
442 if(file_exists($path .
'/'. $filename)) @unlink($path . $filename);
443 if(!move_uploaded_file($source[
'tmp_name'], $path . $filename ))
return false;
455 $this->removeUserLayoutImage(
$layout_srl,$filename);
456 $this->setMessage(
'success_deleted');
457 $this->setRedirectUrl(
Context::get(
'error_return_url'));
469 $path = $oLayoutModel->getUserLayoutImagePath(
$layout_srl);
470 @unlink($path . $filename);
485 if(!$mid)
return new BaseObject(-1,
'msg_invalid_request');
488 $columnList = array(
'layout_srl');
499 $oLayoutModel->setUseUserLayoutTemp();
507 $this->add(
'saveTemp',$temp);
512 $file = $oLayoutModel->getUserLayoutHtml(
$layout_srl);
514 $content = $this->addExtension(
$layout_srl,$extension_obj,$content);
520 $css_file = $oLayoutModel->getUserLayoutFaceOffCss(
$layout_srl);
526 $src = $oLayoutModel->getUserLayoutIniConfig(
$layout_srl);
527 foreach(
$obj as $key => $val) $src[$key] = $val;
540 $file = $oLayoutModel->getUserLayoutIni(
$layout_srl);
554 $reg =
'/(<\!\-\- start\-e1 \-\->)(.*)(<\!\-\- end\-e1 \-\->)/i';
555 $extension_content =
'\1' .stripslashes($arg->e1) .
'\3';
556 $content = preg_replace($reg,$extension_content,$content);
558 $reg =
'/(<\!\-\- start\-e2 \-\->)(.*)(<\!\-\- end\-e2 \-\->)/i';
559 $extension_content =
'\1' .stripslashes($arg->e2) .
'\3';
560 $content = preg_replace($reg,$extension_content,$content);
562 $reg =
'/(<\!\-\- start\-neck \-\->)(.*)(<\!\-\- end\-neck \-\->)/i';
563 $extension_content =
'\1' .stripslashes($arg->neck) .
'\3';
564 $content = preg_replace($reg,$extension_content,$content);
566 $reg =
'/(<\!\-\- start\-knee \-\->)(.*)(<\!\-\- end\-knee \-\->)/i';
567 $extension_content =
'\1' .stripslashes($arg->knee) .
'\3';
568 $content = preg_replace($reg,$extension_content,$content);
580 $file_list = $oLayoutModel->getUserLayoutTempFileList(
$layout_srl);
581 foreach($file_list as $key => $file)
596 require_once(
_XE_PATH_.
'libs/tar.class.php');
600 $file_path = $oLayoutModel->getUserLayoutPath(
$layout_srl);
601 $target_path = $oLayoutModel->getUserLayoutPath(0);
605 $ini_config = $oLayoutModel->getUserLayoutIniConfig(0);
606 $file_list = $oLayoutModel->getUserLayoutFileList(
$layout_srl);
607 unset($file_list[2]);
609 foreach($file_list as $file)
611 if(strncasecmp(
'images', $file, 6) === 0)
continue;
614 $file = $target_path . $file;
616 $pattern =
'/(http:\/\/[^ ]+)?(\.\/)?' . str_replace(
'/',
'\/', (str_replace(
'./',
'', $file_path))) .
'/';
617 if(basename($file) ==
'faceoff.css' || basename($file) ==
'layout.css')
618 $content = preg_replace($pattern,
'../', $content);
620 $content = preg_replace($pattern,
'./', $content);
623 foreach($ini_config as $key => $value)
625 $content = str_replace(
'{$layout_info->faceoff_ini_config[\'' . $key .
'\']}
', $value, $content);
628 FileHandler::writeFile($file, $content);
632 $info_file = $target_path . 'conf/info.xml
';
633 FileHandler::copyFile('./modules/
layout/faceoff/conf/info.xml
', $info_file);
634 $content = FileHandler::readFile($info_file);
635 $content = str_replace('type=
"faceoff"', '', $content);
636 FileHandler::writeFile($info_file, $content);
637 $file_list[] = 'conf/info.xml
';
640 $css_file = $target_path . 'css/
layout.css
';
641 FileHandler::copyFile('./modules/
layout/faceoff/css/
layout.css
', $css_file);
642 $content = FileHandler::readFile('./modules/
layout/tpl/css/
widget.css
');
643 FileHandler::writeFile($css_file, "\n" . $content, 'a
');
644 $content = FileHandler::readFile($target_path . 'faceoff.css
');
645 FileHandler::writeFile($css_file, "\n" . $content, 'a
');
646 $content = FileHandler::readFile($target_path . 'layout.css
');
647 FileHandler::writeFile($css_file, "\n" . $content, 'a
');
650 $content = FileHandler::readFile($target_path . 'layout.html
');
651 $content = "<load target=\"css/layout.css\" />\n" . $content;
652 FileHandler::writeFile($target_path . 'layout.html
', $content);
653 unset($file_list[3]);
654 unset($file_list[1]);
655 $file_list[] = 'css/
layout.css
';
657 // Compress the files
659 $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath(0));
660 chdir($user_layout_path);
661 foreach($file_list as $key => $file) $tar->addFile($file);
663 $stream = $tar->toTarStream();
664 $filename = 'faceoff_
' . date('YmdHis
') . '.tar
';
665 header("Cache-Control: ");
667 header("Content-Type: application/x-compressed");
668 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
669 // header("Content-Length: " .strlen($stream)); ?? why??
670 header('Content-Disposition: attachment; filename=
"'. $filename .'"');
671 header("Content-Transfer-Encoding: binary\n");
673 // Close Context and then exit
677 FileHandler::removeDir($target_path);
687 function procLayoutAdminUserLayoutImport()
689 return $this->stop('not supported
');
692 if(!Context::isUploaded()) exit();
693 $file = Context::get('file');
694 if(!is_uploaded_file($file['tmp_name
']) || !checkUploadedFile($file['tmp_name
'])) exit();
696 if(substr_compare($file['name
'], '.tar
', -4) !== 0) exit();
699 if(!$layout_srl) exit();
701 $oLayoutModel = getModel('layout');
702 $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl));
703 if(!move_uploaded_file($file['tmp_name
'], $user_layout_path . 'faceoff.tar
')) exit();
705 $this->importLayout($layout_srl, $user_layout_path.'faceoff.tar
');
707 $this->setRedirectUrl(Context::get('error_return_url
'));
714 function procLayoutAdminCopyLayout()
716 $sourceArgs = Context::getRequestVars();
717 if($sourceArgs->layout == 'faceoff
')
719 return $this->stop('not supported
');
722 if(!$sourceArgs->layout_srl)
724 return $this->stop('msg_empty_origin_layout
');
727 $oLayoutModel = getModel('layout');
728 $layout = $oLayoutModel->getLayout($sourceArgs->layout_srl);
730 if(!$sourceArgs->title)
732 $sourceArgs->title = array($layout->title.'_
'.$this->_makeRandomMid());
735 if(!is_array($sourceArgs->title) || count($sourceArgs->title) == 0)
737 return $this->stop('msg_empty_target_layout
');
740 $output = $oLayoutModel->getLayoutRawData($sourceArgs->layout_srl, array('extra_vars'));
741 $args = new stdClass();
742 $args->extra_vars = $output->extra_vars;
743 $extra_vars = unserialize($args->extra_vars);
745 if($layout->extra_var_count) {
746 $reg = "/^.\/files\/attach\/images\/([0-9]+)\/(.*)/";
747 if($extra_vars) foreach($extra_vars as $key => $val) {
748 if($layout->extra_var->{$key}->type == 'image
') {
749 if(!preg_match($reg,$val,$matches)) continue;
750 $image_list[$key]->filename = $matches[2];
751 $image_list[$key]->old_file = $val;
756 $oModuleController = getController('module');
757 $layout_config = new stdClass();
758 $layout_config->header_script = $extra_vars->header_script;
760 // Get information to create a layout
761 $args->site_srl = (int)$layout->site_srl;
762 $args->layout = $layout->layout;
763 $args->layout_type = $layout->layout_type;
764 if(!$args->layout_type) $args->layout_type = "P";
766 $oDB = &DB::getInstance();
769 if(is_array($sourceArgs->title))
771 foreach($sourceArgs->title AS $key=>$value)
778 $args->layout_srl = getNextSequence();
779 $args->title = $value;
781 if(is_array($image_list)) {
782 foreach($image_list as $key=>$val) {
783 $new_file = sprintf("./files/attach/images/%s/%s", $args->layout_srl,$val->filename);
784 FileHandler::copyFile($val->old_file, $new_file);
785 $extra_vars->{$key} = $new_file;
787 $args->extra_vars = serialize($extra_vars);
791 $oModuleController->insertModulePartConfig('layout', $args->layout_srl, $layout_config);
793 // Insert into the DB
794 $output = $this->insertLayout($args);
795 if(!$output->toBool())
801 // initiate if it is faceoff layout
802 $this->initLayout($args->layout_srl, $args->layout);
804 // update layout info
805 $output = $this->updateLayout($args);
806 if (!$output->toBool())
812 $this->_copyLayoutFile($layout->layout_srl, $args->layout_srl);
817 $this->setMessage('success_registed
');
818 if(!in_array(Context::getRequestMethod(),array('XMLRPC
','JSON
'))) {
821 alertScript($lang->success_registed);
830 private function _makeRandomMid()
832 $time = $_SERVER['REQUEST_TIME
'];
837 $randomString .= chr($doc);
840 return $randomString.substr($time, -4);
849 function _copyLayoutFile($sourceLayoutSrl, $targetLayoutSrl)
851 $oLayoutModel = getModel('layout');
852 $sourceLayoutPath = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($sourceLayoutSrl));
853 $targetLayoutPath = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($targetLayoutSrl));
855 $sourceImagePath = $oLayoutModel->getUserLayoutImagePath($sourceLayoutSrl);
856 $targetImagePath = $oLayoutModel->getUserLayoutImagePath($targetLayoutSrl);
857 FileHandler::makeDir($targetImagePath);
859 $sourceFileList = $oLayoutModel->getUserLayoutFileList($sourceLayoutSrl);
860 foreach($sourceFileList as $key => $file)
862 if(is_readable($sourceLayoutPath.$file))
864 FileHandler::copyFile($sourceLayoutPath.$file, $targetLayoutPath.$file);
867 $this->_changeFilepathInSource($targetLayoutPath.$file, $sourceImagePath, $targetImagePath);
878 function _changeFilepathInSource($file, $source, $target)
880 $content = FileHandler::readFile($file);
881 $content = str_replace($source, $target, $content);
882 FileHandler::writeFile($file, $content);
891 function importLayout($layout_srl, $source_file)
893 $oLayoutModel = getModel('layout');
894 $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl));
895 $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl);
896 foreach($file_list as $key => $file)
898 FileHandler::removeFile($user_layout_path . $file);
901 require_once(_XE_PATH_.'libs/
tar.class.php
');
902 $image_path = $oLayoutModel->getUserLayoutImagePath($layout_srl);
903 FileHandler::makeDir($image_path);
905 $tar->openTAR($source_file);
906 // If layout.ini file does not exist
907 if(!$tar->getFile('layout.ini
')) return;
909 $replace_path = getNumberingPath($layout_srl,3);
910 foreach($tar->files as $key => $info)
912 FileHandler::writeFile($user_layout_path . $info['name
'],str_replace('__LAYOUT_PATH__
',$replace_path,$info['file']));
914 // Remove uploaded file
915 FileHandler::removeFile($source_file);
921 function procLayoutAdminConfigImageUpload()
924 $name = Context::get('name
');
925 $img = Context::get('img
');
927 $this->setTemplatePath($this->module_path.'tpl
');
928 $this->setTemplateFile("after_upload_config_image.html");
930 if(!$img['tmp_name
'] || !is_uploaded_file($img['tmp_name
']) || !checkUploadedFile($img['tmp_name
']))
932 Context::set('msg
', Context::getLang('upload failed
'));
936 if(!preg_match('/\.(jpg|jpeg|gif|png)$/i
', $img['name
']))
938 Context::set('msg
', Context::getLang('msg_layout_image_target
'));
942 $path = sprintf('./files/attach/images/%s/
', $layoutSrl);
943 $tmpPath = $path . 'tmp/
';
944 if(!FileHandler::makeDir($tmpPath))
946 Context::set('msg
', Context::getLang('make directory failed
'));
950 $ext = substr(strrchr($img['name
'],'.
'),1);
951 $_fileName = md5(crypt(rand(1000000,900000), rand(0,100))).'.
'.$ext;
952 $fileName = $path . $_fileName;
953 $tmpFileName = $tmpPath . $_fileName;
955 if(!move_uploaded_file($img['tmp_name
'], $tmpFileName))
957 Context::set('msg
', Context::getLang('move
file failed
'));
961 Context::set('name
', $name);
962 Context::set('fileName
', $fileName);
963 Context::set('tmpFileName
', $tmpFileName);
969 function procLayoutAdminConfigImageDelete()
972 $name = Context::get('name
');
974 $this->setTemplatePath($this->module_path.'tpl
');
975 $this->setTemplateFile("after_delete_config_image.html");
977 $oModel = getModel('layout');
978 $layoutInfo = $oModel->getLayout($layoutSrl);
980 if($layoutInfo->extra_var_count)
982 foreach($layoutInfo->extra_var as $varId => $val)
984 $newLayoutInfo->{$varId} = $val->value;
988 unset($newLayoutInfo->{$name});
990 $args->layout_srl = $layoutSrl;
991 $args->extra_vars = serialize($newLayoutInfo);
992 $output = $this->updateLayout($args);
993 if(!$output->toBool())
995 Context::set('msg
', Context::getLang($output->getMessage()));
999 FileHandler::removeFile($layoutInfo->extra_var->{$name}->value);
1000 Context::set('name
', $name);
1003 /* End of file layout.admin.controller.php */
1004 /* Location: ./modules/layout/layout.admin.controller.php */
getController($module_name)
procLayoutAdminUserImageUpload()
& getInstance($target= 'object', $info=null, $always_use_file=false)
addExtension($layout_srl, $arg, $content)
importLayout($layout_srl, $source_file)
foreach($sitemap as $id=> &$val) $extra_vars
set($key, $val, $set_to_get_vars=0)
writeFile($filename, $buff, $mode="w")
procLayoutAdminUserValueInsert()
procLayoutAdminCodeUpdate()
moveFile($source, $target)
insertUserLayoutValue($layout_srl, $arr)
setRedirectUrl($url= './', $output=NULL)
getAdminModel($module_name)
procLayoutAdminCodeReset()
writeIniFile($filename, $arr)
procLayoutAdminUserImageDelete()
removeUserLayoutImage($layout_srl, $filename)
procLayoutAdminUserLayoutExport()
copyDir($source_dir, $target_dir, $filter=null, $type=null)
deleteLayout($layout_srl, $force=FALSE)
deleteUserLayoutTempFile($layout_srl)
insertUserLayoutImage($layout_srl, $source)
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
getAdminController($module_name)
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
initLayout($layout_srl, $layout_name)
high class of the module module