Location: PHPKode > projects > EZphotopress > ezphotopress-1.0.0/admin/posts/managePosts.php
<h3><?=$typeObject==OBJECT_ENABLE?MANAGEPOSTS_TITLE:MANAGEDISABLEDPOSTS_TITLE?></h3>
<br>
<br>
<h3 onClick="expandcontent('sc1')" style="cursor:pointer; margin-left: auto; margin-right: auto;"><?=MANAGEPOSTS_ADVANCED_SEARCH?></h3>
<div id="sc1" class="switchcontent" style="text-align: center; margin-left: auto; margin-right: auto;">
<form action="home.php?id=blog&action=manage&type=<?=$typeObject?>" method="post">
	<table style="margin-left: auto; margin-right: auto; text-align: left; width: 700px;" border="0" cellpadding="2" cellspacing="2">
		<tr>
			<td class="td_left">
				<?=MANAGEPOSTS_ADVANCED_SEARCH_1?>
			</td>
			<td class="td_right">
				<input type="text" name="value" class="form">
			</td>
			<td class="td_right">
				<?=MANAGEPOSTS_ADVANCED_SEARCH_2?>
			</td>
		</tr>
		<tr>
			<td class="td_left">
				<?=MANAGEPOSTS_ADVANCED_SEARCH_3?>
			</td>
			<td class="td_center">
				<select name="order">
					<option value="title"><?=MANAGEPOSTS_ADVANCED_SEARCH_4?></option>
					<option value="create_date"><?=MANAGEPOSTS_ADVANCED_SEARCH_5?></option>
				</select>
			</td>
			<td class="td_right">
				
			</td>
		</tr>
		<tr>
			<td class="td_left">
				<?=MANAGEPOSTS_ADVANCED_SEARCH_6?>
			</td>
			<td class="td_center">
				<select name="maxr" class="form">
					<option value="10">10</option>
					<option value="20">20</option>
					<option value="30">30</option>
					<option value="40">40</option>
					<option value="50">50</option>
				</select>
			</td>
		</tr>
		
		<tr>
			<td colspan="3" rowspan="1" style="text-align: center;">
				<input type="submit" name="submit" value="<?=MANAGEPOSTS_ADVANCED_SEARCH_FORM_SUBMIT?>" />
				&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="reset" name="reset" value="<?=MANAGEPOSTS_ADVANCED_SEARCH_FORM_RESET?>" />
			</td>
		</tr>
	</table>
</form>
<br>
<br>
<h3 onClick="closeComponent('sc1')" style="cursor:pointer; margin-left: auto; margin-right: auto;"><?=MANAGEPOSTS_CLOSE?></h3>
</div>
<br>
<?php
//set value for deleted options
$isDeleted = $typeObject==OBJECT_ENABLE?1:0;
if (isset($_POST['submit']) && $_POST['submit'] == MANAGEPOSTS_ADVANCED_SEARCH_FORM_SUBMIT) {
	//get all parameter
	$value = $_POST['value']; //value to search
	$order = $_POST['order']; // order result by
	$maxr = $_POST['maxr']; //max result per page
	
	$query = "select * from ".TABPREFIX."blog where published = ".$isDeleted;

	if (isset($value) && $value != "") {
		$query .= " and (lower(title) like '%".strtolower($value)."%' || lower(body) like '%".strtolower($value)."%')";
	}

	$query .= " order by ".$order;

	//query to count object for pagination
	$sqlCount = "select count(id) as total from ".TABPREFIX."blog where published = ".$isDeleted;
	if (isset($value) && $value != "") {
		$sqlCount .= " and (lower(title) like '%".strtolower($value)."%' || lower(body) like '%".strtolower($value)."%')";
	}
} else {
	$query = "select * from ".TABPREFIX."blog where published = ".$isDeleted." order by title,create_date";
	$maxr = 10;
	
	//query to count object for pagination
	$sqlCount = "select count(id) as total from ".TABPREFIX."blog where published = ".$isDeleted;
}

//count the items
$queryCount = $db->query($sqlCount);
$resultCount = $queryCount->fetch();

if (@$resultCount['total'] > 0) {

//number of items per page
$npp = @$_GET['npp'];
$maxr = (isset($npp) && $npp != "") ? $npp : $maxr;

// start pager class
$pager = new Pager($db,$maxr);

// page number
$pager->PageNumber=@$_GET[PageNumber];

// sql query 
$pager->sql_query($query);

// Previous Page Link
if($pager->PreviousPage()) {
	echo " <a href='home.php?id=blog&action=manage&npp=".$maxr."&PageNumber=".$pager->PreviousPage()."'>Previous</a>";
}
	
// print page link number
foreach($pager->PageLink() as $key=>$value) {
	if($pager->PageNumber()==$key) {		
		echo "<b>".$key."</b>";	
	} else {
		echo " <a href='home.php?id=blog&action=manage&npp=".$maxr."&PageNumber=".$key."'>".$key."</a>";		
	}
}
	
// Next Page Link
if($pager->NextPage()) {
	echo " <a href='home.php?id=blog&action=manage&npp=".$maxr."&PageNumber=".$pager->NextPage()."'>Next</a>";	
}

?>
<br>
<table style="margin-left: auto; margin-right: auto; text-align: left; width: 600px;" border="0" cellpadding="2" cellspacing="2">			
	<tr>
		<td class="td_right">
			<?=MANAGEPOSTS_TITLE_TABLE?>
		</td>
		<td class="td_right">
			<?=MANAGEPOSTS_CREATE_TABLE?>
		</td>
		<td class="td_right">
			
		</td>
	</tr>
	<?php
	echo"<hr>";
	// print records
	foreach($pager->mysql_fetch() as $row) {
		extract($row);
		?>
		<tr>
			<td class="td_right">
				<?php echo $title; ?>
			</td>
			<td class="td_right">
				<?php echo $utils->convertDateToPhp($create_date); ?>
			</td>
			<td>
				<?php 
				if ($isDeleted == 1) {
					?>
					<!-- modify -->
					<a href="home.php?id=blog&action=modify&bid=<?php echo $id; ?>" class="error"><img src="images/modify.png" alt="<?=MANAGEPOSTS_TOOLTIP_MODIFY?>" title="<?=MANAGEPOSTS_TOOLTIP_MODIFY?>"></a>
					&nbsp;
					<!-- disable -->
					<a href="home.php?id=blog&action=enable&enable=off&bid=<?php echo $id; ?>" class="error" onclick="return confirm('<?=MANAGEPOSTS_DISABLED_QUESTION; ?>')"><img src="images/unpublished.png" alt="<?=MANAGEPOSTS_TOOLTIP_DISABLE?>" title="<?=MANAGEPOSTS_TOOLTIP_DISABLE?>"></a>
					<?php 
				} else {
					$msg = MANAGEDISABLEDPOSTS_ENABLE_QUESTION;
					$msgDelete = MANAGEDISABLEDPOSTS_DELETE_QUESTION;
					?>
					<!-- delete -->
					<a href="home.php?id=blog&action=delete&bid=<?php echo $id; ?>" class="error" onclick="return confirm('<?php echo $msgDelete; ?>')"><img src="images/delete.png" alt="<?=MANAGEDISABLEDPOSTS_TOOLTIP_DELETE?>" title="<?=MANAGEDISABLEDPOSTS_TOOLTIP_DELETE?>"></a>
					&nbsp;
					<!-- enable -->
					<a href="home.php?id=blog&action=enable&enable=on&bid=<?php echo $id; ?>" class="error" onclick="return confirm('<?php echo $msg; ?>')"><img src="images/published.png" alt="<?=MANAGEDISABLEDPOSTS_TOOLTIP_ENABLE?>" title="<?=MANAGEDISABLEDPOSTS_TOOLTIP_ENABLE?>"></a>
					<?php  
				}
				?>
				
			</td>
		</tr>
		<?php
	}
	?>
</table>
<?php
} else {
	?>
	<p class="ok">
		<?=MANAGEPOSTS_NO_FOUND?>
	</p>	
	<?php 
}

?>
Return current item: EZphotopress