Mini Shell

Direktori : /home/emypro/www/admin/
Upload File :
Current File : /home/emypro/www/admin/noticias.php

<?php include('header.php') ?>
<?php
$noticia = new Noticia();

$flash = array();
// DELETE
if(isset($_GET['action']) && $_GET['action'] == 'delete'):
	if($noticia->delete($_GET['id'])):
		$flash = Helper::flash('success');
	else:
		$flash = Helper::flash('error');
	endif;
endif;

// READ
$paginate = new Paginate($noticia->total(), $noticia->limit);
$noticias = $noticia->paginate($paginate->page());
?>
<div id="page">
	<div class="row">
		<div class="col lg-12">
			<h2>Notícias</h2>
		</div>
	</div>
	<div class="row">
		<?php if($flash): ?>
		<div class="col-lg-12">
			<div class="alert alert-<?= $flash['class'] ?> alert-dismissible">
				<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<?= $flash['message'] ?>
			</div>
		</div>
		<?php endif ?>
		<div class="col-lg-12">
			<a href="noticias_new.php" class="btn btn-primary">Adicionar</a>
			<hr>
			<div class="table-responsive">
				<table class="table">
					<thead>
						<tr>
							<th>Título:</th>
							<th>Link:</th>
							<th>Image:</th>
							<th width="100px">Ação:</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach($noticias as $noticia): ?>
						<tr>
							<td><?= $noticia->title ?></td>
							<td><?= substr(strip_tags($noticia->body), 0, 100) ?> [...]</td>
							<td><?= $noticia->image ?></td>
							<td>
								<a href="noticias_edit.php?id=<?= $noticia->id ?>" class="btn btn-default btn-xs">
									<i class="glyphicon glyphicon-pencil"></i>
								</a>
								<a href="noticias.php?action=delete&id=<?= $noticia->id ?>" class="btn btn-danger btn-xs" onclick="return confirm('Deseja realmente deletar?')">
									<i class="glyphicon glyphicon-trash"></i>
								</a>
							</td>
						</tr>
						<?php endforeach ?>
					</tbody>
				</table>
			</div>
			<?= $paginate->render() ?>
		</div>
	</div>
</div>

<?php include('footer.php') ?>

Zerion Mini Shell 1.0