Example #1
0
art_parse_function('

/**#@-*/

/**#@+
 * Function to display spotlight
 *
 * {@link spotlight} 
 * {@link config} 
 *
 * @param    array     $options:  
 *                    $options[0] - use specified spotlight only
 *                    $options[1] - show editor note if available
 */
function [VAR_PREFIX]_spotlight_show( $options )
{
    global $xoopsDB;

    $block = array();
    $artConfig = art_load_config();
    art_define_url_delimiter();
    
    $spotlight_handler =& xoops_getmodulehandler("spotlight", $GLOBALS["artdirname"]);
    $sp_data = $spotlight_handler->getContent(false, $options[0]);
    if (empty($sp_data)) return $block;
    foreach ($sp_data as $key => $val) {
        $block[$key] = $val;
    }
    if (isset($block["sp_note"]) && empty($optioins[1])) unset($block["sp_note"]);
    
    $block["url"] = XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.article.php" . URL_DELIMITER . $sp_data["art_id"];
    
    include_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/include/functions.author.php";
    $users = art_getAuthorNameFromId($sp_data["uid"], true, true);
    $block["author"] = $users[$sp_data["uid"]] ;
    if (!empty($sp_data["writer_id"])) {
        $writers = art_getWriterNameFromIds($sp_data["writer_id"]);
        $block["writer"] = $writers[$sp_data["writer_id"]] ;
    }
    
    $block["lang_author"] = art_constant("MB_AUTHOR");
    $block["lang_time"] = art_constant("MB_TIME");
    return $block;
}


function [VAR_PREFIX]_spotlight_edit($options)
{

    $form = art_constant("MB_SPECIFIED_ONLY") . "&nbsp;&nbsp;<input type=\\"radio\\" name=\\"options[0]\\" value=\\"1\\"";
    if ($options[0] == 1) $form .= " checked=\\"checked\\"";
    $form .= " />" . _YES . "<input type=\\"radio\\" name=\\"options[0]\\" value=\\"0\\"";
    if ($options[0] == 0) $form .= " checked=\\"checked\\"";
    $form .= " />" . _NO.  "<br />";

    $form .= art_constant("MB_SHOW_NOTE") . "&nbsp;&nbsp;<input type=\\"radio\\" name=\\"options[1]\\" value=\\"1\\"";
    if ($options[1] == 1) $form .= " checked=\\"checked\\"";
    $form .= " />" . _YES . "<input type=\\"radio\\" name=\\"options[1]\\" value=\\"0\\"";
    if ($options[1] == 0) $form .= " checked=\\"checked\\"";
    $form .= " />"._NO."<br />";

    return $form;
}

/**#@-*/

/**#@+
 * Function to display categories
 *
 * {@link Xcategory} 
 * {@link config} 
 *
 * @param    array     $options (not used) 
 */
function [VAR_PREFIX]_category_show($options)
{
    art_define_url_delimiter();
    
    $block = array();
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $categories = $category_handler->getTree();
    $cats_counts = $category_handler->getArticleCounts(array_keys($categories));
    foreach ($categories as $id => $cat) {
        $block["categories"][] = array(
                                    "cat_id"    => $id,
                                    "cat_title"    => $cat["prefix"].$cat["cat_title"], 
                                    "articles"    => @$cats_counts[$id]);
    }
    $block["dirname"] = $GLOBALS["artdirname"];
    unset($categories, $cats_stats);
    return $block;
}
/**#@-*/

/**#@+
 * Function to display topics
 *
 * {@link Xtopic} 
 * {@link Xcategory} 
 * {@link permission} 
 * {@link config} 
 *
 * @param    array     $options: 
 *                        0 - limit for topic count; 
 *                        1 - allowed categories; 
 */
function [VAR_PREFIX]_topic_show($options)
{
    global $xoopsDB;
    static $access_cats;

    art_define_url_delimiter();
    
    $block = array();
    if (!isset($access_cats)) {
        $permission_handler =& xoops_getmodulehandler("permission", $GLOBALS["artdirname"]);
        $access_cats = $permission_handler->getCategories("access"); // get all accessible categories
    }
    if (!empty($options[1])) {
        $allowed_cats = array_filter(array_slice($options, 1)); // get allowed cats
    } else {
        $allowed_cats = $access_cats;
    }
    $allowed_cats = array_intersect($allowed_cats, $access_cats);
    if ( count($allowed_cats) == 0 ) return $block;

    $query = "SELECT top_id, top_title, top_time, cat_id FROM " . art_DB_prefix("topic");
    $query .= " WHERE cat_id IN (" . implode(",", $allowed_cats) . ") ";
    $query .= " ORDER BY top_time DESC";
    $result = $xoopsDB->query($query, $options[0], 0);
    if (!$result) {
        //xoops_error($xoopsDB->error());
        return $block;
    }
    $tops = array();
    $cids = array();
    $topic_handler =& xoops_getmodulehandler("topic", $GLOBALS["artdirname"]);
    while ($row = $xoopsDB->fetchArray($result)) {
        $topic =& $topic_handler->create(false);
        $topic->assignVars($row);
        $_top = array();
        foreach ($row as $tag => $val) {
            $_top[$tag] = $topic->getVar($tag);
        }
        $_top["time"] = $topic->getTime();
        $tops[] = $_top;
        unset($topic, $_top);
        $cids[$row["cat_id"]] = 1;
    }

    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $criteria = new Criteria("cat_id", "(" . implode(",", array_keys($cids)) . ")", "IN");
    $cats = $category_handler->getList($criteria);

    for ($i = 0; $i < count($tops); $i++) {
        $tops[$i]["category"]=$cats[$tops[$i]["cat_id"]];
    }
    $block["topics"] = $tops;
    unset($cats, $tops);

    $block["dirname"] = $GLOBALS["artdirname"];
    return $block;
}

function [VAR_PREFIX]_topic_edit($options)
{
    $form = art_constant("MB_ITEMS") . "&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[0]\\" value=\\"" . $options[0] . "\\" /><br /><br />";

    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $isAll = empty($options[1]);
    $options_cat = array_slice($options, 1); // get allowed categories
    
    $form .= art_constant("MB_CATEGORYLIST") . "&nbsp;&nbsp;<select name=\\"options[]\\" multiple=\\"multiple\\">";
    $form .= "<option value=\\"0\\" ";
    if ($isAll) $form .= " selected=\\"selected\\"";
    $form .= ">" . _ALL . "</option>";
    
    $categories = $category_handler->getTree(0, "moderate", "----");
    foreach ($categories as $id => $cat) {
        $sel = ($isAll || in_array($id, $options_cat)) ? " selected":"";
        $form .= "<option value=\\"{$id}\\" {$sel}>" . $cat["prefix"] . $cat["cat_title"] . "</option>";
    }
    $form .= "</select><br />";

    return $form;
}
/**#@-*/

/**#@+
 * Function to display authors
 *
 * {@link config} 
 *
 * @param    array     $options: 
 *                        0 - limit for author count; 
 */
function [VAR_PREFIX]_author_show($options)
{
    global $xoopsDB;
    
    $block = array();
    $artConfig = art_load_config();
    art_define_url_delimiter();

    $query = "SELECT COUNT(*) AS count, uid" .
        " FROM " . art_DB_prefix("article") .
        " WHERE art_time_publish>0 AND uid>0" .
        " GROUP BY uid ORDER BY count DESC";
    $result = $xoopsDB->query($query, $options[0], 0);
    if (!$result) {
        //xoops_error($xoopsDB->error());
        return $block;
    }
    $rows = array();
    $author = array();
    while ($row = $xoopsDB->fetchArray($result)) {
        $rows[] = $row;
        $author[$row["uid"]] = 1;
    }
    if (count($rows) < 1) return $block;
    mod_loadFunctions("user", $GLOBALS["artdirname"]);
    $author_name = art_getUnameFromId(array_keys($author));
    foreach ($rows as $row) {
        $block["authors"][] = array( "uid" => $row["uid"], "name" => $author_name[$row["uid"]], "articles" => $row["count"]);
    }
    $block["dirname"] = $GLOBALS["artdirname"];
    return $block;
}

function [VAR_PREFIX]_author_edit($options)
{
    $form = art_constant("MB_ITEMS") . "&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[0]\\" value=\\"" . $options[0] . "\\" /><br /><br />";
    return $form;
}
/**#@-*/

');
Example #2
0
if (DIRECTORY_SEPARATOR != "/") {
    $current_path = str_replace(strpos($current_path, "\\\\", 2) ? "\\\\" : DIRECTORY_SEPARATOR, "/", $current_path);
}
$url_arr = explode("/", strstr($current_path, "/modules/"));
include XOOPS_ROOT_PATH . "/modules/" . $url_arr[2] . "/include/vars.php";
include_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/include/functions.php";
art_parse_function('
function [VAR_PREFIX]_com_update($art_id, $count)
{
    $article_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
    $article_obj =& $article_handler->get($art_id);
    $article_obj->setVar( "art_comments", $count, true );
    return $article_handler->insert($article_obj, true);
}

function [VAR_PREFIX]_com_approve(&$comment)
{
    art_define_url_delimiter();
    if (!empty($GLOBALS["xoopsModuleConfig"]["notification_enabled"])) {
        $article_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
        $article_obj =& $article_handler->get($comment->getVar("com_itemid"));
        $notification_handler =& xoops_gethandler("notification");
        $tags = array();
        $tags["ARTICLE_TITLE"] = $article_obj->getVar("art_title");
        $tags["ARTICLE_URL"] = XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.article.php" . URL_DELIMITER . $article_obj->getVar("art_id") . "#comment" . $comment->getVar("com_id");
        $tags["ARTICLE_ACTION"] = art_constant("MD_NOT_ACTION_COMMENT");
        $notification_handler->triggerEvent("article", $article_obj->getVar("art_id"), "article_monitor", $tags);
        $notification_handler->triggerEvent("global", 0, "article_monitor", $tags);
    }
}
');
art_parse_function('
function [VAR_PREFIX]_notify_iteminfo($category, $item_id)
{
    // The $item is not used !
    
    $item_id = intval($item_id);
    art_define_url_delimiter();

    switch ($category) {
    case "category":
        $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
        $category_obj =& $category_handler->get($item_id);
        if (!is_object($category_obj)) {
            redirect_header(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/index.php", 2, art_constant("MD_NOACCESS"));
            exit();
        }
        $item["name"] = $category_obj->getVar("cat_title");
        $item["url"] = XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.category.php" . URL_DELIMITER . $item_id;
        break;
    case "article":
        $article_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
        $article_obj =& $article_handler->get($item_id);
        if (!is_object($article_obj)) {
            redirect_header(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/index.php", 2, art_constant("MD_NOACCESS"));
            exit();
        }
        $item["name"] = $article_obj->getVar("art_title");
        $item["url"] = XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.article.php" . URL_DELIMITER . $item_id;
        break;
    case "global":
    default:
        $item["name"] = "";
        $item["url"] = "";
        break;
    }
    return $item;
}
');
Example #4
0
art_parse_function('
function xoops_module_install_[DIRNAME](&$module)
{
    [DIRNAME]_updateXoopsConfig();
    
    $data_file = XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/sql/mysql." . $GLOBALS["xoopsConfig"]["language"] . ".sql";
    if (!file_exists($data_file)) {
        $data_file = XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/sql/mysql.english.sql";
    }
    // The mysql data was exported with UTF-8, so restore it
    $GLOBALS["xoopsDB"]->queryF("SET NAMES utf8");
    if (!$GLOBALS["xoopsDB"]->queryFromFile($data_file)) {
        $module->setErrors("Pre-set data were not installed");
        return true;
    }
    
    /* Set tags */
    mod_loadFunctions("recon", $GLOBALS["artdirname"]);
    art_updateTag($module->getVar("mid"));
    
    require_once(XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/class/permission.php");
    
    /* Set corresponding permissions for categories and articles */
    $module_id = $module->getVar("mid") ;
    $gperm_handler =& xoops_gethandler("groupperm");
    $groups_view = array(XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
    $groups_post = array(XOOPS_GROUP_USERS);
    $groups_admin = array(XOOPS_GROUP_ADMIN);
    
    $view_items = array("access", "view");
    $post_items = array("submit", "rate");
    $admin_items = array("publish", "moderate");
    
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $cat_ids = $category_handler->getIds();
    
    foreach ($groups_view as $group_id) {
        $gperm_handler->addRight("global", $GLOBALS["perms_global"]["search"]["id"], $group_id, $module_id);
        foreach ($view_items as $item) {
            foreach ($cat_ids as $id) {
                $gperm_handler->addRight($item, $id, $group_id, $module_id);
            }
        }
    }
    foreach ($groups_post as $group_id) {
        $gperm_handler->addRight("global", $GLOBALS["perms_global"]["html"]["id"], $group_id, $module_id);
        foreach ($post_items as $item) {
            foreach ($cat_ids as $id) {
                $gperm_handler->addRight($item, $id, $group_id, $module_id);
            }
        }
    }
    foreach ($groups_admin as $group_id) {
        $gperm_handler->addRight("global", $GLOBALS["perms_global"]["upload"]["id"], $group_id, $module_id);
        foreach ($admin_items as $item) {
            foreach ($cat_ids as $id) {
                $gperm_handler->addRight($item, $id, $group_id, $module_id);
            }
        }
    }
    return true;
}

function xoops_module_pre_install_[DIRNAME](&$module)
{
    $mod_tables = $module->getInfo("tables");
    foreach ($mod_tables as $table) {
        $GLOBALS["xoopsDB"]->queryF("DROP TABLE IF EXISTS " . $GLOBALS["xoopsDB"]->prefix($table) . ";");
    }
    return [DIRNAME]_setModuleConfig($module);
}

function xoops_module_pre_update_[DIRNAME](&$module)
{
    return [DIRNAME]_setModuleConfig($module);
}

function xoops_module_update_[DIRNAME](&$module, $prev_version = null)
{
    //if ($prev_version < 100) {
        [DIRNAME]_updateXoopsConfig();
    //}
    
    load_functions("config");
    mod_clearConfg($module->getVar("dirname", "n"));
    
    if ($prev_version < 96) {
        $GLOBALS["xoopsDB"]->queryFromFile(XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/sql/mysql.096.sql");
    }
    if ($prev_version < 97) {
        include_once dirname(__FILE__) . "/module.v097.php";
        xoops_module_update_art_v097($module);
    }
    if ($prev_version < 100) {
        $GLOBALS["xoopsDB"]->queryFromFile(XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/sql/mysql.100.sql");
    }
    
    mod_loadFunctions("recon", $GLOBALS["artdirname"]);
    art_synchronization();
    
    // Update permissions
    $permission_handler =& xoops_getmodulehandler("permission", $GLOBALS["artdirname"]);
    $permission_handler->createPermData();
    
    // Clear caches
    load_functions("cache");
    $dirname = $GLOBALS["artdirname"];
    mod_clearSmartyCache("/(^{$dirname}\\^.*\\.html$|blk_.*{$dirname}[^\\.]*\\.html$)/");
    
    // Update templates
    mod_loadFunctions("render", $GLOBALS["artdirname"]);
    art_template_lookup();
    art_template_lookup(true);
        
    return true;
}

function [DIRNAME]_updateXoopsConfig()
{
    $GLOBALS["xoopsDB"]->queryF("ALTER TABLE " . $GLOBALS["xoopsDB"]->prefix("config") . " CHANGE `conf_name` `conf_name` varchar(64) NOT NULL default " . $GLOBALS["xoopsDB"]->quoteString(""));
    $GLOBALS["xoopsDB"]->queryF("ALTER TABLE " . $GLOBALS["xoopsDB"]->prefix("config") . " CHANGE `conf_title` `conf_title` varchar(64) NOT NULL default " . $GLOBALS["xoopsDB"]->quoteString(""));
    $GLOBALS["xoopsDB"]->queryF("ALTER TABLE " . $GLOBALS["xoopsDB"]->prefix("config") . " CHANGE `conf_desc` `conf_desc` varchar(64) NOT NULL default " . $GLOBALS["xoopsDB"]->quoteString(""));
    
    $GLOBALS["xoopsDB"]->queryF("ALTER TABLE " . $GLOBALS["xoopsDB"]->prefix("configcategory") . " CHANGE `confcat_name` `confcat_name` varchar(64) NOT NULL default " . $GLOBALS["xoopsDB"]->quoteString(""));
    
    $GLOBALS["xoopsDB"]->queryF("ALTER TABLE " . $GLOBALS["xoopsDB"]->prefix("xoopsnotifications") . " CHANGE `not_category` `not_category` varchar(64) NOT NULL default " . $GLOBALS["xoopsDB"]->quoteString(""));
    $GLOBALS["xoopsDB"]->queryF("ALTER TABLE " . $GLOBALS["xoopsDB"]->prefix("xoopsnotifications") . " CHANGE `not_event` `not_event` varchar(64) NOT NULL default " . $GLOBALS["xoopsDB"]->quoteString(""));
    
    return true;
}

function [DIRNAME]_setModuleConfig(&$module)
{
    return true;
}
');
Example #5
0
art_parse_function('

/**#@+
 * Function to display news item: spotlight + recent news
 *
 * {@link spotlight} 
 * {@link config} 
 *
 * @param    array     $options:  
 *                        0 - display mode: 0 - compact title list; 1 sorted by categories 
 *                        1 - limit for article count; 
 *                        2 - title length; 
 *                        3 - time format; 
 *                        4 - allowed categories; 
 */
function [VAR_PREFIX]_block_news_show( $options )
{
    global $xoopsDB;
    static $access_cats;
    $block = array();
    
    if (!isset($access_cats)) {
        $permission_handler =& xoops_getmodulehandler("permission", $GLOBALS["artdirname"]);
        $access_cats = $permission_handler->getCategories("access");
    }
    if (!empty($options[4])) {
        $allowed_cats = array_filter(array_slice($options, 4));
    } else {
        $allowed_cats = $access_cats;
    }
    $allowed_cats = array_intersect($allowed_cats, $access_cats);
    
    if ( count($allowed_cats) == 0 ) {
        return $block;
    }
    
    mod_loadFunctions("url", $GLOBALS["artdirname"]);
    
    $spotlight_handler =& xoops_getmodulehandler("spotlight", $GLOBALS["artdirname"]);
    $sp_data = $spotlight_handler->getContent(false);
    foreach ($sp_data as $key => $val) {
        $block["spotlight"][$key] = $val;
    }
    $block["spotlight"]["url"] = art_buildUrl(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.article.php", array("article" => $block["spotlight"]["art_id"]));
    
    mod_loadFunctions("author", $GLOBALS["artdirname"]);
    $users = art_getAuthorNameFromId($sp_data["uid"], true, true);
    $block["spotlight"]["author"] = $users[$sp_data["uid"]] ;
    if (!empty($sp_data["writer_id"])) {
        $writers = art_getWriterNameFromIds($sp_data["writer_id"]);
        $block["spotlight"]["writer"] = $writers[$sp_data["writer_id"]] ;
    }
    
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    
    if (empty($options[0])):
    
    $sql =     "    SELECT art_id, art_title, art_time_publish, cat_id, ( art_comments + art_trackbacks ) AS comments " .
            "    FROM " . art_DB_prefix("article") .
            "    WHERE cat_id IN (" . implode(",", $allowed_cats) . ") " .
            "        AND art_time_publish >0 " .
            "    ORDER BY art_time_publish DESC";
    if (!$result = $xoopsDB->query($sql, $options[1], 0)) {
        //xoops_error($xoopsDB->error());
        return $block;
    }
    
    mod_loadFunctions("time", $GLOBALS["artdirname"]);
    $articles = array();
    $cids = array();
    while ($row = $xoopsDB->fetchArray($result)) {
        $_art = array();
        $_art["title_full"]    = htmlspecialchars($row["art_title"]);
        $_art["title"]        = $row["art_title"];
        $_art["time"]        = art_formatTimestamp($row["art_time_publish"], $options[3]);
        $_art["comments"]    = $row["comments"];
        $_art["category"]    = $row["cat_id"];
        $_art["url"]         = art_buildUrl(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.article.php", array("article" => $row["art_id"]));
        
        $articles[$row["art_id"]] = $_art;
        $cids[$row["cat_id"]] = 1;
    }
    
    $criteria = new CriteriaCompo( new Criteria("cat_id", "(" . implode(",", array_keys($cids)) . ")", "IN") );
    $criteria_top = new CriteriaCompo( new Criteria("cat_id", "(" . implode(",", $allowed_cats) . ")", "IN") ); 
    $criteria_top->add( new Criteria("cat_pid", 0) );
    $criteria->add( $criteria_top, "OR" );
    $criteria->setSort("cat_order");
    $categories_obj = $category_handler->getAll($criteria, array("cat_title", "cat_pid"));

    foreach (array_keys($articles) as $id) {
        $articles[$id]["title"] = "[" . $categories_obj[$articles[$id]["category"]]->getVar("cat_title", "n") . "] " . $articles[$id]["title"];
        if (!empty($options[2])) {
            $articles[$id]["title"] = xoops_substr($articles[$id]["title"], 0, $options[2]);
        }
        $articles[$id]["title"] = htmlspecialchars($articles[$id]["title"]);
    }
    
    $categories = array();
    foreach (array_keys($categories_obj) as $cid) {
        if($categories_obj[$cid]->getVar("cat_pid")) continue;
        $categories[$cid]["title"]    = $categories_obj[$cid]->getVar("cat_title");
        $categories[$cid]["url"]    = art_buildUrl(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.category.php", array("category" => $cid));
    }
    $block["articles"] = $articles;
    $block["categories"] = $categories;
    
    else:
    
    $articles_id = array();
    $criteria = new Criteria("cat_id", "(" . implode(",", $allowed_cats) . ")", "IN");
    $criteria->setSort("cat_order");
    $categories_obj = $category_handler->getAll($criteria, array("cat_title", "cat_lastarticles"));
    
    foreach (array_keys($categories_obj) as $id) {
        if (!$articles_category = $category_handler->getLastArticleIds($categories_obj[$id], $options[1])) continue;
        $articles_id = array_merge($articles_id, $articles_category);
    }
    
    if ( count($articles_id) ==0 ) {
        return $block;
    }
    
    $sql =     "    SELECT art_id, art_title, art_time_publish, ( art_comments + art_trackbacks ) AS comments " .
            "    FROM " . art_DB_prefix("article") .
            "    WHERE art_id IN (" . implode(",", array_unique($articles_id)) . ") ";
    if (!$result = $xoopsDB->query($sql)) {
        //xoops_error($xoopsDB->error());
        return $block;
    }
    
    $articles = array();
    while ($row = $xoopsDB->fetchArray($result)) {
        $_art = array();
        $_art["title_full"]    = htmlspecialchars($row["art_title"]);
        if (!empty($options[2])) {
            $row["art_title"] = xoops_substr($row["art_title"], 0, $options[2]);
        }
        $_art["title"]        = htmlspecialchars($row["art_title"]);
        $_art["time"]        = art_formatTimestamp($row["art_time_publish"], $options[3]);
        $_art["comments"]    = $row["comments"];
        $_art["url"]         = art_buildUrl(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.article.php", array("article" => $row["art_id"]));
        $articles[$row["art_id"]] = $_art;
    }
    
    $categories = array();
    foreach (array_keys($categories_obj) as $id) {
        $category =& $categories_obj[$id];
        $cat = array(
            "id"                 => $id,
            "title"             => $category->getVar("cat_title"),
            "image"             => $category->getImage(),
            "url"                 => art_buildUrl(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.category.php", array("category" => $id)),
            "articles"            => array(),
        );
        $articles_category_id = $category_handler->getLastArticleIds($category, $options[1]);
        foreach ($articles_category_id as $art_id) {
            if (!isset($articles[$art_id])) continue;
            $cat["articles"][] =& $articles[$art_id];
        }
        $categories[$id] = $cat;
        unset($cat);
    }
    $block["categories"] =& $categories;
    
    endif;
        
    $block["lang"]         = array(
                                "categories"    => art_constant("MB_CATEGORIES"), 
                                "articles"        => art_constant("MB_ARTICLES"),
                                "comments"        => art_constant("MB_COMMENTS"),
                                "views"            => art_constant("MB_VIEWS"),
                                );
    $block["mode"]         = $options[0];
    $block["dirname"]    = $GLOBALS["artdirname"];
    return $block;
}


function [VAR_PREFIX]_block_news_edit($options)
{
    $form = art_constant("MB_DISPLAY_MODE")."&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[0]\\" value=\\"" . $options[0] . "\\" /><br />";
    $form .= art_constant("MB_ITEMS")."&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[1]\\" value=\\"" . $options[1] . "\\" /><br />";
    $form .= art_constant("MB_TITLE_LENGTH")."&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[2]\\" value=\\"" . $options[2] . "\\" /><br />";
    $form .= art_constant("MB_TIMEFORMAT")."&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[3]\\" value=\\"" . $options[3] . "\\" />";
    
    xoops_load("xoopslocal");
    $form .= "<p style=\\"font-size: small; padding-left: 10px;\\">" . XoopsLocal::getTimeFormatDesc() . "</p>";
    
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $isAll = empty($options[4]);
    $options_cat = array_slice($options, 4); // get allowed categories
    
    $form .= art_constant("MB_CATEGORYLIST") . "<br /><select name=\\"options[]\\" multiple=\\"multiple\\">";
    $form .= "<option value=\\"0\\" ";
    if ($isAll) $form .= " selected=\\"selected\\"";
    $form .= ">" . _ALL . "</option>";
    
    $categories = $category_handler->getTree(0, "moderate", "----");
    foreach ($categories as $id => $cat) {
        $sel = ( $isAll || in_array($id, $options_cat) ) ? " selected" : "";
        $form .= "<option value=\\"{$id}\\" {$sel}>" . $cat["prefix"] . $cat["cat_title"] . "</option>";
    }
    $form .= "</select><br />";

    return $form;
}
');
Example #6
0
art_parse_function('

function b_sitemap_[DIRNAME]()
{
    art_define_url_delimiter();
    
    $sitemap = array();
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    
    if (!empty($GLOBALS["xoopsModuleConfig"]["show_subcategoris"])):
    $category_depth = 3;
    $data = $category_handler->getArrayTree(0, "access", null, $category_depth);
    if (empty($data["child"])) {
        return $sitemap;
    }
    
    $pi = -1;
    foreach (array_keys($data["child"]) as $key) {
        $_cat = array();
        $_cat["id"] = $key;
        $_cat["title"] = $data["child"][$key]["cat_title"];
        $_cat["url"] = "view.category.php" . URL_DELIMITER . $key;
        $sitemap["parent"][++$pi] = $_cat;
        unset($_cat);
        $ci = -1;
        if (empty($data["child"][$key]["child"])) continue;
        foreach (array_keys($data["child"][$key]["child"]) as $skey) {
            $_cat = array();
            $_cat["id"] = $skey;
            $_cat["title"] = $data["child"][$key]["child"][$skey]["cat_title"];
            $_cat["url"] = "view.category.php" . URL_DELIMITER . $skey;
            $_cat["image"] = 2;
            $sitemap["parent"][$pi]["child"][++$ci] = $_cat;
            unset($_cat);
            if (empty($data["child"][$key]["child"][$skey]["child"])) continue;
            foreach (array_keys($data["child"][$key]["child"][$skey]["child"]) as $ckey) {
                $subcats = art_getSubCategory($ckey);
                $_cat = array();
                $_cat["id"] = $ckey;
                $_cat["title"] = $data["child"][$key]["child"][$skey]["child"][$ckey]["cat_title"] . (empty($subcats) ? "" : " (" . count($subcats) . ")");
                $_cat["url"] = "view.category.php" . URL_DELIMITER . $ckey;
                $_cat["image"] = 3;
                $sitemap["parent"][$pi]["child"][++$ci] = $_cat;
                unset($_cat);
            }
        }
    }
    unset($data);
    else:
    $categories =& $category_handler->getTree();
    foreach ($categories as $id => $cat) {
        $sitemap["parent"][] = array("id" => $id, "title" => $cat["cat_title"], "url"=> "view.category.php" . URL_DELIMITER . $id);
    }
    unset($categories);
    endif;
    return $sitemap;
}
');
Example #7
0
art_parse_function('

/**#@+
 * Function to display tag cloud
 */
function [VAR_PREFIX]_tag_block_cloud_show($options) 
{
    if (!@include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php") {
        return null; 
    } 
    $block_content = tag_block_cloud_show($options, $GLOBALS["artdirname"]);
    return $block_content;
}

function [VAR_PREFIX]_tag_block_cloud_edit($options) 
{
    if (!@include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php") {
        return null; 
    }
    $form = tag_block_cloud_edit($options);
    return $form;
}

/**#@+
 * Function to display top tag list
 */
function [VAR_PREFIX]_tag_block_top_show($options) 
{
    if (!@include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php") {
        return null; 
    }
    $block_content = tag_block_top_show($options, $GLOBALS["artdirname"]);
    return $block_content;
}

function [VAR_PREFIX]_tag_block_top_edit($options) {
    if (!@include_once XOOPS_ROOT_PATH . "/modules/tag/blocks/block.php") {
        return null; 
    } 
    $form = tag_block_top_edit($options);
    return $form;
}
');
Example #8
0
    art_parse_function('
function [DIRNAME]_tag_iteminfo(&$items)
{
    if(empty($items) || !is_array($items)){
        return false;
    }
    
    $items_id = array();
    foreach (array_keys($items) as $cat_id) {
        // Some handling here to build the link upon catid
            // catid is not used in article, so just skip it
        foreach (array_keys($items[$cat_id]) as $item_id) {
            // In article, the item_id is "art_id"
            $items_id[] = intval($item_id);
        }
    }
    $item_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
    $items_obj = $item_handler->getObjects(new Criteria("art_id", "(" . implode(", ", $items_id) . ")", "IN"), true);
    art_define_url_delimiter();
    
    foreach (array_keys($items) as $cat_id) {
        foreach (array_keys($items[$cat_id]) as $item_id) {
            if (!$item_obj =& $items_obj[$item_id]) {
                continue;
            }
            $items[$cat_id][$item_id] = array(
                "title"        => $item_obj->getVar("art_title"),
                "uid"        => $item_obj->getVar("uid"),
                "link"        => "view.article.php" . URL_DELIMITER . "article={$item_id}",
                "time"        => $item_obj->getVar("art_time_publish"),
                "tags"        => tag_parse_tag($item_obj->getVar("art_keywords", "n")),
                "content"    => "",
                );
        }
    }
    unset($items_obj);    
}

/**
 * Remove orphan tag-item links
 *
 * @return    boolean
 * 
 */
function [DIRNAME]_tag_synchronization($mid)
{
    $item_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
    $link_handler =& xoops_getmodulehandler("link", "tag");
        
    /* clear tag-item links */
    if (version_compare( mysql_get_server_info(), "4.1.0", "ge" )):
    $sql =  "    DELETE FROM {$link_handler->table}" .
            "    WHERE " .
            "        tag_modid = {$mid}" .
            "        AND " .
            "        ( tag_itemid NOT IN " .
            "            ( SELECT DISTINCT {$item_handler->keyName} " .
            "                FROM {$item_handler->table} " .
            "                WHERE {$item_handler->table}.art_time_publish > 0" .
            "            ) " .
            "        )";
    else:
    $sql =     "    DELETE {$link_handler->table} FROM {$link_handler->table}" .
            "    LEFT JOIN {$item_handler->table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler->keyName} " .
            "    WHERE " .
            "        tag_modid = {$mid}" .
            "        AND " .
            "        ( aa.{$item_handler->keyName} IS NULL" .
            "            OR aa.art_time_publish < 1" .
            "        )";
    endif;
    if (!$result = $link_handler->db->queryF($sql)) {
        //xoops_error($link_handler->db->error());
      }
}
');
Example #9
0
art_parse_function('
/**#@+
 * Function to display articles
 *
 * {@link article} 
 * {@link xcategory} 
 * {@link permission} 
 * {@link config} 
 *
 * @param    array     $options: 
 *                        0 - criteria for fetching articles; 
 *                        1 - limit for article count; 
 *                        2 - bool flag for displaying summary: 0 - none; 1 - summary; 2 - summary and image
 *                        3 - title length; 
 *                        4 - time format; 
 *                        5 - allowed categories; 
 */
function [VAR_PREFIX]_article_show($options)
{
    global $xoopsDB;
    static $access_cats;

    $artConfig = art_load_config();
    art_define_url_delimiter();

    $block = array();
    $select = "art_id";
    $disp_tag = "";
    $from = "";
    $where = "";
    $order = "art_time_publish DESC";
    switch ($options[0]) {
        case "views":
            $select .= ", art_counter";
            $order = "art_counter DESC";
            $disp_tag = "art_counter";
            break;
        case "rates":
            $select .= ", art_rates";
            $order = "art_rates DESC";
            $disp_tag = "art_rates";
            break;
        case "rating":
            $select .= ", art_rating/art_rates AS ave_rating";
            $order = "ave_rating DESC";
            $disp_tag = "ave_rating";
            break;
        case "random":
            $order = "RAND()";
            $mysqlOldClient = version_compare( mysql_get_server_info(), "4.1.0", "lt" );
            /* for MySQL 4.1+ */
            if (!$mysqlOldClient) {
                $from = " LEFT JOIN (SELECT art_id AS aid FROM " . art_DB_prefix("article") . " LIMIT 1000 ORDER BY art_id DESC) AS random ON art_id = random.aid";
            }
            break;
        case "time":
        default:
            $order = "art_time_publish DESC";
            $disp_tag = "art_counter";
            break;
    }
    $select .= ", cat_id, art_title, uid, writer_id, art_time_publish";
    if (!empty($options[2])) {
        $select .= ", art_summary, art_pages";
        if ($options[2] == 2) $select .= ", art_image";
    }
    if (!isset($access_cats)) {
        $permission_handler =& xoops_getmodulehandler("permission", $GLOBALS["artdirname"]);
        $access_cats = $permission_handler->getCategories("access");
    }
    if (!empty($options[5])) {
        $allowed_cats = array_filter(array_slice($options, 5));
    } else {
        $allowed_cats = $access_cats;
    }
    $allowed_cats = array_intersect($allowed_cats, $access_cats);
    
    if (count($allowed_cats) ==0 ) {
        return $block;
    }

    $query = "SELECT {$select} FROM " . art_DB_prefix("article") . $from;
    $query .= " WHERE cat_id IN (" . implode(",", $allowed_cats) . ") AND art_time_publish > 0 " . $where;
    $query .= " ORDER BY " . $order;
    if (!$result = $xoopsDB->query($query, $options[1], 0)) {
        //xoops_error($xoopsDB->error());
        return $block;
    }
    
    $author_array = array();
    $writer_array = array();
    $users = array();
    $writers = array();
    $rows = array();
    while ($row = $xoopsDB->fetchArray($result)) {
        $rows[] = $row;
        $author_array[$row["uid"]] = 1;
        $writer_array[$row["writer_id"]] = 1;
    }
    if (count($rows) < 1) return $block;
    
    if (!empty($author_array)) {
        include_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/include/functions.author.php";
        $users = art_getAuthorNameFromId(array_keys($author_array), true, true);
    }
    
    if (!empty($writer_array)) {
        include_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/include/functions.author.php";
        $writers = art_getWriterNameFromIds(array_keys($writer_array));
    }

    $arts = array();
    $uids = array();
    $cids = array();
    $article_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
    foreach ($rows as $row) {
        if (!empty($row["ave_rating"])) {
            $row["ave_rating"] = number_format($row["ave_rating"], 1);
        }
        $article =& $article_handler->create(false);
        $article->assignVars($row);
        $_art = array();
        foreach ($row as $tag => $val) {
            $_art[$tag] = @$article->getVar($tag);
        }
        $_art["author"] = $users[$row["uid"]];
        $_art["writer"] = @$writers[$row["writer_id"]];
        $_art["time"] = $article->getTime($options[4]);
        $_art["summary"] = $article->getSummary($options[2]);
        $_art["image"] = $article->getImage();
        if (!empty($disp_tag)) {
            $_art["disp"] = @$article->getVar($disp_tag);
            if (!empty($row[$disp_tag]) && empty($_art["disp"])) {
                $_art["disp"] = $row[$disp_tag];
            }
        }
        if (!empty($options[3])) {
            $_art["art_title"] = xoops_substr($_art["art_title"], 0, $options[3]);
        }
        $arts[] = $_art;
        unset($article, $_art);
        $cids[$row["cat_id"]] = 1;
    }
    
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $criteria = new Criteria("cat_id", "(" . implode(",",array_keys($cids)) . ")", "IN");
    $cats = $category_handler->getList($criteria);

    for ($i = 0; $i < count($arts); $i++) {
        $arts[$i]["category"]=$cats[$arts[$i]["cat_id"]];
    }
    $block["articles"] = $arts;
    unset($users, $cats, $arts);

    $block["dirname"] = $GLOBALS["artdirname"];
    return $block;
}

function [VAR_PREFIX]_article_edit($options)
{
    $form = art_constant("MB_TYPE") . "&nbsp;&nbsp;<select name=\\"options[0]\\">";
    $form .= "<option value=\\"time\\"";
    if ($options[0] == "time") $form .= " selected=\\"selected\\" ";
    $form .= ">" . art_constant("MB_TYPE_TIME") . "</option>\\n";
    $form .= "<option value=\\"views\\"";
    if ($options[0] == "views") $form .= " selected=\\"selected\\" ";
    $form .= ">" . art_constant("MB_TYPE_VIEWS") . "</option>\\n";
    $form .= "<option value=\\"rates\\"";
    if ($options[0] == "rates") $form .= " selected=\\"selected\\" ";
    $form .= ">" . art_constant("MB_TYPE_RATES") . "</option>\\n";
    $form .= "<option value=\\"rating\\"";
    if ($options[0] == "rating") $form .= " selected=\\"selected\\" ";
    $form .= ">" . art_constant("MB_TYPE_RATING") . "</option>\\n";
    $form .= "<option value=\\"random\\"";
    if ($options[0] == "random") $form .= " selected=\\"selected\\" ";
    $form .= ">" . art_constant("MB_TYPE_RANDOM") . "</option>\\n";
    $form .= "</select><br /><br />";

    $form .= art_constant("MB_ITEMS") . "&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[1]\\" value=\\"" . $options[1] . "\\" /><br /><br />";

    $form .= art_constant("MB_SHOWSUMMARY") . "&nbsp;&nbsp;<input type=\\"radio\\" name=\\"options[2]\\" value=\\"0\\"";
    if ($options[2] == 0) $form .= " checked=\\"checked\\"";
    $form .= " />" . _NO . "&nbsp;&nbsp;<input type=\\"radio\\" name=\\"options[2]\\" value=\\"1\\"";
    if ($options[2] == 1) $form .= " checked=\\"checked\\"";
    $form .= " />" . _YES . "&nbsp;&nbsp;<input type=\\"radio\\" name=\\"options[2]\\" value=\\"2\\"";
    if ($options[2] == 2) $form .= " checked=\\"checked\\"";
    $form .= " />" . art_constant("MB_SUMMARY_IMAGE") . "<br /><br />";

    $form .= art_constant("MB_TITLE_LENGTH") . "&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[3]\\" value=\\"" . $options[3] . "\\" /><br /><br />";
    
    $form .= art_constant("MB_TIMEFORMAT") . "&nbsp;&nbsp;<input type=\\"text\\" name=\\"options[4]\\" value=\\"" . $options[4] . "\\" /><br />";
    
    xoops_load("xoopslocal");
    $form .= "<p style=\\"font-size: small; padding-left: 10px;\\">" . XoopsLocal::getTimeFormatDesc() . "</p>";
    
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $isAll = empty($options[5]) ? true : false;
    $options_cat = array_slice($options, 5); // get allowed categories
    
    $form ."<br />";
    $form .= art_constant("MB_CATEGORYLIST") . "<br /><select name=\\"options[]\\" multiple=\\"multiple\\">";
    $form .= "<option value=\\"0\\" ";
    if ($isAll) $form .= " selected=\\"selected\\"";
    $form .= ">" . _ALL . "</option>";
    
    $categories = $category_handler->getTree(0, "moderate", "----");
    foreach ($categories as $id => $cat) {
        $sel = ($isAll || in_array($id, $options_cat)) ? " selected" : "";
        $form .= "<option value=\\"{$id}\\" {$sel}>" . $cat["prefix"] . $cat["cat_title"] . "</option>";
    }
    $form .= "</select><br />";

    return $form;
}
/**#@-*/
');
Example #10
0
art_parse_function('
function &[VAR_PREFIX]_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "all", $extra = "")
{
    global $xoopsDB, $xoopsConfig, $myts, $xoopsUser;
    $ret = array();

    art_define_url_delimiter();
    
    $uid = (is_object($xoopsUser) && $xoopsUser->isactive()) ? $xoopsUser->getVar("uid") : 0;
    $permission_handler =& xoops_getmodulehandler("permission", $GLOBALS["artdirname"]);
    $allowed_ids = $permission_handler->getCategories();
    if (count($categories) > 0) {
        $allowed_ids = array_intersect($allowed_ids, $categories);
    }    
    if (empty($allowed_ids)) {
        return $ret;
    }
    
    $searchin = empty($searchin) ? array("all") : (is_array($searchin) ? $searchin : array($searchin));
    if (in_array("all", $searchin) || count($searchin) == 0) {
        $searchin = array("title", "author", "keywords", "summary", "text", "subtitle");
    }
    
    $isFulltext = ($searchin == array("text"));
    
    /* Fulltext search */
    if ($isFulltext):
     $sql = "SELECT" .
            " DISTINCT t.text_id, t.text_body, a.art_id, a.art_title, a.uid, a.art_time_publish, a.art_pages";
    $sql .= " FROM" .
            " " . art_DB_prefix("text") . " AS t" .
            " LEFT JOIN " . art_DB_prefix("article") . " AS a ON a.art_id=t.art_id" .
            " LEFT JOIN " . art_DB_prefix("artcat") . " AS ac ON a.art_id=ac.art_id";
    /* regular search */
    else:
     $sql = "SELECT" .
            " DISTINCT a.art_id, a.art_title, a.uid, a.art_time_publish";
    $sql .= " FROM" .
            " " . art_DB_prefix("article") . " AS a" .
            " LEFT JOIN " . art_DB_prefix("artcat") . " AS ac ON a.art_id=ac.art_id";
    if (in_array("text", $searchin) || in_array("subtitle", $searchin)):
    $sql .= " LEFT JOIN " . art_DB_prefix("text") . " AS t ON t.art_id =a.art_id";
    endif;
    endif;
    
    $sql .= " WHERE" .
            " a.art_time_publish > 0" .
            " AND ac.cat_id IN (" . implode(",", $allowed_ids) . ")" .
            " AND ac.ac_publish > 0";

    if (is_array($userid) && count($userid) > 0) {
        $userid = array_map("intval", $userid);
        $sql .= " AND a.uid IN (" . implode(",", $userid) . ") ";
    }elseif ( is_numeric($userid) && $userid > 0 ) {
        $sql .= " AND a.uid=" . $userid . " ";
    }

    $count = count($queryarray);
    if ( is_array($queryarray) && $count > 0) {
        foreach($queryarray as $query){
            $query_array["title"][] = "a.art_title LIKE " . $xoopsDB->quoteString("%" . $query."%");
            //$query_array["author"][] = "a.art_author LIKE " . $xoopsDB->quoteString("%" . $query."%");
            $query_array["keywords"][] = "a.art_keywords LIKE " . $xoopsDB->quoteString("%" . $query . "%");
            $query_array["summary"][] = "a.art_summary LIKE " . $xoopsDB->quoteString("%" . $query . "%");
            $query_array["text"][] = "t.text_body LIKE " . $xoopsDB->quoteString("%" . $query . "%");
            $query_array["subtitle"][] = "t.text_title LIKE " . $xoopsDB->quoteString("%" . $query . "%");
        }
        foreach ($query_array as $term => $terms) {
            $querys[$term] = "(" . implode(" $andor ", $terms) . ")";
        }
        foreach ($searchin as $term) {
            if (empty($query_array[$term])) continue;
            $query_term[] = $querys[$term];
        }
        $sql .= " AND (" . implode(" OR ", $query_term) . ") ";
    }

    if (empty($sortby)) {
        $sortby = "a.art_id DESC";
    }
    $sql .= $extra . " ORDER BY " . $sortby;
    
    if (!$result = $xoopsDB->query($sql, $limit, $offset)) {
        //xoops_error($xoopsDB->error());
        return $ret;
    }
    $_ret = array();
    $users = array();
    $arts = array();
    mod_loadFunctions("time", $GLOBALS["artdirname"]);
    while ($myrow = $xoopsDB->fetchArray($result)) {
        if (empty($isFulltext)):
        $ret[] = array(
            "link"        => "view.article.php" . URL_DELIMITER . $myrow["art_id"],
            "title"        => $myrow["art_title"],
            "time"        => $myrow["art_time_publish"],
            "uid"        => $myrow["uid"],
            "art_title"    => $myts->htmlSpecialChars($myrow["art_title"]),
            "art_time"    => art_formatTimestamp($myrow["art_time_publish"])
        );
        else:
        $_ret[] = $myrow;
        endif;
        $users[$myrow["uid"]] = 1;
    }
    
    if (!empty($isFulltext)):
    $article_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
    xoops_load("xoopslocal");
    foreach ($_ret as $myrow) {
        $article_obj =& $article_handler->create(false);
        $article_obj->assignVars($myrow);
        $page = array_search($myrow["text_id"], $article_obj->getPages());
        $text = $myts->htmlSpecialChars($myrow["text_body"]);
        
        /* 
         * "Fulltext search"/highlight needs better formulize
         * 
         */
        $sanitized_text = "";
        $text_i = strtolower($text);
        foreach ($queryarray as $query) {
            $pos        = xoops_local("strpos", $text_i, strtolower($query));
            $start        = max(($pos - 100), 0);
            $length        = xoops_local("strlen", $query) + 200;
            $context    = preg_replace("/(" . preg_quote($query) . ")/si", "<span class=\\"article-highlight\\">$1</span>", xoops_substr($text, $start, $length, " [...]"));
            $sanitized_text .= "<p>[...] " . $context . "</p>";
        }
        
        $ret[] = array(
            "link"        => "view.article.php" . URL_DELIMITER . $myrow["art_id"] . "/p" . intval($page),
            "title"        => $myrow["art_title"],
            "time"        => $myrow["art_time_publish"],
            "uid"        => $myrow["uid"],
            "art_title"    => $article_obj->getVar("art_title"),
            "art_time"    => $article_obj->getTime(),
            "text"        => $sanitized_text
        );
        unset($article_obj, $page, $sanitized_text, $matches);
    }
    endif;    
    
    mod_loadFunctions("user", $GLOBALS["artdirname"]);
    $users = art_getUnameFromId(array_keys($users), false, true);
    foreach ( array_keys($ret) as $i) {
        if ($ret[$i]["uid"] >0) {
            $ret[$i]["author"] = @$users[$ret[$i]["uid"]];
        } else {
            $ret[$i]["author"] = $xoopsConfig["anonymous"];
        }
    }
    unset($users);

    return $ret;
}
');