本文整理汇总了PHP中F::build方法的典型用法代码示例。如果您正苦于以下问题:PHP F::build方法的具体用法?PHP F::build怎么用?PHP F::build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F
的用法示例。
在下文中一共展示了F::build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVisualization
/**
* @return CityVisualization
*/
protected function getVisualization()
{
if (empty($this->visualization)) {
$this->visualization = F::build('CityVisualization');
}
return $this->visualization;
}
示例2: uploadImageFromUrl
/**
* @desc Uploads an image on a wki
*
* @static
* @param string $imageUrl url address to original file
* @param Object $oImageData an object with obligatory field "name" and optional fields: "comment", "description"
* @param User | null $user optional User's class instance (the file will be "uploaded" by this user)
*
* @return array
*/
public static function uploadImageFromUrl($imageUrl, $oImageData, $user = null)
{
// disable recentchange hooks
global $wgHooks;
$wgHooks['RecentChange_save'] = array();
$wgHooks['RecentChange_beforeSave'] = array();
/* prepare temporary file */
$data = array('wpUpload' => 1, 'wpSourceType' => 'web', 'wpUploadFileURL' => $imageUrl);
//validate of optional image data
foreach (array(self::FILE_DATA_COMMENT_OPION_NAME, self::FILE_DATA_DESC_OPION_NAME) as $option) {
if (!isset($oImageData->{$option})) {
$oImageData->{$option} = $oImageData->name;
}
}
$upload = F::build('UploadFromUrl');
/* @var $upload UploadFromUrl */
$upload->initializeFromRequest(F::build('FauxRequest', array($data, true)));
$upload->fetchFile();
$upload->verifyUpload();
// create destination file
$title = Title::newFromText($oImageData->name, NS_FILE);
$file = F::build('WikiaLocalFile', array($title, RepoGroup::singleton()->getLocalRepo()));
/* @var $file WikiaLocalFile */
/* real upload */
$result = $file->upload($upload->getTempPath(), $oImageData->comment, $oImageData->description, File::DELETE_SOURCE, false, false, $user);
return array('status' => $result->ok, 'page_id' => $title->getArticleID(), 'errors' => $result->errors);
}
示例3: onSkinAfterBottomScripts
/**
* Load WelcomeBar front-end code for anonymous visitors only
*
* @param Skin $skin current skin object
* @param string $text content of bottom scripts
* @return boolean it't a hook
*/
public function onSkinAfterBottomScripts(Skin $skin, &$text)
{
if ($this->wg->User->isAnon()) {
$text .= F::build('JSSnippets')->addToStack(array('/extensions/wikia/hacks/WelcomeBar/js/WelcomeBar.js'), array(), 'WelcomeBar.init');
}
return true;
}
示例4: init
public function init()
{
$this->privateData[] = 'foo';
$this->privateData[] = 'bar';
$this->privateData[] = 'baz';
$this->helper = F::build('HelloWorld', array('currentTitle' => $this->app->wg->Title));
}
示例5: getUrl
public function getUrl()
{
wfProfileIn(__METHOD__);
$title = F::build('title', array($this->getUser()->getName(), NS_USER_WALL), 'newFromText');
wfProfileOut(__METHOD__);
return $title->getFullUrl();
}
示例6: getHTML
public function getHTML()
{
wfProfileIn(__METHOD__);
$this->report->loadSources();
$aData = array();
$aLabel = array();
if (count($this->report->reportSources) == 0) {
return '';
}
foreach ($this->report->reportSources as $reportSource) {
$reportSource->getData();
$this->actualDate = $reportSource->actualDate;
if (!empty($reportSource->dataAll) && !empty($reportSource->dataTitles)) {
if (is_array($reportSource->dataAll)) {
foreach ($reportSource->dataAll as $key => $val) {
if (isset($aData[$key])) {
$aData[$key] = array_merge($aData[$key], $val);
} else {
$aData[$key] = $val;
}
}
}
$aLabel += $reportSource->dataTitles;
}
}
sort($aData);
$this->sourceData = array_reverse($aData);
$this->sourceLabels = array_reverse($aLabel);
$oTmpl = F::build('EasyTemplate', array(dirname(__FILE__) . "/templates/"));
/** @var $oTmpl EasyTemplate */
$oTmpl->set_vars(array('data' => $this->sourceData, 'labels' => $this->sourceLabels));
wfProfileOut(__METHOD__);
$this->beforePrint();
return $oTmpl->render('../../templates/output/' . self::TEMPLATE_MAIN);
}
示例7: testGetImageResizeParams
/**
* @param $requestedWidth
* @param $requestedHeight
* @param $originalWidth
* @param $originalHeight
* @param $expParams
* @dataProvider testGetImageResizeParamsDataProvider
*/
public function testGetImageResizeParams($originalWidth, $originalHeight, $requestedWidth, $requestedHeight, $expParams)
{
/* @var $helper WikiaHomePageHelper */
$helper = F::build('WikiaHomePageHelper');
$params = $helper->getImageServingParamsForResize($requestedWidth, $requestedHeight, $originalWidth, $originalHeight);
$this->assertEquals($expParams, $params);
}
示例8: setUp
protected function setUp()
{
global $wgCityId;
$this->wgCityId = $wgCityId;
$this->setupFile = dirname(__FILE__) . '/../FounderProgressBar.setup.php';
parent::setUp();
// Mock response using $this->getValCallBack()
$mockR = $this->getMock('WikiaResponse', array('getVal'), array('raw'));
$mockR->expects($this->any())->method('getVal')->will($this->returnCallback(array($this, "getValCallback")));
$mock_result = $this->getMock('ResultWrapper', array(), array(), '', false);
$this->mock_db = $this->getMock('DatabaseMysql', array('select', 'query', 'update', 'commit', 'fetchObject', 'fetchRow'));
$this->mock_db->expects($this->any())->method('select')->will($this->returnValue($mock_result));
$this->mock_db->expects($this->any())->method('query');
$this->mock_db->expects($this->any())->method('update');
$this->mock_db->expects($this->any())->method('commit');
$cache = $this->getMock('stdClass', array('get', 'set', 'delete'));
$cache->expects($this->any())->method('get')->will($this->returnValue(null));
$cache->expects($this->any())->method('set');
$cache->expects($this->any())->method('delete');
$mock = $this->getMock('FounderProgressBarController', array('sendSelfRequest', 'getDb', 'getMCache'));
$mock->expects($this->any())->method('sendSelfRequest')->will($this->returnValue($mockR));
$mock->expects($this->any())->method('getDb')->will($this->returnValue($this->mock_db));
$mock->expects($this->any())->method('getMCache')->will($this->returnValue($cache));
F::setInstance("FounderProgressBarController", $mock);
$this->object = F::build('FounderProgressBarController');
$this->task_id = 0;
}
示例9: getLocalFileLogic
protected function getLocalFileLogic()
{
if (empty($this->oLocalFileLogic)) {
$this->oLocalFileLogic = F::build('WikiaLocalFileShared', array($this));
}
return $this->oLocalFileLogic;
}
示例10: ActivityFeedTag_render
function ActivityFeedTag_render($content, $attributes, $parser, $frame)
{
global $wgExtensionsPath, $wgEnableAchievementsInActivityFeed, $wgEnableAchievementsExt;
if (!class_exists('ActivityFeedHelper')) {
return '';
}
wfProfileIn(__METHOD__);
$parameters = ActivityFeedHelper::parseParameters($attributes);
$tagid = str_replace('.', '_', uniqid('activitytag_', true));
//jQuery might have a problem with . in ID
$jsParams = "size={$parameters['maxElements']}";
if (!empty($parameters['includeNamespaces'])) {
$jsParams .= "&ns={$parameters['includeNamespaces']}";
}
if (!empty($parameters['flags'])) {
$jsParams .= '&flags=' . implode('|', $parameters['flags']);
}
$parameters['tagid'] = $tagid;
$feedHTML = ActivityFeedHelper::getList($parameters);
$style = empty($parameters['style']) ? '' : ' style="' . $parameters['style'] . '"';
$timestamp = wfTimestampNow();
$snippetsDependencies = array('/extensions/wikia/MyHome/ActivityFeedTag.js', '/extensions/wikia/MyHome/ActivityFeedTag.css');
if (!empty($wgEnableAchievementsInActivityFeed) && !empty($wgEnableAchievementsExt)) {
array_push($snippetsDependencies, '/extensions/wikia/AchievementsII/css/achievements_sidebar.css');
}
$snippets = F::build('JSSnippets')->addToStack($snippetsDependencies, null, 'ActivityFeedTag.initActivityTag', array('tagid' => $tagid, 'jsParams' => $jsParams, 'timestamp' => $timestamp));
wfProfileOut(__METHOD__);
return "<div{$style}>{$feedHTML}</div>{$snippets}";
}
示例11: setTitle
public function setTitle($title)
{
$this->title = $title;
$globalTitleObj = (array) F::build('GlobalTitle', array($this->title), 'explodeURL');
$this->setArticleName($globalTitleObj['articleName']);
$this->setWikiId($globalTitleObj['wikiId']);
}
示例12: index
/**
* @brief Displays the main menu for the admin dashboard
*
*/
public function index()
{
$this->wg->Out->setPageTitle(wfMsg('admindashboard-title'));
if (!$this->wg->User->isAllowed('admindashboard')) {
$this->displayRestrictionError();
return false;
// skip rendering
}
$this->tab = $this->getVal('tab', 'general');
// links
$this->urlThemeDesigner = Title::newFromText('ThemeDesigner', NS_SPECIAL)->getFullURL();
$this->urlRecentChanges = Title::newFromText('RecentChanges', NS_SPECIAL)->getFullURL();
$this->urlTopNavigation = Title::newFromText('Wiki-navigation', NS_MEDIAWIKI)->getFullURL('action=edit');
$this->urlWikiFeatures = Title::newFromText('WikiFeatures', NS_SPECIAL)->getFullURL();
$this->urlPageLayoutBuilder = Title::newFromText('PageLayoutBuilder', NS_SPECIAL)->getFullURL('action=list');
$this->urlListUsers = Title::newFromText('ListUsers', NS_SPECIAL)->getFullURL();
$this->urlUserRights = Title::newFromText('UserRights', NS_SPECIAL)->getFullURL();
$this->urlCommunityCorner = Title::newFromText('Community-corner', NS_MEDIAWIKI)->getFullURL('action=edit');
$this->urlAllCategories = Title::newFromText('Categories', NS_SPECIAL)->getFullURL();
$this->urlAddPage = Title::newFromText('CreatePage', NS_SPECIAL)->getFullURL();
$this->urlAddPhoto = Title::newFromText('Upload', NS_SPECIAL)->getFullURL();
$this->urlCreateBlogPage = Title::newFromText('CreateBlogPage', NS_SPECIAL)->getFullURL();
$this->urlMultipleUpload = Title::newFromText('MultipleUpload', NS_SPECIAL)->getFullURL();
$this->urlGetPromoted = Title::newFromText('Promote', NS_SPECIAL)->getFullURL();
// special:specialpages
$this->advancedSection = (string) $this->app->sendRequest('AdminDashboardSpecialPage', 'getAdvancedSection', array());
// icon display logic
$this->displayPageLayoutBuilder = !empty($this->wg->EnablePageLayoutBuilder);
$this->displayWikiFeatures = !empty($this->wg->EnableWikiFeatures);
$this->displaySpecialPromote = !empty($this->wg->EnableSpecialPromoteExt);
// add messages package
F::build('JSMessages')->enqueuePackage('AdminDashboard', JSMessages::INLINE);
}
示例13: pageNotFound
/**
* Page Not Found
*
* Get 20 most recent edited page
* get 5 images per page
*
* display random image on 404 page
* example:
*
* Open non existent page on any wiki
*
*/
function pageNotFound()
{
//setup all needed assets on 404 page
/**
* @var $out OutputPage
*/
$out = $this->request->getVal('out', $this->wg->Out);
$assetManager = F::build('AssetsManager', array(), 'getInstance');
//add styles that belongs only to 404 page
$styles = $assetManager->getURL(array('wikiamobile_404_scss'));
//this is going to be additional call but at least it won't be loaded on every page
foreach ($styles as $s) {
$out->addStyle($s);
}
//this is mainly for tracking
$scipts = $assetManager->getURL(array('wikiamobile_404_js'));
foreach ($scipts as $s) {
$out->addScript('<script src="' . $s . '"></script>');
}
//suppress rendering stuff that is not to be on 404 page
WikiaMobileFooterService::setSkipRendering(true);
WikiaMobilePageHeaderService::setSkipRendering(true);
/**
* @var $wikiaMobileStatsModel WikiaMobileStatsModel
*/
$wikiaMobileStatsModel = F::build('WikiaMobileStatsModel');
$ret = $wikiaMobileStatsModel->getRandomPopularPage();
$this->response->setVal('title', $this->wg->Out->getTitle());
$this->response->setVal('link', $ret[0]);
$this->response->setVal('img', $ret[1]);
}
示例14: addVideo
/**
* add video
* @requestParam integer articleId
* @requestParam string url
* @responseParam string html
* @responseParam string error - error message
*/
public function addVideo()
{
if (!$this->wg->User->isLoggedIn()) {
$this->error = $this->wf->Msg('videos-error-not-logged-in');
return;
}
$url = urldecode($this->getVal('url', ''));
if (empty($url)) {
$this->error = $this->wf->Msg('videos-error-no-video-url');
return;
}
if ($this->wg->User->isBlocked()) {
$this->error = $this->wf->Msg('videos-error-blocked-user');
return;
}
$videoService = F::build('VideoService');
$retval = $videoService->addVideo($url);
if (is_array($retval)) {
$this->html = '<div></div>';
$this->error = null;
} else {
$this->html = null;
$this->error = $retval;
}
}
示例15: index
public function index()
{
if (!$this->wg->User->isAllowed('gameguidescontent')) {
$this->displayRestrictionError();
return false;
// skip rendering
}
$title = $this->wf->Msg('wikiagameguides-content-title');
$this->wg->Out->setPageTitle($title);
$this->wg->Out->setHTMLTitle($title);
$this->wg->Out->addModules('jquery.autocomplete');
$assetManager = AssetsManager::getInstance();
$styles = $assetManager->getUrl('extensions/wikia/GameGuides/css/GameGuidesContentManagmentTool.scss');
foreach ($styles as $s) {
$this->wg->Out->addStyle($s);
}
$scripts = $assetManager->getURL('extensions/wikia/GameGuides/js/GameGuidesContentManagmentTool.js');
foreach ($scripts as $s) {
$this->wg->Out->addScriptFile($s);
}
F::build('JSMessages')->enqueuePackage('GameGuidesContentMsg', JSMessages::INLINE);
$tags = WikiFactory::getVarValueByName('wgWikiaGameGuidesContent', $this->wg->CityId);
$this->response->setVal('tags', $tags);
return true;
}