Esempio n. 1
0
function print_results($query, $advanced = false)
{
    global $perm, $sess, $HTTP_GET_VARS, $glob_userdata, $glob_search_words;
    $glob_search_words = array();
    if (!defined("SEARCH_INC")) {
        include "search/search2.inc";
    }
    if (!defined("LAY_DIRECTORY_INC")) {
        include "layout/lay_directory.inc";
    }
    if (!defined("LAY_SEARCH_INC")) {
        include "layout/lay_search.inc";
    }
    if (!defined("COMMON_PERMISSIONS_INC")) {
        include "commonapi/common_permissions.inc";
    }
    $ciu = $HTTP_GET_VARS['ciu'] == "" ? 0 : $HTTP_GET_VARS['ciu'];
    $cit = $HTTP_GET_VARS['cit'] == "" ? 0 : $HTTP_GET_VARS['cit'];
    $cic = $HTTP_GET_VARS['cic'] == "" ? 0 : $HTTP_GET_VARS['cic'];
    if ($glob_userdata['ResPerPage'] == "") {
        $glob_userdata['ResPerPage'] = DIR_MAX_SEARCH;
    }
    if ($glob_userdata['HighlightSearch'] == "") {
        $glob_userdata['HighlightSearch'] = true;
    }
    $restriction = $HTTP_GET_VARS['restriction'];
    if ($query != "") {
        $err = "";
        if ($advanced == false) {
            $query = format_query($query);
        } else {
            $query = format_query_simple($query);
        }
        // echo("freag: $query<p>");
        $users = array();
        if (!ereg('^/Experts', $restriction)) {
            $cats = execute_query($query, $sess->id, $cic, "c", $restriction, $glob_userdata['ResPerPage']);
            if (!isset($cats['error'])) {
                $trails = execute_query($query, $sess->id, $cit, "t", $restriction, $glob_userdata['ResPerPage']);
                $glob_search_words = $cats['resinfo']['words'];
            } else {
                $err = $cats['error'];
            }
            if (!is_array($err)) {
                $experts = execute_query($query, $sess->id, 0, "e", $restriction, $glob_userdata['ResPerPage']);
            }
            if (isset($experts['error']) and !is_array($err)) {
                $err = $experts['error'];
            }
        } else {
            $users = execute_query($query, $sess->id, $ciu, "t", $restriction, $glob_userdata['ResPerPage']);
            $glob_search_words = $cats['words'];
            //  die($users['resinfo']['rescount']);
            if (isset($users['error'])) {
                $err = $users['error'];
            }
            $users['resinfo']['ci'] = $ciu;
        }
    }
    print_page_begin();
    $tpl = new Template(APPLICATION_HOME . "/templates/search", "keep");
    $tpl->set_file(array("main" => "main.html"));
    $caps = get_caps($perm, '/');
    $tpl->set_var("IWANTTO", print_iwantto('/', $caps));
    //printf("Test: %d / %d / %d<p>",count($trails['results']) ,count($trails['results']) ,count($trails['results']) );
    //printf("Test: %d, %d, %d", count($cats['results']), count($trails['results']), count($users['results']));
    if (count($cats['results']) == 0 and count($trails['results']) == 0 and count($users['results']) == 0 or $query == "") {
        if (is_array($err)) {
            $tpl->set_var("CATEGORIES", print_search_error($err));
        } else {
            $tpl->set_var("CATEGORIES", implode("\n", file(TEMPLATE_ROOT . 'search/nothing_found.html')));
        }
        $tpl->set_var("TRAILS", "");
        $tpl->set_var("EXPERTS", "");
    } elseif (count($users) > 0) {
        $tpl->set_var("CATEGORIES", print_found_users($users));
        $tpl->set_var("EXPERTS", "");
        $tpl->set_var("TRAILS", "");
    } else {
        $tpl->set_var("CATEGORIES", print_found_categories($cats));
        $tpl->set_var("TRAILS", print_found_trails($trails));
        $tpl->set_var("EXPERTS", print_found_experts($experts));
    }
    $tpl->parse("main", "main");
    $tpl->p("main");
    print_page_end();
}
Esempio n. 2
0
function slot_edit_error($errors)
{
    global $kat, $HTTP_POST_VARS, $capabilities, $nodeinfo, $id;
    $slot['id'] = $HTTP_POST_VARS['id'];
    $slot['node'] = $nodeinfo['id'];
    $slot['trail_1_path'] = $HTTP_POST_VARS['field_trail_1'];
    $slot['trail_1_text'] = $HTTP_POST_VARS['field_title_1'];
    $slot['trail_2_path'] = $HTTP_POST_VARS['field_trail_2'];
    $slot['trail_2_text'] = $HTTP_POST_VARS['field_title_2'];
    $slot['description'] = $HTTP_POST_VARS['field_description'];
    $errstrs = "<font size=\"2\" face=\"verdana, arial, helvetica\">The following errors occured:<ul>";
    foreach ($errors as $errstr) {
        $errstrs .= "<li>{$errstr}";
    }
    $errstrs .= "</ul></font>";
    print_page_begin();
    $tpl = new Template(APPLICATION_HOME . "/templates/directory", "keep");
    $tpl->set_file(array("main" => "main.html"));
    $tpl->set_var("SUBNODES", print_slot_form($nodeinfo, $slot, $errstrs));
    $tpl->set_var("TRAILS", "");
    $tpl->set_var("IWANTTO", print_iwantto($kat, $capabilities));
    $tpl->set_var("FEATURED", print_featured($kat));
    $tpl->set_var("TOPEX", print_topex($kat));
    $tpl->set_var("NEWTRAILS", print_newtrails($activekat));
    $tpl->set_var("DIDYOUKNOW", "");
    $tpl->set_var("OPENTRAIL", "");
    $tpl->parse("main", "main");
    $tpl->p("main");
    print_page_end();
    exit;
}