Smuggli has uploaded a new change for review. https://gerrit.wikimedia.org/r/141971
Change subject: Implemented changes for translatewiki ...................................................................... Implemented changes for translatewiki Created languages folder Moved php i18n file into languages folder Moved to Json i18n files Change-Id: Iac4676c3e5ac035d263431f955eaf95d30f0a704 --- M SecureFileStore/SecureFileStore.class.php D SecureFileStore/SecureFileStore.i18n.php M SecureFileStore/SecureFileStore.setup.php A SecureFileStore/i18n/de.json A SecureFileStore/i18n/en.json A SecureFileStore/i18n/qqq.json A SecureFileStore/languages/SecureFileStore.i18n.php 7 files changed, 114 insertions(+), 79 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions refs/changes/71/141971/1 diff --git a/SecureFileStore/SecureFileStore.class.php b/SecureFileStore/SecureFileStore.class.php index b273d41..6d69a42 100644 --- a/SecureFileStore/SecureFileStore.class.php +++ b/SecureFileStore/SecureFileStore.class.php @@ -3,7 +3,7 @@ * SecureFileStore extension for BlueSpice * * Prevent unauthorized access to files and images. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * + * * This file is part of BlueSpice for MediaWiki * For further information visit http://www.blue-spice.org * @@ -86,11 +86,11 @@ protected function initExt() { wfProfileIn( 'BS::'.__METHOD__ ); BsExtensionManager::setContext( 'MW::SecureFileStore::Active' ); - - BsConfig::registerVar( 'MW::SecureFileStore::Active', true, BsConfig::LEVEL_PRIVATE|BsConfig::TYPE_BOOL|BsConfig::RENDER_AS_JAVASCRIPT, 'bs-securefilestore-pref-Active' ); - BsConfig::registerVar( 'MW::SecureFileStore::DefaultDisposition', 'inline', BsConfig::LEVEL_PUBLIC|BsConfig::TYPE_STRING|BsConfig::USE_PLUGIN_FOR_PREFS, 'bs-securefilestore-pref-DefaultDisposition', 'select' ); - BsConfig::registerVar( 'MW::SecureFileStore::DispositionInline', array( 'pdf' ), BsConfig::LEVEL_PUBLIC|BsConfig::TYPE_ARRAY_STRING, 'bs-securefilestore-pref-DispositionInline', 'multiselectplusadd' ); - BsConfig::registerVar( 'MW::SecureFileStore::DispositionAttachment', array( 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx' ), BsConfig::LEVEL_PUBLIC|BsConfig::TYPE_ARRAY_STRING, 'bs-securefilestore-pref-DispositionAttachment', 'multiselectplusadd' ); + + BsConfig::registerVar( 'MW::SecureFileStore::Active', true, BsConfig::LEVEL_PRIVATE|BsConfig::TYPE_BOOL|BsConfig::RENDER_AS_JAVASCRIPT ); + BsConfig::registerVar( 'MW::SecureFileStore::DefaultDisposition', 'inline', BsConfig::LEVEL_PUBLIC|BsConfig::TYPE_STRING|BsConfig::USE_PLUGIN_FOR_PREFS, 'bs-securefilestore-pref-defaultdisposition', 'select' ); + BsConfig::registerVar( 'MW::SecureFileStore::DispositionInline', array( 'pdf' ), BsConfig::LEVEL_PUBLIC|BsConfig::TYPE_ARRAY_STRING, 'bs-securefilestore-pref-dispositioninline', 'multiselectplusadd' ); + BsConfig::registerVar( 'MW::SecureFileStore::DispositionAttachment', array( 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx' ), BsConfig::LEVEL_PUBLIC|BsConfig::TYPE_ARRAY_STRING, 'bs-securefilestore-pref-dispositionattachment', 'multiselectplusadd' ); BsConfig::registerVar( 'MW::SecureFileStore::FileExtensionWhitelist', array(), BsConfig::LEVEL_PUBLIC|BsConfig::TYPE_ARRAY_STRING|BsConfig::RENDER_AS_JAVASCRIPT, 'bs-securefilestore-pref-FileExtensionWhitelist', 'multiselectplusadd' ); $this->setHook( 'SkinTemplateOutputPageBeforeExec', 'secureImages' ); @@ -107,7 +107,12 @@ } public function runPreferencePlugin( $sAdapterName, $oVariable ) { - $aPrefs = array( 'options' => array( 'inline' => 'inline', 'attachment' => 'attachment' ) ); + $aPrefs = array( + 'options' => array( + wfMessage( 'bs-securefilestore-pref-defaultdisposition-brower' )->plain() => 'inline', + wfMessage( 'bs-securefilestore-pref-defaultdisposition-external' )->plain() => 'attachment' + ) + ); return $aPrefs; } @@ -115,7 +120,7 @@ * Replaces links to files with links to secure file dispatcher. * @param object $oObject needed by hook * @param object $oText reference to skin template object - * @return bool hook must return true + * @return bool hook must return true */ public function secureImages( $oObject, &$oText ) { if ( !BsConfig::get( 'MW::SecureFileStore::Active' ) ) return true; @@ -126,7 +131,7 @@ /** * Replaces links to files with links to secure file dispatcher. * @param string $sText HTML source text - * @return string HTML with replaced links + * @return string HTML with replaced links */ public static function secureFilesInText( $sText ) { if ( !BsConfig::get( 'MW::SecureFileStore::Active' ) ) return $sText; @@ -137,7 +142,7 @@ * Replaces links to files with links to secure file dispatcher. * @param string $sText HTML source text * @param bool $bIsUrl switches replacement mode - * @return string HTML with replaced links + * @return string HTML with replaced links */ public static function secureStuff( $sText, $bIsUrl = false ) { global $wgScriptPath, $wgUploadPath; @@ -161,10 +166,10 @@ */ public static function getFile() { global $wgUploadDirectory; - $sRawFilePath = RequestContext::getMain()->getRequest()->getVal( 'f' ); + $sRawFilePath = RequestContext::getMain()->getRequest()->getVal( 'f' ); // Some extensions (e.g. Social Profile) add params with ? to filename - $aRawFilePathPcs = preg_split( "/\?.*=/", $sRawFilePath ); - $sRawFilePath = $aRawFilePathPcs[0]; + $aRawFilePathPcs = preg_split( "/\?.*=/", $sRawFilePath ); + $sRawFilePath = $aRawFilePathPcs[0]; $sUploadDirectory = realpath( $wgUploadDirectory ); if ( empty( $sUploadDirectory ) ) throw new MWException( '$wgUploadDirectory is empty. This should never happen!' ); @@ -179,8 +184,7 @@ $sFilePath = realpath( $oImgRepoLocalRef->getPath() ); } } - } - else { + } else { $sFilePath = realpath( $sUploadDirectory . $sRawFilePath ); } @@ -201,15 +205,16 @@ // At this point we have a valid and readable file path in $sFilePath. // Now create a File object to get some properties - if ( strstr( $sFilePath, 'thumb' ) ) $sFindFileName = preg_replace( "#(\d*px-)#", '', $sFileName ); - else $sFindFileName = $sFileName; + $sFindFileName= ( strstr( $sFilePath, 'thumb' ) ) + ? preg_replace( "#(\d*px-)#", '', $sFileName ) + : $sFileName; $aOptions = array( 'time' => false ); //TODO: maybe check for "/archive" in $sFilePath, too. But this migth be a config setting, so do not hardcode - $isArchive = preg_match('#^\d{14}!#si', $sFindFileName); //i.e. "20120724112914!Adobe-reader-x-tco-de.pdf" - if( $isArchive ) { - $aFilenameParts = explode( '!', $sFindFileName, 2); - $sFindFileName = $aFilenameParts[1]; + $isArchive = preg_match( '#^\d{14}!#si', $sFindFileName ); //i.e. "20120724112914!Adobe-reader-x-tco-de.pdf" + if ( $isArchive ) { + $aFilenameParts = explode( '!', $sFindFileName, 2); + $sFindFileName = $aFilenameParts[1]; $aOptions['time'] = $aFilenameParts[0]; } $oFile = RepoGroup::singleton()->findFile( $sFindFileName, $aOptions ); @@ -235,11 +240,13 @@ // User is allowed to retrieve file. Get things going. # If file is not in MW's repo try to guess MIME type - $sFileMime = ( $oFile ) ? $oFile->getMimeType() : MimeMagic::singleton()->guessMimeType( $sFilePath, false ); + $sFileMime = ( $oFile ) + ? $oFile->getMimeType() + : MimeMagic::singleton()->guessMimeType( $sFilePath, false ); $sFileDispo = BsConfig::get( 'MW::SecureFileStore::DefaultDisposition' ); if ( in_array( $sFileExt, BsConfig::get( 'MW::SecureFileStore::DispositionAttachment' ) ) ) $sFileDispo = 'attachment'; - if ( in_array( $sFileExt, BsConfig::get( 'MW::SecureFileStore::DispositionInline' ) ) ) $sFileDispo = 'inline'; + if ( in_array( $sFileExt, BsConfig::get( 'MW::SecureFileStore::DispositionInline' ) ) ) $sFileDispo = 'inline'; $aFileStat = stat( $sFilePath ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', $aFileStat['mtime'] ) . ' GMT' ); @@ -248,10 +255,10 @@ header( "Cache-Control: no-cache,must-revalidate", true ); //Otherwise IE might deliver old version if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { - $sModSince = preg_replace( '/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); + $sModSince = preg_replace( '/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); $sSinceTime = strtotime( $sModSince ); if ( $aFileStat['mtime'] <= $sSinceTime ) { - ini_set('zlib.output_compression', 0); + ini_set( 'zlib.output_compression', 0 ); header( "HTTP/1.0 304 Not Modified" ); exit; } diff --git a/SecureFileStore/SecureFileStore.i18n.php b/SecureFileStore/SecureFileStore.i18n.php deleted file mode 100644 index 1fbc7b3..0000000 --- a/SecureFileStore/SecureFileStore.i18n.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Internationalisation file for SecureFileStore - * - * Part of BlueSpice for MediaWiki - * - * @author Stephan Muggli <[email protected]> - - * @package BlueSpice_Extensions - * @subpackage SecureFileStore - * @copyright Copyright (C) 2012 Hallo Welt! - Medienwerkstatt GmbH, All rights reserved. - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or later - * @filesource - */ - -$messages = array(); - -$messages['en'] = array( - 'bs-securefilestore-extension-description' => 'Prevents unauthorized access to files and pictures', - 'SecureFileStore' => 'Secure file store', - 'prefs-SecureFileStore' => 'Secure file store', - 'bs-securefilestore-pref-DefaultDisposition' => 'By default view files in browser (inline) or in external applications (attachment)', - 'bs-securefilestore-pref-DispositionAttachment' => 'View these file types in external applications', - 'toc-DispositionAttachment-title' => 'Add file type', - 'toc-DispositionAttachment-message' => 'Which (additional) file type do you wish to view in external applications?', - 'bs-securefilestore-pref-DispositionInline' => 'View these file types in browser', - 'toc-DispositionInline-title' => 'Add file type', - 'toc-DispositionInline-message' => 'Which (additional) file type do you wish to view in your browser?', - 'bs-securefilestore-pref-FileExtensionWhitelist' => 'Always display these file types', - 'toc-FileExtensionWhitelist-title' => 'Add file type', - 'toc-FileExtensionWhitelist-message' => 'Which (additional) file type do you always wish to view?' -); - -$messages['de'] = array( - 'bs-securefilestore-extension-description' => 'Verhindert unberechtigten Zugriff auf Dateien und Bilder', - 'SecureFileStore' => 'Gesicherte Dateiablage', - 'prefs-SecureFileStore' => 'Gesicherte Dateiablage', - 'bs-securefilestore-pref-DefaultDisposition' => 'Dateien standardmäßig im Browser anzeigen (inline) oder mit externer Anwendung öffnen (attachment)', - 'bs-securefilestore-pref-DispositionAttachment' => 'Diese Dateitypen immer mit externer Anwendung öffnen', - 'toc-DispositionAttachment-title' => 'Dateityp hinzufügen', - 'toc-DispositionAttachment-message' => 'Welchen Dateityp möchtest Du (zusätzlich) mit externer Anwendung öffnen?', - 'bs-securefilestore-pref-DispositionInline' => 'Diese Dateitypen immer im Browser anzeigen', - 'toc-DispositionInline-title' => 'Dateityp hinzufügen', - 'toc-DispositionInline-message' => 'Welchen (zusätzlichen) Dateityp möchtest Du im Browser anzeigen?', - 'bs-securefilestore-pref-FileExtensionWhitelist' => 'Diese Dateitypen immer anzeigen', - 'toc-FileExtensionWhitelist-title' => 'Dateityp hinzufügen', - 'toc-FileExtensionWhitelist-message' => 'Welchen (zusätzlichen) Dateityp möchtest Du immer anzeigen?' -); - -$messages['de-formal'] = array(); - -$messages['qqq'] = array(); \ No newline at end of file diff --git a/SecureFileStore/SecureFileStore.setup.php b/SecureFileStore/SecureFileStore.setup.php index 9fce08d..9567a51 100644 --- a/SecureFileStore/SecureFileStore.setup.php +++ b/SecureFileStore/SecureFileStore.setup.php @@ -2,6 +2,6 @@ BsExtensionManager::registerExtension('SecureFileStore', BsRUNLEVEL::FULL|BsRUNLEVEL::REMOTE); -$wgExtensionMessagesFiles['SecureFileStore'] = __DIR__ . '/SecureFileStore.i18n.php'; +$wgExtensionMessagesFiles['SecureFileStore'] = __DIR__ . '/languages/SecureFileStore.i18n.php'; $wgAjaxExportList[] = 'SecureFileStore::getFile'; \ No newline at end of file diff --git a/SecureFileStore/i18n/de.json b/SecureFileStore/i18n/de.json new file mode 100644 index 0000000..ba76368 --- /dev/null +++ b/SecureFileStore/i18n/de.json @@ -0,0 +1,15 @@ +{ + "@metadata": { + "authors": [ + "Stephan Muggli <[email protected]>" + ] + }, + "bs-securefilestore-extension-description": "Verhindert unberechtigten Zugriff auf Dateien und Bilder", + "prefs-securefilestore": "Gesicherte Dateiablage", + "bs-securefilestore-pref-defaultdisposition": "Dateien standardmäßig darstellen:", + "bs-securefilestore-pref-defaultdisposition-brower": "Browser", + "bs-securefilestore-pref-defaultdisposition-external": "Extern", + "bs-securefilestore-pref-dispositionattachment": "Externe Dateitypen: ", + "bs-securefilestore-pref-dispositioninline": "Browser Dateitypen:", + "bs-securefilestore-pref-fileextensionwhitelist": "Diese Dateitypen immer anzeigen:" +} diff --git a/SecureFileStore/i18n/en.json b/SecureFileStore/i18n/en.json new file mode 100644 index 0000000..22693ff --- /dev/null +++ b/SecureFileStore/i18n/en.json @@ -0,0 +1,15 @@ +{ + "@metadata": { + "authors": [ + "Stephan Muggli <[email protected]>" + ] + }, + "bs-securefilestore-desc": "Prevents unauthorized access to files and pictures", + "prefs-securefilestore": "Secure file store", + "bs-securefilestore-pref-defaultdisposition": "Display files by default:", + "bs-securefilestore-pref-defaultdisposition-brower": "Browser", + "bs-securefilestore-pref-defaultdisposition-external": "External", + "bs-securefilestore-pref-dispositionattachment": "External file types:", + "bs-securefilestore-pref-dispositioninline": "Browser file types:", + "bs-securefilestore-pref-fileextensionwhitelist": "Always display these file types:" +} diff --git a/SecureFileStore/i18n/qqq.json b/SecureFileStore/i18n/qqq.json new file mode 100644 index 0000000..bcae7ea --- /dev/null +++ b/SecureFileStore/i18n/qqq.json @@ -0,0 +1,15 @@ +{ + "@metadata": { + "authors": [ + "Stephan Muggli <[email protected]>" + ] + }, + "bs-securefilestore-desc": "Used in [[Special:Wiki_Admin&mode=ExtensionInfo]], description of secure file store extension", + "prefs-securefilestore": "Used in [[Special:Wiki_Admin&mode=Preferences]], headline for secure file store section in preferences.\n{{Identical|Secure file store}}", + "bs-securefilestore-pref-defaultdisposition": "Option in [[Special:Wiki_Admin&mode=Preferences]], label text for display files by default:", + "bs-securefilestore-pref-defaultdisposition-brower": "Option in [[Special:Wiki_Admin&mode=Preferences]], label text for browser", + "bs-securefilestore-pref-defaultdisposition-external": "Option in [[Special:Wiki_Admin&mode=Preferences]], label text for external", + "bs-securefilestore-pref-dispositionattachment": "Option in [[Special:Wiki_Admin&mode=Preferences]], label text for external file types:", + "bs-securefilestore-pref-dispositioninline": "Option in [[Special:Wiki_Admin&mode=Preferences]], label text for browser file types:", + "bs-securefilestore-pref-fileextensionwhitelist": "Option in [[Special:Wiki_Admin&mode=Preferences]], label text for always display these file types:" +} diff --git a/SecureFileStore/languages/SecureFileStore.i18n.php b/SecureFileStore/languages/SecureFileStore.i18n.php new file mode 100644 index 0000000..f319f9d --- /dev/null +++ b/SecureFileStore/languages/SecureFileStore.i18n.php @@ -0,0 +1,35 @@ +<?php +/** + * This is a backwards-compatibility shim, generated by: + * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php + * + * Beginning with MediaWiki 1.23, translation strings are stored in json files, + * and the EXTENSION.i18n.php file only exists to provide compatibility with + * older releases of MediaWiki. For more information about this migration, see: + * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format + * + * This shim maintains compatibility back to MediaWiki 1.17. + */ +$messages = array(); +if ( !function_exists( 'wfJsonI18nShimc0319b6f58a1c872' ) ) { + function wfJsonI18nShimc0319b6f58a1c872( $cache, $code, &$cachedData ) { + $codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] ); + foreach ( $codeSequence as $csCode ) { + $fileName = dirname( __FILE__ ) . "/../i18n/$csCode.json"; + if ( is_readable( $fileName ) ) { + $data = FormatJson::decode( file_get_contents( $fileName ), true ); + foreach ( array_keys( $data ) as $key ) { + if ( $key === '' || $key[0] === '@' ) { + unset( $data[$key] ); + } + } + $cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); + } + + $cachedData['deps'][] = new FileDependency( $fileName ); + } + return true; + } + + $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShimc0319b6f58a1c872'; +} -- To view, visit https://gerrit.wikimedia.org/r/141971 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iac4676c3e5ac035d263431f955eaf95d30f0a704 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions Gerrit-Branch: master Gerrit-Owner: Smuggli <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
