public function admin(PMDataNode $node) { $pm = new Pagemill($node->fork()); $this->settings = array_merge(array('driver' => ''), $this->settings); $pm->setVariableArray($this->settings); $db = Typeframe::Database(); // @todo Should this be in a central location somewhere? // Assemble a list of "Driverable" pages for the driver option. //$driverables = array(); $rs = $db->prepare('SELECT pageid, nickname FROM #__page WHERE driver != "" ORDER BY nickname'); $rs->execute(); // Add the "default/none" option. $pm->addLoop('driverables', array('pageid' => '', 'nickname' => 'None/Blank')); while ($data = $rs->fetch_array()) { // $driverables[] = $data; $pm->addLoop('driverables', $data); } return $pm->writeText('<pm:include template="/admin/pluginforms/driver.html" />'); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { // TODO: Implement return; // setup pagemill $pm = new Pagemill($node->fork()); // add settings $this->attributes['id'] = isset($this->attributes['id']) ? $this->attributes['id'] : 'newsarticle-' . rand(0, 9) . rand(0, 9) . rand(0, 9); $this->attributes['include_comments'] = isset($this->attributes['include_comments']) ? $this->attributes['include_comments'] : 'true'; $this->attributes['include_comments'] = 'true' == $this->attributes['include_comments']; // Make the string into a boolean. $this->attributes['category'] = isset($this->attributes['category']) ? $this->attributes['category'] : '__any'; $pm->setVariableArray($this->attributes); // get most recent article; use settings for category id $articles = new News_Article_Factory(); $categoryid = News::GetCategoryId(true); $articles->setCategoryId($categoryid); $articles->setPubDate(); $articles->setLimit(1); $article = $articles->get(); if ($article->exists()) { // add some stuff to it $url = TYPEF_WEB_DIR . (@$this->attributes['news_page_base'] ? $this->attributes['news_page_base'] : News::GetCategoryUri($article->get('categoryid'))) . '/' . ($article->get('encodedtitle') ? $article->get('encodedtitle') : $article->get('newsid')); $article->set('url', $url); if (!trim($article->get('title'))) { $article->set('title', '[untitled]'); } // add to template $pm->setVariable('article', $article); // included for backwards compatibility (?) $pm->setVariable('newsid', $article->get('newsid')); // update the view count for this article $article->incrementViews(); } // @todo retrieve all the comments also if ($this->attributes['include_comments']) { } // output the result //return $pm->writeText('<pm:include template="/news/article.plug.html" />'); $this->pluginTemplate = '/news/article.plug.html'; parent::output($data, $stream); }