Example #1
0
 function getPageWideStats($results)
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $key = wfMemcKey("rcbuddy_pagewidestats");
     $result = $wgMemc->get($key);
     if (is_array($result)) {
         wfProfileOut(__METHOD__);
         return array_merge($results, $result);
     }
     $dbr = wfGetDB(DB_SLAVE);
     $newstuff = array();
     $count = $dbr->selectField(array('recentchanges'), array('count(*) as c'), array('rc_patrolled=0'), __METHOD__);
     $newstuff['unpatrolled_total'] = $count;
     $t = gmdate("YmdHis", time() - 60 * 30);
     // thirty minutes ago
     $row = $dbr->selectRow(array('recentchanges'), array('count(distinct(rc_user)) as c'), array("rc_timestamp > {$t}", 'rc_user > 0'), __METHOD__);
     $count = $row->c;
     $newstuff['users_editing'] = $count;
     $nab_unpatrolled = Newarticleboost::getNABCount($dbr);
     $newstuff['nab_unpatrolled'] = $nab_unpatrolled;
     $wgMemc->set($key, $newstuff, 60);
     wfProfileOut(__METHOD__);
     return array_merge($newstuff, $results);
 }
Example #2
0
 public function getUserCount(&$dbr)
 {
     global $wgUser;
     $startdate = strtotime('7 days ago');
     $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000';
     return Newarticleboost::getUserNABCount($dbr, $wgUser->getID(), $starttimestamp);
 }
 /**	
  * hasProblems
  * (returns TRUE if there's a problem)
  * - Checks an article to see if it contains an image in the intro section
  * - Checks to see if there's a {{nointroimg}} template
  * - Checks to see if there's an {{nfd}} template
  * - Checks to see if there's an {{copyvio}} template
  * - Checks to see if there's an {{copyviobot}} template
  * - Makes sure an article has been NABbed
  * - Makes sure last edit has been patrolled
  **/
 function hasProblems($t, $dbr)
 {
     $r = Revision::newFromTitle($t);
     $intro = Article::getSection($r->getText(), 0);
     //check for intro image
     if (preg_match('/\\[\\[Image:(.*?)\\]\\]/', $intro)) {
         return true;
     }
     //check for {{nointroimg}} template
     if (preg_match('/{{nointroimg/', $intro)) {
         return true;
     }
     //check for {{nfd}} template
     if (preg_match('/{{nfd/', $intro)) {
         return true;
     }
     //check for {{copyvio}} or {{copyviobot}} template
     if (preg_match('/{{copyvio/', $intro)) {
         return true;
     }
     //is it NABbed?
     $is_nabbed = Newarticleboost::isNABbed($dbr, $t->getArticleId());
     if (!$is_nabbed) {
         return true;
     }
     //last edit patrolled?
     if (!GoodRevision::patrolledGood($t)) {
         return true;
     }
     //all clear?
     return false;
 }
Example #4
0
 function execute()
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang;
     //$userGroups = $wgUser->getGroups();
     if ($wgUser->isBlocked()) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     if ($wgRequest->wasPosted()) {
         $dbr = wfGetDB(DB_SLAVE);
         $pageList = $wgRequest->getVal('pages-list', '');
         $wgOut->setArticleBodyOnly(true);
         $pageList = preg_split('@[\\r\\n]+@', $pageList);
         foreach ($pageList as $url) {
             $url = trim($url);
             $pagename = self::getTitleFromURL($url);
             if (!empty($pagename)) {
                 $t = Title::newFromURL($pagename);
                 if (!empty($t)) {
                     $is_nabbed = Newarticleboost::isNABbed($dbr, $t->getArticleId());
                     if ($is_nabbed) {
                         $nabbed = 'yes';
                     } else {
                         $nabbed = 'no';
                         $nabbed .= '<br />[<a href="./Special:Newarticleboost/' . $pagename . '" target="_blank">boost it</a>]';
                     }
                 }
                 $urls[] = array('url' => $url, 'id' => $t->getArticleId(), 'boosted' => $nabbed);
             }
         }
         $html = '<style>.tres tr:nth-child(even) {background: #ccc;}</style>';
         $html .= '<table class="tres"><tr><th width="450px">URL</th><th>ID</th><th>Boosted?</th></tr>';
         foreach ($urls as $row) {
             $html .= "<tr><td class='nab_url'><a href='{$row['url']}'>{$row['url']}</a></td><td class='nab_id'>{$row['id']}</td><td class='boost'>{$row['boosted']}</td></tr>";
         }
         $html .= '</table>';
         $result = array('result' => $html);
         print json_encode($result);
         return;
     }
     $wgOut->setHTMLTitle('Admin - Lookup NAB - wikiHow');
     $wgOut->addStyle('../extensions/wikihow/adminlookup.css?rev=' . WH_SITEREV);
     $tmpl = AdminLookupPages::getGuts('AdminLookupNab');
     $wgOut->addHTML($tmpl);
     $wgOut->addHTML($wgServer);
 }
Example #5
0
 public function execute($par)
 {
     global $wgOut, $wgRequest, $wgUser, $wgHooks;
     $wgHooks['PreWikihowProcessHTML'][] = array('Misc::removePostProcessing');
     if (!in_array('staff', $wgUser->getGroups()) && !in_array('newarticlepatrol', $wgUser->getGroups())) {
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $list = $wgRequest->getVal('list', 'risingstar');
     if (!self::checkValidListName($list)) {
         $wgOut->addHTML('bad list');
         return;
     }
     $wgOut->addHTML("<div class='wh_block'>");
     $wgOut->addHTML('<link rel="stylesheet" href="' . wfGetPad('/extensions/min/f/extensions/wikihow/pagelist.css') . '" type="text/css" />');
     $dbr = wfGetDB(DB_SLAVE);
     // handle removals
     if ($wgRequest->getVal('a') == 'remove') {
         $articleID = $wgRequest->getInt('id');
         $t = Title::newFromID($articleID);
         $dbw = wfGetDB(DB_MASTER);
         $dbw->delete('pagelist', array('pl_page' => $articleID, 'pl_list' => $list), __METHOD__);
         $wgOut->addHTML("<p style='color:blue; font-weight: bold;'>{$t->getFullText()} has been remove from the list.</p>");
     }
     if ($wgRequest->wasPosted()) {
         $newtitle = strip_tags($wgRequest->getVal('newtitle'));
         if ($newtitle) {
             $url = $newtitle;
             $url = preg_replace("@http://@", "", $url);
             $url = preg_replace("@.*/@U", "", $url);
             $t = Title::newFromURL($url);
             if (!$t || !$t->getArticleID()) {
                 $wgOut->addHTML("<p style='color:red; font-weight: bold;'>Error: Couldn't find article id for {$newtitle}</p>");
             } else {
                 if ($dbr->selectField("pagelist", array("count(*)"), array('pl_page' => $t->getArticleID(), 'pl_list' => $list), __METHOD__) > 0) {
                     $wgOut->addHTML("<p style='color:red; font-weight: bold;'>Oops! This title is already in the list</p>");
                 } else {
                     $dbw = wfGetDB(DB_MASTER);
                     $dbw->insert('pagelist', array('pl_page' => $t->getArticleID(), 'pl_list' => $list), __METHOD__);
                     if ($list == 'risingstar') {
                         // add the rising star template to the discussion page
                         $talk = $t->getTalkPage();
                         $a = new Article($talk);
                         $text = $a->getContent();
                         $min = $dbr->selectField('revision', array("min(rev_id)"), array('rev_page' => $t->getArticleId()), __METHOD__);
                         $name = $dbr->selectField('revision', array('rev_user_text'), array('rev_id' => $min), __METHOD__);
                         $text = "{{Rising-star-discussion-msg-2|[[User:{$name}|{$name}]]|[[User:{$wgUser->getName()}|{$wgUser->getName()}]]}}\n" . $text;
                         $a->doEdit($text, wfMsg('nab-rs-discussion-editsummary'));
                         // add the comment to the user's talk page
                         Newarticleboost::notifyUserOfRisingStar($t, $name);
                     }
                     $wgOut->addHTML("<p style='color:blue; font-weight: bold;'>{$t->getFullText()} has been added to the list.</p>");
                 }
             }
         }
     }
     $wgOut->setPageTitle("Manage page list - " . wfMsg('pagelist_' . $list));
     $wgOut->addHTML("<form name='addform' method='POST' action='/Special:Managepagelist'>\n\t\t\t\t<table style='width: 100%;'><tr><td style='width: 430px;'>\n\t\t\t\t\tAdd article to this list by URL or title: \n\t\t\t\t\t\t<input type='text' name='newtitle' id='newtitle'></td>\n\t\t\t\t\t<td style='width: 32px; vertical-align: bottom;'><input type='image' class='addicon' src='" . wfGetPad('/skins/WikiHow/images/plus.png') . "' onclick='javascript:document.addform.submit()'/></td>\n\t\t<td style='text-align: right;'>View list:<br/>\n\t\t\t\t\t<select onchange='window.location.href=\"/Special:Managepagelist&list=\" + this.value;'>\n\t\t\t");
     $res = $dbr->query("select distinct(pl_list) from pagelist", __METHOD__);
     while ($row = $dbr->fetchObject($res)) {
         if ($row->pl_list == $list) {
             $wgOut->addHTML("<OPTION SELECTED style='font-weight: bold;'>" . wfMsg('pagelist_' . $row->pl_list) . "</OPTION>\n");
         } else {
             $wgOut->addHTML("<OPTION>" . wfMsg('pagelist_' . $row->pl_list) . "</OPTION>\n");
         }
     }
     $wgOut->addHTML("</select></td></tr></table>\n\t\t\t\t</form>");
     $res = $dbr->select(array('page', 'pagelist'), array('page_title', 'page_namespace', 'page_id'), array('page_id=pl_page', 'pl_list' => $list), __METHOD__, array("ORDER BY" => "pl_page DESC"));
     $wgOut->addHTML("<br/><p>There are " . number_format($dbr->numRows($res), 0, "", ",") . " articles in this list.</p>");
     $wgOut->addHTML("<table class='pagelist'>");
     $index = 0;
     while ($row = $dbr->fetchObject($res)) {
         $t = Title::makeTitle($row->page_namespace, $row->page_title);
         if (!$t) {
             echo "Couldn't make title out of {$row->page_namespace} {$row->page_title}\n";
             continue;
         }
         if ($index % 2 == 0) {
             $wgOut->addHTML("<tr>");
         } else {
             $wgOut->addHTML("<tr class='shaded'>");
         }
         $wgOut->addHTML("<td class='pagelist_title'><a href='{$t->getFullURL()}' target='new'>{$t->getFullText()}</td>\n\t\t\t\t<td><a href='/Special:Managepagelist?a=remove&list={$list}&id={$row->page_id}' onclick='return confirm(\"Do you really want to remove this article?\")'><img src='" . wfGetPad('/extensions/wikihow/rcwidget/rcwDelete.png') . "' style='height: 24px; width: 24px;'></a></td>");
         $wgOut->addHTML("</tr>");
         $index++;
     }
     $wgOut->addHTML("</table>");
     $wgOut->addHTML("</div><!--end wh_block-->");
 }
 /**
  * Check whether the article is yet to be nabbed and is short in length.  Use byte size as a proxy for length
  * for better performance.
  */
 private function isShortUnNABbedArticle()
 {
     $ret = false;
     if ($this->article && $this->title->exists() && $this->title->getNamespace() == NS_MAIN) {
         if (class_exists('Newarticleboost') && !Newarticleboost::isNABbed(self::getDB(), $this->title->getArticleID())) {
             $r = $this->article->getRevisionFetched();
             if ($r) {
                 $ret = $r->getSize() < 1500;
                 // ~1500 bytes
             }
         }
     }
     return $ret;
 }
Example #7
0
 public function calc(&$dbr, &$r, &$t, &$pageRow)
 {
     $nab = Newarticleboost::isNABbed($dbr, $pageRow->page_id) ? '1' : '0';
     $ret = array('ti_nab' => $nab);
     return $ret;
 }