コード例 #1
0
ファイル: Archive.php プロジェクト: ssrsfs/blg
 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);
 }
コード例 #2
0
ファイル: Feed.php プロジェクト: ssrsfs/blg
 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);
 }
コード例 #3
0
ファイル: index.php プロジェクト: ssrsfs/blg
<?php

/**
 * Typeframe News application
 *
 * client-side index controller
 */
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// get category id, if any
//$categoryid = News::GetCategoryId();
$settings = Typeframe::CurrentPage()->settings();
// set category id in template
//$pm->setVariable('categoryid', $settings['categoryid']);
// get articles; limit to this category and valid publication date
$articles = new Model_News_Article();
$categories = new Model_News_Category();
if (isset($settings['categoryid']) && is_array($settings['categoryid']) && count($settings['categoryid']) && !in_array(0, $settings['categoryid'])) {
    $articles->where('news.categoryid IN ?', $settings['categoryid']);
    $categories->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');
$total = $articles->count();
// set up pagination
$perpage = !empty($settings['perpage']) ? $settings['perpage'] : 20;
$pag = Pagination::Calculate($total, $perpage);
$articles->paginate($pag['page'], $pag['perpage']);
$pm->setVariable('pagination', $pag);
$settings = Typeframe::CurrentPage()->settings();
コード例 #4
0
ファイル: index.php プロジェクト: ssrsfs/blg
 */
// 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);
コード例 #5
0
ファイル: integration.php プロジェクト: ssrsfs/blg
 public function testUniqueEncodedTitles()
 {
     // SELECT encodedtitle, COUNT(newsid) AS articles FROM typef_news GROUP BY encodedtitle HAVING articles > 1
     $articles = new Model_News_Article();
     $articles->selectFields('encodedtitle', 'COUNT(newsid) AS articles');
     $articles->group('encodedtitle');
     $articles->having('articles > 1');
     $titles = array();
     foreach ($articles->select() as $article) {
         $titles[] = "'{$article['encodedtitle']}' ({$article['articles']})";
     }
     $this->assertTrue(count($titles) == 0, "The following encoded titles are not unique: " . implode(',', $titles));
 }
コード例 #6
0
ファイル: delete.php プロジェクト: ssrsfs/blg
<?php

/**
 * Typeframe News application
 *
 * admin-side delete controller
 */
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// if not posting, bounce out of here
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Typeframe::Redirect('Nothing to do.', $typef_app_dir);
    return;
}
// create news article object from given id
$newsid = @$_POST['newsid'];
$article = Model_News_Article::Get($newsid);
// news article must exist to proceed
if (!$article->exists()) {
    Typeframe::Redirect('Invalid article id specified.', $typef_app_dir);
    return;
}
// current user must be the author of the article or an admin
if (Typeframe::User()->get('userid') != $article['authorid'] && Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) {
    Typeframe::Redirect("You cannot delete other users' news items.", $typef_app_dir, 1, false);
    return;
}
// perform the delete
$article->delete();
// done
Typeframe::Redirect('Article has been deleted.', Plugin_Breadcrumbs::SavedState($typef_app_dir));
コード例 #7
0
ファイル: edit.php プロジェクト: ssrsfs/blg
<?php

$article = Model_News_Article::Get($_REQUEST['newsid']);
if ($article->exists()) {
    include 'form.inc.php';
    if (!empty($_REQUEST['revisionid'])) {
        $revisions = $article['revisions'];
        $revision = Model_News_ArticleRevision::Get($_REQUEST['revisionid']);
        $article->setArray(json_decode($revision['data'], true));
    }
    $pm->setVariable('article', $article);
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        include 'update.inc.php';
        if (!$article->dirty()) {
            Typeframe::Redirect('Article updated.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri()));
        }
    }
} else {
    Typeframe::Redirect('Invalid article specified.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri()), -1);
}
コード例 #8
0
ファイル: view.php プロジェクト: ssrsfs/blg
    return;
}
// create news category object
$category = Model_News_Category::Get($categoryid);
// redirect if category id is invalid
if (!$category->exists()) {
    Typeframe::Redirect('Invalid category specified.', $typef_app_dir, 1);
    return;
}
// determine if there are 0 or more than 1 categories; add flag to template
if ($setcat && (in_array(0, $setcat) || count($setcat) > 1)) {
    $pm->setVariable('multicats', true);
}
// add category name, id, and object to template
$pm->setVariable('categoryname', $category->get('categoryname'));
$pm->setVariable('categoryid', $category->get('categoryid'));
$pm->setVariable('category', $category);
// create news article factory; filter by category id
$articles = new Model_News_Article();
$articles->where('categoryid = ?', $category->get('categoryid'));
// add articles to template
$pm->setVariable('news', $articles);
// get comment types
//$comment_types = CommentType::DAOFactory();
//$comment_types->setOrder('name');
// add comment types to template
//$pm->setVariable('comment_types', $comment_types);
// add page title and header to template
//$title = News::GetTitle();
//$pm->setVariable('page_title',  $title);
//$pm->setVariable('page_header', $title);
コード例 #9
0
ファイル: article.php プロジェクト: ssrsfs/blg
<?php

$path = Typeframe::CurrentPage()->pathInfo();
$settings = Typeframe::CurrentPage()->settings();
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
$articles = new Model_News_Article();
$redirect = false;
if ($path) {
    // Get the article by encoded title
    $articles->where('encodedtitle = ?', $path);
} else {
    // Get the article by news ID if possible
    if (isset($_REQUEST['newsid'])) {
        $articles->where('newsid = ?', $_REQUEST['newsid']);
        $redirect = true;
    } else {
        Typeframe::Redirect('No news article was specified.', $typef_app_dir, 1, false);
        return;
    }
}
if (isset($settings['categoryid']) && is_array($settings['categoryid']) && !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', '0000-00-00 00:00:00', Typeframe::Now());
$articles->where('status = ?', 'published');
$article = $articles->getFirst();
if (!$article->exists()) {
    http_response_code(404);
    Typeframe::Redirect('Invalid article specified.', $typef_app_dir, 1, false);
    return;
コード例 #10
0
ファイル: rss.php プロジェクト: ssrsfs/blg
<?php

/**
 * Typeframe News application
 *
 * client-side rss controller
 */
// set the appropriate content type
header('Content-Type: application/rss+xml');
// set the template
Typeframe::SetPageTemplate('/news/rss.xml');
// add title, description, link, and lastbuild date to template
$pm->setVariable('title', TYPEF_TITLE);
$pm->setVariable('description', TYPEF_TITLE . ' News');
$pm->setVariable('link', 'http://' . $_SERVER['HTTP_HOST']);
$pm->setVariable('lastbuild', date('D, d M Y H:i:s T'));
// get articles; limit to published if non-admin
$articles = new Model_News_Article();
$articles->where('pubdate <= ?', Typeframe::Now());
$articles->limit('0, 10');
// add articles to template
$pm->setVariable('items', $articles);
コード例 #11
0
ファイル: news.php プロジェクト: ssrsfs/blg
<?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'));
}
コード例 #12
0
ファイル: add.php プロジェクト: ssrsfs/blg
<?php

include 'form.inc.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $article = Model_News_Article::Create();
    include 'update.inc.php';
    if (!$article->dirty()) {
        Typeframe::Redirect('Article created.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->page()->uri()));
    }
}