Exemplo n.º 1
0
 public function action_index()
 {
     $category_uri = $this->request->param('category_uri');
     $news_category = new News_Category();
     $category_list = $news_category->get_list($this->page_id);
     if (empty($category_list)) {
         throw new HTTP_Exception_404();
     }
     $category_orm = $news_category->by_uri($category_list, $category_uri);
     $orm = ORM::factory('news')->where('category_id', 'IN', array_keys($category_list));
     if ($category_orm) {
         $orm->where('category_id', '=', $category_orm->id);
         $properties = $news_category->get_properties(array($category_orm));
         $properties = reset($properties);
         $this->title = $category_orm->title;
         $this->breadcrumbs[] = array('title' => $category_orm->title);
     } else {
         $orm_helper = ORM_Helper::factory('page', $this->page_id);
         $properties = $orm_helper->property_list();
     }
     $paginator_orm = clone $orm;
     $paginator = new Paginator('layout/paginator');
     $paginator->per_page($this->limit)->count($paginator_orm->count_all());
     unset($paginator_orm);
     $list = $orm->paginator($paginator)->find_all()->as_array();
     $titlebar_title = Arr::path($properties, 'Title.value');
     if (empty($titlebar_title)) {
         $titlebar_title = __('Blog');
     }
     $this->template->set_filename('modules/news/list')->set('list', $list)->set('paginator', $paginator)->set('categories', $category_list)->set('properties', $properties)->set('titlebar_title', $titlebar_title);
 }
Exemplo n.º 2
0
 public function action_categories()
 {
     $list = array();
     $page = Page_Route::page_by_alias('news');
     if (!empty($page)) {
         $news_category = new News_Category();
         $list = $news_category->get_list($page['id']);
     }
     $this->template = View_Theme::factory('widgets/template/news/categories', array('list' => $list, 'page' => $page));
 }
Exemplo n.º 3
0
Arquivo: index.php Projeto: ssrsfs/blg
<?php

/*
	29 december 2010: cleanup while trying to add
		status field to typef_news table;
		rewrote to use news categories class
	3 january 2011: DAOFactory, not DAO_Factory;
		setCategoryId now static
	28 march 2011: merged in HL code
	29 march 2011: added page title, header
*/
// define some handy shortcuts to save typing
$settings = Typeframe::CurrentPage()->settings();
if (Typeframe::CurrentPage()->pathInfo()) {
    Typeframe::IncludeScript('/news/categories/view.php');
    return;
}
if (is_array($settings['categoryid']) && !in_array(0, $settings['categoryid']) && 1 == count($settings['categoryid'])) {
    Typeframe::Redirect('Redirecting to category listing...', Typeframe::CurrentPage()->applicationUri() . 'categories/' . $settings['categoryid'][0]);
    return;
}
// create news category object
$categories = News_Category::DAOFactory();
// limit to a particular category id
News::SetCategoryId($categories, @$settings['categoryid']);
// add categories to template
$pm->setVariable('categories', $categories);
// add page title and header to template
$title = News::GetTitle();
$pm->setVariable('page_title', $title);
$pm->setVariable('page_header', $title);
Exemplo n.º 4
0
 */
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// requires post
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Typeframe::Redirect('Invalid request method.', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $typef_app_dir);
    return;
}
// create news article object
$article = new News_Article();
// set author user id and name
$article->set('authorid', Typeframe::User()->get('userid'));
$article->set('author', @$_POST['author']);
// get and validate category id
$categoryid = @$_POST['categoryid'];
$category = new News_Category($categoryid);
if (!$category->exists()) {
    $category = null;
}
// get, validate, and set incoming the values
$article->set('categoryid', $categoryid);
$article->set('title', $_POST['title']);
$article->set('article', $_POST['article']);
$article->set('status', News_Article::ValidateField('status', @$_POST['status']));
$article->set('pubdate', News_Article::ValidateField('pubdate', @$_POST['pubdate']));
$article->set('expdate', @$_POST['expdate']);
// handle (auto)summary
$autosummary = News_Article::ValidateField('autosummary', @$_POST['autosummary']);
$text = @$_POST[$autosummary ? 'article' : 'summary'];
$article->set('autosummary', $autosummary);
$article->set('summary', News_Article::ValidateField('summary', array($autosummary, $text)));
Exemplo n.º 5
0
Arquivo: view.php Projeto: ssrsfs/blg
		added comment types
*/
// define some handy shortcuts to save typing
$categoryid = Typeframe::CurrentPage()->pathInfo();
$settings = Typeframe::CurrentPage()->settings();
// get category id from request if not in path info
if (!$categoryid) {
    $categoryid = @$_REQUEST['categoryid'];
}
// validate category id in settings
if (!in_array(0, $settings['categoryid']) && !in_array($categoryid, $settings['categoryid'])) {
    Typeframe::Redirect('Invalid category specified.', Typeframe::CurrentPage()->applicationUri(), 1);
    return;
}
// create news category object
$category = new News_Category($categoryid);
// redirect if category id is invalid
if (!$category->exists()) {
    Typeframe::Redirect('Invalid category specified.', Typeframe::CurrentPage()->applicationUri(), 1);
    return;
}
// determine if there are 0 or more than 1 categories; add flag to template
if (in_array(0, $settings['categoryid']) || count($settings['categoryid']) > 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 object
$articles = News_Article::DAOFactory();