Example #1
0
 public function index($args)
 {
     $db = $this->database();
     $articles = array();
     $sth = $db->prepare("\n\t\t\tSELECT\t\tid, title, body, date_added, author, publisher, date\n\t\t\tFROM\t\tarticles\n\t\t\tORDER BY\tdate_added DESC\n\t\t\tLIMIT\t\t5\n\t\t");
     $sth->execute();
     while ($article = $sth->fetch()) {
         $seo_url = new seo_url($article);
         $s = new markdown_smartypantstypographer();
         $articles[] = array("id" => $article["id"], "title" => $article["title"], "excerpt" => $s->transform(utf8_encode(substr($article["body"], 0, 200))) . "…", "seo_url" => $seo_url->url, "date_added" => date("dS M", strtotime($article["date_added"])), "author" => $article["author"], "publisher" => $article["publisher"], "date" => $article["date"]);
     }
     $tpl = new view($this->registry);
     $tpl->set("articles", $articles);
     $tpl->set("page_title", "Look At That F***ing Title");
     $tpl->set("subview", "home_body");
     $tpl->show("home");
 }
Example #2
0
 public function view($args)
 {
     $template = new view($this->registry);
     $db = $this->database();
     $sth = $db->prepare("\n\t\t\tSELECT \tid, title, body, author, date, publisher\n\t\t\tFROM \tarticles\n\t\t\tWHERE\tid = :id\n\t\t\tLIMIT \t1\n\t\t");
     $sth->execute(array(":id" => $args["id"]));
     $article = $sth->fetch();
     $template->set("page_title", "Look At That F***ing Title");
     $template->set("title", utf8_encode($article["title"]));
     $p = new markdown_parser();
     $s = new markdown_smartypantstypographer();
     include SITE_PATH . DIRSEP . "definitions" . DIRSEP . "article.php";
     $body_text = $p->transform($s->transform($article["body"]));
     $article_info = sprintf(HTML_ARTICLE_INFO, $article["author"], $article["date"], $article["publisher"]);
     $template->set("info", $article_info);
     $template->set("body", utf8_encode(sprintf(HTML_ARTICLE_BODY, $body_text)));
     $template->show("home");
 }