secret
Created

ArticleContent

  • Download Gist
gistfile1.aw
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
<?php
 
$AC = new articleContent();
 
class articleContent {
public $current_article = 0;
public $article_count = 0;
 
protected $in_the_loop = false;
 
public $articles = array();
public $article = array();
 
function __construct() {
global $dbDriver;
 
/* Article Data */
$articleQuery = $dbDriver->query("SELECT p.*, a.*, (SELECT COALESCE(COUNT(m_article_id), 0) FROM xc_meta m WHERE m.m_article_id = a._article_id) AS widgetCount FROM xc_page AS p LEFT JOIN xc_articles AS a ON p._page_id = a.a_page_id WHERE p._page_id=1 ORDER BY a.a_section_id, a.a_order_id");
 
$this->article_count = $articleQuery->num_rows;
 
while ($aRow = $dbDriver->fetch('assoc', $articleQuery)) {
$this->articles[] = $aRow;
}
}
 
function next_article() {
$this->current_article++;
 
$this->article = $this->articles[$this->current_article];
return $this->article;
}
 
function the_article() {
$this->in_the_loop = true;
 
if($this->current_article == 0) add_action('loop_start');
 
$this->article = $this->next_article();
}
 
public function have_articles() {
if($this->current_article + 1 <= $this->article_count) {
return true;
}
 
$this->in_the_loop = false;
return false;
}
 
public function __get($io) {
echo "<pre>" . print_r($this->articles[$this->current_article], true) . "</pre>";
return $this->articles[$this->current_article][$io];
}
}
 
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.