function wysiwyg_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    static $search_sql = FALSE;
    if (function_exists('search_make_sql_part')) {
        if ($search_sql === FALSE) {
            $search_sql = search_make_sql_part($func_search_url_array, $func_search_match, array('`content`'));
        }
    } else {
        $search_sql = '1=1';
    }
    // how many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    $divider = ".";
    $result = false;
    // we have to get 'content' instead of 'text', because strip_tags() dosen't remove scripting well.
    // scripting will be removed later on automatically
    $table = TABLE_PREFIX . "mod_wysiwyg";
    $query = $func_database->query("\n\t\tSELECT content\n\t\tFROM {$table}\n\t\tWHERE section_id='{$func_section_id}'\n\t");
    if ($query->numRows() > 0) {
        if ($res = $query->fetchRow()) {
            $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => "#wb_section_{$func_section_id}", 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => $func_page_modified_when, 'page_modified_by' => $func_page_modified_by, 'text' => $res['content'] . $divider, 'max_excerpt_num' => $max_excerpt_num);
            if (print_excerpt2($mod_vars, $func_vars)) {
                $result = true;
            }
        }
    }
    return $result;
}
Example #2
0
function wysiwyg_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    // how many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    $divider = ".";
    $result = false;
    // we have to get 'content' instead of 'text', because strip_tags()
    // doesn't remove scripting well.
    // scripting will be removed later on automatically
    $query = $func_database->query(sprintf("SELECT content FROM `%smod_wysiwyg` WHERE section_id='%d'", CAT_TABLE_PREFIX, $func_section_id));
    if ($query->numRows() > 0) {
        if ($res = $query->fetchRow()) {
            if (CAT_Helper_Addons::isModuleInstalled('kit_framework')) {
                // remove all kitCommands from the content
                preg_match_all('/(~~)( | )(.){3,512}( | )(~~)/', $res['content'], $matches, PREG_SET_ORDER);
                foreach ($matches as $match) {
                    $res['content'] = str_replace($match[0], '', $res['content']);
                }
            }
            $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => SEC_ANCHOR . "#section_{$func_section_id}", 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => $func_page_modified_when, 'page_modified_by' => $func_page_modified_by, 'text' => $res['content'] . $divider, 'max_excerpt_num' => $max_excerpt_num);
            if (print_excerpt2($mod_vars, $func_vars)) {
                $result = true;
            }
        }
    }
    return $result;
}
Example #3
0
function bakery_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    // How many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    // Show thumbnails?
    $show_thumb = true;
    // Show option-attributes?
    $show_options = true;
    $divider = '.';
    $result = false;
    // Get some default values
    require_once WB_PATH . '/modules/bakery/config.php';
    $table_item = TABLE_PREFIX . "mod_bakery_items";
    $table_images = TABLE_PREFIX . "mod_bakery_images";
    $table_item_att = TABLE_PREFIX . "mod_bakery_item_attributes";
    $table_att = TABLE_PREFIX . "mod_bakery_attributes";
    // Fetch all active bakery-items in this section
    // Do not care if the shop is offline
    $query = $func_database->query("\n\t\tSELECT item_id, title, sku, definable_field_0, definable_field_1, definable_field_2, link, description, full_desc, modified_when, modified_by\n\t\tFROM {$table_item}\n\t\tWHERE section_id = '{$func_section_id}' AND active = '1'\n\t\tORDER BY title ASC\n\t");
    // Now call print_excerpt() for every single item
    if ($query->numRows() > 0) {
        while ($res = $query->fetchRow()) {
            // $res['link'] contains PAGES_DIRECTORY/bakery/... (e.g. "/pages/bakery/...")
            // Remove the leading PAGES_DIRECTORY
            $page_link = preg_replace('/^\\' . PAGES_DIRECTORY . '/', '', $res['link'], 1);
            // Thumbnail
            $pic_link = '';
            if ($show_thumb) {
                $query_thumb = $func_database->query("\n\t\t\t\t\tSELECT filename\n\t\t\t\t\tFROM {$table_images}\n\t\t\t\t\tWHERE item_id = '" . $res['item_id'] . "' AND active = '1'\n\t\t\t\t\tORDER BY position ASC\n\t\t\t\t\tLIMIT 1\n\t\t\t\t");
                if ($query_thumb->numRows() > 0) {
                    $thumb = $query_thumb->fetchRow();
                    $thumb_dir = '/' . $img_dir . '/thumbs/item' . $res['item_id'] . '/';
                    if (is_file(WB_PATH . MEDIA_DIRECTORY . $thumb_dir . $thumb['filename'])) {
                        $pic_link = $thumb_dir . $thumb['filename'];
                    }
                }
            }
            // Option attributes
            $options = '.';
            if ($show_options) {
                $query_att = $func_database->query("\n\t\t\t\t\tSELECT attribute_name\n\t\t\t\t\tFROM {$table_item_att} INNER JOIN {$table_att} USING(attribute_id)\n\t\t\t\t\tWHERE item_id = '{$res['item_id']}'\n\t\t\t\t\tORDER BY {$table_att}.option_id ASC\n\t\t\t\t");
                if ($query_att->numRows() > 0) {
                    while ($res_att = $query_att->fetchRow()) {
                        $options .= $res_att['attribute_name'] . '.';
                    }
                }
            }
            $mod_vars = array('page_link' => $page_link, 'page_link_target' => "#wb_section_{$func_section_id}", 'page_title' => $res['title'], 'page_description' => $res['description'], 'page_modified_when' => $res['modified_when'], 'page_modified_by' => $res['modified_by'], 'text' => $res['title'] . $divider . $res['description'] . $divider . $res['full_desc'] . $divider . $res['definable_field_0'] . $divider . $res['definable_field_1'] . $divider . $res['definable_field_2'] . $divider . $options . $divider . $res['sku'] . $divider, 'max_excerpt_num' => $max_excerpt_num, 'pic_link' => $pic_link);
            if (print_excerpt2($mod_vars, $func_vars)) {
                $result = true;
            }
        }
    }
    return $result;
}
Example #4
0
function news_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    // how many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    // do we want excerpt from comments?
    $excerpt_from_comments = true;
    // TODO: make this configurable
    $divider = ".";
    $result = false;
    // fetch all active news-posts (from active groups) in this section.
    $t = time();
    $table_posts = TABLE_PREFIX . "mod_news_posts";
    $table_groups = TABLE_PREFIX . "mod_news_groups";
    $query = $func_database->query("\n\t\tSELECT p.post_id, p.title, p.content_short, p.content_long, p.link, p.posted_when, p.posted_by\n\t\tFROM {$table_posts} AS p LEFT OUTER JOIN {$table_groups} AS g ON p.group_id = g.group_id\n\t\tWHERE p.section_id='{$func_section_id}' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' )\n\t\tAND (published_when = '0' OR published_when <= {$t}) AND (published_until = 0 OR published_until >= {$t})\n\t\tORDER BY p.post_id DESC\n\t");
    // now call print_excerpt() for every single post
    if ($query->numRows() > 0) {
        while ($res = $query->fetchRow()) {
            $text = $res['title'] . $divider . $res['content_short'] . $divider . $res['content_long'] . $divider;
            // fetch comments and add to $text
            if ($excerpt_from_comments) {
                $table = TABLE_PREFIX . "mod_news_comments";
                $commentquery = $func_database->query("\n\t\t\t\t\tSELECT title, comment\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tWHERE post_id='{$res['post_id']}'\n\t\t\t\t\tORDER BY commented_when ASC\n\t\t\t\t");
                if ($commentquery->numRows() > 0) {
                    while ($c_res = $commentquery->fetchRow()) {
                        $text .= $c_res['title'] . $divider . $c_res['comment'] . $divider;
                    }
                }
            }
            $mod_vars = array('page_link' => $res['link'], 'page_link_target' => "", 'page_title' => $func_page_title, 'page_description' => $res['title'], 'page_modified_when' => $res['posted_when'], 'page_modified_by' => $res['posted_by'], 'text' => $text, 'max_excerpt_num' => $max_excerpt_num);
            if (print_excerpt2($mod_vars, $func_vars)) {
                $result = true;
            }
        }
    }
    // now fetch group-titles - ignore those without (active) postings
    $table_groups = TABLE_PREFIX . "mod_news_groups";
    $table_posts = TABLE_PREFIX . "mod_news_posts";
    $query = $func_database->query("\n\t\tSELECT DISTINCT g.title, g.group_id\n\t\tFROM {$table_groups} AS g INNER JOIN {$table_posts} AS p ON g.group_id = p.group_id\n\t\tWHERE g.section_id='{$func_section_id}' AND g.active = '1' AND p.active = '1'\n\t");
    // now call print_excerpt() for every single group, too
    if ($query->numRows() > 0) {
        while ($res = $query->fetchRow()) {
            $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => "&g=" . $res['group_id'], 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => $func_page_modified_when, 'page_modified_by' => $func_page_modified_by, 'text' => $res['title'] . $divider, 'max_excerpt_num' => $max_excerpt_num);
            if (print_excerpt2($mod_vars, $func_vars)) {
                $result = true;
            }
        }
    }
    return $result;
}
/**
 * This function will be called by the search function and returns the results
 * via print_excerpt2() for the specified SECTION_ID
 *
 * @param array $search
 * @return boolean
 */
function wysiwyg_search($search)
{
    global $database;
    $SQL = sprintf("SELECT `content` FROM `%smod_wysiwyg` WHERE `section_id`='%d'", TABLE_PREFIX, $search['section_id']);
    $content = $database->get_one($SQL, MYSQL_ASSOC);
    if (!empty($content)) {
        $content = extendedWYSIWYG::unsanitizeText($content);
        // remove HTML
        $content = strip_tags($content);
        // remove dbGlossary tags
        $content = str_replace('||', '', $content);
        $result = array('page_link' => $search['page_link'], 'page_link_target' => SEC_ANCHOR . $search['section_id'], 'page_title' => $search['page_title'], 'page_description' => $search['page_description'], 'page_modified_when' => $search['page_modified_when'], 'page_modified_by' => $search['page_modified_by'], 'text' => $content . '.', 'max_exerpt_num' => $search['default_max_excerpt']);
        if (print_excerpt2($result, $search)) {
            return true;
        }
    }
    return false;
}
Example #6
0
/**
 *  @module         code2
 *  @version        see info.php of this module
 *  @authors        Ryan Djurovich, Chio Maisriml, Thomas Hornik, Dietrich Roland Pehlke
 *  @copyright      2004-2014 Ryan Djurovich, Chio Maisriml, Thomas Hornik, Dietrich Roland Pehlke
 *  @license        GNU General Public License
 *  @license terms  see info.php of this module
 *  @platform       see info.php of this module
 *
 */
function code2_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    // how many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    $divider = ".";
    $result = false;
    $table = TABLE_PREFIX . "mod_code2";
    $query = $func_database->query("\n\t\tSELECT `content`\n\t\tFROM `{$table}`\n\t\tWHERE `section_id`={$func_section_id} AND `whatis`=1\n\t");
    if ($query->numRows() > 0) {
        if ($res = $query->fetchRow()) {
            $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => "#wb_section_{$func_section_id}", 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => $func_page_modified_when, 'page_modified_by' => $func_page_modified_by, 'text' => $res['content'] . $divider, 'max_excerpt_num' => $max_excerpt_num);
            if (print_excerpt2($mod_vars, $func_vars)) {
                $result = true;
            }
        }
    }
    return $result;
}
Example #7
0
function download_gallery_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    // how many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    $divider = ".";
    $result = false;
    // fetch all active download-gallery-items (from active groups) from this section
    $table_files = "`" . TABLE_PREFIX . $tablename . "_files`";
    $table_groups = "`" . TABLE_PREFIX . $tablename . "_groups`";
    $query = $func_database->query("\n\t\tSELECT `f`.`title`, `f`.`filename`, `f`.`description`, `f`.`modified_when`, `f`.`modified_by`\n\t\tFROM {$table_files} AS f LEFT OUTER JOIN {$table_groups} AS g ON `f`.`group_id` = `g`.`group_id`\n\t\tWHERE `f`.`section_id`='{$func_section_id}' AND `f`.`active` = '1' AND ( `g`.`active` IS NULL OR `g`.`active` = '1' )\n\t\tORDER BY `f`.`title` ASC\n\t");
    // here, we call print_excerpt() only once for _all_ items
    // $res['modified_when'] and ..by'] doesn't make sense in this case.
    if ($query->numRows() > 0) {
        $text = "";
        while ($res = $query->fetchRow()) {
            $text .= $res['title'] . $divider . $res['filename'] . $divider . $res['description'] . $divider;
        }
        $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => "#wb_section_{$func_section_id}", 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => 0, 'page_modified_by' => "", 'text' => $text, 'max_excerpt_num' => $max_excerpt_num);
        if (print_excerpt2($mod_vars, $func_vars)) {
            $result = true;
        }
    }
    // now fetch group-titles - ignore those without (active) items
    $table_groups = "`" . TABLE_PREFIX . $tablename . "_groups`";
    $table_files = "`" . TABLE_PREFIX . $tablename . "_files`";
    $query = $func_database->query("\n\t\tSELECT `g`.`title`\n\t\tFROM {$table_groups} AS g INNER JOIN {$table_files} AS f ON `g`.`group_id` = `f`.`group_id`\n\t\tWHERE `g`.`section_id`='{$func_section_id}' AND `g`.`active` = '1' AND `f`.`active` = '1'\n\t");
    // now call print_excerpt() for all groups, too
    if ($query->numRows() > 0) {
        $text = "";
        while ($res = $query->fetchRow()) {
            $text .= $res['title'] . $divider;
        }
        $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => "#wb_section_{$func_section_id}", 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => 0, 'page_modified_by' => "", 'text' => $text, 'max_excerpt_num' => $max_excerpt_num);
        if (print_excerpt2($mod_vars, $func_vars)) {
            $result = true;
        }
    }
    return $result;
}
/**
 * This function will be called by the search function and returns the results
 * via print_excerpt2() for the specified SECTION_ID
 *
 * @param array $search
 * @return boolean
 */
function topics_search($search)
{
    global $database;
    // include module_settings
    include WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/defaults/module_settings.default.php';
    include WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/module_settings.php';
    $divider = ".";
    $result = false;
    $SQL = "SELECT * FROM `" . TABLE_PREFIX . "mod_topics` " . "WHERE `section_id`='{$search['section_id']}' AND `active` > '3' ORDER BY `topic_id` DESC";
    if (null == ($query = $database->query($SQL))) {
        trigger_error(sprintf('[%s - %s] %s', __FUNCTION__, __LINE__, $database->get_error()), E_USER_ERROR);
    }
    while ($topic = $query->fetchRow(MYSQL_ASSOC)) {
        $text = $topic['title'] . $divider . $topic['description'] . $divider . $topic['content_long'] . $divider;
        $text = stripcslashes($text);
        $text = str_replace('||', '', $text);
        $item = array('page_link' => $topics_search_directory . $topic['link'], 'page_link_target' => "", 'page_title' => $topic['title'], 'page_description' => $topic['short_description'], 'page_modified_when' => $topic['posted_modified'], 'page_modified_by' => $topic['posted_by'], 'text' => $text, 'max_excerpt_num' => $search['default_max_excerpt']);
        if (print_excerpt2($item, $search)) {
            $result = true;
        }
    }
    return $result;
}
Example #9
0
File: search.php Project: WBCE/form
function form_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    // how many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    $divider = ".";
    $result = false;
    // fetch all form-fields on this page
    $table = TABLE_PREFIX . "mod_form_fields";
    $query = $func_database->query("\n\t\tSELECT title, value\n\t\tFROM {$table}\n\t\tWHERE section_id='{$func_section_id}'\n\t\tORDER BY position ASC\n\t");
    // now call print_excerpt() only once for all items
    if ($query->numRows() > 0) {
        $text = "";
        while ($res = $query->fetchRow()) {
            $text .= $res['title'] . $divider . $res['value'] . $divider;
        }
        $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => "#wb_section_{$func_section_id}", 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => $func_page_modified_when, 'page_modified_by' => $func_page_modified_by, 'text' => $text, 'max_excerpt_num' => $max_excerpt_num);
        if (print_excerpt2($mod_vars, $func_vars)) {
            $result = true;
        }
    }
    return $result;
}
         $func_vars = array('database' => $database, 'page_id' => $page['page_id'], 'page_title' => $page['page_title'], 'page_menu_title' => $page['menu_title'], 'page_description' => $cfg_show_description ? $page['description'] : "", 'page_keywords' => $page['keywords'], 'page_link' => $page['link'], 'page_modified_when' => $page['modified_when'], 'page_modified_by' => $page['modified_by'], 'users' => $users, 'search_words' => $search_words, 'search_match' => $match, 'search_url_array' => $search_url_array, 'search_entities_array' => $search_entities_array, 'results_loop_string' => $fetch_results_loop['value'], 'default_max_excerpt' => $max_excerpt_num, 'enable_flush' => $cfg_enable_flush);
         // Only show this page if we are allowed to see it
         if ($admin->page_is_visible($page) == false) {
             if ($page['visibility'] != 'registered') {
                 continue;
             } else {
                 // page: registered, user: access denied
                 $func_vars['page_description'] = $TEXT['REGISTERED'];
             }
         }
         if ($admin->page_is_active($page) == false) {
             continue;
         }
         $text = $func_vars['page_title'] . $divider . $func_vars['page_menu_title'] . $divider . ($cfg_search_description ? $func_vars['page_description'] : "") . $divider . ($cfg_search_keywords ? $func_vars['page_keywords'] : "") . $divider;
         $mod_vars = array('page_link' => $func_vars['page_link'], 'page_link_target' => "", 'page_title' => $func_vars['page_title'], 'page_description' => $func_vars['page_description'], 'page_modified_when' => $func_vars['page_modified_when'], 'page_modified_by' => $func_vars['page_modified_by'], 'text' => $text, 'max_excerpt_num' => $func_vars['default_max_excerpt']);
         if (print_excerpt2($mod_vars, $func_vars)) {
             $pages_listed[$page['page_id']] = true;
         }
     }
 }
 // Now use the old method for pages not displayed by the new method above
 // in case someone has old modules without search.php.
 // Get modules
 $table_search = TABLE_PREFIX . "search";
 $table_sections = TABLE_PREFIX . "sections";
 $get_modules = $database->query("\n\t\tSELECT DISTINCT s.value, s.extra\n\t\tFROM {$table_search} AS s INNER JOIN {$table_sections} AS sec\n\t\t\tON s.value = sec.module\n\t\tWHERE s.name = 'module'\n\t");
 $modules = array();
 if ($get_modules->numRows() > 0) {
     while ($module = $get_modules->fetchRow()) {
         $modules[] = $module;
         // $modules in an array of arrays
Example #11
0
function news_search($func_vars)
{
    extract($func_vars, EXTR_PREFIX_ALL, 'func');
    static $search_sql1 = FALSE;
    static $search_sql2 = FALSE;
    static $search_sql3 = FALSE;
    if (function_exists('search_make_sql_part')) {
        if ($search_sql1 === FALSE) {
            $search_sql1 = search_make_sql_part($func_search_url_array, $func_search_match, array('`title`', '`content_short`', '`content_long`'));
        }
        if ($search_sql2 === FALSE) {
            $search_sql2 = search_make_sql_part($func_search_url_array, $func_search_match, array('`title`', '`comment`'));
        }
        if ($search_sql3 === FALSE) {
            $search_sql3 = search_make_sql_part($func_search_url_array, $func_search_match, array('g.`title`'));
        }
    } else {
        $search_sql1 = $search_sql2 = $search_sql3 = '1=1';
    }
    // how many lines of excerpt we want to have at most
    $max_excerpt_num = $func_default_max_excerpt;
    // do we want excerpt from comments?
    $excerpt_from_comments = true;
    // TODO: make this configurable
    $divider = ".";
    $result = false;
    if ($func_time_limit > 0) {
        $stop_time = time() + $func_time_limit;
    }
    // fetch all active news-posts (from active groups) in this section.
    $t = time();
    $table_posts = TABLE_PREFIX . "mod_news_posts";
    $table_groups = TABLE_PREFIX . "mod_news_groups";
    $query = $func_database->query("\r\n\t\tSELECT p.post_id, p.title, p.content_short, p.content_long, p.link, p.posted_when, p.posted_by\r\n\t\tFROM {$table_posts} AS p LEFT OUTER JOIN {$table_groups} AS g ON p.group_id = g.group_id\r\n\t\tWHERE p.section_id='{$func_section_id}' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' )\r\n\t\tAND (published_when = '0' OR published_when <= {$t}) AND (published_until = 0 OR published_until >= {$t})\r\n\t\tORDER BY p.post_id DESC\r\n\t");
    // now call print_excerpt() for every single post
    if ($query->numRows() > 0) {
        while ($res = $query->fetchRow()) {
            $text = '';
            // break out if stop-time is reached
            if (isset($stop_time) && time() > $stop_time) {
                return $result;
            }
            // fetch content
            $postquery = $func_database->query("\r\n\t\t\t\tSELECT title, content_short, content_long\r\n\t\t\t\tFROM {$table_posts}\r\n\t\t\t\tWHERE post_id='{$res['post_id']}' AND {$search_sql1}\r\n\t\t\t");
            if ($postquery->numRows() > 0) {
                if ($p_res = $postquery->fetchRow()) {
                    $text = $p_res['title'] . $divider . $p_res['content_short'] . $divider . $p_res['content_long'] . $divider;
                }
            }
            // fetch comments and add to $text
            if ($excerpt_from_comments) {
                $table = TABLE_PREFIX . "mod_news_comments";
                $commentquery = $func_database->query("\r\n\t\t\t\t\tSELECT title, comment\r\n\t\t\t\t\tFROM {$table}\r\n\t\t\t\t\tWHERE post_id='{$res['post_id']}' AND {$search_sql2}\r\n\t\t\t\t\tORDER BY commented_when ASC\r\n\t\t\t\t");
                if ($commentquery->numRows() > 0) {
                    while ($c_res = $commentquery->fetchRow()) {
                        // break out if stop-time is reached
                        if (isset($stop_time) && time() > $stop_time) {
                            return $result;
                        }
                        $text .= $c_res['title'] . $divider . $c_res['comment'] . $divider;
                    }
                }
            }
            if ($text) {
                $mod_vars = array('page_link' => $res['link'], 'page_link_target' => "", 'page_title' => $func_page_title, 'page_description' => $res['title'], 'page_modified_when' => $res['posted_when'], 'page_modified_by' => $res['posted_by'], 'text' => $text, 'max_excerpt_num' => $max_excerpt_num);
                if (print_excerpt2($mod_vars, $func_vars)) {
                    $result = true;
                }
            }
        }
    }
    // now fetch group-titles - ignore those without (active) postings
    $table_groups = TABLE_PREFIX . "mod_news_groups";
    $table_posts = TABLE_PREFIX . "mod_news_posts";
    $query = $func_database->query("\r\n\t\tSELECT DISTINCT g.title, g.group_id\r\n\t\tFROM {$table_groups} AS g INNER JOIN {$table_posts} AS p ON g.group_id = p.group_id\r\n\t\tWHERE g.section_id='{$func_section_id}' AND g.active = '1' AND p.active = '1' AND {$search_sql3}\r\n\t");
    // now call print_excerpt() for every single group, too
    if ($query->numRows() > 0) {
        while ($res = $query->fetchRow()) {
            // break out if stop-time is reached
            if (isset($stop_time) && time() > $stop_time) {
                return $result;
            }
            $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => "&g=" . $res['group_id'], 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => $func_page_modified_when, 'page_modified_by' => $func_page_modified_by, 'text' => $res['title'] . $divider, 'max_excerpt_num' => $max_excerpt_num);
            if (print_excerpt2($mod_vars, $func_vars)) {
                $result = true;
            }
        }
    }
    return $result;
}
function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link = "")
{
    $mod_vars = array('page_link' => $page_link, 'page_link_target' => $page_link_target, 'page_title' => $page_title, 'page_description' => $page_description, 'page_modified_when' => $page_modified_when, 'page_modified_by' => $page_modified_by, 'text' => $text, 'max_excerpt_num' => $max_excerpt_num, 'pic_link' => $pic_link);
    print_excerpt2($mod_vars, $func_vars);
}
Example #13
0
/**
 * Compatibillity wrapper for the old function print_excerpt()
 * This function is no longer supported!
 * 
 * @deprecated - use print_excerpt2() instead!
 * @todo - remove at LEPTON 2.1.x!
 * @param string $page_link
 * @param string $page_link_target
 * @param string $page_title
 * @param string $page_description
 * @param integer $page_modified_when
 * @param string $page_modified_by
 * @param string $text
 * @param integer $max_excerpt_num
 * @param array $func_vars
 * @param string $pic_link
 */
function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link = "")
{
    // print_excerpt() is deprecated!
    trigger_error('The function print_excerpt() is no longer supported, use print_excerpt2() instead!', E_USER_ERROR);
    $mod_vars = array('page_link' => $page_link, 'page_link_target' => $page_link_target, 'page_title' => $page_title, 'page_description' => $page_description, 'page_modified_when' => $page_modified_when, 'page_modified_by' => $page_modified_by, 'text' => $text, 'max_excerpt_num' => $max_excerpt_num, 'pic_link' => $pic_link);
    print_excerpt2($mod_vars, $func_vars);
}
Example #14
0
 protected function execSearch()
 {
     global $database;
     global $admin;
     $data = array();
     if ($this->search_string == '') {
         // empty search string - just return the dialog
         $this->search_result = array('form' => $this->getSearchForm());
         return true;
     }
     // Get the modules from module table
     $get_modules = $database->query(sprintf("SELECT DISTINCT module FROM %ssections WHERE module != '' ", TABLE_PREFIX));
     if ($database->is_error()) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $database->get_error()));
         return false;
     }
     $modules = array();
     if ($get_modules->numRows() > 0) {
         while (false !== ($module = $get_modules->fetchRow(MYSQL_ASSOC))) {
             $modules[] = $module['module'];
         }
     }
     // get the modules for the Droplet search
     $SQL = sprintf("SELECT * FROM %ssearch WHERE name='droplet'", TABLE_PREFIX);
     if (false === ($get_droplets = $database->query($SQL))) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $database->get_error()));
         return false;
     }
     $droplets = array();
     $droplet_array = array();
     if ($get_droplets->numRows() > 0) {
         while (false !== ($module = $get_droplets->fetchRow(MYSQL_ASSOC))) {
             $value = unserialize($module['extra']);
             if (isset($value['page_id']) && isset($value['module_directory'])) {
                 $droplets[] = array('module_directory' => $value['module_directory'], 'page_id' => $value['page_id'], 'droplet_name' => $module['value']);
                 if (!isset($droplet_array[$value['module_directory']])) {
                     $modules[] = $value['module_directory'];
                     $droplet_array[$value['module_directory']] = $value['module_directory'];
                 }
             }
         }
     }
     // sort module search order - first modules from CFG_MODULE_ORDER
     $sorted_modules = array();
     $search_modules = explode(',', $this->setting[CFG_SEARCH_MODULE_ORDER]);
     foreach ($search_modules as $item) {
         $item = trim($item);
         for ($i = 0; $i < count($modules); $i++) {
             if (isset($modules[$i]) && $modules[$i] == $item) {
                 $sorted_modules[] = $modules[$i];
                 unset($modules[$i]);
                 break;
             }
         }
     }
     // ... then add the rest
     foreach ($modules as $item) {
         $sorted_modules[] = $item;
     }
     // Use the module's search-extensions.
     // This is somewhat slower than the orginial method.
     // init the $_SESSION for the search result items
     $_SESSION[SESSION_SEARCH_RESULT_ITEMS] = array();
     // call $search_funcs['__before'] first
     $search_func_vars = array('database' => $database, 'page_id' => 0, 'section_id' => 0, 'page_title' => '', 'page_menu_title' => '', 'page_description' => '', 'page_keywords' => '', 'page_link' => '', 'page_visibility' => 'public', 'page_modified_when' => 0, 'page_modified_by' => 0, 'users' => $this->users, 'search_words' => $this->search_words, 'search_match' => $this->search_type, 'search_url_array' => $this->search_url_array, 'search_entities_array' => $this->search_entities_array, 'default_max_excerpt' => $this->setting[CFG_SEARCH_MAX_EXCERPTS], 'time_limit' => $this->setting[CFG_SEARCH_TIME_LIMIT], 'search_path' => $this->search_path, 'settings' => $this->setting);
     // see docu
     foreach ($this->search_functions['__before'] as $func) {
         $uf_res = call_user_func($func, $search_func_vars);
     }
     // now call module-based $search_funcs[]
     $seen_pages = array();
     // seen pages per module.
     $pages_listed = array();
     // seen pages.
     // skip this search if $search_max_excerpt == 0
     if ($this->setting[CFG_SEARCH_MAX_EXCERPTS] != 0) {
         foreach ($sorted_modules as $module_name) {
             $start_time = time();
             // get start-time to check time-limit; not very accurate, but ok
             $seen_pages[$module_name] = array();
             if (!isset($this->search_functions[$module_name])) {
                 // there is no search_func for this module
                 continue;
             }
             if (isset($droplet_array[$module_name])) {
                 // don't look for sections - call droplets search function
                 $pids = array();
                 foreach ($droplets as $dl) {
                     if ($dl['module_directory'] == $module_name) {
                         $pids[] = $dl['page_id'];
                     }
                 }
                 foreach ($pids as $pid) {
                     $SQL = sprintf("SELECT * FROM %spages WHERE page_id='%s'", TABLE_PREFIX, $pid);
                     if (false === ($pages_query = $database->query($SQL))) {
                         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $database->get_error()));
                         return false;
                     }
                     if ($pages_query->numRows() > 0) {
                         while (false !== ($res = $pages_query->fetchRow(MYSQL_ASSOC))) {
                             // check if time-limit is exceeded for this module
                             if ($this->setting[CFG_SEARCH_TIME_LIMIT] > 0 && time() - $start_time > $this->setting[CFG_SEARCH_TIME_LIMIT]) {
                                 break;
                             }
                             $search_func_vars = array('database' => $database, 'page_id' => $res['page_id'], 'section_id' => -1, 'page_title' => $res['page_title'], 'page_menu_title' => $res['menu_title'], 'page_description' => $this->setting[CFG_SEARCH_SHOW_DESCRIPTIONS] ? $res['description'] : "", 'page_keywords' => $res['keywords'], 'page_link' => $res['link'], 'page_visibility' => $res['visibility'], 'page_modified_when' => $res['modified_when'], 'page_modified_by' => $res['modified_by'], 'users' => $this->users, 'search_words' => $this->search_words, 'search_match' => $this->search_type, 'search_url_array' => $this->search_url_array, 'search_entities_array' => $this->search_entities_array, 'default_max_excerpt' => $this->setting[CFG_SEARCH_MAX_EXCERPTS], 'time_limit' => $this->setting[CFG_SEARCH_TIME_LIMIT], 'settings' => $this->setting);
                             // Only show this page if we are allowed to see it
                             if ($admin->page_is_visible($res) == false) {
                                 if ($res['visibility'] == 'registered') {
                                     if (!$this->setting[CFG_SEARCH_NON_PUBLIC_CONTENT]) {
                                         // don't show excerpt
                                         $search_func_vars['default_max_excerpt'] = 0;
                                         $search_func_vars['page_description'] = $MOD_SEARCH['This content is reserved for registered users.'];
                                     } else {
                                         // show non public content so set $_SESSIONs for print_excerpt2()
                                         $_SESSION[SESSION_SEARCH_NON_PUBLIC_CONTENT] = true;
                                         $_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT] = $this->setting[CFG_SEARCH_LINK_NON_PUBLIC_CONTENT];
                                     }
                                 } else {
                                     // private
                                     continue;
                                 }
                             }
                             // call the module search function
                             $uf_res = call_user_func($this->search_functions[$module_name], $search_func_vars);
                             if ($uf_res) {
                                 $pages_listed[$res['page_id']] = true;
                                 $seen_pages[$module_name][$res['page_id']] = true;
                             } else {
                                 $seen_pages[$module_name][$res['page_id']] = true;
                             }
                         }
                     }
                 }
             } else {
                 // get each section for $module_name
                 $table_s = TABLE_PREFIX . "sections";
                 $table_p = TABLE_PREFIX . "pages";
                 $SQL = "SELECT s.section_id, s.page_id, s.module, s.publ_start, \n                        s.publ_end, p.page_title, p.menu_title, p.link, p.description, \n                        p.keywords, p.modified_when, p.modified_by, p.visibility, \n                        p.viewing_groups, p.viewing_users FROM {$table_s} AS s \n                        INNER JOIN {$table_p} AS p ON s.page_id = p.page_id WHERE \n                        s.module = '{$module_name}' AND p.visibility NOT IN \n                        ('none','deleted') AND p.searching = '1' " . $this->search_path_SQL . " " . $this->search_language_SQL . " ORDER BY s.page_id, s.position ASC";
                 if (false === ($sections_query = $database->query($SQL))) {
                     $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $database->get_error()));
                     return false;
                 }
                 if ($sections_query->numRows() > 0) {
                     while (false !== ($res = $sections_query->fetchRow())) {
                         // check if time-limit is exceeded for this module
                         if ($this->setting[CFG_SEARCH_TIME_LIMIT] > 0 && time() - $start_time > $this->setting[CFG_SEARCH_TIME_LIMIT]) {
                             break;
                         }
                         // Only show this section if it is not "out of publication-date"
                         $now = time();
                         if (!($now < $res['publ_end'] && ($now > $res['publ_start'] || $res['publ_start'] == 0) || $now > $res['publ_start'] && $res['publ_end'] == 0)) {
                             continue;
                         }
                         $search_func_vars = array('database' => $database, 'page_id' => $res['page_id'], 'section_id' => $res['section_id'], 'page_title' => $res['page_title'], 'page_menu_title' => $res['menu_title'], 'page_description' => $this->setting[CFG_SEARCH_SHOW_DESCRIPTIONS] ? $res['description'] : "", 'page_keywords' => $res['keywords'], 'page_link' => $res['link'], 'page_visibility' => $res['visibility'], 'page_modified_when' => $res['modified_when'], 'page_modified_by' => $res['modified_by'], 'users' => $this->users, 'search_words' => $this->search_words, 'search_match' => $this->search_type, 'search_url_array' => $this->search_url_array, 'search_entities_array' => $this->search_entities_array, 'default_max_excerpt' => $this->setting[CFG_SEARCH_MAX_EXCERPTS], 'time_limit' => $this->setting[CFG_SEARCH_TIME_LIMIT], 'settings' => $this->setting);
                         // Only show this page if we are allowed to see it
                         if ($admin->page_is_visible($res) == false) {
                             if ($res['visibility'] == 'registered') {
                                 if (!$this->setting[CFG_SEARCH_NON_PUBLIC_CONTENT]) {
                                     // don't show excerpt
                                     $search_func_vars['default_max_excerpt'] = 0;
                                     $search_func_vars['page_description'] = $MOD_SEARCH['This content is reserved for registered users.'];
                                 } else {
                                     // show non public content so set $_SESSIONs for print_excerpt2()
                                     $_SESSION[SESSION_SEARCH_NON_PUBLIC_CONTENT] = true;
                                     $_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT] = $this->setting[CFG_SEARCH_LINK_NON_PUBLIC_CONTENT];
                                 }
                             } else {
                                 // private
                                 continue;
                             }
                         }
                         // call the module search function
                         $uf_res = call_user_func($this->search_functions[$module_name], $search_func_vars);
                         if ($uf_res) {
                             $pages_listed[$res['page_id']] = true;
                             $seen_pages[$module_name][$res['page_id']] = true;
                         } else {
                             $seen_pages[$module_name][$res['page_id']] = true;
                         }
                     }
                     // while
                 }
                 // if
             }
         }
         // foreach
     }
     // max_excerpts
     // call $search_funcs['__after']
     $search_func_vars = array('database' => $database, 'page_id' => 0, 'section_id' => 0, 'page_title' => '', 'page_menu_title' => '', 'page_description' => '', 'page_keywords' => '', 'page_link' => '', 'page_visibility' => 'public', 'page_modified_when' => 0, 'page_modified_by' => 0, 'users' => $this->users, 'search_words' => $this->search_words, 'search_match' => $this->search_type, 'search_url_array' => $this->search_url_array, 'search_entities_array' => $this->search_entities_array, 'default_max_excerpt' => $this->setting[CFG_SEARCH_MAX_EXCERPTS], 'time_limit' => $this->setting[CFG_SEARCH_TIME_LIMIT], 'search_path' => $this->search_path, 'settings' => $this->setting);
     // see docu
     foreach ($this->search_functions['__after'] as $func) {
         $uf_res = call_user_func($func, $search_func_vars);
     }
     // Search page details only, such as description, keywords, etc, but only of unseen pages.
     $max_excerpt_num = 3;
     // we don't want excerpt here ???
     $divider = ".";
     $table = TABLE_PREFIX . "pages";
     $SQL = "SELECT page_id, page_title, menu_title, link, description, \n            keywords, modified_when, modified_by, visibility, viewing_groups, \n            viewing_users FROM {$table} WHERE visibility NOT IN ('none','deleted') \n            AND searching = '1' " . $this->search_path_SQL . " " . $this->search_language_SQL;
     if (false === ($query_pages = $database->query($SQL))) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $database->get_error()));
         return false;
     }
     if ($query_pages->numRows() > 0) {
         while (false !== ($page = $query_pages->fetchRow())) {
             if (isset($pages_listed[$page['page_id']])) {
                 continue;
             }
             $func_vars = array('database' => $database, 'page_id' => $page['page_id'], 'page_title' => $page['page_title'], 'page_menu_title' => $page['menu_title'], 'page_description' => $this->setting[CFG_SEARCH_SHOW_DESCRIPTIONS] ? $page['description'] : '', 'page_keywords' => $page['keywords'], 'page_link' => $page['link'], 'page_visibility' => $page['visibility'], 'page_modified_when' => $page['modified_when'], 'page_modified_by' => $page['modified_by'], 'users' => $this->users, 'search_words' => $this->search_words, 'search_match' => $this->search_type, 'search_url_array' => $this->search_url_array, 'search_entities_array' => $this->search_entities_array, 'default_max_excerpt' => $max_excerpt_num, 'settings' => $this->setting);
             // Only show this page if we are allowed to see it
             if ($admin->page_is_visible($page) == false) {
                 if ($page['visibility'] != 'registered') {
                     continue;
                 } else {
                     // page: registered, user: access denied
                     $func_vars['page_description'] = $MOD_SEARCH['This content is reserved for registered users.'];
                 }
             }
             if ($admin->page_is_active($page) == false) {
                 continue;
             }
             $text = $func_vars['page_title'] . $divider . $func_vars['page_menu_title'] . $divider . ($this->setting[CFG_SEARCH_DESCRIPTIONS] ? $func_vars['page_description'] : '') . $divider . ($this->setting[CFG_SEARCH_DESCRIPTIONS] ? $func_vars['page_keywords'] : '') . $divider;
             $mod_vars = array('page_link' => $func_vars['page_link'], 'page_link_target' => "", 'page_title' => $func_vars['page_title'], 'page_description' => $func_vars['page_description'], 'page_modified_when' => $func_vars['page_modified_when'], 'page_modified_by' => $func_vars['page_modified_by'], 'text' => $text, 'max_excerpt_num' => $func_vars['default_max_excerpt']);
             if (print_excerpt2($mod_vars, $func_vars)) {
                 $pages_listed[$page['page_id']] = true;
             }
         }
     }
     // ok - all done ...
     $src = LEPTON_PATH . '/modules/lib_search/images/content-locked.gif';
     list($width, $height) = getimagesize($src);
     $this->search_result = array('form' => $this->getSearchForm(), 'result' => array('count' => count($_SESSION[SESSION_SEARCH_RESULT_ITEMS]), 'items' => $_SESSION[SESSION_SEARCH_RESULT_ITEMS]), 'images' => array('locked' => array('src' => LEPTON_URL . '/modules/lib_search/images/content-locked.gif', 'width' => $width, 'height' => $height)));
     return true;
 }