Example #1
0
 private function resetUrls()
 {
     global $wgRequest, $wgOut;
     $urls = preg_split("@\n@", trim($wgRequest->getVal('if_urls')));
     foreach ($urls as $url) {
         if (!empty($url)) {
             $t = WikiPhoto::getArticleTitle($url);
             if ($t && $t->exists()) {
                 $aids[] = $t->getArticleId();
             } else {
                 $invalid[] = $url;
             }
         }
     }
     $numUrls = sizeof($aids);
     if ($numUrls) {
         $dbw = wfGetDB(DB_MASTER);
         $aidsList = "(" . implode(",", $aids) . ")";
         $dbw->delete('image_feedback', array("ii_img_page_id IN {$aidsList}"), __METHOD__);
     }
     if (sizeof($invalid)) {
         $invalid = "These input urls are invalid:<br><br>" . implode("<br>", $invalid);
     }
     $wgOut->setArticleBodyOnly(true);
     $wgOut->addHtml("{$numUrls} reset.{$invalid}");
 }
Example #2
0
 /**
  * Parse the input field into an array of URLs and Title objects
  */
 private static function parseURLlist($type, $pageList)
 {
     $pageList = preg_split('@[\\r\\n]+@', $pageList);
     $urls = array();
     foreach ($pageList as $url) {
         $url = trim($url);
         if (!empty($url)) {
             $title = WikiPhoto::getArticleTitle($url);
             if ($title && $title->exists()) {
                 $id = $title->getArticleId();
                 $url = array('url' => $url, 'title' => $title, 'id' => $id);
                 if ('descs' == $type) {
                     $meta = new ArticleMetaInfo($title);
                     $desc = $meta->getDescription();
                     $url['desc'] = $desc;
                 } else {
                     $tt = TitleTests::newFromTitle($title);
                     if ($tt) {
                         $pageTitle = $tt->getTitle();
                     } else {
                         $pageTitle = '<i>error generating title</i>';
                     }
                     $url['page-title'] = $pageTitle;
                 }
                 $urls[] = $url;
             }
         }
     }
     return $urls;
 }
Example #3
0
 /**
  * Parse the input field into an array of URLs and Title objects
  */
 public static function parseURLlist($pageList)
 {
     $pageList = preg_split('@[\\r\\n]+@', $pageList);
     $urls = array();
     foreach ($pageList as $url) {
         $url = trim($url);
         if (!empty($url)) {
             $title = WikiPhoto::getArticleTitle($url);
             $urls[] = array('url' => $url, 'title' => $title);
         }
     }
     return $urls;
 }
 function getIdsFromUrls(&$urls)
 {
     $ids = array();
     $urls = explode("\n", trim($urls));
     foreach ($urls as $url) {
         $t = WikiPhoto::getArticleTitle($url);
         if ($t && $t->exists()) {
             $ids[] = $t->getArticleId();
         }
     }
     return $ids;
 }