r114595 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114594‎ | r114595 | r114596 >
Date:08:56, 29 March 2012
Author:netbrain
Status:new (Comments)
Tags:
Comment:
added edit parameter. Wheter to display a edit link for sidebarmenu.
Modified paths:
  • /trunk/extensions/SideBarMenu/SideBarMenu.hooks.php (modified) (history)
  • /trunk/extensions/SideBarMenu/SideBarMenu.i18n.php (modified) (history)
  • /trunk/extensions/SideBarMenu/SideBarMenu.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SideBarMenu/SideBarMenu.i18n.php
@@ -16,7 +16,8 @@
1717 'sidebarmenu-parser-input-error' => 'Parser returned with error: $1',
1818 'sidebarmenu-parser-syntax-error' => 'Could not parse "$1", make sure the syntax is correct.',
1919 'sidebarmenu-js-init-error' => 'Failed loading JavaScript resources.',
20 - 'sidebarmenu-parser-menuitem-expanded-null' => '"parser.menuitem.expanded" should be true or false, instead it is null.'
 20+ 'sidebarmenu-parser-menuitem-expanded-null' => '"parser.menuitem.expanded" should be true or false, instead it is null.',
 21+ 'sidebarmenu-edit' => 'Edit'
2122 );
2223
2324 /** Message documentation (Message documentation)
@@ -29,6 +30,7 @@
3031 'sidebarmenu-parser-syntax-error' => '$1 is the line which failed to be parsed',
3132 'sidebarmenu-js-init-error' => 'General error message',
3233 'sidebarmenu-parser-menuitem-expanded-null' => '"parser.menuitem.expanded" is a configuration property.',
 34+ 'sidebarmenu-edit' => 'The text/html of the edit link',
3335 );
3436
3537 /** Belarusian (Taraškievica orthography) (‪Беларуская (тарашкевіца)‬)
Index: trunk/extensions/SideBarMenu/SideBarMenu.php
@@ -9,6 +9,7 @@
1010 const SBM_CONTROLS_SHOW = 'controls.show';
1111 const SBM_CONTROLS_HIDE = 'controls.hide';
1212 const SBM_JS_ANIMATE = 'js.animate';
 13+const SBM_EDIT_LINK = 'edit';
1314
1415
1516 //default settings
@@ -16,6 +17,7 @@
1718 $wgSideBarMenuConfig[SBM_CONTROLS_HIDE]= null;
1819 $wgSideBarMenuConfig[SBM_JS_ANIMATE] = true;
1920 $wgSideBarMenuConfig[SBM_EXPANDED] = true;
 21+$wgSideBarMenuConfig[SBM_EDIT_LINK] = true;
2022
2123 $wgExtensionCredits['parserhook'][] = array(
2224 'path' => __FILE__,
@@ -67,4 +69,4 @@
6870 'group' => 'ext.sidebarmenu',
6971 'localBasePath' => dirname( __FILE__ ),
7072 'remoteExtPath' => 'SideBarMenu'
71 -);
\ No newline at end of file
 73+);
Index: trunk/extensions/SideBarMenu/SideBarMenu.hooks.php
@@ -18,16 +18,19 @@
1919 $output = '<div class="sidebar-menu-container">';
2020 try{
2121 $menuParser = new MenuParser($config[SBM_EXPANDED]);
22 - $output .= $menuParser->getMenuTree($input)->toHTML();
 22+ $output .= $parser->recursiveTagParse($menuParser->getMenuTree($input)->toHTML(),$frame);
2323 }catch(Exception $x){
2424 wfDebug("An error occured during parsing of: '$input' caught exception: $x");
2525 return wfMsg('sidebarmenu-parser.input-error',$x->getMessage());
2626 }
 27+ if($config[SBM_EDIT_LINK]){
 28+ $output .= Linker::link($frame->getTitle(),wfMsg('sidebarmenu-edit'),array('title' => wfMsg('sidebarmenu-edit')),array('action' => 'edit'));
 29+ }
2730 $output .= '</div>';
2831
2932 $jsOutput = self::getJSConfig($config);
3033
31 - return array( $jsOutput.$parser->recursiveTagParse($output,$frame), 'noparse' => true, 'isHTML' => true );
 34+ return array( $jsOutput.$output, 'noparse' => true, 'isHTML' => true );
3235 }
3336
3437 public static function registerUnitTests( &$files ) {
@@ -86,6 +89,7 @@
8790 $config[SBM_CONTROLS_SHOW] = array_key_exists(SBM_CONTROLS_SHOW, $args) ? $args[SBM_CONTROLS_SHOW] : (isset($wgSideBarMenuConfig[SBM_CONTROLS_SHOW]) ? $wgSideBarMenuConfig[SBM_CONTROLS_SHOW] : '['.wfMsg('showtoc').']');
8891 $config[SBM_CONTROLS_HIDE] = array_key_exists(SBM_CONTROLS_HIDE, $args) ? $args[SBM_CONTROLS_HIDE] : (isset($wgSideBarMenuConfig[SBM_CONTROLS_HIDE]) ? $wgSideBarMenuConfig[SBM_CONTROLS_HIDE] : '['.wfMsg('hidetoc').']');
8992 $config[SBM_JS_ANIMATE] = array_key_exists(SBM_JS_ANIMATE, $args) ? $args[SBM_JS_ANIMATE] : $wgSideBarMenuConfig[SBM_JS_ANIMATE];
 93+ $config[SBM_EDIT_LINK] = array_key_exists(SBM_EDIT_LINK, $args) ? $args[SBM_EDIT_LINK] : $wgSideBarMenuConfig[SBM_EDIT_LINK];
9094 return $config;
9195 }
9296 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r114681styled code properly.netbrain06:45, 3 April 2012

Comments

#Comment by Nikerabbit (talk | contribs)   17:08, 2 April 2012

Could you run code-utils/stylize.php on the files? Currently the indentation and other whitespace is not consistent.

#Comment by Netbrain (talk | contribs)   06:46, 3 April 2012

fixed code indentation