/**
  * SkinTemplateOutputPageBeforeExec hook handler
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateOutputPageBeforeExec
  *
  * Adds a link to view the current page in 'mobile view' to the desktop footer.
  *
  * @param SkinTemplate $skin
  * @param QuickTemplate $tpl
  * @return bool
  */
 public static function onSkinTemplateOutputPageBeforeExec(&$skin, &$tpl)
 {
     $title = $skin->getTitle();
     $context = MobileContext::singleton();
     if (!$context->isBlacklistedPage()) {
         $footerlinks = $tpl->data['footerlinks'];
         $args = $skin->getRequest()->getQueryValues();
         // avoid title being set twice
         unset($args['title']);
         unset($args['useformat']);
         $args['mobileaction'] = 'toggle_view_mobile';
         $mobileViewUrl = $title->getFullURL($args);
         $mobileViewUrl = MobileContext::singleton()->getMobileUrl($mobileViewUrl);
         $link = Html::element('a', array('href' => $mobileViewUrl, 'class' => 'noprint stopMobileRedirectToggle'), wfMessage('mobile-frontend-view')->text());
         $tpl->set('mobileview', $link);
         $footerlinks['places'][] = 'mobileview';
         $tpl->set('footerlinks', $footerlinks);
     }
     return true;
 }
 /**
  * Modifies the logo on runtime
  * @param SkinTemplate $sktemplate
  * @param BaseTemplate $tpl
  * @return boolean Always true to keep hook running
  */
 public static function onSkinTemplateOutputPageBeforeExec(&$sktemplate, &$tpl)
 {
     $sFlexiskin = $sktemplate->getRequest()->getVal('flexiskin');
     if ($sFlexiskin || BsConfig::get('MW::Flexiskin::Active') != '') {
         $sId = $sFlexiskin != '' ? $sFlexiskin : BsConfig::get('MW::Flexiskin::Active');
         if ($sId != "default") {
             $bPreview = $sktemplate->getRequest()->getVal('preview', false);
             $api = new ApiMain(new DerivativeRequest($sktemplate->getRequest(), array('action' => 'flexiskin', 'type' => 'get', 'mode' => 'config', 'id' => $sId, 'preview' => $bPreview), false), true);
             $api->execute();
             $aResult = $api->getResultData();
             $oResult = FormatJson::decode($aResult['flexiskin']);
             if ($oResult->success === false) {
                 return true;
             }
             $aConfig = FormatJson::decode($oResult->config);
             $sLogo = BsConfig::get("MW::Flexiskin::Logo");
             if ($sLogo == "") {
                 return true;
             }
             $sPath = BS_DATA_PATH . "/flexiskin/" . $sId . "/images/";
             $tpl->set('logopath', $sPath . $sLogo);
             return true;
         }
         return true;
     }
     return true;
 }
 public static function addApprovalButton(SkinTemplate &$sktemplate, array &$links)
 {
     $title = $sktemplate->getRelevantTitle();
     $user = $sktemplate->getUser();
     if ($sktemplate->isRevisionCurrent() && ApprovedRevs::isAssignedToProject($title) && ApprovedRevs::userCanApprovePage($title, $user) && !ApprovedRevs::isLatestRevisionApproved($title)) {
         /* This is somewhat a replication of code from SkinTemplate::buildContentNavigationUrls() */
         $onPage = $title->equals($sktemplate->getTitle());
         $request = $sktemplate->getRequest();
         $action = $request->getVal('action', 'view');
         /* /Code Replication */
         $isInAction = $onPage && $action == 'approveprojectpage';
         $links['actions']['approveprojectpage'] = array('text' => 'אישור הדף', 'href' => $title->getLocalURL('action=approveprojectpage'), 'class' => $isInAction ? 'selected' : '');
     }
     return true;
 }
コード例 #4
0
 /**
  * Display the tabs for a course or institution.
  *
  * @since 0.1
  *
  * @param SkinTemplate $sktemplate
  * @param array $links
  * @param Title $title
  */
 protected static function displayTabs(SkinTemplate &$sktemplate, array &$links, Title $title)
 {
     $classes = array(EP_NS_INSTITUTION => 'EPOrg', EP_NS_COURSE => 'EPCourse');
     $exists = null;
     if (array_key_exists($title->getNamespace(), $classes)) {
         $links['views'] = array();
         $links['actions'] = array();
         $user = $sktemplate->getUser();
         $class = $classes[$title->getNamespace()];
         $exists = $class::hasIdentifier($title->getText());
         $type = $sktemplate->getRequest()->getText('action');
         $isSpecial = $sktemplate->getTitle()->isSpecialPage();
         if ($exists) {
             $links['views']['view'] = array('class' => !$isSpecial && $type === '' ? 'selected' : false, 'text' => wfMsg('ep-tab-view'), 'href' => $title->getLocalUrl());
         }
         if ($user->isAllowed($class::getEditRight())) {
             $links['views']['edit'] = array('class' => $type === 'edit' ? 'selected' : false, 'text' => wfMsg($exists ? 'ep-tab-edit' : 'ep-tab-create'), 'href' => $title->getLocalUrl(array('action' => 'edit')));
         }
         if ($exists) {
             $links['views']['history'] = array('class' => $type === 'history' ? 'selected' : false, 'text' => wfMsg('ep-tab-history'), 'href' => $title->getLocalUrl(array('action' => 'history')));
             if ($title->getNamespace() === EP_NS_COURSE) {
                 if ($user->isAllowed('ep-enroll')) {
                     $student = EPStudent::newFromUser($user);
                     if ($student === false || !$student->hasCourse(array('name' => $title->getText()))) {
                         $links['views']['enroll'] = array('class' => $isSpecial ? 'selected' : false, 'text' => wfMsg('ep-tab-enroll'), 'href' => SpecialPage::getTitleFor('Enroll', $title->getText())->getLocalURL());
                     }
                 }
             }
         }
     }
 }