<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 9/9/2008
// Revised: 2/8/2012	ELL
// Added table prefix handling.
	
	include ("check_session.php");
		
	$selected_page_name = $_REQUEST['selected_page_name'];
	$metatags_saved = $_REQUEST['metatags_saved'];
		
	if (!$selected_page_name)	// First time, use first page.
	{
		$query = "SELECT page_name FROM " . BWB_TABLE_PREFIX . "page_data ORDER BY page_name";
		$result = $bwb_dbh->query($query);
		$row = $result->fetch(PDO::FETCH_ASSOC);
		$selected_page_name = $row['page_name'];
	}
	if ($selected_page_name)
	{
		$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "meta_tags WHERE page_name = '$selected_page_name'";
		$result = $bwb_dbh->query($query);
		if ($row = $result->fetch(PDO::FETCH_ASSOC))
		{
			$owner = $row["owner"];
			$author = $row["author"];
			$lanquage = $row["lanquage"];
			$copyright = $row["copyright"];
			$description = $row["description"];
			$abstract = $row["abstract"];
			$keywords = $row["keywords"];
			$subject = $row["subject"];
			$robots_index = $row["robots_index"];
			$robots_follow = $row["robots_follow"];
			$robots_revisit = $row["robots_revisit"];
		}
		else
		{
			$owner = "";
			$author = "";
			$lanquage = "ENGLISH";
			$copyright = "";
			$description = "";
			$abstract = "";
			$keywords = "";
			$subject = "";
			$robots_index = 1;
			$robots_follow = 1;
			$robots_revisit = 30;
		}
	}
	else
	{
		$owner = "";
		$author = "";
		$lanquage = "ENGLISH";
		$copyright = "";
		$description = "";
		$abstract = "";
		$keywords = "";
		$subject = "";
		$robots_index = 1;
		$robots_follow = 1;
		$robots_revisit = 30;
	}
?>
<!DOCTYPE html>
<html>
<head>
<title>Editing <?php echo $selected_page_name; ?> Meta Tags | Breeze Website Builder</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="theme/<?php echo $theme; ?>/manager.css" type="text/css">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">

<style type="text/css">
#help_button	{	
	position:relative;
	display:block;
	top:-15px;
	left:215px;
	height:31px;
	width:31px;
	z-index:100;
}
#save_metatags_btn	{	width:110px;	}
</style>

<script language="javascript" type="text/javascript" src="js/browser_detect.js"></script>
<script language="javascript" type="text/javascript" src="js/mouse_position.js"></script>
<script language="javascript" type="text/javascript" src="js/popup_msg.js"></script>
<script language="javascript" type="text/javascript" src="js/edit_meta_tags.js"></script>

</head>

<body id="workspace_body">
<table width="90%" align="center"><tr><td>
<div class="button_heading_sub_level_1" id="edit_metatags_heading"><div class="button_heading_text_sub_level_1"><?php echo EDIT_META_TAGS_HEADING; ?></div><div class="help_button" id="help_button" onClick="OpenHelpWindow();">&nbsp;</div></div>
</td></tr></table>

<form name="formEditMetatags" id="formEditMetatags" method="post" action="save_meta_tags.php">
<table width="90%" class="group_box_table" align="center">
  <tr>
    <td colspan="4" align="center" width="90%">
    <table width="100%" class="layout_box_table"><tr>
      <td width="90%">
      
	  <?php echo EDIT_META_TAGS_SELECT_PAGE; ?>:
	        <select name="page_name" id="page_name" OnChange="GetPageMetatags(this.options[this.selectedIndex].value);">
		      <?php
			$query = "SELECT page_name FROM " . BWB_TABLE_PREFIX . "page_data ORDER BY page_name";
			$result2 = $bwb_dbh->query($query);
			$num_results = $result2->rowCount();
			for ($i = 0; $i < $num_results; $i++)
			{
				$row2 = $result2->fetch(PDO::FETCH_ASSOC);
				$page_name = $row2["page_name"];
				if (($page_name == $selected_page_name) || (!$selected_page_name && !$page_selected))
				{
				if ($page_name == "index")
						echo "<option value='$page_name' selected='selected'>$page_name (Home)</option>";
					else
						echo "<option value='$page_name' selected='selected'>$page_name</option>";
					$page_selected = 1;
				}
				else
				{
					if ($page_name == "index")
						echo "<option value='$page_name'>$page_name (Home)</option>";
					else
						echo "<option value='$page_name'>$page_name</option>";
				}
			}
			
		?>
            </select>
	        
       </td>
       </tr></table>
       </td>
    </tr>
  <tr>
    <td style="padding-left:5px;"><?php echo OWNER_WORD; ?>:</td>
	<td>
      <input name="owner" type="text" id="owner" value="<?php echo $owner; ?>"></td>
    <td style="padding-left:5px;"><?php echo AUTHOR_WORD; ?>:</td> 
	<td>
      <input name="author" type="text" id="author" value="<?php echo $author; ?>"></td>
    </tr>
  <tr>
    <td style="padding-left:5px;"><?php echo LANGUAGE_WORD; ?>:</td> 
	<td>
      <input name="lanquage" type="text" id="lanquage" value="<?php echo $lanquage; ?>"></td>
    <td style="padding-left:5px;"><?php echo COPYRIGHT_WORD; ?>:</td>
	<td> 
      <input name="copyright" type="text" id="copyright" value="<?php echo $copyright; ?>"></td>
    </tr>
  <tr>
    <td style="padding-left:5px;"><?php echo DESCRIPTION_WORD; ?>:</td>
    <td colspan="3"><textarea name="description" cols="100" id="description"><?php echo $description; ?></textarea></td>
    </tr>
  <tr>
    <td style="padding-left:5px;"><?php echo ABSTRACT_WORD; ?>:</td>
    <td colspan="3"><textarea name="abstract" cols="100" id="abstract"><?php echo $abstract; ?></textarea></td>
    </tr>
  <tr>
    <td style="padding-left:5px;"><?php echo KEYWORDS_WORD; ?>:</td>
    <td colspan="3"><textarea name="keywords" cols="100" id="keywords"><?php echo $keywords; ?></textarea>
	<br>
    <span class="small_message"><?php echo EDIT_META_TAGS_KEYWORDS_NOTE; ?></span></td>
    </tr>
  <tr>
    <td style="padding-left:5px;"><?php echo SUBJECT_WORD; ?>:</td>
    <td colspan="3"><textarea name="subject" cols="100" id="subject"><?php echo $subject; ?></textarea></td>
    </tr>
  <tr>
    <td style="padding-left:5px;"><?php echo ROBOTS_WORD; ?>:</td>
    <td style="padding-left:5px;"><input name="robots_index" type="checkbox" id="robots_index" value="checkbox" <?php if ($robots_index == 1) echo "checked"; ?>>
      <?php echo INDEX_WORD; ?></td>
    <td style="padding-left:5px;"><input name="robots_follow" type="checkbox" id="robots_follow" value="checkbox" <?php if ($robots_follow == 1) echo "checked"; ?>> 
      <?php echo FOLLOW_WORD; ?></td>
    <td style="padding-left:5px;"><?php echo REVISIT_WORD; ?>: 
      <input name="robots_revisit" type="text" id="robots_revisit" value="<?php echo $robots_revisit; ?>"> 
      <?php echo DAYS_WORD; ?></td>
  </tr>
  <tr>
    <td colspan="4" align="center">
	  
        <div class='button_console_save' id="save_metatags_btn" onClick="document.getElementById('formEditMetatags').submit();"><span class='button_console_text_w_icon'><?php echo SUBMIT_WORD; ?></span></div>
      
	  </td>
    </tr>
</table>
</form>

<?php include("lib/popup_msg.html"); ?>

<script language="JavaScript"  type="text/javascript">
	HidePopupMsg();
<?php	if ($metatags_saved == 1)	{	?>
	popup_msg.top_offset = 100;
	popup_msg.left_offset = 320;
	popup_msg.popup_msg_type = 1;
	popup_msg.popup_timeout = 3000;
	popup_msg.status_msg = "<?php echo EDIT_META_TAGS_META_TAGS_SAVED_MSG; ?>";
	popup_msg.ShowPopupMsg();
<?php	}	?>
</script>

</body>
</html>
