コード例 #1
0
ファイル: JSSnippetsTest.php プロジェクト: Tjorriemorrie/app
 public function testAddToStack()
 {
     $instance = new JSSnippets();
     $snippet = $instance->addToStack(array('/extensions/wikia/Feature/js/Feature.js', '/extensions/wikia/Feature/css/Feature.css'));
     $this->assertEquals('<script>JSSnippetsStack.push({dependencies:["/extensions/wikia/Feature/js/Feature.js","/extensions/wikia/Feature/css/Feature.css"]})</script>', $snippet);
     $snippet = $instance->addToStack(array('/extensions/wikia/Feature/js/Feature.js'), array('$.loadJQueryUI'), 'Feature.init', array('foo' => 'bar'));
     $this->assertEquals('<script>JSSnippetsStack.push({dependencies:["/extensions/wikia/Feature/js/Feature.js"],getLoaders:function(){return [$.loadJQueryUI]},callback:function(json){Feature.init(json)},id:"Feature.init",options:{"foo":"bar"}})</script>', $snippet);
 }
コード例 #2
0
ファイル: ActivityFeedTag.php プロジェクト: Tjorriemorrie/app
function ActivityFeedTag_render($content, $attributes, $parser, $frame)
{
    global $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 = JSSnippets::addToStack($snippetsDependencies, null, 'ActivityFeedTag.initActivityTag', array('tagid' => $tagid, 'jsParams' => $jsParams, 'timestamp' => $timestamp));
    wfProfileOut(__METHOD__);
    return "<div{$style}>{$feedHTML}</div>{$snippets}";
}
コード例 #3
0
 /**
  * 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 .= JSSnippets::addToStack(array('/extensions/wikia/hacks/WelcomeBar/js/WelcomeBar.js'), array(), 'WelcomeBar.init');
     }
     return true;
 }
コード例 #4
0
 /**
  * parser hook for <twitteruser> tag
  * @author macbre
  * @return string tag body
  */
 public static function userTweetsParserHook($input, $args, $parser)
 {
     global $wgOut, $wgExtensionsPath, $wgTitle;
     $limit = isset($args['limit']) && intval($args['limit']) ? $args['limit'] : 5;
     $user = isset($args['username']) ? $args['username'] : '';
     if (empty($user)) {
         return '';
     }
     self::$userTweetsTagCount++;
     $tagId = 'cfUserTweetsTag' . self::$userTweetsTagCount;
     $tagBody = '<ul class="cfUserTweetsTag" id="' . $tagId . '">';
     $tagBody .= '<a href="http://twitter.com/' . urlencode($user) . '" target="_blank">Loading ...</a>';
     $tagBody .= '</ul>';
     $tagBody .= JSSnippets::addToStack(array('/extensions/wikia/ContentFeeds/js/ContentFeeds.js'), array(), 'ContentFeeds.getUserTweets', array('tagId' => $tagId, 'user' => $user, 'limit' => $limit));
     return $tagBody;
 }
コード例 #5
0
 protected function getAssets($widget)
 {
     wfProfileIn(__METHOD__);
     $name = $widget['type'];
     $assets = array();
     if (file_exists(dirname(__FILE__) . '/Widgets/' . $name . '/' . $name . '.js')) {
         $assets[] = "/extensions/wikia/WidgetFramework/Widgets/{$name}/{$name}.js";
     }
     if (file_exists(dirname(__FILE__) . '/Widgets/' . $name . '/' . $name . '.css')) {
         $assets[] = "/extensions/wikia/WidgetFramework/Widgets/{$name}/{$name}.css";
     }
     if (!empty($assets)) {
         $jsOut = JSSnippets::addToStack($assets);
     } else {
         $jsOut = '';
     }
     wfProfileOut(__METHOD__);
     return $jsOut;
 }
コード例 #6
0
ファイル: tabber.php プロジェクト: Tjorriemorrie/app
function renderTabber($paramstring, $params, $parser)
{
    global $wgExtensionsPath, $wgStyleVersion;
    $path = $wgExtensionsPath . '/3rdparty/tabber/';
    /*
     * Wikia Change Start @author: marzjan
     */
    $snippets = JSSnippets::addToStack(array('/extensions/3rdparty/tabber/tabber.js'), array('$.loadJQueryUI'));
    $htmlHeader = '<link rel="stylesheet" href="' . $path . 'tabber.css?' . $wgStyleVersion . '" TYPE="text/css" MEDIA="screen">' . $snippets . '<div class="tabber">';
    $htmlFooter = '</div>';
    /*
     * Wikia Change End
     */
    $htmlTabs = "";
    $arr = explode("|-|", $paramstring);
    foreach ($arr as $tab) {
        $htmlTabs .= buildTab($tab, $parser);
        # macbre: pass Parser object (refs RT #34513)
    }
    return $htmlHeader . $htmlTabs . $htmlFooter;
}
コード例 #7
0
 /**
  * Render Poll namespace page
  */
 public function view()
 {
     wfProfileIn(__METHOD__);
     // let MW handle basic stuff
     parent::view();
     $wg = F::app()->wg;
     // poll doesn't exist
     if (!$wg->Title->exists() || empty($this->mPoll)) {
         wfProfileOut(__METHOD__);
         return;
     }
     // set page title
     $question = wfMsg('wikiapoll-question', $this->mPoll->getTitle());
     $wg->Out->setPageTitle($question);
     // add CSS/JS
     $wg->Out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/WikiaPoll/css/WikiaPoll.scss'));
     $jsFile = JSSnippets::addToStack(array('/extensions/wikia/WikiaPoll/js/WikiaPoll.js'), array(), 'WikiaPoll.init');
     // render poll page
     $wg->Out->clearHTML();
     $wg->Out->addHTML($jsFile);
     $wg->Out->addHTML($this->mPoll->render());
     wfProfileOut(__METHOD__);
 }
コード例 #8
0
 public function executeIndex()
 {
     $this->gameId = $this->getVal('inWikiGameId', 1);
     $this->jsSnippet = JSSnippets::addToStack(array('/extensions/wikia/InWikiGame/js/InWikiGame.js'), null, 'InWikiGame.init', array('id' => 'InWikiGameWrapper-' . $this->gameId));
 }
コード例 #9
0
 /**
  * Return a HTML representation of the image slider
  *
  * @author Jakub Kurcek
  */
 private function renderSlider()
 {
     wfProfileIn(__METHOD__);
     // do not render empty sliders
     if (empty($this->mFiles)) {
         wfProfileOut(__METHOD__);
         return '';
     }
     $orientation = $this->getParam('orientation');
     // setup image serving for main images and navigation thumbnails
     if ($orientation == 'mosaic') {
         $imagesDimensions = array('w' => WikiaPhotoGalleryHelper::WIKIA_GRID_SLIDER_MOSAIC_MIN_IMG_WIDTH, 'h' => WikiaPhotoGalleryHelper::SLIDER_MOSAIC_MIN_IMG_HEIGHT);
         $sliderClass = 'mosaic';
         $thumbDimensions = array("w" => WikiaPhotoGalleryHelper::WIKIA_GRID_THUMBNAIL_MAX_WIDTH, "h" => 100);
     } else {
         $imagesDimensions = array('w' => WikiaPhotoGalleryHelper::SLIDER_MIN_IMG_WIDTH, 'h' => WikiaPhotoGalleryHelper::SLIDER_MIN_IMG_HEIGHT);
         if ($orientation == 'right') {
             $sliderClass = 'vertical';
             $thumbDimensions = array("w" => 110, "h" => 50);
         } else {
             $sliderClass = 'horizontal';
             $thumbDimensions = array("w" => 90, "h" => 70);
         }
     }
     $out = array();
     $sliderImageLimit = $orientation == 'mosaic' ? 5 : 4;
     foreach ($this->mFiles as $p => $pair) {
         /**
          * @var $nt Title
          * @var $text String
          * @var $link String
          */
         $nt = $pair[0];
         $text = $pair[1];
         $link = $pair[2];
         $linkText = $this->mData['images'][$p]['linktext'];
         $shortText = $this->mData['images'][$p]['shorttext'];
         $time = $descQuery = false;
         // parse link (RT #142515)
         $linkAttribs = $this->parseLink($nt->getLocalUrl(), $nt->getText(), $link);
         wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time, &$descQuery));
         $file = wfFindFile($nt, $time);
         if (is_object($file) && $nt->getNamespace() == NS_FILE) {
             list($adjWidth, $adjHeight) = $this->fitWithin($file, $imagesDimensions);
             if (F::app()->checkSkin('wikiamobile')) {
                 $imageUrl = wfReplaceImageServer($file->getUrl(), $file->getTimestamp());
             } else {
                 $imageUrl = $this->resizeURL($file, $imagesDimensions);
             }
             // generate navigation thumbnails
             $thumbUrl = $this->cropURL($file, $thumbDimensions);
             // Handle videos
             $videoHtml = false;
             $videoPlayButton = false;
             $navClass = '';
             if (WikiaFileHelper::isFileTypeVideo($file)) {
                 // Get HTML for main video image
                 $htmlParams = array('file-link' => true, 'linkAttribs' => array('class' => 'wikiaPhotoGallery-slider force-lightbox'));
                 $videoHtml = $file->transform(array('width' => $imagesDimensions['w']))->toHtml($htmlParams);
                 // Get play button overlay for little video thumb
                 $videoPlayButton = $this->videoPlayButton;
                 $navClass = 'xxsmall video-thumbnail';
             }
             $data = array('imageUrl' => $imageUrl, 'imageTitle' => Sanitizer::removeHTMLtags($text), 'imageName' => $file->getTitle()->getText(), 'imageKey' => $file->getTitle()->getDBKey(), 'imageShortTitle' => Sanitizer::removeHTMLtags($shortText), 'imageLink' => !empty($link) ? $linkAttribs['href'] : '', 'imageDescription' => Sanitizer::removeHTMLtags($linkText), 'imageThumbnail' => $thumbUrl, 'adjWidth' => $adjWidth, 'adjHeight' => $adjHeight, 'centerTop' => $imagesDimensions['h'] > $adjHeight ? intval(($imagesDimensions['h'] - $adjHeight) / 2) : 0, 'centerLeft' => $imagesDimensions['w'] > $adjWidth ? intval(($imagesDimensions['w'] - $adjWidth) / 2) : 0, 'videoHtml' => $videoHtml, 'videoPlayButton' => $videoPlayButton, 'navClass' => $navClass);
             if (F::app()->checkSkin('wikiamobile')) {
                 $origWidth = $file->getWidth();
                 $origHeight = $file->getHeight();
                 $size = WikiaMobileMediaService::calculateMediaSize($origWidth, $origHeight);
                 $thumb = $file->transform($size);
                 $imageAttribs = array('src' => wfReplaceImageServer($thumb->getUrl(), $file->getTimestamp()), 'width' => $size['width'], 'height' => $size['height']);
                 $imageParams = array('full' => $imageUrl);
                 if ($this->mParser) {
                     $this->mParser->replaceLinkHolders($text);
                 }
                 $data['mediaInfo'] = array('attributes' => $imageAttribs, 'parameters' => $imageParams, 'caption' => $text, 'noscript' => Xml::element('img', $imageAttribs, '', true));
             }
             $out[] = $data;
         }
         if (count($out) >= $sliderImageLimit) {
             break;
         }
     }
     $html = '';
     //check if we have something to show (images might not match required sizes)
     if (count($out)) {
         $template = new EasyTemplate(dirname(__FILE__) . '/templates');
         $template->set_vars(array('sliderClass' => $sliderClass, 'files' => $out, 'thumbDimensions' => $thumbDimensions, 'sliderId' => $this->mData['id'], 'imagesDimensions' => $imagesDimensions));
         if (F::app()->checkSkin('wikiamobile')) {
             $html = $template->render('renderWikiaMobileSlider');
         } else {
             if ($orientation == 'mosaic') {
                 $html = $template->render('renderMosaicSlider');
             } else {
                 $html = $template->render('renderSlider');
             }
         }
         if ($orientation == 'mosaic') {
             $sliderResources = array('wikia_photo_gallery_mosaic_js', 'wikia_photo_gallery_mosaic_scss');
             $javascriptInitializationFunction = 'WikiaMosaicSliderMasterControl.init';
         } else {
             $sliderResources = array('wikia_photo_gallery_slider_js', 'wikia_photo_gallery_slider_scss');
             $javascriptInitializationFunction = 'WikiaPhotoGallerySlider.init';
         }
         $html .= JSSnippets::addToStack($sliderResources, array(), $javascriptInitializationFunction, array($this->mData['id']));
         //load WikiaMobile resources if needed using JSSnippets filtering mechanism
         $html .= JSSnippets::addToStack(array('wikiaphotogallery_slider_scss_wikiamobile', 'wikiaphotogallery_slider_js_wikiamobile'));
     }
     wfProfileOut(__METHOD__);
     return $html;
 }
コード例 #10
0
 /**
  * Get JavaScript code snippet to be loaded
  */
 public static function getJSSnippet(array $options = array())
 {
     $am = AssetsManager::getInstance();
     $html = JSSnippets::addToStack(array('places_css', 'places_js'), array(), 'Places.init', $options);
     return $html;
 }
コード例 #11
0
 public static function renderGamingMapTag($content, array $attributes, Parser $parser, PPFrame $frame)
 {
     $app = F::app();
     //var_dump($attributes);
     //default map's valuse
     if (!isset($attributes['StartZoom'])) {
         $attributes['StartZoom'] = 0;
     }
     if (!isset($attributes['MaxZoom'])) {
         $attributes['MaxZoom'] = 10;
     }
     if (!isset($attributes['name'])) {
         $attributes['name'] = "A Map";
     }
     $aLines = preg_split('/\\r\\n|\\r|\\n/', $content);
     $aMarkers = array();
     $aDefMarkers = array();
     $aPolygons = array();
     $aTemp = array();
     //var_dump($content);
     /* $xmlVal = "<gamingmap img='wall2.jpg' name='Where is wally?'>
            <layer  name='Positions' id='pos' img='iPosIcon.png'>
                <marker lat='100' lon='50'>North(100,50)</marker>
                <marker lat='0' lon='50'>South(0,50)</marker>
                <marker lat='50' lon='0'>West(50,0)</marker>
                <marker lat='50' lon='50'>Mid(50,50)</marker>
                <marker lat='50' lon='100'>East(50,100)</marker>
                <marker lat='9' lon='9'>Wally?</marker>
            <polygon text='Somewhere here is wally'>
                <point lat='10' lon='10'/>
                <point lat='10' lon='20'/>
                <point lat='20' lon='20'/>
                <point lat='20' lon='10'/>
            </polygon>
            </layer>
            <layer  name='Cities' id='city' img='iCityIcon.png'>
                <marker lat='8.156' lon='10.352' type='city'>works?</marker>
            </layer>
            <layer  name='Quests' id='quest' img='iQuestIcon.png' />
        </gamingmap>";*/
     $xmlVal = '<?xml version="1.0" encoding="UTF-8"?><root>' . trim($content) . '</root>';
     $simplyxml = new SimpleXMLElement($xmlVal);
     foreach ($simplyxml->children() as $node) {
         $arr = $node->attributes();
         // returns an array
         if ($node->children()) {
             $aDefMarkers[] = array('name' => (string) $arr["name"], 'id' => (string) $arr["id"], 'img' => self::getUrlIMG((string) $arr["img"]), 'view' => (string) $arr["view"]);
             foreach ($node->children() as $nodeNodes) {
                 if (trim($nodeNodes->getName()) == 'marker') {
                     $arr2 = $nodeNodes->attributes();
                     // returns an array
                     if ($arr2["title"]) {
                         $aMarkers[] = array('lat' => (string) $arr2["lat"], 'lon' => (string) $arr2["lon"], 'id' => (string) $arr["id"], 'content' => "", 'title' => (string) $arr2["title"]);
                     } else {
                         $aMarkers[] = array('lat' => (string) $arr2["lat"], 'lon' => (string) $arr2["lon"], 'id' => (string) $arr["id"], 'content' => (string) $nodeNodes, 'title' => "");
                     }
                 } elseif (trim($nodeNodes->getName()) == 'polygon') {
                     $aPolygons[] = self::setPolygon($nodeNodes, (string) $arr["id"]);
                 }
             }
         }
     }
     /*foreach($aDefMarkers as $val)
       {
           if(!empty($val))
           {
               $val[2]=self::getUrlIMG($val[2]);
           }
       }*/
     /*$imgFile = wfFindFile( $attributes['img']);
       if($imgFile->exists()){
           $app->sendRequest("GamingMaps", "createMap", array( 'oImage' => $imgFile )); //send values to controller
       }*/
     $aDefMarkers[sizeof($aDefMarkers)] = array('name' => 'Others', 'id' => 'other', 'img' => self::getUrlIMG('iOtherIcon.png'), 'true');
     // create default marker
     $mapa = $app->sendRequest("GamingMaps", "index", array('attr' => $attributes, 'markers' => $aMarkers));
     //send values to controller
     $mapa = str_replace("\n", "", $mapa);
     $mapa .= JSSnippets::addToStack(array('/extensions/wikia/GamingMaps/js/Leaflet.js', '/extensions/wikia/GamingMaps/js/Maps.js', '/extensions/wikia/GamingMaps/css/Leaflet.css'), array(), 'Maps.init', array('attr' => $attributes, 'markers' => $aMarkers, 'defMarkers' => $aDefMarkers, 'polygons' => $aPolygons));
     return $mapa;
 }
コード例 #12
0
 /**
  * @brief Gets JavaScript code snippet to be loaded
  *
  * @param Array $options passed to callback javascript function
  *
  * @return string
  */
 private static function getJSSnippet($options)
 {
     $html = JSSnippets::addToStack(array('/extensions/wikia/WikiaRSS/js/WikiaRss.js'), array(), 'WikiaRss.init', $options);
     return $html;
 }
コード例 #13
0
 /**
  * Called in index action to manipulate the view based on the user's skin
  * @return boolean true
  */
 protected function handleSkinSettings()
 {
     global $wgCityId;
     $this->wg->Out->addHTML(JSSnippets::addToStack(array("/extensions/wikia/Search/js/WikiaSearch.js")));
     $this->wg->SuppressRail = true;
     if ($this->isCorporateWiki()) {
         OasisController::addBodyClass('inter-wiki-search');
         $this->setVal('corporateWikiId', $wgCityId);
         $this->overrideTemplate('CrossWiki_index');
     }
     $skin = $this->wg->User->getSkin();
     if ($skin instanceof SkinMonoBook) {
         $this->response->addAsset('extensions/wikia/Search/monobook/monobook.scss');
     }
     if ($skin instanceof SkinOasis || $skin instanceof SkinVenus) {
         $this->response->addAsset('extensions/wikia/Search/css/WikiaSearch.scss');
     }
     if ($skin instanceof SkinWikiaMobile) {
         $this->overrideTemplate('WikiaMobileIndex');
     }
     return true;
 }
コード例 #14
0
ファイル: AjaxPoll_body.php プロジェクト: yusufchang/app
 /**
  * render
  *
  * render HTML code of poll
  *
  * @access public
  * @author Krzysztof Krzyżaniak (eloy)
  * @author Marooned (switching to JSSnippets)
  *
  * @return string: rendered HTML code
  */
 public function render()
 {
     global $wgRequest, $wgContLang;
     wfProfileIn(__METHOD__);
     wfDebug("AjaxPoll: rendering poll #" . self::$mCount . "\n");
     /**
      * check, maybe form is submited?
      */
     if ($wgRequest->wasPosted()) {
         wfDebug(__METHOD__ . "(): posted without ajax\n");
         $this->doSubmit($wgRequest);
     }
     /**
      * save if not saved
      */
     $this->save();
     wfDebug(__METHOD__ . "(): rendering Ajax poll {$this->mId}\n");
     list($question, $answers) = $this->parseInput();
     list($votes, $total) = $this->getVotes();
     $before = '<!-- AjaxPoll #' . self::$mCount . ' -->';
     // load CSS/JS only when needed
     $before .= JSSnippets::addToStack(array('/extensions/wikia/AjaxPoll/css/AjaxPoll.scss', '/extensions/wikia/AjaxPoll/js/AjaxPoll.js'), array(), 'AjaxPoll.init');
     $oTmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $timestamp = wfTimestamp(TS_MW, $this->mCreated);
     $oTmpl->set_vars(array('id' => $this->mId, 'votes' => $votes, 'total' => $total, 'answers' => $answers, 'question' => $question, 'title' => $this->mTitle, 'status' => $this->mStatus, 'attribs' => $this->mAttribs, 'created_time' => $wgContLang->time($timestamp), 'created_date' => $wgContLang->date($timestamp)));
     $before .= $oTmpl->render('poll');
     $out = '';
     /**
      * trim lines to avoid parser false behaviour
      */
     $lines = explode("\n", $before);
     if (is_array($lines)) {
         foreach ($lines as $line) {
             $out .= trim($line);
         }
     } else {
         $out = trim($before);
     }
     self::$mCount++;
     /**
      * because this parser tag contains elements of interface we need to
      * inform parser to vary parser cache key by user lang option
      */
     $this->mParser->mOutput->recordOption('userlang');
     wfProfileOut(__METHOD__);
     return $out;
 }
コード例 #15
0
<div id="<?php 
echo $mapId;
?>
" class="places-map" style="width:100%; height:<?php 
echo $height;
?>
px"></div>
<?php 
echo JSSnippets::addToStack(array('places_css', 'places_js'), array('$.loadGoogleMaps'), 'Places.renderMap', array_merge(array('mapId' => $mapId, 'markers' => $markers, 'center' => $center), $options));
コード例 #16
0
function ImagePlaceholderMakePlaceholder($file, $frameParams, $handlerParams)
{
    wfProfileIn(__METHOD__);
    global $wgRequest, $wgWikiaImagePlaceholderId, $wgWikiaVideoPlaceholderId, $wgContLang, $wgTitle;
    // Shortcuts
    $fp =& $frameParams;
    $hp =& $handlerParams;
    global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright, $wgRTEParserEnabled;
    $plc_tag = '';
    $plc_tag = $wgContLang->getFormattedNsText(NS_FILE) . ':' . wfMsgForContent('imgplc-placeholder');
    isset($hp['options']) && is_string($hp['options']) && '' != $hp['options'] ? $wikitext = '[[' . $plc_tag . '|' . $hp['options'] . ']]' : ($wikitext = '[[' . $plc_tag . ']]');
    $prefix = $postfix = '';
    $thumb = false;
    $frame = false;
    $caption = '';
    $link = '';
    $align = '';
    $isalign = 0;
    $isthumb = 0;
    $iswidth = 0;
    $iscaption = 0;
    $islink = 0;
    $isvideo = 0;
    if (!empty($hp['isvideo'])) {
        $isvideo = 1;
    }
    if (isset($hp['width']) && 0 != $hp['width']) {
        // FCK takes 0
        $width = $hp['width'];
        // if too small, the box will end up looking... extremely silly
        if ($width < IMG_PLC_MIN_WIDTH) {
            $width = IMG_PLC_MIN_WIDTH;
        }
        $iswidth = $width;
    } else {
        $width = IMG_PLC_DEF_WIDTH;
    }
    $height = $width;
    if (isset($fp['thumbnail'])) {
        $thumb = true;
        $isthumb = 1;
    }
    if (isset($fp['frame'])) {
        $frame = true;
    }
    if (isset($fp['align'])) {
        if ('left' == $fp['align'] || 'right' == $fp['align'] || 'center' == $fp['align']) {
            $align = $fp['align'];
            'left' == $fp['align'] ? $isalign = 1 : ($isalign = 2);
        }
    } else {
        $thumb || $frame ? $align = 'right' : ($align = '');
    }
    // set margin accordingly to alignment, identical to normal Image: -- RT#21368
    // FIXME: this REALLY should be done in a class
    $margin = '';
    if (isset($align)) {
        if ($align == 'right') {
            $margin = 'margin: 0.5em 0 1.2em 1.4em;';
        } else {
            if ($align == 'center') {
                $margin = 'margin: 0.5em auto 1.2em;';
            } else {
                $margin = 'margin: 0.5em 1.4em 1.2em 0;';
            }
        }
    }
    if (isset($fp['caption'])) {
        $caption = $fp['caption'];
        $iscaption = 1;
    }
    if (isset($fp['link'])) {
        $link = $fp['link'];
        $islink = 1;
    }
    $height = $width;
    // this is for positioning the "Add Image" button
    $lmarg = ceil(($width - 90) / 2);
    $tmarg = ceil(($height - 30) / 2);
    $additionalClass = '';
    if ($isvideo) {
        $additionalClass .= ' wikiaVideoPlaceholder';
    } else {
        $additionalClass .= ' wikiaImagePlaceholder';
    }
    // render HTML (RT #21087)
    $out = '';
    $wrapperAttribs = array('class' => "gallerybox wikiaPlaceholder{$additionalClass}");
    // ImagePlaceholders still use id attribute, videos use data-id attribute. Images should be updated to match videos at some point
    if (!$isvideo) {
        $wrapperAttribs['id'] = "WikiaImagePlaceholder{$wgWikiaImagePlaceholderId}";
    }
    if (isset($refid)) {
        $wrapperAttribs['refid'] = $refid;
    }
    $out .= Xml::openElement('div', $wrapperAttribs);
    $out .= Xml::openElement('div', array('class' => "thumb t{$align} videobox", 'style' => "height: {$height}px; width: {$width}px;"));
    $linkAttrs = array('id' => "WikiaImagePlaceholderInner{$wgWikiaImagePlaceholderId}", 'class' => 'wikia-button', 'style' => "top: {$tmarg}px;", 'href' => $wgTitle instanceof Title ? $wgTitle->getLocalUrl(array('action' => 'edit')) : '#', 'data-id' => $isvideo ? $wgWikiaVideoPlaceholderId : $wgWikiaImagePlaceholderId, 'data-align' => $isalign, 'data-thumb' => $isthumb, 'data-caption' => htmlspecialchars($caption), 'data-width' => $width);
    if (!$isvideo) {
        // image placeholder
        $linkAttrs = array_merge($linkAttrs, array('data-link' => htmlspecialchars($link), 'data-width' => $width));
    }
    $out .= Xml::openElement('a', $linkAttrs);
    $out .= $isvideo ? wfMsg('imgplc-add-video') : wfMsg('imgplc-add-image');
    $out .= Xml::closeElement('a');
    // caption (RT #47460)
    if ($caption != '') {
        $out .= Xml::element('span', array('class' => 'thumbcaption'), $caption);
    }
    $out .= Xml::closeElement('div') . Xml::closeElement('div') . Xml::closeElement('td');
    // increase counter
    if ($isvideo) {
        $wgWikiaVideoPlaceholderId++;
    } else {
        $wgWikiaImagePlaceholderId++;
    }
    // dirty hack for CK support
    global $wgRTEParserEnabled;
    if (!empty($wgRTEParserEnabled)) {
        $out = RTEParser::renderMediaPlaceholder(array('type' => $isvideo ? 'video-placeholder' : 'image-placeholder', 'params' => array('width' => $width, 'height' => $height, 'caption' => $caption, 'align' => $align, 'isAlign' => $isalign, 'isThumb' => $isthumb)));
    } else {
        $out .= JSSnippets::addToStack(array('/extensions/wikia/ImagePlaceholder/js/MediaPlaceholder.js'), array(), 'MediaPlaceholder.init');
    }
    wfProfileOut(__METHOD__);
    return $out;
}
コード例 #17
0
 /**
  * Return HTML to be used when embedding polls from inside parser
  * TODO: replace all this with a hook inside parser
  *
  * @param WikiaPoll $poll
  * @param Title $finalTitle
  */
 public static function generate($poll, $finalTitle)
 {
     wfProfileIn(__METHOD__);
     if ($finalTitle instanceof Title && $finalTitle->exists() && $finalTitle->getNamespace() == NS_WIKIA_POLL) {
         $app = F::app();
         $ret = $poll->renderEmbedded();
         if (self::$alreadyAddedCSSJS == false) {
             // make sure we don't include twice if there are multiple polls on one page
             self::$alreadyAddedCSSJS = true;
             // add CSS & JS and Poll HTML together
             if ($app->checkSkin('wikiamobile')) {
                 $cssLinks = AssetsManager::getInstance()->getURL('wikiapoll_wikiamobile_scss');
                 $jsLinks = AssetsManager::getInstance()->getURL('wikiapoll_wikiamobile_js');
                 $css = '';
                 $js = '';
                 if (is_array($cssLinks)) {
                     foreach ($cssLinks as $s) {
                         $css .= "<link rel=stylesheet href={$s} />";
                     }
                 }
                 if (is_array($jsLinks)) {
                     foreach ($jsLinks as $s) {
                         $js .= "<script src={$s}></script>";
                     }
                 }
                 $js .= JSMessages::printPackages(array('WikiaMobilePolls'));
                 $ret = str_replace("\n", ' ', "{$css}{$ret}{$js}");
             } else {
                 $sassUrl = AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaPoll/css/WikiaPoll.scss');
                 $css = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($sassUrl) . ' " />';
                 $jsFile = JSSnippets::addToStack(array('/extensions/wikia/WikiaPoll/js/WikiaPoll.js'), array(), 'WikiaPoll.init');
                 $ret = str_replace("\n", ' ', "{$css} {$ret} {$jsFile}");
             }
         }
         wfProfileOut(__METHOD__);
         return $ret;
     }
     wfProfileOut(__METHOD__);
     return '';
 }
コード例 #18
0
ファイル: TabView.php プロジェクト: Tjorriemorrie/app
function tabviewRender($input, $params, $parser)
{
    global $tabsCount;
    if (isset($params['id']) && $params['id'] != '' && strpos($params['id'], '<') === false && strpos($params['id'], '>') === false) {
        $id = $params['id'];
        $id = preg_replace('/[^A-Za-z0-9_]/', '', $id);
    }
    if (empty($id)) {
        $id = $tabsCount++;
    }
    // remove empty lines
    $tabs = array_filter(explode("\n", $input));
    if (isset($tabs[0]) && $tabs[0] == "") {
        unset($tabs[0]);
    }
    if ($tabs[count($tabs)] == "") {
        unset($tabs[count($tabs)]);
    }
    // prepeare tabs options array
    $options = array();
    $optionsIndex = $index = 0;
    foreach ($tabs as $tab) {
        $onetab = explode('|', trim($tab));
        if (isset($onetab[0]) && strpos($onetab[0], '<') === false && strpos($onetab[0], '>') === false) {
            $titleObj = Title::newFromText($onetab[0]);
            if (is_object($titleObj) && $titleObj->exists()) {
                $url = $titleObj->getLocalURL('action=render');
                $text = $titleObj->getFullText();
                if (isset($onetab[1]) && strpos($onetab[1], '<') === false && strpos($onetab[1], '>') === false) {
                    if ($onetab[1] != '') {
                        $text = $onetab[1];
                    }
                    if (isset($onetab[2])) {
                        if ($onetab[2] != '') {
                            $noCache = strtolower($onetab[2]) == 'false';
                        }
                        if (isset($onetab[3])) {
                            if ($onetab[3] != '') {
                                if (strtolower($onetab[3]) == 'true') {
                                    $optionsIndex = $index;
                                }
                            }
                        }
                    }
                }
                // prepare flytab options array
                $options[] = array('caption' => $text, 'url' => $url);
            }
        }
        $index++;
        unset($url, $text, $noCache, $active);
    }
    //$out = '<script>wgAfterContentAndJS.push(function() { $.loadJQueryUI(function(){ $("#flytabs_'.$id.'").tabs({ cache: true, selected: '.$optionsIndex.' }); });});</script>';
    $out = '<div id="flytabs_' . $id . '"><ul>';
    foreach ($options as $option) {
        $out .= '<li><a href="' . $option['url'] . '"><span>' . $option['caption'] . '</span></a></li>';
    }
    $out .= '</ul></div>';
    // lazy load JS
    $out .= JSSnippets::addToStack(array('/extensions/wikia/TabView/js/TabView.js', '/resources/wikia/libraries/mustache/mustache.js'), array(), 'TabView.init', array('id' => 'flytabs_' . $id, 'selected' => $optionsIndex));
    return $out;
}