Exemplo n.º 1
0
    function outputCategoryReport()
    {
        global $wgRequest, $wgOut;
        $cat = str_replace("http://www.wikihow.com/Category:", "", trim(Misc::getUrlDecodedData($wgRequest->getVal('data'))));
        $catArr = array($cat);
        $cats = CategoryInterests::getSubCategoryInterests($catArr);
        $cats[] = $cat;
        $cats = '"' . join('","', $cats) . '"';
        $sql = 'SELECT 
					page_id, page_title, page_counter 
				FROM page p 
				INNER JOIN categorylinks c ON c.cl_from = page_id 
				WHERE page_namespace = 0  and page_is_redirect = 0 AND c.cl_to IN (' . $cats . ')';
        $dbr = wfGetDB(DB_SLAVE);
        $res = $dbr->query($sql);
        $articles = array();
        while ($row = $dbr->fetchObject($res)) {
            $altsData = "";
            if ($this->slowQuery) {
                $r = Revision::loadFromPageId($dbr, $row->page_id);
                $wikitext = $r->getText();
                //$imgs = $this->hasImages($wikitext);
                $altsData = $this->hasAlternateMethods($wikitext) ? "Yes" : "No";
                $sizeData = $this->getArticleSize($r);
            }
            //$output .= join("\t", array_values(get_object_vars($row))) . "\t$imgs\t$altsData\t$sizeData\n";
            $row = array_values(get_object_vars($row));
            $row[1] = Misc::makeUrl($row[1]);
            $articles[] = $row;
        }
        if ($wgRequest->getVal('format') == 'csv') {
            $output = $this->getCategoryReportCSV($articles);
            $this->sendFile($cat, $output);
        } else {
            $output = $this->getCategoryReportHtml($articles);
            $this->sendHtml($output);
        }
    }
Exemplo n.º 2
0
 function getUserInterests()
 {
     $interests = CategoryInterests::getCategoryInterests();
     $interests = array_merge($interests, CategoryInterests::getSubCategoryInterests($interests));
     $interests = array_values(array_unique($interests));
     $fn = function (&$value) {
         $dbr = wfGetDB(DB_SLAVE);
         $value = $dbr->strencode($value);
     };
     array_walk($interests, $fn);
     $sql = " AND c.cl_to IN ('" . implode("','", $interests) . "') ";
     return $sql;
 }