Index: trunk/admin/listview/listview.php =================================================================== diff -u -r291 -r642 --- trunk/admin/listview/listview.php (.../listview.php) (revision 291) +++ trunk/admin/listview/listview.php (.../listview.php) (revision 642) @@ -1,472 +1,472 @@ -SetToolBar($ToolBar); - $this->SetListItems($ListItems); - $this->ColumnHeaders = new clsColumnHeaderList(); - $this->CurrentPage=1; - $this->CheckboxName = "itemlist[]"; - $this->SelectorType="checkbox"; - $this->RowIcons = array(); - $this->PageLinks = ""; - $this->SearchAction = ""; - $this->extra_env=""; - $this->PriorityField="Priority"; - $this->TotalItemCount = 0; - - if (!is_null($ToolBar)) - $this->JSCheckboxName = $ToolBar->Get("CheckClass"); - $this->SetFormatters(); // for setting custom formatters - } - - function SetToolbar($ToolBar) - { - $this->ToolBar=$ToolBar; - if(is_object($this->ToolBar)) - $this->CheckArray=$this->ToolBar->Get("CheckClass"); - } - - function GetPage() - { - // get current page - $this->RefreshPageVar(); - return $this->CurrentPage; - } - - function GetLimitSQL() - { - return GetLimitSQL($this->GetPage(), $this->GetPerPage() ); - } - - function SetListItems($ListItems) - { - $this->ListItems = $ListItems; - } - - function SetIDfield($field) - { - $this->IdField = $field; - } - - function SetSort($SortField,$SortOrderVariable) - { - $this->ColumnHeaders->SetSort($SortField,$SortOrder); - } - - function SetRowIcon($index,$url) - { - $this->RowIcons[$index] = $url; - } - - function ConfigureViewMenu($SortFieldVar,$SortOrderVar,$DefaultSort,$FilterVar,$FilterValue,$FilterMax) - { - global $objConfig; - - //$FilterVal = $this->CurrentFilter; - //$fMax = $this->Filtermax; - //$sOrder = $this->CurrentSortOrder; - //$sOrderVar = $this->OrderVar; - //$sField = $this->CurrentSortField; - //$sDefault = $this->DefaultSortField; - - $this->ViewMenu = new clsViewMenu(); - $this->ViewMenu->PerPageVar = $this->PerPageVar; - $this->ViewMenu->PerPageValue = (int)$objConfig->Get($this->PerPageVar); - if($this->ViewMenu->PerPageValue==0) - $this->ViewMenu->PerPageValue = 20; - $this->ViewMenu->CurrentSortField = $objConfig->Get($SortFieldVar); - $this->ViewMenu->CurrentSortOrder = $objConfig->get($SortOrderVar); - $this->ViewMenu->SortVar = $SortFieldVar; - $this->ViewMenu->OrderVar = $SortOrderVar; - $this->ViewMenu->CurrentFilter= $FilterValue; - $this->ViewMenu->FilterVar = $FilterVar; - $this->ViewMenu->FilterMax = $FilterMax; - foreach($this->ColumnHeaders->Columns as $col) - { - $this->ViewMenu->AddSortField($col->field,$col->label,$DefaultSort==$col->field); - } - } - - function AddViewMenuFilter($Label,$Bit) - { - if(is_object($this->ViewMenu)) - $this->ViewMenu->AddFilterField($Label,$Bit); - } - - function GetViewMenu($imagesURL) - { - if(is_object($this->ViewMenu)) - { - $this->ViewMenu->CheckboxName = $this->JSCheckboxName; - return $this->ViewMenu->GetViewMenuJS($imagesURL); - } - else - return ""; - } - - function SetFormatters() - { - // for setting custom formatters - // abstract - } - - function SetFormatter($field, $type, $params) - { - // by Alex - // all params after 2nd are formmater type specific - $this->Formatters[$field]['type'] = $type; - switch($type) - { - case FT_OPTION: - $this->Formatters[$field]['options'] = $params; - break; - } - } - - function PrintItem($index) - { - if( !isset($this->ListItems->Items[$index]) ) return ''; - $li = $this->ListItems->Items[$index]; - - $o = ""; - $first=1; - - if(is_object($li)) - { - // ==== new by Alex: begin ==== - $li->Formatters =& $this->Formatters; - // ==== new by Alex: end ==== - - $id_field = $this->IdField; - $row_id = $li->Get($id_field); - if(is_numeric($li->Get($this->PriorityField))) - { - $Priority = (int)$li->Get($this->PriorityField); - } - else - $Priority=0; - $o = "\n"; - foreach($this->ColumnHeaders->Columns as $col) - { - $width=""; - $ColId = $row_id."_col_".$col->field; - if($first==1) - { - if(strlen($col->width)) - { - $width = $col->width; - } - $o .= ""; - if($this->checkboxes) - { - $onclick = "onclick=\"if (this.checked) {".$this->CheckArray.".addCheck('$row_id');} else {".$this->CheckArray.".removeCheck('$row_id');}\""; - $onclicksrc = "onclicksrc=\"if (this.checked) {".$this->CheckArray.".addCheck('$row_id');} else {".$this->CheckArray.".removeCheck('$row_id');}\""; - $o .= "SelectorType."\" name=\"".$this->CheckboxName."\" value=\"$row_id\" $onclick $onclicksrc>"; - } - if(isset($this->RowIcons[$index])) - { - $url = $this->RowIcons[$index]; - if(strlen($url)) - $o .= " "; - } - $first=0; - } - else - { - if(strlen($col->width)) - { - $o .= "width.">"; - } - else - $o .= ""; - } - if($Priority!=0) - { - $o .= "$Priority"; - $Priority=0; - } - $o .= "".stripslashes($li->GetFormatted($col->field))."\n"; - } - $o .= "\n"; - } - return $o; - } - - function PrintItems() - { - $o = ''; - $numitems = $this->ListItems->NumItems(); - for($index=0;$index<=$numitems;$index++) - { - $o .= $this->PrintItem($index); - } - return $o; - } - - function TotalPageNumbers() - { - if($this->PerPage>0) - { - $ret = $this->ListItems->NumItems() / $this->PerPage; - $ret = (int)$ret; - } - else - $ret = 1; - - return $ret; - } - - function GetPerPage() - { - global $objConfig; - $PerPage = $objConfig->Get($this->PerPageVar); - if($PerPage < 1) - { - if( defined('DEBUG_MODE') ) echo 'PerPage Variable ['.$this->PerPageVar.'] not defined in Config
'; - $PerPage = 20; - //$objConfig->Set($this->PerPageVar,20); - //$objConfig->Save(); - } - return $PerPage; - } - - function GetAdminPageLinkList($url) - { - global $objConfig; - - $PerPage = $this->GetPerPage(); - - if($this->TotalItemCount>0) - { - $NumPages = ceil($this->TotalItemCount / $PerPage); - } - else - $NumPages = ceil($this->ListItems->NumItems() / $PerPage); - - if($NumPages<1) - $NumPages =1; - //echo $this->CurrentPage." of ".$NumPages." Pages"; - - $o = ""; - if($this->CurrentPage>$NumPages) - $this->CurrentPage=$NumPages; - - $StartPage = $this->CurrentPage - 5; - if($StartPage<1) - $StartPage=1; - $EndPage = $StartPage+9; - if($EndPage>$NumPages) - { - $EndPage = $NumPages; - $StartPage = $EndPage-10; - if($StartPage<1) - $StartPage=1; - } - - $o .= "".admin_language("la_Page")." "; - if($StartPage>1) - { - $target = $this->CurrentPage-10; - $prev_url = str_replace("{TargetPage}",$target,$url); - $o .= "<<"; - } - - for($p=$StartPage;$p<=$EndPage;$p++) - { - if($p!=$this->CurrentPage) - { - $href = str_replace("{TargetPage}",$p,$url); - $o .= " $p "; - } - else - { - $o .= " $p "; - } - } - if($EndPage<$NumPages-1) - { - $target = $this->CurrentPage+10; - $next_url = str_replace("{TargetPage}",$target,$url); - $o .= " >>"; - } - return $o; - } - - function SliceItems() - { - global $objConfig; - - $PerPage = (int)$objConfig->Get($this->PerPageVar); - if($PerPage<1) - $PerPage=20; - $NumPages = ceil($this->ListItems->NumItems() / $PerPage); - if($NumPages>1) - { - $Start = ($this->CurrentPage-1)*$PerPage; - $this->ListItems->Items = array_slice($this->ListItems->Items,$Start,$PerPage); - } - } - - function RefreshPageVar() - { - global $objSession; - if( (int)GetVar('lpn') > 0) - { - $this->CurrentPage = $_GET["lpn"]; - $objSession->SetVariable($this->CurrentPageVar,$this->CurrentPage); - } - else - $this->CurrentPage = $objSession->GetVariable($this->CurrentPageVar); - - $this->ListItems->Page = $this->CurrentPage; - } - - function PrintPageLinks($add_search = '') - { - global $imagesURL, $objSession, $lvErrorString; - - if(strlen($this->PageLinks)>0) - { - return $this->PageLinks; - } - $this->RefreshPageVar(); - - if($this->CurrentPage<1) - $this->CurrentPage = 1; - if(!strlen($this->PageURL)) - { - $this->PageURL = $_SERVER["PHP_SELF"]."?env=".BuildEnv(); - if(strlen($this->extra_env)) - $this->PageURL .= "&".$this->extra_env; - $this->PageURL .= "&lpn={TargetPage}"; - } - $cols = $this->ColumnHeaders->Count(); - $o = "\n"; - - if(strlen($lvErrorString)) - { - $o .= ""; - - } - if($this->SearchBar==FALSE) - { - $o .= '\n"; - } - else - { - $val = str_replace(","," ", $this->SearchKeywords); - $o .= ""; - $o .= ""; - } - $o .= "
$lvErrorString
'; - $o .= $this->GetAdminPageLinkList($this->PageURL); - $o .= ""; - $o .= $this->GetAdminPageLinkList($this->PageURL)."$add_search".admin_language("la_prompt_Search"); - $o .= " "; - $o .= " SearchAction."');\">"; - $o .= " SearchAction."_reset');\">"; - if(strlen($this->SearchDropdownId)>0) - { - $o .= " SearchDropdownId."');\">"; - } - $o .= "
"; - return $o; - } - - function PrintJavaScriptInit() - { - $o = ''; - if($this->checkboxes) - { - $o = ""; - } - return $o; - } - - - function PrintList($footer = '',$add_search = '') - { - global $objSession; - if((int)$this->CurrentPage<1) - $this->CurrentPage=1; - - $o = "\n"; - - if(is_object($this->ToolBar)) - { - if($this->PrintToolBar) - $o .= $this->ToolBar->Build(); - } - $o .= $this->PrintPageLinks($add_search); - $o .= "\n"; - - if($this->ShowColumnHeaders) - { - $o .= $this->ColumnHeaders->PrintColumns(); - } - if($this->ListItems->NumItems()>0) - { - $o .= $this->PrintItems(); - - } - - $o .= "$footer
"; - if($this->ListItems->NumItems()>0) - $o .= $this->PrintJavaScriptInit(); - return $o; - } -} +SetToolBar($ToolBar); + $this->SetListItems($ListItems); + $this->ColumnHeaders = new clsColumnHeaderList(); + $this->CurrentPage=1; + $this->CheckboxName = "itemlist[]"; + $this->SelectorType="checkbox"; + $this->RowIcons = array(); + $this->PageLinks = ""; + $this->SearchAction = ""; + $this->extra_env=""; + $this->PriorityField="Priority"; + $this->TotalItemCount = 0; + + if (!is_null($ToolBar)) + $this->JSCheckboxName = $ToolBar->Get("CheckClass"); + $this->SetFormatters(); // for setting custom formatters + } + + function SetToolbar($ToolBar) + { + $this->ToolBar=$ToolBar; + if(is_object($this->ToolBar)) + $this->CheckArray=$this->ToolBar->Get("CheckClass"); + } + + function GetPage() + { + // get current page + $this->RefreshPageVar(); + return $this->CurrentPage; + } + + function GetLimitSQL() + { + return GetLimitSQL($this->GetPage(), $this->GetPerPage() ); + } + + function SetListItems($ListItems) + { + $this->ListItems = $ListItems; + } + + function SetIDfield($field) + { + $this->IdField = $field; + } + + function SetSort($SortField,$SortOrderVariable) + { + $this->ColumnHeaders->SetSort($SortField,$SortOrder); + } + + function SetRowIcon($index,$url) + { + $this->RowIcons[$index] = $url; + } + + function ConfigureViewMenu($SortFieldVar,$SortOrderVar,$DefaultSort,$FilterVar,$FilterValue,$FilterMax) + { + global $objConfig; + + //$FilterVal = $this->CurrentFilter; + //$fMax = $this->Filtermax; + //$sOrder = $this->CurrentSortOrder; + //$sOrderVar = $this->OrderVar; + //$sField = $this->CurrentSortField; + //$sDefault = $this->DefaultSortField; + + $this->ViewMenu = new clsViewMenu(); + $this->ViewMenu->PerPageVar = $this->PerPageVar; + $this->ViewMenu->PerPageValue = (int)$objConfig->Get($this->PerPageVar); + if($this->ViewMenu->PerPageValue==0) + $this->ViewMenu->PerPageValue = 20; + $this->ViewMenu->CurrentSortField = $objConfig->Get($SortFieldVar); + $this->ViewMenu->CurrentSortOrder = $objConfig->get($SortOrderVar); + $this->ViewMenu->SortVar = $SortFieldVar; + $this->ViewMenu->OrderVar = $SortOrderVar; + $this->ViewMenu->CurrentFilter= $FilterValue; + $this->ViewMenu->FilterVar = $FilterVar; + $this->ViewMenu->FilterMax = $FilterMax; + foreach($this->ColumnHeaders->Columns as $col) + { + $this->ViewMenu->AddSortField($col->field,$col->label,$DefaultSort==$col->field); + } + } + + function AddViewMenuFilter($Label,$Bit) + { + if(is_object($this->ViewMenu)) + $this->ViewMenu->AddFilterField($Label,$Bit); + } + + function GetViewMenu($imagesURL) + { + if(is_object($this->ViewMenu)) + { + $this->ViewMenu->CheckboxName = $this->JSCheckboxName; + return $this->ViewMenu->GetViewMenuJS($imagesURL); + } + else + return ""; + } + + function SetFormatters() + { + // for setting custom formatters + // abstract + } + + function SetFormatter($field, $type, $params) + { + // by Alex + // all params after 2nd are formmater type specific + $this->Formatters[$field]['type'] = $type; + switch($type) + { + case FT_OPTION: + $this->Formatters[$field]['options'] = $params; + break; + } + } + + function PrintItem($index) + { + if( !isset($this->ListItems->Items[$index]) ) return ''; + $li = $this->ListItems->Items[$index]; + + $o = ""; + $first=1; + + if(is_object($li)) + { + // ==== new by Alex: begin ==== + $li->Formatters =& $this->Formatters; + // ==== new by Alex: end ==== + + $id_field = $this->IdField; + $row_id = $li->Get($id_field); + if(is_numeric($li->Get($this->PriorityField))) + { + $Priority = (int)$li->Get($this->PriorityField); + } + else + $Priority=0; + $o = "\n"; + foreach($this->ColumnHeaders->Columns as $col) + { + $width=""; + $ColId = $row_id."_col_".$col->field; + if($first==1) + { + if(strlen($col->width)) + { + $width = $col->width; + } + $o .= ""; + if($this->checkboxes) + { + $onclick = "onclick=\"if (this.checked) {".$this->CheckArray.".addCheck('$row_id');} else {".$this->CheckArray.".removeCheck('$row_id');}\""; + $onclicksrc = "onclicksrc=\"if (this.checked) {".$this->CheckArray.".addCheck('$row_id');} else {".$this->CheckArray.".removeCheck('$row_id');}\""; + $o .= "SelectorType."\" name=\"".$this->CheckboxName."\" value=\"$row_id\" $onclick $onclicksrc>"; + } + if(isset($this->RowIcons[$index])) + { + $url = $this->RowIcons[$index]; + if(strlen($url)) + $o .= " "; + } + $first=0; + } + else + { + if(strlen($col->width)) + { + $o .= "width.">"; + } + else + $o .= ""; + } + if($Priority!=0) + { + $o .= "$Priority"; + $Priority=0; + } + $o .= "".stripslashes($li->GetFormatted($col->field))."\n"; + } + $o .= "\n"; + } + return $o; + } + + function PrintItems() + { + $o = ''; + $numitems = $this->ListItems->NumItems(); + for($index=0;$index<=$numitems;$index++) + { + $o .= $this->PrintItem($index); + } + return $o; + } + + function TotalPageNumbers() + { + if($this->PerPage>0) + { + $ret = $this->ListItems->NumItems() / $this->PerPage; + $ret = (int)$ret; + } + else + $ret = 1; + + return $ret; + } + + function GetPerPage() + { + global $objConfig; + $PerPage = $objConfig->Get($this->PerPageVar); + if($PerPage < 1) + { + if( defined('DEBUG_MODE') ) echo 'PerPage Variable ['.$this->PerPageVar.'] not defined in Config
'; + $PerPage = 20; + //$objConfig->Set($this->PerPageVar,20); + //$objConfig->Save(); + } + return $PerPage; + } + + function GetAdminPageLinkList($url) + { + global $objConfig; + + $PerPage = $this->GetPerPage(); + + if($this->TotalItemCount>0) + { + $NumPages = ceil($this->TotalItemCount / $PerPage); + } + else + $NumPages = ceil($this->ListItems->NumItems() / $PerPage); + + if($NumPages<1) + $NumPages =1; + //echo $this->CurrentPage." of ".$NumPages." Pages"; + + $o = ""; + if($this->CurrentPage>$NumPages) + $this->CurrentPage=$NumPages; + + $StartPage = $this->CurrentPage - 5; + if($StartPage<1) + $StartPage=1; + $EndPage = $StartPage+9; + if($EndPage>$NumPages) + { + $EndPage = $NumPages; + $StartPage = $EndPage-10; + if($StartPage<1) + $StartPage=1; + } + + $o .= "".admin_language("la_Page")." "; + if($StartPage>1) + { + $target = $this->CurrentPage-10; + $prev_url = str_replace("{TargetPage}",$target,$url); + $o .= "<<"; + } + + for($p=$StartPage;$p<=$EndPage;$p++) + { + if($p!=$this->CurrentPage) + { + $href = str_replace("{TargetPage}",$p,$url); + $o .= " $p "; + } + else + { + $o .= " $p "; + } + } + if($EndPage<$NumPages-1) + { + $target = $this->CurrentPage+10; + $next_url = str_replace("{TargetPage}",$target,$url); + $o .= " >>"; + } + return $o; + } + + function SliceItems() + { + global $objConfig; + + $PerPage = (int)$objConfig->Get($this->PerPageVar); + if($PerPage<1) + $PerPage=20; + $NumPages = ceil($this->ListItems->NumItems() / $PerPage); + if($NumPages>1) + { + $Start = ($this->CurrentPage-1)*$PerPage; + $this->ListItems->Items = array_slice($this->ListItems->Items,$Start,$PerPage); + } + } + + function RefreshPageVar() + { + global $objSession; + if( (int)GetVar('lpn') > 0) + { + $this->CurrentPage = $_GET["lpn"]; + $objSession->SetVariable($this->CurrentPageVar,$this->CurrentPage); + } + else + $this->CurrentPage = $objSession->GetVariable($this->CurrentPageVar); + + $this->ListItems->Page = $this->CurrentPage; + } + + function PrintPageLinks($add_search = '') + { + global $imagesURL, $objSession, $lvErrorString; + + if(strlen($this->PageLinks)>0) + { + return $this->PageLinks; + } + $this->RefreshPageVar(); + + if($this->CurrentPage<1) + $this->CurrentPage = 1; + if(!strlen($this->PageURL)) + { + $this->PageURL = $_SERVER["PHP_SELF"]."?env=".BuildEnv(); + if(strlen($this->extra_env)) + $this->PageURL .= "&".$this->extra_env; + $this->PageURL .= "&lpn={TargetPage}"; + } + $cols = $this->ColumnHeaders->Count(); + $o = "\n"; + + if(strlen($lvErrorString)) + { + $o .= ""; + + } + if($this->SearchBar==FALSE) + { + $o .= '\n"; + } + else + { + $val = inp_htmlize(str_replace(","," ", $this->SearchKeywords),1); + $o .= ""; + $o .= ""; + } + $o .= "
$lvErrorString
'; + $o .= $this->GetAdminPageLinkList($this->PageURL); + $o .= ""; + $o .= $this->GetAdminPageLinkList($this->PageURL)."$add_search".admin_language("la_prompt_Search"); + $o .= " "; + $o .= " SearchAction."');\">"; + $o .= " SearchAction."_reset');\">"; + if(strlen($this->SearchDropdownId)>0) + { + $o .= " SearchDropdownId."');\">"; + } + $o .= "
"; + return $o; + } + + function PrintJavaScriptInit() + { + $o = ''; + if($this->checkboxes) + { + $o = ""; + } + return $o; + } + + + function PrintList($footer = '',$add_search = '') + { + global $objSession; + if((int)$this->CurrentPage<1) + $this->CurrentPage=1; + + $o = "\n"; + + if(is_object($this->ToolBar)) + { + if($this->PrintToolBar) + $o .= $this->ToolBar->Build(); + } + $o .= $this->PrintPageLinks($add_search); + $o .= "\n"; + + if($this->ShowColumnHeaders) + { + $o .= $this->ColumnHeaders->PrintColumns(); + } + if($this->ListItems->NumItems()>0) + { + $o .= $this->PrintItems(); + + } + + $o .= "$footer
"; + if($this->ListItems->NumItems()>0) + $o .= $this->PrintJavaScriptInit(); + return $o; + } +}