PHPFusion\News\News::set_NewsCatInfo PHP Метод

set_NewsCatInfo() публичный Метод

Executes category information - $_GET['cat_id']
public set_NewsCatInfo ( $news_cat_id ) : array
$news_cat_id
Результат array
    public function set_NewsCatInfo($news_cat_id)
    {
        $locale = fusion_get_locale('', NEWS_LOCALE);
        $info = array('news_cat_id' => 0, 'news_cat_name' => $locale['news_0007'], 'news_cat_image' => '', 'news_cat_language' => LANGUAGE, 'news_categories' => array(), 'news_image' => '', 'news_item_rows' => 0, 'news_last_updated' => 0, 'news_items' => array());
        $info['allowed_filters'] = array('recent' => $locale['news_0011'], 'comment' => $locale['news_0012'], 'rating' => $locale['news_0013']);
        foreach ($info['allowed_filters'] as $type => $filter_name) {
            $filter_link = INFUSIONS . "news/news.php?" . (isset($_GET['cat_id']) ? "cat_id=" . $_GET['cat_id'] . "&" : '') . "type=" . $type;
            $info['news_filter'][$filter_link] = $filter_name;
            unset($filter_link);
        }
        /* News Category */
        $result = dbquery("SELECT news_cat_id, news_cat_name FROM " . DB_NEWS_CATS . "\n        " . (multilang_table("NS") ? "WHERE news_cat_language='" . LANGUAGE . "'" : '') . " ORDER BY news_cat_id ASC");
        if (dbrows($result) > 0) {
            while ($cdata = dbarray($result)) {
                $info['news_categories'][$cdata['news_cat_id']] = array('link' => INFUSIONS . 'news.php?cat_id=' . $cdata['news_cat_id'], 'name' => $cdata['news_cat_name']);
            }
        }
        // Filtered by Category ID.
        $result = dbquery("SELECT * FROM " . DB_NEWS_CATS . " " . (multilang_table("NS") ? "WHERE news_cat_language='" . LANGUAGE . "' AND" : "WHERE") . " news_cat_id='" . intval($news_cat_id) . "'");
        if (dbrows($result)) {
            $data = dbarray($result);
            set_title(SiteLinks::get_current_SiteLinks("", "link_name"));
            add_breadcrumb(array('link' => INFUSIONS . 'news/news.php', 'title' => SiteLinks::get_current_SiteLinks("", "link_name")));
            add_to_title($locale['global_201'] . $data['news_cat_name']);
            // Predefined variables, do not edit these values
            $news_cat_index = dbquery_tree(DB_NEWS_CATS, 'news_cat_id', 'news_cat_parent');
            // build categorial data.
            $info['news_cat_id'] = $data['news_cat_id'];
            $info['news_cat_name'] = $data['news_cat_name'];
            $info['news_cat_image_src'] = $data['news_cat_image'] && file_exists(IMAGES_NC . $data['news_cat_image']) ? IMAGES_NC . $data['news_cat_image'] : "";
            $info['news_cat_image'] = $data['news_cat_image'] && file_exists(IMAGES_NC . $data['news_cat_image']) ? "<img class='img-responsive' src='" . IMAGES_NC . $data['news_cat_image'] . "' />" : "<img class='img-responsive' src='holder.js/80x80/text:" . $locale['no_image'] . "/grey' />";
            $info['news_cat_language'] = $data['news_cat_language'];
            $max_news_rows = dbcount("(news_id)", DB_NEWS, "news_cat='" . $data['news_cat_id'] . "' AND\n\t\t\t" . groupaccess('news_visibility') . " AND (news_start='0'||news_start<= NOW()) AND\n\t\t\t(news_end='0'||news_end>=NOW()) AND news_draft='0'");
            $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $max_news_rows ? intval($_GET['rowstart']) : 0;
            if ($max_news_rows) {
                $result = dbquery($this->get_NewsQuery(array('condition' => "news_cat='" . $data['news_cat_id'] . "'")));
                $info['news_item_rows'] = dbrows($result);
                $info['news_total_rows'] = $max_news_rows;
                $this->news_cat_breadcrumbs($news_cat_index);
            } else {
                redirect(INFUSIONS . "news/news.php");
            }
        } elseif ($_GET['cat_id'] == 0) {
            $max_news_rows = dbcount("(news_id)", DB_NEWS, "news_cat='0' AND " . groupaccess('news_visibility') . " AND (news_start='0'||news_start<=NOW())\n\t\t\tAND (news_end='0'||news_end>=NOW()) AND news_draft='0'");
            $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $max_news_rows ? intval($_GET['rowstart']) : 0;
            if ($max_news_rows) {
                // apply filter.
                $result = dbquery($this->get_NewsQuery(array('condition' => 'news_cat=0')));
                add_breadcrumb(array('link' => INFUSIONS . "news/news.php?cat_id=" . $_GET['cat_id'], 'title' => $locale['news_0006']));
                $info['news_total_rows'] = $max_news_rows;
                $info['news_item_rows'] = dbrows($result);
            } else {
                redirect(INFUSIONS . "news/news.php");
            }
        } else {
            redirect(INFUSIONS . "news/news.php");
        }
        /**
         * Parse
         */
        if ($max_news_rows) {
            $news_count = 0;
            while ($data = dbarray($result)) {
                $news_count++;
                if ($news_count == 1) {
                    $info['news_last_updated'] = $data['news_datestamp'];
                }
                $news_info[$news_count] = self::get_NewsData($data);
            }
            $info['news_items'] = $news_info;
        }
        $this->info = $info;
        return (array) $info;
    }