public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); $apps = array(); foreach (Typeframe::Registry()->pages() as $page) { if ($page->siteid() == Typeframe::CurrentPage()->siteid()) { if (strpos($page->uri(), '/admin/') !== false) { if ($page->allow()) { $apps[] = array('title' => $page->title(), 'icon' => $page->icon(), 'uri' => $page->uri()); } } } } $data['applications'] = $apps; if (class_exists('Model_Site')) { $sites = new Model_Site(); if (Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) { $sites->innerJoin('perm', 'Model_User_Site', 'id = perm.siteid'); $sites->where('perm.userid = ?', Typeframe::User()->get('userid')); $primary = new Model_User_Site(); $primary->where('userid = ?', Typeframe::User()->get('userid')); $primary->where('siteid = ?', 0); $data['admin_primary'] = $primary->count() > 0; } else { $data['admin_primary'] = 1; } $data['sites'] = $sites; } $data->sortNodes(array('applications', 'title')); if (defined('TYPEF_HOST')) { $data['primary_host'] = TYPEF_HOST; } parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { if (self::$_loaded) { return ''; } self::$_loaded = true; if (defined('COMMENTS_DISABLED') && COMMENTS_DISABLED) { return ''; } $data = $data->fork(); $urlmeta = Model_UrlMeta::GetUrl(); if (!$urlmeta->exists()) { return ''; } $commeta = Model_Comment_Meta::Get($urlmeta['id']); if (!$commeta->exists()) { $commeta['urlmetaid'] = $urlmeta['id']; $commeta->save(); } else { if ($commeta['closed']) { $pm->setVariable('comments_closed', true); } } $data->set('meta', $commeta); $comments = new Model_Comment(); $comments->where('urlmetaid = ?', $urlmeta['id']); if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) { $comments->where('approved = 1'); } $comments->order('datecreated ASC'); $data->set('comments', $comments); $data->set('comments_require_captcha', COMMENTS_REQUIRE_CAPTCHA); parent::output($data, $stream); }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $this->pluginTemplate = "/downloads/downloads.plug.html"; $data = $data->fork(); $downloads = new Model_Download_File(); $downloads->where('siteid = ?', Typeframe::CurrentPage()->siteid()); $data['downloads'] = $downloads; parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $this->pluginTemplate = '/users/online.plug.html'; $data = $data->fork(); $users = new Model_User(); $users->where('DATE_ADD(lastrequest, INTERVAL 30 MINUTE) > NOW()'); $data->set('usersonline', $users->getTotal()); parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $this->pluginTemplate = '/news/archive.plug.html'; $data = $data->fork(); $data->setArray($this->attributes()); $articles = new Model_News_Article(); $articles->where('categoryid IN ?', $this->getAttribute('categoryid')); // TODO: Group by date $data->set('articles', $articles); parent::output($data, $stream); }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $data = $data->fork(); $data->setArray($this->attributes()); $content = Model_Content_Plug::Get($this->attributes['plugid']); if (is_array($content['content'])) { $data->setArray($content['content']); } //$tag->process($data, $stream); $this->pluginTemplate = !empty($this->attributes['template']) ? '/content/' . $this->attributes['template'] : '/content/generic.plug.html'; parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); $comments = new Model_Comment(); if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) { $comments->select()->where('approved = 1'); } $comments->order('datecreated DESC'); $comments->limit(10); $data->set('comments', $comments); parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); if (!empty($this->attributes['menuplugid'])) { $menuplugid = $this->attributes['menuplugid']; $db = Typeframe::Database(); $base = substr(Typeframe::CurrentPage()->uri(), STRLEN(TYPEF_WEB_DIR)); if ($base == '') { $base = '/'; } $search = new Model_Nav(); $search->where('plugid = ?', $menuplugid); $search->where('url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR pageid = ?', "~{$base}", "~{$base}/", "/{$base}", "/{$base}/", TYPEF_WEB_DIR . $base, TYPEF_WEB_DIR . $base . '/', Typeframe::CurrentPage()->pageid()); foreach ($search->select() as $current) { $current['url'] = $this->_convertUrl($current['url']); $data->set('current', $current); $parentid = $current['parent']; $siblings = new Model_Nav(); $siblings->where('plugid = ?', $menuplugid); $siblings->where('parent = ?', $parentid); $siblings->order('sortnum'); $data['siblings'] = $siblings; /*$sibArray = array(); foreach ($siblings->select() as $sib) { $sib['url'] = $this->_convertUrl($sib['url']); $sibArray[] = $sib; } $data['siblings'] = $sibArray;*/ if (!empty($this->attributes['showparent'])) { $parent = $db->execute('SELECT * FROM #__nav WHERE itemid = ' . $parentid); foreach ($parent as $par) { $par['url'] = $this->_convertUrl($par['url']); $data->set('parent', $par); } } if (!empty($this->attributes['showchildren'])) { $childArray = array(); $children = $db->execute('SELECT * FROM #__nav WHERE plugid = ' . $menuplugid . ' AND parent = ' . $current['itemid'] . ' ORDER BY sortnum'); foreach ($children as $chi) { $chi['url'] = $this->_convertUrl($chi['url']); $childArray[] = $chi; } $data['children'] = $childArray; } } } $this->pluginTemplate = "navigation/submenu.plug.html"; parent::output($data, $stream); }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $data = $data->fork(); $url = Typeframe::CurrentPage()->uri(); if (substr($url, -1) == '/') { $url = substr($url, 0, -1); } $dirs = explode('/', substr($url, strlen(TYPEF_WEB_DIR))); $this->pluginTemplate = '/breadcrumbs/breadcrumbs.plug.html'; $data['breadcrumbs'] = array(); $currentUrl = TYPEF_WEB_DIR; $start = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($this->getAttribute('start'))); while (count($dirs) > 0) { $currentUrl .= '/' . array_shift($dirs); $currentUrl = preg_replace('/\\/+/', '/', $currentUrl); if ($start && strpos($currentUrl, $start) === false) { continue; } if (isset($_SESSION['breadcrumbs'][$currentUrl])) { $bc = $_SESSION['breadcrumbs'][$currentUrl]; $bc['url'] = $currentUrl . ($bc['query'] ? '?' . $bc['query'] : ''); $data['breadcrumbs'][] = $bc; } else { $response = Typeframe::Registry()->responseAt($currentUrl); if ($currentUrl == $response->page()->uri()) { if ($response->application()->name() != '403' && $response->application()->name() != '404') { $settings = $response->page()->settings(); if (!empty($settings['nickname'])) { $title = $settings['nickname']; } else { $title = $response->page()->title(); } $bc = array('title' => $title, 'query' => ''); $_SESSION['breadcrumbs'][$currentUrl] = $bc; $bc['url'] = $currentUrl; $data['breadcrumbs'][] = $bc; } } } } parent::output($data, $stream); return; }
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); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $this->pluginTemplate = '/mailform/mailform.plug.html'; $data = $data->fork(); if (!isset($this->attributes['cssid']) || !$this->attributes['cssid']) { $this->attributes['cssid'] = "mailform-{$this->attributes['mailformid']}"; } $data->setArray($this->attributes); $mailform = Model_Mailform::Get($this->attributes['mailformid']); if (!$mailform->exists()) { return; } foreach ($mailform['formfields'] as &$fields) { if (!empty($fields['values'])) { $fields['values'] = preg_split('/,[\\s]*?/', trim($fields['values'])); } } $data->set('mailform', $mailform); parent::output($data, $stream); }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $this->pluginTemplate = '/admin/admintree.plug.html'; $data = $data->fork(); $apps = array(); foreach (Typeframe::Registry()->pages() as $page) { if (strpos($page->uri(), TYPEF_WEB_DIR . '/admin/') === 0) { $category = $page->application()->category() ? $page->application()->category() : 'Other'; if (!isset($apps[$category])) { $apps[$category] = array(); } $apps[$category][] = array('title' => $page->title(), 'icon' => $page->icon(), 'uri' => $page->uri()); } } ksort($apps); $categories = array(); foreach ($apps as $category => $applications) { $categories[] = array('name' => $category, 'applications' => $applications); } $data['categories'] = $categories; parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $this->pluginTemplate = '/news/categories.plug.html'; $data = $data->fork(); $this->settings['id'] = isset($this->settings['id']) ? $this->settings['id'] : 'newscategoryfeed-' . rand(0, 9) . rand(0, 9) . rand(0, 9); $this->settings['template'] = isset($this->settings['template']) ? $this->settings['template'] : 'newscategoryfeed.plug.html'; $data->setArray($this->settings); $categories = new Model_News_Category(); $categoryid = News::GetCategoryId(true); if (isset($this->settings['count'])) { $categories->limit($this->settings['count']); } $categories = $categories->getAll(); foreach ($categories as $index => $category) { $cid = $category->get('categoryid'); $category->set('url', TYPEF_WEB_DIR . News::GetCategoryUri($cid) . "/categories?categoryid={$cid}"); $category->set('articlesCount', News::CountArticles($category)); $categories[$index] = $category; } $data->set('categories', $categories); $this->pluginTemplate = '/news/' . $this->settings['template']; parent::output($data, $stream, $tag); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $this->pluginTemplate = '/news/feed.plug.html'; $default = array('limit' => 5, 'categoryid' => null); $settings = array_merge($default, $this->attributes()); $articles = new Model_News_Article(); if (!is_null($settings['categoryid'])) { if (!is_array($settings['categoryid'])) { $settings['categoryid'] = array($settings['categoryid']); } if (!in_array(0, $settings['categoryid'])) { $articles->where('categoryid IN ?', $settings['categoryid']); } } $articles->where('pubdate <= ?', Typeframe::Now()); $articles->where('expdate >= ? OR expdate = ? OR expdate IS NULL', Typeframe::Now(), '0000-00-00 00:00:00'); $articles->where('status = ?', 'published'); $articles->limit($settings['limit']); $data = $data->fork(); $data['header'] = $settings['header']; $data['articles'] = $articles; parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); $data->setArray($this->attributes()); $navigation = new Model_Nav(); $navigation->where('plugid = ?', $this->attributes['plugid']); $navigation->where('parent = 0'); $items = array(); foreach ($navigation->select() as $item) { $item['link'] = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($item['link'])); $items[] = $this->get_tree_down($item); } $data->set('navigation', $items); $this->pluginTemplate = '/navigation/navigation.plug.html'; parent::output($data, $stream); }