/**	
  * 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;
 }
예제 #2
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);
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 public function calc(&$dbr, &$r, &$t, &$pageRow)
 {
     $nab = Newarticleboost::isNABbed($dbr, $pageRow->page_id) ? '1' : '0';
     $ret = array('ti_nab' => $nab);
     return $ret;
 }