/**
  * Make a "what links here" link for a given title
  *
  * @param Title $title Title to make the link for
  * @param Skin $skin Skin to use
  * @param object $result Result row
  * @return string
  */
 private function makeWlhLink($title, $skin, $result)
 {
     global $wgLang;
     $wlh = SpecialPage::getTitleFor('Whatlinkshere');
     $label = wfMsgExt('nlinks', array('parsemag', 'escape'), $wgLang->formatNum($result->value));
     return $skin->link($wlh, $label, array(), array('target' => $title->getPrefixedText()));
 }
Example #2
0
 public static function onBeforePageDisplay(\OutputPage &$output, \Skin &$skin)
 {
     $title = $output->getTitle();
     // Disallow commenting on pages without article id
     if ($title->getArticleID() == 0) {
         return true;
     }
     if ($title->isSpecialPage()) {
         return true;
     }
     // These could be explicitly allowed in later version
     if (!$title->canTalk()) {
         return true;
     }
     if ($title->isTalkPage()) {
         return true;
     }
     if ($title->isMainPage()) {
         return true;
     }
     // Do not display when printing
     if ($output->isPrintable()) {
         return true;
     }
     // Disable if not viewing
     if ($skin->getRequest()->getVal('action', 'view') != 'view') {
         return true;
     }
     // Blacklist several namespace
     if (in_array($title->getNamespace(), array(NS_MEDIAWIKI, NS_TEMPLATE, NS_CATEGORY, NS_FILE, NS_USER))) {
         return true;
     }
     $output->addModules('ext.pagerating');
     return true;
 }
Example #3
0
function deletefontform_submit(Pieform $form, $values)
{
    global $SESSION;
    $fontname = $values['font'];
    $result = delete_records('skin_fonts', 'name', $fontname);
    if ($result == false) {
        $SESSION->add_error_msg(get_string('cantdeletefont', 'skin'));
    } else {
        // Check to see if the font is being used in a skin. If it is remove it from
        // the skin's viewskin data
        $skins = get_records_array('skin');
        if (is_array($skins)) {
            foreach ($skins as $skin) {
                $options = unserialize($skin->viewskin);
                foreach ($options as $key => $option) {
                    if (preg_match('/font_family/', $key) && $option == $fontname) {
                        require_once get_config('docroot') . 'lib/skin.php';
                        $skinobj = new Skin($skin->id);
                        $viewskin = $skinobj->get('viewskin');
                        $viewskin[$key] = 'Arial';
                        // the default font
                        $skinobj->set('viewskin', $viewskin);
                        $skinobj->commit();
                    }
                }
            }
        }
        // Also delete all the files in the appropriate folder and the folder itself...
        $fontpath = get_config('dataroot') . 'skins/fonts/' . $fontname;
        recurse_remove_dir($fontpath);
        $SESSION->add_ok_msg(get_string('fontdeleted', 'skin'));
    }
    redirect('/admin/site/fonts.php');
}
    public static function onSkinAfterBottomScripts(Skin $skin, &$text)
    {
        global $wgWRGoogleSearchEnableSitelinksSearch, $wgWRGoogleSearchCSEID;
        if (!$wgWRGoogleSearchEnableSitelinksSearch || empty($wgWRGoogleSearchCSEID) || !$skin->getTitle()->isMainPage()) {
            return true;
        }
        $mainPageUrl = Title::newFromText(wfMessage('mainpage')->plain())->getFullURL();
        $searchUrl = SpecialPage::getTitleFor('WRGoogleSearch')->getFullURL();
        $sitelinksSearch = <<<HTML

\t<script type="application/ld+json">
\t\t{
\t\t\t"@context": "http://schema.org",
\t  \t\t"@type": "WebSite",
\t\t\t"url": "{$mainPageUrl}",
\t\t\t"potentialAction": {
\t\t\t\t"@type": "SearchAction",
\t\t\t    "target": "{$searchUrl}?q={search_term_string}",
\t\t\t    "query-input": "required name=search_term_string"
\t  \t\t}
\t\t}
\t</script>

HTML;
        $text .= $sitelinksSearch;
        return true;
    }
    private static function getFbPixelScript(Skin $skin)
    {
        global $egFacebookConversionPixelId;
        if (empty($egFacebookConversionPixelId)) {
            throw new MWException("You must set \$egFacebookConversionPixelId to the Pixel ID supplied by Facebook");
        }
        if ($skin->getUser()->isAllowed('noanalytics')) {
            return "\n<!-- Facebook Conversion Pixel tracking is disabled for this user -->\n";
        }
        $script = <<<SCRIPT
‪<script>(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
  _fbq.push(['addPixelId', '{$egFacebookConversionPixelId}']);
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', 'PixelInitialized', {}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id={$egFacebookConversionPixelId}&amp;ev=PixelInitialized" /></noscript>‬
SCRIPT;
        return $script;
    }
Example #6
0
 public static function initializeSkins()
 {
     Doctrine::getTable('Location')->getRecordListener()->get('MultiTenant')->setOption('disabled', true);
     Doctrine::getTable('User')->getRecordListener()->get('MultiTenant')->setOption('disabled', true);
     // Install stock Bluebox skin
     $skin = new Skin();
     $skin->name = 'Bluebox';
     $skin->location = 'skins/bluebox';
     $skin->default = TRUE;
     $skin->save();
     // Map all sites with no skin assigned to this default skin
     $sites = Doctrine::getTable('Site')->findAll();
     if ($sites) {
         foreach ($sites as $site) {
             if ($site->skin_id == NULL) {
                 $site->skin_id = $skin->skin_id;
                 $site->save();
                 $site->free(TRUE);
             }
         }
     }
     $skin->free(TRUE);
     Doctrine::getTable('Location')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
     Doctrine::getTable('User')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
 }
Example #7
0
 public static function onSkinBuildSidebar(\Skin $skin, &$bar)
 {
     $relevUser = $skin->getRelevantUser();
     if ($relevUser) {
         $bar['sidebar-section-extension'][] = array('text' => wfMsg('sidebar-viewavatar'), 'href' => \SpecialPage::getTitleFor('ViewAvatar')->getLocalURL(array('user' => $relevUser->getName())), 'id' => 'n-viewavatar', 'active' => '');
     }
     return true;
 }
 /**
  * @brief Adds Wall Notifications script to Monobook pages
  *
  * @return boolean
  *
  * @author Liz Lee
  */
 public static function onSkinAfterBottomScripts(Skin $skin, &$text)
 {
     global $wgUser, $wgJsMimeType, $wgResourceBasePath, $wgExtensionsPath;
     if ($wgUser instanceof User && $wgUser->isLoggedIn() && $skin->getSkinName() == 'monobook') {
         $text .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgResourceBasePath}/resources/wikia/libraries/jquery/timeago/jquery.timeago.js\"></script>\n" . "<script type=\"{$wgJsMimeType}\" src=\"{$wgExtensionsPath}/wikia/WallNotifications/scripts/WallNotifications.js\"></script>\n";
     }
     return true;
 }
 /**
  * @brief Adds Wall Notifications script to Monobook pages
  *
  * @return boolean
  *
  * @author Liz Lee
  */
 public function onSkinAfterBottomScripts(Skin $skin, &$text)
 {
     $app = F::App();
     $user = $app->wg->User;
     if ($user instanceof User && $user->isLoggedIn() && $skin->getSkinName() == 'monobook') {
         $text .= "<script type=\"{$app->wg->JsMimeType}\" src=\"{$app->wg->ResourceBasePath}/resources/wikia/libraries/jquery/timeago/jquery.timeago.js\"></script>\n" . "<script type=\"{$app->wg->JsMimeType}\" src=\"{$app->wg->ExtensionsPath}/wikia/Wall/js/WallNotifications.js\"></script>\n";
     }
     return true;
 }
Example #10
0
 public static function fnSetOutput(OutputPage &$out, Skin &$skin)
 {
     global $wpdBundle;
     $page_path = explode('/', $skin->getTitle());
     for ($pp = 1; count($page_path) >= $pp; $pp++) {
         $path_part = implode('/', array_slice($page_path, 0, $pp));
         self::$menuhtml .= '<li data-comment="Not removing underscore here"><a href="' . $wpdBundle['root_uri'] . str_replace(' ', '_', $path_part) . '">' . str_replace('_', ' ', $page_path[$pp - 1]) . '</a></li>';
     }
     return true;
 }
 /**
  * Hook function to draw the wenu
  */
 static function createMenu(Skin $skin, &$bar)
 {
     global $dsmDebug;
     $menu = new DynamicSidebarMenu($skin->getRelevantTitle());
     $options = array("parent" => "/");
     $menu->options($options);
     $text = $menu->render();
     $bar["DynamicSidebarMenu"] = "<div id=\"DSM\">{$text}</div>";
     return true;
 }
 public static function onSkinAfterBottomScripts(Skin $skin, &$text)
 {
     $title = $skin->getTitle();
     if (TemplateDraftHelper::allowedForTitle($title)) {
         $scripts = AssetsManager::getInstance()->getURL('template_draft');
         foreach ($scripts as $script) {
             $text .= Html::linkedScript($script);
         }
     }
     return true;
 }
Example #13
0
/**
 * Helper function (called by smarty()) to determine what stylesheets to include
 * on the page (based on constants, global variables, and $extraconfig)
 *
 * @param $stylesheets Stylesheets we already know we're going to need
 * @param $extraconfig Extra configuration passed to smarty()
 * @return array
 */
function get_stylesheets_for_current_page($stylesheets, $extraconfig)
{
    global $USER, $SESSION, $THEME, $HEADDATA, $langselectform;
    // stylesheet set up - if we're in a plugin also get its stylesheet
    $allstylesheets = $THEME->get_url('style/style.css', true);
    // determine if we want to include the parent css
    if (isset($THEME->overrideparentcss) && $THEME->overrideparentcss && $THEME->parent) {
        unset($allstylesheets[$THEME->parent]);
    }
    $stylesheets = array_merge($stylesheets, array_reverse(array_values($allstylesheets)));
    if (defined('SECTION_PLUGINTYPE') && defined('SECTION_PLUGINNAME') && SECTION_PLUGINTYPE != 'core') {
        if ($pluginsheets = $THEME->get_url('style/style.css', true, SECTION_PLUGINTYPE . '/' . SECTION_PLUGINNAME)) {
            $stylesheets = array_merge($stylesheets, array_reverse($pluginsheets));
        }
    }
    if ($adminsection = in_admin_section()) {
        if ($adminsheets = $THEME->get_url('style/admin.css', true)) {
            $stylesheets = array_merge($stylesheets, array_reverse($adminsheets));
        }
    }
    if (get_config('developermode') & DEVMODE_DEBUGCSS) {
        $stylesheets[] = get_config('wwwroot') . 'theme/debug.css';
    }
    // look for extra stylesheets
    if (isset($extraconfig['stylesheets']) && is_array($extraconfig['stylesheets'])) {
        foreach ($extraconfig['stylesheets'] as $extrasheet) {
            if ($sheets = $THEME->get_url($extrasheet, true)) {
                $stylesheets = array_merge($stylesheets, array_reverse(array_values($sheets)));
            }
        }
    }
    if ($sheets = $THEME->additional_stylesheets()) {
        $stylesheets = array_merge($stylesheets, $sheets);
    }
    // Give the skin a chance to affect the page
    if (!empty($extraconfig['skin'])) {
        require_once get_config('docroot') . '/lib/skin.php';
        $skinobj = new Skin($extraconfig['skin']['skinid']);
        $viewid = isset($extraconfig['skin']['viewid']) ? $extraconfig['skin']['viewid'] : null;
        $stylesheets = array_merge($stylesheets, $skinobj->get_stylesheets($viewid));
    }
    $langdirection = get_string('thisdirection', 'langconfig');
    // Include rtl.css for right-to-left langs
    if ($langdirection == 'rtl') {
        $smarty->assign('LANGDIRECTION', 'rtl');
        if ($rtlsheets = $THEME->get_url('style/rtl.css', true)) {
            $stylesheets = array_merge($stylesheets, array_reverse($rtlsheets));
        }
    }
    $stylesheets = append_version_number($stylesheets);
    return $stylesheets;
}
Example #14
0
function deleteskin_submit(Pieform $form, $values)
{
    global $SESSION, $USER, $skinid, $redirect;
    $skin = new Skin($skinid, null);
    if ($skin->get('owner') == $USER->get('id') || $USER->get('admin')) {
        $skin->delete();
        unlink(get_config('dataroot') . 'skins/' . $skinid . '.png');
        $SESSION->add_ok_msg(get_string('skindeleted', 'skin'));
    } else {
        $SESSION->add_error_msg(get_string('cantdeleteskin', 'skin'));
    }
    redirect($redirect);
}
Example #15
0
 /**
  * @param IContextSource|Skin $obj
  * @throws MWException
  */
 public function __construct($obj)
 {
     if ($obj instanceof Skin) {
         // @todo: deprecate constructing with Skin
         $context = $obj->getContext();
     } else {
         if (!$obj instanceof IContextSource) {
             throw new MWException('EnhancedChangesList must be constructed with a ' . 'context source or skin.');
         }
         $context = $obj;
     }
     parent::__construct($context);
     // message is set by the parent ChangesList class
     $this->cacheEntryFactory = new RCCacheEntryFactory($context, $this->message);
 }
Example #16
0
 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!($delta = SQL::count($result))) {
         return $text;
     }
     // flag idle users
     $idle = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600);
     // process all items in the list
     $count = 0;
     $items = array();
     while ($item = SQL::fetch($result)) {
         // url to view the user
         $url = Users::get_permalink($item);
         // initialize variables
         $prefix = $suffix = '';
         // signal restricted and private users
         if (isset($item['active']) && $item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif (isset($item['active']) && $item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // signal locked profiles
         if (isset($item['capability']) && $item['capability'] == '?') {
             $prefix .= EXPIRED_FLAG;
         }
         // item title
         if (isset($item['full_name']) && $item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
             $hover = $item['nick_name'];
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
             $hover = $item['full_name'];
         }
         // flag idle users
         if (!isset($item['click_date']) || $item['click_date'] < $idle) {
             $class = 'idle user';
         } else {
             $class = 'user';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, $class, NULL, $hover);
         // provide only some results
         if (++$count >= 5) {
             break;
         }
     }
     // end of processing
     SQL::free($result);
     // turn this to some text
     $text = Skin::build_list($items, 'comma');
     // some indications on the number of connections
     if ($delta -= $count) {
         $text .= ', ...';
     }
     return $text;
 }
Example #17
0
    /**
     * Get ready for displaying the skin.
     *
     * This may register some CSS or JS...
     */
    function display_init()
    {
        // call parent:
        parent::display_init();
        // Add CSS:
        require_css('basic_styles.css', 'blog');
        // the REAL basic styles
        require_css('basic.css', 'blog');
        // Basic styles
        require_css('blog_base.css', 'blog');
        // Default styles for the blog navigation
        require_css('item_base.css', 'blog');
        // Default styles for the post CONTENT
        // Make sure standard CSS is called ahead of custom CSS generated below:
        require_css('style.css', true);
        // Add custom CSS:
        $custom_css = '';
        if ($body_bg_color = $this->get_setting('body_bg_color')) {
            // Custom Header background color:
            $custom_css .= '	body { background-color: ' . $body_bg_color . " }\n";
        }
        if (!empty($custom_css)) {
            $custom_css = '<style type="text/css">
	<!--
' . $custom_css . '	-->
	</style>';
            add_headline($custom_css);
        }
        // Colorbox (a lightweight Lightbox alternative) allows to zoom on images and do slideshows with groups of images:
        if ($this->get_setting("colorbox")) {
            require_js_helper('colorbox', 'blog');
        }
    }
Example #18
0
 /**
  * list links
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&amp;', $item['link_url']);
         // initialize variables
         $prefix = $suffix = '';
         // flag links that are dead, or created or updated very recently
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG;
         }
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // the main anchor link
         if (is_object($anchor)) {
             $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * @param ResourceLoader $resourceLoader
  * @param WebRequest $request
  */
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $resourceLoader->getConfig()->get('ResourceLoaderDebug'));
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     $this->raw = $request->getFuzzyBool('raw');
     // Image requests
     $this->image = $request->getVal('image');
     $this->variant = $request->getVal('variant');
     $this->format = $request->getVal('format');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $resourceLoader->getConfig()->get('DefaultSkin');
     }
 }
Example #20
0
 /**
  * Prepare data output
  *
  * @since 1.8
  *
  * @param array $data label => value
  */
 protected function getFormatOutput(array $data)
 {
     //Init
     $dataObject = array();
     static $statNr = 0;
     $chartID = 'sparkline-' . $this->params['charttype'] . '-' . ++$statNr;
     $this->isHTML = true;
     // Prepare data array
     foreach ($data as $key => $value) {
         if ($value >= $this->params['min']) {
             $dataObject['label'][] = $key;
             $dataObject['value'][] = $value;
         }
     }
     $dataObject['charttype'] = $this->params['charttype'];
     // Encode data objects
     $requireHeadItem = array($chartID => FormatJson::encode($dataObject));
     SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
     // RL module
     SMWOutputs::requireResource('ext.srf.sparkline');
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement(false);
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
     // Beautify class selector
     $class = $this->params['class'] ? ' ' . $this->params['class'] : '';
     // Chart/graph wrappper
     return Html::rawElement('span', array('class' => 'srf-sparkline' . $class), $processing . $chart);
 }
Example #21
0
 function display_init()
 {
     global $Messages, $debug;
     // Request some common features that the parent function (Skin::display_init()) knows how to provide:
     parent::display_init(array('jquery', 'font_awesome', 'bootstrap', 'bootstrap_evo_css', 'bootstrap_messages', 'style_css', 'colorbox', 'bootstrap_init_tooltips', 'disp_auto'));
     // Skin specific initializations:
 }
Example #22
0
 /**
  * list images
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the image
         $url = Images::get_url($item['id']);
         // initialize variables
         $prefix = $suffix = '';
         // flag new images
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // image title or image name
         $label = Skin::strip($item['title'], 10);
         if (!$label) {
             $name_as_title = TRUE;
             $label = ucfirst($item['image_name']);
         }
         $label = str_replace('_', ' ', str_replace('%20', ' ', $label));
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 protected function getDefaultHeaderVars()
 {
     global $wgRequest, $wgLanguageCode, $wgSSLsite, $wgUser;
     $t = $this->t;
     $articleName = $t->getText();
     $action = $wgRequest->getVal('action', 'view');
     $deviceOpts = $this->getDevice();
     $pageExists = $t->exists();
     $randomUrl = '/' . wfMsg('special-randomizer');
     $isMainPage = $articleName == wfMsg('mainpage');
     $titleBar = $isMainPage ? wfMsg('mobile-mainpage-title') : wfMsg('pagetitle', $articleName);
     $canonicalUrl = 'http://' . MobileWikihow::getNonMobileSite() . '/' . $t->getPartialURL();
     if ($wgUser->getID() > 0) {
         $login_link = '/Special:Mypage';
         $login_text = wfMsg('me');
     } else {
         $login_link = '/Special:Userlogin';
         $login_text = wfMsg('log_in');
     }
     if (SSL_LOGIN_DOMAIN && !$wgSSLsite) {
         $login_link = 'https://' . SSL_LOGIN_DOMAIN . $login_link;
     }
     $headerVars = array('isMainPage' => $isMainPage, 'title' => $titleBar, 'css' => $this->cssScriptsCombine, 'randomUrl' => $randomUrl, 'deviceOpts' => $deviceOpts, 'canonicalUrl' => $canonicalUrl, 'pageExists' => $pageExists, 'jsglobals' => Skin::makeGlobalVariablesScript(array('skinname' => 'mobile')), 'lang' => $wgLanguageCode, 'loginlink' => $login_link, 'logintext' => $login_text);
     return $headerVars;
 }
 /**
  * Get the Skin object
  *
  * @return Skin
  */
 public function getSkin()
 {
     if ($this->skin === null) {
         wfProfileIn(__METHOD__ . '-createskin');
         $skin = null;
         wfRunHooks('RequestContextCreateSkin', array($this, &$skin));
         // If the hook worked try to set a skin from it
         if ($skin instanceof Skin) {
             $this->skin = $skin;
         } elseif (is_string($skin)) {
             $this->skin = Skin::newFromKey($skin);
         }
         // If this is still null (the hook didn't run or didn't work)
         // then go through the normal processing to load a skin
         if ($this->skin === null) {
             global $wgHiddenPrefs;
             if (!in_array('skin', $wgHiddenPrefs)) {
                 # get the user skin
                 $userSkin = $this->getUser()->getOption('skin');
                 $userSkin = $this->getRequest()->getVal('useskin', $userSkin);
             } else {
                 # if we're not allowing users to override, then use the default
                 global $wgDefaultSkin;
                 $userSkin = $wgDefaultSkin;
             }
             $this->skin = Skin::newFromKey($userSkin);
         }
         // After all that set a context on whatever skin got created
         $this->skin->setContext($this);
         wfProfileOut(__METHOD__ . '-createskin');
     }
     return $this->skin;
 }
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return an array of $url => (NULL, $title, NULL, 'section_123', NULL, 'visit this section')
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // no hovering label
     $href_title = '';
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $suffix = '';
         // list all components for this item
         $items[$url] = array($prefix, ucfirst(Skin::strip($item['index_title'], 30)), $suffix, 'section_' . $item['id'], NULL, $href_title);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfig($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion, $wgSearchType;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgSearchType' => $wgSearchType, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values(array_unique($wgFileExtensions)), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion, 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled);
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
 /**
  * @param ResourceLoader $resourceLoader
  * @param WebRequest $request
  */
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     $this->logger = $resourceLoader->getLogger();
     // Future developers: Avoid use of getVal() in this class, which performs
     // expensive UTF normalisation by default. Use getRawVal() instead.
     // Values here are either one of a finite number of internal IDs,
     // or previously-stored user input (e.g. titles, user names) that were passed
     // to this endpoint by ResourceLoader itself from the canonical value.
     // Values do not come directly from user input and need not match.
     // List of modules
     $modules = $request->getRawVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : [];
     // Various parameters
     $this->user = $request->getRawVal('user');
     $this->debug = $request->getFuzzyBool('debug', $resourceLoader->getConfig()->get('ResourceLoaderDebug'));
     $this->only = $request->getRawVal('only', null);
     $this->version = $request->getRawVal('version', null);
     $this->raw = $request->getFuzzyBool('raw');
     // Image requests
     $this->image = $request->getRawVal('image');
     $this->variant = $request->getRawVal('variant');
     $this->format = $request->getRawVal('format');
     $this->skin = $request->getRawVal('skin');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $resourceLoader->getConfig()->get('DefaultSkin');
     }
 }
Example #28
0
 /**
  *
  */
 function setupSkinUserCss(OutputPage $out)
 {
     global $wgContLang;
     $qb = $this->qbSetting();
     $rules = array();
     if (2 == $qb) {
         # Right
         $rules[] = "#quickbar { position: absolute; top: 4px; right: 4px; border-left: 2px solid #000000; }";
         $rules[] = "#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }";
     } elseif (1 == $qb || 3 == $qb) {
         $rules[] = "#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }";
         $rules[] = "#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }";
         if (3 == $qb) {
             $rules[] = "#quickbar { position: fixed; padding: 4px; }";
         }
     } elseif (4 == $qb) {
         $rules[] = "#quickbar { position: fixed; right: 0px; top: 0px; padding: 4px;}";
         $rules[] = "#quickbar { border-right: 1px solid gray; }";
         $rules[] = "#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }";
     }
     $style = implode("\n", $rules);
     if ($wgContLang->getDir() === 'rtl') {
         $style = CSSJanus::transform($style, true, false);
     }
     $out->addInlineStyle($style);
     parent::setupSkinUserCss($out);
 }
 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
 private function getUsersData($usersObjects)
 {
     $key = 0;
     $usersInvolved = array();
     $sorting = array();
     foreach ($usersObjects as $user) {
         if ($user->isAnon()) {
             $name = wfMsg('oasis-anon-user');
         }
         $username = $user->getName();
         $userpage = $user->getUserPage()->getFullUrl();
         $usersInvolved[$key]['userpage'] = $userpage;
         if (empty($name)) {
             $usersInvolved[$key]['name1'] = $username;
             $sorting[$key] = $username;
         } else {
             $usersInvolved[$key]['name1'] = $name;
             $usersInvolved[$key]['name2'] = $username;
             // if user has real name and is not an anon use the real name
             // if he's an anon use username
             $sorting[$key] = $user->isAnon() ? $username : $name;
         }
         $usersInvolved[$key]['username'] = $username;
         $usersInvolved[$key]['userpage'] = $userpage;
         $usersInvolved[$key]['userwall'] = Title::newFromText($username, NS_USER_WALL)->getFullUrl();
         $usersInvolved[$key]['usertalk'] = Title::newFromText($username, NS_USER_TALK)->getFullUrl();
         $usersInvolved[$key]['usercontribs'] = Skin::makeSpecialUrl('Contributions') . '/' . $username;
         $usersInvolved[$key]['userblock'] = Skin::makeSpecialUrl('Block') . '/' . $username;
         $key++;
     }
     $sorting = array_map('mb_strtolower', $sorting);
     array_multisort($sorting, SORT_ASC, SORT_STRING, $usersInvolved);
     return $usersInvolved;
 }