Commit 5ccd4c18 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+15 −0
Changes for README.md: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
## Example files for the title:  
  
# MediaWiki, by Daniel Barrett
  
[![MediaWiki, by Daniel Barrett](http://akamaicovers.oreilly.com/images/9780596519797/cat.gif)](https://www.safaribooksonline.com/library/view/title/9780596156299//)
  
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
  
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
  
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
  
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <permissions@oreilly.com>.
  
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.

logo.png

0 → 100644
+3.11 KiB
Loading image diff...

mediawiki-code/README

0 → 100644
+22 −0
Changes for mediawiki-code/README: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
Version 1.0

These are code examples from the book "MediaWiki" by Daniel J. Barrett,
first edition, published by O'Reilly Media.

http://www.oreilly.com/catalog/9780596519681/

You may freely copy and use these examples for any purpose whatsoever.

To run a typical extension in your wiki, append a line like this to
your LocalSettings.php file:

require_once( "$IP/extensions/Whatever/Whatever.php" );

This assumes the extension is in the standard "extensions" folder, in
a subfolder named "Whatever", in a file "Whatever.php".

In some cases, there are multiple versions of the extension
(corresponding to multiple examples in the book). These extensions
contain files named Whatever_body2.php, Whatever_body3.php, etc.  To
use these other versions, replace the original file (e.g.,
Whatever_body.php) with the desired alternative file.
+43 −0
Changes for mediawiki-code/extensions/Capitalizer/Capitalizer.php: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

# Credits
$wgExtensionCredits['other'][] = array(
  'name' => 'Capitalizer',
  'author' =>'Ron Nibbly',
  'url' => 'http://wiki.example.com/wiki/Caps',
  'description' => 'Capitalize all words in a string.',
  'version' => '1.0');

# Set up the hook, using different logic depending
# on the version of MediaWiki
if (defined('MW_SUPPORTS_PARSERFIRSTCALLINIT')) {
  $wgHooks['ParserFirstCallInit'][] = 'efCapitalizer_Setup';
} else {
  $wgExtensionFunctions[] = 'efCapitalizer_Setup';
}

# Set up magic word hook
$wgHooks['LanguageGetMagic'][] = 'efCapitalizer_Magic';

# Name the magic word
define('CAPITALIZER_NAME', 'caps');

function efCapitalizer_Setup($parser) {
  // Associate the parser function name with its implementation.
  $parser->setFunctionHook(CAPITALIZER_NAME, 'efCapitalizer_Render');
  return true;
}
 
function efCapitalizer_Magic(&$magicWords, $langID) {
  // Declare that your parser function name is a magic word.
  $magicWords[CAPITALIZER_NAME] = array( 0, CAPITALIZER_NAME );
  return true;
}
 
function efCapitalizer_Render(&$parser, $text) {
  // All the action happens here.
  // For more complicated behavior, define some PHP classes and
  // use them here.
  global $wgContLang;
  return $wgContLang->ucwords($text);
}
+3 −0
Changes for mediawiki-code/extensions/Capitalizer/README: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
After installing this extension, try this in an article:

{{#caps:look at this sentence}}
Loading