Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F773291
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, 6:50 AM
Size
37 KB
Mime Type
text/x-diff
Expires
Tue, Feb 4, 6:50 AM (1 h, 11 m)
Engine
blob
Format
Raw Data
Handle
556537
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/include/custommetadata.php
===================================================================
--- trunk/kernel/include/custommetadata.php (revision 765)
+++ trunk/kernel/include/custommetadata.php (revision 766)
@@ -1,274 +1,275 @@
<?php
class clsCustomMetaData extends clsItem
{
// var $m_CustomDataId;
// var $m_ResourceId;
// var $m_CustomFieldId;
// var $m_Value;
var $FieldName;
function clsCustomMetaData($CustomDataId=-1,$table="CustomMetaData")
{
$this->clsItem();
$this->tablename=GetTablePrefix()."CustomMetaData";
$this->type=12;
$this->BasePermission="";
$this->id_field = "CustomDataId";
$this->NoResourceId=1; //set this to avoid using a resource ID
if(isset($CustomDataId))
$this->LoadFromDatabase($CustomDataId);
}
function Validate()
{
global $Errors;
$dataValid = true;
if(!strlen($this->Get("ResourceId")))
{
$Errors->AddError("error.fieldIsRequired",'ResourceId',"","",get_class($this),"Validate");
$dataValid = false;
}
return $dataValid;
}
function SetFieldName($name)
{
$this->FieldName = $name;
}
function GetFieldName()
{
return $this->FieldName;
}
function Save()
{
if(is_numeric($this->Get("CustomDataId")))
{
$this->Update();
}
else
$this->Create();
}
/*
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->SourceTable." WHERE CustomDataId = '%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;
$this->SetFromArray($data);
$this->Clean();
return true;
}
*/
} /*clsCustomMetaData*/
class clsCustomDataList extends clsItemCollection
{
function clsCustomDataList($table="")
{
$this->clsItemCollection();
$this->classname = "clsCustomMetaData";
if(!strlen($table))
$table = GetTablePrefix()."CustomMetaData";
$this->SetTable('live', $table);
}
function LoadResource($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=".$ResourceId;
$this->Query_Item($sql);
return $this->Items;
}
function DeleteResource($ResourceId)
{
+ if(!is_numeric($ResourceId))return;
$sql = "DELETE FROM ".$this->SourceTable." WHERE ResourceID=".$ResourceId;
- $this->adodbConnection->Execute($ResourceId);
+ $this->adodbConnection->Execute($sql);
}
function &SetFieldValue($FieldId,$ResourceId,$Value)
{
// so strange construction used, because in normal
// way it doesn't work at all (gets item copy not
// pointer)
$index = $this->GetDataItem($FieldId, true);
if($index !== false)
$d =& $this->Items[$index];
else
$d = null;
if(is_object($d))
{
$d->Set("Value",$Value);
if(!strlen($Value))
{
for($x=0;$x<count($this->Items);$x++)
{
if($this->Items[$x]->Get("CustomFieldId")==$FieldId &&
$this->Items[$x]->Get("ResourceId")==$ResourceId)
{
$this->Items[$x]->Set("CustomFieldId",0);
break;
}
}
$d->Delete();
}
}
else
{
if(strlen($Value)>0)
{
$d = new clsCustomMetaData();
$d->Set("CustomFieldId",$FieldId);
$d->Set("ResourceId",$ResourceId);
$d->Set("Value",$Value);
array_push($this->Items,$d);
}
}
return $d;
}
function &GetDataItem($id, $return_index = false)
{
// $id - custom field id to find
// $return_index - return index to items, not her.
$found = false;
$index = false;
for($i = 0; $i < $this->NumItems(); $i++)
{
$d =& $this->GetItemRefByIndex($i);
if($d->Get("CustomFieldId")==$id)
{
$found=TRUE;
break;
}
}
return $found ? ($return_index ? $i : $d) : false;
}
function SaveData()
{
foreach($this->Items as $f)
{
$FieldId = $f->Get("CustomFieldId");
$value = $f->Get("Value");
$ResId = $f->Get("ResourceId");
$DataId = $f->Get("CustomDataId");
if(is_numeric($DataId))
{
$sql = "UPDATE ".$this->SourceTable." SET Value='".$value."' WHERE CustomFieldId='$FieldId' AND ResourceId='$ResId'";
$this->adodbConnection->Execute($sql);
}
else
{
if($FieldId>0)
{
$sql = "INSERT INTO ".$this->SourceTable." (ResourceId,CustomFieldId,Value) VALUES ('".$ResId."','$FieldId','$value')";
$this->adodbConnection->Execute($sql);
}
}
}
$rs = $this->adodbConnection->Execute("SELECT * FROM ".$this->SourceTable." WHERE CustomDataId=0 ");
while($rs && !$rs->EOF)
{
$m = $this->adodbConnection->Execute("SELECT MIN(CustomDataId) as MinValue FROM ".$this->SourceTable);
$NewId = $m->fields["MinValue"]-1;
$sql = "UPDATE ".$this->SourceTable." SET CustomDataId=$NewId WHERE ResourceId=".$rs->fields["ResourceId"]." AND ";
$sql .= "CustomFieldId=".$rs->fields["CustomFieldId"];
$this->adodbConnection->Execute($sql);
$rs->MoveNext();
}
}
function CopyToEditTable($idfield, $idlist)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield IN ($list)";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if((int)$GLOBALS["debuglevel"])
echo $insert;
$this->adodbConnection->Execute($insert);
$this->SourceTable = $edit_table;
$this->SaveData();
}
function CopyFromEditTable($ResourceId)
{
global $objSession;
$GLOBALS['_CopyFromEditTable']=1;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$idlist = array();
//$this->adodbConnection->Execute($sql);
$sql = "SELECT * FROM $edit_table";
$this->Clear();
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = $this->AddItemFromArray($data);
if(strlen($data["Value"])>0)
{
$c->Dirty();
if($data["CustomDataId"]>0)
{
$c->Update();
}
else
{
$c->UnsetIdField();
$c->Create();
}
$idlist[] = $c->Get("CustomDataId");
}
else
{
$sql = "DELETE FROM ".$this->SourceTable." WHERE ResourceId=".$data["ResourceId"]." AND CustomFieldId=".$data["CustomFieldId"];
//echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
}
$rs->MoveNext();
}
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
unset($GLOBALS['_CopyFromEditTable']);
}
} /* clsCustomDataList */
?>
Property changes on: trunk/kernel/include/custommetadata.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/kernel/include/theme.php
===================================================================
--- trunk/kernel/include/theme.php (revision 765)
+++ trunk/kernel/include/theme.php (revision 766)
@@ -1,730 +1,732 @@
<?php
define('THEME_ERROR_1', 'Theme folder not writable');
define('THEME_ERROR_2', 'Template File Not Found');
class clsThemeFile extends clsItem
{
var $Contents;
var $Root;
var $Errors = Array(); // global template error messages (not db related)
function clsThemeFile($id=NULL)
{
$this->clsItem();
$this->tablename = GetTablePrefix()."ThemeFiles";
$this->id_field = "FileId";
$this->NoResourceId=1;
$this->Root = "";
$this->Contents = '';
if($id) $this->LoadFromDatabase($id);
}
function ThemeRoot()
{
if( !$this->Root )
{
$t = new clsTheme( $this->Get("ThemeId") );
$this->Root = $t->Get("Name");
}
return $this->Root;
}
function FullPath()
{
// need to rewrite (by Alex)
global $objConfig, $pathchar,$pathtoroot;
$path = $pathtoroot."themes".$pathchar.$this->ThemeRoot();
if(strlen(trim($this->Get("FilePath"))))
$path .= $pathchar.$this->Get("FilePath");
$path .= $pathchar.$this->Get("FileName");
//echo "Full Path is $path <br>\n";
return str_replace('//','/',$path);
}
function Get($name)
{
if($name == 'Contents')
return $this->Contents;
else
return parent::Get($name);
}
function Set($name, $value)
{
if( !is_array($name) )
{
$name = Array($name);
$value = Array($value);
}
$i = 0; $field_count = count($name);
while($i < $field_count)
{
if($name[$i] == 'Contents')
$this->Contents = $value[$i];
else
parent::Set($name[$i], $value[$i]);
$i++;
}
}
/*
function LoadFromDatabase($Id)
{
global $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->IdField()." = '%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;
$this->SetFromArray($data);
$this->Clean();
return true;
}
*/
function Delete()
{
$path = $this->FullPath();
if($this->debuglevel) echo "Trying to delete file [$path]<br>";
if( file_exists($path) ) @unlink($path);
parent::Delete();
}
function LoadFileContents($want_return = true)
{
global $objConfig,$pathchar;
$this->Contents = '';
$path = $this->FullPath();
if( file_exists($path) )
$this->Contents = file_get_contents($path);
else
$this->SetError(THEME_ERROR_2, 2); // template not found
if($want_return) return $this->Contents;
}
function SetError($msg, $code, $field = 'global_error')
{
$this->Errors[$field]['msg'] = $msg;
$this->Errors[$field]['code'] = $code;
}
function HasError()
{
return count($this->Errors) ? 1 : 0;
}
function ErrorMsg()
{
return $this->Errors['global_error']['msg'];
}
function SaveFileContents($filecontents, $new_file = false)
{
$path = $this->FullPath();
if( is_array($filecontents) ) $filecontents = implode("\n",$filecontents);
if( $this->IsWriteablePath($new_file) )
{
$fp = fopen($path,"w");
if($fp)
{
fwrite($fp,$filecontents);
fclose($fp);
return true;
}
}
return false;
}
function IsWriteablePath($new_file = false)
{
$path = $this->FullPath();
$path = str_replace('//','/',$path);
$ret = $new_file ? is_writable(dirname($path)): is_writable($path);
if(!$ret)
{
$this->SetError(THEME_ERROR_1, 1);
return false;
}
return $ret;
}
}
class clsThemeFileList extends clsItemCollection
{
var $Page;
var $PerPageVar;
var $ThemeId;
function clsThemeFileList($theme_id=NULL)
{
global $m_var_list;
$this->clsItemCollection();
$this->classname = "clsThemeFile";
$this->Page=(int)$m_var_list["p"];
$this->PerPageVar = "Perpage_ThemeFiles";
$this->SourceTable = GetTablePrefix()."ThemeFiles";
$this->AdminSearchFields = array("FileName","FilePath","Description");
$this->ThemeId=$theme_id;
//if($theme_id)
// $this->LoadFiles($theme_id);
}
function LoadFiles($id,$where="",$orderBy="",$limit="")
{
global $objConfig;
$this->Clear();
$this->ThemeId=$id;
$sql = "SELECT * FROM ".$this->SourceTable. " WHERE ThemeId=$id ";
if(strlen(trim($where))) $sql .= ' AND '.$where." ";
if(strlen(trim($orderBy))) $sql .= "ORDER BY $orderBy";
if(strlen(trim($limit))) $sql .= $limit;
if(strlen($this->PerPageVar))
{
$sql .= GetLimitSQL($this->Page,$objConfig->Get($this->PerPageVar));
}
//echo $sql;
return $this->Query_Item($sql);
}
function GetFileByName($path,$name,$LoadFromDB=TRUE)
{
$found = FALSE;
$f = FALSE;
//echo "Looking through ".$this->NumItems()." Files <br>\n";
if($this->NumItems()>0)
{
foreach($this->Items as $f)
{
if(($f->Get("FilePath")== $path) && ($f->Get("FileName")==$name))
{
$found = TRUE;
break;
}
}
}
if(!$found && $LoadFromDB)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ThemeId=".$this->ThemeId." AND FileName LIKE '$name' AND FilePath LIKE '$path'";
$rs = $this->adodbConnection->Execute($sql);
//echo $sql."<br>\n";
if($rs && !$rs->EOF)
{
$data = $rs->fields;
$f =& $this->AddItemFromArray($data);
}
else
$f = FALSE;
}
return $f;
}
function AddFile($Path,$Name,$ThemeId,$Type,$Description,$contents=NULL)
{
$f = new clsThemeFile();
$f->Set(array("FilePath","FileName","ThemeId","FileType","Description"),
array($Path,$Name,$ThemeId,$Type,$Description));
$f->Create();
if($contents!=NULL)
$f->SaveFileContents($contents);
//echo $f->Get("FilePath")."/".$f->Get("FileName")."<br>\n";
return $f;
}
function EditFile($FileId,$Path,$Name,$ThemeId,$Type,$Description,$contents=NULL)
{
$f = $this->GetItem($FileId);
$f->Set(array("FilePath","FileName","ThemeId","FileType","Description"),
array($Path,$Name,$ThemeId,$Type,$Description));
$f->Update();
if($Contents!=NULL)
$f->SaveFileContents($Contents);
return $f;
}
function DeleteFile($FileId)
{
$f = $this->GetItem($FileId);
$f->Delete();
}
function DeleteAll()
{
$this->Clear();
$this->LoadFiles($this->ThemeId);
foreach($this->Items as $f)
$f->Delete();
$this->Clear();
}
function SetFileContents($FileId,$Contents)
{
$f = $this->GetItem($FileId);
$f->SaveFileContents($Contents);
}
function GetFileContents($FileId)
{
$f = $this->GetItem($FileId);
return $f->LoadFileContents();
}
function FindMissingFiles($path, $where = null, $OrderBy = null, $limit = null)
{
global $pathtoroot;
$this->Clear();
$fullpath = $pathtoroot.'themes/'.$path;
// get all templates from database
$sql = 'SELECT FileId AS i,CONCAT(FilePath,"/",FileName) AS f FROM '.$this->SourceTable. ' WHERE ThemeId='.$this->ThemeId;
$DBfiles=Array();
if($rs = $this->adodbConnection->Execute($sql))
{
while(!$rs->EOF)
{
$DBfiles[$rs->fields['i']] = $fullpath.$rs->fields['f'];
$rs->MoveNext();
}
$rs->Free();
}
// get all templates file from disk
$HDDfiles = filelist($fullpath, NULL, "tpl");
$missingFiles=array_diff($HDDfiles,$DBfiles);
$orphanFiles=array_diff($DBfiles,$HDDfiles);
-
- $sql = 'DELETE FROM '.$this->SourceTable.' WHERE FileId IN('.join(',',array_keys($orphanFiles)).')';
- $this->adodbConnection->Execute($sql);
-
+ if($orphanFiles)
+ {
+ $sql = 'DELETE FROM '.$this->SourceTable.' WHERE FileId IN('.join(',',array_keys($orphanFiles)).')';
+ $this->adodbConnection->Execute($sql);
+ }
$l=strlen($fullpath);
foreach($missingFiles as $file)
$this->AddFile(substr(dirname($file),$l),basename($file),$this->ThemeId,0,'');
}
}
RegisterPrefix("clsTheme","theme","kernel/include/theme.php");
class clsTheme extends clsParsedItem
{
var $Files;
var $FileCache;
var $IdCache;
var $ParseCacheDate;
var $ParseCacheTimeout;
function clsTheme($Id = NULL)
{
$this->clsParsedItem($Id);
$this->tablename = GetTablePrefix()."Theme";
$this->id_field = "ThemeId";
$this->NoResourceId=1;
$this->TagPrefix="theme";
$this->Files = new clsThemeFileList($Id);
$this->FileCache = array();
$this->IdCache = array();
$this->ParseCacheDate=array();
$this->ParseCacheTimeout = array();
if($Id)
$this->LoadFromDatabase($Id);
}
function ThemeDirectory()
{
global $objConfig, $pathchar, $pathtoroot;
$path = $pathtoroot."themes/".strtolower($this->Get("Name"));
return $path;
}
function UpdateFileCacheData($id,$CacheDate)
{
$sql = "UPDATE ".GetTablePrefix()."ThemeFiles SET CacheDate=$CacheDate WHERE FileId=$id";
$this->adodbConnection->Execute($sql);
}
function LoadFileCache()
{
- $sql = "SELECT * FROM ".GetTablePrefix()."ThemeFiles WHERE ThemeId=".$this->Get("ThemeId");
+ if(!is_numeric($id=$this->Get("ThemeId")))return;
+ $sql = "SELECT * FROM ".GetTablePrefix()."ThemeFiles WHERE ThemeId=".$id;
$rs = $this->adodbConnection->Execute($sql);
while($rs && ! $rs->EOF)
{
//$this->Files->AddItemFromArray($rs->fields,TRUE);
$f = $rs->fields["FileName"];
$t = $rs->fields["FilePath"];
if(strlen($t))
$t .= "/";
$parts = pathinfo($f);
$fname = substr($f,0,(strlen($parts["extension"])+1)*-1);
// echo "Name: $fname<br>\n";
$t .= $fname;
$this->FileCache[$t] = $rs->fields["FileId"];
$this->IdCache[$rs->fields["FileId"]] = $t;
/*
if($rs->fields["EnableCache"]) // no such field in this table (commented by Alex)
{
$this->ParseCacheDate[$rs->fields["FileId"]] = $rs->fields["CacheDate"];
$this->ParseCacheTimeout[$rs->fields["FileId"]] = $rs->fields["CacheTimeout"];
}
*/
if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 )
adodb_movenext($rs);
else
$rs->MoveNext();
}
//echo "<PRE>"; print_r($this->IdCache); echo "</PRE>";
}
function GetTemplateById($FileId)
{
if(count($this->FileCache)==0)
$this->LoadFileCache();
$f = $this->IdCache[$FileId];
return $f;
}
function GetTemplateId($t)
{
if( count($this->IdCache) == 0 ) $this->LoadFileCache();
$f = isset( $this->FileCache[$t] ) ? $this->FileCache[$t] : '';
return is_numeric($f) ? $f : $t;
}
function LoadFromDatabase($Id)
{
global $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->IdField()." = '%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;
$this->SetFromArray($data);
$this->Clean();
$this->Files = new clsThemeFileList($Id);
return true;
}
function GetFileList($where,$OrderBy)
{
global $objConfig, $pathchar;
$this->Files->PerPageVar="";
$this->Files->ThemeId = $this->Get("ThemeId");
$this->Files->LoadFiles($this->Get("ThemeId"),$where,$OrderBy);
}
function VerifyTemplates($where = null,$OrderBy = null,$limit = null)
{
if(!is_object($this->Files))
$this->Files = new clsThemeFileList($this->Get("ThemeId"));
$this->Files->ThemeId = $this->Get("ThemeId");
$this->Files->FindMissingFiles(strtolower($this->Get("Name")),$where,$OrderBy,$limit);
}
function EditTemplateContents($FileId,$Contents)
{
$this->Files->SetFileContents($FileId,$Contents);
}
function ReadTemplateContents($FileId)
{
return $this->Files->GetFileContents($FileId);
}
function CreateDirectory()
{
$dir = $this->ThemeDirectory();
if(!is_dir($dir))
mkdir($dir);
}
function Delete()
{
$this->Files->DeleteAll();
$dir = $this->ThemeDirectory();
if(is_writable($dir))
@rmdir($dir);
parent::Delete();
}
function AdminIcon()
{
global $imagesURL;
$file = $imagesURL."/itemicons/icon16_theme";
if($this->Get("PrimaryTheme")==1)
{
$file .= "_primary.gif";
}
else
{
if($this->Get("Enabled")==0)
{
$file .= "_disabled";
}
$file .= ".gif";
}
return $file;
}
function ParseObject($element)
{
global $var_list_update, $objSession;
$extra_attribs = ExtraAttributes($element->attributes);
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
switch($field)
{
case "id":
$ret = $this->Get("ThemeId");
break;
case "name": // was "nane"
$ret = $this->Get("Name");
break;
case "description":
$ret = $this->Get("Description");
break;
case "adminicon":
$ret = $this->AdminIcon();
break;
case "directory":
$ret = $this->ThemeDirectory();
break;
case "select_url":
$var_list_update["t"] = "index";
$ret = GetIndexURL()."?env=".BuildEnv()."&Action=m_set_theme&ThemeId=".$this->Get("ThemeId");
break;
case "selected":
$ret = "";
if($this->Get("Name")==$objSession->Get("Theme"))
$ret = "SELECTED";
break;
default:
$tag = $this->TagPrefix."_".$field;
$ret = ""; $this->parsetag($tag);
break;
}
}
return $ret;
}
}
class clsThemeList extends clsItemCollection
{
var $Page;
var $PerPageVar;
function clsThemeList($id=NULL)
{
$this->clsItemCollection();
$this->classname="clsTheme";
$this->SourceTable=GetTablePrefix()."Theme";
$this->PerPageVar = "Perpage_Themes";
$this->AdminSearchFields = array("Name","Description");
}
function LoadThemes($where="",$order="")
{
global $objConfig;
$this->Clear();
$sql = "SELECT * FROM ".$this->SourceTable." ";
if(strlen(trim($where)))
$sql .= "WHERE ".$where." ";
if(strlen(trim($orderBy)))
$sql .= "ORDER BY $orderBy";
$sql .= GetLimitSQL($this->Page,$objConfig->Get($this->PerPageVar));
return $this->Query_Item($sql);
}
function AddTheme($Name,$Description,$Enabled,$Primary,$CacheTimeout=3600)
{
$t = new clsTheme();
$t->tablename = $this->SourceTable;
$t->Set(array("Name","Description","Enabled","PrimaryTheme","CacheTimeout"),
array($Name,$Description,$Enabled,$Primary,$CacheTimeout));
$t->Create();
if($Primary==1)
{
$sql = "UPDATE ".$this->SourceTable." SET PrimaryTheme=0 WHERE ThemeId != ".$t->Get("ThemeId");
$this->adodbConnection->Execute($sql);
}
return $t;
}
function EditTheme($ThemeId,$Name,$Description,$Enabled,$Primary, $CacheTimeout)
{
$t = $this->GetItem($ThemeId);
$t->Set(array("Name","Description","Enabled","PrimaryTheme","CacheTimeout"),
array($Name, $Description, $Enabled, $Primary, $CacheTimeout));
$t->Dirty();
$t->Update();
if($Primary==1)
{
$sql = "UPDATE ".$this->SourceTable." SET PrimaryTheme=0 WHERE ThemeId!=$ThemeId";
$this->adodbConnection->Execute($sql);
}
return $t;
}
function DeleteTheme($ThemeId)
{
$t = $this->GetItem($ThemeId);
$t->Delete();
}
function SetPrimaryTheme($ThemeId)
{
$theme = $this->GetItem($ThemeId);
$theme->Dirty();
if($theme->Get("Enabled")==1)
{
$sql = "UPDATE ".$this->SourceTable." SET PrimaryTheme=0";
$this->adodbConnection->Execute($sql);
$theme->Set("PrimaryTheme","1");
$theme->Update();
}
}
function GetPrimaryTheme($field="ThemeId")
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE PrimaryTheme=1";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$l = $rs->fields[$field];
}
else
$l = 0;
return $l;
}
function CreateMissingThemes()
{
global $objConfig,$pathchar, $pathtoroot;
$path = $pathtoroot."themes";
$themes = array();
if ($dir = @opendir($path))
{
while (($file = readdir($dir)) !== false)
{
if($file !="." && $file !=".." && substr($file,0,1)!="_")
{
if(is_dir($path."/".$file))
{
$file = strtolower($file);
$themes[$file]=0;
}
}
}
}
closedir($dir);
$this->Clear();
$this->Query_Item("SELECT * FROM ".$this->SourceTable);
foreach($this->Items as $i)
{
$n = strtolower($i->Get("Name"));
$themes[$n] = $i->Get("ThemeId");
}
$names = array_keys($themes);
for($i=0;$i<count($names);$i++)
{
$name = $names[$i];
$value = $themes[$name];
if($value==0)
{
$t = $this->AddTheme($name,"New Theme",0,0);
$themes[$name] = $t->Get("ThemeId");
}
}
$where = implode(",",array_values($themes));
$sql = "DELETE FROM ".$this->SourceTable." WHERE ThemeId NOT IN ($where)";
}
function CopyFromEditTable()
{
global $objSession;
$GLOBALS['_CopyFromEditTable']=1;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$idlist = array();
$sql = "SELECT * FROM $edit_table";
$this->Clear();
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = $this->AddItemFromArray($data);
$c->Dirty();
if($data["ThemeId"]>0)
{
$c->Update();
}
else
{
$c->UnsetIdField();
$c->Create();
$c->CreateDirectory();
}
if($c->Get("PrimaryTheme"))
{
$this->SetPrimaryTheme($c->Get("ThemeId"));
}
$rs->MoveNext();
}
$this->adodbConnection->Execute($sql);
unset($GLOBALS['_CopyFromEditTable']);
}
function PurgeEditTable()
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
}
}
?>
Property changes on: trunk/kernel/include/theme.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/config/addtheme.php
===================================================================
--- trunk/admin/config/addtheme.php (revision 765)
+++ trunk/admin/config/addtheme.php (revision 766)
@@ -1,244 +1,245 @@
<?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;
//print_r($_GET);
//print_r($_POST);
require_once($pathtoroot."kernel/startup.php");
//admin only util
/* set the destination of the image upload, relative to the root path */
$DestDir = "kernel/images/";
$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";
$browseURL = $adminURL."/browse";
$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/browse/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
$m = GetModuleArray();
foreach($m as $key=>$value)
{
$path = $pathtoroot. $value."admin/include/parser.php";
if(file_exists($path))
{
include_once($path);
}
}
unset($objEditItems);
$objEditItems = new clsThemeList();
$objEditItems->SourceTable = $objSession->GetEditTable("Theme");
$objEditItems->EnablePaging = FALSE;
if ($_GET["new"] == 1)
{
$c = new clsTheme(NULL);
$en = 0;
$action = "m_theme_add";
$name = prompt_language("la_Text_NewTheme");
$objThemes->CreateEmptyEditTable("ThemeId");
}
else
{
$en = (int)$_GET["en"];
if (isset($_POST["itemlist"]))
{
$objThemes->CopyToEditTable("ThemeId",$_POST["itemlist"]);
}
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
$itemcount=$objEditItems->NumItems();
$c = $objEditItems->GetItemByIndex($en);
if($itemcount>1)
{
if ($en+1 == $itemcount)
$en_next = -1;
else
$en_next = $en+1;
if ($en == 0)
$en_prev = -1;
else
$en_prev = $en-1;
}
$action = "m_theme_edit";
$name = $c->Get("Name");
}
$section = "in-portal:theme_general";
$envar = "env=".BuildEnv();
$title = GetTitle("la_Text_Theme", "la_tab_General", $c->Get('ThemeId'), $c->Get('Name'));//prompt_language("la_Text_Editing")." ".prompt_language("la_Text_Theme")." -'".$name."'";
//Display header
$sec = $objSections->GetSection($section);
$objCatToolBar = new clsToolBar();
$objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('theme','ThemeEditStatus','".$admin."/config/config_theme.php',1);","/toolbar/tool_select.gif");
$objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('theme','ThemeEditStatus','".$admin."/config/config_theme.php',2);",$imagesURL."/toolbar/tool_cancel.gif");
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl.$admin."/config/addtheme.php";
$StatusField = "ThemeEditStatus";
$form = "theme";
MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"));
$objCatToolBar->Add("divider");
}
int_header($objCatToolBar,NULL,$title);
+ $c->Data=inp_htmlize($c->Data);
?>
<FORM enctype="multipart/form-data" ID="theme" NAME="theme" method="POST" ACTION="">
<TABLE cellSpacing="0" cellPadding="2" width="100%" class="tableborder">
<?php int_subsection_title(prompt_language("la_tab_General")); ?>
<TR <?php int_table_color(); ?> >
<TD><?php echo prompt_language("la_prompt_ThemeId"); ?></TD>
<TD><?php echo $c->Get("ThemeId"); ?></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_name" CLASS="text"><?php echo prompt_language("la_prompt_Name"); ?></SPAN></TD>
<TD><input type=text ValidationType="exists" NAME="name" VALUE="<?php echo $c->Get("Name"); ?>"></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_description"><?php echo prompt_language("la_prompt_Description"); ?></SPAN></TD>
<TD><input type=text NAME="description" VALUE="<?php echo $c->Get("Description"); ?>"></TD>
<TD></TD>
</TR>
<tr <?php int_table_color(); ?>>
<td valign="top" class="text"><?php echo prompt_language("la_prompt_Enabled"); ?></td>
<td>
<input type="checkbox" name="enabled" class="text" value="1" <?php if($c->Get("Enabled") == 1) echo "checked"; ?>>
</td>
<td class="text"> </td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top" class="text"><?php echo prompt_language("la_prompt_lang_cache_timeout"); ?></td>
<td>
<input type=text NAME="CacheTimeout" VALUE="<?php echo $c->Get("CacheTimeout"); ?>">
</td>
<td class="text"> </td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top" class="text"><?php echo prompt_language("la_prompt_Primary"); ?></td>
<td>
<input type="checkbox" name="primary" class="text" value="1" <?php if($c->Get("PrimaryTheme") == 1) echo "checked"; ?>>
</td>
<td class="text"> </td>
<input type=hidden NAME="Action" VALUE="<?php echo $action; ?>">
<INPUT TYPE="hidden" NAME="ThemeId" VALUE="<?php echo $c->Get("ThemeId"); ?>">
<input TYPE="HIDDEN" NAME="DataType" VALUE="<?php echo $DataType; ?>">
<input type="hidden" name="ThemeEditStatus" VALUE="0">
</FORM>
</tr>
<FORM>
<TR <?php int_table_color(); ?> >
<td colspan="3">
</td>
</tr>
</FORM>
</TABLE>
<!-- CODE FOR VIEW MENU -->
<form method="post" action="user_groups.php?<?php echo $envar; ?>" name="viewmenu">
<input type="hidden" name="fieldname" value="">
<input type="hidden" name="varvalue" value="">
<input type="hidden" name="varvalue2" value="">
<input type="hidden" name="Action" value="">
</form>
<!-- END CODE-->
<?php int_footer(); ?>
Property changes on: trunk/admin/config/addtheme.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