<?php if (!defined('PmWiki')) exit();
/*  Copyright 2005 Ben Wilson (ameen@dausha.net)
This file adds a page rename capability to pmwiki 2.
This file extends PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.  See pmwiki.php for full details.
*/

$AsSpacedFunction       = 'TitleCaseSpaceWikiWords';
$SpaceWikiWordsFunction = 'TitleCaseSpaceWikiWords';
#
# If you need different words (because of a different language),
# Just replace this array.
#
SDVA($TitleCaseLowerCase, array(
'A', 'An', 'And', 'But', 'By', 'For', 'From', 'In', 'Is',
'It', 'Of', 'On', 'Or', 'The', 'To', 'With',
));
#
# Because some "Wiki words" just should not be capitalized.
#
SDVA($TitleCaseUnspacedList, array( 'Mac ', 'Mc ', 'Pm Wiki', 'Side Bar'));

function TitleCaseSpaceWikiWords($text) {
global $TitleCaseLowerCase,$TitleCaseUnspacedList;
 $text = AsSpaced($text);
 foreach((array)$TitleCaseLowerCase as $s)
 $text = preg_replace("/(\\s$s\\s)/e","strtolower('$1')",$text);
  foreach((array)$TitleCaseUnspacedList as $u)
    $text = str_replace($u,str_replace(' ','',$u),$text);
  return $text;
}