improve mediawiki editing/user login handling
authorZbigniew Braniecki (zbraniecki@mozilla.com)
Fri, 07 Aug 2009 17:52:33 +0200
changeset 26 66f2a4442c7f5fabcbaf28c1e472fac040af69bf
parent 25 c1648656a8c780c49f0b77190cfdfe71055d5871
child 27 9c4f3d0ed668220e661f5e5cbc7eed77c0af5924
push id14
push userzbraniecki@mozilla.com
push dateFri, 07 Aug 2009 15:52:39 +0000
improve mediawiki editing/user login handling
mediawiki/extensions/cmo.php
mediawiki/skins/cmo.php
mediawiki/skins/cmo/style/mediawiki.css
--- a/mediawiki/extensions/cmo.php
+++ b/mediawiki/extensions/cmo.php
@@ -25,17 +25,17 @@ function urlize ($input, $url) {
 	  $string .= '<a href="'.$url.'">';
   $string .= $input;
 	if ($url)
 	  $string .= '</a>';
 	return $string;
 }
 // the function that reacts to "<topicbox>"
 
-function CMOBox( $input, $argv, &$parser) {
+function CMOBox( $input, $argv, $parser) {
   global $wgScriptPath;
   $parser->disableCache();
  
   $input = '<cmobox title="'.$argv['title'].'">'.$input.'</cmobox>';
   $xml = new SimpleXMLElement($input);
 
   $cols = $argv['columns']?$argv['columns']:2;
 
--- a/mediawiki/skins/cmo.php
+++ b/mediawiki/skins/cmo.php
@@ -32,16 +32,17 @@ class SkinCMO extends SkinTemplate {
     function setupSkinUserCss( OutputPage $out ) {
         global $wgHandheldStyle;
 
         parent::setupSkinUserCss( $out );
 
         // Append to the default screen common & print styles...
         $out->addStyle( 'cmo/style/screen.css', 'screen, projection' );
         $out->addStyle( 'cmo/style/enhanced.css', 'screen, projection' );
+        $out->addStyle( 'cmo/style/mediawiki.css', 'screen, projection' );
         $out->addStyle( 'cmo/style/ie.css', 'screen, projection', 'gte IE 6');
     }
 }
 
 /**
  * @todo document
  * @ingroup Skins
  */
@@ -178,42 +179,83 @@ class CMOTemplate extends QuickTemplate 
             <input type="text" name="q" id="q" />
             <input type="image" src="<?php echo $this->stylepath ?>/img/widgets/right-arrow.png" alt="Search" id="quick-search-btn" />
         </p>
     </form>
     
 </div>
 <?php
     }
+    
+    /*************************************************************************************************/
+    function crumbs($arr=Array()) {
+        array_unshift($arr, $t = Array('http://contribute.mozilla.org', 'Contribute'));
+        array_unshift($arr, $t = Array('http://www.mozilla.org', 'Home'));
+        print('<p id="crumbs">');
+        foreach($arr as $v) {
+            print('<a href="'.$v[0].'">'.$v[1].'</a> / ');
+        }
+        print('</p>'); 
+    }
 
     /*************************************************************************************************/
-    function body() {?>
-<p id="crumbs">
-  <a href="http://www.mozilla.org">Home</a> / 
-  <a href="http://contribute.mozilla.org">Contribute</a> / 
-</p>
-<?php	
+    function title_crumbs($title) {
+    	global $wgScriptPath;
+        $elems = explode(':',$this->data['title']);
+        $elems2 = Array();
+        $url = Array();
+    	foreach($elems as $v) {
+    		$url[] = str_replace(' ','_',$v);
+            $elems2[] = Array($wgScriptPath.'/'.implode(':',$url), str_replace(' ','_',$v));
+    	}
+    	$title = array_pop($elems); // take last element as title
+    	array_pop($elems2); // and remove the last element from crumbs
+        return Array($elems2, $title);
+    }
+    
+    /*************************************************************************************************/
+    function body() {
+        $menu = false;
+        $ar = $this->title_crumbs($this->data['title']);
+        $title = $ar[1];
+        $crumbs = $ar[0];
+        $this->crumbs($crumbs);
         if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php }
 ?>
-        <h1 id="page-title"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1>
-        <div id="main" class="with-menu"><div id="main-content">   
+        <ul id="ptools">
+<?php           foreach($this->data['personal_urls'] as $key => $item) {
+	               if (in_array($key, Array('anontalk','anonuserpage','userpage','mytalk','preferences','watchlist','mycontris')))
+	                   continue; 
+?>
+                <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
+                    if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
+                echo htmlspecialchars($item['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey('pt-'.$key) ?><?php
+                if(!empty($item['class'])) { ?> class="<?php
+                echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
+                echo htmlspecialchars($item['text']) ?></a></li>
+<?php           } ?>
+        </ul>
+        <h1 id="page-title"><?php print($title);?></h1>
+        <div id="main"<?php if($menu)print(' class="with-menu"');?>><div id="main-content">   
             <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
             <div id="contentSub"><?php $this->html('subtitle') ?></div>
             <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php     $this->html('undelete') ?></div><?php } ?>
             <?php if($this->data['newtalk'] ) { ?><div class="usermessage"><?php $this->html('newtalk')  ?></div><?php } ?>
             <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
             <!-- start content -->
             <?php $this->html('bodytext') ?>
             <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
             <!-- end content -->
             <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
             <div class="visualClear"></div>
         </div>
 
 <?php
+        if($menu)
+          $this->menu();
     }
 
     /*************************************************************************************************/
     function footer() {
 ?>
     </div><!-- end #main -->
 <div id="footer-wrap">
     <div id="footer" class="cols">
@@ -285,138 +327,37 @@ class CMOTemplate extends QuickTemplate 
                 <li><a href="http://contribute.mozilla.org">More&hellip;</a></li>
             </ul>
         </div>
     </div><!-- end #footer -->
 </div><!-- end #footer-wrap -->
 
 <?php
     }
-    
-    /*************************************************************************************************/
-    function searchBox() {
-        global $wgUseTwoButtonsSearchForm;
-?>
-    <div id="p-search" class="portlet">
-        <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
-        <div id="searchBody" class="pBody">
-            <form action="<?php $this->text('wgScript') ?>" id="searchform"><div>
-                <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
-                <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
-                    if( isset( $this->data['search'] ) ) {
-                        ?> value="<?php $this->text('search') ?>"<?php } ?> />
-                <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?>&nbsp;
-                <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
-
-                <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
-
-            </div></form>
-        </div>
-    </div>
-<?php
-    }
 
     /*************************************************************************************************/
-    function toolbox() {
+    function menu() {
 ?>
-    <div class="portlet" id="p-tb">
-        <h5><?php $this->msg('toolbox') ?></h5>
-        <div class="pBody">
+<div id="localnav">
+    <ul class="first">
+        <li class="first"><a href="/community/">Community</a>
             <ul>
-<?php
-        if($this->data['notspecialpage']) { ?>
-                <li id="t-whatlinkshere"><a href="<?php
-                echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
-                ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
-<?php
-            if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
-                <li id="t-recentchangeslinked"><a href="<?php
-                echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
-                ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked') ?></a></li>
-<?php       }
-        }
-        if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
-            <li id="t-trackbacklink"><a href="<?php
-                echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
-                ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
-<?php   }
-        if($this->data['feeds']) { ?>
-            <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
-                    ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
-                    echo htmlspecialchars($feed['href']) ?>" rel="alternate" type="application/<?php echo $key ?>+xml" class="feedlink"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&nbsp;
-                    <?php } ?></li><?php
-        }
-
-        foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
-
-            if($this->data['nav_urls'][$special]) {
-                ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
-                ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
-<?php       }
-        }
-
-        if(!empty($this->data['nav_urls']['print']['href'])) { ?>
-                <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
-                ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
-        }
-
-        if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
-                <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
-                ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
-        } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
-                <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
-        }
+                <li class="first"><a href="/community/blogs.html">Blogs and Feeds</a></li>
+                <li><a href="/community/chat.html">Chat Servers</a></li>
 
-        wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
-        wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
-?>
-            </ul>
-        </div>
-    </div>
-<?php
-    }
+                <li><a href="/community/events.html">Events and Parties</a></li>
+                <li><a href="/community/intl/">International Pages</a></li>
+                <li><a href="/community/developer-forums.html">Official Developer Forums</a></li>
+                <li><a href="/community/other-forums.html">Other Community Forums</a></li>
+                <li><a href="/community/social.html">Social Networking</a></li>
+                <li><a href="/community/websites.html">Websites</a></li>
 
-    /*************************************************************************************************/
-    function languageBox() {
-        if( $this->data['language_urls'] ) {
-?>
-    <div id="p-lang" class="portlet">
-        <h5><?php $this->msg('otherlanguages') ?></h5>
-        <div class="pBody">
-            <ul>
-<?php       foreach($this->data['language_urls'] as $langlink) { ?>
-                <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
-                ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
-<?php       } ?>
+                <li><a href="/community/wikis.html">Wikis</a></li>
             </ul>
-        </div>
-    </div>
-<?php
-        }
-    }
-
-    /*************************************************************************************************/
-    function customBox( $bar, $cont ) {
-?>
-    <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
-        <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
-        <div class='pBody'>
-<?php   if ( is_array( $cont ) ) { ?>
-            <ul>
-<?php           foreach($cont as $key => $val) { ?>
-                <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
-                    if ( $val['active'] ) { ?> class="active" <?php }
-                ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
-<?php           } ?>
-            </ul>
-<?php   } else {
-            # allow raw HTML block to be defined by extensions
-            print $cont;
-        }
-?>
-        </div>
-    </div>
+        </li>
+    </ul>
+</div>
 <?php
     }
 
 } // end of class
 
 
new file mode 100644
--- /dev/null
+++ b/mediawiki/skins/cmo/style/mediawiki.css
@@ -0,0 +1,16 @@
+#siteSub,
+#jump-to-nav,
+.printfooter {
+  display:none;
+}
+
+#ptools {
+  float: right;
+  list-style-type: none;
+}
+
+#ptools > li {
+  padding-left: 0;
+  background: none;
+  display:inline;
+}
\ No newline at end of file