Index: trunk/kernel/include/parseditem.php =================================================================== diff -u -N -r4446 -r6093 --- trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 4446) +++ trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 6093) @@ -7,7 +7,7 @@ function RegisterPrefix($class,$prefix,$file) { global $ItemTypePrefixes, $ItemTagFiles; - + $ItemTypePrefixes[$class] = $prefix; $ItemTagFiles[$prefix] = $file; } @@ -16,7 +16,7 @@ { var $TagPrefix; var $Parser; - var $AdminParser; + var $AdminParser; function clsParsedItem($id=NULL) { @@ -26,7 +26,7 @@ $this->Parser = new clsTemplateList($TemplateRoot); $this->AdminParser = new clsAdminTemplateList(); } - + /* function ParseObject($element) { $extra_attribs = ExtraAttributes($element->attributes); @@ -42,12 +42,12 @@ function ParseTimeStamp($d,$attribs=array()) { global $objSession; - + if (isset($attribs['_tz'])) { $timezone = $attribs['_tz'] == 'auto' ? null : $objSession->Get('tz'); $d = GetLocalTime($d, $timezone); } - + $part = isset($attribs['_part']) ? strtolower($attribs['_part']) : ''; if ($part) { $ret = ExtractDatePart($part,$d); @@ -57,23 +57,23 @@ } return $ret; } - + function ParseObject($element) { global $objConfig, $objCatList, $var_list_update, $var_list, $n_var_list_update, $m_var_list_update; $extra_attribs = ExtraAttributes($element->attributes); $ret = ""; - + if ($this->TagPrefix == "email" && strtolower($element->name) == "touser") { - $this->TagPrefix = "touser"; + $this->TagPrefix = "touser"; } - + if(strtolower($element->name)==$this->TagPrefix) { $field = strtolower($element->attributes["_field"]); switch($field) - { + { case 'primarycategorylink': $m_var_list_update['cat'] = (int)$this->GetPrimaryCategory(); $m_var_list_update['p'] = 1; @@ -82,57 +82,61 @@ unset($m_var_list_update['p']); return $ret; break; - + case 'primarycategory': $db =& GetADODBConnection(); - $sql = 'SELECT CachedNavbar FROM '.$objCatList->SourceTable.' WHERE CategoryId = '.(int)$this->GetPrimaryCategory(); + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + + $sql = 'SELECT '.$ml_formatter->LangFieldName('CachedNavbar').' FROM '.$objCatList->SourceTable.' WHERE CategoryId = '.(int)$this->GetPrimaryCategory(); $ret = prompt_language($objConfig->Get("Root_Name")); - if( $this->GetPrimaryCategory() ) $ret .= '>'.$db->GetOne($sql); + if ($this->GetPrimaryCategory()) { + $ret .= ' > '.str_replace('&|&', ' > ', $db->GetOne($sql)); + } break; - + case "id": $ret = $this->Get($this->id_field); - break; + break; case "resourceid": if(!$this->NoResourceId) $ret = $this->Get("ResourceId"); - break; + break; case "category": $c = $objCatList->GetItem($this->Get("CategoryId")); if(is_object($c)) { $ret = $c->parsetag($element->attributes["_cattag"]); } - break; + break; case "priority": if($this->Get("Priority")!=0) - { + { $ret = (int)$this->Get("Priority"); } else $ret = ""; - break; + break; case "link": /* if(method_exists($this,"ItemURL")) - { - $ret = $this->ItemURL($element->attributes["_template"],FALSE,""); + { + $ret = $this->ItemURL($element->attributes["_template"],FALSE,""); } break; */ case "cat_link": if(method_exists($this,"ItemURL")) { - $ret = $this->ItemURL($element->attributes["_template"],TRUE,""); - } + $ret = $this->ItemURL($element->attributes["_template"],TRUE,""); + } break; - case "fullpath": - $ret = $this->Get("CachedNavbar"); + case "fullpath": + $ret = str_replace('&|&', ' > ', $this->Get("CachedNavbar")); if(!strlen($ret)) { if(is_numeric($this->Get("CategoryId"))) { $c = $objCatList->GetItem($this->Get("CategoryId")); if(is_object($c)) - $ret = $c->Get("CachedNavbar"); + $ret = $c->GetNavBar(); } else { @@ -141,34 +145,34 @@ $cat = $this->GetPrimaryCategory(); $c = $objCatList->GetItem($cat); if(is_object($c)) - $ret = $c->Get("CachedNavbar"); + $ret = $c->GetNavBar(); } } } // $ret = $this->HighlightText($ret); - break; - - case "relevance": - $style = $element->attributes["_displaymode"]; + break; + + case "relevance": + $style = $element->attributes["_displaymode"]; if(!strlen($style)) $style = "numerical"; switch ($style) - { - case "numerical": + { + case "numerical": $ret = (100 * LangNumber($this->Get("Relevance"),1))."%"; - break; - case "bar": + break; + case "bar": $OffColor = $element->attributes["_offbackgroundcolor"]; $OnColor = $element->attributes["_onbackgroundcolor"]; $percentsOff = (int)(100 - (100 * $this->Get("Relevance"))); if ($percentsOff) { $percentsOn = 100 - $percentsOff; - $ret = ""; + $ret = ""; } else - $ret = ""; - break; - case "graphical": + $ret = ""; + break; + case "graphical": $OnImage = $element->attributes["_onimage"]; if (!strlen($OnImage)) break; @@ -178,24 +182,24 @@ unset($image_data[count($image_data)-1]); $rel = (10 * LangNumber($this->Get("Relevance"),1)); $OnImage1 = join(".", $image_data); - + if ($rel) - $img_src = $OnImage1."_".$rel.".".$image_ext; + $img_src = $OnImage1."_".$rel.".".$image_ext; else $img_src = $OnImage; - + $ret = "\"".(10*$rel)."\""; break; - } - + } + break; - + case "rating": $style = $element->GetAttributeByName("_displaymode"); if(!strlen($style)) - $style = "numerical"; + $style = "numerical"; switch($style) - { + { case "numerical": $ret = LangNumber($this->Get("CachedRating"),1); break; @@ -206,12 +210,12 @@ $OnImage = $element->attributes["_onimage"]; $OffImage = $element->attributes["_offimage"]; $images = RatingTickImage($this->Get("CachedRating"),$OnImage,$OffImage); - + for($i=1;$i<=count($images);$i++) { $url = $images[$i]; if(strlen($url)) - { + { $ret .= ""; $ret .= $element->GetAttributeByName('_separator'); } @@ -221,39 +225,39 @@ break; case "reviews": $today = FALSE; - + if(method_exists($this,"ReviewCount")) - { + { if($element->GetAttributeByName("_today")) - $today = TRUE; + $today = TRUE; $ret = $this->ReviewCount($today); - $ret = ($element->GetAttributeByName("_dataexists") && empty($ret))? "" : $ret; + $ret = ($element->GetAttributeByName("_dataexists") && empty($ret))? "" : $ret; } else $ret = ""; - + break; case "votes": $ret = (int)$this->Get("CachedVotesQty"); - break; + break; case "favorite": if(method_exists($this,"IsFavorite")) - { + { if($this->IsFavorite()) { $ret = $element->attributes["_label"]; if(!strlen($ret)) $ret = "lu_favorite"; - $ret = language($ret); + $ret = language($ret); } else $ret = ""; } - break; + break; case "new": if(method_exists($this,"IsNewItem")) - { + { if($this->IsNewItem()) { $ret = $element->GetAttributeByName('_label'); @@ -267,7 +271,7 @@ break; case "pop": if(method_exists($this,"IsPopItem")) - { + { if($this->IsPopItem()) { $ret = $element->GetAttributeByName('_label'); @@ -303,7 +307,7 @@ } else $ret = ""; - break; + break; case "admin_icon": if(method_exists($this,"StatusIcon")) { @@ -314,7 +318,7 @@ else $ret = $this->StatusIcon(); } - break; + break; case "custom": if(method_exists($this,"GetCustomFieldValue")) { @@ -324,11 +328,11 @@ if (strlen($field)) $ret = $this->GetCustomFieldValue($field, $default, $listvalue); } - break; + break; case "image": $default = $element->attributes["_primary"]; $name = $element->attributes["_name"]; - + if(strlen($name)) { $img = $this->GetImageByName($name); @@ -338,10 +342,10 @@ if($default) $img = $this->GetDefaultImage(); } - + if(is_object($img)) { - + if(strlen($element->attributes["_imagetemplate"])) { $ret = $img->ParseTemplate($element->attributes["_imagetemplate"]); @@ -350,18 +354,18 @@ else { if($element->attributes["_thumbnail"]) - { + { $url = $img->parsetag("thumb_url"); } else { - + if(!$element->attributes["_nothumbnail"]) { - $url = $img->parsetag("image_url"); + $url = $img->parsetag("image_url"); } else - { + { $url = $img->FullURL(TRUE,""); } } @@ -370,7 +374,7 @@ else { $url = $element->attributes["_defaulturl"]; - + } if($element->attributes["_imagetag"]) @@ -394,14 +398,14 @@ $ret = "Undefined:".$element->name; break; } - + } else if ($this->TagPrefix == 'email'){ $ret = "Undefined:".$element->name; } return $ret; } - + function ParseString($name) { $el = new clsHtmlTag(); @@ -451,17 +455,17 @@ $tag->inner_html = $inner_html; if($tag->parsed) - { + { if($tag->name=="include" || $tag->name=="perm_include" || $tag->name=="lang_include") { $output = $this->Parser->IncludeTemplate($tag); } else - { - $output = $this->ParseObject($tag); + { + $output = $this->ParseObject($tag); //echo $output."
"; if(substr($output,0,9)=="Undefined") - { + { $output = $tag->Execute(); // if(substr($output,0,8)="{Unknown") // $output = $raw; @@ -530,7 +534,7 @@ if ($TagNameEnd) { $Tag = strtolower(substr($html, $next_tag, $TagNameEnd-$next_tag)); - $TagName = explode(":", $Tag); + $TagName = explode(":", $Tag); if (strlen($TagName[1])) $CloserTag = ""; } @@ -573,7 +577,7 @@ function ParseTemplate($tname) { global $objTemplate, $LogLevel,$ptime,$timestart; - + //echo 'Saving ID'.$this->UniqueId().' in Main parseTempalate
'; //$GLOBALS[$this->TagPrefix.'_ID'] = $this->UniqueId(); LogEntry("Parsing $tname\n"); @@ -601,7 +605,7 @@ } return $html; } - + function SendUserEventMail($EventName,$ToUserId,$LangId=NULL,$RecptName=NULL) { global $objMessageList,$FrontEnd; @@ -612,9 +616,9 @@ { if($Event->Get("Enabled")=="1" || ($Event->Get("Enabled")==2 && $FrontEnd)) { - $Event->Item = $this; + $Event->Item = $this; if(is_numeric($ToUserId)) - { + { return $Event->SendToUser($ToUserId); } else @@ -643,7 +647,7 @@ function parse_template($t) { } - + } class clsItemCollection @@ -661,74 +665,74 @@ var $id_field = null; // id field for list item var $BasePermission; var $Dummy = null; - + // enshure that same sql won't be queried twice var $QueryDone = false; var $LastQuerySQL = ''; - + var $Prefix = ''; var $Special = ''; - + /** * Application object * * @var kApplication */ var $Application = null; - + /** * Connection to database * * @var kDBConnection */ var $Conn = null; - + function isLiveTable() { global $objSession; return !preg_match('/'.GetTablePrefix().'ses_'.$objSession->GetSessionKey().'_edit_(.*)/', $this->SourceTable); } - + function SetTable($action, $table_name = null) // new by Alex { // $action = {'live', 'restore','edit'} switch($action) { - case 'live': + case 'live': $this->LiveTable = $table_name; $this->SourceTable = $this->LiveTable; break; - case 'restore': - $this->SourceTable = $this->LiveTable; + case 'restore': + $this->SourceTable = $this->LiveTable; break; case 'edit': global $objSession; $this->SourceTable = $objSession->GetEditTable($this->LiveTable); break; } } - + function &GetDummy() // new by Alex { if( !isset($this->Dummy) ) $this->Dummy =& new $this->classname(); - $this->Dummy->tablename = $this->SourceTable; + $this->Dummy->tablename = $this->SourceTable; return $this->Dummy; } - + function clsItemCollection() { if (class_exists('kApplication')) { // just in case when aplication is not found - $this->Application =& kApplication::Instance(); + $this->Application =& kApplication::Instance(); $this->Conn =& $this->Application->GetADODBConnection(); } - + $this->adodbConnection =& GetADODBConnection(); - + $this->Clear(); $this->BasePermission = ''; - } + } function GetIDField() // new by Alex { @@ -745,12 +749,12 @@ { return new $this->classname(); } - + function Clear() { unset($this->Items); $this->Items = array(); - $this->CurrentItem=0; + $this->CurrentItem=0; } function &SetCurrentItem($id) @@ -779,7 +783,7 @@ else return 0; } - + function ItemLike($index, $string) { // check if any of the item field @@ -796,42 +800,42 @@ } return $found; } - + function DeleteItem($index) // by Alex { // deletes item with specific index from list $i = $index; $item_count = $this->NumItems(); while($i < $item_count - 1) { $this->Items[$i] = $this->Items[$i + 1]; - $i++; + $i++; } unset($this->Items[$i]); } - + function ShowItems() { $i = 0; $item_count = $this->NumItems(); while($i < $item_count) { echo "Item No $i:
"; $this->Items[$i]->PrintVars(); - $i++; + $i++; } } - + function SwapItems($Index,$Index2) { $temp = $this->Items[$Index]->GetData(); $this->Items[$Index]->SetData($this->Items[$Index2]->GetData()); $this->Items[$Index2]->SetData($temp); - + } - + function CopyResource($OldId,$NewId, $main_prefix) { $this->Clear(); - + $sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$OldId"; $this->Query_Item($sql); // echo $sql."
\n"; @@ -845,20 +849,20 @@ } } } - + function ItemsOnClipboard() { global $objSession; $clip = $objSession->GetPersistantVariable("ClipBoard"); $count = 0; $table = $this->SourceTable; $prefix = GetTablePrefix(); - - + + if(substr($table,0,strlen($prefix))==$prefix) $table = substr($table,strlen($prefix)); - + if(strlen($clip)) { $clipboard = ParseClipboard($clip); @@ -874,7 +878,7 @@ return $count; } - + function CopyToClipboard($command,$idfield, $idlist) { global $objSession,$objCatList; @@ -886,14 +890,14 @@ else $list = $idlist; $clip = $command."-".$objCatList->CurrentCategoryID().".".$this->SourceTable.".$idfield=".$list; - + $objSession->SetVariable("ClipBoard",$clip); } - + function SortItems($asc=TRUE) { $done = FALSE; - + $field = $this->SortField; $ItemCount = $this->NumItems(); while(!$done) @@ -903,16 +907,16 @@ { $doswap = FALSE; if($asc) - { - $val1 = $this->Items[$i-1]->Get($field); + { + $val1 = $this->Items[$i-1]->Get($field); $val2 = $this->Items[$i]->Get($field); - $doswap = ($val1 > $val2); + $doswap = ($val1 > $val2); } else { $val1 = $this->Items[$i-1]->Get($field); - $val2 = $this->Items[$i]->Get($field); - $doswap = ($val1 < $val2); + $val2 = $this->Items[$i]->Get($field); + $doswap = ($val1 < $val2); } if($doswap) { @@ -934,17 +938,17 @@ { $i =& $this->GetItemRefByIndex($x); if($i->UniqueID()==$ID) - { + { $found=TRUE; break; } } } - + if(!$found) { if($LoadFromDB) - { + { $n = NULL; $n = new $this->classname(); $n->tablename = $this->SourceTable; @@ -1024,13 +1028,13 @@ } function GetNumPages($ItemsPerPage) - { + { if( isset($_GET['reset']) && $_GET['reset'] == 1) $this->Page = 1; return GetPageCount($ItemsPerPage,$this->QueryItemCount); } function &AddItemFromArray($data, $clean=FALSE) - { + { $class = new $this->classname; $class->SetFromArray($data); $class->tablename = $this->SourceTable; @@ -1042,8 +1046,8 @@ } function Query_Item($sql, $offset=-1,$rows=-1) - { - global $Errors, $objConfig; + { + global $Errors, $objConfig; //echo "Method QItem [".get_class($this).'], sql: ['.$sql.']
'; $dummy =& $this->GetDummy(); if( !$dummy->TableExists() ) @@ -1060,21 +1064,21 @@ //echo "Executing SelectLimit $sql Offset: $offset,$rows
\n"; $result = $this->adodbConnection->SelectLimit($sql, $rows,$offset); } - else { + else { $result = $this->adodbConnection->Execute($sql); } - + if ($result === false) { $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Query_Item"); if($this->debuglevel) { echo '

'.$sql.'

'; - echo "Error: ".$this->adodbConnection->ErrorMsg()."
"; + echo "Error: ".$this->adodbConnection->ErrorMsg()."
"; } $this->Clear(); return false; } - + $this->Clear(); if($this->debuglevel > 0) @@ -1089,12 +1093,12 @@ //echo "SQL: $sql

"; LogEntry("SQL Loop Start\n"); $count = 0; - + while ($result && !$result->EOF) { $count++; $data = $result->fields; - $this->AddItemFromArray($data,TRUE); + $this->AddItemFromArray($data,TRUE); if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 ) adodb_movenext($result); else @@ -1115,23 +1119,23 @@ $TableName = $this->SourceTable."."; } else - $TableName = ""; + $TableName = ""; $PriorityClause = $TableName."EditorsPick DESC, ".$TableName."Priority DESC"; - + if(strlen(trim($FieldVar))>0) { if(is_object($objSession)) { - if(strlen($objSession->GetPersistantVariable($FieldVar))>0) - { - $OrderBy = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". + if(strlen($objSession->GetPersistantVariable($FieldVar))>0) + { + $OrderBy = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". $objSession->GetPersistantVariable($OrderVar)); - $FieldUsed = $objSession->GetPersistantVariable($FieldVar); + $FieldUsed = $objSession->GetPersistantVariable($FieldVar); } - } + } $OrderBy = trim($OrderBy); - if (strlen(trim($OrderBy))==0) + if (strlen(trim($OrderBy))==0) { if(!$UseTableName) { @@ -1143,20 +1147,20 @@ { $OrderBy = $this->SourceTable.".".$DefaultField.".".$DefaultVar; } - $FieldUsed=$DefaultField; + $FieldUsed=$DefaultField; } } - } + } if(($FieldUsed != "Priority" || strlen($OrderBy)==0) && $Priority==TRUE) { if(strlen($OrderBy)==0) { $OrderBy = $PriorityClause; } - else + else $OrderBy = $PriorityClause.", ".$OrderBy; } - return $OrderBy; + return $OrderBy; } function GetResourceIDList() @@ -1192,9 +1196,9 @@ $this->Clear(); $this->Query_Item($sql); if($this->NumItems()>0) - { + { foreach($this->Items as $i) - { + { $i->DeleteCategoryItems($CatId,$CatTable); } } @@ -1203,7 +1207,7 @@ function CopyToEditTable($idfield = null, $idlist = 0) { global $objSession; - + if($idfield == null) $idfield = $this->GetIDField(); $edit_table = $objSession->GetEditTable($this->SourceTable); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); @@ -1221,14 +1225,14 @@ } function CreateEmptyEditTable($idfield = null) - { + { global $objSession; if($idfield == null) $idfield = $this->GetIDField(); - + $edit_table = $objSession->GetEditTable($this->SourceTable); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); $query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield = -1"; - $insert = "CREATE TABLE ".$edit_table." ".$query; + $insert = "CREATE TABLE ".$edit_table." ".$query; if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($insert,ENT_NOQUOTES)."
\n"; $this->adodbConnection->Execute($insert); @@ -1242,18 +1246,18 @@ $dropRelTableFlag = false; if($idfield == null) $idfield = $this->GetIDField(); - $edit_table = $objSession->GetEditTable($this->SourceTable); + $edit_table = $objSession->GetEditTable($this->SourceTable); $sql = "SELECT * FROM $edit_table"; $rs = $this->adodbConnection->Execute($sql); - + $item_ids = Array(); while ($rs && !$rs->EOF) { - $data = $rs->fields; + $data = $rs->fields; $c = new $this->classname; $c->SetFromArray($data); $c->idfield = $idfield; $c->Dirty(); - + if($c->Get($idfield) < 1) { $old_id = $c->Get($idfield); @@ -1271,22 +1275,22 @@ $org->DeleteCustomData(); $org->Delete(TRUE); $c->Set("OrgId",0); - } - } + } + } $c->Create(); } $item_ids[] = $c->UniqueId(); // save item id for future use if(is_numeric($c->Get("ResourceId"))) - { + { if( isset($c->Related) && is_object($c->Related) ) - { - $r = $c->Related; + { + $r = $c->Related; $r->CopyFromEditTable($c->Get("ResourceId")); $dropRelTableFlag = true; - } - + } + unset($r); - + if( isset($c->Reviews) && is_object($c->Reviews) ) { $r = $c->Reviews; @@ -1306,9 +1310,9 @@ $org->DeleteCustomData(); $org->Delete(TRUE); $c->Set("OrgId",0); - } - } - + } + } + $GLOBALS['_CopyFromEditTable']=1; if(method_exists($c,"CategoryMemberList")) { @@ -1323,38 +1327,38 @@ unset($c); unset($r); - + $rs->MoveNext(); } - + $objReviews = new clsItemReviewList(); $objReviews->PurgeEditTable(); - + if ($dropRelTableFlag) { - $objRelGlobal = new clsRelationshipList(); + $objRelGlobal = new clsRelationshipList(); $objRelGlobal->PurgeEditTable(); } - - if($edit_table) @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); + + if($edit_table) @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$objSession->GetEditTable("CategoryItems")); unset($GLOBALS['_CopyFromEditTable']); - + return $item_ids; } - + function GetNextTempID() { // get next temporary id (lower then zero) from temp table $db =& $this->adodbConnection; $sql = 'SELECT MIN(%s) AS MinValue FROM %s'; return $db->GetOne( sprintf($sql, $this->GetIDField(), $this->SourceTable) ) - 1; } - + function PurgeEditTable($idfield = null) { global $objSession; - + if($idfield == null) $idfield = $this->GetIDField(); $edit_table = $objSession->GetEditTable($this->SourceTable); /* $rs = $this->adodbConnection->Execute("SELECT * FROM $edit_table"); @@ -1375,7 +1379,7 @@ function CopyCatListToEditTable($idfield, $idlist) { global $objSession; - + $edit_table = $objSession->GetEditTable("CategoryItems"); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); if(is_array($idlist)) @@ -1385,32 +1389,32 @@ else $list = $idlist; $query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield IN ($list)"; - + $insert = "CREATE TABLE ".$edit_table." ".$query; if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($insert,ENT_NOQUOTES)."
\n"; $this->adodbConnection->Execute($insert); } - + function CreateEmptyCatListTable($idfield) { global $objSession; - + $edit_table = $objSession->GetEditTable("CategoryItems"); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); $query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield = -1"; $insert = "CREATE TABLE ".$edit_table." ".$query; if($objSession->HasSystemPermission("DEBUG.LIST")) - echo htmlentities($insert,ENT_NOQUOTES)."
\n"; + echo htmlentities($insert,ENT_NOQUOTES)."
\n"; $this->adodbConnection->Execute($insert); } - + function RefreshPage($page_var, $total_items) { global $objConfig, $objSession; - + $this->QueryItemCount = $total_items; - + if ( (int)GetVar('lpn') > 0) { $this->Page = $_GET['lpn']; @@ -1419,21 +1423,21 @@ { $this->Page = $objConfig->Get($page_var); } - + if ( ($this->Page > $this->GetNumPages($this->PerPage) || $this->Page == 0) && ($this->PerPage != -1) ) { - $this->Page = 1; + $this->Page = 1; } - + $objSession->SetVariable($page_var, $this->Page); } - + function PurgeCatListEditTable() { global $objSession; - + $edit_table = $objSession->GetEditTable("CategoryItems"); - $this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); + $this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); } function AdminSearchWhereClause($SearchList) @@ -1449,12 +1453,12 @@ $SearchList=$SearchListTmp; if( !count($SearchList) || !count($this->AdminSearchFields) ) return ''; - + for($f = 0; $f < count($SearchList); $f++) - { + { $value = $SearchList[$f]; if( strlen($value) ) - { + { $inner_sql = ""; for($i = 0; $i < count($this->AdminSearchFields); $i++) { @@ -1467,7 +1471,7 @@ } if( strlen($inner_sql) ) { - $sql .= '('.$inner_sql.') '; + $sql .= '('.$inner_sql.') '; if($f < count($SearchList) - 1) $sql .= " AND "; } } @@ -1495,7 +1499,7 @@ $this->Clear(); } } - + function RestoreData($InFileName,$Start,$Limit) { $res = -1; @@ -1511,29 +1515,29 @@ $Line++; } $res = ftell($fp); - fclose($fp); + fclose($fp); } return $res; } - + function Delete_Item($Id, $DetectCategories = false) { global $objCatList; - + $l =& $this->GetItem($Id); $l->BasePermission=$this->BasePermission; - + if (!$DetectCategories) { - $l->DeleteCategoryItems($objCatList->CurrentCategoryID()); + $l->DeleteCategoryItems($objCatList->CurrentCategoryID()); } else { $l->RemoveFromAllCategories(); $l->Delete(); } } - + function Move_Item($Id, $OldCat, $ParentTo) - { + { global $objCatList; $l = $this->GetItem($Id); @@ -1543,15 +1547,15 @@ } function Copy_Item($Id, $ParentTo) - { + { $l = $this->GetItem($Id); $l->BasePermission=$this->BasePermission; $l->AddtoCategory($ParentTo); - } - + } + }/* clsItemCollection */ -class clsItemList extends clsItemCollection +class clsItemList extends clsItemCollection { var $Page; var $PerPageVar; @@ -1561,23 +1565,23 @@ var $PageEnvar; var $PageEnvarIndex; var $ListType; - + var $LastLimitClause = ''; // used to store last limit cluse used in query - + function setPageFromENV() { $this->Page=$GLOBALS[$this->PageEnvar][$this->PageEnvarIndex]; } - + function clsItemList() { $this->clsItemCollection(); - $this->EnablePaging = TRUE; - $this->PageEnvarIndex = "p"; + $this->EnablePaging = TRUE; + $this->PageEnvarIndex = "p"; } - + function GetPageLimitSQL() - { + { global $objConfig; $limit = NULL; if($this->EnablePaging) @@ -1591,34 +1595,34 @@ $limit = "LIMIT ".$Start.",".$objConfig->Get($this->PerPageVar); } else - $limit = NULL; + $limit = NULL; } - else + else { if($this->MaxListCount) { $limit = 'LIMIT 0, '.$this->MaxListCount; } } return $limit; - } - + } + function GetPageOffset() { $Start = 0; if($this->EnablePaging) - { + { if($this->Page < 1) $this->Page = 1; $PerPage = $this->GetPerPage(); $Start = ($this->Page - 1) * $PerPage; } - else - { + else + { if((int)$this->MaxListCount == 0) $Start = -1; } return $Start; } - + function GetPageRowCount() { if($this->EnablePaging) @@ -1627,10 +1631,10 @@ //echo "Got PerPage: ".$this->GetPerPage()."
"; return $this->GetPerPage(); } - else + else return (int)$this->MaxListCount; - } - + } + function Query_Item($sql,$limit = null, $fix_method = 'set_first') { // query itemlist (module items) using $sql specified @@ -1641,22 +1645,22 @@ $sql .= " ".$limit; return parent::Query_Item($sql); } - else - { + else + { //echo "page fix pre (class: ".get_class($this).")
"; $this->QueryItemCount = QueryCount($sql); // must get total item count before fixing - + $this->FixInvalidPage($fix_method); - + // specially made for cats delete if ( GetVar('Action', true) != 'm_cat_delete') { - return parent::Query_Item($sql,$this->GetPageOffset(),$this->GetPageRowCount()); + return parent::Query_Item($sql,$this->GetPageOffset(),$this->GetPageRowCount()); } - else { + else { return parent::Query_Item($sql); } } - } + } function Query_List($whereClause,$orderByClause=NULL,$JoinCats=TRUE,$fix_method='set_first') { @@ -1665,7 +1669,7 @@ if($JoinCats) { $cattable = GetTablePrefix()."CategoryItems"; - $t = $this->SourceTable; + $t = $this->SourceTable; $sql = "SELECT *,CategoryId FROM $t INNER JOIN $cattable ON $cattable.ItemResourceId=$t.ResourceId"; } else @@ -1681,20 +1685,20 @@ { $sql .= " ".$orderByClause; } - else + else { $sql .= " ORDER BY $orderByClause"; } } if($objSession->HasSystemPermission("DEBUG.LIST")) echo $sql."
\n"; - + return $this->Query_Item($sql, null, $fix_method); - } - + } + function GetPerPage() - { + { //echo "Getting Per Page ".get_class($this)."
"; // return category perpage global $objConfig; @@ -1704,7 +1708,7 @@ //echo "Returning: $PerPage
"; return $PerPage; } - + /** * Returns current page from env var * @@ -1715,68 +1719,68 @@ $var_name = preg_replace('/(.*)_update$/', '\\1', $this->PageEnvar); return $GLOBALS[$var_name]['p']; } - + function FixInvalidPage($fix_method = 'set_first') { // in case if current page > total page count, // then set current page to last possible "set_last" // or first possible "set_first" $PerPage = $this->GetPerPage(); $NumPages = ceil( $this->GetNumPages($PerPage) ); -/* +/* echo "=====
"; echo "Class ".get_class($this).": Page ".$this->Page." of $NumPages
"; echo "PerPage: $PerPage
"; echo "Items Queries: ".$this->QueryItemCount."
"; echo "=====
"; -*/ +*/ // if ( $this->getEnvPage() ) $fix_method = 'set_current'; - + if( ($this->Page > $NumPages || $this->Page == 0) && $PerPage != -1) { switch($fix_method) { - case 'set_first': - $this->Page = 1; - //echo "Move 2 First (class ".get_class($this).")
"; + case 'set_first': + $this->Page = 1; + //echo "Move 2 First (class ".get_class($this).")
"; break; - case 'set_last': - $this->Page = $NumPages; - //echo "Move 2 Last (class ".get_class($this).")
"; + case 'set_last': + $this->Page = $NumPages; + //echo "Move 2 Last (class ".get_class($this).")
"; break; case 'set_current': $this->Page = $this->getEnvPage(); - //echo "Move 2 Page reflected in env (class ".get_class($this).")
"; + //echo "Move 2 Page reflected in env (class ".get_class($this).")
"; break; } $this->SaveNewPage(); } } - + function SaveNewPage() { - // redefine in each list, should save to env array new page value - + // redefine in each list, should save to env array new page value + } - + function GetPageLinkList($dest_template=NULL,$page = "",$PagesToList=10, $HideEmpty=TRUE,$EnvSuffix = '', $extra_attributes = '') { global $objConfig, $var_list_update, $var_list; $url_params = $EnvSuffix ? ExtractParams($EnvSuffix) : Array(); - + $v= $this->PageEnvar; - - global ${$v}; - + + global ${$v}; + // if(!strlen($page)) $page = GetIndexURL(2); $PerPage = $objConfig->Get($this->PerPageVar); if($PerPage < 1) $PerPage = 20; $NumPages = ceil( $this->GetNumPages($PerPage) ); if($NumPages == 1 && $HideEmpty) return ''; - + $var_list_update['t'] = isset($dest_template) && $dest_template ? $dest_template : $var_list['t']; $o = ''; @@ -1798,7 +1802,7 @@ if($StartPage > 1) { ${$v}[$this->PageEnvarIndex] = $this->Page - $PagesToList; - + $prev_url = HREF_Wrapper('', $url_params); $o .= '<<'; } @@ -1825,24 +1829,24 @@ } unset(${$v}[$this->PageEnvarIndex],$var_list_update["t"] ); return $o; - } - + } + function GetAdminPageLinkList($url) { global $objConfig; - + $update =& $GLOBALS[$this->PageEnvar]; // env_var_update - + $page_backup = $update[$this->PageEnvarIndex]; - + // insteresting stuff :) if(!$this->PerPageVar) $this->PerPageVar = "Perpage_Links"; $PerPage = $objConfig->Get($this->PerPageVar); if($PerPage < 1) $PerPage = 20; - + $NumPages = ceil($this->GetNumPages($PerPage)); - + //echo $this->CurrentPage." of ".$NumPages." Pages"; if($this->Page > $NumPages) $this->Page = $NumPages; @@ -1851,7 +1855,7 @@ if($StartPage < 1) $StartPage = 1; $EndPage = $StartPage + 9; if($EndPage > $NumPages) - { + { $EndPage = $NumPages; $StartPage = $EndPage-9; if($StartPage < 1) $StartPage = 1; @@ -1866,7 +1870,7 @@ $o .= '<<'; } - + for($p = $StartPage; $p <= $EndPage; $p++) { if($p != $this->Page) @@ -1887,8 +1891,8 @@ $o .= ' >>'; } $update[$this->PageEnvarIndex] = $page_backup; - return $o; - } + return $o; + } } function ParseClipboard($clip) @@ -1901,7 +1905,7 @@ $prefix = GetTablePrefix(); if(substr($table,0,strlen($prefix))==$prefix) $table = substr($table,strlen($prefix)); - + $subparts = explode("=",$parts[2],2); $idfield = $subparts[0]; $idlist = $subparts[1]; @@ -1918,7 +1922,7 @@ function UpdateCategoryItems($item,$NewCatList,$PrimaryCatId = false) { global $objCatList; - + $CurrentList = explode(",",$item->CategoryMemberList()); $del_list = array(); $ins_list = array(); @@ -1928,7 +1932,7 @@ { if(strlen(trim($NewCatList))==0) $NewCatList = $objCatList->CurrentCategoryID(); - + $NewCatList = explode(",",$NewCatList); } //print_r($NewCatList); @@ -1952,28 +1956,28 @@ } for($i=0;$iRemoveFromCategory($cat); } if($PrimaryCatId !== false) $item->SetPrimaryCategory($PrimaryCatId); } -class clsCatItemList extends clsItemList +class clsCatItemList extends clsItemList { var $PerPageVarLong; var $PerPageShortVar; var $Query_SortField; var $Query_SortOrder; var $ItemType; - + function clsCatItemList() { $this->ClsItemList(); $this->Query_SortField = array(); $this->Query_SortOrder = array(); - } - - function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE) + } + + function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE) { global $objSession; @@ -2002,7 +2006,7 @@ { $FieldVar = $this->Query_SortField[$x]; $OrderVar = $this->Query_SortOrder[$x]; - + if(is_object($objSession)) { $FieldVarData = $objSession->GetPersistantVariable($FieldVar); @@ -2025,7 +2029,7 @@ //echo "ORDER BY: $OrderBy
"; return $OrderBy; } - + function AddSortField($SortField, $SortOrder) { if(strlen($SortField)) @@ -2034,38 +2038,38 @@ $this->Query_SortOrder[] = $SortOrder; } } - + function ClearSortFields() { $this->Query_SortField = array(); $this->Query_SortOrder = array(); } - + /* skeletons in this closet */ - + function GetNewValue($CatId=NULL) { return 0; } - + function GetPopValue($CategoryId=NULL) { return 0; - } - + } + /* end of skeletons */ - + function GetCountSQL($PermName,$CatId=NULL, $GroupId=NULL, $AdditonalWhere="") { global $objSession, $objPermissions, $objCatList; - + $ltable = $this->SourceTable; $acl = $objSession->GetACLClause(); $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; - $ptable = GetTablePrefix()."PermCache"; + $ptable = GetTablePrefix()."PermCache"; $VIEW = $objPermissions->GetPermId($PermName); - + $sql = "SELECT count(*) as CacheVal FROM $ltable "; $sql .="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) "; $sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) "; @@ -2075,39 +2079,39 @@ if(strlen($AdditonalWhere)>0) { $sql .= "AND (".$AdditonalWhere.")"; - } - + } + return $sql; } - + function SqlCategoryList($attribs = array()) - { + { $CatTable = GetTablePrefix()."CategoryItems"; $t = $this->SourceTable; - + $sql = "SELECT *,$CatTable.CategoryId FROM $t INNER JOIN $CatTable ON $CatTable.ItemResourceId=$t.ResourceId "; $sql .="WHERE ($CatTable.CategoryId=".$catid." AND $t.Status=1)"; - + return $sql; } - - + + function CategoryCount($attribs=array()) - { + { global $objCatList, $objCountCache; - + $cat = $attribs["_catid"]; if(!is_numeric($cat)) { $cat = $objCatList->CurrentCategoryID(); } if((int)$cat>0) - $c = $objCatList->GetCategory($cat); - + $c = $objCatList->GetCategory($cat); + $CatTable = GetTablePrefix()."CategoryItems"; $t = $this->SourceTable; - - $sql = "SELECT count(*) as MyCount FROM $t INNER JOIN $CatTable ON ($CatTable.ItemResourceId=$t.ResourceId) "; + + $sql = "SELECT count(*) as MyCount FROM $t INNER JOIN $CatTable ON ($CatTable.ItemResourceId=$t.ResourceId) "; if($attribs["_subcats"]) { $ctable = $objCatList->SourceTable; @@ -2121,12 +2125,12 @@ $sql .=") AND ($t.Status=1)"; } else - $sql .="WHERE ($CatTable.CategoryId=".$cat." AND $t.Status=1) "; - + $sql .="WHERE ($CatTable.CategoryId=".$cat." AND $t.Status=1) "; + if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - $sql .= "AND ($t.CreatedOn>=$today) "; + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $sql .= "AND ($t.CreatedOn>=$today) "; } //echo $sql."

\n"; $rs = $this->adodbConnection->Execute($sql); @@ -2135,11 +2139,11 @@ $ret = (int)$rs->fields["MyCount"]; return $ret; } - + function SqlGlobalCount($attribs=array()) { global $objSession; - + $where = ''; $p = $this->BasePermission.'.VIEW'; $t = $this->SourceTable; @@ -2148,19 +2152,19 @@ $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where = "($t.CreatedOn>=$today)"; } - + $GroupList = getArrayValue($attribs,'_grouponly') ? $objSession->Get('GroupList') : null; $sql = $this->GetCountSQL($p,NULL,$GroupList,$where); return $sql; } - + function DoGlobalCount($attribs) { global $objCountCache; - + $cc = $objCountCache->GetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)getArrayValue($attribs,'_today'), 3600); if(!is_numeric($cc)) - { + { $sql = $this->SqlGlobalCount($attribs); $ret = QueryCount($sql); $objCountCache->SetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)getArrayValue($attribs,'_today'),$ret); @@ -2169,22 +2173,22 @@ $ret = $cc; return $ret; } - + function CacheListExtraId($ListType) { global $objSession; - + if(!strlen($ListType)) - $ListType="_"; + $ListType="_"; switch($ListType) - { + { case "_": - $ExtraId = $objSession->Get("GroupList"); + $ExtraId = $objSession->Get("GroupList"); break; case "category": $ExtraId = $objSession->Get("GroupList"); - break; + break; case "myitems": $ExtraId = $objSession->Get("PortalUserId"); break; @@ -2202,12 +2206,12 @@ break; case "new": $ExtraId = $objSession->Get("GroupList"); - break; + break; } return $ExtraId; } - - + + /** * Return all listype (from tags) to id mappings * @@ -2218,46 +2222,46 @@ { return Array('_' => 0, 'category' => 1, 'myitems' => 2, 'hot' => 3, 'pop' => 4, 'pick' => 5, 'favorites' => 6, 'new' => 8); } - + function CacheListType($ListType) { if(empty($ListType)) $ListType='_'; - + $mapping = $this->GetListTypes(); - + return $mapping[$ListType]; - } + } function PerformItemCount($attribs=array()) { global $objCountCache, $objSession; - + $ret = ""; $sql = ""; $ListType = getArrayValue($attribs,'_listtype'); if(!strlen($ListType)) $ListType="_"; - + $ListTypeId = $this->CacheListType($ListType); - //echo "ListType: $ListType ($ListTypeId)
\n"; + //echo "ListType: $ListType ($ListTypeId)
\n"; $ExtraId = $this->CacheListExtraId($ListType); switch($ListType) - { + { case "_": $ret = $this->DoGlobalCount($attribs); break; - case "category": + case "category": $ret = $this->CategoryCount($attribs); - break; + break; case "myitems": - $sql = $this->SqlMyItems($attribs); + $sql = $this->SqlMyItems($attribs); break; case "hot": - $sql = $this->SqlHotItems($attribs); + $sql = $this->SqlHotItems($attribs); break; case "pop": - $sql = $this->SqlPopItems($attribs); + $sql = $this->SqlPopItems($attribs); break; case "pick": $sql = $this->SqlPickItems($attribs); @@ -2278,7 +2282,7 @@ if(is_numeric($ListTypeId) && $ListTypeId) { $cc = $objCountCache->GetValue($ListTypeId,$this->ItemType,$ExtraId,(int)getArrayValue($attribs,'_today'), 3600); - + if(!is_numeric($cc) || $attribs['_nocache'] == 1) { $ret = QueryCount($sql); @@ -2290,32 +2294,32 @@ else $ret = QueryCount($sql); } - - return $ret; + + return $ret; } - + function GetJoinedSQL($PermName, $CatId=NULL, $AdditionalWhere="", $LoadOnlyPrimary = true) { global $objSession, $objPermissions; - + $ltable = $this->SourceTable; $acl = $objSession->GetACLClause(); $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; - $ptable = GetTablePrefix()."PermCache"; + $ptable = GetTablePrefix()."PermCache"; $VIEW = $objPermissions->GetPermId($PermName); $sql ="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) "; $sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) "; $sql .= "INNER JOIN $ptable ON ($cattable.CategoryId=$ptable.CategoryId) "; - + // here will come checking for PrimaryCat on search if ($LoadOnlyPrimary) { $sql .="WHERE ($acl AND PermId=$VIEW AND PrimaryCat=1 AND $CategoryTable.Status=1) "; } else { $sql .="WHERE ($acl AND PermId=$VIEW AND $CategoryTable.Status=1) "; } - + if(is_numeric($CatId) && $CatId > 0) { $sql .= " AND ($CategoryTable.CategoryId=$CatId) "; @@ -2326,9 +2330,16 @@ } return $sql; } - + + /** + * Not used in php files directly [comment by Alex] + * + * @param unknown_type $attribs + * @return unknown + * + */ function CountFavorites($attribs) - { + { if($attribs["_today"]) { global $objSession, $objConfig, $objPermissions; @@ -2339,14 +2350,15 @@ $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; $ptable = GetTablePrefix()."PermCache"; - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1"; - $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; + $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; $p = $this->BasePermission.".VIEW"; - - $sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) "; - $sql .= $this->GetJoinedSQL($p,NULL,$where); + + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavBar')." AS CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) "; + $sql .= $this->GetJoinedSQL($p,NULL,$where); $ret = QueryCount($sql); } else @@ -2355,101 +2367,101 @@ { $this->ListType = "favorites"; $this->LoadFavorites($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; } return $ret; } - - - + + + function CountPickItems($attribs) - { + { if (!$this->ListType == "pick") { $this->ListType = "pick"; $this->LoadPickItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountMyItems($attribs) - { + { if (!$this->ListType == "myitems") { $this->ListType = "myitems"; $this->LoadMyItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountHotItems($attribs) - { + { if (!$this->ListType == "hotitems") { $this->ListType = "hotitems"; $this->LoadHotItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountNewItems($attribs) - { + { if (!$this->ListType == "newitems") { $this->ListType = "newitems"; $this->LoadNewItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountPopItems($attribs) - { + { if (!$this->ListType == "popitems") { $this->ListType = "popitems"; $this->LoadPopItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - - + + function CountSearchItems($attribs) - { + { if (!$this->ListType == "search") { $this->ListType = "search"; $this->LoadSearchItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function SqlFavorites($attribs) { global $objSession, $objConfig, $objPermissions; @@ -2460,71 +2472,72 @@ $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; $ptable = GetTablePrefix()."PermCache"; - + $where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1"; if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; } $p = $this->BasePermission.".VIEW"; - - $sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) "; + + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavBar')." AS CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) "; $sql .= $this->GetJoinedSQL($p,NULL,$where); $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); $sql .= " ".$OrderBy; return $sql; } - + function LoadFavorites($attribs) { global $objSession, $objCountCache, $objConfig; - + $sql = $this->SqlFavorites($attribs); - + if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount = QueryCount($sql); $objCountCache->SetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount = (int)$CachedCount; - - return $this->Query_Item($sql); + + return $this->Query_Item($sql); } - + function SqlPickItems($attribs) { global $objSession, $objCatList; $catid = (int)getArrayValue($attribs,'_catid'); $scope = (int)getArrayValue($attribs,'_scope'); - //$JoinCats = (int)$attribs["_catinfo"] || $scope; - + //$JoinCats = (int)$attribs["_catinfo"] || $scope; + $TableName = $this->SourceTable; if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } $where = GetTablePrefix()."CategoryItems.CategoryId =".$catid." AND ".$TableName.".EditorsPick=1 AND ".$TableName.".Status=1"; } else @@ -2534,43 +2547,44 @@ } if(getArrayValue($attribs,'_today')) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; - } + } $CategoryTable = GetTablePrefix()."Category"; - $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName "; + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,$catid,$where); - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); - $sql .= " ".$OrderBy; - - //echo "SQL: $sql
"; - + $sql .= " ".$OrderBy; + + //echo "SQL: $sql
"; + return $sql; - } - + } + function LoadPickItems($attribs) { global $objSession, $objCountCache, $objConfig; - - $sql = $this->SqlPickItems($attribs); + + $sql = $this->SqlPickItems($attribs); if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; - + if($attribs["_shortlist"]) - { + { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)getArrayValue($attribs,'_today'),3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)getArrayValue($attribs,'_today'),3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); @@ -2579,9 +2593,9 @@ else $this->QueryItemCount=$CachedCount; - return $this->Query_Item($sql); + return $this->Query_Item($sql); } - + function SqlMyItems($attribs= array()) { global $objSession; @@ -2590,76 +2604,77 @@ $where = " ".$TableName.".Status>-1 AND ".$TableName.".CreatedById=".$objSession->Get("PortalUserId"); if(getArrayValue($attribs,'_today')) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; } - $CategoryTable = GetTablePrefix()."Category"; - $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName "; + $CategoryTable = GetTablePrefix()."Category"; + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,null,$where); // maybe null should be replaced by some CategoryId - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); - $sql .= " ".$OrderBy; - + $sql .= " ".$OrderBy; + return $sql; - } - + } + function LoadMyItems($attribs=array()) - { - global $objSession,$objCountCache; + { + global $objSession,$objCountCache; $sql = $this->SqlMyItems($attribs); if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else - $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],3600); + else + $this->PerPageVar = $this->PerPageVarLong; + + $CachedCount = $objCountCache->GetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount=$CachedCount; - - return $this->Query_Item($sql); - } - + + return $this->Query_Item($sql); + } + function SqlNewItems($attribs = array()) { global $objSession, $objCatList; $catid = (int)getArrayValue($attribs,'_catid'); $scope = (int)getArrayValue($attribs,'_scope'); $show_since_last = (int)getArrayValue($attribs,'_show_since_last'); - //$JoinCats = (int)$attribs["_catinfo"] || $scope; + //$JoinCats = (int)$attribs["_catinfo"] || $scope; //echo "Last: $scope

"; $TableName = $this->SourceTable; if(getArrayValue($attribs,'_today')) { - $cutoff = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $cutoff = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); } else { if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } if (!$show_since_last) { $cutoff = $this->GetNewValue($catid); } - else { + else { $cutoff = $scope; } } @@ -2668,16 +2683,16 @@ } if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } - + } + if (!$show_since_last) { - $where = "CategoryId =".$catid." AND ((".$TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 "; + $where = "CategoryId =".$catid." AND ((".$TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 "; } else { - $where = $TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".Status=1 "; + $where = $TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".Status=1 "; } } else @@ -2686,195 +2701,198 @@ } $CategoryTable = GetTablePrefix()."Category"; - $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName "; + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,$catid,$where); - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); - $sql .= " ".$OrderBy; - //echo "SQL: $sql

"; + $sql .= " ".$OrderBy; + //echo "SQL: $sql

"; return $sql; } function LoadNewItems($attribs) { global $objSession,$objCountCache,$objConfig; - + $sql = $this->SqlNewItems($attribs); - + if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if( getArrayValue($attribs,'_shortlist') ) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)getArrayValue($attribs,'_today'),3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)getArrayValue($attribs,'_today'),3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)getArrayValue($attribs,'_today'),$this->QueryItemCount); } else - $this->QueryItemCount=$CachedCount; - + $this->QueryItemCount=$CachedCount; + $ret = $this->Query_Item($sql); - return $ret; - } + return $ret; + } function SqlPopItems($attribs) { global $objSession, $objCatList; $catid = (int)$attribs["_catid"]; $scope = (int)$attribs["_scope"]; - //$JoinCats = (int)$attribs["_catinfo"] || $scope; - + //$JoinCats = (int)$attribs["_catinfo"] || $scope; + $TableName = $this->SourceTable; if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } $where = "CategoryId =".$catid." AND ((".$TableName.".Hits >=".$this->GetLinkPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1"; } - else + else { $where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 "; - + $where = "((".$TableName.".Hits >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 "; } if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; - } + } $CategoryTable = GetTablePrefix()."Category"; - $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName "; + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,$catid,$where); - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); $sql .= " ".$OrderBy; - + return $sql; } - + function LoadPopItems($attribs) { global $objSession,$objCountCache; $sql = $this->SqlPopItems($attribs); - + if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount=$CachedCount; - - return $this->Query_Item($sql); - } + return $this->Query_Item($sql); + } + function SqlHotItems($attribs) { global $objSession, $objCatList; $catid = (int)$attribs["_catid"]; $scope = (int)$attribs["_scope"]; -// $JoinCats = (int)$attribs["_catinfo"] || $scope; +// $JoinCats = (int)$attribs["_catinfo"] || $scope; - $TableName = $this->SourceTable; - - $OrderBy = $TableName.".CachedRating DESC"; + $TableName = $this->SourceTable; + $OrderBy = $TableName.".CachedRating DESC"; + if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } $where = "CategoryId =".$catid." AND ((".$TableName.".CachedRating >=".$this->GetHotValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1"; } else { $where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 "; } - + if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; - } + } $CategoryTable = GetTablePrefix()."Category"; - $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName "; + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; - $CatId = !$scope? NULL : $catid; + $CatId = !$scope? NULL : $catid; $sql .= $this->GetJoinedSQL($p,$CatId,$where); - + if(strlen($OrderBy)) - $sql .= " ORDER BY $OrderBy "; - + $sql .= " ORDER BY $OrderBy "; + return $sql; } - + function LoadHotItems($attribs) { - global $objSession,$objCountCache; - + global $objSession,$objCountCache; + $sql = $this->SqlHotItems($attribs); if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; - + if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else - $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"], 0); + else + $this->PerPageVar = $this->PerPageVarLong; + + $CachedCount = $objCountCache->GetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"], 0); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount=$CachedCount; - - return $this->Query_Item($sql); + + return $this->Query_Item($sql); } - + function SqlSearchItems($attribs = array()) { global $objConfig, $objItemTypes, $objSession, $objPermissions, $CountVal; @@ -2889,33 +2907,34 @@ $ptable = GetTablePrefix()."PermCache"; $p = $this->BasePermission.".VIEW"; $i = new $this->classname(); - - $sql = "SELECT $cattable.CategoryId,$cattable.CachedNavbar,$ltable.*, Relevance FROM $stable "; + + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = "SELECT $cattable.CategoryId,$cattable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavbar,$ltable.*, Relevance FROM $stable "; $sql .= "INNER JOIN $ltable ON ($stable.ItemId=$ltable.".$i->id_field.") "; - + $where = "ItemType=".$this->ItemType." AND $ltable.Status=1"; - + $load_multiple = $objConfig->Get("Search_ShowMultiple_".$attribs['multiple']); $LoadOnlyPrimary = true; - + if ($load_multiple == 1) { $LoadOnlyPrimary = false; } - - $sql .= $this->GetJoinedSQL($p,NULL,$where, $LoadOnlyPrimary); - $tmp = $this->QueryOrderByClause(FALSE,TRUE,TRUE); + + $sql .= $this->GetJoinedSQL($p,NULL,$where, $LoadOnlyPrimary); + $tmp = $this->QueryOrderByClause(FALSE,TRUE,TRUE); //echo "TMP: $tmp
"; //$tmp = substr($tmp,9); if(strlen($tmp)) { $sql .= $tmp.", "; - } - - $sql .= " EdPick DESC,Relevance DESC "; + } + + $sql .= " EdPick DESC,Relevance DESC "; //echo "SQL Search Items: $sql

"; - return $sql; + return $sql; } - + function LoadSearchItems($attribs = array()) { global $CountVal, $objSession; @@ -2940,9 +2959,9 @@ //echo "SQL: ".$sql."

"; $CountVal[$this->ItemType] = $this->QueryItemCount; } - + } - + /** * Updates count cache for selected ids in list * @@ -2953,18 +2972,18 @@ { $db =& GetADODBConnection(); if(is_array($item_ids)) $item_ids=implode(',',$item_ids); - + $sql = 'SELECT ResourceId FROM '.$this->SourceTable.' WHERE '.$this->GetIDField().' IN ('.$item_ids.')'; $resource_ids=$db->GetCol($sql); $sql='SELECT CategoryId FROM '.GetTablePrefix().'CategoryItems WHERE ItemResourceId IN ('.implode(',',$resource_ids).')'; $cat_ids=$db->GetCol($sql); UpdateCategoryCount($this->ItemType, $cat_ids, $this->GetListTypes()); } - + function PasteFromClipboard($TargetCat,$NameField="") { global $objSession,$objCatList; - + $clip = $objSession->GetVariable("ClipBoard"); if(strlen($clip)) { @@ -2973,40 +2992,40 @@ $item_ids = explode(",",$ClipBoard["ids"]); for($i=0;$iGetItem($item_ids[$i]); if(!$IsCopy) // paste to other category then current - { - $item->MoveToCategory($ClipBoard["source"],$TargetCat); + { + $item->MoveToCategory($ClipBoard["source"],$TargetCat); $clip = str_replace("CUT","COPY",$clip); $objSession->SetVariable("ClipBoard",$clip); } else - { + { $item->CopyToNewResource($TargetCat,$NameField); // create item copy, but with new ResourceId $item->AddToCategory($TargetCat); UpdateCategoryCount($item->type,$TargetCat, $this->GetListTypes() ); - + } } } } - + function AdminPrintItems($template) { // prints item listing for admin (browse/advanced view) tabs $o = ''; - + $i = 1; - + $topleft = 0; $topright = 0; $rightcount = 0; $total_items = $this->NumItems(); $topleft = ceil($total_items / 2); $topright = $total_items - $topleft; - - for($x = 0; $x < $topleft; $x++) + + for($x = 0; $x < $topleft; $x++) { //printingleft $item = $this->Items[$x]; @@ -3017,13 +3036,13 @@ } $o .= $item->AdminParseTemplate($template); $i++; - + //printingright - if ($rightcount < $topright && ( ($x + $topleft) < $total_items) ) + if ($rightcount < $topright && ( ($x + $topleft) < $total_items) ) { $item = $this->Items[ $x + $topleft ]; if ($i > 2) - { + { $o.="\n"; $i = 1; } @@ -3032,73 +3051,73 @@ $rightcount++; } } - $o .= "\n
\n"; + $o .= "\n\n"; return $o; } - + } // -------------- NEW CLASSES ----------------------- class DBList { - + // table related attributes var $db = null; var $table_name = ''; var $LiveTable = ''; var $EditTable = ''; - - + + // record related attributes var $records = Array(); var $record_count = 0; var $cur_rec = -1; // "-1" means no records, or record index otherwise - + // query related attributes var $SelectSQL = "SELECT * FROM %s"; - + function DBList() { // use $this->SetTable('live', 'table name'); // in inherited constructors to set table for list - $this->db =&GetADODBConnection(); + $this->db =&GetADODBConnection(); } - + function SetTable($action, $table_name = null) { // $action = {'live', 'restore','edit'} switch($action) { - case 'live': + case 'live': $this->LiveTable = $table_name; $this->table_name = $this->LiveTable; break; - case 'restore': - $this->table_name = $this->LiveTable; + case 'restore': + $this->table_name = $this->LiveTable; break; case 'edit': global $objSession; $this->table_name = $objSession->GetEditTable($this->LiveTable); break; } } - + function Clear() { // no use of this method at a time :) $this->records = Array(); $this->record_count = 0; - $this->cur_rec = -1; + $this->cur_rec = -1; } - + function Query() { - // query list + // query list $sql = sprintf($this->SelectSQL, $this->table_name); // echo "SQL: $sql
"; $rs =& $this->db->Execute($sql); - + if( $this->db->ErrorNo() == 0 ) { $this->records = $rs->GetRows(); @@ -3108,11 +3127,11 @@ else return false; } - + function ProcessList($callback_method) { // process list using user-defined method called - // with one parameter - current record fields + // with one parameter - current record fields // (associative array) if($this->record_count > 0) { @@ -3121,17 +3140,17 @@ { if( method_exists($this, $callback_method) ) $this->$callback_method( $this->GetCurrent() ); - $this->cur_rec++; + $this->cur_rec++; } } } - + function &GetCurrent() { // return currently processed record (with change ability) return ($this->cur_rec != -1) ? $this->records[$this->cur_rec] : false; } - + function GetDBField($field_name) { $rec =& $this->GetCurrent();