Exemplo n.º 1
0
 /**
  * Parse template contains xml_news_feed
  * @return parsed template
  */
 function parse_news_feed()
 {
     global $ft;
     $query = sprintf("\n            SELECT \n                a.*, b.*, c.comments_id, count(DISTINCT c.id) \n            AS \n                comments \n            FROM \n                %1\$s a, \n                %2\$s b \n            LEFT JOIN \n                %3\$s c \n            ON \n                a.id = c.comments_id \n            LEFT JOIN \n                %4\$s d \n            ON \n                a.id = d.news_id\n            WHERE \n                published = '1' \n            GROUP BY \n                a.date \n            DESC \n            LIMIT \n                %5\$d", TABLE_MAIN, TABLE_CATEGORY, TABLE_COMMENTS, TABLE_ASSIGN2CAT, 10);
     $this->view->db->query($query);
     $ft->define('xml_feed', 'xml_feed.tpl');
     $ft->define_dynamic('xml_row', 'xml_feed');
     $ft->define_dynamic("cat_row", "xml_feed");
     $ft->assign(array('MAINSITE_LINK' => 'http://' . $this->http_root, 'NEWS_FEED' => true));
     if ($this->view->db->num_rows() > 0) {
         while ($this->view->db->next_record()) {
             $date = $this->view->db->f("date");
             $title = $this->view->db->f("title");
             $text = $this->view->db->f("text");
             $author = $this->view->db->f("author");
             $id = $this->view->db->f("id");
             $image = $this->view->db->f("image");
             $comments_allow = $this->view->db->f("comments_allow");
             $comments = $this->view->db->f("comments");
             $date = $this->date_convert($date);
             $text = str_replace($this->pattern, $this->replacement, $text);
             list_assigned_categories($id);
             if ((bool) $this->rewrite) {
                 $comments_link = sprintf('%s1,%s,2,item.html', $this->http_root, $id);
                 $permanent_link = sprintf('%s1,%s,1,item.html', $this->http_root, $id);
             } else {
                 $comments_link = sprintf('%sindex.php?p=2&id=%s', $this->http_root, $id);
                 $permanent_link = sprintf('%sindex.php?p=1&id=%s', $this->http_root, $id);
             }
             $ft->assign(array('DATE' => $date, 'TITLE' => $title, 'AUTHOR' => $author, 'PERMALINK' => $permanent_link, 'TEXT' => $text, 'COMMENTS_LINK' => $comments_link, 'DISPLAY_XML' => true));
             $ft->parse('XML_ROW', ".xml_row");
         }
     } else {
         $ft->assign('DISPLAY_XML', false);
         $ft->parse('XML_ROW', ".xml_row");
     }
     $this->display();
 }
Exemplo n.º 2
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 */
$mainposts_per_page = get_config('mainposts_per_page');
$CoreNews = new CoreNews();
$num_items = $CoreNews->news_count();
// inicjowanie funkcji stronnicuj�cej wpisy
$pagination = pagination($CoreRewrite->pagination($rewrite), $mainposts_per_page, $num_items);
// definiujemy blok dynamiczny szablonu
$ft->define_dynamic('note_row', 'rows');
$ft->define_dynamic('cat_row', 'rows');
$CoreNews->news_list(null);
if (count($CoreNews->news)) {
    foreach ($CoreNews->news as $news) {
        $id = $news->get_id();
        list_assigned_categories($id);
        $text = show_me_more($news->get_text());
        $text = preg_replace("/\\[code:\"?([a-zA-Z0-9\\-_\\+\\#\$\\%]+)\"?\\](.*?)\\[\\/code\\]/sie", "highlighter('\\2', '\\1')", $text);
        $ft->assign(array('DATE' => date($date_format, $news->get_timestamp()), 'NEWS_TITLE' => $news->get_title(), 'NEWS_TEXT' => $text, 'NEWS_AUTHOR' => $news->get_author(), 'NEWS_ID' => $id, 'NEWS_CATEGORY' => '', 'PERMA_LINK' => $CoreRewrite->permanent_news($id, $rewrite), 'PAGINATED' => !empty($pagination['page_string']) ? true : false, 'STRING' => $pagination['page_string']));
        get_comments_link($news->get_comments_allow(), 0, $id);
        //TODO
        $ft->assign('RETURN', '');
        $ft->parse('MAIN', '.note_row');
    }
} else {
    // Obs�uga b��du, kiedy w bazie danych nie ma jeszcze �adnego wpisu
    $ft->assign(array('QUERY_FAILED' => $i18n['main_view'][1], 'STRING' => '', 'PAGINATED' => false, 'MOVE_BACK' => false, 'MOVE_FORWARD' => false));
    $ft->parse('MAIN', '.query_failed');
}
Exemplo n.º 3
0
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; version 2 only.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 */
$CoreNews = new CoreNews();
$CoreNews->news_get($_GET['id']);
if (count($CoreNews->news)) {
    $news =& end($CoreNews->news);
    $id = $news->get_id();
    $text = str_replace(array('[podziel]', '[more]'), '', $news->get_text());
    $text = preg_replace("/\\[code:\"?([a-zA-Z0-9\\-_\\+\\#\$\\%]+)\"?\\](.*?)\\[\\/code\\]/sie", "highlighter('\\2', '\\1')", $text);
    $ft->define_dynamic('cat_row', 'rows');
    list_assigned_categories($_GET['id']);
    $ft->assign(array('DATE' => date($date_format, $news->get_timestamp()), 'NEWS_TITLE' => $news->get_title(), 'NEWS_TEXT' => $text, 'NEWS_AUTHOR' => $news->get_author(), 'NEWS_ID' => $_GET['id'], 'STRING' => '', 'PERMA_LINK' => $CoreRewrite->permanent_news($id, $rewrite), 'PAGINATED' => false, 'MOVE_BACK' => false, 'MOVE_FORWARD' => false));
    $comments = 0;
    get_comments_link($news->get_comments_allow(), $comments, $_GET['id']);
    // definiujemy blok dynamiczny szablonu
    $ft->define_dynamic('note_row', 'rows');
    $ft->assign('RETURN', $i18n['alter_view'][0]);
    $ft->parse('MAIN', '.note_row');
} else {
    $ft->assign(array('QUERY_FAILED' => $i18n['alter_view'][1], 'STRING' => '', 'PAGINATED' => false, 'MOVE_BACK' => false, 'MOVE_FORWARD' => false));
    $ft->parse('MAIN', '.query_failed');
}