Beispiel #1
0
<?php

elgg_require_js('faq/list');
$catId = (int) get_input("categoryId");
if (!empty($catId)) {
    $cats = getCategories();
    $cat = faq_get_metastring($catId);
    if (in_array($cat, $cats)) {
        $faqs = getFaqs($cat);
        if (!empty($faqs)) {
            $display = "<div class='mbm'><h3>" . elgg_echo("faq:list:category_title") . $cat . "</h3></div>";
            foreach ($faqs as $faq) {
                $display .= elgg_view("object/faq", array("entity" => $faq));
            }
        } else {
            forward(elgg_get_site_url() . "faq/");
        }
    } else {
        register_error(elgg_echo("faq:list:no_category"));
        forward(elgg_get_site_url() . "faq/");
    }
} else {
    register_error(elgg_echo("faq:list:no_category"));
    forward(elgg_get_site_url() . "faq/");
}
echo "<div><div id='result'>" . $display . "</div></div>";
if (elgg_is_admin_logged_in() && !empty($catId)) {
    elgg_require_js('faq/list_admin');
    echo "<div id='beginEdit' class='listEditBegin mtm mbm'>";
    echo elgg_view('input/button', array("class" => "elgg-button elgg-button-submit", "name" => "beginEdit", "value" => elgg_echo("faq:list:edit:begin")));
    echo "</div>";
Beispiel #2
0
function faq_page_handler($page)
{
    if (!isset($page[0])) {
        $page[0] = 'index';
    }
    elgg_push_breadcrumb(elgg_echo('faq:shorttitle'), 'faq/');
    $title = elgg_echo('faq:title');
    $page_type = $page[0];
    switch ($page_type) {
        case 'index':
            $area = elgg_view('faq/search');
            $area .= elgg_view('faq/stats');
            break;
        case 'list':
            $catId = (int) get_input("categoryId");
            if (!empty($catId)) {
                $cats = getCategories();
                $cat = faq_get_metastring($catId);
                if (in_array($cat, $cats)) {
                    elgg_push_breadcrumb(elgg_echo("faq:list:category_title") . $cat);
                }
            }
            $area = elgg_view('faq/list');
            break;
        case 'ask':
            gatekeeper();
            elgg_push_breadcrumb(elgg_echo('faq:ask:title'));
            $area = elgg_view('faq/forms/ask');
            break;
        case 'asked':
            admin_gatekeeper();
            elgg_push_breadcrumb(elgg_echo('faq:asked:title'));
            $area = elgg_view('faq/asked');
            break;
        case 'add':
            admin_gatekeeper();
            elgg_push_breadcrumb(elgg_echo('faq:add:title'));
            $area = elgg_view('faq/forms/add');
            break;
        case 'edit':
            admin_gatekeeper();
            elgg_push_breadcrumb(elgg_echo('faq:edit:title'));
            $area = elgg_view('faq/forms/add');
            break;
        default:
            return false;
    }
    $sidebar = elgg_view('faq/sidebar');
    // Format page
    $body = elgg_view_layout('content', array('content' => $area, 'filter' => '', 'title' => $title, 'sidebar' => $sidebar));
    // Draw it
    echo elgg_view_page(elgg_echo('faq:title'), $body);
    return true;
}