Ejemplo n.º 1
0
function show_news_post($id_or_slug)
{
    $post = null;
    if (is_numeric($id_or_slug)) {
        $post = db_getRow("SELECT * FROM news WHERE id=? AND status='a'", $id_or_slug);
    } else {
        $post = db_getRow("SELECT * FROM news WHERE slug=? AND status='a'", $id_or_slug);
    }
    news_AugmentItem($post);
    $content_html = Markdown($post['content']);
    $prettydate = pretty_date(strtotime($post['posted']));
    page_header($post['title']);
    $news = news_RecentNews(5);
    ?>
<div class="main">
<div class="head">
 <h2><?php 
    echo $post['title'];
    ?>
</h2>
<?php 
    if ($post['kind'] == 'newsletter') {
        ?>
 for the week ending <?php 
        echo $post['pretty_to'];
    }
    ?>
</div>
<div class="body">
<?php 
    echo $content_html;
    if ($post['kind'] == 'newsletter') {
        ?>
<hr />
<?php 
    }
    ?>
</div>
<div class="foot">
  <small>(posted by <em><?php 
    echo $post['author'];
    ?>
</em> on <em><?php 
    echo $prettydate;
    ?>
</em>)</small>
</div>
</div> <!-- end main -->


<div class="sidebar">

<div class="box">
 <div class="head"><h3>Archive</h3></div>
 <div class="body">
 <ul>
<?php 
    foreach ($news as $n) {
        ?>
  <li>
<?php 
        if ($n['slug'] == $post['slug']) {
            ?>
    <em><?php 
            echo $n['title'];
            ?>
</em><br/>
<?php 
        } else {
            ?>
    <a href="/news/<?php 
            echo $n['slug'];
            ?>
"><?php 
            echo $n['title'];
            ?>
</a><br/>
<?php 
        }
        if ($n['kind'] == 'newsletter') {
            ?>
    <small>(week ending <?php 
            echo $n['pretty_to'];
            ?>
)</small>
<?php 
        }
        ?>
  </li>
<?php 
    }
    ?>
 </ul>
 <a href="/news">more...</a>
 </div>
<div class="foot"></div>
</div>

<?php 
    emit_subscribebox();
    emit_also_on_jl();
    ?>
</div> <!-- end sidebar -->
<?php 
    page_footer();
}
Ejemplo n.º 2
0
function news_RecentNews($limit = 5)
{
    // recent newsletters
    $news = null;
    if (is_null($limit)) {
        $news = db_getAll("SELECT id,slug,kind,title,posted,date_from,date_to FROM news WHERE status='a' ORDER BY posted DESC");
    } else {
        $news = db_getAll("SELECT id,slug,kind,title,posted,date_from,date_to FROM news WHERE status='a' ORDER BY posted DESC LIMIT ?", $limit);
    }
    foreach ($news as &$n) {
        news_AugmentItem($n);
    }
    unset($n);
    return $news;
}