コード例 #1
0
function getURLbyID($ArticleID, $Nameonly = false)
{
    global $REX;
    if (!$ArticleID) {
        return '';
    }
    if ($GLOBALS[REX][MOD_REWRITE]) {
        @(include "redaxo/include/generated/articles/{$ArticleID}.article");
        $name = $REX[ART][$ArticleID][name];
        $path = $REX[ART][$ArticleID][path];
        $tmp = explode("-", $path);
        foreach ($tmp as $var) {
            if ($var != "") {
                @(include "redaxo/include/generated/categories/{$var}.category");
                if ($REX[CAT][$var][name] != $name) {
                    $linkpath .= $REX[CAT][$var][name] . "/";
                }
            }
        }
        $name = $linkpath . $name;
        if ($Nameonly) {
            return str_replace('/', $Nameonly, $name);
        }
        $url = $ArticleID . "-" . ModRewriteName($name);
    } else {
        $url = 'index.php?article_id=' . $ArticleID;
    }
    return $url;
}
コード例 #2
0
function getURLbyID($ArticleID)
{
    if (!$ArticleID) {
        return '';
    }
    global $REX;
    if ($REX[MOD_REWRITE]) {
        $db = new sql();
        $sql = "SELECT name FROM rex_article WHERE id='{$ArticleID}'";
        $res = $db->get_array($sql);
        $url = $ArticleID . "-" . ModRewriteName($res[0][name]);
    } else {
        $url = 'index.php?article_id=' . $ArticleID;
    }
    return $url;
}
コード例 #3
0
 function getModRewriteName()
 {
     $url = ModRewriteName($this->_name);
     return $url;
 }
コード例 #4
0
function REX_SEARCH($searchtxt, $surroundchars = 20, $categories = "", $surround_tag_start = "<b>", $surround_tag_end = "</b>")
{
    ###### CHECK WHICH PATHES SHOULD BE SEARCHED
    if (!is_array($categories)) {
        $ADD_AREA .= "AND rex_article.path like '%-%'";
    } else {
        $ADD_AREA = "AND (";
        foreach ($categories as $var) {
            $ADD_AREA .= " rex_article.path like '%-{$var}%' OR ";
        }
        $ADD_AREA = substr($ADD_AREA, 0, -3) . ")";
    }
    ##### TRIM SEARCHTXT
    $searchtxt = trim($searchtxt, " ");
    ##### CHECK IF SEARCH STRING IS LONG ENOUGH
    if (strlen($searchtxt) < 40 and strlen($searchtxt) > 2) {
        ##### EXPLODE SEARCH STRING
        $words = explode(" ", $searchtxt);
        $words_count = 0;
        if (count($words) > 3) {
            $words_count = 3;
            $RETURN[msg] = "Es wurden nur die ersten 3 Begriffe benutzt";
        } else {
            $words_count = count($words);
        }
        ##### START SQL CLASS
        $SUCHE = new sql();
        #### SEARCH FOR ALL KEYWORDS
        for ($i = 0; $i < $words_count; $i++) {
            $SUCHE->flush();
            $KEYWORD = current($words);
            #### SQL QUERY
            $sql = "\r\n\t        SELECT\r\n\r\n\t        rex_article.id,rex_article.name,rex_article.beschreibung,\r\n\r\n\t\t\trex_article_slice.value1,rex_article_slice.value2,rex_article_slice.value3,\r\n\t\t\trex_article_slice.value4,rex_article_slice.value5,rex_article_slice.value6,\r\n\t\t\trex_article_slice.value7,rex_article_slice.value8,rex_article_slice.value9,\r\n\r\n\t        (FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article.name,' ',',')) * 10) +\r\n\t        (FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article.beschreibung,' ',',')) * 5) +\r\n\t        (FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article.suchbegriffe,' ',',')) * 5) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value1,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value2,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value3,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value4,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value5,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value6,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value7,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value8,' ',',')) +\r\n\t        FIND_IN_SET('{$KEYWORD}',REPLACE(rex_article_slice.value9,' ',','))\r\n\t        AS COUNTWORD\r\n\r\n\t        FROM rex_article_slice\r\n\r\n\t        LEFT JOIN rex_article ON rex_article.id=rex_article_slice.article_id\r\n\r\n\t        WHERE\r\n\r\n\t        (\r\n\t        rex_article.name LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article.beschreibung LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article.suchbegriffe LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value1 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value2 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value3 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value4 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value5 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value6 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value7 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value8 LIKE ('%{$KEYWORD}%') OR\r\n\t        rex_article_slice.value9 LIKE ('%{$KEYWORD}%')\r\n\t        )\r\n\r\n\t        AND status = 1\r\n\r\n\t\t\t{$ADD_AREA}\r\n\r\n\t        GROUP BY id\r\n\r\n\t        ORDER BY COUNTWORD DESC\r\n\r\n\t        LIMIT 0,50\r\n\r\n\t        ";
            $SUCHE->setQuery($sql);
            $count_limit = 0;
            ###### GO THROUGH RESULTS
            for ($j = 0; $j < $SUCHE->getRows(); $j++) {
                $ART[$SUCHE->getValue("rex_article.id")][ID] = $SUCHE->getValue("rex_article.id");
                $ART[$SUCHE->getValue("rex_article.id")][NAME] = $SUCHE->getValue("rex_article.name");
                $ART[$SUCHE->getValue("rex_article.id")][DESC] = $SUCHE->getValue("rex_article.beschreibung");
                $ART[$SUCHE->getValue("rex_article.id")][COUNTWORD] = $SUCHE->getValue("COUNTWORD");
                $ART[$SUCHE->getValue("rex_article.id")][URL] = $SUCHE->getValue("rex_article.id") . "-" . ModRewriteName($SUCHE->getValue("rex_article.name"));
                ###### CHECK OCURRENCE OF KEYWORD
                for ($val = 1; $val < 10; $val++) {
                    $regex = "/\\b.{0," . $surroundchars . "}" . $KEYWORD . ".{0," . $surroundchars . "}\\b/im";
                    preg_match_all($regex, strip_tags($SUCHE->getValue("rex_article_slice.value" . $val)), $matches);
                    if ($matches[0][0] != '') {
                        $ART_REGEX[$SUCHE->getValue("rex_article.id")] .= "... " . implode($matches[0], " ... ");
                    }
                }
                $SUCHE->next();
            }
            $SEARCH_WORDS[] = $KEYWORD;
            next($words);
        }
        if (is_array($ART_REGEX)) {
            $replace_string = implode("|", $SEARCH_WORDS);
            foreach ($ART_REGEX as $key => $var) {
                $ART[$key][DESC_REGEX] = preg_replace("/(" . $replace_string . ")/im", $surround_tag_start . "\\1" . $surround_tag_end, $var) . " ...";
            }
        }
    }
    return $ART;
}