$value)
{
$path = $pathtoroot.$value."admin/include/parser.php";
if( file_exists($path) ) include_once($path);
}
unset($objEditItems);
$objEditItems = new clsLinkList();
$objEditItems->SourceTable = $objSession->GetEditTable("Link");
$objEditItems->EnablePaging = FALSE;
$en = (int)$_GET["en"];
if (isset($_POST["linklist"]))
{
$objLinkList->CopyToEditTable("LinkId",$_POST["linklist"]);
}
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
$itemcount=$objEditItems->NumItems();
if( $GLOBALS['debuglevel'] ) echo $itemcount . " items loaded..
\n";
$c = $objEditItems->GetItemByIndex($en);
if($itemcount>1)
{
if ($en+1 == $itemcount)
$en_next = -1;
else
$en_next = $en+1;
if ($en == 0)
$en_prev = -1;
else
$en_prev = $en-1;
}
$action = "l_edit_link";
$section = 'in-link:editlink_relations';
$envar = "env=" . BuildEnv() . "&en=$en";
$saveURL = $admin."/".$objSession->GetVariable('ReturnScript');
//Set Environment Variable
if( $GLOBALS['debuglevel'] ) echo $envar."
\n";
//Display header
$sec = $objSections->GetSection($section);
$objListToolBar = new clsToolBar();
$objListToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","do_edit_save('save_edit_buttons','LinkEditStatus','".$saveURL."',1);","tool_select.gif");
$objListToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","do_edit_save('save_edit_buttons','LinkEditStatus','".$saveURL."',2);","tool_cancel.gif");
if($itemcount == 1) $objListToolBar->Add("divider");
$objListToolBar->Set("section",$section);
$objListToolBar->Set("load_menu_func","");
$objListToolBar->Set("CheckClass","PermChecks");
$objListToolBar->Set("CheckForm","permlistform");
//Display header
$sec = $objSections->GetSection($section);
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl."/in-link/admin/addlink_relations.php";
$StatusField = "LinkEditStatus";
$form = "link";
MultiEditButtons($objListToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"));
$objListToolBar->Add("divider");
}
$listImages = array();
//$img, $alt, $link, $onMouseOver, $onMouseOut, $onClick
$objListToolBar->Add("new_rel", "la_ToolTip_New_Relation","#".$envar,"swap('new_rel','toolbar/tool_new_relation_f2.gif');",
"swap('new_rel', 'toolbar/tool_new_relation.gif');",
"OpenItemSelector('$envar&source=addcategory_relations&CatId=".$c->Get("CategoryId")."&destform=popup&destfield=itemlist&Selector=radio');",
"tool_new_relation.gif");
$objListToolBar->Add("rel_edit","la_ToolTip_Edit","#", "if (PermChecks.itemChecked()) swap('rel_edit','toolbar/tool_edit_f2.gif');",
"if (PermChecks.itemChecked()) swap('rel_edit', 'toolbar/tool_edit.gif');","if (PermChecks.itemChecked()) PermChecks.check_submit('addrelation', '');",
"tool_edit.gif",TRUE,TRUE);
$listImages[] = "PermChecks.addImage('rel_edit','$imagesURL/toolbar/tool_edit.gif','$imagesURL/toolbar/tool_edit_f3.gif',1); ";
$objListToolBar->Add("rel_del","la_ToolTip_Delete","#", "if (PermChecks.itemChecked()) swap('rel_del','toolbar/tool_delete_f2.gif');",
"if (PermChecks.itemChecked()) swap('rel_del', 'toolbar/tool_delete.gif');","if (PermChecks.itemChecked()) PermChecks.check_submit('addlink_relations', 'm_rel_delete');",
"tool_delete.gif",FALSE,TRUE);
$listImages[] = "PermChecks.addImage('rel_del','$imagesURL/toolbar/tool_delete.gif','$imagesURL/toolbar/tool_delete_f3.gif',1); ";
$objListToolBar->Add("divider");
$objListToolBar->Add("rel_move_up","la_ToolTip_Move_Up","#", "if (PermChecks.itemChecked()) swap('rel_move_up','toolbar/tool_move_up_f2.gif');",
"if (PermChecks.itemChecked()) swap('rel_move_up', 'toolbar/tool_move_up.gif');","if (PermChecks.itemChecked()) PermChecks.check_submit('addlink_relations', 'm_rel_move_up');",
"tool_move_up.gif",FALSE,TRUE);
$listImages[] = "PermChecks.addImage('rel_move_up','$imagesURL/toolbar/tool_move_up.gif','$imagesURL/toolbar/tool_move_up_f3.gif',1); ";
$objListToolBar->Add("rel_move_down","la_ToolTip_Move_Down","#", "if (PermChecks.itemChecked()) swap('rel_move_down','toolbar/tool_move_down_f2.gif');",
"if (PermChecks.itemChecked()) swap('rel_move_down', 'toolbar/tool_move_down.gif');","if (PermChecks.itemChecked()) PermChecks.check_submit('addlink_relations', 'm_rel_move_down');",
"tool_move_down.gif",FALSE,TRUE);
$listImages[] = "PermChecks.addImage('rel_move_down','$imagesURL/toolbar/tool_move_down.gif','$imagesURL/toolbar/tool_move_down_f3.gif',1); ";
$objListToolBar->Add("divider");
$objListToolBar->Add("viewmenubutton", "la_ToolTip_View","#","swap('viewmenubutton','toolbar/tool_view_f2.gif'); ",
"swap('viewmenubutton', 'toolbar/tool_view.gif');",
"ShowViewMenu();","tool_view.gif");
/* ----------------------------------------- Set the View Filter ---------------------------------------- */
$Rel_AllValue = 255;
$Bit_Categories = 1;
$Bit_Links = 2;
$Bit_News = 4;
$Bit_Topics = 8;
$Bit_OneWay = 16;
$Bit_Recip = 32;
$Bit_Enabled=64;
$Bit_Disabled=128;
$FilterLabels[0] = admin_language("la_Text_Category");
$FilterLabels[1] = admin_language("la_Text_Links");
$FilterLabels[2] = admin_language("la_Text_Articles");
$FilterLabels[3] = admin_language("la_Text_Topics");
$FilterLabels[4] = admin_language("la_Text_OneWay");
$FilterLabels[5] = admin_language("la_Text_Reciprocal");
$FilterLabels[6] = admin_language("la_Text_Enabled");
$FilterLabels[7] = admin_language("la_Text_Disabled");
$RelView = $objConfig->Get("LinkRel_View");
if(!is_numeric($RelView))
{
$RelView = $Rel_AllValue;
}
else
{
$RelTypes = array();
if($RelView & $Bit_Categories) $RelTypes[] = 1;
if($RelView & $Bit_Links) $RelTypes[] = 4;
if($RelView & $Bit_News) $RelTypes[] = 2;
if($RelView & $Bit_Topics) $RelTypes[] = 3;
$RelFilters = array();
$RelFilters[]='rel.TargetType IN ('.($RelTypes?implode(',',$RelTypes):'-1').')';
$RelTypes = array();
if($RelView & $Bit_OneWay) $RelTypes[] = 0;
if($RelView & $Bit_Recip) $RelTypes[] = 1;
$RelFilters[] = 'rel.Type IN ('.($RelTypes?implode(',',$RelTypes):'-1').')';
$EnabledFilter = Array();
if($RelView & $Bit_Enabled) $EnabledFilter[] = 'rel.Enabled=1';
if($RelView & $Bit_Disabled) $EnabledFilter[] = 'rel.Enabled=0';
$RelFilters[] = '('.($EnabledFilter?implode(' OR ',$EnabledFilter):'rel.Enabled=-1').')';
$RelFilter = implode(' AND ',$RelFilters);
}
$objListToolBar->AddToInitScript("fwLoadMenus(); \n");
$objListToolBar->AddToInitScript($listImages);
//$r =& $c->RelationObject();
$objRelList = new clsRelationshipList();
$objRelList->SourceTable = $objSession->GetEditTable("Relationship");
$reltable = $objRelList->SourceTable;
// ==== build sql depending on modules installed: begin ====
$prefix = GetTablePrefix();
$modules = $objModules->GetModuleList();
$sql_source = $objModules->ExecuteFunction('GetModuleInfo', 'rel_list');
$sql_templates['ItemName'] = 'IFNULL('.$prefix."%s.%s,' ')";
$sql_templates['TableJoin'] = 'LEFT JOIN '.$prefix."%1\$s ON ".$prefix."%1\$s.ResourceId = rel.TargetId";
$sql_templates['TargetName'] = "IF(rel.TargetType = %s, '%s', %s)";
$sql = "SELECT TRIM(CONCAT(%s)) AS ItemName, %s AS ItemType,".
GetELT('rel.Type+1', Array('la_Text_OneWay','la_Text_Reciprocal')).' AS RelationType,'.
"RelationshipId, rel.Priority AS Priority, rel.Type as Type, rel.Enabled as Enabled,".
GetELT('rel.Enabled+1', Array('la_Text_Disabled','la_Text_Enabled')).' AS Status '.
'FROM '.$reltable.' AS rel %s WHERE rel.SourceId = '.$c->Get('ResourceId');
$sql_parts = Array();
$sql_parts['TargetName'] = "''";
foreach($modules as $module)
{
$sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $sql_source[$module]['MainTable'], $sql_source[$module]['ItemNameField']);
$sql_parts['TableJoin'][] = sprintf($sql_templates['TableJoin'], $sql_source[$module]['MainTable']);
$sql_parts['TargetName'] = sprintf( $sql_templates['TargetName'],
$sql_source[$module]['TargetType'],
admin_language($sql_source[$module]['ItemNamePhrase']),
$sql_parts['TargetName']);
}
$sql = sprintf($sql, implode(', ',$sql_parts['ItemName']), $sql_parts['TargetName'], implode(' ',$sql_parts['TableJoin']));
// ==== build sql depending on modules installed: end ====
if( isset($RelFilter) && $RelFilter )
{
$sql .= " AND (".$RelFilter.")";
}
$SearchWords = $objSession->GetVariable("LinkRelSearchWord");
if(strlen($SearchWords))
{
$having = $objRelList->AdminSearchWhereClause($SearchWords);
}
else
$having = "";
if(strlen($having))
$sql .= " HAVING ($having) ";
if(strlen(trim($objConfig->Get("LinkRelation_LV_Sortfield"))))
{
$order = " ORDER BY rel.Priority DESC, ".$objConfig->Get("LinkRelation_LV_Sortfield")." ".$objConfig->Get("LinkRelation_LV_Sortorder");
}
else
$order = " ORDER BY rel.Priority DESC";
$total_records = QueryCount($sql);
$objRelList->RefreshPage('Page_Relations', $total_records);
if($objConfig->Get("Perpage_Relations")>0)
{
$objListView->PerPage = $objConfig->Get("Perpage_Relations");
}
$sql .= $order." ".$objRelList->GetLimitSQL();
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."
\n";
$objRelList->Query_Item($sql);
$objListView = new clsListView($objListToolBar,$objRelList);
$objListView->IdField = "RelationshipId";
$objListView->PageLinkTemplate = $pathtoroot.$admin."/templates/user_page_link.tpl";
for($i=0;$iItems);$i++)
{
$rel =& $objRelList->GetItemRefByIndex($i);
$objListView->RowIcons[] = $rel->Admin_Icon();
}
$objListView->ColumnHeaders->Add("ItemName",admin_language("la_ColHeader_Item"),1,0,$order,"width=\"20%\"","LinkRelation_LV_Sortfield","LinkRelation_LV_Sortorder","ItemName");
$objListView->ColumnHeaders->Add("ItemType",admin_language("la_ColHeader_ItemType"),1,0,$order,"width=\"20%\"","LinkRelation_LV_Sortfield","LinkRelation_LV_Sortorder","ItemType");
$objListView->ColumnHeaders->Add("RelationType",admin_language("la_prompt_RelationType"),1,0,$order,"width=\"20%\"","LinkRelation_LV_Sortfield","LinkRelation_LV_Sortorder","RelationType");
$objListView->ColumnHeaders->Add("Status",admin_language("la_prompt_Status"),1,0,$order,"width=\"10%\"","LinkRelation_LV_Sortfield","LinkRelation_LV_Sortorder","Status");
$objListView->ColumnHeaders->SetSort($objConfig->Get("LinkRelation_LV_Sortfield"), $objConfig->Get("LinkRelation_LV_Sortorder"));
$objListView->PrintToolBar = FALSE;
$objListView->SearchBar = TRUE;
$objListView->SearchKeywords = $SearchWords;
$objListView->SearchAction="l_rel_search";
$objListView->CurrentPageVar = "Page_Relations";
$objListView->PerPageVar = "Perpage_Relations";
$objListView->CheckboxName = "itemlist[]";
$objListView->TotalItemCount = $total_records;
$filter = false; // always initialize variables before use
if($objSession->GetVariable("LinkRelSearchWord") != '') {
$filter = true;
}
else {
if ($RelView != $Rel_AllValue) {
$filter = true;
}
}
$title = prompt_language("la_Text_Editing")." ".prompt_language("la_Text_Link")." '".$c->Get("Name")."' - ".prompt_language("la_tab_Relations");
int_header($objListToolBar,NULL,$title);
if ($objSession->GetVariable("HasChanges") == 1) {
?>