SourceTable = $objSession->GetEditTable("News");
$objEditItems->EnablePaging = FALSE;
$objRelList = new clsRelationshipList();
$objReviewList = new clsItemReviewList();
$application->SetVar('n_mode', 't');
$objCustomFields = new clsCustomFieldList(2);
$objCustomDataList = new clsCustomDataList();
$objImages = new clsImageList();
//Multiedit init
if ($_GET["new"] == 1)
{
$c = new clsNews(NULL);
$c->Set("CreatedOn", adodb_mktime());
// echo "val: ".$objConfig->Get("News_Archive")."
\n";
if($objConfig->Get("News_Archive")>0)
{
$e = ((int)$objConfig->Get("News_Archive")*86400) + (int)adodb_date("U");
$c->Set("EndOn", $e);
}
else
$c->Set("EndOn",0);
$c->Set("StartDate",0);
$c->Set("CategoryId",$objCatList->CurrentCategoryID());
$c->Set("HotItem",2);
$c->Set("NewItem",2);
$c->Set("PopItem",2);
$c->Set("Status",2);
$c->Set('AutomaticFilename', 1);
$c->Set("TextFormat",1); //html enabled
if($objSession->Get("PortalUserId")>0)
{
$u = $objUsers->GetUser($objSession->Get("PortalUserId"));
$c->Set("Author",$u->Get("Login"));
}
else
{
$c->Set("Author","root");
}
$en = 0;
$action = "n_add_article";
$objArticleList->CreateEmptyEditTable("NewsId");
$objRelList->CreateEmptyEditTable("SourceId");
$objCustomDataList->CreateEmptyEditTable('n');
$objArticleList->CreateEmptyCatListTable("ItemResourceId");
$objReviewList->CreateEmptyEditTable("ReviewId");
$objImages->CreateEmptyEditTable("ResourceId");
$TitleVerb = prompt_language("la_Text_Adding");
$Org = NULL;
}
else
{
$env_id=$n_var_list['id'];
if($env_id) $_POST['newslist']=Array($env_id);
$en = (int)$_GET["en"];
if($_GET["item"])
{
if($_GET["newsession"]==1)
{
$objSession->CopyToNewSession();
$objEditItems->SourceTable = $objSession->GetEditTable("News");
}
/*shortcut to edit link */
$objArticleList->CopyToEditTable("ResourceId",$_GET["item"]);
}
else
{
if (isset($_POST["newslist"]))
{
$objArticleList->CopyToEditTable("NewsId",$_POST["newslist"]);
}
}
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
/* make a copy of the relationship records */
if(isset($_POST["newslist"]) || $_GET["item"])
{
$ids = $objEditItems->GetResourceIDList();
$objRelList->CopyToEditTable("SourceId",$ids);
$objCustomDataList->CopyToEditTable('n', $ids);
$objArticleList->CopyCatListToEditTable("ItemResourceId", $ids);
$objReviewList->CopyToEditTable("ItemId",$ids);
$objImages->CopyToEditTable("ResourceId",$ids);
}
$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 = "n_edit_article";
$TitleVerb = prompt_language("la_Text_Editing");
/* check to see if this is a pending item */
if((int)$c->Get("OrgId")>0 && $c->Get("Status")==-2)
{
$Org = new clsNews($c->Get("OrgId"));
}
else
$Org = NULL;
}
$envar = "env=" . BuildEnv() . "&en=$en";
//$formaction = "addarticle.php?".$envar;
//Set Section
//if (isset($itemlist))
$section = 'in-news:editarticle_general';
//else
// $section = 'in-news:addarticle_general';
//Set Environment Variable
$saveURL = $admin."/".$objSession->GetVariable('ReturnScript');
//Display header
$sec = $objSections->GetSection($section);
$objCatToolBar = new clsToolBar();
$objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('article','NewsEditStatus','$saveURL',1);","tool_select.gif");
$objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('article','NewsEditStatus','$saveURL',2);","tool_cancel.gif");
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl."in-news/admin/addarticle.php";
$StatusField = "NewsEditStatus";
$form = "article";
MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"));
//$objCatToolBar->Add("divider");
}
$article_t = inp_textarea_unescape($c->parsetag("article_title"));
if (strlen($article_t))
$editing_title = "'".$article_t."' ";
else
$editing_title = "";
$title = $TitleVerb." ".prompt_language("la_Text_Article")." $editing_title- ".prompt_language("la_tab_General");
int_header($objCatToolBar,NULL,$title);
if ($objSession->GetVariable("HasChanges") == 1) {
?>