<?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($_REQUEST['action']) && $_REQUEST['action'] == "custom_module") {
	$show_init_form = true;


	// Initialize defaults

	$fal_title = "";
	$fal_title_tag = "h1";
	$fal_meta_desc = "";
	$fal_meta_keywords = "";
	$current_catdom_module_id = $admin_catdom_module_id;

}

if($show_init_form) {
	
	?>
	<style type="text/css">
		#selected_categs ul {
			margin:4px;
			padding:0;
		}
		
		#selected_categs ul li {
			list-style:none;
			margin: 3px;
		}
	
	</style>
	<?php
	
	require_once(dirname(__FILE__) . "/../../admin/modules/contents/functions.php");
	require_once(dirname(__FILE__) . "/../../admin/functions/root_display.php");
	require_once(dirname(__FILE__) . "/../../admin/classes/tree_checkbox_class.php");

	//print_r($module_params);
	// Try to get any previously saved customization
	if(isset($module_params) && is_array($module_params)) {
		foreach ($module_params as $key=>$value) {
			${$key} = $value;
		}
	}
	
	$side_parent_id_ar = array();
	if(isset($side_parent_id) && count($side_parent_id)>0) {
		foreach ($side_parent_id as $art_id) {
			$side_parent_id_ar[$art_id] = "==not found==";
		}
	}
	?>
	<form method="POST" action="custom_module_update.php" name="full_adverts_list_frm" id="full_adverts_list_frm">

		<div class="inline_container">
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<th nowrap align="left" colspan="2">Full Adverts List - Customization</th>
				</tr>
				<tr>
					<td class="itdh" align="left">Title</td>
					<td class="itd_lb"><input type="text" name="fal_title" id="fal_title" value="<?php echo $fal_title;?>" maxlength="255" style="width:100%;"></td>
				</tr>
                <tr>
                    <td nowrap class="itdh">Title TAG</td>
                    <td class="itd">
                        <?php
                        $tags = array(
                            'h1', 'h2', 'h3', 'span'
                        );
                        ?>
                        <select name="fal_title_tag">
                            <?php
                            foreach ($tags as $tag) {
                                $selected = "";
                                if($tag == $fal_title_tag) $selected = 'selected="selected"';
                                echo '<option value="', $tag, '" ', $selected, '>', strtoupper($tag), '</option>';
                            }
                            ?>
                        </select>
                    </td>
                </tr>
				<tr>
					<td class="itdh" align="left">META Desc</td>
					<td class="itd_lb"><textarea name="fal_meta_desc" id="fal_meta_desc" rows="3" cols="30" style="width:100%;"><?php echo $fal_meta_desc;?></textarea></td>
				</tr>
				<tr>
					<td class="itdh" align="left">META Keywords</td>
					<td class="itd_lb"><textarea name="fal_meta_keywords" id="fal_meta_keywords" rows="3" cols="30" style="width:100%;"><?php echo $fal_meta_keywords;?></textarea></td>
				</tr>
				<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>
		</div>
	</form>

	<?php
	
	$module_forms = array(
		"form_name" => "full_adverts_list_frm",
		"form_action" => "",
		"form_method" => "POST"
	);
}
else {
	// We are in the front-end
	// Initialize defaults
	$fal_title = "";
    $fal_title_tag = "h1";
	$fal_meta_desc = "";
	$fal_meta_keywords = "";
	
	// Try to get any customization done
	if(isset($module_params) && is_array($module_params)) {
		
		if(isset($_REQUEST['debug'])) {
			echo '<pre>', var_export($module_params), '</pre>';
		}
		
		foreach ($module_params as $key=>$value) {
			${$key} = $value;
		}
	}
}
?>
