<?php
require_once ("../config.inc.php");
require_once ("../includes/adminlogincheck.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../includes/arrays.inc.php");
require_once ("../classes/miscellaneous.class.php");

$message	= "";
$data		= array();
$flag		= isset($_REQUEST['act'])	?	trim($_REQUEST['act'])	:	"0";
$title		= isset($_REQUEST['title'])	?	trim($_REQUEST['title'])	:	"";
$order		= isset($_REQUEST['order'])	?	trim($_REQUEST['order'])	:	"";
$image='<img src="../images/bgar.gif"></img>';
if($order=='DESC') {

    $image='<img src="../images/descar.gif"></img>';
}

else if($order=='ASC') {

    $image='<img src="../images/ascrar.gif" ></img>';

}
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objM		= new miscellaneous($objDB);
	
	if ($flag == "1") {
		$message	= "<font color='green'>You have successfully saved the details.</font><br>";
	} 
	$data		= $objM->get_all_cms($title.' '.$order);
	if (empty($data))
		$message	.= "No record(s) exists.<br>";
}

include_once('title.inc.php');
?>
<?php include_once('tophtml.php');?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="white"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="72%" valign="top">
			<table width="100%"  border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="5">
                <tr>
                    <td height="10">&nbsp;</td>
                </tr>
              <tr>
                <td width="41%" class="headings1" colspan="2">Contents</td>
              </tr>
            </table>
			<div class="bordernew padding2">
		<form name="form1" method="post" action="" onSubmit="return confirm_check();">
          <table width="100%"  border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td><table width="100%"  border="0" cellspacing="1" cellpadding="0" class="listing_tbl_admin">
					<?php 	if(isset($message) && $message!='')
							{
					?>
                <tr align="left">
                  <td align="center" class="maintext2">&nbsp;</td>
                  <td colspan="2" class="maintext2 warning"><?php echo $message;?></td>
                  </tr>
				<?php }//end if
					  if ($objDB) 
					  { 
                 			if (!empty($data)) 
							{ 
				?>
                <tr align="left">
                  <th align="center" class="maintext2">#</th>
                  <th class="maintext2">Content<a href="cms.php?title=vTitle&order=<?php echo $order == 'ASC' ? 'DESC' : 'ASC'?>"><?php echo $image ?></a></th>
                  <th class="maintext2">Action</th>
                  </tr>
					<?php  
							foreach ($data as $key => $value) 
							{ 
				?>
                <tr align="left">
                  <td width="4%" align="center" class="maintext2"><?php echo $key+1;?></td>
                  <td width="33%" class="maintext2"><?php echo htmlspecialchars(stripslashes($value['vTitle']))?></td>
                  <td width="63%" class="maintext2"><a href="view_page.php?id=<?php echo $value['nCMS_Id']?>" class="signupbuttonlink">View</a>&nbsp;&nbsp;<a href="manage_page.php?id=<?php echo $value['nCMS_Id']?>" class="signupbuttonlink">Edit</a></td>
                  </tr>
				<?php 			}//end foreach
					 		}//end if
						}//end first if
				?>
              </table>
				<?php if(!empty($data))
					  {
				?>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="82%">&nbsp;</td>
                    <td width="18%"><table width="100%"  border="0" cellspacing="2" cellpadding="0">
                        <tr align="center" class="textbox">
                          <td><?php echo $objP->links;?></td>
                          </tr>
                    </table></td>
                  </tr>
                </table><?php }//end if?>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                      </td>
                  </tr>
                </table></td>
            </tr>
          </table></form>
		  </div>
			</td>
          </tr>
		  <tr>
		  	<td>
				
			</td>
		  </tr>
        </table>
		</td>
        </tr>
    </table>      
    </td>
  </tr>
</table>
<?php include_once('bottomhtml.php');?>