Skip to content

Instantly share code, notes, and snippets.

@Cacodaimon
Created September 26, 2012 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cacodaimon/3788538 to your computer and use it in GitHub Desktop.
Save Cacodaimon/3788538 to your computer and use it in GitHub Desktop.
<?php
$mongoDb = new Mongo;
$article = $mongoDb->blog->article->findOne(array(
'_id' => new MongoId($_GET['_id'])
));
ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>MVC Test Blog</title>
</head>
<body>
<header>
<h1>Linux MVC Shootout Test Blog</h1>
</header>
<section id="content">
<article>
<h2><?= $article['title'] ?></h2>
<span><?= date('Y-m-d H:i:s', $article['date']->sec) ?></span>
<p><?= html_entity_decode($article['text']) ?></p>
<a href="#comments"><h3>Comments</h3></a>
<?php foreach ($article['comments'] as $comment): ?>
<aside class="comments">
<p>Autor: <?= $comment['autor'] ?></p>
<span><?= date('Y-m-d H:i:s', $comment['date']->sec) ?></span>
<p><?= $comment['text'] ?></p>
</aside>
<?php endforeach; ?>
<a href="#post_comment"></a>
<aside class="post_comment">
<form action="post_comment.php" method="post">
<input type="hidden" name="_id" value="<?= $article['_id']?>">
<fieldset>
<legend>Post a comment</legend>
<p>Name: <input type="text" name="autor" /></p>
<p><textarea rows="5" cols="100" name="text"></textarea></p>
<p><input type="submit" value="Submit" /></p>
</fieldset>
</form>
</aside>
</article>
</section>
<footer>
Insert a stupid text here...
</footer>
</body>
</html>
<?php ob_flush();?>
<?php
$mongoDb = new Mongo;
$mongoDbCursor = $mongoDb->blog->article->find();
ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>MVC Test Blog</title>
</head>
<body>
<header>
<h1>MVC Test Blog</h1>
</header>
<section id="content">
<?php foreach($mongoDbCursor as $article): ?>
<article>
<h2><a href="article.php?_id=<?= $article['_id']?>"><?= $article['title'] ?></a></h2>
<span><?= date('Y-m-d H:i:s', $article['date']->sec) ?></span>
<p><?= $article['text'] ?></p>
<p>Comments: <a href="article.php?_id=<?= $article['_id']?>#comments">[<?= count($article['comments']) ?>]</a></p>
</article>
<?php endforeach; ?>
</section>
<footer>
Insert a stupid text here...
</footer>
</body>
</html>
<?php ob_flush(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment