Beispiel #1
0
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser;
     $ratrItem = $wgRequest->getVal("item_id");
     $ratrUser = $wgUser->getID();
     $ratrUserText = $wgUser->getName();
     $ratrReason = $wgRequest->getVal('reason');
     $ratrType = $wgRequest->getVal('type');
     $target = intval($target);
     $wgOut->disable();
     wfLoadExtensionMessages('RateItem');
     $ratingTool = new RatingSample();
     echo $ratingTool->addRatingReason($ratrItem, $ratrUser, $ratrUserText, $ratrReason, $ratrType);
 }
            $sql .= ", ";
        }
        $sql .= "('" . $row->{$ratingTool->getTablePrefix() . 'page'} . "', '{$row->R}', '{$row->C}')";
        $count++;
        if ($count % $insertMax == 0) {
            $dbw->query($sql, __FILE__);
            $sql = $sqlStart;
        }
    }
}
if ($sql != $sqlStart) {
    $dbw->query($sql, __FILE__);
}
////////////////////////////////////
//now refresh the SAMPLE ratings
$ratingTool = new RatingSample();
$res = DatabaseHelper::batchSelect($ratingTool->getTableName(), array('*'), array('rats_isdeleted' => 0), __FILE__);
$newStats = array();
$deletedPages = array();
foreach ($res as $row) {
    if ($row->ratsisdeleted != 0) {
    } else {
        if ($newStats[$row->rats_page] == null) {
            $newStats[$row->rats_page] = array("count" => 0, "ratingCount" => 0);
        }
        $newStats[$row->rats_page]["count"]++;
        $newStats[$row->rats_page]["ratingCount"] += $row->rats_rating;
    }
}
//dump the table
$dbw->query("delete from {$ratingTool->getLowTableName()}", __FILE__);
Beispiel #3
0
 function getRatingTool($type)
 {
     switch (strtolower($type)) {
         case 'article':
             $rTool = new RatingArticle();
             break;
         case 'sample':
             $rTool = new RatingSample();
             break;
     }
     $rTool->setContext($this->getContext());
     return $rTool;
 }