Goldbishop
Game Sites:
http://lotrowiki.woodassoc.us
Content Sites:
http://sl3d.woodassoc.us/wiki Silverlight 3D Wiki
Favorites
editExtension(s) Used in past
editMediaWiki version: | 1.19 |
- Extension:ConfirmEdit
- Extension:Gadgets
- Extension:Google_AdSense_2
- Extension:googleAnalytics
- Extension:Nuke
- Extension:ParserFunctions
- Extension:Renameuser
- Extension:SemanticMediaWiki
- Extension:Validator
- Extension:Vector
- Extension:WikiEditor
MediaWiki version: | 1.15 |
Sidebar/Navbar
editIn reference to Manual:Interface/Sidebar, i have made some customization changes that would allow the administrator (sysop/beuarocrat) to effectively show/hide various segments of the Sidebar/Navbar. This has been tested and verified with MediaWiki 1.15.x.
- Sidebar x1
MediaWiki version: | 1.15 |
Reason
editIn response to one of my sites that I host, i needed to lock-down certain sections from the normal user/anon viewers. One way i did this was, to create two forms of the sidebar, Anon_sidebar and Sidebar. Obviously, the Sidebar form is hard-coded into the wiki site and I used this for those registerd users of the site. The second form, Anon_sidebar, is for those that are viewing the site and do not feel the need to register.
Sidebar
editThis form is very similar to most, I setup various sections of the sidebar. As my site has three navigation sections outside of the normal (information, toolbox, etc), I setup the main Parents in here, as such:
MediaWiki:Sidebar
edit* SEARCH * navigation ** mainpage|mainpage-description ** Production|Production ** Core|Core * source * project * Information ** portal-url|portal ** currentevents-url|currentevents ** recentchanges-url|recentchanges ** randompage-url|randompage ** helppage|help * TOOLBOX * LANGUAGES
MediaWiki:Anon_sidebar
edit(viewable at Silverlight 3D wiki)
* SEARCH * navigation ** Home|mainpage-description ** Administrativo|Production * information ** portal-url|portal ** currentevents-url|currentevents ** helppage|help
Skin.php
edit===== 1.19 =====
MediaWiki version: | 1.19 |
Reviewed the new structure and noted the correct location for this version.
function buildSidebar() {
global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry,
$wgUser; <-- Add this to list so you can access it.
...
$bar = array();
/** Change this
* $this->addToSidebar( $bar, 'sidebar' );
** To below **/
if( $wgUser->isLoggedIn() ){
$this->addToSidebar( $bar, 'sidebar' );
} else {
$this->addToSidebar( $bar, 'anon_sidebar' );
}
wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
...
}
...
===== 1.15 =====
MediaWiki version: | 1.15 |
After developing these two pages, went into the Skin.php page and edited the following section (Manual:Interface/Sidebar#Change_sidebar_content_when_logged_in_.28PHP.29)
...
function buildSidebar() {
...
if( $wgUser->isLoggedIn() ){
$lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
}else{
$lines = explode( "\n", wfMsgForContent( 'anon_sidebar' ) );
}
...
}
...
Common.js
editMediaWiki version: | 1.15 |
In reference to Manual:Interface/Sidebar#Add_or_remove_sections_.28JavaScript.29, I changed up the code tee-tiny bit to allow me to visibly manage what is available for the anon/users to the site.
Only part i really changed is the way the addOnloadHook() function is used, as you will see below. I will not repeat what has already been stated but will simply show you the changes that i made to accomidate what i was using it for.
This file can be accessed through your wiki via http://<your wiki address>/MediaWiki:Common.js
function ModifySidebar(action, section, name, link) {
try {
switch (section) {
case "languages":
var target = "p-lang";
break;
case "toolbox":
var target = "p-tb";
break;
case "navigation":
var target = "p-navigation";
break;
default:
var target = "p-" + section;
var custom = true;
break;
}
if (action == "addC") {
var node = document.getElementById(target)
.getElementsByTagName('div')[0]
.getElementsByTagName('ul')[0];
var nodeelements = node.getElementsByTagName('li');
for (var i = 0; i < nodeelements.length; i++) {
if (nodeelements[i].getElementsByTagName('a')[0].innerHTML == name ||
nodeelements[i].getElementsByTagName('a')[0].href == link) {
node.removeChild(nodeelements[i]);
}
}
var aNode = document.createElement('a');
var liNode = document.createElement('li');
aNode.appendChild(document.createTextNode(name));
aNode.setAttribute('href', link);
liNode.appendChild(aNode);
liNode.className='plainlinks';
node.appendChild(liNode);
node.style.display = "visible";
}
if (action == "removeC") {
var list = document.getElementById(target)
.getElementsByTagName('div')[0]
.getElementsByTagName('ul')[0];
var listelements = list.getElementsByTagName('li');
for (var i = 0; i < listelements.length; i++) {
if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
listelements[i].getElementsByTagName('a')[0].href == link) {
list.removeChild(listelements[i]);
}
}
}
if (action == "removeP"){
var node = document.getElementById(target);
node.style.visibility = "hidden";
}
} catch(e) {
// lets just ignore what's happened
return;
}
}
function AdminSidebar() {
ModifySidebar("addC", "source", "Design", "http://sl3d.woodassoc.us/wiki/Source:Design");
ModifySidebar("addC", "source", "Conceptual", "http://sl3d.woodassoc.us/wiki/Source:Conceptual");
ModifySidebar("addC", "source", "Layout", "http://sl3d.woodassoc.us/wiki/Source:Layout");
ModifySidebar("addC", "project", "Design", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Design");
ModifySidebar("addC", "project", "Conceptual", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Conceptual");
ModifySidebar("addC", "project", "Layout", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Layout");
ModifySidebar("addC", "toolbox", "Upload file", "http://sl3d.woodassoc.us/wiki/Special:Upload");
}
function UserSidebar(){
ModifySidebar("removeP", "toolbox", "toolbox", null);
}
if (isArray(wgUserGroups)){
if (wgUserGroups.Contains('bureaucrat') || wgUserGroups.Contains('sysop')){
//If the user logged in is a Bureaucrat or Sysop
addOnloadHook(AdminSidebar);
}else{
//If the user logged in is not a Bureaucrat or Sysop
addOnloadHook(UserSidebar);
}
}else{
//If an anonymous user is viewing the site
addOnloadHook(UserSidebar);
}
I changed the "add" and "remove" actions to "addC", "addP", "removeC" and "removeP" only to clarify if the items being added/removed was a Child (C) or Parent (P).
Parent nodes are those that contain mutliple children, such as "navigation", "toolbox", "information", etc. Child nodes are those that are contained within a Parent node.
WORD OF ADVISE
If you are looking to have several parent-child-grandchild relationships, it is best to get an extension that utilizes ajax or java to overlay a menu structure. When using the Sidebar, it should be noted that it should contain only parent-child relationships, going only 1 deep. Any further than that and the reader may not be able to effectively browse your content. Think of the Sidebar as more of a Category-Topic relationship. As long as you keep to a simple 1 tier menu structure, this hack should work just fine.
Clean URL
edit- Clean URL x1
- (Version 1.19) http://wiki.domain.tld/title or http://wiki.domain.tld/action/edit/title
- LocalSettings.php
...
$wgScriptPath = "/index.php";
...
$actions = array( 'edit', 'watch', 'unwatch', 'delete','revert', 'rollback',
'protect', 'unprotect', 'markpatrolled', 'render', 'submit', 'history', 'purge' );
foreach ( $actions as $action ) {
$wgActionPaths[$action] = "/action/$action/$1";
}
$wgActionPaths['view'] = "/$1";
$wgArticlePath = $wgActionPaths['view'];
$wgUsePathInfo = true;
- .htaccess
RewriteEngine On
#Rewrite Urls<br/>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)?$ /index.php [PT,L,QSA]