[MediaWiki-commits] [Gerrit] changed pdf export link to be displayed in the toolbox if bl... - change (mediawiki...BlueSpiceExtensions)

2015-03-12 Thread Tweichart (Code Review)
Tweichart has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/196169

Change subject: changed pdf export link to be displayed in the toolbox if 
bluespiceskin is not active
..

changed pdf export link to be displayed in the toolbox if bluespiceskin is not 
active

Change-Id: I1d3461c87b605dd37adf22a39c265aaf94045e05
---
M UEModulePDF/UEModulePDF.class.php
1 file changed, 56 insertions(+), 28 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/69/196169/1

diff --git a/UEModulePDF/UEModulePDF.class.php 
b/UEModulePDF/UEModulePDF.class.php
index 1c8698c..4980d66 100644
--- a/UEModulePDF/UEModulePDF.class.php
+++ b/UEModulePDF/UEModulePDF.class.php
@@ -93,6 +93,7 @@
$this-setHook('BSUniversalExportGetWidget');
$this-setHook('BSUniversalExportSpecialPageExecute');
$this-setHook('SkinTemplateOutputPageBeforeExec');
+   $this-setHook('BaseTemplateToolbox');
wfProfileOut( 'BS::'.__METHOD__ );
}
 
@@ -200,7 +201,58 @@
return true;
}
 
-   public function onSkinTemplateOutputPageBeforeExec($skin, $template){
+   /**
+* Hook to insert the PDF-Export link if BlueSpiceSkin is active
+* @param SkinTemplate $oSkin
+* @param QuickTemplate $oTemplate
+* @return boolean
+*/
+   public function onSkinTemplateOutputPageBeforeExec( $oSkin, 
$oTemplate ) {
+   if ( !$oTemplate instanceof BsBaseTemplate ) {
+   return true;
+   }
+
+   $oTemplate-data['bs_title_actions'][] = 
$this-buildContentAction();
+
+   return true;
+   }
+
+   /**
+* Hook to be executed when the Vector Skin is activated to add the 
PDF-Export Link to the Toolbox
+* @param SkinTemplate $oTemplate
+* @param Array $aToolbox
+* @return boolean
+*/
+   public function onBaseTemplateToolbox( $oTemplate, $aToolbox ) {
+   $oTitle = RequestContext::getMain()-getTitle();
+   //if the BlueSpiceSkin is activated we don't need to add the 
Link to the Toolbox,
+   //onSkinTemplateOutputPageBeforeExec will handle it
+   if ( $oTemplate instanceof BsBaseTemplate || 
!$oTitle-isContentPage() ) {
+   return true;
+   }
+
+   //if print is set insert pdf export afterwards
+   if ( isset( $aToolbox['print'] ) ) {
+   $aToolboxNew = array();
+   foreach ( $aToolbox as $sKey = $aValue ) {
+   $aToolboxNew[$sKey] = $aValue;
+   if ( $sKey === print ) {
+   $aToolboxNew['uemodulepdf'] = 
$this-buildContentAction();
+   }
+   }
+   $aToolbox = $aToolboxNew;
+   } else {
+   $aToolbox['uemodulepdf'] = $this-buildContentAction();
+   }
+
+   return true;
+   }
+
+   /**
+* Builds the ContentAction Array fort the current page
+* @return Array The ContentAction Array
+*/
+   private function buildContentAction() {
$aCurrentQueryParams = $this-getRequest()-getValues();
if ( isset( $aCurrentQueryParams['title'] ) ) {
$sTitle = $aCurrentQueryParams['title'];
@@ -213,37 +265,13 @@
unset( $aCurrentQueryParams['title'] );
}
$aCurrentQueryParams['ue[module]'] = 'pdf';
-   $aContentActions = array(
+   return array(
'id' = 'bs-ta-uemodulepdf',
'href' = $oSpecialPage-getLinkUrl( 
$aCurrentQueryParams ),
'title' = wfMessage( 
'bs-uemodulepdf-widgetlink-single-no-attachments-title' )-text(),
-   'text' = 
wfMessage('bs-uemodulepdf-widgetlink-single-no-attachments-text')-text(),
+   'text' = wfMessage( 
'bs-uemodulepdf-widgetlink-single-no-attachments-text' )-text(),
'class' = 'icon-file-pdf'
);
-
-   if ( $template instanceof BsBaseTemplate ) {
-   $template-data['bs_title_actions'][] = 
$aContentActions;
-   } else {
-   //this is the case when BlueSpice Skin is not active, 
so use vector methods.
-   $template-data['prebodyhtml'] = Html::rawElement(
-   span,
-   array('class' = 
'bs-ta-uemodulepdf-container'),
-   Html::rawElement(
-   'a',
-   

[MediaWiki-commits] [Gerrit] changed pdf export link to be displayed in the toolbox if bl... - change (mediawiki...BlueSpiceExtensions)

2015-03-12 Thread Robert Vogel (Code Review)
Robert Vogel has submitted this change and it was merged.

Change subject: changed pdf export link to be displayed in the toolbox if 
bluespiceskin is not active
..


changed pdf export link to be displayed in the toolbox if bluespiceskin is not 
active

Change-Id: I1d3461c87b605dd37adf22a39c265aaf94045e05
---
M UEModulePDF/UEModulePDF.class.php
1 file changed, 56 insertions(+), 28 deletions(-)

Approvals:
  Robert Vogel: Verified; Looks good to me, approved



diff --git a/UEModulePDF/UEModulePDF.class.php 
b/UEModulePDF/UEModulePDF.class.php
index 1c8698c..4980d66 100644
--- a/UEModulePDF/UEModulePDF.class.php
+++ b/UEModulePDF/UEModulePDF.class.php
@@ -93,6 +93,7 @@
$this-setHook('BSUniversalExportGetWidget');
$this-setHook('BSUniversalExportSpecialPageExecute');
$this-setHook('SkinTemplateOutputPageBeforeExec');
+   $this-setHook('BaseTemplateToolbox');
wfProfileOut( 'BS::'.__METHOD__ );
}
 
@@ -200,7 +201,58 @@
return true;
}
 
-   public function onSkinTemplateOutputPageBeforeExec($skin, $template){
+   /**
+* Hook to insert the PDF-Export link if BlueSpiceSkin is active
+* @param SkinTemplate $oSkin
+* @param QuickTemplate $oTemplate
+* @return boolean
+*/
+   public function onSkinTemplateOutputPageBeforeExec( $oSkin, 
$oTemplate ) {
+   if ( !$oTemplate instanceof BsBaseTemplate ) {
+   return true;
+   }
+
+   $oTemplate-data['bs_title_actions'][] = 
$this-buildContentAction();
+
+   return true;
+   }
+
+   /**
+* Hook to be executed when the Vector Skin is activated to add the 
PDF-Export Link to the Toolbox
+* @param SkinTemplate $oTemplate
+* @param Array $aToolbox
+* @return boolean
+*/
+   public function onBaseTemplateToolbox( $oTemplate, $aToolbox ) {
+   $oTitle = RequestContext::getMain()-getTitle();
+   //if the BlueSpiceSkin is activated we don't need to add the 
Link to the Toolbox,
+   //onSkinTemplateOutputPageBeforeExec will handle it
+   if ( $oTemplate instanceof BsBaseTemplate || 
!$oTitle-isContentPage() ) {
+   return true;
+   }
+
+   //if print is set insert pdf export afterwards
+   if ( isset( $aToolbox['print'] ) ) {
+   $aToolboxNew = array();
+   foreach ( $aToolbox as $sKey = $aValue ) {
+   $aToolboxNew[$sKey] = $aValue;
+   if ( $sKey === print ) {
+   $aToolboxNew['uemodulepdf'] = 
$this-buildContentAction();
+   }
+   }
+   $aToolbox = $aToolboxNew;
+   } else {
+   $aToolbox['uemodulepdf'] = $this-buildContentAction();
+   }
+
+   return true;
+   }
+
+   /**
+* Builds the ContentAction Array fort the current page
+* @return Array The ContentAction Array
+*/
+   private function buildContentAction() {
$aCurrentQueryParams = $this-getRequest()-getValues();
if ( isset( $aCurrentQueryParams['title'] ) ) {
$sTitle = $aCurrentQueryParams['title'];
@@ -213,37 +265,13 @@
unset( $aCurrentQueryParams['title'] );
}
$aCurrentQueryParams['ue[module]'] = 'pdf';
-   $aContentActions = array(
+   return array(
'id' = 'bs-ta-uemodulepdf',
'href' = $oSpecialPage-getLinkUrl( 
$aCurrentQueryParams ),
'title' = wfMessage( 
'bs-uemodulepdf-widgetlink-single-no-attachments-title' )-text(),
-   'text' = 
wfMessage('bs-uemodulepdf-widgetlink-single-no-attachments-text')-text(),
+   'text' = wfMessage( 
'bs-uemodulepdf-widgetlink-single-no-attachments-text' )-text(),
'class' = 'icon-file-pdf'
);
-
-   if ( $template instanceof BsBaseTemplate ) {
-   $template-data['bs_title_actions'][] = 
$aContentActions;
-   } else {
-   //this is the case when BlueSpice Skin is not active, 
so use vector methods.
-   $template-data['prebodyhtml'] = Html::rawElement(
-   span,
-   array('class' = 
'bs-ta-uemodulepdf-container'),
-   Html::rawElement(
-   'a',
-   array(
-