jenkins-bot has submitted this change and it was merged.

Change subject: UEModulePDF: Fix for templates, backend and upload
......................................................................


UEModulePDF: Fix for templates, backend and upload

* Fixed stylings for TOC indention in default PDF templates
* PDF backend now overrides tmp files in debug mode
* Implemented upload size threshold to avoid out-of-memory issues in JAVA

PatchSet 3:
* Fixed newbie bug in foreach statement

Change-Id: I45e783f06897f701cf5e5a3e029b02cd4f18adb5
---
M UEModulePDF/UEModulePDF.setup.php
M UEModulePDF/data/PDFTemplates/BlueSpice Landscape/stylesheets/styles.css
M UEModulePDF/data/PDFTemplates/BlueSpice/stylesheets/styles.css
M UEModulePDF/includes/PDFServlet.class.php
M UEModulePDF/webservices/BShtml2PDF.war
5 files changed, 91 insertions(+), 60 deletions(-)

Approvals:
  Robert Vogel: Looks good to me, approved
  Tweichart: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/UEModulePDF/UEModulePDF.setup.php 
b/UEModulePDF/UEModulePDF.setup.php
index 79a5fda..57d86b7 100644
--- a/UEModulePDF/UEModulePDF.setup.php
+++ b/UEModulePDF/UEModulePDF.setup.php
@@ -2,8 +2,16 @@
 
 BsExtensionManager::registerExtension( 'UEModulePDF', 
BsRUNLEVEL::FULL|BsRUNLEVEL::REMOTE, BsACTION::LOAD_SPECIALPAGE );
 
+/**
+ * Allows modification for CURL request. E.g. setting an CA file for HTTPS
+ */
 $bsgUEModulePDFCURLOptions = array();
 
+/**
+ * This value is considered when asseta are being uploaded to the PDF service
+ */
+$bsgUEModulePDFUploadThreshold = 50 * 1024 * 1024;
+
 $wgMessagesDirs['UEModulePDF'] = __DIR__ . '/i18n';
 
 $wgExtensionMessagesFiles['UEModulePDF'] = __DIR__ . 
'/languages/UEModulePDF.i18n.php';
diff --git a/UEModulePDF/data/PDFTemplates/BlueSpice 
Landscape/stylesheets/styles.css b/UEModulePDF/data/PDFTemplates/BlueSpice 
Landscape/stylesheets/styles.css
index 3474cc0..fa576c1 100644
--- a/UEModulePDF/data/PDFTemplates/BlueSpice Landscape/stylesheets/styles.css
+++ b/UEModulePDF/data/PDFTemplates/BlueSpice Landscape/stylesheets/styles.css
@@ -74,12 +74,12 @@
        color:#6c6d6f;
 }
 
-div.bs-tableofcontentspage .toclevel-1, .toclevel-1 { margin-left: 0cm; }
-div.bs-tableofcontentspage .toclevel-2, .toclevel-2 { margin-left: 0.1cm; }
-div.bs-tableofcontentspage .toclevel-3, .toclevel-3 { margin-left: 0.2cm; }
-div.bs-tableofcontentspage .toclevel-4, .toclevel-4 { margin-left: 0.3cm; }
-div.bs-tableofcontentspage .toclevel-5, .toclevel-5 { margin-left: 0.4cm; }
-div.bs-tableofcontentspage .toclevel-6, .toclevel-6 { margin-left: 0.5cm; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-1 { margin-left: 0em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-2 { margin-left: 2em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-3 { margin-left: 4em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-4 { margin-left: 6em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-5 { margin-left: 8em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-6 { margin-left: 10em; }
 
 td.bs-wiki-article-ancestors-table-left,
 td.bs-wiki-article-ancestors-table-right { width: 50%;}
diff --git a/UEModulePDF/data/PDFTemplates/BlueSpice/stylesheets/styles.css 
b/UEModulePDF/data/PDFTemplates/BlueSpice/stylesheets/styles.css
index 3474cc0..fa576c1 100644
--- a/UEModulePDF/data/PDFTemplates/BlueSpice/stylesheets/styles.css
+++ b/UEModulePDF/data/PDFTemplates/BlueSpice/stylesheets/styles.css
@@ -74,12 +74,12 @@
        color:#6c6d6f;
 }
 
-div.bs-tableofcontentspage .toclevel-1, .toclevel-1 { margin-left: 0cm; }
-div.bs-tableofcontentspage .toclevel-2, .toclevel-2 { margin-left: 0.1cm; }
-div.bs-tableofcontentspage .toclevel-3, .toclevel-3 { margin-left: 0.2cm; }
-div.bs-tableofcontentspage .toclevel-4, .toclevel-4 { margin-left: 0.3cm; }
-div.bs-tableofcontentspage .toclevel-5, .toclevel-5 { margin-left: 0.4cm; }
-div.bs-tableofcontentspage .toclevel-6, .toclevel-6 { margin-left: 0.5cm; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-1 { margin-left: 0em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-2 { margin-left: 2em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-3 { margin-left: 4em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-4 { margin-left: 6em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-5 { margin-left: 8em; }
+div.bs-tableofcontentspage .toc > ul > li.toclevel-6 { margin-left: 10em; }
 
 td.bs-wiki-article-ancestors-table-left,
 td.bs-wiki-article-ancestors-table-right { width: 50%;}
diff --git a/UEModulePDF/includes/PDFServlet.class.php 
b/UEModulePDF/includes/PDFServlet.class.php
index e86b4a7..0d09868 100644
--- a/UEModulePDF/includes/PDFServlet.class.php
+++ b/UEModulePDF/includes/PDFServlet.class.php
@@ -104,72 +104,48 @@
         * Uploads all files found in the markup by the "findFiles" method.
         */
        protected function uploadFiles() {
-               foreach( $this->aFiles as $sType => $aFiles ) {
+               global $bsgUEModulePDFUploadThreshold;
 
-                       //Backwards compatibility to old inconsitent 
PDFTemplates (having "STYLESHEET" as type but linnking to "stylesheets")
+               foreach( $this->aFiles as $sType => $aFiles ) {
+                       //Backwards compatibility to old inconistent 
PDFTemplates (having
+                       //"STYLESHEET" as type but linking to "stylesheets")
                        //TODO: Make conditional?
                        if( $sType == 'IMAGE' )      $sType = 'images';
                        if( $sType == 'STYLESHEET' ) $sType = 'stylesheets';
 
                        $aPostData = array(
-                               'fileType'              => $sType,
+                               'fileType'      => $sType,
                                'documentToken' => 
$this->aParams['document-token'],
                                'wikiId'        => wfWikiID()
                        );
 
                        $aErrors = array();
+                       $aPostFiles = array();
                        $iCounter = 0;
+                       $iCurrentUploadSize = 0;
                        foreach( $aFiles as $sFileName => $sFilePath ) {
                                if( file_exists( $sFilePath) == false ) {
                                        $aErrors[] = $sFilePath;
                                        continue;
                                }
-                               $aPostData['file'.$iCounter.'_name'] = 
$sFileName;
-                               $aPostData['file'.$iCounter] = '@'.$sFilePath;
+
+                               $iFileSize = filesize( $sFilePath );
+                               if( $iCurrentUploadSize >= 
$bsgUEModulePDFUploadThreshold ) {
+                                       $this->doFilesUpload( array_merge( 
$aPostFiles , $aPostData), $aErrors );
+
+                                       //Reset all loop variables
+                                       $aErrors = array();
+                                       $aPostFiles = array();
+                                       $iCounter = 0;
+                                       $iCurrentUploadSize = $iFileSize;
+                               }
+
+                               $aPostFiles['file'.$iCounter.'_name'] = 
$sFileName;
+                               $aPostFiles['file'.$iCounter] = '@'.$sFilePath;
                                $iCounter++;
+                               $iCurrentUploadSize += $iFileSize;
                        }
-
-                       if( !empty( $aErrors ) ) {
-                               wfDebugLog(
-                                       'BS::UEModulePDF',
-                                       'BsPDFServlet::uploadFiles: Error 
trying to fetch files:'."\n". var_export( $aErrors, true )
-                               );
-                       }
-
-                       wfRunHooks( 'BSUEModulePDFUploadFilesBeforeSend', 
array( $this, &$aPostData, $sType ) );
-
-                       $aOptions = array(
-                               'timeout' => 120,
-                               'postData' => $aPostData
-                       );
-
-                       global $bsgUEModulePDFCURLOptions;
-                       $aOptions = array_merge_recursive($aOptions, 
$bsgUEModulePDFCURLOptions);
-
-                       $vHttpEngine = Http::$httpEngine;
-                       Http::$httpEngine = 'curl';
-                       $sResponse = Http::post(
-                               
$this->aParams['soap-service-url'].'/UploadAsset',
-                               $aOptions
-                       );
-                       Http::$httpEngine = $vHttpEngine;
-
-                       if( $sResponse != false ) {
-                               wfDebugLog(
-                                       'BS::UEModulePDF',
-                                       'BsPDFServlet::uploadFiles: 
Successfully added "'.$sType.'"'
-                               );
-                               wfDebugLog(
-                                       'BS::UEModulePDF',
-                                       FormatJson::encode( 
FormatJson::decode($sResponse), true )
-                               );
-                       }
-                       else {
-                               wfDebugLog(
-                                       'BS::UEModulePDF',
-                                       'BsPDFServlet::uploadFiles: Failed 
adding "'.$sType.'"'
-                               );
-                       }
+                       $this->doFilesUpload( array_merge( $aPostFiles, 
$aPostData ), $aErrors ); //For last iteration contents
                }
        }
 
@@ -292,5 +268,52 @@
                $sNewUrl = $this->aParams['webroot-filesystempath'].$sUrl; // 
TODO RBV (08.02.11 15:56): What about $wgUploadDirectory?
                return $sNewUrl;
        }
+
+       protected function doFilesUpload( $aPostData, $aErrors = array() ) {
+               global $bsgUEModulePDFCURLOptions;
+               $aOptions = array(
+                       'timeout' => 120,
+               );
+               $aOptions = array_merge_recursive( $aOptions, 
$bsgUEModulePDFCURLOptions );
+
+               $sType = $aPostData['fileType'];
+
+               if( !empty( $aErrors ) ) {
+                       wfDebugLog(
+                               'BS::UEModulePDF',
+                               'BsPDFServlet::uploadFiles: Error trying to 
fetch files:'."\n". var_export( $aErrors, true )
+                       );
+               }
+
+               wfRunHooks( 'BSUEModulePDFUploadFilesBeforeSend', array( $this, 
&$aPostData, $sType ) );
+
+               $aOptions['postData'] = $aPostData;
+
+               $vHttpEngine = Http::$httpEngine;
+               Http::$httpEngine = 'curl';
+               $sResponse = Http::post(
+                       $this->aParams['soap-service-url'].'/UploadAsset',
+                       $aOptions
+               );
+               Http::$httpEngine = $vHttpEngine;
+
+               if( $sResponse != false ) {
+                       wfDebugLog(
+                               'BS::UEModulePDF',
+                               'BsPDFServlet::uploadFiles: Successfully added 
"'.$sType.'"'
+                       );
+                       wfDebugLog(
+                               'BS::UEModulePDF',
+                               FormatJson::encode( 
FormatJson::decode($sResponse), true )
+                       );
+               }
+               else {
+                       wfDebugLog(
+                               'BS::UEModulePDF',
+                               'BsPDFServlet::uploadFiles: Failed adding 
"'.$sType.'"'
+                       );
+               }
+       }
+
        //</editor-fold>
-}
\ No newline at end of file
+}
diff --git a/UEModulePDF/webservices/BShtml2PDF.war 
b/UEModulePDF/webservices/BShtml2PDF.war
index d0f843b..06830fb 100644
--- a/UEModulePDF/webservices/BShtml2PDF.war
+++ b/UEModulePDF/webservices/BShtml2PDF.war
Binary files differ

-- 
To view, visit https://gerrit.wikimedia.org/r/208591
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I45e783f06897f701cf5e5a3e029b02cd4f18adb5
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: Pwirth <wi...@hallowelt.biz>
Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Tweichart <weich...@hallowelt.biz>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to