Esempio n. 1
0
    /**
     * Sett opp innhold til en enhet i noden
     * @param array $unit
     */
    public static function content_build($unit)
    {
        switch ($unit['ni_type']) {
            case 1:
                // bb
                $content = '
<div class="p">' . game::format_data($unit['nir_content']) . '</div>';
                break;
            case 2:
                // html
            // html
            case 3:
                // htmleditor
                $content = '
' . $unit['nir_content'];
                break;
            case 5:
                // gallery_section
                $content = '
<p>Not implementet.</p>';
                break;
            case 6:
                // gallery_item
                $content = '
<p>Not implementet.</p>';
                break;
            case 7:
                // news
                $params = new params($unit['nir_params']);
                // hvilke tags?
                $tags = new container($params->get("tags"));
                $page_name = "ni_s_{$unit['ni_id']}";
                $pageinfo = new pagei(PAGEI_ACTIVE_GET, $page_name, PAGEI_PER_PAGE, max(1, min(50, $params->get("per_page", 15))));
                // hent nyhetene
                if (count($tags->items) > 0) {
                    $tags_db = array_map(array(ess::$b->db, "quote"), $tags->items);
                    // filter via tags
                    $query = "n_id, n_title, n_content, n_userid, n_time, n_visible, n_type FROM news, news_tags WHERE n_visible > 0 AND n_id = nt_n_id AND nt_tagname IN (" . implode(", ", $tags_db) . ") GROUP BY n_id ORDER BY n_time DESC";
                } else {
                    $query = "n_id, n_title, n_intro, LEFT(n_content, 5) AS n_content, n_userid, n_time, n_visible, n_type FROM news WHERE n_visible > 0 ORDER BY n_time DESC";
                }
                $result = $pageinfo->query($query);
                $content = '';
                if ($result->rowCount() == 0) {
                    $content .= '
<p>Ingen nyheter.</p>';
                } else {
                    while ($row = $result->fetch()) {
                        $content .= '
<h2>' . htmlspecialchars($row['n_title']) . '</h2>
<p class="h_right">' . ess::$b->date->get($row['n_time'])->format() . '</p>
<div class="p">' . game::format_data($row['n_intro']) . '</div>';
                        // mer info?
                        if (mb_strlen($row['n_content']) > 0) {
                            $content .= '
<p><a href="' . game::address(PHP_SELF, $_GET, array(), array("show_n" => $row['n_id'])) . '">Les mer &raquo;</a></p>';
                        }
                    }
                    if (!$params->get("hide_select_page") && $pageinfo->pages > 1) {
                        $content .= '
<p>' . game::pagenumbers(game::address(PHP_SELF, $_GET, array($page_name)), game::address(PHP_SELF, $_GET, array($page_name), array($page_name => true)) . "=", $pageinfo->pages, $pageinfo->active) . '</p>';
                    }
                }
                break;
            case 8:
                // php include
                $content = '
<p>Not implementet.</p>';
                break;
            default:
                // plaintext
                $content = '
<p>' . htmlspecialchars($unit['nir_content']) . '</p>';
        }
        return $content;
    }