<?php
##############################################################
##In-portal                                     ##
##############################################################
##                   In-portal                     ##
##             Intechnic Corporation               ##
##          All Rights Reserved, 1998-2002            ##
##                                           ## 
## No portion of this code may be copied, reproduced or  ## 
##    otherwise redistributed without proper written     ##
##   consent of Intechnic Corporation.  Violation will      ##
##    result in revocation of the license and support    ##
##  privileges along maximum prosecution allowed by law. ##
##############################################################

// new startup: begin
define('REL_PATH', 'in-news/admin');
$relation_level = count( explode('/', REL_PATH) );
define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) );
require_once FULL_PATH.'/kernel/startup.php';
// new startup: end

$pathtolocal = $pathtoroot."in-news/";
require_once ($pathtoroot.$admin."/include/elements.php"); 
require_once ($pathtoroot."kernel/admin/include/navmenu.php"); 
require_once ($pathtolocal."admin/include/navmenu.php"); 
require_once($pathtoroot.$admin."/toolbar.php");

unset($objEditItems);

$objEditItems = new clsNewsList();
$objEditItems->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")."<br>\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) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
  <tr>
    <td valign="top">
      <?php int_hint_red(admin_language("la_Warning_Save_Item")); ?>
    </td>
  </tr>
</table>
<?php } ?>     
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<form ID="article" enctype="multipart/form-data" name="article" action="" method=POST>
  <tr <?php int_table_color(); ?>> 
    <td valign="top" colspan="3"><?php echo prompt_language("la_prompt_Enable_HTML"); ?> 
<?php
  if($c->Get("TextFormat")==1)
    $checked=" checked";    
?>    
      <input type="checkbox" tabindex="1" name="html_enable" value="1" <?php echo $checked; ?>>
      <br>
      <?php int_hint(prompt_language("la_Warning_Enable_HTML")); ?>
    </td>
  </tr>
  <?php int_subsection_title(prompt_language("la_Text_Article")); ?>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text" ID="prompt_NewsId"><?php echo prompt_language("la_prompt_NewsId"); ?></span></td>
    <TD><?php echo $c->Get("NewsId"); ?>
    <TD><b><?php if(is_object($Org)) echo prompt_language("la_origional_values"); ?></b></TD>
  </TR>  
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span ID="prompt_news_title" class="text"><?php echo prompt_language("la_prompt_Title"); ?></span></td>
    <td> 
      <input type="text" ValidationType="exists" tabindex="2" name="news_title" class="text" size="40" value="<?php echo inp_htmlize($c->Get("Title")); ?>">
    </td>
    <td>
<?php    
  if(is_object($Org))
  {
  	 $OrgValue = $Org->Get("Title");
  	 $NewValue = $c->Get("Title");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">".inp_textarea_unescape($OrgValue)."</SPAN>"; 
  }    
?>      
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span ID="prompt_news_author" class="text"><?php echo prompt_language("la_prompt_Author"); ?></span></td>
    <td> 
     <input type="text" ValidationType="exists" tabindex="3" name="news_author" class="text" size="40" value="<?php echo inp_htmlize($c->Get("Author")); ?>">      
       <a href="#">
           <img src="<?php echo $imagesURL; ?>/icon24_link_user.gif" style="cursor:hand" border="0"
         ONCLICK="OpenUserSelector('','','<?php echo $envar; ?>&destform=article&destfield=news_author&IdField=Login&Selector=radio');">
         </a>
     </td>
    <td>
<?php    
  if(is_object($Org))
  {
  	 $OrgValue = $Org->Get("Author");
  	 $NewValue = $c->Get("Author");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">".inp_textarea_unescape($OrgValue)."</SPAN>"; 
  }    
?>         
    </td>
  </tr>
    <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN id="prompt_news_body" class="text"><?php echo prompt_language("la_prompt_ArticleBody"); ?></span><br>
       <a href="#">
         <img src="<?php echo $adminURL; ?>/icons/icon24_link_editor.gif" style="cursor:hand" border="0"
         ONCLICK="document.forms[0].elements[0].checked=true; OpenEditor('&section=<?php echo $section; ?>','article','news_body');">
         </a>
    </td>
    <td> 
      <textarea ValidationType="exists" tabindex="4" rows="8" name="news_body" id="news_body" cols="70" class="text"><?php echo inp_textarea_unescape(inp_htmlize($c->Get("Body"))); ?></textarea>
    </td>
    <td>
<?php    
  if(is_object($Org))
  {
  	 $OrgValue = $Org->Get("Body");
  	 $NewValue = $c->Get("Body");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">".substr(strip_tags($OrgValue),0,100);
  	 if(strlen($OrgValue)>100)
  	   echo " ..";
  	 echo "</SPAN>"; 
  }    
?>      
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN ID="prompt_news_excerpt" class="text"><?php echo prompt_language("la_prompt_ArticleExcerpt"); ?></SPAN></td>
    <td> 
      <textarea rows="3" name="news_excerpt" tabindex="5" cols="70" class="text"><?php echo inp_textarea_unescape(inp_htmlize($c->Get("Excerpt"))); ?></textarea>
      <br><input type="checkbox" name="excerpt_generate" tabindex="6" value="1"><?php echo prompt_language("la_prompt_AutoGen_Excerpt"); ?>
    </td>
    <td>
<?php    
  if(is_object($Org))
  {
  	 $OrgValue = $Org->Get("Excerpt");
  	 $NewValue = $c->Get("Excerpt");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">".inp_textarea_unescape($OrgValue)."</SPAN>"; 
  }    
?>      
    </td>
  </tr>
  
	<tr <?php int_table_color(); ?>>
		<td valign="top"><span id="prompt_auto_filename" class="text"><?php echo prompt_language('la_prompt_AutomaticFilename'); ?></span></td>
		<td>
			<input type="checkbox" tabindex="5" name="auto_filename" id="auto_filename" class="text" value="1"<?php if( $c->Get('AutomaticFilename') == 1) echo ' checked'; ?> onchange="reflect_filename();">
		</td>
		<td class="text">&nbsp;</td>
	</tr>
	<tr <?php int_table_color(); ?>>
		<td valign="top"><span ID="prompt_filename" class="text"><?php echo prompt_language('la_prompt_CustomFilename'); ?></span></td>
		<td>
			<input type="text" name="filename" id="filename" tabindex="1" class="text" size="63" value="<?php echo $c->Get('Filename'); ?>">
		</td>
		<td>&nbsp;</td>
	</tr>
	
   <?php int_subsection_title(prompt_language("la_tab_Properties")); ?>  

  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Status"); ?></td>
     <td> 
      <input type="radio" tabindex="7" name="status" class="text" value="1" <?php if($c->Get("Status") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Active"); ?>
<?php
  if(is_object($Org))
  {
  	$PendingVal = -2;
  }
  else
    $PendingVal = 2;
?>          
      <input type="radio" tabindex="7" name="status" class="text" value="<?php echo $PendingVal; ?>" <?php if($c->Get("Status") == $PendingVal) echo "checked"; ?>><?php echo prompt_language("la_val_Pending"); ?>
      <input type="radio" tabindex="7" name="status" class="text" value="0" <?php if($c->Get("Status") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Disabled"); ?>
     </td>
    <td class="text">
    <?php 
       if(is_object($Org))
       {
       	  echo prompt_language("la_approve_description"); 
       }       	  
    ?>       	  
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_New"); ?></td>
    <td> 
      <input type="radio" name="itemnew" class="text" tabindex="8" value="2" <?php if($c->Get("NewItem") == 2) echo "checked"; ?>><?php echo prompt_language("la_val_Auto"); ?>
      <input type="radio" name="itemnew" class="text" tabindex="8" value="1" <?php if($c->Get("NewItem") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Always"); ?>
      <input type="radio" name="itemnew" class="text" tabindex="8" value="0" <?php if($c->Get("NewItem") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Never"); ?>           
    </td>
    <td>
<?php
  if(is_object($Org))
  {
  	switch($Org->Get("NewItem"))
  	{
  		case 2:
  			echo prompt_language("la_val_Auto"); 
  		break;
  		case 1:
  		 	echo prompt_language("la_val_Always");
  		break;
  		case 0:
  			echo prompt_language("la_val_Never");
  		break;  	
  	}
  }
?>     
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Hot"); ?></td>
     <td> 
      <input type="radio" name="itemhot" class="text" tabindex="9" value="2" <?php if($c->Get("HotItem") == 2) echo "checked"; ?>><?php echo prompt_language("la_val_Auto"); ?>
         <input type="radio" name="itemhot" class="text" tabindex="9" value="1" <?php if($c->Get("HotItem") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Always"); ?>
          <input type="radio" name="itemhot" class="text" tabindex="9" value="0" <?php if($c->Get("HotItem") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Never"); ?>
         
        </td>
    <td>
<?php
  if(is_object($Org))
  {
  	switch($Org->Get("HotItem"))
  	{
  		case 2:
  			echo prompt_language("la_val_Auto"); 
  		break;
  		case 1:
  		 	echo prompt_language("la_val_Always");
  		break;
  		case 0:
  			echo prompt_language("la_val_Never");
  		break;  	
  	}
  }
?>     
    </td>
  </tr>
   <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Pop"); ?></td>
     <td> 
        <input type="radio" name="itempop" class="text" value="2" tabindex="10" <?php if($c->Get("PopItem") == 2) echo "checked"; ?>><?php echo prompt_language("la_val_Auto"); ?>
        <input type="radio" name="itempop" class="text" value="1" tabindex="10" <?php if($c->Get("PopItem") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Always"); ?>
        <input type="radio" name="itempop" class="text" value="0" tabindex="10" <?php if($c->Get("PopItem") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Never"); ?>
       
        </td>
    <td>
<?php
  if(is_object($Org))
  {
  	switch($Org->Get("PopItem"))
  	{
  		case 2:
  			echo prompt_language("la_val_Auto"); 
  		break;
  		case 1:
  		 	echo prompt_language("la_val_Always");
  		break;
  		case 0:
  			echo prompt_language("la_val_Never");
  		break;  	
  	}
  }
?>     
    </td>
  </tr> 
  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_EditorsPick"); ?></td>
    <td> 
      <input type="checkbox" name="news_pick" class="text" value="1" tabindex="11" <?php if($c->Get("EditorsPick") == 1) echo "checked"; ?>></td>
    <td>
<?php
  if(is_object($Org))
  {
  	if($c->Get("EditorsPick"))
  	{
  	  echo prompt_language("lu_yes");
  	}
  	else   
  	  echo prompt_language("lu_no");
  }  
?>        
    </td>
  </tr>

  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_LeadArticle"); ?></td>
    <td> 
      <input type="checkbox" name="news_leading" class="text" tabindex="12" value="1" <?php if($c->Get("LeadStory") == 1) echo "checked"; ?>>
    </td>
    <td>
<?php
  if(is_object($Org))
  {
  	if($c->Get("LeadStory"))
  	{
  	  echo prompt_language("lu_yes");
  	}
  	else   
  	  echo prompt_language("lu_no");
  }  
?>        
    </td>
  </tr>
   <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_CatLead"); ?></td>
    <td> 
      <input type="checkbox" name="news_leading_cat" class="text" tabindex="13" value="1" <?php if($c->Get("LeadCatStory") == 1) echo "checked"; ?>>
    </td>
    <td>
<?php
  if(is_object($Org))
  {
  	if($c->Get("LeadCatStory"))
  	{
  	  echo prompt_language("lu_yes");
  	}
  	else   
  	  echo prompt_language("lu_no");
  }  
?>        
    </td>
  </tr>

  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Priority"); ?></td>
    <td> 
        <input type="text" name="news_priority" tabindex="14" class="text" size="3" value="<?php echo $c->Get("Priority"); ?>">
    </td>
    <td>
<?php
  if(is_object($Org))
  {
  	 $OrgValue = (int)$Org->Get("Priority");
  	 $NewValue = (int)$c->Get("Priority");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">$OrgValue</SPAN>"; 
  }
?>        
    </td>
  </tr>

    <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN id="prompt_news_date" class="text"><?php echo prompt_language("la_prompt_CreatedOn"); ?></SPAN></td>
    <td> 
      <input type="text" ValidationType="date,exists" tabindex="15" name="news_date" id="news_date_selector" datepickerIcon="<?php echo $imagesURL; ?>/ddarrow.gif" class="text" size="20" value="<?php echo $c->parsetag('article_date'); ?>">      
      <span class="small"><?php echo prompt_language("la_prompt_DateFormat"); ?></span></td>
    <td>
<?php
  if(is_object($Org))
  {
  	 $OrgValue = $Org->parsetag('article_date');
  	 $NewValue = $c->parsetag('article_date');
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">$OrgValue</SPAN>"; 
  }
?>             
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN id="prompt_news_startdate" class="text"><?php echo prompt_language("la_prompt_StartDate"); ?></span></td>
    <td> 
      <input type="text" ValidationType="date" tabindex="16" name="news_startdate" id="news_startdate_selector" datepickerIcon="<?php echo $imagesURL; ?>/ddarrow.gif" class="text" size="20" value="<?php echo $c->parsetag($c->Get('StartDate') > 0 ? 'article_startdate' : 'article_date'); ?>">
      <span class="small"><?php echo prompt_language("la_prompt_DateFormat"); ?></span></td>
    <td>
<?php
  if(is_object($Org))
  {
  	 $OrgValue = $Org->parsetag('article_startdate');
  	 $NewValue = $c->parsetag('article_startdate');
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">$OrgValue</SPAN>"; 
  }
?>         
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN id="prompt_news_enddate" class="text"><?php echo prompt_language("la_prompt_ArchiveDate"); ?></td>
    <td> 
      <input type="text" ValidationType="date" tabindex="17" name="news_enddate" id="news_enddate_selector" datepickerIcon="<?php echo $imagesURL; ?>/ddarrow.gif" class="text" size="20" value="<?php echo $c->parsetag('article_enddate'); ?>">                  
      <span class="small"><?php echo prompt_language("la_prompt_DateFormat"); ?></span></td>
    <td>
<?php
  if(is_object($Org))
  {
  	 $OrgValue = $Org->parsetag('article_enddate');
  	 $NewValue = $c->parsetag('article_enddate');
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">$OrgValue</SPAN>"; 
  }
?>     
    </td>
  </tr>

  <?php int_subsection_title(prompt_language("la_Text_Counters")); ?>
  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Rating"); ?></td>
    <td> 
      <input type="text" name="news_rating" class="text" tabindex="18" size="5" value="<?php echo LangNumber($c->Get("CachedRating"),1); ?>">
      <span class="small"><?php echo prompt_language("la_prompt_RatingLimits"); ?></span></td>
    <td>
<?php
  if(is_object($Org))
  {
  	 $OrgValue = (int)$Org->Get("CachedRating");
  	 $NewValue = (int)$c->Get("CachedRating");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">$OrgValue</SPAN>"; 
  }
?>     
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Votes"); ?></td>
    <td> 
      <input type="text" name="news_votes" class="text" tabindex="19" size="5" value="<?php echo LangNumber($c->Get("CachedVotesQty",0)); ?>">
      <span class="small"><?php echo prompt_language("la_prompt_VoteLimits"); ?></span></td>
    <td>
<?php
  if(is_object($Org))
  {
  	 $OrgValue = (int)$Org->Get("CachedVotesQty");
  	 $NewValue = (int)$c->Get("CachedVotesQty");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">$OrgValue</SPAN>"; 
  }
?>      
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Views"); ?></td>
    <td> 
      <input type="text" name="news_hits_show" class="text" tabindex="20" size="5" value="<?php echo LangNumber(round($c->Get("Hits")),0); ?>">
      <input type="hidden" name="news_hits" value="<?php echo LangNumber($c->Get("Hits"),0); ?>">
      <span class="small"><?php echo prompt_language("la_prompt_HitLimits"); ?></span></td>
    <td>
<?php
  if(is_object($Org))
  {
  	 $OrgValue = (int)$Org->Get("Views");
  	 $NewValue = (int)$c->Get("Views");
  	 if($OrgValue != $NewValue)
  	 {
  	 	$class = "error";
  	 }
  	 else
  	   $class = "text";
  	 echo "<SPAN CLASS=\"$class\">$OrgValue</SPAN>"; 
  }
?>        
    </td>
  </tr>
<?php  
$CustomFieldUI = $objCustomFields->GetFieldUIList(TRUE);
if($CustomFieldUI->NumItems()>0)
{
  $objCustomDataList->SourceTable = $objSession->GetEditTable("CustomMetaData");	
  if((int)$c->Get("ResourceId")>0)
  {
	$objCustomDataList->LoadResource($c->Get("ResourceId"));
  }
  $headings = $CustomFieldUI->GetHeadingList();
  //echo "<PRE>";print_r($objCustomFields); echo "</PRE>";
  $tab_index = 21;
  for($i=0;$i<=count($headings);$i++)
  {
    $h = $headings[$i];
    if(strlen($h))
    {
        int_subsection_title(prompt_language($h));
        $Items = $CustomFieldUI->GetHeadingItems($h);
        foreach($Items as $f)
        {
        	$n = substr($f->name,1);
        	$cfield = $objCustomFields->GetItemByField("FieldName",$n,FALSE);
        	if (is_object($cfield)) {
				$f->default_value = $c->GetCustomFieldValue($n, '', 0, true);
        	}
            print "<tr ".int_table_color_ret().">\n"; 
            print "  <td valign=\"top\" class=\"text\">".$f->GetPrompt()."</td>\n";
            print "  <td nowrap>".$f->ItemFormElement($tab_index++)."</TD>";       
            if(is_object($f->NextItem))
            {
                $n = $f->NextItem;
                print "  <td>".$n->ItemFormElement($tab_index++)."</TD>";       
            }
            else
              print "  <td><span class=\"text\">&nbsp;</span></td>\n";
            print "</tr>\n";
        }
    }
  }
}  
?>    
  <input type="hidden" name="CategoryId" value="<?php echo $objCatList->CurrentCategoryID(); ?>">
  <input type="hidden" name="NewsId" value="<?php echo $c->Get("NewsId"); ?>">
  <input type="hidden" name="Action" value="<?php echo $action; ?>">
  <input type="hidden" name="NewsEditStatus" VALUE="0">
</FORM>
</table>
<script src="<?php echo $adminURL; ?>/include/calendar.js"></script>
<SCRIPT language="JavaScript">
    initCalendar("news_date_selector", CalDateFormat);
    initCalendar("news_startdate_selector", CalDateFormat);
    initCalendar("news_enddate_selector", CalDateFormat);
    function reflect_filename($e)
    {
    	var $checked = document.getElementById('auto_filename').checked;
    	document.getElementById('filename').readOnly = $checked;
    }
	reflect_filename();
</SCRIPT>  

<?php 
	MarkFields('article');
	int_footer();
?>