Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F773058
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 2, 12:46 AM
Size
40 KB
Mime Type
text/x-diff
Expires
Tue, Feb 4, 12:46 AM (1 d, 14 h)
Engine
blob
Format
Raw Data
Handle
556323
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/include/tag-class.php
===================================================================
--- trunk/kernel/include/tag-class.php (revision 385)
+++ trunk/kernel/include/tag-class.php (revision 386)
@@ -1,443 +1,444 @@
<?php
class clsAttribute extends clsItemDB
{
/* var $name;
var $default;
var $description;
var $required;
*/
function clsAttribute($id = NULL)
{
$this->clsItemDB();
$this->tablename = GetTablePrefix()."TagAttributes";
$this->id_field = "AttrId";
$this->type=-99;
$this->NoResourceId=1;
}
function LoadFromDatabase($Id)
{
global $objSession,$Errors;
if(!isset($Id))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->id_field." = '%s'",$Id);
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
if(is_array($data))
$this->SetFromArray($data);
$this->Clean();
return TRUE;
}
function Write($value)
{
$ret = $name."=\"$value\"";
return $ret;
}
}
class clsTagAttribs extends clsItemCollection
{
function clsTagAttribs($TagId=NULL)
{
$this->clsItemCollection();
$this->SourceTable = GetTablePrefix()."TagAttributes";
$this->classname = "clsAttribute";
if($TagId)
$this->LoadTag($TagId);
}
function LoadTag($TagId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE TagId=$TagId";
$this->Query_Item($sql);
}
}
class clsTagFunction extends clsItemDB
{
var $attribs;
function clsTagFunction()
{
$this->clsItemDB();
$this->tablename = GetTablePrefix()."TagLibrary";
$this->id_field = "TagId";
$this->type=-99;
$this->NoResourceId=1;
$this->attribs = new clsTagAttribs();
}
function LoadAttribs()
{
if($this->attribs->NumItems()<1)
{
$this->attribs->LoadTag($this->Get("TagId"));
}
}
function AddAttribute($name,$Type="str",$desc="",$default="",$required=FALSE)
{
if($this->attribs->NumItems()<1)
$this->attribs->LoadTag($this->Get("TagId"));
$a = $this->attribs->GetItemByField("Name",$name,FALSE);
if(!is_object($a))
{
$a = new clsAttribute();
$a->Set("TagId",$this->Get("TagId"));
$a->Set("Name",$name);
$a->Set("AttrType",$Type);
$a->Set("DefValue",$default);
$a->Set("Description",$desc);
$a->Set("Required",$required);
$a->Create();
}
else
{
if($a->Get("Name")!=$name)
{
$a = new clsAttribute();
$a->Set("TagId",$this->Get("TagId"));
$a->Set("Name",$name);
$a->Set("AttrType",$Type);
$a->Set("DefValue",$default);
$a->Set("Description",$desc);
$a->Set("Required",$required);
$a->Create();
}
else
{
$a->Set("TagId",$this->Get("TagId"));
$a->Set("Name",$name);
$a->Set("AttrType",$Type);
$a->Set("DefValue",$default);
$a->Set("Description",$desc);
$a->Set("Required",$required);
$a->Update();
}
}
$this->attribs->Items[] =& $a;
}
function LoadFromDatabase($Id)
{
global $objSession,$Errors;
if(!isset($Id))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->id_field." = '%s'",$Id);
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
if(is_array($data))
$this->SetFromArray($data);
$this->attribs->LoadTag($this->Get("TagId"));
$this->Clean();
return TRUE;
}
}
class clsTagList extends clsItemCollection
{
function clsTagList()
{
$this->clsItemCollection();
$this->SourceTable = GetTablePrefix()."TagLibrary";
$this->classname = "clsTagFunction";
//$this->tags = array();
}
function DeleteTags()
{
$this->adodbConnection->Execute("DELETE FROM ".$this->SourceTable);
$this->adodbConnection->Execute("DELETE FROM ".GetTablePrefix()."TagAttributes");
}
function FindStr($code,$str,$offset,$limit=0)
{
$x = $offset;
$found = FALSE;
while($x<count($code) && !$found && ($x<$limit || $limit==0))
{
$found = (strpos($code[$x],$str)!==false);
if(!$found)
$x++;
}
if($found)
return $x;
return "";
}
function GetTagName($func)
{
$f = explode(" ",$func);
//echo "$func:<PRE>";print_r($f); echo "</PRE>";
$fname = $f[1];
$fname = substr($fname,0,strpos($fname,"("));
return $fname;
}
function ParseComments($name,$code)
{
//echo "function $name:<br>\n";
$data = array();
$attribs = array();
$field = '';
for($l=0;$l<count($code);$l++)
{
$line = trim($code[$l]);
if(substr($line,0,1)=="@")
{
if(substr($line,1,6)=="attrib")
{
$field = "attrib";
$line=trim(substr($line,8));
$parts = explode(":",$line,3);
if(strpos($parts[0],"=")>0)
{
$p = explode($parts[0],"=",2);
$attr = $p[0];
$attr_default = $p[1];
}
else
{
$attr = $parts[0];
$attr_default="";
}
if(count($parts)==3)
{
$atype=$parts[1];
$attr_desc=$parts[2];
}
else
{
$attr_desc = $parts[1];
$atype="";
}
$attribs[$attr] = $attr_desc;
$attr_default[$attr] = $attr_default;
$attr_type[$attr] = $atype;
}
else
{
$parts = explode(":",$line,2);
$field = strtolower(substr($parts[0],1));
$data[$field] = htmlentities($parts[1]);
}
}
else
{
if(substr($line,0,2)!="*/")
{
if(strlen($field))
{
if($field=="attrib")
{
$attribs[$attr] .= $line;
}
else
$data[$field] .=$line;
}
}
}
}
if(strlen($name)>0)
{
$data["name"] = $name;
$data["scope"]="global";
}
else
{
if( isset($data["field"]) ) // process something, but don't work
{
$field = $data["field"];
$fparts = explode(".",$field,2);
$data["name"]=$fparts[1];
$data["scope"]=$fparts[0];
unset($data["field"]);
}
}
$t =& $this->AddItemFromArray($data);
//echo "<PRE>";print_r($data); echo "</PRE>";
$t->Dirty();
if(strlen($t->get("name"))>0 && strlen($t->Get("description"))>0)
{
$t->Create();
if(count($attribs)>0)
{
foreach($attribs as $field=>$desc)
{
$req = (substr($field,0,1)=="*");
$t->AddAttribute($field, GetElem($attr_type,$field),$desc,GetElem($attr_default,$field),$req);
}
}
}
}
function ParseFile($file)
{
$code = file($file);
//echo count($code)." lines<br>\n";
if(count($code))
{
$funcline = $this->FindStr($code,"function ",0);
//echo "First function $funcline :".$code[$funcline];
while(is_numeric($funcline) && $funcline<count($code))
{
$TagName = "";
$TagName = $this->GetTagName($code[$funcline]);
//echo "Parsing function $TagName <br>\n";
$comment_start = $funcline-1;
$temp = $code[$funcline-1];
while(($comment_start>0) && (substr($temp,0,1) != "}"))
{
$comment_start--;
$temp = $code[$comment_start];
}
//echo "Comment Start: $comment_start End: $funcline<br>\n";
if(substr($code[$comment_start],0,1)=="}")
$comment_start++;
$x = $comment_start;
$comments = array();
while($x<$funcline)
{
$comments[] = $code[$x];
$x++;
}
$this->ParseComments($TagName,$comments);
$funcline = $this->FindStr($code,"function ",$funcline+1);
}
}
}
function ParseItemFile($file)
{
$code = file($file);
if(count($code))
{
$funcline = $this->FindStr($code,"function ParseObject(",0);
if($funcline>0)
{
$nextfunc = $this->FindStr($code,"function ",$funcline+1);
if($nextfunc==0)
$nextfunc = count(code);
$comment_line = $this->FindStr($code,"/*",$funcline,$nextfunc);
while(is_numeric($comment_line))
{
$end_comment = $this->FindStr($code,"*/",$comment_line+1,$nextfunc);
if(is_numeric($end_comment))
{
$x=$comment_line+1;
$comments=array();
while($x<$end_comment)
{
$comments[] = $code[$x];
$x++;
}
$this->ParseComments("",$comments);
//echo "<PRE>";print_r($comments);echo "</PRE>";
unset($comments);
$comment_line=$this->FindStr($code,"/*",$end_comment+1,$nextfunc);
}
else
$comment_line="";
}
}
}
}
function LoadGlobalTags()
{
$this->Clear();
$this->Query_Item("SELECT * FROM ".$this->SourceTable);
+
for($i=0;$i<$this->NumItems();$i++)
{
$this->Items[$i]->LoadAttribs();
}
}
function ParseInportalTags()
{
global $ParserFiles,$ItemTagFiles,$pathtoroot;
$this->DeleteTags();
$t = new clsTagFunction();
$t->Set("name","include");
$t->Set("description","insert template output into the current template");
$t->Create();
$t->AddAttribute("_template","tpl","Template to insert","",TRUE);
$t->AddAttribute("_supresserror","bool","Supress missing template errors","",FALSE);
unset($t);
$t = new clsTagFunction();
$t->Set("name","perm_include");
$t->Set("description","insert template output into the current template if permissions are set");
$t->Create();
$t->AddAttribute("_template","tpl","Template to insert","",TRUE);
$t->AddAttribute("_noaccess","tpl","Template to insert if access is denied","",FALSE);
$t->AddAttribute("_permission","","Comma-separated list of permissions, any of which will grant access","",FALSE);
$t->AddAttribute("_module","","Used in place of the _permission attribute, this attribute verifies the module listed is enabled","",FALSE);
$t->AddAttribute("_system","bool","Must be set to true if any permissions in _permission list is a system permission","",FALSE);
$t->AddAttribute("_supresserror","bool","Supress missing template errors","",FALSE);
unset($t);
$t = new clsTagFunction();
$t->Set("name","mod_include");
$t->Set("description","insert templates from all enabled modules. No error occurs if the template does not exist.");
$t->Create();
$t->AddAttribute("_template","tpl","Template to insert. This template path should be relative to the module template root directory","",TRUE);
$t->AddAttribute("_modules","","Comma-separated list of modules. Defaults to all enabled modules if not set","",FALSE);
unset($t);
$t = new clsTagFunction();
$t->Set("name","lang_include");
$t->Set("description","Include a template based on the current language");
$t->Create();
$t->AddAttribute("_template","tpl","Template to insert. This template path should be relative to the module template root directory","",TRUE);
$t->AddAttribute("_language","","Pack name of language","",FALSE);
unset($t);
if(is_array($ParserFiles))
{
foreach($ParserFiles as $file)
{
$this->ParseFile($pathtoroot.$file);
}
}
if(is_array($ItemTagFiles))
{
foreach($ItemTagFiles as $file)
{
$this->ParseItemFile($pathtoroot.$file);
}
}
}
}
Property changes on: trunk/kernel/include/tag-class.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/kernel/admin/include/toolbar/template_editor.php
===================================================================
--- trunk/kernel/admin/include/toolbar/template_editor.php (revision 385)
+++ trunk/kernel/admin/include/toolbar/template_editor.php (revision 386)
@@ -1,584 +1,635 @@
<?php
global $rootURL, $envar, $objUsers, $objGroups, $objConfig, $adminURL, $imagesURL,
$objTagList, $TemplateType, $AllThemeFiles;
$editor_url = $adminURL."/editor";
$editorcss = $adminURL."/include/textedit.css";
$editorjs = $adminURL."/include/textedit.js";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$editorcss\">\n";
print "<script language=\"Javascript\">";
print "<!-- \n";
print "//load all tags\n\n";
print " var TagArray = Array();\n";
print " var TagAttribs = Array();\n";
-foreach($objTagList->Items as $tag)
+
+// get taglist + tags attributes using 2 queries
+$TablePrefix = GetTablePrefix();
+$db =& GetADODBConnection();
+
+// get all tag attributes
+$TagAttribs = array();
+$sql = 'SELECT * FROM '.$TablePrefix.'TagAttributes ORDER BY TagId, Name';
+$rs = $db->Execute($sql);
+
+while(!$rs->EOF)
+{
+ $rec =& $rs->fields;
+ $TagId = $rec['TagId'];
+ unset($rec['TagId']);
+ $TagAttribs[$TagId][] = $rec;
+ $rs->MoveNext();
+}
+
+// get taglist
+$sql = 'SELECT * FROM '.$TablePrefix.'TagLibrary ORDER BY TagId';
+$rs =& $db->Execute($sql);
+while(!$rs->EOF)
+{
+ $tag_rec =& $rs->fields;
+ // create main tag record
+ $Name = addslashes( $tag_rec['name'] );
+ $Description = addslashes( $tag_rec['description'] );
+ $Example = addslashes( $tag_rec['example'] );
+ $Scope = $tag_rec['scope'];
+ $TagId = $tag_rec['TagId'];
+ echo ' var Tag = Array("'.$Name.'","'.$Description.'","'.$Example.'","'.$Scope.'");'."\n";
+ echo ' TagArray['.$TagId.'] = Tag;'."\n";
+ echo ' TagAttribs['.$TagId.'] = Array();'."\n";
+
+ // set tag attribs
+ if( isset($TagAttribs[$TagId]) )
+ foreach($TagAttribs[$TagId] as $TagAttribute)
+ {
+ $Name = strtolower( addslashes( $TagAttribute['Name'] ) );
+ $Type = strtolower( addslashes( $TagAttribute['AttrType'] ) );
+ $Description = addslashes( $TagAttribute['Description'] );
+ $Required = $TagAttribute['Required'];
+ $DefaultValue = addslashes( $TagAttribute['DefValue'] );
+ print ' var Attr = Array("'.$Name.'","'.$Type.'","'.$Description.'","'.$Required.'","'.$DefaultValue.'");'."\n";
+ print ' TagAttribs['.$TagId.'].push(Attr);'."\n";
+ }
+ $rs->MoveNext();
+}
+
+
+/*foreach($objTagList->Items as $tag)
{
$Name= addslashes($tag->Get("name"));
$Description = addslashes($tag->Get("description"));
$Example = addslashes($tag->Get("example"));
$Scope = $tag->Get("scope");
$TagId = $tag->Get("TagId");
echo " var Tag=Array(\"$Name\",\"$Description\",\"$Example\",\"$Scope\");\n";
echo " TagArray[$TagId] = Tag;\n";
echo " TagAttribs[$TagId] = Array();\n";
foreach($tag->attribs->Items as $a)
{
$Name = strtolower(addslashes($a->Get("Name")));
$Type = strtolower(addslashes($a->Get("AttrType")));
$Description = addslashes($a->Get("Description"));
$Required = $a->Get("Required");
$DefaultValue = addslashes($a->Get("DefValue"));
print " var Attr = Array('$Name','$Type','$Description','$Required','$DefaultValue');\n";
print " TagAttribs[$TagId].push(Attr);\n";
}
-}
+} */
/*
$ViewMenuJS = array();
if(is_object($theme))
{
$theme->GetFileList("","FilePath,FileName"); // slow down process
$AllThemeFiles = $theme->Files->Items;
}
foreach($AllThemeFiles as $f)
{
$p = $f->Get("FilePath");
$parent_menu = str_replace("/","_",$p);
$n = $f->Get("FileName");
// $ViewMenuJS[] = "AddMenuTree('$parent_menu','$n');";
$ViewMenuJS[] = "menu_all.addMenuItem('$parent_menu','$n'); ";
}
*/
$lang_AllTemplates = language("la_prompt_all_templates");
$lang_ParentTemplates = language("la_prompt_parent_templates");
print "//-->\n";
print "</script>\n";
print <<<END
<script language="JavaScript" src="$editorjs"></script>
<script language="Javascript">
<!--
var CurrentTagPos = -1;
var CurrentTagEnd = -1;
var thisText;
var TemplateType='$TemplateType';
var lang_AllTemplates = '$lang_AllTemplates';
var lang_ParentTemplates = '$lang_ParentTemplates';
function init(formname,txtareaid)
{
thisForm = document.getElementById(formname);
thisText = document.getElementById(txtareaid);
}
function getTagId(tagName)
{
for(var x=0;x<TagArray.length;x++)
{
if(TagArray[x])
{
if(TagArray[x].length>0)
{
name = TagArray[x][0];
if(name==tagName)
return x;
}
}
}
return 0;
}
function LoadTags(SelectId,TagScope,inverse)
{
var s = document.getElementById(SelectId);
s.options.length=0; //clear all options 1052
for(var x=0;x<TagArray.length;x++)
{
if(TagArray[x])
{
if(TagArray[x].length>0)
{
name = TagArray[x][0];
scope = TagArray[x][3];
// TagScope.length==0
if( (!inverse && scope == TagScope) || (inverse && scope != TagScope) )
s.options[s.options.length]= new Option(name,x);
}
}
}
}
function AttribFormElement(name,value,type,desc)
{
out = '';
switch(type)
{
case 'bool':
if(value==0)
checked=' CHECKED';
out = '<input type=radio name="'+name+'" VALUE=0'+checked+'> No ';
if(value!=0)
checked=' CHECKED';
out = out + '<input type=radio name="'+name+'" VALUE=1'+checked+'> Yes ';
break;
default:
out = '<input type=text onmouseover="ShowAttrHelp(\''+desc+'\');" name="'+name+'" value="'+def+'" >';
break;
}
return out;
}
function ShowTagHelp(txt,ex)
{
el = document.getElementById('taghelp');
el.innerHTML=txt;
el = document.getElementById('tagexample');
el.innerHTML=ex;
}
function ShowAttrHelp(desc)
{
el = document.getElementById('attrhelp');
el.innerHTML=desc;
}
//function BuildItemTag()
//{
// var frm = document.getElementById('frmAttribs');
// var tag = '';
// extra_html = frm.extrahtml.value;
// tag = TemplateType+' _field="'+frmtagname.value+'" ";
function BuildInportalTag()
{
var frm = document.getElementById('frmAttribs');
var tag = '';
tagname = frm.tagname.value;
extra_html = frm.extrahtml.value;
if(tagname.length>0)
{
if(frm.scope.value!='global')
{
tag = tag + TemplateType+' _field="'+tagname+'" '+extra_html;
}
else
tag = tag + tagname+' '+extra_html;
for(var fld=0; fld<frm.elements.length; fld++)
{
var el = frm.elements[fld];
if(el.name.charAt(0)=="_" && el.value.length>0)
{
switch(el.type)
{
case 'radio':
if(el.checked)
{
tag = tag + el.name+'="'+el.value+'" ';
}
break;
case 'checkbox':
if(el.checked)
{
tag = tag + el.name+'="1" ';
}
else
tag = tag + el.name+'="0" ';
break;
default:
tag = tag + el.name+'="'+el.value+'" ';
break;
}
}
}
}
return tag;
}
function ReplaceText(txtarea,txt,start,end)
{
var pre = (txtarea.value).slice(0,start);
var post = (txtarea.value).slice(end);
txtarea.value = pre + txt + post;
}
function insertTag()
{
tag = BuildInportalTag();
if(tag.length>0)
{
tag = '<inp:'+tag+' />';
wrapSelection(thisText,tag,'');
}
return false;
}
function updateTag()
{
tag = BuildInportalTag();
if(tag.length>0 && CurrentTagPos>-1 && CurrentTagEnd>-1)
{
ReplaceText(thisText,tag,CurrentTagPos,CurrentTagEnd);
}
return false;
}
function cancelTag(id)
{
td = document.getElementById(id);
td.innerHTML=' ';
}
function TagSelectChange(SelectEl,TDid,isInsert)
{
if(SelectEl.selectedIndex>-1)
{
out='<form id="frmAttribs" name="frmAttribs" >';
opt = SelectEl.options[SelectEl.selectedIndex];
TagId = opt.value;
ShowTagHelp(TagArray[TagId][1],TagArray[TagId][2]);
var scope = TagArray[TagId][3];
if(TagId>0)
{
for(var x=0;x<TagAttribs[TagId].length;x++)
{
attr = TagAttribs[TagId][x];
name = attr[0];
type = attr[1];
desc = attr[2];
req = attr[3];
def = attr[4];
if(req=='1')
{
out = out + '<b>'+name+'</b><br />';
}
else
{
out = out + name + '<br />';
}
out = out + AttribFormElement(name,def,type,desc)+'<br />';
}
}
out = out+'<input type=hidden name="tagname" value="'+opt.text+'">';
out = out+'<input type=hidden name="extrahtml" value="">';
out = out+'<input type=hidden name="scope" VALUE="'+scope+'">';
if(isInsert)
{
out = out + '<input type=button class="button" value="Insert" onclick="insertTag(); cancelTag(\''+TDid+'\'); return false;">';
}
else
{
out = out + '<input type=button class="button" value="Update" onclick="updateTag(); cancelTag(\''+TDid+'\'); return false;">';
}
out = out + ' <input type=button class="button" value="Cancel" onClick="cancelTag(\''+TDid+'\'); return false;">';
out = out + '</form>';
td = document.getElementById(TDid);
//alert(td.innerHTML);
//alert(out);
//td.innerHTML=out;
//window.setTimeout('frmAttribs.elements[0].focus(); frmAttribs.elements[0].select();',30);
}
}
function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}
function InsertTag(select_name)
{
var TagId = document.getElementById(select_name).value;
var Tag = '<inp:' + TagArray[TagId][0] + ' />';
insertAtCursor(document.getElementById('contents'), Tag);
}
function BuildAttribText(attribs)
{
var s = '';
for(var x=0; x<attribs.length; x++)
{
name = attribs[x][0];
value = attribs[x][1];
s=s+name+'="'+value+'" "';
}
return s;
}
function SetAttributeFields(attribs,html_attribs)
{
var f = document.getElementById('frmAttribs');
if(f)
{
for(var x=0; x<attribs.length; x++)
{
name = attribs[x][0];
value = attribs[x][1];
if(value.length==0)
value = '1';
for(var fld=0;fld<f.elements.length;fld++)
{
if(f.elements[fld].name==name)
{
f.elements[fld].value=value;
break;
}
}
}
f.extrahtml.value = BuildAttribText(html_attribs);
}
}
function GetItemTagFieldValue(attribs)
{
var field='';
if(attribs.length>0)
{
for(var x=0; x<attribs.length; x++)
{
if(attribs[x][0]=='_field')
{
field = attribs[x][1];
break;
}
}
}
return field;
}
function SetItemAttributeFields(attribs,html_attribs)
{
var field = GetItemTagFieldValue(attribs);
var f = document.getElementById('frmAttribs');
if(f && field.length>0)
{
for(var x=0; x<attribs.length; x++)
{
name = attribs[x][0];
if(name=='_field')
continue;
value = attribs[x][1];
if(value.length==0)
value = '1';
for(var fld=0;fld<f.elements.length;fld++)
{
if(f.elements[fld].name==name)
{
f.elements[fld].value=value;
break;
}
}
}
f.extrahtml.value = BuildAttribText(html_attribs);
}
}
function SetTagDropdown(TagId,attribs,html_attribs,IsItemTag)
{
if(!IsItemTag)
{
var selName='taglib';
}
else
{
var selName='itemtags';
var TagName = GetItemTagFieldValue(attribs);
TagId = getTagId(TagName);
}
sel = document.getElementById(selName);
if(sel)
{
for(var x=0;x<sel.options.length;x++)
{
o = sel.options[x];
if(o.value==TagId)
{
sel.selectedIndex = x;
TagSelectChange(sel,'tagattribs',false);
if(!IsItemTag)
{
SetAttributeFields(attribs,html_attribs);
}
else
SetItemAttributeFields(attribs,html_attribs);
}
}
}
}
function WatchForTags(el)
{
var selLength = el.textLength;
var selStart = el.selectionStart;
var selEnd = el.selectionEnd;
desc = 'Start: '+selStart+' Length: '+selLength+' End:'+selEnd;
ShowTagHelp(desc,'');
if(selStart==selEnd)
{
var pos = selStart;
var s1 = (el.value).substring(pos,pos+5);
FirstChar = (el.value).charAt(pos);
while(s1 != '<inp:' && pos>-1 && FirstChar !='<' && FirstChar != ' ' && FirstChar != '')
{
pos--;
if(pos>-1)
{
s1 = (el.value).substring(pos,pos+5);
if(FirstChar=='<' && (el.value.charAt(pos)==' '))
FirstChar = (el.value).charAt(pos);
}
}
if((FirstChar=='<' && s1 != '<inp:') || (FirstChar == ' ' || FirstChar == ''))
pos=-1;
}
else
{
pos=selStart;
}
CurrentTagEnd=-1;
CurrentTagPos=-1
if(pos>-1)
{
endpos = (el.value).indexOf(' ',pos);
if(endpos>-1)
{
tagname = (el.value).substring(pos+5,endpos);
if(tagname != TemplateType)
{
tagid = getTagId(tagname);
}
else
tagid=0;
if(tagid>0 || (tagname==TemplateType))
{
var closer = (el.value).indexOf('>',endpos);
var endtag = (el.value).indexOf('/>',endpos);
var tagtext='';
if(endtag < closer || closer == 0)
{
tagtext = (el.value).substring(pos+5,endtag);
CurrentTagEnd = endtag-1;
}
else
{
tagtext = (el.value).substring(pos+5,closer);
CurrentTagEnd = closer-1;
}
attribs = GetTagAttributes(tagtext,true);
extra_attribs = GetTagAttributes(tagtext,false);
if(tagname==TemplateType)
{
var IsItemTag = true;
}
else
{
var IsItemTag = false;
}
if(attribs.length>0)
{
SetTagDropdown(tagid,attribs,extra_attribs,IsItemTag);
}
CurrentTagPos = pos+5; //store this for use later
}
}
}
}
function GetTagAttributes(tagtext,inp_attribs)
{
var parts = tagtext.split(' ');
var attribs = Array();
var peices = Array();
for(var x=1;x<parts.length;x++)
{
peices = parts[x].split('=');
name = peices[0];
value = '';
if(peices.length>1)
{
value = peices[1];
value = value.slice(1,-1);
}
if(name.length>0)
{
if(inp_attribs)
{
if(name.charAt(0)=='_')
{
name = name.toLowerCase();
attribs[attribs.length] = Array(name,value);
}
}
else
{
if(name.charAt(0)!='_')
{
name = name.toLowerCase();
attribs[attribs.length] = Array(name,value);
}
}
}
}
return attribs;
}
function SelectSubmit()
{
var env_str = '$envar';
f = document.getElementById('template');
if(f)
{
//f.Action.value = "m_template_edit";
if (f.onsubmit) f.onsubmit();
f.submit();
//window.close();
}
}
function ShowPreview(url)
{
window.open(url);
}
//-->
</script>
END;
?>
\ No newline at end of file
Property changes on: trunk/kernel/admin/include/toolbar/template_editor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/admin/config/edit_template.php
===================================================================
--- trunk/admin/config/edit_template.php (revision 385)
+++ trunk/admin/config/edit_template.php (revision 386)
@@ -1,293 +1,298 @@
<?php
##############################################################
##In-portal ##
##############################################################
## In-portal ##
## Intechnic Corporation ##
## All Rights Reserved, 1998-2002 ##
## ##
## No portion of this code may be copied, reproduced or ##
## otherwise redistributed without proper written ##
## consent of Intechnic Corporation. Violation will ##
## result in revocation of the license and support ##
## privileges along maximum prosecution allowed by law. ##
##############################################################
+
if(!strlen($pathtoroot))
{
$path=dirname(realpath(__FILE__));
if(strlen($path))
{
/* determine the OS type for path parsing */
$pos = strpos($path,":");
if ($pos === false)
{
$gOS_TYPE="unix";
$pathchar = "/";
}
else
{
$gOS_TYPE="win";
$pathchar="\\";
}
$p = $path.$pathchar;
/*Start looking for the root flag file */
while(!strlen($pathtoroot) && strlen($p))
{
$sub = substr($p,strlen($pathchar)*-1);
if($sub==$pathchar)
{
$filename = $p."root.flg";
}
else
$filename = $p.$pathchar."root.flg";
if(file_exists($filename))
{
$pathtoroot = $p;
}
else
{
$parent = realpath($p.$pathchar."..".$pathchar);
if($parent!=$p)
{
$p = $parent;
}
else
$p = "";
}
}
if(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
//admin only util
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
require_once($pathtoroot."kernel/include/tag-class.php");
+
+
$objTagList = new clsTagList();
-$objTagList->LoadGlobalTags();
+
+//$objTagList->LoadGlobalTags();
$section = "in-portal:template_editor";
$ThemeId = GetVar('ThemeId');
$FileId = GetVar('FileId');
if(!GetVar('Action',true) || !is_object($f) ) $f = new clsThemeFile($FileId);
+
if($FileId)
{
$theme = new clsTheme( $f->Get("ThemeId") ); // create theme from file
$f->LoadFileContents(false);
$name = $f->Get("FileName");
$Action="m_template_edit";
}
else
{
if($ThemeId) // if theme is set
{
$theme = new clsTheme($ThemeId);
$f->Set("ThemeId",$ThemeId);
$f->Set("FilePath",$theme->Get("name"));
$name = "New Template";
$Action = "m_template_add";
}
}
if( is_object($f) && isset($_POST['Action']) )
{
// aka SetFieldsFromHash
//print_pre($_POST);
//echo "SetFields From POST<br>";
$f->Set( Array('FileName','Description','Contents'),
Array(basename($_POST['name']), $_POST['Description'], $_POST['contents']) );
}
$objTemplateCheck = new clsTemplateChecker($theme->ThemeDirectory()."/");
if(count($f->Contents)>0)
{
$fullname = $f->Get("FilePath")."/".$name;
$TemplateType = $objTemplateCheck->GetTemplateType($fullname);
}
else
$TemplateType="new";
if($ThemeId)
{
$m_var_list_update["theme"]=$ThemeId;
$cat = 0;
$template = "index";
if(is_object($f))
{
$p = $f->Get("FilePath");
if(strlen($p))
{
if(substr($p,0,1)=="/")
$p = substr($p,1);
$p .= "/";
$mod = $objModules->GetModuleByPath($p);
if(is_object($mod))
{
$cat = $mod->Get("RootCat");
$template=$mod->Get("TemplatePath")."index";
}
}
}
$m_var_list_update["t"] = $template;
$m_var_list_update["cat"] = $cat;
$PreviewUrl ="http://".ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv();
}
unset($objEditItems);
$envar = "env=".BuildEnv();
$formaction = $_SERVER["PHP_SELF"]."?".$envar;
$sec = $objSections->GetSection($section);
$objListToolBar = new clsToolBar();
$objListToolBar->Set("section",$section);
$objListToolBar->Set("load_menu_func","");
$objListToolBar->Set("CheckClass","ThemeChecks");
$objListToolBar->Add("select", "la_ToolTip_Save","#","swap('select','toolbar/tool_select_f2.gif');",
"swap('select', 'toolbar/tool_select.gif');",
"SelectSubmit();",
"tool_select.gif");
$objListToolBar->Add("cancel", "la_ToolTip_Close","#","swap('cancel','toolbar/tool_stop_f2.gif');",
"swap('cancel', 'toolbar/tool_stop.gif');","window.close();","tool_stop.gif");
$objListToolBar->Add("divider");
$objListToolBar->Add("template_preview","la_ToolTip_Preview","#", "swap('template_preview','toolbar/tool_preview_template_f2.gif');",
"swap('template_preview', 'toolbar/tool_preview_template.gif');",
"ShowPreview('$PreviewUrl');","tool_preview_template.gif");
//$objListToolBar->AddToInitScript("fwLoadMenus();");
$title = prompt_language("la_Text_Editing")." ".prompt_language("la_Text_Theme")." '".$theme->Get("Name")."' - ".prompt_language("la_Text_Template");
$title .= " '".$name."'";
$path = $f->FullPath();
if(!is_writable($path))
$title .= " (".admin_language("la_text_ReadOnly").")";
int_header($objListToolBar,NULL,$title);
?>
<TABLE cellSpacing="0" cellPadding="2" width="100%" border="0" class="tableborder">
<form name="template" ID="template" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar;?>" method=POST>
<?php if( $f->HasError() ) { ?>
<TR <?php int_table_color(); ?> style="color: red;">
<TD>ERROR:</TD>
<TD><?php echo $f->ErrorMsg(); ?></TD>
<TD></TD>
</TR>
<?php } ?>
<?php int_subsection_title(prompt_language("la_tab_General")); ?>
<TR <?php int_table_color(); ?> >
<TD><?php echo prompt_language("la_prompt_FileId"); ?></TD>
<TD><?php echo $f->Get("FileId"); ?></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_name" CLASS="text"><?php echo prompt_language("la_prompt_FileName"); ?></SPAN></TD>
<TD><input type="text" NAME="name" <?php if($Action == 'm_template_edit') echo 'Readonly'; ?> VALUE="<?php echo $f->Get("FileName"); ?>"> <?php if($Action == 'm_template_edit') echo ' (read only)'; ?></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_description" CLASS="text"><?php echo prompt_language("la_prompt_Description"); ?></SPAN></TD>
<TD><input type="text" NAME="Description" VALUE="<?php echo $f->Get("Description"); ?>"></TD>
<TD></TD>
</TR>
<!--
<tr <?php int_table_color(); ?>>
<td valign="top" class="text"><?php echo prompt_language("la_prompt_EnableCache"); ?></td>
<td>
<input type="checkbox" name="enable_cache" class="text" value="1" <?php if($f->Get("EnableCache") == 1) echo "checked"; ?>>
<input type=text NAME="cache_timeout" VALUE="<?php echo $f->Get("CacheTimeout"); ?>">
</td>
<td class="text"> </td>
</tr>
-->
<?php int_subsection_title(prompt_language("la_Text_Template")); ?>
<tr <?php int_table_color(); ?> >
<td colspan="3">
Item Tags:
<SELECT id="itemtags" name="itemtags" onChange="TagSelectChange(this,'tagattribs',true);"></select>
<a href="javascript:InsertTag('itemtags');">Insert Tag</a>
Global Tags:
<SELECT id="taglib" name="taglib" onChange="TagSelectChange(this,'tagattribs',true);"></select>
<a href="javascript:InsertTag('taglib');">Insert Tag</a>
</td>
</tr>
<TR <?php int_table_color(); ?> >
<td colspan="3" align="center">
<textarea NAME="contents" id="contents" rows="20" cols="95" nowrap><?php echo stripslashes($f->Get('Contents')); ?></textarea>
</td>
</TR>
<tr <?php int_table_color(); ?> >
<td colspan="3">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="30%" align="left" id="taghelp"> </td>
<td width="70%" align="left" id="tagexample"> </td>
<!--<td width="33%" align="left" id="attrhelp"> </td>-->
<!--<td id="tagattribs" valign="top"> </td>-->
</tr>
</table>
</td>
</tr>
<TR <?php int_table_color(); ?> >
<td colspan="3">
<input type="hidden" NAME="Action" VALUE="<?php echo $Action; ?>">
<INPUT TYPE="hidden" NAME="ThemeId" VALUE="<?php echo $f->Get("ThemeId"); ?>">
<INPUT TYPE="hidden" NAME="FileId" VALUE="<?php echo $f->Get("FileId"); ?>">
<INPUT TYPE="hidden" NAME="FilePath" VALUE="<?php echo $f->Get("FilePath"); ?>">
<input type="hidden" name="ThemeEditStatus" VALUE="0">
</td>
</tr>
</FORM>
</TABLE>
<SCRIPT language="JavaScript">
init('template','contents');
LoadTags('taglib','global',false);
LoadTags('itemtags','global',true);
</SCRIPT>
<?php int_footer(); ?>
Property changes on: trunk/admin/config/edit_template.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Event Timeline
Log In to Comment