示例#1
0
/**
 * Add a 'todo' tab on user pages
 * @param SkinTemplate $skin
 * @param array $actions
 * @return bool true to continue running hooks, false to abort operation
 */
function todoAddTab( $skin, &$actions ) {
	if ( $skin->getTitle()->getNamespace() == NS_USER || $skin->getTitle()->getNamespace() == NS_USER_TALK ) {
		$title = SpecialPage::getTitleFor( 'Todo', $skin->getTitle()->getText() );
		$actions['todo'] = array(
			'text' => wfMsg( 'todo-tab' ),
			'href' => $title->getLocalUrl() );
	}
	return true;
}
 /**
  * @param SkinTemplate $skintemplate
  * @param $nav_urls
  * @param $oldid
  * @param $revid
  * @return bool
  */
 public static function onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink(&$skintemplate, &$nav_urls, &$oldid, &$revid)
 {
     // check whether we’re in the right namespace, the $revid has the correct type and is not empty
     // (which would mean that the current page doesn’t exist)
     $title = $skintemplate->getTitle();
     if ($title->isContentPage() && $revid !== 0 && !empty($revid)) {
         $nav_urls['citeThisPage'] = array('args' => array('page' => $title->getPrefixedDBkey(), 'id' => $revid));
     }
     return true;
 }
function wfSpecialTalkHook( SkinTemplate &$skin_template, array &$content_actions ) {
	$title = Title::makeTitle( NS_PROJECT_TALK, $skin_template->getTitle()->getText() );

	$content_actions['talk'] = $skin_template->tabAction(
		$title,
		// msg
		'talk',
		// selected
		false,
		// &query=
		'',
		// check existance
		true
	);

	return true;
}
示例#4
0
 /**
  * Add variables to SkinTemplate
  */
 public static function onSkinTemplateOutputPageBeforeExec(SkinTemplate $skinTemplate, QuickTemplate $tpl)
 {
     wfProfileIn(__METHOD__);
     $out = $skinTemplate->getOutput();
     $title = $skinTemplate->getTitle();
     # quick hack for rt#15730; if you ever feel temptation to add 'elseif' ***CREATE A PROPER HOOK***
     if ($title instanceof Title && NS_CATEGORY == $title->getNamespace()) {
         // FIXME
         $tpl->set('pagetitle', preg_replace("/^{$title->getNsText()}:/", '', $out->getHTMLTitle()));
     }
     // Pass parameters to skin, see: Login friction project (Marooned)
     $tpl->set('thisurl', $title->getPrefixedURL());
     $tpl->set('thisquery', $skinTemplate->thisquery);
     wfProfileOut(__METHOD__);
     return true;
 }
 /**
  * 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;
 }
 /**
  * Adds Focus tab to main navigation
  * @param SkinTemplate $sktemplate
  * @param BaseTemplate $tpl
  * @return boolean Always true to keep hook running
  */
 public function onSkinTemplateOutputPageBeforeExec(&$sktemplate, &$tpl)
 {
     $aViews = array();
     $oUser = $sktemplate->getUser();
     $oCurrentTitle = $sktemplate->getTitle();
     $sEditLink = '';
     if ($oUser->isLoggedIn() === false) {
         $this->getDefaultWidgets($aViews, $oUser, $oCurrentTitle);
     } else {
         $oTitle = Title::makeTitle(NS_USER, $oUser->getName() . '/Sidebar');
         $sEditLink = Linker::link($oTitle, '', array('id' => 'bs-usersidebar-edit', 'class' => 'icon-pencil'), array('action' => 'edit', 'preload' => ''));
         if ($oTitle->exists() === false) {
             $this->getDefaultWidgets($aViews, $oUser, $oTitle);
         } else {
             $aWidgets = BsWidgetListHelper::getInstanceForTitle($oTitle)->getWidgets();
             if (empty($aWidgets)) {
                 $this->getDefaultWidgets($aViews, $oUser, $oTitle);
             }
             $aViews = array_merge($aViews, $aWidgets);
         }
     }
     $aOut = array();
     $aOut[] = $sEditLink;
     foreach ($aViews as $oView) {
         if ($oView instanceof ViewBaseElement) {
             $aOut[] = $oView->execute();
         }
     }
     if ($tpl instanceof BsBaseTemplate) {
         $tpl->data['bs_navigation_main']['bs-usersidebar'] = array('position' => 20, 'label' => wfMessage('bs-tab_focus')->plain(), 'class' => 'icon-clipboard', 'content' => implode("\n", $aOut));
     } else {
         $tpl->data['sidebar'][wfMessage('bs-tab_focus')->plain()] = implode("\n", $aOut);
     }
     return true;
 }
 /**
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateTabs
  * This is here for compatibility with MediaWiki 1.17. Once we can require 1.18, we can ditch this code :)
  *
  * @since 0.1
  *
  * @param SkinTemplate $skinTemplate
  * @param array $contentActions
  *
  * @return boolean
  */
 public static function addRefreshTab(SkinTemplate $skinTemplate, array &$contentActions)
 {
     global $wgUser;
     if ($wgUser->isAllowed('purge')) {
         $contentActions['purge'] = array('class' => false, 'text' => wfMessage('smw_purge')->text(), 'href' => $skinTemplate->getTitle()->getLocalUrl(array('action' => 'purge')));
     }
     return true;
 }
 /**
  * Regular talk page "Create source" and "Add topic" links are quite useless
  * in the context of Flow boards. Let's get rid of them.
  *
  * @param SkinTemplate $template
  * @param array $links
  * @return bool
  */
 public static function onSkinTemplateNavigation(SkinTemplate &$template, &$links)
 {
     global $wgFlowCoreActionWhitelist, $wgMFPageActions;
     $title = $template->getTitle();
     // if Flow is enabled on this talk page, overrule talk page red link
     if (self::$occupationController->isTalkpageOccupied($title)) {
         // Turn off page actions in MobileFrontend.
         // FIXME: Find more elegant standard way of doing this.
         $wgMFPageActions = array();
         // watch star & delete links are inside the topic itself
         if ($title->getNamespace() === NS_TOPIC) {
             unset($links['actions']['watch']);
             unset($links['actions']['unwatch']);
             unset($links['actions']['delete']);
         }
         // hide all views unless whitelisted
         foreach ($links['views'] as $action => $data) {
             if (!in_array($action, $wgFlowCoreActionWhitelist)) {
                 unset($links['views'][$action]);
             }
         }
         // hide all actions unless whitelisted
         foreach ($links['actions'] as $action => $data) {
             if (!in_array($action, $wgFlowCoreActionWhitelist)) {
                 unset($links['actions'][$action]);
             }
         }
         if (isset($links['namespaces']['topic_talk'])) {
             // hide discussion page in Topic namespace(which is already discussion)
             unset($links['namespaces']['topic_talk']);
             // hide protection (topic protection is done via moderation)
             unset($links['actions']['protect']);
             // topic pages are also not movable
             unset($links['actions']['move']);
         }
     }
     return true;
 }
 /**
  * Hook-Handler for 'BlueSpiceSkin:Widgets'. Adds Widgets to the Widgetbar.
  * @param SkinTemplate $sktemplate
  * @param BaseTemplate $tpl
  * @return boolean Always true to keep hook running
  */
 public function onSkinTemplateOutputPageBeforeExec(&$sktemplate, &$tpl)
 {
     $oCurrentTitle = $sktemplate->getTitle();
     $oUser = $sktemplate->getUser();
     $oView = $this->getWidgets($oCurrentTitle, $oUser);
     if ($tpl instanceof BsBaseTemplate) {
         $tpl->data['bs_dataBeforeContent']['bs-widgetbar'] = array('position' => 10, 'label' => wfMessage('prefs-widgetbar')->text(), 'content' => $oView);
     } else {
         $tpl->data['prebodyhtml'] .= $oView;
     }
     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;
 }
示例#11
0
 /**
  * Show the tab
  * @param SkinTemplate $skin
  * @param array $content_actions
  * @return bool true to continue running other hooks, false to abort operation
  */
 public static function onSkinTemplateNavigation($skin, &$content_actions)
 {
     # Checked for HTML and MySQL insertion attacks
     global $wgRequest;
     $title = $skin->getTitle();
     if ($title->isTalkPage()) {
         # No talk pages please
         return true;
     }
     if ($title->getNamespace() < 0) {
         # No special pages please
         return true;
     }
     $content_actions['actions']['tasks'] = array('class' => $wgRequest->getVal('action', 'view') == 'tasks' ? 'selected' : false, 'text' => wfMsgHTML('tasks_tab'), 'href' => $title->getLocalUrl('action=tasks'));
     return true;
 }
 /**
  * Hook-Handler for 'SkinTemplateOutputPageBeforeExec'. Creates the Readers list below an article.
  * @param SkinTemplate $sktemplate a collection of views. Add the view that needs to be displayed
  * @param BaseTemplate $tpl currently logged in user. Not used in this context.
  * @return bool always true
  */
 public function onSkinTemplateOutputPageBeforeExec(&$sktemplate, &$tpl)
 {
     if ($this->checkContext() === false || !$sktemplate->getTitle()->userCan('viewreaders')) {
         return true;
     }
     if (!$sktemplate->getTitle()->userCan('viewreaders')) {
         return true;
     }
     $oViewReaders = $this->getReadersViewForAfterContent($sktemplate->getTitle());
     $tpl->data['bs_dataAfterContent']['bs-readers'] = array('position' => 20, 'label' => wfMessage('bs-readers-title')->text(), 'content' => $oViewReaders);
     return true;
 }
 /**
  * Creates the StateBar. on articles.
  * @param SkinTemplate $sktemplate
  * @param BaseTemplate $tpl
  * @return boolean Always true to keep hook running
  */
 public function onSkinTemplateOutputPageBeforeExec(&$sktemplate, &$tpl)
 {
     if (BsExtensionManager::isContextActive('MW::StateBarShow') === false) {
         return true;
     }
     if (!is_null($this->oRedirectTargetTitle)) {
         $oTitle = $this->oRedirectTargetTitle;
     }
     wfRunHooks('BSStateBarBeforeTopViewAdd', array($this, &$this->aTopViews, $sktemplate->getUser(), $sktemplate->getTitle(), $sktemplate));
     if (count($this->aTopViews) == 0) {
         // TODO RBV (01.07.11 18:26): Ain't this too late?
         BsExtensionManager::removeContext('MW::StateBarShow');
         return true;
     }
     $aSortTopVars = BsConfig::get('MW::StateBar::SortTopVars');
     if (!empty($aSortTopVars)) {
         $this->aTopViews = $this->reorderViews($this->aTopViews, $aSortTopVars);
     }
     $oViewStateBar = new ViewStateBar();
     foreach ($this->aTopViews as $mKey => $oTopView) {
         $oViewStateBar->addStateBarTopView($oTopView);
     }
     if ($tpl instanceof BsBaseTemplate) {
         $tpl->data['bs_dataBeforeContent']['bs-statebar'] = array('position' => 20, 'label' => wfMessage('prefs-statebar')->text(), 'content' => $oViewStateBar);
     } else {
         //this is the case when BlueSpice Skin is not active, so use vector methods.
         $tpl->data['prebodyhtml'] .= $oViewStateBar;
     }
     return true;
 }
 /**
  * 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());
                     }
                 }
             }
         }
     }
 }