Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 1:54 AM

in-portal

Index: trunk/kernel/include/parse.php
===================================================================
--- trunk/kernel/include/parse.php (revision 719)
+++ trunk/kernel/include/parse.php (revision 720)
@@ -1,977 +1,978 @@
<?php
class clsHtmlTag
{
var $rawtext;
var $parsed;
var $prefix;
var $name;
var $attributes;
var $inner_html;
function clsHtmlTag($text=NULL)
{
$this->SetRawText($text);
if(strlen($text))
$this->parse();
}
function Clear()
{
$this->parsed = FALSE;
$this->rawtext = NULL;
$this->prefix = "";
$this->name = "";
$this->attributes = NULL;
$this->inner_html = "";
}
function ValidTag()
{
return (strlen($this->prefix) && strlen($this->name));
}
function SetRawText($text)
{
$this->Clear();
if($text != NULL)
$text = trim($text);
$this->rawtext = $text;
}
function GetAttributeByName($attr)
{
if(is_array($this->attributes))
{
$attr = strtolower($attr);
if( array_key_exists($attr,$this->attributes))
{
return $this->attributes[$attr];
}
else
return FALSE;
}
else
return FALSE;
}
function SetAttributeByName($attr,$value)
{
if(!is_array($this->attributes))
$this->attributes = array();
$this->attributes[$attr] = $value;
}
function GetAttributeByIndex($index)
{
if(is_array($this->attributes))
{
if($index < count($this->attributes))
{
return $this->attributes[$index];
}
else
return FALSE;
}
else
return FALSE;
}
function ParseAttributes($attributes)
{
unset($output);
$attribute = "";
$attributes = str_replace("\\>",">",$attributes);
$attributes = str_replace("\\<","<",$attributes);
$attributes = str_replace("\\\\","\\",$attributes);
while(strpos($attributes,"=")>0)
{
$pos = strpos($attributes,"=");
$attribute = trim(substr($attributes,0,$pos));
$attributes = trim(substr($attributes,$pos+1));
$pos2 = strpos($attributes,"\"");
$pos3 = strpos($attributes,"'");
if(!($pos3===false) and !($pos2===false) and ($pos3<$pos2)) $pos2 = $pos3;
if(!($pos3===false) and ($pos2===false) and (($pos3<$pos) or ($pos==0))) $pos2 = $pos3;
if(!($pos2===false) and (($pos2<$pos) or ($pos==0)))
{
if (substr($attributes,0,1) == "\"")
{
$pos = strpos($attributes,"\"",1);
$val = substr($attributes,1,$pos-1);
}
elseif (substr($attributes,0,1) == "'")
{
$pos = strpos($attributes,"'",1);
$val = substr($attributes,1,$pos-1);
}
else
{
$pos1 = strpos($attributes,"=",1);
$val = substr($attributes,0,$pos1);
$pos1a = strrpos($val," ");
$pos = $pos1-(strlen($val)-$pos1a);
$val = substr($val,0,$pos1a);
}
while (strpos($attribute," ")>0)
{
$pos1 = strpos($attribute," ");
$attr1 = substr($attribute,0,$pos1);
$output[$attr1] = null;
$attribute = trim(substr($attribute,$pos1+1));
}
$output[strtolower($attribute)] = $val;
$attributes = trim(substr($attributes,$pos+1));
}
elseif ($pos>0)
{
if (strpos($attributes,"=")>0)
{
$pos = strpos($attributes,"=");
$val = substr($attributes,0,$pos);
}
else
{
$val = $attributes;
}
$pos2 = strrpos($val," ");
if($pos2>0)
{
$len = strlen($val);
$val = substr($val,0,$pos2);
$attributes = trim(substr($attributes,($pos-$len)+$pos2));
}
else
{
$len = strlen($val);
$attributes = trim(substr($attributes,$len));
}
while (strpos($attribute," ")>0)
{
$pos1 = strpos($attribute," ");
$attr1 = substr($attribute,0,$pos1);
$output[$attr1] = null;
$attribute = trim(substr($attribute,$pos1+1));
}
$output[strtolower($attribute)] = $val;
}
else
{
while (strpos($attribute," ")>0)
{
$pos1 = strpos($attribute," ");
$attr1 = substr($attribute,0,$pos1);
$output[$attr1] = null;
$attribute = trim(substr($attribute,$pos1+1));
}
$output[strtolower($attribute)] = $attributes;
}
}
if(strlen(trim($attributes))>0)
{
while (strpos($attribute," ")>0)
{
$pos1 = strpos($attribute," ");
$attr1 = substr($attribute,0,$pos1);
$output[$attr1] = null;
$attribute = trim(substr($attribute,$pos1+1));
}
$output[strtolower($attributes)] = null;
}
if (isset($output))
return($output);
}
function parse()
{
global $objSession;
$html = $this->rawtext;
$html = substr($html,1,strlen($html)-2);
if(substr($html,strlen($html)-1,1)=="/")
{
$html = substr($html,0,strlen($html)-1);
}
$tagparts = explode(" ",$html,2);
$tagname = $tagparts[0];
$attribs = array();
if(count($tagparts)>0)
$attribs = $this->ParseAttributes( isset($tagparts[1]) ? $tagparts[1] : '');
if(is_object($objSession) && is_array($attribs))
{
$referer = $objSession->GetVariable("Template_Referer");
foreach($attribs as $key=>$value)
{
if($value=="_referer_")
$attribs[$key] = $referer;
}
}
$name = explode(":",$tagname);
$this->prefix = strtolower($name[0]);
$this->name = strtolower($name[1]);
if(is_array($attribs))
{
foreach($attribs as $key=>$value)
{
if(!strlen($value))
{
$attribs[$key]=1;
}
}
$this->attributes = $attribs;
}
else
$this->attributes = array();
$this->parsed=TRUE;
}
function Execute()
{
$func = $this->name;
$override = "_".$func;
if( function_exists($override) )
{
$ret = @$override($this->attributes);
}
else
{
if(function_exists($func))
{
$ret = @$func($this->attributes);
}
else
{
//$ret = "{Unknown Tag:" .$this->name."}";
$ret = '';
}
}
return $ret;
}
}
class clsTemplate
{
var $source;
var $name;
var $out;
var $error;
function clsTemplate($template=NULL)
{
$this->name=$template;
$this->source=NULL;
$this->out = NULL;
$this->error = "";
}
function LoadByFileName($file,$SupressError=FALSE)
{
if(file_exists($file))
{
$fp = fopen ($file, "r");
if($fp)
{
$this->source = fread($fp, filesize ($file));
$this->source = trim($this->source);
fclose($fp);
return TRUE;
}
else
{
if(!$SupressError)
$this->error = "lu_read_error";
return FALSE;
}
}
else
{
if(!$SupressError)
$this->error = "lu_missing_error";
return FALSE;
}
}
function HasExtension()
{
$t = strtolower($this->name);
if(strlen($t))
{
return (substr($t,-4)==".tpl");
}
else
return false;
}
function TemplateFilename($template_root)
{
if(!$this->HasExtension())
{
$filename = $template_root.$this->name.".tpl";
}
else
$filename = $template_root.$this->name;
return $filename;
}
function LoadFile($template_root="",$SupressError=FALSE)
{
$filename = $this->TemplateFilename($template_root);
if(file_exists($filename))
{
//echo "Loading $filename from Filesystem<br>\n";
$fp = @fopen ($filename, "r");
if($fp)
{
$this->source = fread($fp, filesize ($filename));
$this->source = trim($this->source);
fclose($fp);
return TRUE;
}
else
{
if(!$SupressError)
$this->error = "lu_read_error";
return FALSE;
}
}
else
{
if(!$SupressError)
$this->error = "lu_missing_error";
return FALSE;
}
}
function WriteFile($template_root="")
{
$filename = $this->TemplateFilename($template_root);
$pos = strrpos($this->name,"/");
if(!is_dir(substr($template_root,0,-1)))
@mkdir(substr($tempalate_root0,-1));
if($pos>0)
$path=$template_root.substr($this->name,0,$pos);
if(!is_dir($path))
{
@mkdir($path);
}
if(strlen($this->out))
{
$fp = @fopen($filename, "w");
if($fp)
{
fwrite($fp,$this->out);
fclose($fp);
return TRUE;
}
else
return FALSE;
}
else
return TRUE;
}
}
class clsTemplateList
{
var $templates;
var $root_dir;
var $ErrorStr;
var $ErrorNo;
var $stack;
var $SkipIncludes = 0;
function clsTemplateList($root_dir)
{
$this->templates = array();
$this->root_dir = $root_dir;
$this->ErrorStr = "";
$this->ErrorNo = 0;
$this->SkipIncludes = 0;
$this->stack = array();
}
function InStack($template)
{
if(in_array($template,$this->stack))
{
return TRUE;
}
else
return FALSE;
}
function GetTemplate($name,$SupressError=FALSE)
{
if(!strlen($name))
{
$ret = FALSE;
if(!$SupressError)
{
$this->ErrorNo = -2;
$this->ErrorStr=language("lu_template_error").":".language("lu_no_template_error");
}
}
else
{
$ret = FALSE;
foreach($this->templates as $n => $t)
{
if($n == $name)
{
$ret=$t;
break;
}
}
if(!is_object($ret))
{
$ret = new clsTemplate($name);
if($ret->LoadFile($this->root_dir,$SupressError))
{
$this->templates[$name]=$ret;
}
else
{
if( IsDebugMode() )
{
echo '<span style="color: red;">Template <b>'.$name.'</b> not found</span><br />';
}
if(!$SupressError)
{
$this->ErrorNo = -1;
$this->ErrorStr = language("lu_template_error").":".language($ret->error).":"."'$name'";
LogEntry($this->ErrorStr);
}
}
}
}
return $ret;
}
function GetTemplateCache($template,$SupressError=FALSE)
{
global $CurrentTheme, $pathtoroot;
$ret = '';
if( $CurrentTheme->Get("CacheTimeout") > 0)
{
$id = $CurrentTheme->GetTemplateId($template);
if($id)
{
$exp = isset($CurrentTheme->ParseCacheDate[$id]) ? $CurrentTheme->ParseCacheDate[$id] : false;
if($exp)
{
//echo "$template Cache expires: ".date("m-d-Y h:m s",$exp)."<br>\n";
if( $exp > time() )
{
/* look for a cache file */
$t = new clsTemplate($template);
$dir = $CurrentTheme->ThemeDirectory();
if( $t->LoadFile($dir."/_cache/",$SupressError) ) $ret = $t->source;
}
}
}
}
return $ret;
}
function SaveTemplateCache($objTemplate)
{
global $CurrentTheme, $objThemes, $pathtoroot;
if(!is_object($CurrentTheme))
$CurrentTheme = $objThemes->GetItem($m_var_list["theme"]);
if($CurrentTheme->Get("CacheTimeout")>0)
{
$TemplateId = $CurrentTheme->GetTemplateId($objTemplate->name);
if($TemplateId)
{
if(isset($CurrentTheme->ParseCacheDate[$TemplateId]))
{
//echo "Writing Template ".$objTemplate->name."<br>\n";
$interval = $CurrentTheme->ParseCacheTimeout[$TemplateId];
$CurrentTheme->UpdateFileCacheData($TemplateId,time()+$interval);
$dir = $CurrentTheme->ThemeDirectory()."/_cache/";
$objTemplate->WriteFile($dir);
}
}
}
}
function IncludeTemplate($tag, $SupressError=FALSE)
{
global $LogLevel, $objSession,$objLanguages;
$t = '';
$ret = '';
$SupressError = ($SupressError || $tag->GetAttributeByName("_supresserror"));
switch($tag->name)
{
case 'perm_include':
$perms = $tag->GetAttributeByName('_permission');
if(strlen($perms))
{
$plist = explode(',',$perms);
$value=0;
$CheckSys = $tag->GetAttributeByName('_system');
for($p=0;$p<count($plist);$p++)
{
if($objSession->HasCatPermission(trim($plist[$p])))
{
$value = 1;
break;
}
else
{
if($CheckSys)
{
if($objSession->HasSystemPermission(trim($plist[$p])))
{
$value = 1;
break;
}
}
}
}
$t = $tag->GetAttributeByName( $value ? '_template' : '_noaccess');
}
else
{
$module = $tag->GetAttributeByName('_module');
if(strlen($module))
{
$t = $tag->GetAttributeByName( ModuleEnabled($module) ? '_template' : '_noaccess' );
}
}
break;
case "lang_include":
$lang = $tag->GetAttributeByName("_language");
if(strlen($lang))
{
$LangId = $objSession->Get("Language");
$l = $objLanguages->GetItem($LangId);
if(strtolower($lang)==strtolower($l->Get("PackName")))
{
$t = $tag->GetAttributeByName("_template");
}
}
break;
case 'include':
$t = $tag->GetAttributeByName("_template");
break;
}
LogEntry("Parsing $t\n");
$LogLevel++;
if($t)
{
if(!$this->InStack($t))
{
//return $this->ParseTemplate($t);
//if(!$tag->GetAttributeByName("_nocache"));
$ret = $this->GetTemplateCache($t,$SupressError);
if(!strlen($ret))
{
$req = $tag->GetAttributeByName("_dataexists");
if($req)
{
global $content_set;
$content_set=1;
$temp = $this->ParseTemplate($t,0,0,$SupressError);
if($content_set)
{
$ret = $temp;
}
else
{
$t_nodata = $tag->GetAttributeByName("_nodatatemplate");
if(strlen($t_nodata))
{
$nodata_tag = new clsHtmlTag();
$nodata = $tag;
$nodata->attributes = $tag->attributes;
$nodata->SetAttributeByName("_template",$t_nodata);
$nodata->SetAttributeByName("_nodatatemplate","");
$nodata->SetAttributeByName("_dataexists","");
$ret = $this->IncludeTemplate($nodata,$SupressError);
}
else
$ret = "";
}
}
else
$ret = $this->ParseTemplate($t,0,0,$SupressError);
}
}
else
$ret = "";
}
$LogLevel--;
if($LogLevel<0)
$LogLevel=0;
LogEntry("Finished Parsing $t\n");
return $ret;
}
/* <inp:mod_include _Template=".." [_perm=".."] [_modules=".."] [_system=".."] */
function ModuleInclude($tag)
{
global $var_list;
$o = "";
$el = new clsHtmlTag();
$el->attributes = $tag->attributes;
$el->parsed=1;
$t = $tag->attributes["_template"];
if(!strlen($t))
$t = $var_list["t"];
$el->name = "perm_include";
$tpath = GetModuleArray("template");
if(!strlen( $tag->GetAttributeByName('_modules') ))
{
$mods = array_keys($tpath);
}
else
$mods = explode(",",$tag->attributes["_modules"]);
foreach($mods as $m)
{
if($t==$var_list["t"] && !strlen($tpath[$m]))
continue;
$el->attributes = $tag->attributes;
$el->attributes["_template"] = $tpath[$m].$t;
$el->attributes["_module"] = $m;
if(strlen( $tag->GetAttributeByName('_nodatatemplate') ))
{
$el->attributes["_nodatatemplate"] = $tpath[$m].$tag->attributes["_nodatatemplate"];
}
//print_pre($el);
$o .= $this->IncludeTemplate($el,true);
}
if(!strlen($o) && strlen($tag->attributes["_nodatamaintemplate"]))
$o = $this->ParseTemplate($tag->attributes["_nodatamaintemplate"]);
return $o;
}
function ParseTag($raw)
{
$tag = new clsHtmlTag($raw);
$res = "";
switch($tag->name)
{
case "lang_include":
case "include":
case "perm_include":
$res = $this->IncludeTemplate($tag);
break;
case "mod_include":
$res = $this->ModuleInclude($tag);
break;
default:
//print_pre($tag);
$res = $tag->Execute();
break;
}
unset($tag);
return $res;
}
function ParseTemplateText($text)
{
$html = $text;
$search = "<inp:";
$next_tag = strpos($html,$search);
$left = substr($html,0,5);
while($next_tag || $left=="<inp:")
{
$left = "";
$closer = strpos(strtolower($html),">",$next_tag);
$tmp = substr($html,$next_tag,$closer+1 - $next_tag);
while(substr($html,$closer-1,1)=="\\" && $closer < strlen($html))
{
$closer = strpos(strtolower($html),">",$closer+1);
}
$end_tag = strpos($html,"/>",$next_tag);
if(($end_tag < $closer || $closer == 0))
{
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2);
$pre = substr($html,0,$next_tag);
$post = substr($html,$end_tag+2);
$inner = $this->ParseTag($tagtext);
$html = $pre.$inner.$post;
}
else
{
$OldTagStyle = "</inp>";
## Try to find end of TagName
$TagNameEnd = strpos($html, " ", $next_tag);
## Support Old version
// $closer = strpos(strtolower($html),"</inp>",$next_tag);
if ($TagNameEnd)
{
$Tag = strtolower(substr($html, $next_tag, $TagNameEnd-$next_tag));
$TagName = explode(":", $Tag);
if (strlen($TagName[1]))
$CloserTag = "</inp:".$TagName[1].">";
}
else
{
$CloserTag = $OldTagStyle;
}
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
## Try to find old tag closer
if (!$closer && ($CloserTag != $OldTagStyle))
{
$CloserTag = $OldTagStyle;
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
}
$end_tag = strpos($html,">",$next_tag);
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+1);
$pre = substr($html,0,$next_tag);
$inner = substr($html,$end_tag+1,$closer-($end_tag+1));
$post = substr($html,$end_tag+1+strlen($inner) + strlen($CloserTag));
$parsed = trim($this->ParseTag($tagtext));
if(strlen($parsed))
{
$html = $pre.$this->ParseTemplateText($inner).$post;
}
else
$html = $pre.$post;
}
//$next_tag = strpos($html,"<inp:");
$next_tag = 0;
$next_tag = strpos($html,$search);
}
return $html;
}
function ParseTemplate($tname, $NoCache=0, $NoStack=0,$SupressError=FALSE)
{
$html = "";
+ if( defined('TEMPLATE_PREFIX') ) $tname = TEMPLATE_PREFIX.'/'.$tname;
$t = $this->GetTemplate($tname,$SupressError);
if(is_object($t))
{
if(!$NoStack)
array_push($this->stack,$tname);
$html = $t->source;
$html = $this->ParseTemplateText($html);
if(!$NoStack)
array_pop($this->stack);
$t->out = $html;
if(!$NoCache)
$this->SaveTemplateCache($t);
}
unset($t);
return $html;
}
}
class clsAdminTemplateList extends clsTemplateList
{
function clsAdminTemplateList()
{
global $TemplateRoot;
$this->clsTemplateList($TemplateRoot);
}
function GetTemplate($file)
{
$ret = FALSE;
$ret = new clsTemplate();
if(!$ret->LoadByFileName($file))
{
$this->ErrorNo = -1;
$this->ErrorStr = "Error Loading Template '$file'";
}
return $ret;
}
}
class clsTemplateChecker extends clsTemplateList
{
var $Dependencies;
var $TemplateType;
var $Tags;
function clsTemplateChecker($rootdir)
{
$this->clsTemplateList($rootdir);
$this->Dependencies = Array();
$this->Tags = array();
$this->TemplateType="global"; //default
}
function ParseTag($text)
{
$this->Tags[] = new clsHtmlTag($text);
return "";
}
function ParseTemplateText($text)
{
$html = $text;
$search = "<inp:";
$next_tag = strpos($html,$search);
$left = substr($html,0,5);
while($next_tag || $left=="<inp:")
{
$left = "";
$closer = strpos(strtolower($html),">",$next_tag);
$end_tag = strpos($html,"/>",$next_tag);
if($end_tag < $closer || $closer == 0)
{
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2);
$pre = substr($html,0,$next_tag);
$post = substr($html,$end_tag+2);
$inner = $this->ParseTag($tagtext);
$html = $pre.$inner.$post;
}
else
{
$closer = strpos(strtolower($html),"</inp>",$next_tag);
$end_tag = strpos($html,">",$next_tag);
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+1);
$pre = substr($html,0,$next_tag);
$inner = substr($html,$end_tag+1,$closer-($end_tag+1));
$post = substr($html,$end_tag+1+strlen($inner)+6);
$parsed = $this->ParseTag($tagtext);
if(strlen($parsed))
{
$html = $pre.$inner.$post;
}
else
$html = $pre.$post;
}
//$next_tag = strpos($html,"<inp:");
$next_tag = 0;
$next_tag = strpos($html,$search);
}
return $html;
}
function ParseTemplate($tname, $NoCache=0, $NoStack=0,$SupressError=FALSE)
{
$html = "";
$t = $this->GetTemplate($tname,$SupressError);
if(is_object($t))
{
$html = $this->ParseTemplateText($t->source);
$t->out = $html;
}
unset($t);
return $html;
}
function ReadTemplateTags($tname)
{
$this->Tags[]=Array();
$this->ParseTemplate($tname,1,1,TRUE);
return $this->Tags;
}
function GetTemplateType($tname)
{
global $ItemTypePrefixes;
$ret = "global";
$this->ReadTemplateTags($tname);
if(count($this->Tags)>0)
{
foreach($this->Tags as $t)
{
if(in_array($t->name,$ItemTypePrefixes))
{
$ret = $t->name;
break;
}
}
}
return $ret;
}
function IncludeTemplate($tag, $SupressError=FALSE)
{
$this->AddDependency($tag->GetAttributeByName("_template"));
$this->AddDependency($tag->GetAttributeByName("_noaccess"));
}
function ModuleInclude($tag)
{
}
function AddDependency($template)
{
$template = strtolower($template);
if(!in_array($template,$this->Dependencies))
$this->Dependencies[] = $template;
}
}
function admintemplate($fileh)
{
if(file_exists($fileh))
{ $fd = fopen($fileh, "r");
$ret=fread($fd, filesize($fileh));
fclose($fd);
return $ret;
}
else
echo "Unable to load $fileh";
}
function ExtraAttributes($attribs)
{
$html_attr = "";
if(is_array($attribs))
{
foreach($attribs as $name=>$value)
{
if(substr($name,0,1)!="_")
$html_attr .= $name."=\"$value\" ";
}
}
return $html_attr;
}
?>
Property changes on: trunk/kernel/include/parse.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.8
\ No newline at end of property
+1.9
\ No newline at end of property
Index: trunk/admin/include/mainscript.php
===================================================================
--- trunk/admin/include/mainscript.php (revision 719)
+++ trunk/admin/include/mainscript.php (revision 720)
@@ -1,541 +1,541 @@
<?php
global $imagesURL,$objConfig,$adminURL,$rootURL, $en;
$group_select = $adminURL."/users/group_select.php";
$item_select = $adminURL."/relation_select.php";
$user_select = $adminURL."/users/user_select.php";
$cat_select = $adminURL."/cat_select.php";
$missing_edit = $adminURL."/config/missing_label_search.php";
$lang_Filter = language("la_Text_Filter");
$lang_View = language("la_Text_View");
$lang_Sort = language("la_Text_Sort");
$lang_Select = language("la_Text_Select");
$lang_Unselect = language("la_Text_Unselect");
$lang_Invert = language("la_Text_Invert");
$lang_PerPage = language("la_prompt_PerPage");
$lang_All = language("la_Text_All");
$lang_Asc = language("la_common_ascending");
$lang_Desc = language("la_common_descending");
$lang_Disabled = language("la_Text_Disabled");
$lang_Enabled = language("la_Text_Enabled");
$lang_Pending = language("la_Text_Pending");
$lang_Default = language("la_Text_Default");
$lang_CreatedOn = language("la_prompt_CreatedOn");
$lang_None = language("la_Text_None");
$lang_PerPage = language("la_prompt_PerPage");
$lang_Views = language("la_Text_Views");
$lang_URL = language("la_ColHeader_Url");
$lang_Status = language("la_prompt_Status");
$lang_Name = language("la_prompt_Name");
$lang_MoveDn = language("la_prompt_MoveDown");
$lang_MoveUp = language("la_prompt_MoveUp");
$lang_Delete = language("la_prompt_Delete");
$lang_Edit = language("la_prompt_Edit");
$errormsg = language("la_validation_AlertMsg");
$env2 = BuildEnv();
if(is_numeric($en))
{
$env2 = BuildEnv() . "&en=$en";
}
$editor_url = $adminURL."/editor/editor.php?env=$env2";
$email_url = $adminURL."/email/sendmail.php?env=$env2";
$phrase_edit = $adminURL."/config/edit_label.php?env=".$env2;
$submit_done = isset($_REQUEST['submit_done']) ? 1 : 0; // returns form submit status
$Cal = GetDateFormat();
if(strpos($Cal,"y"))
{
$Cal = str_replace("y","yy",$Cal);
}
else
$Cal = str_replace("Y","y",$Cal);
$Cal = str_replace("m","mm",$Cal);
$Cal = str_replace("n","m",$Cal);
$Cal = str_replace("d","dd",$Cal);
$format = GetStdFormat(GetDateFormat());
$yearpos = (int)DateFieldOrder($format,"year");
$monthpos = (int)DateFieldOrder($format,"month");
$daypos = (int)DateFieldOrder($format,"day");
$ampm = "false";
if($objConfig->Get("ampm_time")=="1")
{
$ampm = "true";
}
require_once($pathtoroot.$admin."/lv/js/js_lang.php");
print <<<END
<script type="text/javascript" src="$adminURL/lv/js/in-portal.js"></script>
<script language="Javascript">
var CurrentTab= new String();
var lang_Filter = "$lang_Filter";
var lang_Sort = "$lang_Sort";
var lang_Select = "$lang_Select";
var lang_Unselect = "$lang_Unselect";
var lang_Invert = "$lang_Invert";
var lang_PerPage = "$lang_PerPage";
var lang_All = "$lang_All";
var lang_Asc = "$lang_Asc";
var lang_Desc = "$lang_Desc";
var lang_Disabled = "$lang_Disabled";
var lang_Pending = "$lang_Pending";
var lang_Default = "$lang_Default";
var lang_CreatedOn = "$lang_CreatedOn";
var lang_View = "$lang_View";
var lang_Views = "$lang_Views";
var lang_None = "$lang_None";
var lang_PerPage = "$lang_PerPage";
var lang_Enabled = "$lang_Enabled";
var lang_URL = "$lang_URL";
var lang_Status = "$lang_Status";
var lang_Name = "$lang_Name";
var lang_Edit = "$lang_Edit";
var lang_Delete = "$lang_Delete";
var lang_MoveUp = "$lang_MoveUp";
var lang_MoveDn = "$lang_MoveDn";
var ampm = $ampm;
var listview_clear=1;
var CalDateFormat = "$Cal";
var yearpos = $yearpos;
var monthpos = $monthpos;
var daypos = $daypos;
var ErrorMsg = '$errormsg';
//en = $en
var rootURL = '$rootURL';
function clear_list_checkboxes()
{
var inputs = document.getElementsByTagName("INPUT");
for (var i = 0; i < inputs.length; i++)
if (inputs[i].type == "checkbox" && inputs[i].getAttribute("isSelector"))
{
inputs[i].checked=false;
}
}
function getRealLeft(el) {
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
function getRealTop(el) {
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function SetButtonStateByImage(btn_id, img_src)
{
// set state depending on image name
var btn = document.getElementById(btn_id);
if(btn)
{
if( !HasParam(img_src) ) img_src = btn.getAttribute('src');
var img_name = img_src.split('/');
img_name = img_name.length ? img_name[img_name.length - 1] : img_name;
img_name = img_name.split('.');
img_name = img_name[0].split('_');
img_name = img_name.length ? img_name[img_name.length - 1] : img_name;
if(img_name)
{
switch(img_name)
{
case 'f2': btn.setAttribute('ButtonState','over'); break;
case 'f3': btn.setAttribute('ButtonState','disabled'); break;
default: btn.setAttribute('ButtonState','enabled'); break;
}
}
}
}
function swap(imgid, src, module_name){
// swaps toobar icons from kernel
// admin or from module specified
var ob = document.getElementById(imgid);
if(ob)
{
- SetButtonStateByImage(imgid, src);
- var s = src;
- s = s.slice(0,4);
- if(s=='http')
- {
- ob.src = src;
- }
- else
- {
- if(module_name == null)
- ob.src = '$adminURL' + '/images/' + src;
- else
- {
- ob.src = '$rootURL' + module_name + '/$admin/images/' + src;
- }
- }
- }
+ SetButtonStateByImage(imgid, src);
+ var s = src;
+ s = s.slice(0,4);
+ if(s=='http')
+ {
+ ob.src = src;
+ }
+ else
+ {
+ if(module_name == null)
+ ob.src = '$adminURL' + '/images/' + src;
+ else
+ {
+ ob.src = '$rootURL' + module_name + '/$admin/images/' + src;
+ }
+ }
+ }
}
function flip(val)
{
if (val == 0)
return 1;
else
return 0;
}
function config_val(field, val2,url){
//alert('Setting ' + field + ' to ' + val2);
if(url)
document.viewmenu.action=url;
document.viewmenu.Action.value = "m_SetVariable";
document.viewmenu.fieldname.value = field;
document.viewmenu.varvalue.value = val2;
document.viewmenu.submit();
}
function session_val(field, val2){
//alert('Setting ' + field + ' to ' + val2);
document.viewmenu.Action.value = "m_SetSessionVariable";
document.viewmenu.fieldname.value = field;
document.viewmenu.varvalue.value = val2;
document.viewmenu.submit();
}
function Submit_ListSearch(action)
{
f = document.getElementById('ListSearchForm');
s = document.getElementById('ListSearchWord');
if(f)
{
f.Action.value = action;
f.list_search.value = s.value;
f.submit();
}
}
function ValidTime(time_str)
{
var valid = true;
if( trim(time_str) == '' ) return true; // is valid in case if not entered
time_str = time_str.toUpperCase();
parts = time_str.split(/\s*[: ]\s*/);
hour = parseInt(parts[0]);
minute = parseInt(parts[1]);
sec = parseInt(parts[2]);
if(ampm == true)
{
amstr = parts[3];
var am_valid = (amstr == 'AM' || amstr == 'PM');
if(am_valid && hour > 12) valid = false;
if(amstr == 'PM' && hour <= 12) hour = hour + 12;
if(hour == 24) hour = 0;
if(!am_valid) valid = false;
}
valid = valid && (hour > -1 && hour < 24);
valid = valid && (minute > -1 && minute < 60);
valid = valid && (sec > -1 && sec < 60);
return valid;
}
function DaysInMonth(month,year)
{
timeA = new Date(year, month,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);
return timeB.getDate();
}
function ValidDate(date_str)
{
var valid = true;
if( trim(date_str) == '' ) return true; // is valid in case if not entered
parts = date_str.split(/\s*\D\s*/);
year = parts[yearpos-1];
month = parts[monthpos-1];
day = parts[daypos-1];
valid = (year>0);
valid = valid && ((month>0) && (month<13));
valid = valid && (day<DaysInMonth(month,year)+1);
return valid;
}
function trim(str)
{
return str.replace(/(^\s*)|(\s*$)/g,'');
}
function ValidateNumber(aValue, aNumberType)
{
var valid = true;
if( trim(aValue) == '' ) return true;
return (parseInt(aValue) == aValue);
}
function OpenEditor(extra_env,TargetForm,TargetField)
{
var url = '$editor_url';
url = url+'&TargetForm='+TargetForm+'&TargetField='+TargetField+'&destform=popup';
if(extra_env.length>0)
url = url+extra_env;
window.open(url,"html_edit","width=800,height=575,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function BitStatus(Value,bit)
{
var val = Math.pow(2,bit);
if((Value & val))
{
return 1;
}
else
return 0;
}
function FlipBit(ValueName,Value,bit)
{
var val = Math.pow(2,bit);
//alert("Setting bit "+bit);
if(BitStatus(Value,bit))
{
Value = Value - val;
}
else
Value = Value + val;
session_val(ValueName,Value);
}
function PerPageSelected(Value,PageCount)
{
if(Value==PageCount)
{
return 2;
}
else
return 0;
}
function RadioIsSelected(Value1,Value2)
{
if(Value1 == Value2)
{
return 2;
}
else
return 0;
}
function OpenItemSelector(envstr)
{
//alert(envstr);
window.open('$item_select?'+envstr,"groupselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function OpenUserSelector(CheckIdField,Checks,envstr)
{
if(Checks) var retval = Checks.getItemList();
f = document.getElementById('userpopup');
if(f)
{
if(CheckIdField)
f.elements[CheckIdField].value = retval;
}
SessionPrepare('$user_select', envstr, 'userselect');
}
function SessionPrepare(url, get_str, window_name)
{
var params = ExtractParams(get_str);
if(params['destform'])
{
if(params['destform'] == 'popup')
{
CreatePopup(window_name, url + '?' + get_str);
return true;
}
else
var frm = CreateFakeForm();
}
else
var frm = CreateFakeForm();
if(!frm) return false;
frm.destform.value = params['destform'];
params['destform'] = 'popup';
get_str = MergeParams(params);
CreatePopup(window_name);
frm.target = window_name;
frm.method = 'POST';
frm.action = url + '?' + get_str;
frm.submit();
}
function addField(form, type, name, value)
{
// create field in form
var field = document.createElement("INPUT");
field.type = type;
field.name = name;
field.id = name;
field.value = value;
form.insertBefore(field, form.nextSibling);
}
function CreateFakeForm()
{
if($submit_done == 0)
{
var theBody = document.getElementsByTagName("BODY");
if(theBody.length == 1)
{
var frm = document.createElement("FORM");
frm.name = "fake_form";
frm.id = "fake_form";
frm.method = "post";
theBody[0].insertBefore(frm, theBody[0].nextSibling);
addField(frm, 'hidden', 'submit_done', 1);
addField(frm, 'hidden', 'destform', '');
return document.getElementById('fake_form');
}
}
return false;
}
function CreatePopup(window_name, url, width, height)
{
// creates a popup window & returns it
if(url == null && typeof(url) == 'undefined' ) url = '';
if(width == null && typeof(width) == 'undefined' ) width = 750;
if(height == null && typeof(height) == 'undefined' ) height = 400;
return window.open(url,window_name,'width='+width+',height='+height+',status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no');
}
function ShowHelp(section)
{
var frm = document.getElementById('help_form');
frm.section.value = section;
frm.method = 'POST';
CreatePopup('HelpPopup','$rootURL$admin/help/blank.html'); // , null, 600
frm.target = 'HelpPopup';
frm.submit();
}
function ExtractParams(get_str)
{
// extract params into associative array
var params = get_str.split('&');
var result = Array();
var temp_var;
var i = 0;
var params_count = params.length;
while(i < params_count)
{
temp_var = params[i].split('=');
result[temp_var[0]] = temp_var[1];
i++;
}
return result;
}
function MergeParams(params)
{
// join splitted params into GET string
var key;
var result = '';
for(key in params)
result += key + '=' + params[key] + '&';
if(result.length) result = result.substring(0, result.length - 1);
return result;
}
function show_props(obj, objName)
{
var result = "";
for (var i in obj) {
result += objName + "." + i + " = " + obj[i] + "\\n";
}
return result;
}
function OpenGroupSelector(envstr)
{
//alert(envstr);
SessionPrepare('$group_select', envstr, 'groupselect');
//window.open('$group_select?'+envstr,"groupselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function OpenCatSelector(envstr)
{
//alert(envstr);
window.open('$cat_select?'+envstr,"catselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function openEmailPopup(envar,form,Checks)
{
var email_url='$email_url';
var url = email_url+envar;
if(Checks.itemChecked())
{
f = document.getElementById(form);
if(f)
{
window.open('',"sendmail","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
f.idlist.value = Checks.getItemList();
f.submit();
}
}
}
function OpenPhraseEditor(extra_env)
{
//SessionPrepare('$phrase_edit', extra_env, 'phrase_edit');
var url = '$phrase_edit'+extra_env+'&destform=popup';
window.open(url,"phrase_edit","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
var env = '$env2';
var SubmitFunc = false;
</script>
END;
?>
Property changes on: trunk/admin/include/mainscript.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6
\ No newline at end of property
+1.7
\ No newline at end of property
Index: trunk/index.php
===================================================================
--- trunk/index.php (revision 719)
+++ trunk/index.php (revision 720)
@@ -1,128 +1,126 @@
<?php
if( file_exists('debug.php') ) include_once('debug.php');
if( defined('DEBUG_MODE') )
{
ini_set('error_prepend_string','<span class="debug_text">');
ini_set('error_append_string','</span>');
}
else
error_reporting(0);
list($usec, $sec) = explode(" ",microtime());
$timestart = (float)$usec + (float)$sec;
$pathtoroot = "./";
$pathtoroot = realpath($pathtoroot)."/";
if (!file_exists($pathtoroot."config.php")) {
echo "In-Portal is probably not installed, or configuration file is missing.<br>";
echo "Please use the installation script to fix the problem.<br><br>";
echo "<a href='admin/install.php'>Go to installation script</a><br><br>";
flush();
die();
}
//ob_start();
$FrontEnd=1;
$indexURL="../../index.php"; //Set to relative URL from the theme directory
/* initalize the in-portal system */
include_once("kernel/startup.php");
LogEntry("System Init Complete\n");
/* load the current front-end language set */
//$objLanguageCache->LoadLanguage($objSession->Get("Language"),0);
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
//$secureURL = "https://".ThisDomain().$objConfig->Get("Site_Path");
$secureURL = $rootURL;
$html="<HTML>No Template</HTML>";
if( !$var_list['t'] ) $var_list['t'] = 'index';
if( !isset($CurrentTheme) ) $CurrentTheme = null;
if( !is_object($CurrentTheme) ) $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]);
if(is_object($CurrentTheme))
{
if(!$CurrentTheme->Get("Enabled"))
{
$CurrentTheme = $objThemes->GetItem($objThemes->GetPrimaryTheme());
}
if((int)$CurrentTheme->Get("ThemeId")>0)
{
$timeout = $CurrentTheme->Get("CacheTimeout");
$objLanguageCache->LoadTemplateCache($var_list["t"],$timeout,$CurrentTheme->Get("ThemeId"));
$objLanguageCache->LoadCachedVars($objSession->Get("Language"));
LogEntry("Language Set Loaded\n");
$TemplateRoot = $CurrentTheme->ThemeDirectory()."/";
-// echo "Template Root: $TemplateRoot<br>\n";
LogEntry("Parsing Templates in $TemplateRoot\n");
$objTemplate = new clsTemplateList($TemplateRoot);
$html = $objTemplate->ParseTemplate($var_list["t"]);
}
else
{
echo "No Primary Theme Selected";
die();
}
}
else
{
echo "No Primary Theme Selected\n";
die();
}
if(is_object($objSession))
{
$objSession->SetVariable("Template_Referer", $_local_t);
}
if($objTemplate->ErrorNo == -1)
{
- $html = $objTemplate->ParseTemplate("error_template");
-
+ $html = $objTemplate->ParseTemplate('error_template');
}
//$html = replacePngTags($html);
LogEntry("Output Start\n");
$html .= "<!-- Page Execution Time: ".( isset($ptime) ? $ptime : 0 )." -->";
if(!IsDebugMode()) header("Content-length: ".strlen($html));
header("Connection-Type: Keep-Alive");
echo $html;
LogEntry("Output End\n");
if( isset($template) && $template->ErrorNo != 0 )
{
print "\n(".$objTemplate->ErrorNo.") ".$objTemplate->ErrorStr."\n";
}
LogEntry("Output Complete\n");
$objLanguageCache->SaveTemplateCache();
LogEntry("Templates Cached\n");
//if($objSession->SessionEnabled())
// $objSession->SaveSessionData();
//echo "Cookie: <PRE>"; print_r($_COOKIE); echo "</PRE><br>\n";
//ob_end_flush();
$timeend = getmicrotime();
$diff = $timeend - $timestart;
LogEntry("\nTotal Queries Executed: $sqlcount in $totalsql seconds\n");
LogEntry("\nPage Execution Time: $diff seconds\n", true);
if($LogFile)
fclose($LogFile);
?>
Property changes on: trunk/index.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6
\ No newline at end of property
+1.7
\ No newline at end of property

Event Timeline