Get("Link_View"); $Links_AllValue = 127; if(!is_numeric($LinkView)) { $LinkView = 127; } $Link_SortField = $objConfig->Get('Link_SortField'); if( !strlen($Link_SortField) ) $Link_SortField = 'Priority'; $Link_SortOrder = $objConfig->Get('Link_SortOrder'); if( !strlen($Link_SortOrder) ) $Link_SortOrder = 'desc'; $Perpage_Links = (int)$objConfig->Get("Perpage_Links"); if(!$Perpage_Links) $Perpage_Links="'all'"; if($LinkView == $Links_AllValue) { $Link_ShowAll = 1; $LinkFilter = ""; } else { // FILTERING CODE V. 1.2 $where_clauses = Array(); $q = ''; // Group #1: Link Statuses (active,pending,disabled) $Status = array(-1); if($LinkView & $Bit_Pending) { $Status[] = STATUS_PENDING; $Status[] = -2; } if($LinkView & $Bit_Active) $Status[] = STATUS_ACTIVE; if($LinkView & $Bit_Disabled) $Status[] = STATUS_DISABLED; if( count($Status) ) $where_clauses[] = 'Status IN ('.implode(',', $Status).')'; // Group #2: Link Statistics (new,popular,hot,pick) $Status = array(); if(!($LinkView & $Bit_New)) { $cutoff = adodb_date("U") - ($objConfig->Get("Link_NewDays") * 86400); if($cutoff > 0) $q = 'CreatedOn > '.$cutoff; $q .= (!empty($q) ? ' OR ' : '').'NewItem = 1'; $Status[] = "NOT ($q)"; } if(!($LinkView & $Bit_Pop)) { $cutoff = $objLinkList->GetPopValue(); if($cutoff > 0) $q = 'CachedRating >= '.$cutoff; $q .= ' AND CachedVotesQty >= '.$objConfig->Get('Link_MinVotes'); $q .= (!empty($q) ? ' OR ' : '').'PopItem = 1'; $Status[] = "NOT ($q)"; } if(!($LinkView & $Bit_Hot)) { $cutoff = $objLinkList->GetHotValue(); if($cutoff > 0) $q = 'Hits >= '.$cutoff; $q .= (!empty($q) ? ' OR ' : '').'HotItem = 1'; $Status[] = "NOT ($q)"; } if(!($LinkView & $Bit_Ed)) $Status[] = 'NOT (EditorsPick = 1)'; if( count($Status) ) $where_clauses[] = '('.implode(') AND (', $Status).')'; $LinkFilter = count($where_clauses) ? '('.implode(') AND (', $where_clauses).')' : ''; } $list = $objSession->GetVariable("l_adv_view_search"); $objLinkList->Clear(); $objLinkList->EnablePaging=TRUE; $lt = $objLinkList->SourceTable; $catjoin = GetTablePrefix()."CategoryItems"; $cattable = $objCatList->SourceTable; $order = "EditorsPick DESC, Priority DESC"; $sql = "SELECT * FROM $lt "; //$sql .= "INNER JOIN $catjoin ON ($lt.ResourceId=$catjoin.ItemResourceId) "; $lado = &GetADODBConnection(); $tsql = $sql." WHERE OrgId IS NOT NULL AND OrgId>0 "; $rs = $lado->Execute($tsql); $OrgIds = array(); while($rs && !$rs->EOF) { $OrgIds[] = $rs->fields["OrgId"]; $rs->MoveNext(); } if(count($OrgIds)>0) { $LinkFilter .= ($LinkFilter ? ' AND ' : '')." (LinkId NOT IN (".implode(",",$OrgIds)."))"; } $order = $objLinkList->QueryOrderByClause(TRUE,TRUE,TRUE); //echo "OBQ: $order
"; if(strlen($list)==0) { $where = $LinkFilter ? "WHERE ".$LinkFilter : ''; $SearchQuery = ''; } else { $SearchQuery = $objLinkList->AdminSearchWhereClause($list); if(strlen($SearchQuery)) { $SearchQuery = " (".$SearchQuery.")".($LinkFilter ? ' AND ('.$LinkFilter.')' : ''); $where = 'WHERE '.$SearchQuery; } else $where = $LinkFilter ? "WHERE ".$LinkFilter : ''; } $sql .= $where." ".$order; //echo "Links SQL: $sql
"; $objLinkList->Query_Item($sql,false,'set_last'); $objLinkList->QueryItemCount = TableCount($objLinkList->SourceTable,($SearchQuery ? $SearchQuery : $LinkFilter),0); $CatTotal = TableCount($objLinkList->SourceTable,null,0); $caption = language("la_ItemTab_Links"); $ItemTabs->AddTab(language("la_ItemTab_Links"),"links",$objLinkList->QueryItemCount, $m_tab_Links_hide,$CatTotal); $lang_URL = language("la_prompt_URL"); $lang_Links = language("la_Text_Links"); $lang_Reviews = language("la_Text_Reviews"); $TotalItemCount += $objLinkList->QueryItemCount; $Link_Paste = "false"; if($objLinkList->ItemsOnClipboard()>0) $Link_Paste = "true"; print << var Link_SortField = '$Link_SortField'; var Link_SortOrder = '$Link_SortOrder'; var Links_Perpage = $Perpage_Links; var LinkView = $LinkView; var LinkTitle = '$caption'; var lang_URL = "$lang_URL"; var lang_Links = "$lang_Links"; var lang_Reviews = "$lang_Reviews"; var Links_Paste = $Link_Paste; PasteButton = PasteButton || Links_Paste; \$fw_menus['l_view_menu'] = function() { // filtring menu \$Menus['l_filtring_menu'] = new Menu(lang_View); \$Menus['l_filtring_menu'].addMenuItem(lang_All,"config_val('Link_View', $Links_AllValue);",LinkView==$Links_AllValue); \$Menus['l_filtring_menu'].addMenuItem(lang_None,"config_val('Link_View', 0);",LinkView==0); \$Menus['l_filtring_menu'].addMenuSeparator(); \$Menus['l_filtring_menu'].addMenuItem(lang_Active,"FlipBit('Link_View',LinkView,6);",BitStatus(LinkView,6)); \$Menus['l_filtring_menu'].addMenuItem(lang_Pending,"FlipBit('Link_View',LinkView,5);", BitStatus(LinkView,5)); \$Menus['l_filtring_menu'].addMenuItem(lang_Disabled,"FlipBit('Link_View',LinkView,4);",BitStatus(LinkView,4)); \$Menus['l_filtring_menu'].addMenuSeparator(); \$Menus['l_filtring_menu'].addMenuItem(lang_New,"FlipBit('Link_View',LinkView,3);",BitStatus(LinkView,3)); \$Menus['l_filtring_menu'].addMenuItem(lang_Pop,"FlipBit('Link_View',LinkView,2);",BitStatus(LinkView,2)); \$Menus['l_filtring_menu'].addMenuItem(lang_Hot,"FlipBit('Link_View',LinkView,1);",BitStatus(LinkView,1)); \$Menus['l_filtring_menu'].addMenuItem(lang_EdPick,"FlipBit('Link_View',LinkView,0);",BitStatus(LinkView,0)); // sorting menu \$Menus['l_sorting_menu'] = new Menu(lang_Sort); \$Menus['l_sorting_menu'].addMenuItem(lang_Asc,"config_val('Link_SortOrder','asc');",RadioIsSelected(Link_SortOrder,'asc')); \$Menus['l_sorting_menu'].addMenuItem(lang_Desc,"config_val('Link_SortOrder','desc');",RadioIsSelected(Link_SortOrder,'desc')); \$Menus['l_sorting_menu'].addMenuSeparator(); \$Menus['l_sorting_menu'].addMenuItem(lang_Default,"config_val('Link_SortField','Name');",""); \$Menus['l_sorting_menu'].addMenuItem(lang_Name,"config_val('Link_SortField','Name');",RadioIsSelected(Link_SortField,'Name')); \$Menus['l_sorting_menu'].addMenuItem(lang_URL,"config_val('Link_SortField','Url');",RadioIsSelected(Link_SortField,'Url')); \$Menus['l_sorting_menu'].addMenuItem(lang_CreatedOn,"config_val('Link_SortField','CreatedOn');",RadioIsSelected(Link_SortField,'CreatedOn')); \$Menus['l_sorting_menu'].addMenuItem(lang_Reviews,"config_val('Link_SortField','CachedReviewsQty');",RadioIsSelected(Link_SortField,'CachedReviewsQty')); \$Menus['l_sorting_menu'].addMenuItem(lang_Rating,"config_val('Link_SortField','CachedRating');",RadioIsSelected(Link_SortField,'CachedRating')); \$Menus['l_sorting_menu'].addMenuItem(lang_Votes,"config_val('Link_SortField','CachedVotesQty');",RadioIsSelected(Link_SortField,'CachedVotesQty')); \$Menus['l_sorting_menu'].addMenuItem(lang_Hits,"config_val('Link_SortField','CachedHits');",RadioIsSelected(Link_SortField,'CachedHits')); // perpage menu \$Menus['l_perpage_menu'] = new Menu(lang_PerPage); \$Menus['l_perpage_menu'].addMenuItem("10","config_val('Perpage_Links', '10');",RadioIsSelected(Links_Perpage,10)); \$Menus['l_perpage_menu'].addMenuItem("20","config_val('Perpage_Links', '20');",RadioIsSelected(Links_Perpage,20)); \$Menus['l_perpage_menu'].addMenuItem("50","config_val('Perpage_Links', '50');",RadioIsSelected(Links_Perpage,50)); \$Menus['l_perpage_menu'].addMenuItem("100","config_val('Perpage_Links', '100');",RadioIsSelected(Links_Perpage,100)); \$Menus['l_perpage_menu'].addMenuItem("500","config_val('Perpage_Links', '500');",RadioIsSelected(Links_Perpage,500)); // select menu \$Menus['l_select_menu'] = new Menu(lang_Select); \$Menus['l_select_menu'].addMenuItem(lang_All,"javascript:selectAllC('"+activeTab.id+"');",""); \$Menus['l_select_menu'].addMenuItem(lang_Unselect,"javascript:unselectAll('"+activeTab.id+"');",""); \$Menus['l_select_menu'].addMenuItem(lang_Invert,"javascript:invert('"+activeTab.id+"');",""); // view menus \$Menus['l_view_menu'] = new Menu(LinkTitle); \$Menus['l_view_menu'].addMenuItem( \$Menus['l_filtring_menu'] ); \$Menus['l_view_menu'].addMenuItem( \$Menus['l_sorting_menu'] ); \$Menus['l_view_menu'].addMenuItem( \$Menus['l_perpage_menu'] ); \$Menus['l_view_menu'].addMenuItem( \$Menus['l_select_menu'] ); } function SubmitSearch(formname, action) { var f = document.getElementById(formname); if(f) { f.Action.value = action; f.submit(); } } END; ?>