<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created:	11/28/2013	ELL
// 

	include ("check_session.php");

	$last_page_edited = $_SESSION['last_page_edited'];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Blog Select</title>
<link rel="stylesheet" href="manager.css" type="text/css">

<script language="javascript" type="text/javascript">
function OpenHelpWindow()
{
	window.open("http://breezewebsitebuilder.com/docs/cms/help.html#blogging", "Help", "scrollbars=1,resizable=1,status=0,toolbar=0,menubar=0,location=0,height=700,width=800");
}
</script>
</head>

<body>
<div id="sub_level_1_buttons">
<table border="0"><tr><td valign="top">
	
        <div class="button_heading_sub_level_1"><div class="button_heading_text_sub_level_1">Create Blog on Page</div><div class="button_heading_help" onclick="OpenHelpWindow();">&nbsp;</div></div>
		<?php
			if (($access_level == "restricted") || ($access_level == "blogger"))
				$query = "SELECT page_name FROM " . BWB_TABLE_PREFIX . "page_data WHERE restricted = 0 ORDER BY page_name";
			else
				$query = "SELECT page_name FROM " . BWB_TABLE_PREFIX . "page_data ORDER BY page_name";
			$result = $bwb_dbh->query($query);
			$num_results = $result->rowCount();
			for ($i = 0; $i < $num_results; $i++)
			{
				$row = $result->fetch(PDO::FETCH_ASSOC);
				$page_name = $row["page_name"];
				if ($page_name == $last_page_edited)
					$selected = " down_sub";
				else
					$selected = "";
				if ($page_name == "index")
					$home = " (Home)";
				else
					$home = "";
				
				echo "<div class='button_sub_level_1$selected' onClick=\"window.location='create_blog.php?page_name=$page_name&mode=blog';\"><span class='button_text_sub_level_1'>$page_name$home</span></div>\n";
			}
			
		?>
		
     </td><td valign="top">
    
         <div class="button_heading_sub_level_1"><div class="button_heading_text_sub_level_1">Edit Post</div><div class="button_heading_help" onclick="OpenHelpWindow();">&nbsp;</div></div>
		<?php
			$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "blogs WHERE `owner`='" . $userid . "' ORDER BY revised";
			$result = $bwb_dbh->query($query);
			$num_results = $result->rowCount();
			for ($i = 0; $i < $num_results; $i++)
			{
				$row = $result->fetch(PDO::FETCH_ASSOC);
				$blog_id = $row["id"];
				$blog_page = $row["page_name"];
				$blog_revised = $row["revised"];
				if ($blog_id == $last_blog_edited)
					$selected = " down_sub";
				else
					$selected = "";
				
				echo "<div class='button_sub_level_1$selected' onClick=\"window.location='edit_page.php?blog_id=$blog_id&mode=blog';\"><span class='button_text_sub_level_1'>$blog_page $blog_revised</span></div>\n";
			}
			
		?>
        
     </td></tr></table>
</div>
</body>
</html>