-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
52,391 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
$magicWords = array(); | ||
|
||
/** English (English) */ | ||
$magicWords['en'] = array( | ||
'docviewer' => array( 0, 'docviewer' ), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( 'wfJsonI18nShim1b3b6a389f517def' ) ) { | ||
function wfJsonI18nShim1b3b6a389e417def( $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'][] = 'wfJsonI18nShim1b3b6a389f517def'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
|
||
if ( !defined( 'MEDIAWIKI' ) ) { | ||
die( 'This file is a MediaWiki extension, it is not a valid entry point' ); | ||
} | ||
|
||
$GLOBALS['wgExtensionCredits']['parserhook'][] = array( | ||
'path' => __FILE__, | ||
'name' => 'DocViewer', | ||
'version' => '0.1', | ||
'url' => 'https://github.com/SimilisTools/mediawiki-DocViewer', | ||
'author' => array( 'Toniher' ), | ||
'descriptionmsg' => 'docviewer-desc', | ||
); | ||
|
||
$GLOBALS['wgAutoloadClasses']['DocViewer'] = __DIR__.'/DocViewer_body.php'; | ||
$GLOBALS['wgMessagesDirs']['DocViewer'] = __DIR__ . '/i18n'; | ||
$GLOBALS['wgExtensionMessagesFiles']['DocViewer'] = __DIR__ . '/DocViewer.i18n.php'; | ||
$GLOBALS['wgExtensionMessagesFiles']['DocViewerMagic'] = __DIR__ . '/DocViewer.i18n.magic.php'; | ||
|
||
$wgHooks['ParserFirstCallInit'][] = 'wfRegisterDocViewer'; | ||
|
||
// Path wrapup for ViewerJS | ||
$GLOBALS['wgDocViewerViewerJSPath'] = __DIR__ . '/libs/ViewerJS#../../..'; | ||
|
||
/** | ||
* @param $parser Parser | ||
* @return bool | ||
*/ | ||
function wfRegisterDocViewer( $parser ) { | ||
$parser->setFunctionHook( 'docviewer', 'DocViewer::generateViewer', SFH_OBJECT_ARGS ); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
class DocViewer { | ||
|
||
/** | ||
* @param $parser Parser | ||
* @param $frame PPFrame | ||
* @param $args array | ||
* @return string | ||
*/ | ||
public static function generateViewer( &$parser, $frame, $args ) { | ||
|
||
global $wgDocViewerViewerJSPath; | ||
|
||
$attrs = array(); | ||
# First value is File in wiki format | ||
|
||
if ( count( $args ) > 0 ) { | ||
|
||
$fileName = array_shift( $args ); | ||
|
||
$fileName = trim( $frame->expand( $file ) ); // Clean file | ||
|
||
// Wer may need to remove namespace here | ||
$file = wfFindFile( $fileName ); | ||
if ( $file && is_object( $file ) ) { | ||
$filepath = $file->getFullPath(); | ||
$attrs["src"] = $wgDocViewerViewerJSPath.$filepath; | ||
} | ||
|
||
foreach ( $args as $arg ) { | ||
$arg_clean = trim( $frame->expand( $arg ) ); | ||
$arg_proc = explode( "=", $arg_clean, 2 ); | ||
|
||
if ( count( $arg_proc ) == 1 ){ | ||
// kind of disabled = disabled | ||
$attrs[ trim( $arg_proc[0] ) ] = trim( $arg_proc[0] ); | ||
} else { | ||
if ( count( $arg_proc ) == 2 ) { | ||
$attrs[ trim( $arg_proc[0] ) ] = trim( $arg_proc[1] ); | ||
} | ||
} | ||
} | ||
} | ||
// Default params | ||
$attrs["id"] = "viewer"; | ||
|
||
// <iframe style="float:right;" id="viewer" src = "/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe> | ||
$tag = Html::element( | ||
'iframe', | ||
$attrs | ||
); | ||
|
||
return $parser->insertStripItem( $tag, $parser->mStripState ); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"docviewer-desc": "Extension for embedding a document viewer for PDF, ODF and other kind of documents." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"alink-desc": "Creates custom anchor links" | ||
} |
Oops, something went wrong.