Inheritance: extends E
 protected function buildData()
 {
     $this->available = F::app()->wg->user->isAllowed('performancestats');
     $this->enabled = F::app()->wg->user->isAllowed('performancestats');
     $this->caption = wfMsg('oasis-toolbar-devinfo');
     $this->linkClass = 'tools-devinfo';
 }
 /**
  * Check if:
  * controller - is first parameter
  * method - is second parameter
  * rest of parameters - are sorted
  *
  * @author Jakub Olek <*****@*****.**>
  *
  * @throws WikiaException
  */
 public final function init()
 {
     $webRequest = F::app()->wg->Request;
     $accessService = new ApiAccessService($this->getRequest());
     $controller = $webRequest->getVal('controller');
     $method = $webRequest->getVal('method');
     $accessService->checkUse($controller . 'Controller', $method);
     //this is used for monitoring purposes, do not change unless you know what you are doing
     //should set api/v1 as the transaction name
     if (!$this->request->isInternal()) {
         Transaction::setEntryPoint(Transaction::ENTRY_POINT_API_V1);
     }
     if (!$this->request->isInternal()) {
         if ($this->hideNonCommercialContent()) {
             $this->blockIfNonCommercialOnly();
         }
         $paramKeys = array_keys($webRequest->getQueryValues());
         $count = count($paramKeys);
         if ($count >= 2 && $paramKeys[0] === 'controller' && $paramKeys[1] === 'method') {
             if ($count > 2) {
                 $origParam = $paramKeys = array_flip(array_slice($paramKeys, 2));
                 ksort($paramKeys);
                 ksort($origParam);
                 if ($paramKeys !== $origParam) {
                     throw new BadRequestApiException('The parameters\' order is incorrect');
                 }
             }
         } else {
             throw new BadRequestApiException('Controller and/or method missing');
         }
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Order'])) {
         $model->attributes = $_POST['Order'];
         $model->id = F::get_order_id();
         $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
         if ($model->save()) {
             $cart = Yii::app()->cart;
             $mycart = $cart->contents();
             foreach ($mycart as $mc) {
                 $OrderItem = new OrderItem();
                 $OrderItem->order_id = $model->order_id;
                 $OrderItem->item_id = $mc['id'];
                 $OrderItem->title = $mc['title'];
                 $OrderItem->pic_url = serialize($mc['pic_url']);
                 $OrderItem->sn = $mc['sn'];
                 $OrderItem->num = $mc['qty'];
                 $OrderItem->save();
             }
             $cart->destroy();
             $this->redirect(array('success'));
         }
     }
     //        $this->render('create', array(
     //            'model' => $model,
     //        ));
 }
Exemple #4
0
 public function uploadIcon($file)
 {
     $filename = $file->getName();
     //获取文件名
     $filename = F::random_filename() . '.' . pathinfo($filename, PATHINFO_EXTENSION);
     $filesize = $file->getSize();
     //获取文件大小
     $filetype = $file->getType();
     //获取文件类型
     $filePath = Yii::app()->params->uploadPath . "tmp/";
     if (!file_exists($filePath)) {
         mkdir($filePath, 0777);
     }
     if ($file->saveAs($filePath . $filename, true)) {
         $ftpsavepath = 'common/frontmenu/';
         $ftp = new Ftp();
         $res = $ftp->uploadfile($filePath . $filename, $ftpsavepath . $filename);
         $ftp->close();
         if ($res['success']) {
             @unlink($filePath . $filename);
             return $filename;
         } else {
             var_dump($res);
             die;
         }
     }
 }
 public function getContent()
 {
     wfProfileIn(__METHOD__);
     $processingTimeStart = null;
     if ($this->mForceProfile) {
         $processingTimeStart = microtime(true);
     }
     $hash = wfAssetManagerGetSASShash($this->mOid);
     $paramsHash = md5(urldecode(http_build_query($this->mParams, '', ' ')));
     $cacheId = "/Sass-{$paramsHash}-{$hash}-" . self::CACHE_VERSION;
     $memc = F::App()->wg->Memc;
     $cachedContent = $memc->get($cacheId);
     if ($cachedContent) {
         $this->mContent = $cachedContent;
     } else {
         $this->processContent();
         // This is the final pass on contents which, among other things, performs minification
         parent::getContent($processingTimeStart);
         // Prevent cache poisoning if we are serving sass from preview server
         if (getHostPrefix() == null && !$this->mForceProfile) {
             $memc->set($cacheId, $this->mContent);
         }
     }
     wfProfileOut(__METHOD__);
     return $this->mContent;
 }
 public function execute($subpage)
 {
     global $wgOut, $wgUser, $wgExtensionsPath, $wgResourceBasePath;
     // Boilerplate special page permissions
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (!$wgUser->isAllowed('wikiaquiz')) {
         $this->displayRestrictionError();
         return;
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     $wgOut->addScript('<script src="' . $wgResourceBasePath . '/resources/wikia/libraries/jquery-ui/jquery-ui-1.8.14.custom.js"></script>');
     $wgOut->addScript('<script src="' . $wgExtensionsPath . '/wikia/WikiaQuiz/js/CreateWikiaQuizArticle.js"></script>');
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaQuiz/css/WikiaQuizBuilder.scss'));
     if ($subpage != '') {
         // We came here from the edit link, go into edit mode
         $wgOut->addHtml(F::app()->renderView('WikiaQuiz', 'EditQuizArticle', array('title' => $subpage)));
     } else {
         $wgOut->addHtml(F::app()->renderView('WikiaQuiz', 'CreateQuizArticle'));
     }
 }
Exemple #7
0
 public function actionGetlogisticslist()
 {
     $organID = Commonmodel::getOrganID();
     //获取机构ID
     $criteria = new CDbCriteria();
     $criteria->select = "*";
     $criteria->order = "id DESC";
     $criteria->addCondition("OrganID=" . $organID);
     //查询条件:根据机构ID查询物流数据
     $count = Logistics::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->applyLimit($criteria);
     $modeles = Logistics::model()->findAll($criteria);
     foreach ($modeles as $key => $value) {
         $data[$key]['ID'] = $value['ID'];
         $data[$key]['OrganID'] = $value['OrganID'];
         $data[$key]['Company'] = F::msubstr($value['LogisticsCompany']);
         $data[$key]['Description'] = F::msubstr($value['LogisticsDescription']);
         $data[$key]['LogisticsCompany'] = $value['LogisticsCompany'];
         $data[$key]['LogisticsDescription'] = $value['LogisticsDescription'];
         $data[$key]['CreateTime'] = date("Y-m-d H:i:s", $value['CreateTime']);
         $data[$key]['UpdateTime'] = $value['UpdateTime'];
         $data[$key]['Status'] = $value['Status'];
         $address = $this->getAddress($value['ID']);
         $data[$key]['Address'] = $address ? F::msubstr(substr($address, 0, -3)) : '';
         $data[$key]['AddressDetail'] = $address ? substr($address, 0, -3) : '';
         //$data[$key]['Address'] = Area::getCity($address['Province']) . Area::getCity($address['City']) . Area::getCity($address['Area']);
     }
     $rs = array('total' => $count, 'rows' => $data ? $data : array());
     //        var_dump($rs);exit;
     echo json_encode($rs);
 }
 /**
  * set appropriate status code for deleted pages
  *
  * @author ADi
  * @param Title $title
  * @param Article $article
  * @return bool
  */
 public function onArticleFromTitle(&$title, &$article)
 {
     if (!$title->exists() && $title->isDeleted()) {
         F::app()->wg->Out->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE);
     }
     return true;
 }
 public function index()
 {
     $this->wg->Out->setPageTitle(wfMsg('wikifeatures-title'));
     if (!$this->wg->User->isAllowed('wikifeaturesview')) {
         // show this feature to logged in users only regardless of their rights
         $this->displayRestrictionError();
         return false;
         // skip rendering
     }
     $this->isOasis = F::app()->checkSkin('oasis');
     if (!$this->isOasis) {
         $this->forward('WikiFeaturesSpecial', 'notOasis');
         return;
     }
     $this->response->addAsset('extensions/wikia/WikiFeatures/css/WikiFeatures.scss');
     $this->response->addAsset('extensions/wikia/WikiFeatures/js/modernizr.transform.js');
     $this->response->addAsset('extensions/wikia/WikiFeatures/js/WikiFeatures.js');
     if ($this->getVal('simulateNewLabs', false)) {
         // debug code
         WikiFeaturesHelper::$release_date = array('wgEnableChat' => '2032-09-01');
     }
     $this->features = WikiFeaturesHelper::getInstance()->getFeatureNormal();
     $this->labsFeatures = WikiFeaturesHelper::getInstance()->getFeatureLabs();
     $this->editable = $this->wg->User->isAllowed('wikifeatures') ? true : false;
     // only those with rights can make edits
     if ($this->getVal('simulateEmptyLabs', false)) {
         // debug code
         $this->labsFeatures = array();
     }
 }
 /**
  * saves user preferences
  *
  * @return Illuminate\View\View
  */
 public function savePreferences()
 {
     $section_ids = function ($input) {
         $input_data = Input::get($input, '');
         if (strlen($input_data) == 0) {
             return "";
         }
         $arr = explode(',', $input_data);
         return implode(',', array_unique(F::map($this->section->getByTitle($arr), function ($m) {
             return $m->id;
         })));
     };
     $show_nsfw = Input::get('show_nsfw', 0);
     $show_nsfl = Input::get('show_nsfl', 0);
     $frontpage_show_sections = $section_ids('frontpage_show_sections');
     $frontpage_ignore_sections = $section_ids('frontpage_ignore_sections');
     if ($frontpage_show_sections == "0") {
         $frontpage_show_sections = "";
     }
     if ($frontpage_ignore_sections == "0") {
         $frontpage_ignore_sections = "";
     }
     $this->user->savePreferences(Auth::id(), ['show_nsfw' => $show_nsfw, 'show_nsfl' => $show_nsfl, 'frontpage_show_sections' => $frontpage_show_sections, 'frontpage_ignore_sections' => $frontpage_ignore_sections]);
     $sections = $this->section->get();
     $section = $this->section->sectionFromEmptySection();
     return View::make('page.user.prefs.savedpreferences', ['sections' => $sections, 'section' => $section]);
 }
 function __construct(User $user)
 {
     $app = F::App();
     $this->user = $user;
     $this->memc = $app->wg->Memc;
     $this->namespaces = wfGetNamespaces();
 }
Exemple #12
0
 /**
  * 筛选数组,获取必备key对应value
  * 
  * @access public
  * @param array $require_params key array
  * @param array $params 待筛选数组
  * @return multitype:
  */
 public static function require_params($require_params = array(), &$params = array())
 {
     if (!$params) {
         $params = F::all_requests();
     }
     return array_values(array_diff($require_params, array_keys($params)));
 }
 public function __construct(WikiaApp $app = null)
 {
     if (is_null($app)) {
         $app = F::app();
     }
     $this->app = $app;
 }
 public static function onGetRecentChangeQuery(&$conds, &$tables, &$join_conds, $opts)
 {
     $app = F::app();
     if ($app->wg->User->isAnon()) {
         return true;
     }
     if ($app->wg->Title->isSpecial('RecentChanges')) {
         return true;
     }
     if ($opts['invert'] !== false) {
         return true;
     }
     if (!isset($opts['namespace']) || empty($opts['namespace'])) {
         $rcfs = new RecentChangesFiltersStorage($app->wg->User);
         $selected = $rcfs->get();
         if (empty($selected)) {
             return true;
         }
         $db = wfGetDB(DB_SLAVE);
         $cond = 'rc_namespace IN (' . $db->makeList($selected) . ')';
         $flag = true;
         foreach ($conds as $key => &$value) {
             if (strpos($value, 'rc_namespace') !== false) {
                 $value = $cond;
                 $flag = false;
                 break;
             }
         }
         if ($flag) {
             $conds[] = $cond;
         }
     }
     return true;
 }
 public function __construct()
 {
     parent::__construct();
     //TODO: use Factory here
     //$this->setProvider(F::build('MysqlWikiaHubsV2SliderModuleDataProvider'));
     $this->setProvider(F::build('StaticWikiaHubsV2SliderModuleDataProvider'));
 }
 public function setTitle($title)
 {
     $this->title = $title;
     $globalTitleObj = (array) F::build('GlobalTitle', array($this->title), 'explodeURL');
     $this->setArticleName($globalTitleObj['articleName']);
     $this->setWikiId($globalTitleObj['wikiId']);
 }
 public function __construct($url, $login = '', $passwd = '', $HTTPProxy = null)
 {
     $this->setCurl(F::build('Curl', array('url' => $url)));
     $this->setLogin($login);
     $this->setPasswd($passwd);
     $this->setHTTPProxy($HTTPProxy);
 }
 /**
  * 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]);
 }
 protected function getInterfaceObjectFromType($type)
 {
     wfProfileIn(__METHOD__);
     $apiUrl = $this->getApiUrl();
     if (empty($this->videoId)) {
         throw new EmptyResponseException($apiUrl);
     }
     $memcKey = F::app()->wf->memcKey(static::$CACHE_KEY, $apiUrl, static::$CACHE_KEY_VERSION);
     $processedResponse = F::app()->wg->memc->get($memcKey);
     if (empty($processedResponse)) {
         $req = MWHttpRequest::factory($apiUrl);
         $req->setHeader('User-Agent', self::$REQUEST_USER_AGENT);
         $status = $req->execute();
         if ($status->isOK()) {
             $response = $req->getContent();
             $this->response = $response;
             // Only for migration purposes
             if (empty($response)) {
                 throw new EmptyResponseException($apiUrl);
             } else {
                 if ($req->getStatus() == 301) {
                     throw new VideoNotFoundException($req->getStatus(), $this->videoId . ' Moved Permanently.', $apiUrl);
                 }
             }
         } else {
             $this->checkForResponseErrors($req->status, $req->getContent(), $apiUrl);
         }
         $processedResponse = $this->processResponse($response, $type);
         F::app()->wg->memc->set($memcKey, $processedResponse, static::$CACHE_EXPIRY);
     }
     wfProfileOut(__METHOD__);
     return $processedResponse;
 }
 /**
  * @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);
 }
 public function execute($subpage)
 {
     global $wgOut, $wgUser, $wgExtensionsPath, $wgResourceBasePath;
     // Boilerplate special page permissions
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if (!$wgUser->isAllowed('createpage') || !$wgUser->isAllowed('edit')) {
         $this->displayRestrictionError();
         return;
     }
     $wgOut->addModules("wikia.jquery.ui");
     $wgOut->addScript('<script src="' . $wgExtensionsPath . '/wikia/WikiaPoll/js/CreateWikiaPoll.js"></script>');
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaPoll/css/CreateWikiaPoll.scss'));
     if ($subpage != '') {
         // We came here from the edit link, go into edit mode
         $wgOut->addHtml(F::app()->renderView('WikiaPoll', 'SpecialPageEdit', array('title' => $subpage)));
     } else {
         $wgOut->addHtml(F::app()->renderView('WikiaPoll', 'SpecialPage'));
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Orders();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Orders'])) {
         $model->attributes = $_POST['Orders'];
         $model->order_sn = F::get_order_sn();
         $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
         if ($model->save()) {
             $cart = Yii::app()->cart;
             $mycart = $cart->contents();
             foreach ($mycart as $mc) {
                 $orderGoods = new OrderGoods();
                 $orderGoods->order_id = $model->order_id;
                 $orderGoods->product_id = $mc['id'];
                 $orderGoods->product_name = $mc['product_name'];
                 $orderGoods->product_image = serialize($mc['product_image']);
                 $orderGoods->product_sn = $mc['product_sn'];
                 $orderGoods->qty = $mc['qty'];
                 $orderGoods->save();
             }
             $cart->destroy();
             $this->redirect(array('success'));
         }
     }
     //
     //        $this->render('create', array(
     //            'model' => $model,
     //        ));
 }
 public function delete($targetWikiId, $wikiList)
 {
     $app = \F::app();
     foreach ($wikiList as $sourceWikiId => $images) {
         $sourceWikiLang = \WikiFactory::getVarValueByName('wgLanguageCode', $sourceWikiId);
         if (!empty($images)) {
             $removedImages = array();
             foreach ($images as $imageName) {
                 if (\PromoImage::fromPathname($imageName)->isValid()) {
                     $result = $this->removeSingleImage($targetWikiId, $imageName);
                     if ($result['status'] === 0) {
                         $removedImages[] = $imageName;
                     }
                 }
             }
         }
         if (!empty($removedImages)) {
             $memcKey = $this->helper->getMemcKey($sourceWikiId, $sourceWikiLang);
             $updateData = $this->syncAdditionalImages($sourceWikiId, $sourceWikiLang, $removedImages);
             // update in db
             if (!empty($updateData)) {
                 // updating city_visualization table
                 $this->model->saveVisualizationData($sourceWikiId, $updateData, $sourceWikiLang);
                 // purging interstitial cache
                 $app->wg->Memc->set($memcKey, null);
             }
         }
     }
     // since an admin can't delete main image we don't purge visualization list cache
     // as it happens during uploads
     return true;
 }
 private function buildMimeTypesBlacklist()
 {
     if (self::$mimeTypesBlacklist === null) {
         wfProfileIn(__METHOD__);
         $app = F::app();
         // blacklist types that thumbnailer cannot generate thumbs for (BAC-770)
         $mimeTypesBlacklist = ['svg+xml', 'svg'];
         if ($app->wg->UseMimeMagicLite) {
             // MimeMagicLite defines all the mMediaTypes in PHP that MimeMagic
             // defines in text files
             $mimeTypes = new MimeMagicLite();
         } else {
             $mimeTypes = new MimeMagic();
         }
         foreach (['AUDIO', 'VIDEO'] as $type) {
             foreach ($mimeTypes->mMediaTypes[$type] as $mime) {
                 // parse mime type - "image/svg" -> "svg"
                 list(, $mimeMinor) = explode('/', $mime);
                 $mimeTypesBlacklist[] = $mimeMinor;
             }
         }
         self::$mimeTypesBlacklist = array_unique($mimeTypesBlacklist);
         wfDebug(sprintf("%s: minor MIME types blacklist - %s\n", __CLASS__, join(', ', self::$mimeTypesBlacklist)));
         wfProfileOut(__METHOD__);
     }
 }
Exemple #25
0
/**
 * Make sure the keys are defined.
 *
 * @throws Exception
 */
function efReCaptcha()
{
    $wg = F::app()->wg;
    if ($wg->ReCaptchaPublicKey == '' || $wg->ReCaptchaPrivateKey == '') {
        throw new Exception(wfMessage('recaptcha-misconfigured')->escaped());
    }
}
 public static function onGalleryBeforeProduceHTML($data, &$out)
 {
     global $wgArticleAsJson;
     wfProfileIn(__METHOD__);
     if ($wgArticleAsJson) {
         $parser = ParserPool::get();
         $parserOptions = new ParserOptions();
         $title = F::app()->wg->Title;
         $media = [];
         foreach ($data['images'] as $image) {
             $details = WikiaFileHelper::getMediaDetail(Title::newFromText($image['name'], NS_FILE), self::$mediaDetailConfig);
             $details['context'] = self::MEDIA_CONTEXT_GALLERY_IMAGE;
             $caption = $image['caption'];
             if (!empty($caption)) {
                 $caption = $parser->parse($caption, $title, $parserOptions, false)->getText();
             }
             $linkHref = isset($image['linkhref']) ? $image['linkhref'] : null;
             $media[] = self::createMediaObject($details, $image['name'], $caption, $linkHref);
             self::addUserObj($details);
         }
         self::$media[] = $media;
         if (!empty($media)) {
             $out = self::createMarker($media[0]['width'], $media[0]['height'], true);
         } else {
             $out = '';
         }
         ParserPool::release($parser);
         wfProfileOut(__METHOD__);
         return false;
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Exemple #27
0
 public function testSort()
 {
     $items = ['y', 'z', 'a', 'c', 'x', 'b'];
     $expect = ['a', 'b', 'c', 'x', 'y', 'z'];
     $actual = fluent()->sort(F::comparedTo())->values()->call($items);
     $this->assertEquals($expect, $actual);
 }
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}";
}
 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);
 }
 /**
  * Whether CategorySelect should be used for the current request.
  * @return Boolean
  */
 public static function isEnabled()
 {
     wfProfileIn(__METHOD__);
     if (!isset(self::$isEnabled)) {
         $app = F::app();
         $request = $app->wg->Request;
         $title = $app->wg->Title;
         $user = $app->wg->User;
         $action = $request->getVal('action', 'view');
         $undo = $request->getVal('undo');
         $undoafter = $request->getVal('undoafter');
         $viewModeActions = array('view', 'purge');
         $editModeActions = array('edit', 'submit');
         $supportedActions = array_merge($viewModeActions, $editModeActions);
         $supportedSkins = array('SkinAnswers', 'SkinOasis', 'SkinVenus');
         $isViewMode = in_array($action, $viewModeActions);
         $isEditMode = in_array($action, $editModeActions);
         $extraNamespacesOnView = array(NS_FILE, NS_CATEGORY);
         $extraNamespacesOnEdit = array(NS_FILE, NS_CATEGORY, NS_USER, NS_SPECIAL);
         $isEnabled = true;
         if ($request->getVal('usecatsel', '') == 'no' || $user->getGlobalPreference('disablecategoryselect') || !in_array(get_class(RequestContext::getMain()->getSkin()), $supportedSkins) || !in_array($action, $supportedActions) || $title->isCssJsSubpage() || $action == 'view' && !$title->exists() || $action == 'purge' && $user->isAnon() && !$request->wasPosted() || $undo > 0 && $undoafter > 0 || $title->mNamespace == NS_TEMPLATE || $isViewMode && !in_array($title->mNamespace, array_merge($app->wg->ContentNamespaces, $extraNamespacesOnView)) || $isEditMode && !in_array($title->mNamespace, array_merge($app->wg->ContentNamespaces, $extraNamespacesOnEdit))) {
             $isEnabled = false;
         }
         self::$isEnabled = $isEnabled;
     }
     wfProfileOut(__METHOD__);
     return self::$isEnabled;
 }