$value)
{
$path = $pathtoroot.$value."admin/include/parser.php";
if( file_exists($path) ) include_once($path);
}
unset($objEditItems);
$objEditItems = new clsTopicList();
$objEditItems->SourceTable = $objSession->GetEditTable("Topic");
$objEditItems->EnablePaging = FALSE;
//Multiedit init
$en = (int)$_GET["en"];
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
$itemcount=$objEditItems->NumItems();
$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 = "bb_edit_topic";
$envar = "env=" . BuildEnv() . "&en=$en";
//Set Section
$section = 'in-bulletin:edittopic_relations';
//Set Environment Variable
$saveURL = $admin."/".$objSession->GetVariable('ReturnScript');
//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','TopicEditStatus','".$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','TopicEditStatus','".$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-bulletin/admin/addtopic_relations.php";
$StatusField = "TopicEditStatus";
$form = "topic";
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");
$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('addtopic_relations', 'm_rel_delete');",
"tool_delete.gif");
$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('addtopic_relations', 'm_rel_move_up');",
"tool_move_up.gif");
$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('addtopic_relations', 'm_rel_move_down');",
"tool_move_down.gif");
$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("TopicRel_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(strlen($RelFilter))
{
$sql .= " AND (".$RelFilter.")";
}
if(strlen(trim($objConfig->Get("TopicRelation_LV_Sortfield"))))
{
$order = " ORDER BY rel.Priority, ".$objConfig->Get("TopicRelation_LV_Sortfield")." ".$objConfig->Get("TopicRelation_LV_Sortorder");
}
else
$order = " ORDER BY rel.Priority";
$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=\"30%\"","TopicRelation_LV_Sortfield","TopicRelation_LV_Sortorder","ItemName");
$objListView->ColumnHeaders->Add("ItemType",admin_language("la_ColHeader_ItemType"),1,0,$order,"width=\"20%\"","TopicRelation_LV_Sortfield","TopicRelation_LV_Sortorder","ItemType");
$objListView->ColumnHeaders->Add("RelationType",admin_language("la_prompt_RelationType"),1,0,$order,"width=\"10%\"","TopicRelation_LV_Sortfield","TopicRelation_LV_Sortorder","RelationType");
$objListView->ColumnHeaders->Add("Status",admin_language("la_prompt_Status"),1,0,$order,"width=\"10%\"","TopicRelation_LV_Sortfield","TopicRelation_LV_Sortorder","Status");
$objListView->ColumnHeaders->SetSort($objConfig->Get("TopicRelation_LV_Sortfield"), $objConfig->Get("TopicRelation_LV_Sortorder"));
$objListView->PrintToolBar = FALSE;
$objListView->CurrentPageVar = "Page_Relations";
$objListView->PerPageVar = "Perpage_Relations";
$objListView->CheckboxName = "itemlist[]";
$objListView->TotalItemCount = $total_records;
$filter = false; // always initialize variables before use
if ($RelView != $Rel_AllValue) {
$filter = true;
}
$title = prompt_language("la_Text_Editing")." ".prompt_language("la_Text_Topic")." '".$c->Get("TopicText")."' - ".prompt_language("la_tab_Relations");
int_header($objListToolBar,NULL,$title);
if ($objSession->GetVariable("HasChanges") == 1) {
?>