<?php
$show_init_form = false;	/* To display or not the initialization form */

/* Try to see if the call is from administration panel */
if(isset($admin_catdom_module_id) && $admin_catdom_module_id>0 && isset($_GET['action']) && $_GET['action'] == "custom_module") {
	$show_init_form = true;

	// Get Article details
	$q = "select * from left_content where catdom_module_id='$admin_catdom_module_id';";
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) == 1) {
		$row = mysql_fetch_assoc($r);
		$params_location = $row['location'];
	}
	
	$main_article_link_title = "";
	$main_article_show_abstract = 1;
	$current_catdom_module_id = $admin_catdom_module_id;

}

if($show_init_form) {

	// Try to get any previously saved customization
	if(isset($module_params) && is_array($module_params)) {
		foreach ($module_params as $key=>$value) {
			${$key} = $value;
		}
	}
	?>
	<div class="inline_container">
	<form method="POST" action="custom_module_update.php" name="main_article_link_frm" id="main_article_link_frm">
		<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<tr>
				<th colspan="2" align="left">
					Main Article Link Settings
				</th>
			</tr>
			<tr>
				<td nowrap class="itdh">Link Title</td>
				<td class="itd">
					<input type="text" name="main_article_link_title" id="main_article_link_title" value="<?php echo $main_article_link_title;?>" size="30" maxlength="255" style="width:100%;">
				</td>
			</tr>
			<?php
			if($params_location == "middle") {
				?>
				<tr>
					<td nowrap class="itdh">Show the abstract text ? (if exists)</td>
					<td class="itd">
						<input type="radio" name="main_article_show_abstract" id="main_article_show_abstract_on" value="1" style="vertical-align:middle;" <?php echo (intval($main_article_show_abstract) == 1) ? 'checked="checked"' : '';?>> Yes 
						<input type="radio" name="main_article_show_abstract" id="main_article_show_abstract_on" value="0" style="vertical-align:middle;" <?php echo (intval($main_article_show_abstract) == 0) ? 'checked="checked"' : '';?>> No 
					</td>
				</tr>
				<?php
			}
			?>
			<tr>
				<td colspan="2" align="right" class="footer">
					<input type="reset" value="Reset" name="submit" class="submit_button"/>
					<input type="submit" value="Save" name="submit" class="submit_button"/>
					<input type="hidden" value="<?php echo $current_catdom_module_id; ?>" name="admin_catdom_module_id" id="admin_catdom_module_id"/>
				</td>
			</tr>
		</table>
	</form>
	</div>
	<script type="text/javascript">
		//initTree();
	</script>
	<?php
	
	$module_forms = array(
		"form_name" => "main_article_link_frm",
		"form_action" => "",
		"form_method" => "POST"
	);
}
else {
	// We are in the front-end
	// Initialize defaults
	$main_article_link_title = "";
	$main_article_show_abstract = 1;
	$middle_parent_id = isset($middle_parent_id) && intval($middle_parent_id) > 0 ? $middle_parent_id : 0;
	
	// Try to get any customization done
	if(isset($module_params) && is_array($module_params)) {
		foreach ($module_params as $key=>$value) {
			${$key} = $value;
		}
	}
}
?>
