public static function GetCategoryUri($categoryid) { static $categories = null; if (is_null($categories)) { // Get all URIs and associated categories $categories = array(); $pages = new Model_Page(); $pages->where('application = ?', 'News'); foreach ($pages->getAll() as $page) { $settings = $page->get('settings'); $uri = $page->get('uri'); // This news page only includes certain categories if (isset($settings['categoryid']) && !in_array(0, $settings['categoryid'])) { foreach ($settings['categoryid'] as $cid) { $categories[$cid] = $uri; } } else { $categories[0] = $uri; } } } // There is a page that explicitly includes this category if (isset($categories[$categoryid])) { return $categories[$categoryid]; } // There is a page that includes all categories if (isset($categories[0])) { return $categories[0]; } // There is no page for this category return null; }
public function testContentPageAdmin() { $this->logIn(); $this->get(TYPEF_WEB_DIR . '/admin/content'); $this->getAssets(); $pages = new Model_Page(); $pages->where('application = ?', 'Content'); foreach ($pages->getAll() as $page) { $this->get(TYPEF_WEB_DIR . '/admin/content/page?pageid=' . $page['pageid']); $this->getAssets(); } }
public function admin(Pagemill_Data $data, Pagemill_Stream $stream) { $this->adminTemplate = '/admin/news/feed.plug.html'; $data = $data->fork(); $categories = new Model_News_Category(); $categories->order('categoryname'); $data['categories'] = $categories; $pages = new Model_Page(); $pages->where('application = ?', 'News'); $data['pages'] = $pages; $data->setArray($this->attributes()); parent::admin($data, $stream); }
public function admin(Pagemill_Data $data, Pagemill_Stream $stream) { // TODO: Implement $data = $data->fork(); $data->setArray($this->attributes()); $pages = new Model_Page(); $pages->where('application = ?', 'News'); $data->set('pages', $pages); $categories = new Model_News_Category(); $categories->order('categoryname'); $data->set('categories', $categories); $this->adminTemplate = '/admin/news/archive.plug.html'; parent::admin($data, $stream); }
public function admin(Pagemill_Data $data, Pagemill_Stream $stream) { $this->adminTemplate = '/admin/news/newsfeed.adminplug.html'; $data = $data->fork(); $this->attributes = array_merge(array('news_page_base' => '', 'limit' => ''), $this->attributes); $data->setArray($this->attributes); // get pages; add to template $pages = new Model_Page(); $pages->where('application = ?', 'News'); $data->set('pages', $pages); // get categories; add to template //$categories = new News_Category_Factory(); $categories = new Model_News_Category(); $categories->order('categoryname'); foreach ($categories->getAll() as $category) { if (isset($this->attributes['categoryid']) && in_array($row['categoryid'], $this->attributes['categoryid'])) { $category->set('selected', true, true); } } $data->set('categories', $categories); parent::output($data, $stream); }
private static function _GetCategoryBases() { static $categoryids = null; static $categoryBases = null; if (is_null($categoryBases)) { $categoryids = array(); $categoryBases = array(); $categories = new Model_News_Category(); foreach ($categories->select() as $category) { $categoryids[] = $category['id']; } $pages = new Model_Page(); $pages->where('application = ?', 'News'); foreach ($pages->select() as $page) { if (isset($page['settings']['categoryid']) && is_array($page['settings']['categoryid']) && !in_array(0, $page['settings']['categoryid'])) { foreach ($page['settings']['categoryid'] as $id) { if (!isset($categoryBases[$id])) { $categoryBases[$id] = array(); } $categoryBases[$id][] = TYPEF_WEB_DIR . $page['uri']; } } else { if (!isset($categoryBases[0])) { $categoryBases[0] = array(); } $categoryBases[0][] = TYPEF_WEB_DIR . $page['uri']; foreach ($categoryids as $id) { if (!isset($categoryBases[$id])) { $categoryBases[$id] = array(); } $categoryBases[$id][] = TYPEF_WEB_DIR . $page['uri']; } } } } return $categoryBases; }
<?php $site->setArray($_POST, false); $site->save(); if ($site['masterid']) { $masterPages = new Model_Site_Master_Page(); $masterPages->where('masterid = ?', $site['masterid']); foreach ($masterPages->select() as $mp) { $realPages = new Model_Page(); $realPages->where('siteid = ?', $site['id']); $realPages->where('uri = ?', $mp['uri']); $realPage = $realPages->getFirst(); if (!$realPage->exists()) { $realPage = Model_Page::Create(); $realPage['siteid'] = $site['id']; } $realPage->setArray($mp->getArray(), false); $realPage->save(); } }
<?php /** * Typeframe Content application * * admin-side index controller */ /*if (!empty($_REQUEST['pageid'])) { Typeframe::Redirect('Redirecting to page content...', Typeframe::CurrentPage()->applicationUri() . '/page?pageid=' . $_REQUEST['pageid']); return; }*/ // add pages $pages = new Model_Page(); //$pages->where('application = ?', 'Content'); $pages->where('siteid = ?', Typeframe::CurrentPage()->siteid()); $pages->order('nickname, uri'); /*foreach ($pages->getAll() as $page) { $settings = $page['settings']; $template = TYPEF_SOURCE_DIR . '/templates/content/' . (!empty($settings['template']) ? $settings['template'] : 'generic.html'); if (!file_exists($template)) { $page->set('dead_template', $settings['template']); $template = (TYPEF_SOURCE_DIR . '/templates/content/generic.html'); } $elements = Insertable::ElementsFrom($template); $groups = Insertable::GroupsFrom($template); if ((count($elements) > 0) || (count($groups) > 0)) { $garray = array();
*/ // get sorting options list($sort_options, $sort, $order) = News::GetAdminSortingOptions(); // set sorting in template $pm->setVariable('sort_options', $sort_options); $pm->setVariable('sort', $sort); if (!empty($_REQUEST['pageid'])) { $page = Model_Page::Get($_REQUEST['pageid']); if (!$page->exists() || $page['application'] != 'News' && $page['application'] != 'News RSS') { Typeframe::Redirect('Invalid page specified.', Typeframe::CurrentPage()->applicationUri(), 1); return; } $pm->setVariable('currentpage', $page); } $newspages = new Model_Page(); $newspages->where('application = ?', 'News'); $pm->setVariable('newspages', $newspages); $articles = new Model_News_Article(); $total = $articles->count(); if (!empty($_REQUEST['status'])) { $articles->where('status = ?', $_REQUEST['status']); } $articles->order($order); // set up pagination $page = @$_REQUEST['page'] && ctype_digit($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $perpage = isset($settings['perpage']) ? $settings['perpage'] : 10; //$articles->setPagination($page, $perpage); $articles->paginate($page, $perpage); // add pagination, articles to template $pm->setVariable('pagination', Pagination::Calculate($total, $perpage, $page)); $pm->setVariable('news', $articles);
<?php if (Typeframe::Allow(TYPEF_WEB_DIR . '/admin/news') || Typeframe::Allow(TYPEF_WEB_DIR . '/admin/pages')) { $pages = new Model_Page(); $pages->where('application IN ?', array('News', 'News RSS')); foreach ($pages->getAll() as $page) { $pm->addLoop('admin_pages', $page); } } if (Typeframe::Allow(TYPEF_WEB_DIR . '/admin/news')) { $admin_news = array(); $articles = new Model_News_Article(); $admin_news['totalarticles'] = $articles->getTotal(); $articles = new Model_News_Article(); $articles->where('status = ?', 'draft'); $admin_news['totaldrafts'] = $articles->getTotal(); $pm->setVariable('admin_news', $admin_news); $pm->addLoop('admin_panels', array('name' => 'News', 'template' => '/admin/news/panel.inc.html')); }