public function setTitle($title)
 {
     $this->title = $title;
     $globalTitleObj = (array) GlobalTitle::explodeURL($this->title);
     $this->setArticleName($globalTitleObj['articleName']);
     $this->setWikiId($globalTitleObj['wikiId']);
 }
/**
 * axWFactoryGetVariable
 *
 * Method for getting variable form via AJAX request.
 *
 * @author Krzysztof Krzyżaniak <*****@*****.**>
 * @access public
 *
 * @return HTML code with variable data
 */
function axWFactoryGetVariable()
{
    global $wgRequest, $wgUser, $wgOut, $wgPreWikiFactoryValues;
    if (!$wgUser->isAllowed('wikifactory')) {
        $wgOut->readOnlyPage();
        #--- FIXME: later change to something reasonable
        return;
    }
    $cv_id = $wgRequest->getVal("varid");
    $city_id = $wgRequest->getVal("wiki");
    $variable = WikiFactory::getVarById($cv_id, $city_id);
    // BugId:3054
    if (empty($variable)) {
        return json_encode(array('error' => true, 'message' => 'No such variable.'));
    }
    $related = array();
    $r_pages = array();
    if (preg_match("/Related variables:(.*)\$/", $variable->cv_description, $matches)) {
        $names = preg_split("/[\\s,;.()]+/", $matches[1], null, PREG_SPLIT_NO_EMPTY);
        foreach ($names as $name) {
            $rel_var = WikiFactory::getVarByName($name, $city_id);
            if (!empty($rel_var)) {
                $related[] = $rel_var;
            } else {
                if (preg_match("/^MediaWiki:.*\$/", $name, $matches2)) {
                    $r_pages[] = array("url" => GlobalTitle::newFromText($name, 0, $city_id)->getFullURL());
                }
            }
        }
    }
    $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
    $oTmpl->set_vars(array("cityid" => $city_id, "variable" => $variable, "groups" => WikiFactory::getGroups(), "accesslevels" => WikiFactory::$levels, "related" => $related, "related_pages" => $r_pages, "preWFValues" => $wgPreWikiFactoryValues, 'wikiFactoryUrl' => Title::makeTitle(NS_SPECIAL, 'WikiFactory')->getFullUrl()));
    return json_encode(array("div-body" => $oTmpl->render("variable"), "div-name" => "wk-variable-form"));
}
 /**
  * Called from maintenance script only.  Send Digest emails for any founders with that preference enabled
  *
  * @param array $events Events is empty for this type
  */
 public function process(array $events)
 {
     global $wgTitle;
     wfProfileIn(__METHOD__);
     $founderEmailObj = FounderEmails::getInstance();
     $wgTitle = Title::newMainPage();
     // Get list of founders with digest mode turned on
     $cityList = $founderEmailObj->getFoundersWithPreference('founderemails-views-digest');
     $wikiService = new WikiService();
     // Gather daily page view stats for each wiki requesting views digest
     foreach ($cityList as $cityID) {
         $user_ids = $wikiService->getWikiAdminIds($cityID);
         $foundingWiki = WikiFactory::getWikiById($cityID);
         $page_url = GlobalTitle::newFromText('Createpage', NS_SPECIAL, $cityID)->getFullUrl(array('modal' => 'AddPage'));
         $emailParams = array('$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$PAGEURL' => $page_url, '$UNIQUEVIEWS' => $founderEmailObj->getPageViews($cityID));
         foreach ($user_ids as $user_id) {
             $user = User::newFromId($user_id);
             // skip if not enable
             if (!$this->enabled($user, $cityID)) {
                 continue;
             }
             self::addParamsUser($cityID, $user->getName(), $emailParams);
             $langCode = $user->getGlobalPreference('language');
             $links = array('$WIKINAME' => $emailParams['$WIKIURL']);
             $mailSubject = strtr(wfMsgExt('founderemails-email-views-digest-subject', array('content')), $emailParams);
             $mailBody = strtr(wfMsgExt('founderemails-email-views-digest-body', array('content', 'parsemag'), $emailParams['$UNIQUEVIEWS']), $emailParams);
             $mailBodyHTML = F::app()->renderView('FounderEmails', 'GeneralUpdate', array_merge($emailParams, array('language' => 'en', 'type' => 'views-digest')));
             $mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
             $mailCategory = FounderEmailsEvent::CATEGORY_VIEWS_DIGEST . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
             $founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $cityID, $mailCategory);
         }
     }
     wfProfileOut(__METHOD__);
 }
 public function execute()
 {
     $wikis = $this->getWikisToFix();
     $corporateModel = new WikiaCorporateModel();
     foreach ($wikis as $wiki) {
         $wikiLocalImage = $this->getCVImage($wiki['city_id']);
         if (!empty($wikiLocalImage)) {
             try {
                 $corpWikiId = $corporateModel->getCorporateWikiIdByLang($wiki['city_lang_code']);
             } catch (Exception $e) {
                 var_dump($wiki['city_id'], $wiki['city_lang_code']);
             }
             $t = GlobalTitle::newFromText('Wikia-Visualization-Main.png', NS_FILE, $wiki['city_id']);
             if (TaskRunner::isModern('PromoteImageReviewTask')) {
                 $task = new \Wikia\Tasks\Tasks\PromoteImageReviewTask();
             } else {
                 $task = new PromoteImageReviewTask();
             }
             var_dump($t->getArticleID(), $wiki['city_main_image'], $corpWikiId, $wiki['city_id']);
             $res = $task->uploadSingleImage($t->getArticleID(), 'Wikia-Visualization-Main.png', $corpWikiId, $wiki['city_id']);
             if ($res['status'] == 0 && !empty($res['name'])) {
                 var_dump($res);
                 $this->updateVisualizationMainImageName($wiki['city_id'], $res['name']);
             }
         }
     }
 }
 /**
  * @desc get central wiki URL for given language.
  * If wiki in given language doesn't exist GlobalTitle method is throwing an exception and this method returns false
  *
  * @param String $lang - language code
  * @return bool|GlobalTitle
  */
 public function getCentralWikiUrlForLangIfExists($lang)
 {
     try {
         return GlobalTitle::newMainPage($this->wikiCorporateModel->getCorporateWikiIdByLang($lang));
     } catch (Exception $ex) {
         return false;
     }
 }
 /**
  * get image page url
  * @param integer $wikiId
  * @param integer $pageId
  * @return string image page URL
  */
 public static function getImagePage($wikiId, $pageId)
 {
     $app = F::app();
     $app->wf->ProfileIn(__METHOD__);
     $title = GlobalTitle::newFromId($pageId, $wikiId);
     $imagePage = $title instanceof Title ? $title->getFullURL() : '';
     $app->wf->ProfileOut(__METHOD__);
     return $imagePage;
 }
示例#7
0
 /**
  * Add a link to central:Special:Phalanx from Special:Contributions/USERNAME
  * if the user has 'phalanx' permission
  *
  * @param $id Integer: user ID
  * @param $nt Title: user page title
  * @param $links Array: tool links
  * @return boolean true
  */
 public static function loadLinks($id, $nt, &$links)
 {
     wfProfileIn(__METHOD__);
     $user = RequestContext::getMain()->getUser();
     if ($user->isAllowed('phalanx')) {
         $links[] = Linker::makeKnownLinkObj(GlobalTitle::newFromText('Phalanx', NS_SPECIAL, WikiFactory::COMMUNITY_CENTRAL), 'PhalanxBlock', wfArrayToCGI(['type' => Phalanx::TYPE_USER, 'wpPhalanxCheckBlocker' => $nt->getText(), 'target' => $nt->getText()]));
     }
     wfProfileOut(__METHOD__);
     return true;
 }
示例#8
0
 function execute($params = null)
 {
     global $IP, $wgWikiaLocalSettingsPath;
     /*  go with each supplied wiki and delete the supplied article
     			load all configs for particular wikis before doing so
     			(from wikifactory, not by _obsolete_ maintenance scripts
     			and from LocalSettings as worked on fps)
     		 */
     $this->mTaskID = $params->task_id;
     $oUser = User::newFromId($params->task_user_id);
     if ($oUser instanceof User) {
         $oUser->load();
         $this->mUser = $oUser->getName();
     } else {
         $this->log("Invalid user - id: " . $params->task_user_id);
         return true;
     }
     $data = unserialize($params->task_arguments);
     foreach ($data['page_list'] as $imageData) {
         $retval = "";
         list($wikiId, $imageId) = $imageData;
         $dbname = WikiFactory::getWikiByID($wikiId);
         if (!$dbname) {
             continue;
         }
         $title = GlobalTitle::newFromId($imageId, $wikiId);
         if (!is_object($title)) {
             $this->log('Apparently the article does not exist anymore');
             continue;
         }
         $city_url = WikiFactory::getVarValueByName("wgServer", $wikiId);
         if (empty($city_url)) {
             continue;
         }
         $city_path = WikiFactory::getVarValueByName("wgScript", $wikiId);
         $city_lang = WikiFactory::getVarValueByName("wgLanguageCode", $wikiId);
         $reason = wfMsgExt('imagereview-reason', array('language' => $city_lang));
         $sCommand = "perl /usr/wikia/backend/bin/run_maintenance --id={$wikiId} --script=wikia/deleteOn.php ";
         $sCommand .= "-- ";
         $sCommand .= "-u " . escapeshellarg($this->mUser) . " ";
         $sCommand .= "-t " . escapeshellarg($title->getPrefixedText()) . " ";
         if ($reason) {
             $sCommand .= "-r " . escapeshellarg($reason) . " ";
         }
         $actual_title = wfShellExec($sCommand, $retval);
         if ($retval) {
             $this->addLog('Article deleting error! (' . $city_url . '). Error code returned: ' . $retval . ' Error was: ' . $actual_title);
         } else {
             $this->addLog('Removed: <a href="' . $city_url . $city_path . '?title=' . wfEscapeWikiText($actual_title) . '">' . $city_url . $city_path . '?title=' . $actual_title . '</a>');
         }
         $this->flagUser($imageId, $wikiId);
         $this->flagWiki($wikiId);
     }
     return true;
 }
 public function execute($subpage)
 {
     global $wgOut;
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     global $wgDBname;
     // $wgOut->addHtml( 'The dbname of this wiki is ['. $wgDBname ."]<br/>\n" );
     $WF = GlobalTitle::newFromText('WikiFactory/db:' . $wgDBname, NS_SPECIAL, 177);
     $url = $WF->getFullURL();
     $wgOut->redirect($url);
 }
 public function getWamPageUrl()
 {
     try {
         $wikiId = (new WikiaCorporateModel())->getCorporateWikiIdByLang($this->langCode);
     } catch (Exception $e) {
         $wikiId = WikiService::WIKIAGLOBAL_CITY_ID;
     }
     $wamPageConfig = WikiFactory::getVarByName('wgWAMPageConfig', $wikiId)->cv_value;
     $pageName = !empty($wamPageConfig['pageName']) ? $wamPageConfig['pageName'] : 'WAM';
     $url = GlobalTitle::newFromText($pageName, NS_MAIN, $wikiId)->getFullURL();
     return $url;
 }
 private function clearCache($langCode)
 {
     $this->wg->Memc->delete($this->getCollectionsListCacheKey($langCode));
     $this->wg->Memc->delete($this->getCollectionsListVisualizationCacheKey($langCode));
     $visualization = new CityVisualization();
     $corporateModel = new WikiaCorporateModel();
     foreach ($this->getList($langCode) as $collection) {
         $this->wg->Memc->delete($visualization->getCollectionCacheKey($collection['id']));
         $title = GlobalTitle::newMainPage($corporateModel->getCorporateWikiIdByLang($langCode));
         $title->purgeSquid();
         Wikia::log(__METHOD__, '', 'Purged memcached for collection #' . $collection['id']);
     }
 }
示例#12
0
 function testUrlsPolishWiki()
 {
     $title = GlobalTitle::newFromText("WikiFactory", NS_SPECIAL, 1686);
     # pl.wikia.com
     $url = "http://spolecznosc.wikia.com/wiki/Special:WikiFactory";
     $this->assertTrue($title->getFullURL() === $url, sprintf("%s = %s, NOT MATCH", $title->getFullURL(), $url));
     $url = "http://spolecznosc.wikia.com/wiki/Special:WikiFactory?diff=0&oldid=500";
     $this->assertTrue($title->getFullURL(wfArrayToCGI(array("diff" => 0, "oldid" => 500))) === $url, sprintf("%s = %s, NOT MATCH", $title->getFullURL(), $url));
     $title = GlobalTitle::newFromText("Strona główna", false, 1686);
     # pl.wikia.com
     $url = "http://spolecznosc.wikia.com/wiki/Strona_g%C5%82%C3%B3wna?diff=0&oldid=500";
     $this->assertTrue($title->getFullURL(wfArrayToCGI(array("diff" => 0, "oldid" => 500))) === $url, "NOT MATCH");
 }
示例#13
0
 public function execute()
 {
     $this->dryRun = $this->hasOption('dry-run');
     $this->verbose = $this->hasOption('verbose');
     $wikiId = $this->getOption('wikiId', '');
     if (empty($wikiId)) {
         die("Error: Empty wiki id.\n");
     }
     $dbname = WikiFactory::IDtoDB($wikiId);
     if (empty($dbname)) {
         die("Error: Cannot find dbname.\n");
     }
     $pageLimit = 20000;
     $totalLimit = $this->getOption('limit', $pageLimit);
     if (empty($totalLimit) || $totalLimit < -1) {
         die("Error: invalid limit.\n");
     }
     if ($totalLimit == -1) {
         $totalLimit = $this->getTotalPages($dbname);
     }
     $maxSet = ceil($totalLimit / $pageLimit);
     $limit = $totalLimit > $pageLimit ? $pageLimit : $totalLimit;
     $totalPages = 0;
     for ($set = 1; $set <= $maxSet; $set++) {
         $cnt = 0;
         if ($set == $maxSet) {
             $limit = $totalLimit - $pageLimit * ($set - 1);
         }
         $offset = ($set - 1) * $pageLimit;
         $pages = $this->getAllPages($dbname, $limit, $offset);
         $total = count($pages);
         foreach ($pages as $page) {
             $cnt++;
             echo "Wiki {$wikiId} - Page {$page['id']} [{$cnt} of {$total}, set {$set} of {$maxSet}]: ";
             $title = GlobalTitle::newFromId($page['id'], $wikiId);
             if ($title instanceof GlobalTitle) {
                 $url = $title->getFullURL();
                 echo "{$url}\n";
                 if (!$this->dryRun) {
                     SquidUpdate::purge([$url]);
                 }
                 $this->success++;
             } else {
                 echo "ERROR: Cannot find global title for {$page['title']}\n";
             }
         }
         $totalPages = $totalPages + $total;
     }
     echo "\nWiki {$wikiId}: Total pages: {$totalPages}, Success: {$this->success}, Failed: " . ($totalPages - $this->success) . "\n\n";
 }
 /**
  * @description Builds slug and localized URLs for each of our partner category pages
  * @responseParam array $partners
  */
 public function partners()
 {
     $partners = array();
     // keys are lowercase as they are used to compose CSS & i18n keys
     $partners['anyclip'] = array('label' => 'AnyClip');
     $partners['ign'] = array('label' => 'IGN');
     $partners['iva'] = array('label' => 'IVA');
     $partners['screenplay'] = array('label' => 'Screenplay');
     $partners['ooyala'] = array('label' => 'Ooyala');
     foreach ($partners as &$partner) {
         $partner['url'] = GlobalTitle::newFromText($partner['label'], NS_CATEGORY, VideoHandlerHooks::VIDEO_WIKI)->getFullUrl();
     }
     // sort by keys, views need to be alphabetized
     ksort($partners);
     $this->partners = $partners;
 }
示例#15
0
/**
 * Render "centralhelpsearch" parser tag
 *
 * @return string
 */
function efCreateSearchForm()
{
    global $wgHelpWikiId;
    if (!empty($wgHelpWikiId)) {
        $helpSearchUrl = GlobalTitle::newFromText('Search', NS_SPECIAL, $wgHelpWikiId)->getFullURL();
    } else {
        $helpSearchUrl = SpecialPage::getTitleFor('Search')->getLocalURL();
    }
    $htmlOut = Xml::openElement('form', array('name' => 'bodyCentralSearch', 'id' => 'bodyCentralSearch', 'class' => 'bodyCentralSearch', 'action' => $helpSearchUrl));
    $htmlOut .= Xml::openElement('div', array('class' => 'bodyCentralSearchWrap', 'style' => 'margin: 20px auto; color: #999; width: 500px;'));
    $htmlOut .= Xml::element('input', array('type' => 'text', 'name' => 'search', 'size' => 50, 'placeholder' => wfMessage('centralhelpsearch-placeholder')->inContentLanguage()->plain(), 'style' => 'border:1px solid #999; padding: 10px; width: 500px; font-size: 20px;', 'id' => 'bodyCentralSearchInput'));
    $htmlOut .= Xml::element('input', array('type' => 'hidden', 'name' => 'ns12', 'value' => 1, 'checked' => 'checked', 'id' => 'mw-inputbox-ns12'));
    $htmlOut .= Html::hidden('fulltext', 'Search');
    $htmlOut .= Xml::closeElement('div');
    $htmlOut .= Xml::closeElement('form');
    return $htmlOut;
}
 function index()
 {
     if (!$this->wg->User->isAllowed('usermanagement')) {
         $this->skipRendering();
         throw new PermissionsError('usermanagement');
     }
     $this->setHeaders();
     $par = $this->getPar();
     $this->mUser = User::newFromName($par);
     $this->editCount = $this->mUser->getEditCount();
     $this->wikisEdited = '(coming soon)';
     $this->firstEdit = $this->wg->Lang->date($this->mUser->getFirstEditTimestamp());
     $this->lastEdit = $this->wg->Lang->date($this->mUser->getTouched());
     $this->email = $this->mUser->getEmail();
     $this->emailConfirmationDate = $this->wg->Lang->date($this->mUser->getEmailAuthenticationTimestamp());
     $this->emailSubscriptionStatus = !$this->mUser->getOption('unsubscribed', 0);
     // email delivery info
     $emailErrors = array();
     $lastEmailData = $this->getLastEmailDelivery();
     if (empty($lastEmailData)) {
         $this->emailLastDelivery = 'none';
     } else {
         $this->emailLastDelivery = $this->wg->Lang->date(wfTimestamp(TS_MW, $lastEmailData['transmitted']));
         /*
         			if ( $lastEmailData['is_bounce'] ) {
         				$this->emailError[] = "bounced";
         			}
         
         			if ( $lastEmailData['is_error'] ) {
         				$this->emailErrors[] = "error (" . $lastEmailData['error_status'] . "): " . $lastEmailData['error_msg'];
         			}
         
         			if ( $lastEmailData['is_spam'] ) {
         				$this->emailErrors[] = "marked as spam";
         			}
         */
         if (empty($emailErrors)) {
             $this->emailLastDeliveryStatus = '';
             // Wikia::successmsg( 'OK' );
         } else {
             $this->emailLastDeliveryStatus = Wikia::errormsg(implode(', ', $emailErrors));
         }
     }
     $this->emailChangeUrl = GlobalTitle::newFromText('EditAccount', NS_SPECIAL, 177)->getFullUrl() . '/' . $par;
     $this->emailChangeSubscriptionUrl = $this->emailChangeUrl;
 }
 /**
  * Called from maintenance script only.  Send Digest emails for any founders with that preference enabled
  * @param array $events
  */
 public function process(array $events)
 {
     global $wgTitle;
     wfProfileIn(__METHOD__);
     $wgTitle = Title::newMainPage();
     $founderEmailObj = FounderEmails::getInstance();
     // Get list of founders with digest mode turned on (defined in FounderEmailsEvent
     $cityList = $founderEmailObj->getFoundersWithPreference('founderemails-complete-digest');
     $wikiService = F::build('WikiService');
     foreach ($cityList as $cityID) {
         $user_ids = $wikiService->getWikiAdminIds($cityID);
         $foundingWiki = WikiFactory::getWikiById($cityID);
         $page_url = GlobalTitle::newFromText('WikiActivity', NS_SPECIAL, $cityID)->getFullUrl();
         $emailParams = array('$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$PAGEURL' => $page_url, '$UNIQUEVIEWS' => $founderEmailObj->getPageViews($cityID), '$USERJOINS' => $founderEmailObj->getNewUsers($cityID), '$USEREDITS' => $founderEmailObj->getDailyEdits($cityID));
         foreach ($user_ids as $user_id) {
             $user = User::newFromId($user_id);
             // skip if not enable
             if (!$this->enabled($cityID, $user)) {
                 continue;
             }
             self::addParamsUser($cityID, $user->getName(), $emailParams);
             $langCode = $user->getOption('language');
             // Only send digest emails for English users until translation is done
             if ($langCode == 'en') {
                 $links = array('$WIKINAME' => $emailParams['$WIKIURL']);
                 $mailSubject = strtr(wfMsgExt('founderemails-email-complete-digest-subject', array('content')), $emailParams);
                 $mailBody = strtr(wfMsgExt('founderemails-email-complete-digest-body', array('content', 'parsemag'), $emailParams['$UNIQUEVIEWS'], $emailParams['$USEREDITS'], $emailParams['$USERJOINS']), $emailParams);
                 $mailBodyHTML = F::app()->renderView("FounderEmails", "GeneralUpdate", array_merge($emailParams, array('language' => 'en', 'type' => 'complete-digest')));
                 $mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
                 $mailCategory = FounderEmailsEvent::CATEGORY_COMPLETE_DIGEST . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
                 // Only send email if there is some kind of activity to report
                 if ($emailParams['$UNIQUEVIEWS'] > 0 || $emailParams['$USERJOINS'] > 0 || $emailParams['$USEREDITS'] > 0) {
                     $founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $cityID, $mailCategory);
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * Get image list
  *
  * @param  integer $userId ID of the user to get the list for
  * @param  string  $from   Timestamp to get images before
  * @return array           List of images
  */
 public function getImageList($userId, $from = null)
 {
     wfProfileIn(__METHOD__);
     $imageList = [];
     $db = $this->getDatawareDB(DB_MASTER);
     $where = ['user_id' => $userId, 'state != ' . ImageReviewStatuses::STATE_DELETED . ' AND state != ' . ImageReviewStatuses::STATE_WIKI_DISABLED];
     $from = wfTimestampOrNull(TS_DB, $from);
     if (!empty($from)) {
         $where[] = 'last_edited < ' . $db->addQuotes($from);
     }
     $result = $db->select(['image_review'], ['wiki_id, page_id, state, flags, priority, last_edited'], $where, __METHOD__, ['ORDER BY' => 'last_edited desc', 'LIMIT' => self::LIMIT_IMAGES]);
     foreach ($result as $row) {
         $img = ImagesService::getImageSrc($row->wiki_id, $row->page_id);
         $wikiRow = WikiFactory::getWikiByID($row->wiki_id);
         $extension = pathinfo(strtolower($img['page']), PATHINFO_EXTENSION);
         $isThumb = true;
         if (empty($img['src'])) {
             // If we don't have a thumb by this point, we still need to display something, fall back to placeholder
             $globalTitle = GlobalTitle::newFromId($row->page_id, $row->wiki_id);
             if (is_object($globalTitle)) {
                 $img['page'] = $globalTitle->getFullUrl();
                 // @TODO this should be taken from the code instead of being hardcoded
                 $img['src'] = '//images.wikia.com/central/images/8/8c/Wikia_image_placeholder.png';
             } else {
                 // This should never happen
                 continue;
             }
         }
         if (in_array($extension, ['gif', 'svg'])) {
             $img = ImagesService::getImageOriginalUrl($row->wiki_id, $row->page_id);
             $isThumb = false;
         }
         $imageList[] = ['wikiId' => $row->wiki_id, 'pageId' => $row->page_id, 'state' => $row->state, 'src' => $img['src'], 'priority' => $row->priority, 'url' => $img['page'], 'isthumb' => $isThumb, 'flags' => $row->flags, 'wiki_url' => isset($wikiRow->city_url) ? $wikiRow->city_url : '', 'user_page' => '', 'last_edited' => $row->last_edited];
     }
     $db->freeResult($result);
     wfProfileOut(__METHOD__);
     return $imageList;
 }
示例#19
0
 public static function onLogLine($logType, $logaction, $title, $paramArray, &$comment, &$revert, $logTimestamp)
 {
     global $wgUser, $wgCityId;
     if (strpos($logaction, 'chatban') === 0) {
         $user = User::newFromId($paramArray[1]);
         if (!empty($user) && Chat::getBanInformation($wgCityId, $user) !== false && $wgUser->isAllowed('chatmoderator')) {
             $revert = "(" . "<a class='chat-change-ban' data-user-id='{$paramArray[1]}' href='#'>" . wfMsg('chat-ban-log-change-ban-link') . "</a>" . ")";
         }
     } elseif ($logaction === 'chatconnect' && !empty($paramArray)) {
         $ipLinks = array();
         if ($wgUser->isAllowed('multilookup')) {
             $mlTitle = GlobalTitle::newFromText('MultiLookup', NS_SPECIAL, 177);
             // Need to make the link manually for this as Linker's normaliseSpecialPage
             // makes the link local if the special page exists locally, rather than
             // keeping the global title
             $ipLinks[] = Xml::tags('a', array('href' => $mlTitle->getFullURL('target=' . urlencode($paramArray[0]))), wfMessage('multilookup')->escaped());
             $ipLinks[] = Linker::makeKnownLinkObj(GlobalTitle::newFromText('Phalanx', NS_SPECIAL, 177), wfMessage('phalanx')->escaped(), wfArrayToCGI(array('type' => '8', 'target' => $paramArray[0], 'wpPhalanxCheckBlocker' => $paramArray[0])));
             $ipLinks[] = Linker::blockLink(0, $paramArray[0]);
             $revert = '(' . implode(wfMessage('pipe-separator')->plain(), $ipLinks) . ')';
         }
     }
     return true;
 }
示例#20
0
 /**
  * Get redirect target
  *
  * @return GlobalTitle|false
  */
 public function getRedirectTarget()
 {
     $this->loadAll();
     if (!is_null($this->mRedirectTarget)) {
         return $this->mRedirectTarget;
     }
     $this->mRedirectTarget = false;
     if (WikiFactory::isPublic($this->mCityId)) {
         $dbName = WikiFactory::IDtoDB($this->mCityId);
         $dbr = wfGetDB(DB_SLAVE, array(), $dbName);
         $id = $dbr->selectField(array('page'), array('page_id'), array('page_title' => $this->mDbkeyform, 'page_namespace' => $this->mNamespace), __METHOD__);
         if ($id) {
             $row = $dbr->selectRow('redirect', array('rd_namespace', 'rd_title', 'rd_fragment', 'rd_interwiki'), array('rd_from' => $id), __METHOD__);
             if ($row) {
                 $this->mRedirectTarget = GlobalTitle::newFromText($row->rd_title, $row->rd_namespace, $this->mCityId);
             }
         }
     }
     return $this->mRedirectTarget;
 }
 /**
  * @param int $imageId
  * @param string $destinationName
  * @param int $targetWikiId
  * @param int $sourceWikiId
  * @return array
  */
 public function uploadSingleImage($imageId, $destinationName, $targetWikiId, $sourceWikiId)
 {
     global $IP;
     $imageTitle = \GlobalTitle::newFromId($imageId, $sourceWikiId);
     $sourceFile = \GlobalFile::newFromText($imageTitle->getText(), $sourceWikiId);
     if ($sourceFile->exists()) {
         $sourceImageUrl = $sourceFile->getUrl();
     } else {
         $this->error('image is not accessible', ['city_id' => $sourceWikiId, 'title' => $imageTitle->getText()]);
         return ['status' => 1];
     }
     $cityUrl = \WikiFactory::getVarValueByName("wgServer", $targetWikiId);
     if (empty($cityUrl)) {
         $this->error('unable to get wgServer', ['wiki_id' => $targetWikiId]);
         return ['status' => 1];
     }
     $destinationName = \PromoImage::fromPathname($destinationName)->ensureCityIdIsSet($sourceWikiId)->getPathname();
     $command = "SERVER_ID={$targetWikiId} php {$IP}/maintenance/wikia/ImageReview/PromoteImage/upload.php" . ' --originalimageurl=' . escapeshellarg($sourceImageUrl) . ' --destimagename=' . escapeshellarg($destinationName) . ' --wikiid=' . escapeshellarg($sourceWikiId);
     $output = wfShellExec($command, $exitStatus);
     if ($exitStatus) {
         $this->error('uploadSingleImage error', ['command' => $command, 'city_url' => $cityUrl, 'output' => $output, 'exitStatus' => $exitStatus]);
     } else {
         $this->info('uploadSingleImage success', ['output' => $output, 'src_img_url' => $sourceImageUrl, 'dest_name' => $destinationName]);
     }
     $output = json_decode($output);
     return ['status' => $exitStatus, 'name' => $output->name, 'id' => $output->id];
 }
 /**
  * Change the module used as an entry-point for Oasis skin and use custom class for rendering edit page
  *
  * Keep global and user nav only.
  *
  * @author macbre
  */
 function setupEditPage(Article $editedArticle, $fullScreen = true, $class = false)
 {
     global $wgHooks;
     wfProfileIn(__METHOD__);
     $user = $this->app->wg->User;
     // don't render edit area when we're in read only mode
     if (wfReadOnly()) {
         // set correct page title
         $this->out->setPageTitle(wfMessage('editing', $this->app->getGlobal('wgTitle')->getPrefixedText())->escaped());
         wfProfileOut(__METHOD__);
         return false;
     }
     // use "reskined" edit page layout
     $this->fullScreen = $fullScreen;
     if ($fullScreen) {
         // set Oasis entry-point
         Wikia::setVar('OasisEntryControllerName', 'EditPageLayout');
     }
     // Disable custom JS while loading the edit page on MediaWiki JS pages and user subpages (BugID: 41449)
     $editedArticleTitle = $editedArticle->getTitle();
     $editedArticleTitleNS = $editedArticleTitle->getNamespace();
     $editedArticleTitleText = $editedArticleTitle->getText();
     if ($editedArticleTitleNS === NS_MEDIAWIKI && substr($editedArticleTitleText, -3) === '.js' || $editedArticleTitleNS === NS_USER && preg_match('/^' . preg_quote($user->getName(), '/') . '\\/.*\\.js$/', $editedArticleTitleText)) {
         $this->out->disallowUserJs();
     }
     // Add variables for pages to edit code (css, js, lua)
     if ($this->isCodeSyntaxHighlightingEnabled($editedArticleTitle)) {
         $this->prepareVarsForCodePage($editedArticleTitle);
     }
     // initialize custom edit page
     $this->editPage = new EditPageLayout($editedArticle);
     $editedTitle = $this->editPage->getEditedTitle();
     $formCustomHandler = $this->editPage->getCustomFormHandler();
     $this->addJsVariable('wgIsEditPage', true);
     $this->addJsVariable('wgEditedTitle', $editedTitle->getPrefixedText());
     $this->addJsVariable('wgEditPageClass', $class ? $class : 'SpecialCustomEditPage');
     $this->addJsVariable('wgEditPageHandler', !is_null($formCustomHandler) ? $formCustomHandler->getLocalUrl('wpTitle=$1') : $this->app->getGlobal('wgScript') . '?action=ajax&rs=EditPageLayoutAjax&title=$1');
     $this->addJsVariable('wgEditPagePopularTemplates', TemplateService::getPromotedTemplates());
     $this->addJsVariable('wgEditPageIsWidePage', $this->isWidePage());
     $this->addJsVariable('wgIsDarkTheme', SassUtil::isThemeDark());
     if ($user->isLoggedIn()) {
         global $wgRTEDisablePreferencesChange;
         $wgRTEDisablePreferencesChange = true;
         $this->addJsVariable('wgEditPageWideSourceMode', (bool) $user->getGlobalPreference('editwidth'));
         unset($wgRTEDisablePreferencesChange);
     }
     $this->addJsVariableRef('wgEditPageFormType', $this->editPage->formtype);
     $this->addJsVariableRef('wgEditPageIsConflict', $this->editPage->isConflict);
     $this->addJsVariable('wgEditPageIsReadOnly', $this->editPage->isReadOnlyPage());
     $this->addJsVariableRef('wgEditPageHasEditPermissionError', $this->editPage->mHasPermissionError);
     $this->addJsVariableRef('wgEditPageSection', $this->editPage->section);
     // data for license module (BugId:6967)
     $titleLicensing = GlobalTitle::newFromText('Community_Central:Licensing', null, 177);
     $this->addJsVariable('wgEditPageLicensingUrl', $titleLicensing->getFullUrl());
     $this->addJsVariable('wgRightsText', $this->app->wg->RightsText);
     // copyright warning for notifications (BugId:7951)
     $this->addJsVariable('wgCopywarn', $this->editPage->getCopyrightNotice());
     // extra hooks for edit page
     $wgHooks['MakeGlobalVariablesScript'][] = 'EditPageLayoutHooks::onMakeGlobalVariablesScript';
     $wgHooks['SkinGetPageClasses'][] = 'EditPageLayoutHooks::onSkinGetPageClasses';
     $this->helper = self::getInstance();
     wfProfileOut(__METHOD__);
     return $this->editPage;
 }
示例#23
0
function wfMakeHelperSignature($contents, $attributes, $parser)
{
    $title = GlobalTitle::newFromText('Helper_Group', 12, 177);
    return wfMakeSignatureCommon($title->getFullURL(), "This user is a Wikia Helper");
}
 public function getLandingParams()
 {
     return GlobalTitle::explodeURL($this->landingTitle);
 }
示例#25
0
    }
    echo "</strong>";
}
?>
		<sup><a href="<?php 
echo "{$wikiFactoryUrl}/{$wiki->city_id}";
?>
/tags">edit</a></sup>
	</li>
	<?php 
if ($wiki->city_public <= 0) {
    ?>
<li>
		<div>Disabled reason: <?php 
    echo wfMsg('closed-reason');
    ?>
 (<?php 
    echo $wiki->city_additional;
    ?>
)</div>
	</li><?php 
}
?>
	<li>
		<?php 
$pstats = GlobalTitle::newFromText("PhalanxStats/wiki/" . $wiki->city_id, NS_SPECIAL, 177);
print "<a href=\"" . $pstats->getFullURL() . "\">Phalanx activity</a>\n";
?>
	</li>
</ul>
 function sendMail($commandLineOptions, $jobOptions, $wikiId, $wikiData)
 {
     global $wgSitename;
     $wiki = WikiFactory::getWikiByID($wikiId);
     $magicwords = array('#WIKINAME' => $wiki->city_title);
     $flags = WikiFactory::getFlags($wikiId);
     $flag = $jobOptions['mailType'] == 'first' ? WikiFactory::FLAG_ADOPT_MAIL_FIRST : WikiFactory::FLAG_ADOPT_MAIL_SECOND;
     //this kind of e-mail already sent for this wiki
     if ($flags & $flag) {
         return;
     }
     $globalTitleUserRights = GlobalTitle::newFromText('UserRights', -1, $wikiId);
     $specialUserRightsUrl = $globalTitleUserRights->getFullURL();
     $globalTitlePreferences = GlobalTitle::newFromText('Preferences', -1, $wikiId);
     $specialPreferencesUrl = $globalTitlePreferences->getFullURL();
     //at least one admin has not edited during xx days
     foreach ($wikiData['admins'] as $adminId) {
         //print info
         if (!isset($commandLineOptions['quiet'])) {
             echo "Trying to send the e-mail to the user (id:{$adminId}) on wiki (id:{$wikiId}).\n";
         }
         $adminUser = User::newFromId($adminId);
         $defaultOption = null;
         if ($wikiId > 194785) {
             $defaultOption = 1;
         }
         $acceptMails = $adminUser->getOption("adoptionmails-{$wikiId}", $defaultOption);
         if ($acceptMails && $adminUser->isEmailConfirmed()) {
             $adminName = $adminUser->getName();
             if (!isset($commandLineOptions['quiet'])) {
                 echo "Sending the e-mail to the user (id:{$adminId}, name:{$adminName}) on wiki (id:{$wikiId}).\n";
             }
             if (!isset($commandLineOptions['dryrun'])) {
                 echo "Really Sending the e-mail to the user (id:{$adminId}, name:{$adminName}) on wiki (id:{$wikiId}).\n";
                 $adminUser->sendMail(strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-subject"), $magicwords), strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-content", $adminName, $specialUserRightsUrl, $specialPreferencesUrl), $magicwords), null, null, 'AutomaticWikiAdoption', strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-content-HTML", $adminName, $specialUserRightsUrl, $specialPreferencesUrl), $magicwords));
             }
         }
     }
     if (!isset($commandLineOptions['dryrun'])) {
         WikiFactory::setFlags($wikiId, $flag);
     }
 }
示例#27
0
/**
 * Add a link to central:Special:Phalanx from Special:Contributions/USERNAME
 * if the user has 'phalanx' permission
 * @param $id Integer: user ID
 * @param $nt Title: user page title
 * @param $links Array: tool links
 * @return true
 */
function efLoadPhalanxLink($id, $nt, &$links)
{
    global $wgUser;
    if ($wgUser->isAllowed('phalanx')) {
        $links[] = RequestContext::getMain()->getSkin()->makeKnownLinkObj(GlobalTitle::newFromText('Phalanx', NS_SPECIAL, 177), 'PhalanxBlock', wfArrayToCGI(array('type' => '8', 'target' => $nt->getText(), 'wpPhalanxCheckBlocker' => $nt->getText())));
    }
    return true;
}
示例#28
0
 /**
  * Add a link to Special:LookupUser from Special:Contributions/USERNAME
  * if the user has 'lookupuser' permission on wikis other than Central
  * since the extension is only enabled there (BugID: 47807)
  *
  * @author grunny
  * @param integer $id User identifier
  * @param Title $title User page title
  * @param Array $tools An array of tool links
  * @return bool true
  */
 public static function onContributionsToolLinks($id, $title, &$links)
 {
     global $wgUser, $wgCityId;
     if ($wgCityId !== '177' && $id !== 0 && $wgUser->isAllowed('lookupuser')) {
         $links[] = Linker::linkKnown(GlobalTitle::newFromText('LookupUser', NS_SPECIAL, 177), wfMsgHtml('lookupuser'), array(), array('target' => $title->getText()));
     }
     return true;
 }
示例#29
0
 protected function createTitle($text, $wikiId)
 {
     return GlobalTitle::newFromText($text, NS_MAIN, $wikiId);
 }
 public function outputResults($skin, $data)
 {
     global $wgContLang, $wgLang, $wgOut;
     wfProfileIn(__METHOD__);
     $num = 0;
     $html = array();
     if ($this->mShow) {
         $wgOut->addHTML(XML::openElement('div', array('class' => 'mw-spcontent')));
     }
     if (isset($data) && $data['numrec'] > 0) {
         $num = $data['numrec'];
         if ($this->mShow) {
             $html[] = XML::openElement('ol', array('start' => $this->offset + 1, 'class' => 'special'));
         }
         if ($data['numrec'] <= self::ORDER_ROWS) {
             arsort($data['order']);
         }
         $loop = 0;
         $skip = 0;
         foreach ($data['order'] as $city_id => $ordered) {
             # check loop
             if ($loop >= $this->offset && $loop < $this->limit + $this->offset) {
                 list($page_id, $page_url, $page_server) = $data['rows'][$city_id];
                 # page url
                 if (empty($page_url) || empty($page_server)) {
                     $oGTitle = GlobalTitle::newFromText($this->mPageTitle, $this->mPageNS, $city_id);
                     if (is_object($oGTitle)) {
                         $page_url = $oGTitle->getFullURL();
                         $page_server = $oGTitle->getServer();
                     }
                     if (empty($page_url) || empty($page_server)) {
                         $skip++;
                         continue;
                     }
                 }
                 # check Wiki
                 if (!empty($city_id)) {
                     $oWikia = WikiFactory::getWikiByID($city_id);
                     if (empty($oWikia) || empty($oWikia->city_public)) {
                         continue;
                     }
                 }
                 if (empty($this->mShow)) {
                     $res = "";
                     $this->data[$city_id] = array('city_id' => $city_id, 'page_id' => $page_id, 'url' => $page_url);
                 } else {
                     $res = wfSpecialList(Xml::openElement('a', array('href' => $page_url)) . $page_url . Xml::closeElement('a'), "");
                 }
                 $html[] = $this->mShow ? Xml::openElement('li') . $res . Xml::closeElement('li') : "";
             }
             $loop++;
         }
         $num = $num - $skip;
         if ($this->mShow) {
             $html[] = XML::closeElement('ol');
         }
     }
     # Top header and navigation
     if ($this->mShow) {
         $wgOut->addHTML('<p>' . wfMsgExt('multiwikirecords', array(), $num) . '</p>');
         if ($num > 0) {
             $wgOut->addHTML('<p>' . wfShowingResults($this->offset, $num) . '</p>');
             # Disable the "next" link when we reach the end
             $paging = $wgLang->viewPrevNext(SpecialPage::getTitleFor($this->mName), $this->offset, $this->limit, $this->linkParameters(), $num < $this->limit);
             $wgOut->addHTML('<p>' . $paging . '</p>');
         } else {
             $wgOut->addHTML(XML::closeElement('div'));
             return;
         }
     }
     $html = $this->mShow ? implode('', $html) : $wgContLang->listToText($html);
     $wgOut->addHTML($html);
     # Repeat the paging links at the bottom
     if ($this->mShow) {
         $wgOut->addHTML('<p>' . $paging . '</p>');
     }
     $wgOut->addHTML(XML::closeElement('div'));
     wfProfileOut(__METHOD__);
     return $num;
 }