Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Mediawiki-CVS

SVN: [111228] trunk/extensions/MobileFrontend

 

 

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded


maxsem at svn

Feb 10, 2012, 11:54 PM

Post #1 of 1 (13 views)
Permalink
SVN: [111228] trunk/extensions/MobileFrontend

https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111228

Revision: 111228
Author: maxsem
Date: 2012-02-11 07:54:11 +0000 (Sat, 11 Feb 2012)
Log Message:
-----------
* Made mobile format non-compulsory
* Full param info

Modified Paths:
--------------
trunk/extensions/MobileFrontend/ApiParseExtender.php
trunk/extensions/MobileFrontend/MobileFrontend.php

Modified: trunk/extensions/MobileFrontend/ApiParseExtender.php
===================================================================
--- trunk/extensions/MobileFrontend/ApiParseExtender.php 2012-02-11 07:09:02 UTC (rev 111227)
+++ trunk/extensions/MobileFrontend/ApiParseExtender.php 2012-02-11 07:54:11 UTC (rev 111228)
@@ -1,24 +1,61 @@
<?php

/**
- *
+ * Extends API action=parse with mobile goodies
*/
class ApiParseExtender {
+ /**
+ * APIGetAllowedParams hook handler
+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/APIGetAllowedParams
+ * @param ApiBase $module
+ * @param array $params
+ */
public static function onAPIGetAllowedParams( ApiBase &$module, Array &$params ) {
if ( $module->getModuleName() == 'parse' ) {
$params['mobileformat'] = array(
ApiBase::PARAM_TYPE => array( 'wml', 'html' ),
- ApiBase::PARAM_DFLT => 'html',
);
}
return true;
}

+ /**
+ * APIGetParamDescription hook handler
+ * @see: https://www.mediawiki.org/wiki/Manual:Hooks/APIGetParamDescription
+ * @param ApiBase $module
+ * @param Array $desc
+ */
+ public static function onAPIGetParamDescription( ApiBase &$module, Array &$params ) {
+ if ( $module->getModuleName() == 'parse' ) {
+ $params['mobileformat'] = 'Return parse output in a format suitable for mobile devices';
+ }
+ return true;
+ }
+
+ /**
+ * APIGetDescription hook handler
+ * @see: https://www.mediawiki.org/wiki/Manual:Hooks/APIGetDescription
+ * @param ApiBase $module
+ * @param Array|string $desc
+ */
+ public static function onAPIGetDescription( ApiBase &$module, &$desc ) {
+ if ( $module->getModuleName() == 'parse' ) {
+ $desc= (array)$desc;
+ $desc[] = 'Extended by MobileFrontend';
+ }
+ return true;
+ }
+
+ /**
+ * APIAfterExecute hook handler
+ * @see: https://www.mediawiki.org/wiki/Manual:Hooks/
+ * @param ApiBase $module
+ */
public static function onAPIAfterExecute( ApiBase &$module ) {
if ( $module->getModuleName() == 'parse' ) {
$data = $module->getResultData();
- if ( isset( $data['parse']['text'] ) ) {
- $params = $module->extractRequestParams();
+ $params = $module->extractRequestParams();
+ if ( isset( $data['parse']['text'] ) && isset( $params['mobileformat'] ) ) {
$mf = new DomManipulator( '<body><div id="content">' . $data['parse']['text']['*'] . '</div></body>',
ExtMobileFrontend::parseContentFormat( $params['mobileformat'] )
);

Modified: trunk/extensions/MobileFrontend/MobileFrontend.php
===================================================================
--- trunk/extensions/MobileFrontend/MobileFrontend.php 2012-02-11 07:09:02 UTC (rev 111227)
+++ trunk/extensions/MobileFrontend/MobileFrontend.php 2012-02-11 07:54:11 UTC (rev 111228)
@@ -89,6 +89,8 @@

$wgHooks['APIGetAllowedParams'][] = 'ApiParseExtender::onAPIGetAllowedParams';
$wgHooks['APIAfterExecute'][] = 'ApiParseExtender::onAPIAfterExecute';
+$wgHooks['APIGetParamDescription'][] = 'ApiParseExtender::onAPIGetParamDescription';
+$wgHooks['APIGetDescription'][] = 'ApiParseExtender::onAPIGetDescription';

function efMobileFrontend_Setup() {
global $wgExtMobileFrontend, $wgHooks;


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS [at] lists
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.