Index: trunk/kernel/include/parseditem.php =================================================================== diff -u -r155 -r295 --- trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 155) +++ trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 295) @@ -2781,4 +2781,106 @@ } } } + +// -------------- 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(); + } + + function SetTable($action, $table_name = null) + { + // $action = {'live', 'restore','edit'} + switch($action) + { + case 'live': + $this->LiveTable = $table_name; + $this->table_name = $this->LiveTable; + break; + 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; + } + + function Query() + { + // 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(); + $this->record_count = count($this->records); + //$this->cur_rec = $this->record_count ? 0 : -1; + } + else + return false; + } + + function ProcessList($callback_method) + { + // process list using user-defined method called + // with one parameter - current record fields + // (associative array) + if($this->record_count > 0) + { + $this->cur_rec = 0; + while($this->cur_rec < $this->record_count) + { + if( method_exists($this, $callback_method) ) + $this->$callback_method( $this->GetCurrent() ); + $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(); + return is_array($rec) && isset($rec[$field_name]) ? $rec[$field_name] : false; + } +} + + ?> Index: trunk/admin/include/elements.php =================================================================== diff -u -r294 -r295 --- trunk/admin/include/elements.php (.../elements.php) (revision 294) +++ trunk/admin/include/elements.php (.../elements.php) (revision 295) @@ -595,7 +595,7 @@ { // gets correct caption for editing windows with tabs //echo "In: $item_phrase, $tab_phrase, $id"; - $is_new = ($_REQUEST['new'] == 1) ? 1 : 0; + $is_new = isset($_REQUEST['new']) && ($_REQUEST['new'] == 1) ? 1 : 0; $text = $is_new ? 'la_Text_Adding' : 'la_Text_Editing'; $text = admin_language($text).' '.admin_language($item_phrase);