/**
  * 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__);
 }
Ejemplo n.º 2
0
 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']);
             }
         }
     }
 }
Ejemplo n.º 3
0
/**
 * 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"));
}
Ejemplo n.º 4
0
 protected static function getArticleIdFromTitle($cityId, $title)
 {
     $title = GlobalTitle::newFromText($title, NS_FILE, $cityId);
     if ($title->exists()) {
         return $title->getArticleID();
     }
     return false;
 }
Ejemplo n.º 5
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;
 }
 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;
 }
Ejemplo n.º 8
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");
 }
 protected function normalizeLink($link)
 {
     if (strpos($link, 'http://') === 0) {
         return $link;
     }
     if (preg_match('/^\\/wiki\\/.+$/', $link)) {
         $pageTitle = preg_replace('/^\\/wiki\\/(.+)$/', '$1', $link);
         $pageTitle = urldecode($pageTitle);
         $title = GlobalTitle::newFromText($pageTitle, NS_MAIN, self::STAR_WARS_WIKIA_ID);
         if ($title) {
             $link = $title->getFullUrl();
         }
     }
     return $link;
 }
 /**
  * @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;
 }
Ejemplo n.º 11
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__);
 }
 function getCustomSettings()
 {
     global $wgExternalSharedDB;
     $city_list = 'city_list';
     $cv = 'city_variables';
     $cv_pool = 'city_variables_pool';
     $dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
     $res = $dbr->select(array($city_list, $cv, $cv_pool), array('cv_value', 'city_url', 'city_id'), array("{$city_list}.city_id = {$cv}.cv_city_id", "{$cv}.cv_variable_id = {$cv_pool}.cv_id", "{$cv_pool}.cv_id     = '{$this->varid}'"), __METHOD__);
     $variable = WikiFactory::getVarById($this->varid, 0);
     $data = array();
     $values = array();
     $row_count = $dbr->numRows($res);
     if ($row_count == 0) {
         $dbr->freeResult($res);
         $out = "no settings found in WikiFactory\n";
         return $out;
     }
     $this->over_limit = false;
     if ($row_count > 1000) {
         $this->over_limit = true;
     }
     if ($this->disable_limit) {
         $this->over_limit = false;
     }
     while ($row = $dbr->fetchObject($res)) {
         $city_id = $row->city_id;
         $cv_value = unserialize($row->cv_value);
         $nom_value = $cv_value;
         if (is_array($cv_value)) {
             asort($cv_value);
             $cv_value = join(', ', $cv_value);
             $nom_value = 'array';
         } elseif (is_bool($cv_value)) {
             $cv_value = $cv_value ? 'true' : 'false';
             $nom_value = $cv_value;
         } else {
             #$cv_value = 'Error. Not an array?!?';
         }
         if (preg_match('/http:\\/\\/([\\w\\.\\-]+)\\//', $row->city_url, $matches)) {
             $city_url = str_ireplace('.wikia.com', '', $matches[1]);
         } else {
             $city_url = 'Error. Unknown wiki?!?';
         }
         if (!empty($cv_value)) {
             if (count($data) <= 1000 || $this->disable_limit) {
                 $data[] = array('value' => $cv_value, 'url' => $city_url, 'city' => $city_id);
             }
             $values[] = $nom_value;
         }
     }
     $dbr->freeResult($res);
     $acv = array_count_values($values);
     asort($acv);
     unset($values);
     global $wgCityId;
     if ($wgCityId == 177) {
         #we're on central (or are faking it), so link locallly
         $WF_title = SpecialPage::getTitleFor('WikiFactory');
         $wie_title = SpecialPage::getTitleFor('WhereIsExtension');
     } else {
         #we're away from home, so make sure the links link back right
         $WF_title = GlobalTitle::newFromText('WikiFactory', NS_SPECIAL, 177);
         $wie_title = GlobalTitle::newFromText('WhereIsExtension', NS_SPECIAL, 177);
     }
     $wie_query = array('var' => $variable->cv_variable_id, 'searchType' => 'full', 'val' => 0);
     #likeValue is appended manually inside the template;
     $wie_base = $wie_title->getFullURL(http_build_query($wie_query));
     unset($wie_query);
     unset($wie_title);
     $limit_message = '';
     if ($this->over_limit) {
         $limit_message = Wikia::errorbox("Warning, this variable has {$row_count} entries. Only first 1000 shown");
         $QS = http_build_query(array('varid' => $variable->cv_variable_id, 'nolimit' => 1));
         $limit_message .= "<a href='/index.php?title=Special:WikiFactoryReporter&{$QS}'>Click here to load all results</a>\n";
     }
     $groups = WikiFactory::getGroups();
     $variable->var_group = $groups[$variable->cv_variable_group];
     unset($groups);
     $sprites = array('search' => "<img src='" . wfBlankImgUrl() . "' class='sprite search' alt='search' height='16' width='22'>", 'edit' => "<img src='" . wfBlankImgUrl() . "' class='sprite edit-pencil' alt='edit'>");
     $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $tmpl->set_vars(array('th' => array($variable->cv_name, 'wiki', 'city_id'), 'data' => $data, 'variable' => $variable, 'acv' => $acv, 'wf_base' => $WF_title->getFullUrl(), 'limit_message' => $limit_message, 'sprites' => $sprites, 'wie_base' => $wie_base));
     $out = $tmpl->render('reporter');
     return $out;
 }
Ejemplo n.º 15
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>
 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;
 }
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
0
 protected function getNewFilesUrl($wikiId)
 {
     $globalNewFilesTitle = GlobalTitle::newFromText('NewFiles', NS_SPECIAL, $wikiId);
     if ($globalNewFilesTitle instanceof Title) {
         $newFilesUrl = $globalNewFilesTitle->getFullURL();
         return $newFilesUrl;
     } else {
         $newFilesUrl = '#';
         return $newFilesUrl;
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 20
0
 /**
  * blogs
  */
 private function makeBlogsList(&$aWikiDigest, $iWikiId, $oResultRow)
 {
     $blogTitle = $oResultRow->gwa_title;
     if ($oResultRow->gwa_namespace == NS_BLOG_ARTICLE_TALK) {
         $parts = ArticleComment::explode($oResultRow->gwa_title);
         $blogTitle = $parts['title'];
     }
     if (empty($blogTitle)) {
         return false;
     }
     if (empty($aWikiDigest['blogs'][$blogTitle])) {
         $wikiDB = WikiFactory::IDtoDB($oResultRow->gwa_city_id);
         if ($wikiDB) {
             $db_wiki = wfGetDB(DB_SLAVE, 'stats', $wikiDB);
             $like_title = $db_wiki->buildLike($oResultRow->gwa_title, $db_wiki->anyString());
             if ($db_wiki && $like_title) {
                 $oRow = $db_wiki->selectRow(array("watchlist"), array("count(*) as cnt"), array("wl_namespace = '" . NS_BLOG_ARTICLE_TALK . "'", "wl_title {$like_title}", "wl_notificationtimestamp is not null", "wl_notificationtimestamp >= '" . $oResultRow->gwa_timestamp . "'", "wl_user > 0"), __METHOD__);
                 $aWikiDigest['blogs'][$blogTitle] = array('comments' => intval($oRow->cnt), 'blogpage' => GlobalTitle::newFromText($blogTitle, NS_BLOG_ARTICLE, $iWikiId), 'own_comments' => 0);
                 if (!in_array($wikiDB, array('wikicities', 'messaging'))) {
                     $db_wiki->close();
                 }
             }
         }
     }
     if ($oResultRow->gwa_namespace == NS_BLOG_ARTICLE_TALK && isset($aWikiDigest['blogs'][$blogTitle])) {
         $aWikiDigest['blogs'][$blogTitle]['own_comments']++;
     }
 }
Ejemplo n.º 21
0
function wfMakeHelperSignature($contents, $attributes, $parser)
{
    $title = GlobalTitle::newFromText('Helper_Group', 12, 177);
    return wfMakeSignatureCommon($title->getFullURL(), "This user is a Wikia Helper");
}
 /**
  * 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;
 }
 /**
  * Returns full URL for a wiki with given $cityId
  * @param String $text
  * @param Integer $namespace
  * @param Integer|null $cityId
  * @return string
  */
 protected function getWikiPageUrl($text, $namespace = NS_MAIN, $cityId = null)
 {
     return GlobalTitle::newFromText($text, $namespace, $cityId)->getFullURL();
 }
Ejemplo n.º 24
0
 function formatRow($row)
 {
     global $wgLang;
     $name = Xml::tags('a', array('href' => $row->city_url), $row->city_title);
     if ($this->more_details) {
         $cuTitle = GlobalTitle::newFromText('CheckUser', NS_SPECIAL, $row->city_id);
         $userLink = Xml::tags('a', array('href' => $cuTitle->getFullURL('user='******'LookupUser', NS_SPECIAL), $row->user_email, array(), 'target=' . urlencode($row->user_email));
         $confirm = $row->user_email_authenticated ? 'Y' : 'N';
         $detail = "{$row->city_lang}, {$row->city_created}, FounderName:{$userLink}, Email:{$emailLink}, Confirm:{$confirm}";
         //FB#11896
         if (!empty($row->city_founding_ip)) {
             $ipMlLink = $this->linker->link(Title::newFromText('MultiLookup', NS_SPECIAL), long2ip($row->city_founding_ip), array(), 'target=' . urlencode(long2ip($row->city_founding_ip)));
             $detail .= ", IP:{$ipMlLink}";
         }
     } else {
         $detail = $row->city_lang;
     }
     $item = wfSpecialList($name, $detail);
     return "<li>{$item}</li>";
 }
Ejemplo n.º 25
0
 /**
  * @desc Create a full url to a file using global title
  * as wfFindFile may return a foreign file
  *
  * @param $fileName
  * @param File $file
  * @return string
  * @throws Exception
  */
 private function getFileUrl($fileName, File $file)
 {
     return GlobalTitle::newFromText($fileName, NS_FILE, $this->getFileCityId($file))->getFullUrl();
 }
Ejemplo n.º 26
0
 protected function createTitle($text, $wikiId)
 {
     return GlobalTitle::newFromText($text, NS_MAIN, $wikiId);
 }
Ejemplo n.º 27
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;
 }
Ejemplo n.º 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;
 }
 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);
     }
 }
Ejemplo n.º 30
0
 /**
  * @desc Returns an array with correct elements from given api results
  *
  * @param array $postData results from API call with request of posts (articles) list in a category
  *
  * @return array
  */
 private function prepareCssUpdateData($postData)
 {
     $cssUpdatePost = [];
     $communityWikiId = WikiFactory::DBtoID($this->getCommunityDbName());
     $blogTitle = GlobalTitle::newFromText($postData['title'], NS_MAIN, $communityWikiId);
     $blogTitleText = $blogTitle->getText();
     $lastRevisionUser = isset($postData['revisions'][0]['user']) ? $postData['revisions'][0]['user'] : null;
     $timestamp = isset($postData['revisions'][0]['timestamp']) ? $postData['revisions'][0]['timestamp'] : null;
     $blogUser = $this->getUserFromTitleText($blogTitleText, $lastRevisionUser);
     $userPage = GlobalTitle::newFromText($blogUser, NS_USER, $communityWikiId);
     if (!is_null($lastRevisionUser) && !is_null($timestamp) && $blogTitle instanceof GlobalTitle && $userPage instanceof GlobalTitle) {
         // $postData['revisions'][0]['*'] is being checked in SpecialCssModel::filterRevisionsData()
         // which is called before this method
         $sectionText = $postData['revisions'][0]['*'];
         $cssUpdateText = $this->truncateAndParseLinks($this->getCssUpdateSection($sectionText));
         $cssUpdatePost = ['title' => $this->getAfterLastSlashText($blogTitleText), 'url' => $this->appendHeadlineAnchor($blogTitle->getFullURL()), 'userAvatar' => AvatarService::renderAvatar($blogUser, 25), 'userUrl' => $userPage->getFullUrl(), 'userName' => $blogUser, 'timestamp' => $timestamp, 'text' => $cssUpdateText];
     }
     return $cssUpdatePost;
 }