recallObject('PermissionsHelper'); if ($perm_helper->TagPermissionCheck(Array('permissions' => 'LINK.VIEW'), 'in-link/admin/include/toolbar/browse.php')) { $session =& $application->recallObject('Session'); $links_list =& $application->recallObject('l','l_List'); $ItemTabs->AddTab(language("la_ItemTab_K4Links"), "k4links", $links_list->RecordsCount, 0, $links_list->NoFilterCount); $Links_Paste = $application->RecallVar('l_clipboard') ? 1 : 0; // K4 VERSION: END print << var Links_Paste = $Links_Paste; PasteButton = PasteButton || Links_Paste; AddButtonAction('new_link',"new_link('l')"); function new_link(prefix_special) { \$form_name = queryTabRegistry('prefix_special', prefix_special, 'tab_id') + '_form'; set_hidden_field(prefix_special+'_mode', 't'); opener_action('d'); submit_event(prefix_special, 'OnPreCreate', queryTabRegistry('prefix_special', prefix_special, 'edit_template'), '../../admin/index.php') } END1; } } else { global $objConfig, $objSession, $objLinkList, $ItemTabs, $SearchType,$LinkSearch, $TotalItemCount; global $Bit_All,$Bit_Pending,$Bit_Disabled,$Bit_New,$Bit_Pop,$Bit_Hot,$Bit_Ed,$DefaultTab, $debugger; $m_tab_Links_hide = 0; if(strlen($DefaultTab)) { $m_tab_Links_hide = ($DefaultTab=="links") ? 0 : 1; } $LinkView = $objConfig->Get("Link_View"); $Links_AllValue = 127; if(!is_numeric($LinkView)) { $LinkView = 127; } // default 1st sorting $Link_SortField = $objConfig->Get('Link_SortField'); // 'Priority'; $Link_SortOrder = $objConfig->Get('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 { $Status = array(); $Mod = array(); if($LinkView & $Bit_Pending) $Status[] = STATUS_PENDING; if($LinkView & $Bit_Active) $Status[] = STATUS_ACTIVE; if($LinkView & $Bit_Disabled) $Status[] = STATUS_DISABLED; if(count($Status)) { $LinkFilter .= " AND (Status IN (".implode(",",$Status).") "; } else $LinkFilter .= " AND ((Status=-1) "; if($LinkView & $Bit_Ed) { $LinkFilter .= " OR (EditorsPick=1) "; } if($LinkView & $Bit_New) { $cutoff = adodb_date("U") - ($objConfig->Get("Link_NewDays") * 86400); $LinkFilter .= " OR (CreatedOn > ".$cutoff.") "; } if($LinkView & $Bit_Pop) { $cutoff = $objLinkList->GetPopValue(); if($cutoff>0) $LinkFilter .= " OR (CachedRating >= ".$cutoff.") "; } if($LinkView & $Bit_Hot) { $cutoff = $objLinkList->GetHotValue(); if($cutoff>0) $LinkFilter .= " OR (Hits >= ".$cutoff.") "; } $LinkFilter .= ")"; } $list = $objSession->GetVariable("SearchWord"); $LinkSearch = (strlen($list)>0 && $SearchType =="Links" || $SearchType="all");// || (strlen($list)==0); $objLinkList->Clear(); $objLinkList->EnablePaging=TRUE; $LinkSearch = $LinkSearch && ($objSession->HasCatPermission("LINK.VIEW")); $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) "; if($LinkSearch) { $lado = &GetADODBConnection(); $tsql = $sql." WHERE OrgId IS NOT NULL AND OrgId>0 AND CategoryId=".$objCatList->CurrentCategoryID(); $rs = $lado->Execute($tsql); $OrgIds = array(); while($rs && !$rs->EOF) { $OrgIds[] = $rs->fields["OrgId"]; $rs->MoveNext(); } if(count($OrgIds)>0) { $LinkFilter .= " AND (LinkId NOT IN (".implode(",",$OrgIds)."))"; } $order = $objLinkList->QueryOrderByClause(TRUE,TRUE,TRUE); if(strlen($list)==0) { $where = "WHERE CategoryId=".$objCatList->CurrentCategoryID().$LinkFilter; } else { $SearchQuery = $objLinkList->AdminSearchWhereClause($list); if(strlen($SearchQuery)) { $SearchQuery = " AND (".$SearchQuery.")"; if(strlen($CatScopeClause)) $SearchQuery .= " AND ".$CatScopeClause; $where = $SearchQuery.$LinkFilter; } else $where = "WHERE CategoryId=".$objCatList->CurrentCategoryID().$LinkFilter; } $sql .= $where." ".$order; $objLinkList->Query_Item($sql); $counting_clause = ' (CategoryId = '.$objCatList->CurrentCategoryID().') AND (OrgId IS NULL OR OrgId = 0) '; if (strlen($list) > 0) { $objLinkList->QueryItemCount = TableCount($objLinkList->SourceTable, ' CategoryId = '.$objCatList->CurrentCategoryID().$where,TRUE); } else { $objLinkList->QueryItemCount = TableCount($objLinkList->SourceTable,$counting_clause,TRUE); } $CatTotal = TableCount($objLinkList->SourceTable, $counting_clause, true); $ItemTabs->AddTab(language("la_ItemTab_Links"),"links",$objLinkList->QueryItemCount, $m_tab_Links_hide,$CatTotal); } $caption = language("la_ItemTab_Links"); $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('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,1);",BitStatus(LinkView,1)); \$Menus['l_filtring_menu'].addMenuItem(lang_Hot,"FlipBit('Link_View',LinkView,2);",BitStatus(LinkView,2)); \$Menus['l_filtring_menu'].addMenuItem(lang_EdPick,"FlipBit('Link_View',LinkView,0);",BitStatus(LinkView,0)); // sorting menu \$Menus['l_sorting_menu'] = new Menu('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','Hits');",RadioIsSelected(Link_SortField,'Hits')); // 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('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 menu \$Menus['l_view_menu'] = new Menu(lang_Links); \$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'] ); } END; } ?>