本文整理汇总了PHP中WikiFactory::getLocalEnvURL方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::getLocalEnvURL方法的具体用法?PHP WikiFactory::getLocalEnvURL怎么用?PHP WikiFactory::getLocalEnvURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::getLocalEnvURL方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetLocalEnvURL
/**
* @dataProvider testGetLocalEnvURLDataProvider
*/
public function testGetLocalEnvURL($env, $url, $expected)
{
$_SERVER['SERVER_NAME'] = $env;
$url = WikiFactory::getLocalEnvURL($url);
$this->assertEquals($expected, $url);
$_SERVER['SERVER_NAME'] = null;
}
示例2: emailFollowNotifications
public function emailFollowNotifications($initiatingUser, $aWatchers, $iUserId, $iNamespace, $sMessage, $sAction)
{
$wg = F::app()->wg;
$wg->DBname = WikiFactory::IDtoDB($this->getWikiId());
$wg->Server = trim(WikiFactory::DBtoUrl(F::app()->wg->DBname), '/');
if (!empty($wg->DevelEnvironment)) {
$wg->Server = WikiFactory::getLocalEnvURL($wg->Server);
}
$wg->User = User::newFromId($initiatingUser);
$targetUser = User::newFromId($iUserId);
$this->logWatchers($aWatchers, $sAction);
foreach ($aWatchers as $sKey => $sValue) {
$oTitle = Title::makeTitle($iNamespace, $sKey);
$oEmailNotification = new EmailNotification($targetUser, $oTitle, wfTimestampNow(), $sMessage, false, $currentRevId = 0, $previousRevId = 0, $sAction, ['notisnull' => 1, 'childTitle' => $this->title]);
$oEmailNotification->notifyOnPageChange();
}
}
示例3: loadServer
/**
* loadServer
*
* Determine wgServer value from WikiFactory variables
*
* @return string
*/
private function loadServer()
{
/**
* don't do this twice
*/
if ($this->mServer) {
return $this->mServer;
}
$server = WikiFactory::getVarValueByName("wgServer", $this->mCityId);
/**
* special handling for dev boxes
*
* @author macbre
*/
global $wgDevelEnvironment;
if (!empty($wgDevelEnvironment)) {
$this->mServer = WikiFactory::getLocalEnvURL($server);
return $this->mServer;
}
/**
* get value from city_variables
*/
if ($server) {
$this->mServer = $server;
return $server;
}
/**
* get value from city_list.city_url
*/
$city = WikiFactory::getWikiByID($this->mCityId);
/**
* if we got this far and not have a value, ask master
*/
if (empty($city)) {
$city = WikiFactory::getWikiByID($this->mCityId, true);
}
if ($city) {
$server = rtrim($city->city_url, "/");
$this->mServer = $server;
return $server;
}
return false;
}
示例4: saveVideo
/**
* After all the video meta data and categories have been prepared, upload the video
* onto Wikia.
* @return int
*/
public function saveVideo()
{
$body = $this->prepareBodyString();
if ($this->debugMode()) {
$this->printReadyToSaveData($body);
$msg = "Ingested {$this->metaData['destinationTitle']} (id: {$this->metaData['videoId']}).\n";
$this->logger->videoIngested($msg, $this->pageCategories);
return 1;
} else {
/** @var Title $uploadedTitle */
$uploadedTitle = null;
$result = VideoFileUploader::uploadVideo($this->metaData['provider'], $this->metaData['videoId'], $uploadedTitle, $body, false, $this->metaData);
if ($result->ok) {
$fullUrl = WikiFactory::getLocalEnvURL($uploadedTitle->getFullURL());
$msg = "Ingested {$uploadedTitle->getText()} from partner clip id {$this->metaData['videoId']}. {$fullUrl}\n";
$this->logger->videoIngested($msg, $this->pageCategories);
wfWaitForSlaves();
wfRunHooks('VideoIngestionComplete', [$uploadedTitle, $this->pageCategories]);
return 1;
}
}
$this->logger->videoWarnings();
return 0;
}
示例5: while
$count = 0;
while($row = $dbw->fetchObject($rows)) {
$count++;
//if($count>30) break;
$name = $row->img_name;
$title = Title::newFromText($name, NS_FILE);
if($onlyEnt && !isset($cachecategories[$title->getArticleID()]) ) {
continue;
}
$wgTitle = $title;
$file = wfFindFile( $name );
if( $file->exists() ) {
//echo "working on $name\n";
$url = WikiFactory::getLocalEnvURL($title->getFullUrl());
$row->url = $url;
$meta = $row->img_metadata;
$metaU = unserialize($meta);
$row->title = $metaU['title'];
$row->cat = $metaU['category'];
$all[$name] = $row;
if($onlyEnt) {
$found = false;
$key2 = $metaU['category'];
if(!isset($by_category2[$key2])) {
$by_category2[$key2] = array();
}
$by_category2[$key2][] = $name;
}
示例6: createVideo
public function createVideo(array $data, &$msg, $params = array())
{
wfProfileIn(__METHOD__);
$debug = !empty($params['debug']);
$ignoreRecent = !empty($params['ignorerecent']) ? $params['ignorerecent'] : 0;
if ($debug) {
print "data after initial processing: \n";
foreach (explode("\n", var_export($data, 1)) as $line) {
print ":: {$line}\n";
}
}
$addlCategories = !empty($params['addlCategories']) ? $params['addlCategories'] : array();
$id = $data['videoId'];
$name = $this->generateName($data);
$metadata = $this->generateMetadata($data, $msg);
if (!empty($msg)) {
print "Error when generating metadata\n";
var_dump($msg);
wfProfileOut(__METHOD__);
return 0;
}
$duplicates = WikiaFileHelper::findVideoDuplicates(static::$PROVIDER, $id);
$dup_count = count($duplicates);
$previousFile = null;
if ($dup_count > 0) {
if ($this->reupload === false) {
// if reupload is disabled finish now
if ($debug) {
print "Not uploading - video already exists and reupload is disabled\n";
}
return 0;
}
// if there are duplicates use name of one of them as reference
// instead of generating new one
$name = $duplicates[0]['img_name'];
echo "Video already exists, using it's old name: {$name}\n";
$previousFile = Title::newFromText($name, NS_FILE);
} else {
// sanitize name
$name = VideoFileUploader::sanitizeTitle($name);
// make sure the name is unique
$name = $this->getUniqueName($name);
}
$metadata['destinationTitle'] = $name;
if (!$this->validateTitle($id, $name, $msg, $debug)) {
wfProfileOut(__METHOD__);
return 0;
}
// prepare wiki categories string (eg [[Category:MyCategory]] )
$categories = $this->generateCategories($data, $addlCategories);
$categories[] = wfMsgForContent('videohandler-category');
$categories = array_unique($categories);
$categoryStr = '';
foreach ($categories as $categoryName) {
$category = Category::newFromName($categoryName);
if ($category instanceof Category) {
$categoryStr .= '[[' . $category->getTitle()->getFullText() . ']]';
}
}
// parepare article body
$apiWrapper = new static::$API_WRAPPER($id, $metadata);
$descriptionHeader = '==' . F::app()->wf->Msg('videohandler-description') . '==';
$body = $categoryStr . "\n" . $descriptionHeader . "\n" . $apiWrapper->getDescription();
if ($debug) {
print "Ready to create video\n";
print "id: {$id}\n";
print "name: {$name}\n";
print "categories: " . implode(',', $categories) . "\n";
print "metadata:\n";
foreach (explode("\n", var_export($metadata, 1)) as $line) {
print ":: {$line}\n";
}
print "body:\n";
foreach (explode("\n", $body) as $line) {
print ":: {$line}\n";
}
wfProfileOut(__METHOD__);
return 1;
} else {
if (!empty($ignoreRecent) && !is_null($previousFile)) {
$revId = $previousFile->getLatestRevID();
$revision = Revision::newFromId($revId);
$time = $revision->getTimestamp();
$timeUnix = intval(wfTimestamp(TS_UNIX, $time));
$timeNow = intval(wfTimestamp(TS_UNIX, time()));
if ($timeUnix + $ignoreRecent >= $timeNow) {
print "Recently uploaded, ignoring\n";
return 0;
}
}
$uploadedTitle = null;
$result = VideoFileUploader::uploadVideo(static::$PROVIDER, $id, $uploadedTitle, $body, false, $metadata);
if ($result->ok) {
$fullUrl = WikiFactory::getLocalEnvURL($uploadedTitle->getFullURL());
print "Ingested {$uploadedTitle->getText()} from partner clip id {$id}. {$fullUrl}\n\n";
wfWaitForSlaves(self::THROTTLE_INTERVAL);
wfProfileOut(__METHOD__);
return 1;
}
}
//.........这里部分代码省略.........
示例7: fetchContributionsDataTables
public function fetchContributionsDataTables()
{
wfProfileIn(__METHOD__);
//error_log( "start" );
$aColumns = array('rev_timestamp', 'user_id', 'event_type', 'wiki_id', 'page_id', 'page_ns', 'rev_size', 'rev_id', 'ip');
$dbr = $this->getDb(DB_SLAVE);
$users = explode(",", $_GET['users']);
$users = array_map("intval", $users);
$limitS = 0;
$limitL = 10;
if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') {
$limitS = mysql_real_escape_string($_GET['iDisplayStart']);
$limitL = mysql_real_escape_string($_GET['iDisplayLength']);
}
$orderBy = array();
if (isset($_GET['iSortCol_0'])) {
for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) {
if ($_GET['bSortable_' . intval($_GET['iSortCol_' . $i])] == "true") {
$orderBy[] = $aColumns[intval($_GET['iSortCol_' . $i])] . " " . mysql_real_escape_string($_GET['sSortDir_' . $i]);
}
}
}
$results = array();
$table = array('events');
$vars = $aColumns;
$conds = array('user_id' => $users);
if (!empty($orderBy)) {
$options = array('LIMIT' => $limitL, 'OFFSET' => $limitS, 'ORDER BY' => implode(",", $orderBy));
} else {
$options = array('LIMIT' => $limitL, 'OFFSET' => $limitS);
}
$res = $dbr->select($table, 'COUNT(1) as c', $conds, __METHOD__);
$row = $dbr->fetchRow($res);
$iTotal = $row['c'];
//error_log( $iTotal );
$iFilteredTotal = $iTotal;
$output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array());
$res = $dbr->select($table, $vars, $conds, __METHOD__, $options);
while ($row = $dbr->fetchRow($res)) {
$wiki = WikiFactory::getWikiById($row['wiki_id']);
if (is_object($wiki) && $wiki->city_public != 0) {
$wikiSitename = WikiFactory::getVarValueByName('wgSitename', $row['wiki_id']);
$url = WikiFactory::getLocalEnvURL($wiki->city_url);
$wikiLink = Xml::element('a', array('class' => 'wiki_name', 'href' => $url), $wikiSitename);
$row['wiki_id'] = $wikiLink . Xml::element('span', array('class' => 'wiki_id'), $row['wiki_id']);
if (!empty($row['user_id'])) {
$name = User::newFromId($row['user_id'])->getName();
} else {
$name = long2ip($row['ip']);
}
$nameLink = Xml::element('a', array('class' => 'user_name', 'href' => GlobalTitle::newFromText($name, NS_USER, $wiki->city_id)->getFullURL()), $name);
$row['user_id'] = $nameLink . Xml::element('span', array('class' => 'user_id'), $row['user_id']);
global $wgDevelEnvironment;
$pageId = $row['page_id'];
$row['page_id'] = 'db not found' . Xml::element('span', array('class' => 'page_id'), $row['page_id']);
if (!$wgDevelEnvironment) {
$title = GlobalTitle::newFromId($row['page_id'], $wiki->city_id);
if (is_object($title)) {
$pageLink = Xml::element('a', array('class' => 'page_name', 'href' => $title->getFullURL()), $title->getPrefixedText());
$row['page_id'] = $pageLink . Xml::element('span', array('class' => 'page_id'), $row['page_id']);
}
}
}
$row['ip'] = long2ip($row['ip']);
$rawtimestamp = wfTimestamp(TS_ISO_8601, $row['rev_timestamp']);
$reltimestamp = Xml::element('div', array('class' => "timeago", 'title' => $rawtimestamp), '.');
$row['rev_timestamp'] .= " " . $reltimestamp;
$namespaceName = MWNamespace::getCanonicalName($row['page_ns']);
if ($namespaceName) {
$row['page_ns'] = $namespaceName;
} elseif ($row['page_ns'] == NS_MAIN) {
$row['page_ns'] = 'main';
}
switch ($row['event_type']) {
case ScribeEventProducer::EDIT_CATEGORY_INT:
$row['event_type'] = 'edit';
break;
case ScribeEventProducer::CREATEPAGE_CATEGORY_INT:
$row['event_type'] = 'create';
break;
case ScribeEventProducer::DELETE_CATEGORY_INT:
$row['event_type'] = 'delete';
break;
case ScribeEventProducer::UNDELETE_CATEGORY_INT:
$row['event_type'] = 'undelete';
}
$output_row = array();
for ($i = 0; $i < count($aColumns); $i++) {
$output_row[] = $row[$aColumns[$i]];
}
$output['aaData'][] = $output_row;
}
echo json_encode($output);
$this->skipRendering();
wfProfileOut(__METHOD__);
return false;
}
示例8: loadFromOurCDN
protected static function loadFromOurCDN()
{
$scriptDomain = WikiFactory::getLocalEnvURL(WikiFactory::getVarValueByName('wgServer', Wikia::COMMUNITY_WIKI_ID));
return '<script src="' . $scriptDomain . '/wikia.php?controller=Optimizely&method=getCode"></script>';
}
示例9: executeIndex
public function executeIndex()
{
global $wgUser, $wgDevelEnvironment, $wgRequest, $wgCityId, $wgFavicon, $wgOut;
wfProfileIn(__METHOD__);
// String replacement logic taken from includes/Skin.php
$this->wgFavicon = str_replace('images.wikia.com', 'images1.wikia.nocookie.net', $wgFavicon);
$this->mainPageURL = Title::newMainPage()->getLocalURL();
// add messages (fetch them using <script> tag)
F::build('JSMessages')->enqueuePackage('Chat', JSMessages::EXTERNAL);
// package defined in Chat_setup.php
$this->jsMessagePackagesUrl = F::build('JSMessages')->getExternalPackagesUrl();
// Variables for this user
$this->username = $wgUser->getName();
$this->avatarUrl = AvatarService::getAvatarUrl($this->username, ChatController::CHAT_AVATAR_DIMENSION);
// Find the chat for this wiki (or create it, if it isn't there yet).
$roomName = $roomTopic = "";
$this->roomId = (int) NodeApiClient::getDefaultRoomId($roomName, $roomTopic);
$this->roomName = $roomName;
$this->roomTopic = $roomTopic;
$this->chatkey = Chat::echoCookies();
// Set the hostname of the node server that the page will connect to.
$server = ChatHelper::getServer('Main');
$this->nodePort = $server['port'];
$this->nodeHostname = $server['host'];
// Some building block for URLs that the UI needs.
$this->pathToProfilePage = Title::makeTitle(!empty($this->wg->EnableWallExt) ? NS_USER_WALL : NS_USER_TALK, '$1')->getFullURL();
$this->pathToContribsPage = SpecialPage::getTitleFor('Contributions', '$1')->getFullURL();
$this->bodyClasses = "";
if ($wgUser->isAllowed('chatmoderator')) {
$this->isChatMod = 1;
$this->bodyClasses .= ' chat-mod ';
} else {
$this->isChatMod = 0;
}
// Adding chatmoderator group for other users. CSS classes added to body tag to hide/show option in menu.
$userChangeableGroups = $wgUser->changeableGroups();
if (in_array('chatmoderator', $userChangeableGroups['add'])) {
$this->bodyClasses .= ' can-give-chat-mod ';
}
$this->app->registerHook('MakeGlobalVariablesScript', 'ChatController', 'onMakeGlobalVariablesScript', array(), false, $this);
$wgOut->getResourceLoader()->getModule('mediawiki');
$ret = implode("\n", array($wgOut->getHeadLinks(null, true), $wgOut->buildCssLinks(), $wgOut->getHeadScripts(), $wgOut->getHeadItems()));
$this->globalVariablesScript = $ret;
//Theme Designer stuff
$themeSettingObj = new ThemeSettings();
$themeSettings = $themeSettingObj->getSettings();
$this->themeSettings = $themeSettings;
$this->wordmarkThumbnailUrl = '';
if ($themeSettings['wordmark-type'] == 'graphic') {
$title = Title::newFromText($themeSettings['wordmark-image-name'], NS_FILE);
if ($title) {
$image = wfFindFile($title);
if ($image) {
$this->wordmarkThumbnailUrl = $image->createThumb(self::CHAT_WORDMARK_WIDTH, self::CHAT_WORDMARK_HEIGHT);
}
}
if (empty($this->wordmarkThumbnailUrl)) {
$this->wordmarkThumbnailUrl = WikiFactory::getLocalEnvURL($themeSettings['wordmark-image-url']);
}
}
wfProfileOut(__METHOD__);
}
示例10: getHostByDbName
/**
* Get domain for a wiki using given database name
*
* @param string $dbName database name
*
* @return string HTTP domain
*/
private static function getHostByDbName($dbName)
{
global $wgDevelEnvironment, $wgDevelEnvironmentName;
$cityId = WikiFactory::DBtoID($dbName);
$hostName = WikiFactory::getVarValueByName('wgServer', $cityId);
if (!empty($wgDevelEnvironment)) {
if (strpos($hostName, "wikia.com")) {
$hostName = str_replace("wikia.com", "{$wgDevelEnvironmentName}.wikia-dev.com", $hostName);
} else {
$hostName = WikiFactory::getLocalEnvURL($hostName);
}
}
return rtrim($hostName, '/');
}
示例11: executeIndex
public function executeIndex()
{
ChatHelper::info(__METHOD__ . ': Method called');
global $wgUser, $wgFavicon, $wgOut, $wgHooks, $wgSitename;
wfProfileIn(__METHOD__);
// String replacement logic taken from includes/Skin.php
$this->wgFavicon = str_replace('images.wikia.com', 'images1.wikia.nocookie.net', $wgFavicon);
$this->mainPageURL = Title::newMainPage()->getLocalURL();
// add messages (fetch them using <script> tag)
JSMessages::enqueuePackage('Chat', JSMessages::EXTERNAL);
// package defined in Chat_setup.php
$this->jsMessagePackagesUrl = JSMessages::getExternalPackagesUrl();
// Variables for this user
$this->username = $wgUser->getName();
$this->avatarUrl = AvatarService::getAvatarUrl($this->username, ChatController::CHAT_AVATAR_DIMENSION);
// Find the chat for this wiki (or create it, if it isn't there yet).
$this->roomId = (int) NodeApiClient::getDefaultRoomId();
// we overwrite here data from redis since it causes a bug DAR-1532
$this->roomName = $wgSitename;
$this->roomTopic = wfMsg('chat-default-topic', $wgSitename);
$this->chatkey = Chat::echoCookies();
// Set the hostname of the node server that the page will connect to.
$chathost = ChatHelper::getChatConfig('ChatHost');
$server = explode(":", $chathost);
$this->nodeHostname = $server[0];
$this->nodePort = $server[1];
$chatmain = ChatHelper::getServer('Main');
$this->nodeInstance = $chatmain['serverId'];
// Some building block for URLs that the UI needs.
$this->pathToProfilePage = Title::makeTitle(!empty($this->wg->EnableWallExt) ? NS_USER_WALL : NS_USER_TALK, '$1')->getFullURL();
$this->pathToContribsPage = SpecialPage::getTitleFor('Contributions', '$1')->getFullURL();
$this->bodyClasses = "";
if ($wgUser->isAllowed('chatmoderator')) {
$this->isChatMod = 1;
$this->bodyClasses .= ' chat-mod ';
} else {
$this->isChatMod = 0;
}
// Adding chatmoderator group for other users. CSS classes added to body tag to hide/show option in menu.
$userChangeableGroups = $wgUser->changeableGroups();
if (in_array('chatmoderator', $userChangeableGroups['add'])) {
$this->bodyClasses .= ' can-give-chat-mod ';
}
// set up global js variables just for the chat page
$wgHooks['MakeGlobalVariablesScript'][] = array($this, 'onMakeGlobalVariablesScript');
$wgOut->getResourceLoader()->getModule('mediawiki');
$ret = implode("\n", array($wgOut->getHeadLinks(null, true), $wgOut->buildCssLinks(), $wgOut->getHeadScripts(), $wgOut->getHeadItems()));
$this->globalVariablesScript = $ret;
//Theme Designer stuff
$themeSettingObj = new ThemeSettings();
$themeSettings = $themeSettingObj->getSettings();
$this->themeSettings = $themeSettings;
$this->wordmarkThumbnailUrl = '';
if ($themeSettings['wordmark-type'] == 'graphic') {
$title = Title::newFromText($themeSettings['wordmark-image-name'], NS_FILE);
if ($title) {
$image = wfFindFile($title);
if ($image) {
$this->wordmarkThumbnailUrl = $image->createThumb(self::CHAT_WORDMARK_WIDTH, self::CHAT_WORDMARK_HEIGHT);
}
}
if (empty($this->wordmarkThumbnailUrl)) {
$this->wordmarkThumbnailUrl = WikiFactory::getLocalEnvURL($themeSettings['wordmark-image-url']);
}
}
// CONN-436: Invalidate Varnish cache for ChatRail:GetUsers
ChatRailController::purgeMethod('GetUsers', ['format' => 'json']);
wfProfileOut(__METHOD__);
}