Beispiel #1
0
 function getUserCategoriesHtml(&$vars)
 {
     $cats = CategoryInterests::getCategoryInterests();
     $html = "";
     if (sizeof($cats)) {
         $vars['cats'] = self::getCategoryDivs($cats);
         $vars['nocats_hidden'] = 'csui_hidden';
     }
     $suggested = self::getSuggestedCategoryDivs(CategoryInterests::suggestCategoryInterests());
     $vars['suggested_cats'] = $suggested;
 }
 function execute()
 {
     global $wgUser, $wgRequest, $wgOut;
     if ($wgUser->isAnon()) {
         $wgOut->blockedPage();
         return;
     }
     $cat = $wgRequest->getval("cat", NULL);
     if ($cat) {
         CategoryInterests::addCategoryInterest($cat);
         $wgOut->redirect('/Special:EditFinder/Topic');
     }
 }
    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);
        }
    }
Beispiel #4
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;
 }
Beispiel #5
0
 function setVars(&$vars, &$t)
 {
     global $wgUser, $wgRequest;
     $vars['cat_head'] = $this->getHeadHtml($t, $vars);
     $vars['cat_help_url'] = wfMsg('cat_help_url');
     $vars['tree'] = json_encode(CategoryInterests::getCategoryTreeArray());
     $vars['cat_search_label'] = wfMsg('cat_search_label');
     $vars['cat_subcats_label'] = wfMsg('cat_subcats_label');
 }
Beispiel #6
0
 function getCategoryPartialMatches($q)
 {
     $cats = CategoryInterests::getCategoriesArray();
     // Only do partial matches when the query is more than 3 characters.  Returns too much gibberish otherwise
     $results = array();
     if (strlen($q) > 3) {
         $results = $this->substrArraySearch($q, $cats);
     }
     foreach ($results as $k => $result) {
         $results[$k] = str_replace(" ", "-", $result);
     }
     return $results;
 }
 function setVars(&$vars, &$t)
 {
     global $wgUser, $wgRequest;
     $vars['cat_head'] = $this->getHeadHtml($t, $vars);
     $vars['cat_help_url'] = wfMsg('cat_help_url');
     $vars['tree'] = json_encode(CategoryInterests::getCategoryTreeArray());
     $vars['cat_search_label'] = wfMsg('cat_search_label');
     $vars['cat_subcats_label'] = wfMsg('cat_subcats_label');
     if ($this->editPage) {
         $vars['js'] = HtmlSnips::makeUrlTags('js', array('categorizer.js'), '/extensions/wikihow/cattool');
     }
 }