X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=mw%2Fenv%2Fmodules%2Fmw_env_out.php;fp=web%2Fapp%2Fenv%2Fmodules%2Fmw_env_out.php;h=12ab2ed848274e67ac7f90ea0f442274820911d0;hb=36ed114046cbe3d72a3589230e9f306a54fcc79d;hp=f4ae9d9f7da03b6e79bd40d8272bbd0f11607db4;hpb=281c96e95451269f2614684b8de5be25862c8374;p=mtweb diff --git a/web/app/env/modules/mw_env_out.php b/mw/env/modules/mw_env_out.php similarity index 68% rename from web/app/env/modules/mw_env_out.php rename to mw/env/modules/mw_env_out.php index f4ae9d9..12ab2ed 100644 --- a/web/app/env/modules/mw_env_out.php +++ b/mw/env/modules/mw_env_out.php @@ -6,8 +6,13 @@ var $out_config; var $layout; + // --------------------------------------------------------------------------------- + // out vars + // + function set_out($key, $value){ - $this->out[$key] = $value; return $value; + $this->out[$key] = $value; + return $value; } function get_out(){ @@ -15,14 +20,39 @@ } function out($key){ - return $this->out[$key]; + return isset($this->out[$key]) ? $this->out[$key] : null; } + // --------------------------------------------------------------------------------- + // templates + // + function out_pathes(){ $pathes = array(); - if($dh = opendir($this->path("out"))){ + if(($plugins = $this->plugins()) !== false){ + foreach($plugins as $plugin_name => $plugin){ + $out_dir = $this->path("mw_dir")."plugins/".$plugin_name."/out/"; + if( + $plugin["installed"] + && $plugin["enabled"] + && file_exists($out_dir) + && is_dir($out_dir) + ){ + if(($pathes = $this->_out_pathes($out_dir, $pathes)) === false) break; + } + } + if($pathes !== false){ + $pathes = $this->_out_pathes($this->path("mw_dir")."out/", $pathes); + } + } + else $pathes = false; + return $pathes; + } + + function _out_pathes($out_dir, $pathes = array()){ + if($dh = opendir($out_dir)){ while(($file = readdir($dh)) !== false){ - if(is_dir($this->path("out").$file) && substr($file, 0 ,1) != ".") $pathes[] = $file; + if(is_dir($out_dir.$file) && substr($file, 0 ,1) != ".") $pathes[] = $file; } closedir($dh); } @@ -30,6 +60,10 @@ return $pathes; } + // --------------------------------------------------------------------------------- + // out files + // + function out_file_exists($file, $PRIORITE = "DESC"){ $out_file = $this->_out_file($file, $PRIORITE); return $out_file ? true : false; @@ -37,19 +71,24 @@ function out_file($file, $PRIORITE = "DESC"){ $out_file = $this->_out_file($file, $PRIORITE); - return $out_file ? $out_file : $file; + return $out_file ? $this->path("mw_dir").$out_file : $file; + } + + function out_url($file, $PRIORITE = "DESC"){ + $out_file = $this->_out_file($file, $PRIORITE); + return $out_file ? $this->path("mw_path").$out_file : $file; } function _out_file($file, $PRIORITE = "DESC"){ $out_file = false; if($PRIORITE == "ASC"){ - $tmp_out_file = $this->path("out").$this->config("out").$file; - if($file && file_exists($tmp_out_file)){ + $tmp_out_file = "out/".$this->config("out")."/".$file; + if($file && file_exists($this->path("mw_dir").$tmp_out_file)){ $out_file = $tmp_out_file; } if(!$out_file){ - $tmp_out_file = $this->path("out").$this->path("dist_out").$file; - if($file && file_exists($tmp_out_file)){ + $tmp_out_file = "out/".$this->config("default_out")."/".$file; + if($file && file_exists($this->path("mw_dir").$tmp_out_file)){ $out_file = $tmp_out_file; } } @@ -57,27 +96,27 @@ if($out_file) return $out_file; if(($plugins = $this->plugins($PRIORITE)) !== false){ foreach($plugins as $plugin_name => $plugin){ - $tmp_out_file = $this->path("plugins").$plugin_name."/out/".$this->config("out").$file; - if($file && $plugin["installed"] && $plugin["enabled"] && file_exists($tmp_out_file)){ + $tmp_out_file = "plugins/".$plugin_name."/out/".$this->config("out")."/".$file; + if($file && $plugin["installed"] && $plugin["enabled"] && file_exists($this->path("mw_dir").$tmp_out_file)){ $out_file = $tmp_out_file; break; } if(!$out_file){ - $tmp_out_file = $this->path("plugins").$plugin_name."/out/".$this->path("dist_out").$file; - if($file && $plugin["installed"] && $plugin["enabled"] && file_exists($tmp_out_file)){ + $tmp_out_file = "plugins/".$plugin_name."/out/".$this->config("default_out")."/".$file; + if($file && $plugin["installed"] && $plugin["enabled"] && file_exists($this->path("mw_dir").$tmp_out_file)){ $out_file = $tmp_out_file; break; } } } if($PRIORITE == "DESC" && !$out_file){ - $tmp_out_file = $this->path("out").$this->config("out").$file; - if($file && file_exists($tmp_out_file)){ + $tmp_out_file = "out/".$this->config("out")."/".$file; + if($file && file_exists($this->path("mw_dir").$tmp_out_file)){ $out_file = $tmp_out_file; } if(!$out_file){ - $tmp_out_file = $this->path("out").$this->path("dist_out").$file; - if($file && file_exists($tmp_out_file)){ + $tmp_out_file = "out/".$this->config("default_out")."/".$file; + if($file && file_exists($this->path("mw_dir").$tmp_out_file)){ $out_file = $tmp_out_file; } } @@ -86,9 +125,9 @@ return $out_file; } - # --------------------------------------------------------------------------------- - # out config - # + // --------------------------------------------------------------------------------- + // out config + // function set_out_config($out_config){ $this->out_config = $out_config; @@ -107,9 +146,9 @@ return null; } - # --------------------------------------------------------------------------------- - # layouts - # + // --------------------------------------------------------------------------------- + // layouts + // function layout(){ return $this->layout; @@ -121,13 +160,13 @@ foreach($plugins as $plugin_name => $plugin){ if($plugin["installed"] && $plugin["enabled"]){ $FOUND = false; - $functions_file = $this->path("plugins").$plugin_name."/out/".$this->config("out")."functions.php"; + $functions_file = $this->path("mw_dir")."plugins/".$plugin_name."/out/".$this->config("out")."/functions.php"; if(file_exists($functions_file)){ $FOUND = true; require $functions_file; } if(!$FOUND){ - $functions_file = $this->path("plugins").$plugin_name."/out/".$this->path("dist_out")."functions.php"; + $functions_file = $this->path("mw_dir")."plugins/".$plugin_name."/out/".$this->config("default_out")."/functions.php"; if($plugin["installed"] && $plugin["enabled"] && file_exists($functions_file)){ require $functions_file; } @@ -135,13 +174,13 @@ } } $FOUND = false; - $functions_file = $this->path("out").$this->config("out")."functions.php"; + $functions_file = $this->path("mw_dir")."out/".$this->config("out")."/functions.php"; if(file_exists($functions_file)){ $FOUND = true; require $functions_file; } if(!$FOUND){ - $functions_file = $this->path("out").$this->path("dist_out")."functions.php"; + $functions_file = $this->path("mw_dir")."out/".$this->config("default_out")."/functions.php"; if(file_exists($functions_file)){ require $functions_file; } @@ -165,20 +204,20 @@ function _init_layout($mod){ if(($plugins = $this->plugins("ASC")) !== false){ $layout_file = false; - $tmp_layout_file = $this->path("out").$this->config("out")."layouts/".$mod.".xml"; + $tmp_layout_file = $this->path("mw_dir")."out/".$this->config("out")."/layouts/".$mod.".xml"; if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file; if(!$layout_file){ - $tmp_layout_file = $this->path("out").$this->path("dist_out")."layouts/".$mod.".xml"; + $tmp_layout_file = $this->path("mw_dir")."out/".$this->config("default_out")."/layouts/".$mod.".xml"; if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file; } if($layout_file) $this->load_layout($layout_file); foreach($plugins as $plugin_name => $plugin){ if($plugin["installed"] && $plugin["enabled"]){ $layout_file = false; - $tmp_layout_file = $this->path("plugins").$plugin_name."/out/".$this->config("out")."layouts/".$mod.".xml"; + $tmp_layout_file = $this->path("mw_dir")."plugins/".$plugin_name."/out/".$this->config("out")."/layouts/".$mod.".xml"; if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file; if(!$layout_file){ - $tmp_layout_file = $this->path("plugins").$plugin_name."/out/".$this->path("dist_out")."layouts/".$mod.".xml"; + $tmp_layout_file = $this->path("mw_dir")."plugins/".$plugin_name."/out/".$this->config("default_out")."/layouts/".$mod.".xml"; if(file_exists($tmp_layout_file)) $layout_file = $tmp_layout_file; } if($layout_file) $this->load_layout($layout_file);