Changeset 77

Show
Ignore:
Timestamp:
11/03/07 18:55:26 (6 years ago)
Author:
d0nut
Message:

updated tagging reloaded mainteance function

Location:
taggingreloaded
Files:
2 modified
1 moved

Legend:

Unmodified
Added
Removed
  • taggingreloaded/files/lib/util/TaggingReloadedUtil.class.php

    r59 r77  
    4848         * @return text 
    4949         */ 
    50         public function bbcode2text($text) { 
     50        public static function bbcode2text($text) { 
    5151                // if there is bold text, then repeat the words 
    5252                $text = preg_replace('/\[b\](.+)\[\/b\]/', '$1 $1', $text); 
     
    6767         * @return array 
    6868         */ 
    69         public function text2tags($text, $limit=15) { 
     69        public static function text2tags($text, $limit=15) { 
    7070                $tags = array(); 
    7171 
     
    7777 
    7878                // filter stopwords 
    79                 $words = array_filter($words, array($this, "noStopword")); 
     79                //$words = array_filter($words, array($this, "noStopword")); 
    8080 
    8181                // search weights 
     
    9393                array_walk($tags, create_function('&$val, $key','$val = array("weight"=>$val*100);')); 
    9494 
    95                 $tags = $this->beautify($tags, 100, 200); 
     95                $tags = TaggingReloadedUtil::beautify($tags, 100, 200); 
    9696 
    9797                // replace weights with sizes TODO: replace through array_walk 
     
    109109         * @param userID -> (optional) 
    110110         */ 
    111         public function tags2db($taggingID, $tags, $userID=null) { 
     111        public static function tags2db($taggingID, $tags, $userID=null) { 
    112112                if(count($tags) == 0) return; 
    113113 
     
    136136         * @param array 
    137137         */ 
    138         public function beautify($tags, $forced_minsize=null, $forced_maxsize=null) { 
     138        public static function beautify($tags, $forced_minsize=null, $forced_maxsize=null) { 
    139139                // TODO: auslagern 
    140140                $minsize = $forced_minsize === null ? 75 : $forced_minsize; 
  • taggingreloaded/optionals/de.easy-coding.wbb.taggingreloaded/files/lib/acp/action/UpdateTaggingReloadedAction.class.php

    r68 r77  
    1616        public $everything = true; 
    1717         
    18         protected function buildQuery() { 
     18        /** 
     19         * 
     20         * @param count 
     21         */ 
     22        protected function buildQuery($count=false) { 
    1923                if($this->everything) { 
    20                         $sql = "SELECT          postID, 
     24                        $columns = "            postID, 
    2125                                                threadID,  
    22                                                 message 
     26                                                message"; 
     27                         
     28                        $sql = "SELECT          ".($count?'COUNT(*) AS count':$columns)." 
    2329                                FROM            wbb".WBB_N."_post 
    2430                                ORDER BY        threadID ASC, 
     
    2733                                OFFSET          ".($this->limit * $this->loop); 
    2834                } else { 
    29                         $sql = "SELECT          p2.postID, 
     35                        $columns = "            p2.postID, 
    3036                                                p2.threadID,  
    31                                                 p2.message 
     37                                                p2.message"; 
     38 
     39                        $sql = "SELECT          ".($count?'COUNT(*) AS count':$columns)." 
    3240                                FROM            wbb".WBB_N."_post p 
    3341                                JOIN            wbb".WBB_N."_thread t 
     
    3745                                WHERE           p.systemTagged = 0 
    3846                                ORDER BY        p2.threadID ASC, 
    39                                                 p2.postID DESC"; 
     47                                                p2.postID DESC 
     48                                LIMIT           ".$this->limit." 
     49                                OFFSET          ".($this->limit * $this->loop); 
    4050                } 
    4151                 
     
    5060                $threadIDs = array(); 
    5161                $systemTaggerUserID = -1; 
     62                $text = ''; 
     63                 
     64                // count board 
     65                $sql = $this->buildQuery(true); 
     66                $row = WCF::getDB()->getFirstRow($sql); 
     67                $count = $row['count']; 
    5268                 
    5369                // get all posts 
     
    5975                                $threadID = $row['threadID']; 
    6076                                $threadIDs[] = $threadID; 
    61  
    6277                                $msg = TaggingReloadedUtil::bbcode2text($row['message']); 
    6378                                $text .= $msg; 
     
    6681                                $tags = TaggingReloadedUtil::text2tags($text); 
    6782                                $first_post = $row['postID']; 
    68                                  
     83 
    6984                                // CLEANUP system tags 
    7085                                $sql = "DELETE FROM     wbb".WBB_N."_taggingreloaded,  
    7186                                                        wcf".WCF_N."_taggingreloaded 
    72                                         USING           wbb".WBB_N."_taggingreloaded wbb 
    73                                         NATURAL JOIN    wcf".WCF_N."_taggingreloaded wcf 
    74                                         JOIN            wbb".WBB_N."_post p 
    75                                         ON              wbb.postID = p.postID 
    76                                         WHERE           userID = {$systemTaggerUserID} 
    77                                         AND             p.threadID = {$threadID};"; 
     87                                        USING           wbb".WBB_N."_taggingreloaded 
     88                                        NATURAL JOIN    wcf".WCF_N."_taggingreloaded 
     89                                        JOIN            wbb".WBB_N."_post 
     90                                        ON              wbb".WBB_N."_taggingreloaded.postID = wbb".WBB_N."_post.postID 
     91                                        WHERE           wcf".WCF_N."_taggingreloaded.userID = {$systemTaggerUserID} 
     92                                        AND             wbb".WBB_N."_post.threadID = {$threadID};"; 
    7893 
    79                                 WBBCore::getDB()->sendQuery($sql); 
    80  
     94                                WCF::getDB()->sendQuery($sql); 
    8195                                if(count($tags) > 0) { 
    8296                                        $sql = "SELECT          taggingID 
     
    94108                                                        VALUES          ({$first_post});"; 
    95109 
    96                                                 WBBCore::getDB()->sendQuery($sql); 
     110                                                WCF::getDB()->sendQuery($sql); 
    97111                                                $taggingID = WBBCore::getDB()->getInsertID(); 
    98112                                        } 
     
    109123                                        systemTagged = 1  
    110124                        WHERE           threadID IN (".implode(',', $threadIDs)."); "; 
    111                 WBBCore::getDB()->sendQuery($sql); 
     125                WCF::getDB()->sendQuery($sql); 
    112126 
    113127                $this->executed(); 
     128 
     129                if($this->everything) { 
    114130                 
    115                 if($this->everything) { 
    116131                        $this->calcProgress(($this->limit * $this->loop), $count); 
    117132                        $this->nextLoop(); 
  • taggingreloaded/templates/messageFormTaggingReloaded.tpl

    r64 r77  
    2020                </div> 
    2121                <div class="formField"> 
    22                         <input type="text" name="inputTagging" id="inputTagging" size="40" /> 
     22                        <input type="text" name="inputTagging" id="inputTagging" size="65" /> 
    2323                        <input type="button" value="{lang}wcf.taggingreloaded.add{/lang}" onclick="tagging.formadd(this.form.inputTagging);" /> 
    2424                        <script type="text/javascript" src="{@RELATIVE_WCF_DIR}js/Suggestion.class.js"></script> 
     
    3434                        <p>{lang}wcf.taggingreloaded.add.description{/lang}</p> 
    3535                </div> 
     36                <p>{lang}wcf.taggingreloaded.add.instruction{/lang}</p> 
    3637        </div> 
    37         <p>{lang}wcf.taggingreloaded.add.instruction{/lang}</p> 
    38          
    3938</div> 
    4039