3 class mw_env_out extends mw_env
9 function set_out($key, $value) { $this->out[$key] = $value; return $value; }
10 function get_out() { return $this->out; }
11 function out($key) { return $this->out[$key]; }
15 if($dh = opendir($this->path("out")))
16 { while(($file = readdir($dh)) !== false)
17 { if(is_dir($this->path("out").$file) && substr($file, 0 ,1) != ".") $pathes[] = $file;
25 function out_file_exists($file, $PRIORITE = "DESC")
26 { $out_file = $this->_out_file($file, $PRIORITE);
27 return $out_file ? true : false;
30 function out_file($file, $PRIORITE = "DESC")
31 { $out_file = $this->_out_file($file, $PRIORITE);
32 return $out_file ? $out_file : $file;
35 function _out_file($file, $PRIORITE = "DESC")
37 if($PRIORITE == "ASC")
38 { $tmp_out_file = $this->path("out").$this->config("out").$file;
39 if($file && file_exists($tmp_out_file))
40 { $out_file = $tmp_out_file;
43 { $tmp_out_file = $this->path("out").$this->path("dist_out").$file;
44 if($file && file_exists($tmp_out_file))
45 { $out_file = $tmp_out_file;
49 if($out_file) return $out_file;
50 if(($plugins = $this->plugins($PRIORITE)) !== false)
51 { foreach($plugins as $plugin_name => $plugin)
52 { $tmp_out_file = $this->path("plugins").$plugin_name."/out/".$this->config("out").$file;
53 if($file && $plugin["installed"] && $plugin["enabled"] && file_exists($tmp_out_file))
54 { $out_file = $tmp_out_file;
58 { $tmp_out_file = $this->path("plugins").$plugin_name."/out/".$this->path("dist_out").$file;
59 if($file && $plugin["installed"] && $plugin["enabled"] && file_exists($tmp_out_file))
60 { $out_file = $tmp_out_file;
65 if($PRIORITE == "DESC" && !$out_file)
66 { $tmp_out_file = $this->path("out").$this->config("out").$file;
67 if($file && file_exists($tmp_out_file))
68 { $out_file = $tmp_out_file;
71 { $tmp_out_file = $this->path("out").$this->path("dist_out").$file;
72 if($file && file_exists($tmp_out_file))
73 { $out_file = $tmp_out_file;
81 # ---------------------------------------------------------------------------------
85 function set_out_config($out_config)
86 { $this->out_config = $out_config;
87 return $this->out_config;
90 function get_out_config() { return isset($this->out_config) ? $this->out_config : array(); }
92 function out_config($name)
93 { if(isset($this->out_config))
94 { $CONFIG = $this->get_CONFIG();
95 return isset($CONFIG["out_".$name]) ? $CONFIG["out_".$name] : $this->out_config[$name]["default"];
100 # ---------------------------------------------------------------------------------
104 function layout() { return $this->layout; }
106 function render_layout($layout = null)
107 { if(!isset($layout)) $layout = $this->init_layout();
108 if(($plugins = $this->plugins("ASC")) !== false)
109 { foreach($plugins as $plugin_name => $plugin)
110 { if($plugin["installed"] && $plugin["enabled"])
112 $functions_file = $this->path("plugins").$plugin_name."/out/".$this->config("out")."functions.php";
113 if(file_exists($functions_file))
115 require $functions_file;
118 { $functions_file = $this->path("plugins").$plugin_name."/out/".$this->path("dist_out")."functions.php";
119 if($plugin["installed"] && $plugin["enabled"] && file_exists($functions_file))
120 { require $functions_file;
126 $functions_file = $this->path("out").$this->config("out")."functions.php";
127 if(file_exists($functions_file))
129 require $functions_file;
132 { $functions_file = $this->path("out").$this->path("dist_out")."functions.php";
133 if(file_exists($functions_file))
134 { require $functions_file;
138 { if($this->out_file_exists($layout["page"])) require $this->out_file($layout["page"]);
140 elseif($layout["content"])
141 { if($this->out_file_exists($layout["content"])) require $this->out_file($layout["content"]);
146 function init_layout()
147 { $this->layout = array();
148 $this->_init_layout("index");
149 if(($mod = $this->etat("mod")) != "index") $this->_init_layout($mod);
150 return $this->get_layout();
153 function _init_layout($mod)
154 { if(($plugins = $this->plugins("ASC")) !== false)
155 { $layout_file = false;
156 $tmp_layout_file = $this->path("out").$this->config("out")."layouts/".$mod.".xml";
157 if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file;
159 { $tmp_layout_file = $this->path("out").$this->path("dist_out")."layouts/".$mod.".xml";
160 if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file;
162 if($layout_file) $this->load_layout($layout_file);
163 foreach($plugins as $plugin_name => $plugin)
164 { if($plugin["installed"] && $plugin["enabled"])
165 { $layout_file = false;
166 $tmp_layout_file = $this->path("plugins").$plugin_name."/out/".$this->config("out")."layouts/".$mod.".xml";
167 if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file;
169 { $tmp_layout_file = $this->path("plugins").$plugin_name."/out/".$this->path("dist_out")."layouts/".$mod.".xml";
170 if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file;
172 if($layout_file) $this->load_layout($layout_file);
178 function load_layout($layout_file)
179 { if(file_exists($layout_file))
180 { $xml_parser = new sxml();
181 $xml_parser->parse(file_get_contents($layout_file));
182 $layout = $xml_parser->data;
183 if(isset($layout["layout"][0]["subs"]))
184 { foreach($layout["layout"][0]["subs"] as $mod => $mod_node)
185 { if(!isset($this->layout[$mod]))
186 { $this->layout[$mod] = array
189 "controllers" => array()
192 if(isset($mod_node[0]["attrs"]["page"])) $this->layout[$mod]["page"] = $mod_node[0]["attrs"]["page"];
193 if(isset($mod_node[0]["attrs"]["content"])) $this->layout[$mod]["content"] = $mod_node[0]["attrs"]["content"];
194 if(isset($mod_node[0]["subs"]))
195 { foreach($mod_node[0]["subs"] as $controller => $controller_node)
196 { if(!isset($this->layout[$mod]["controllers"][$controller]))
197 { $this->layout[$mod]["controllers"][$controller] = array
203 if(isset($controller_node[0]["attrs"]["page"])) $this->layout[$mod]["controllers"][$controller]["page"] = $controller_node[0]["attrs"]["page"];
204 if(isset($controller_node[0]["attrs"]["content"])) $this->layout[$mod]["controllers"][$controller]["content"] = $controller_node[0]["attrs"]["content"];
205 if(isset($controller_node[0]["subs"]))
206 { foreach($controller_node[0]["subs"] as $action => $action_node)
207 { if(!isset($this->layout[$mod]["controllers"][$controller]["actions"][$action]))
208 { $this->layout[$mod]["controllers"][$controller]["actions"][$action] = array
213 if(isset($action_node[0]["attrs"]["page"])) $this->layout[$mod]["controllers"][$controller]["actions"][$action]["page"] = $action_node[0]["attrs"]["page"];
214 if(isset($action_node[0]["attrs"]["content"])) $this->layout[$mod]["controllers"][$controller]["actions"][$action]["content"] = $action_node[0]["attrs"]["content"];
225 function get_layout()
226 { $mod = $this->etat("mod");
227 $controller = $this->etat("controller");
228 $action = $this->etat("action");
230 if(isset($this->layout[$mod]["controllers"][$controller]["actions"][$action]["content"]))
231 { $content = $this->layout[$mod]["controllers"][$controller]["actions"][$action]["content"];
234 { if(isset($this->layout[$mod]["controllers"][$controller]["content"]))
235 { $content = $this->layout[$mod]["controllers"][$controller]["content"];
238 { if(isset($this->layout[$mod]["content"]))
239 { $content = $this->layout[$mod]["content"];
242 { if(isset($this->layout["index"]["content"]))
243 { $content = $this->layout["index"]["content"];
249 if(isset($this->layout[$mod]["controllers"][$controller]["actions"][$action]["page"]))
250 { $page = $this->layout[$mod]["controllers"][$controller]["actions"][$action]["page"];
253 { if(isset($this->layout[$mod]["controllers"][$controller]["page"]))
254 { $page = $this->layout[$mod]["controllers"][$controller]["page"];
257 { if(isset($this->layout[$mod]["page"]))
258 { $page = $this->layout[$mod]["page"];
261 { if(isset($this->layout["index"]["page"]))
262 { $content = $this->layout["index"]["page"];
269 "content" => $content