From 0bb416558e65dcbb79559294e42313d6f4cfb8b2 Mon Sep 17 00:00:00 2001 From: devjin Date: Tue, 26 Jul 2011 09:38:35 +0000 Subject: [PATCH] issue 92 add Theme modify getLayoutPath() function git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8653 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/layout/layout.model.php | 50 ++++++++++++++++++- .../updateAllLayoutInSiteWithTheme.xml | 11 ++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 modules/layout/queries/updateAllLayoutInSiteWithTheme.xml diff --git a/modules/layout/layout.model.php b/modules/layout/layout.model.php index 60afb28fe..cdc0a2318 100644 --- a/modules/layout/layout.model.php +++ b/modules/layout/layout.model.php @@ -52,7 +52,10 @@ function getLayoutPath($layout_name, $layout_type = "P") { if($layout_name == 'faceoff'){ $class_path = './modules/layout/faceoff/'; - }else if($layout_type == "M") { + }else if(strpos($layout_name, '.') !== false){ + $layout_parse = explode('.', $layout_name); + $class_path = sprintf('./themes/%s/layout/%s/', $layout_parse[0], $layout_parse[1]); + }else if($layout_type == "M") { $class_path = sprintf("./m.layouts/%s/", $layout_name); } else @@ -282,7 +285,21 @@ } } + if ($xml_obj->skins){ + $buff .= '$layout_info->skins = array();'; + $buff .= '$layout_info->skins["module"] = array();'; + $buff .= '$layout_info->skins["widget"] = array();'; + $skins = $xml_obj->skins->skin; + + if (is_array($skins)){ + foreach($skins as $val){ + $buff .= '$layout_info->skins["'.$val->attrs->type.'"]["'.$val->attrs->name.'"] = "'.$val->attrs->skin.'";'; + } + }else{ + $buff .= '$layout_info->skins["'.$skins->attrs->type.'"]["'.$skins->attrs->name.'"] = "'.$skins->attrs->skin.'";'; + } + } } else { // Layout title, version and other information @@ -605,5 +622,36 @@ Context::addBodyHeader($oTemplate->compile($this->module_path.'/tpl', 'faceoff_layout_menu')); } } + + function getThemaXml($layout_path){ + if(!$layout_path) return; + + $xml_file = sprintf("%sconf/thema.xml", $layout_path); + if(!file_exists($xml_file)) return; + + $oXmlParser = new XmlParser(); + $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); + $xml_obj = $tmp_xml_obj->thema; + + if(!$xml_obj) return; + + $thema_info->layout_name = $xml_obj->name->body; + $thema_info->skins = array(); + $thema_info->skins['module'] = array(); + $thema_info->skins['widget'] = array(); + + $skins = $xml_obj->skins->skin; + if ($skins){ + if (is_array($skins)){ + foreach($skins as $val){ + $thema_info->skins[$val->attrs->type][$val->attrs->name] = $val->attrs->skin; + } + }else{ + $thema_info->skins[$skins->attrs->type][$skins->attrs->name] = $skins->attrs->skin; + } + } + return $thema_info; + + } } ?> diff --git a/modules/layout/queries/updateAllLayoutInSiteWithTheme.xml b/modules/layout/queries/updateAllLayoutInSiteWithTheme.xml new file mode 100644 index 000000000..fdc0f4fca --- /dev/null +++ b/modules/layout/queries/updateAllLayoutInSiteWithTheme.xml @@ -0,0 +1,11 @@ + + + + + + + + + + +