<?php 
/*
 *
 * sflog!
 * Copyright (C) 2005 Alberto Sfolcini <a.sfolcini@gmail.com>
 *
 * This file is a part of sflog!.
 *
 * sflog! is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * sflog! is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */
 
  error_reporting(E_USER_ERROR);
  
  require_once(dirname(__FILE__)."/../../cms/Validator.class.php");
  require_once(dirname(__FILE__)."/../../cms/Blog.class.php");
  require_once(dirname(__FILE__)."/../../cms/Auth.class.php");
  require_once(dirname(__FILE__)."/../../cms/Constants.inc.php");
  
  
  // Check for authorizations
  $auth = new Auth();
  if (!$auth->isAuth()){
  	header("Location: login.php");
  	die();
  }
  // ------ end auth's check
  
  $cms = new Blog();

  if (isset($_POST['blogID'])){
  	if (!($_POST['blogID']=='')){
  	  $blogID = $_POST['blogID'];	
	}
  }else{
  	if (isset($_GET['blogID']))
  		$blogID = $_GET['blogID'];
  	else
  		$blogID = "";
  }
  if (isset($_POST['contentType'])){
		if (!$_POST['contentType']=='')
			$contentType = $_POST['contentType'];
  }else{
  	if (isset($_GET['contentType']))
  		$contentType = $_GET['contentType'];
  	else
  		$contentType = "";
  }
?>	

<FORM name="section" action="<?=$_SERVER['PHP_SELF']?>" method="POST">
	<table cellspacing="0" cellpaddgin="0" border="0">
			<tr>
			<td><b>Select a blog</b></td>
			<td>
				<SELECT name="blogID" onChange="section.submit();">
					<OPTION></OPTION>
				<?
					$blogs = $cms->getBlogsID();
					foreach($blogs as $id){
						$blogName = $cms->getBlogFullName($id);
						if (strcasecmp($blogID,$id)==0)
							$selected = "selected";
						else
							$selected = "";
						print('<OPTION value='.$id.' '.$selected.'>'.$id.'</OPTION>');
					}
				?>
				</SELECT>
			</td>
			<td><?
					if (isset($blogID))
						$cms->getBlogFullName($blogID);
				?></td>
		</tr>
	<?
	  if (isset($blogID)){
		if (trim($blogID)!=''){
	?>
		<tr>
			<td><b>section's type </b>&nbsp;</td>
			<td>
				<SELECT name="contentType" onChange="section.submit();">
					<OPTION></OPTION>
					<OPTION value="<?=_BLOGS?>" <?if ($contentType==_BLOGS) print('selected')?>>Blog::CMS sections</OPTION>
					<OPTION value="<?=_LINKS?>" <?if ($contentType==_LINKS) print('selected')?>>Links</OPTION>
					<OPTION value="<?=_BANNER?>" <?if ($contentType==_BANNER) print('selected')?>>Banner</OPTION>
					<OPTION value="<?=_CALENDAR?>" <?if ($contentType==_CALENDAR) print('selected')?>>Calendar archive</OPTION>
					<OPTION value="<?=_ALBUM?>" <?if ($contentType==_ALBUM) print('selected')?>>Photo album</OPTION>
					<OPTION value="<?=_UPLOADPHOTO?>" <?if ($contentType==_UPLOADPHOTO) print('selected')?>>Upload photoAlbum content</OPTION>
					<OPTION value="<?=_GOOGLE?>" <?if ($contentType==_GOOGLE) print('selected')?>>Google Search</OPTION>
					<OPTION value="<?=_CONTENT?>" <?if ($contentType==_CONTENT) print('selected')?>>Upload content</OPTION>					
				</SELECT>
			</td>
		</tr>
		<?}}?>
	</table>
</FORM>

<HR size="-1">

<?php
	if (isset($contentType)){
		switch($contentType){
			case _BLOGS: {
				require_once(dirname(__FILE__)."/sectionTitle.inc.php");
				print("<hr>");
				require_once(dirname(__FILE__)."/contentBlog.inc.php");
				break;
			}
			case _LINKS: {
				require_once(dirname(__FILE__)."/linkTitle.inc.php");
				print("<hr>");
				require_once(dirname(__FILE__)."/contentLink.inc.php");
				break;
			}
			case _BANNER: {
				require_once(dirname(__FILE__)."/contentBanner.inc.php");
				break;
			}
			case _CALENDAR: {
				//require_once(dirname(__FILE__)."/calendarTitle.inc.php");
				//print("<hr>");
				require_once(dirname(__FILE__)."/contentCalendar.inc.php");
				break;
			} 
			case _GOOGLE: {
				require_once(dirname(__FILE__)."/contentGoogle.inc.php");
				break;
			}
			case _ALBUM: {
				require_once(dirname(__FILE__)."/albumTitle.inc.php");
				print("<hr>");				
				require_once(dirname(__FILE__)."/contentAlbum.inc.php");
				break;
			}
			case _UPLOADPHOTO: {
				require_once(dirname(__FILE__)."/photoBlogContent.inc.php");
				break;
			}
			case _CONTENT: {
				require_once(dirname(__FILE__)."/uploadContent.inc.php");
				break;
			}
		}
	}
	
	
?>
