Page MenuHomeDevCentral

No OneTemporary

diff --git a/helpers/namecase.php b/helpers/namecase.php
index 83ddc0e..c62ba3b 100644
--- a/helpers/namecase.php
+++ b/helpers/namecase.php
@@ -1,94 +1,94 @@
<?php
/**
* Properly capitalize a name.
*
* @package NameCase
* @version 1.0.2
* @author Alex Dunae, Dialect <alex[at]dialect[dot]ca>
* @copyright Copyright (c) 2008, Alex Dunae
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @link http://dialect.ca/code/name-case/
*/
-
+
/**
* Apply properly capitalization rules to a name.
*
* @param string $str
* @returns string
- */
+ */
function name_case($str) {
// basic check for e-mail addresses to allow copy-and-paste of e-mail lists
if(strpos($str, '@') && strpos($str, '.'))
return $str;
if(function_exists('mb_convert_encoding'))
- $str = @mb_convert_encoding($str, 'UTF-8', 'auto');
-
+ $str = @mb_convert_encoding($str, 'UTF-8', 'auto');
+
$processed_chunks = array();
// build name chunks
$buffer = '';
for($i = 0; $i < strlen($str); $i++) {
// check for delimiters
- if(preg_match('/[\s]+/', $str[$i]) > 0 || $str[$i] == '-' ||
+ if(preg_match('/[\s]+/', $str[$i]) > 0 || $str[$i] == '-' ||
$str[$i] == '.' || $str[$i] == ',') {
$processed_chunks[] = _process_name_case_chunk($buffer . $str[$i]);
$buffer = '';
} else {
$buffer .= $str[$i];
}
}
$processed_chunks[] = _process_name_case_chunk($buffer);
return trim(implode('', $processed_chunks));
}
/**
* Process the chunks generated by the namecase function.
*
* This function should not be called directly.
*
* @param string $str
* @returns string
* @see name_case
- */
+ */
function _process_name_case_chunk($str) {
// Surname prefixes
if(preg_match('/^(van|von|der|la|d[aeio]|d[ao]s|dit)[\s,]*$/i', $str))
return strtolower($str);
// Ordinal suffixes (I - VIII only)
if(preg_match('/^(i{3}|i{1,2}v?|v?i{1,2})[\s,]*$/i', $str))
return strtoupper($str);
if(function_exists('mb_convert_case'))
$str = mb_convert_case($str, MB_CASE_TITLE, 'UTF-8');
else
$str = ucfirst(strtolower($str));
// Second letter capitalized, like D'Angelo, McDonald, St. John, 0'Neil
if(preg_match('/(^|\s)+(Mc|[DO]\'|St\.|St[\.]?[\s]|Dewolf)/i', $str)) {
$str[2] = strtoupper($str[2]);
return $str;
}
// Third letter capitalized, like MacDonald, MacRae
if(preg_match('/(^|\s*)(Mac)(allist|arth|b|c(allu|art|ask|l|r|ull)|d|f|g|i(nn|nty|saa|v)|kinn|kn|l(a|ea|eo)|m|na[mu]|n[ei]|ph|q|ra|sw|ta|w)/i', $str)) {
// not h,
$str[3] = strtoupper($str[3]);
return $str;
}
return $str;
}
/* References
* - http://www.zu.ac.ae/publications/editorial/arabic.html
* - http://snippets.dzone.com/posts/show/2010
* - http://www.johncardinal.com/tmgutil/capitalizenames.htm
* - http://freejava.info/capitalize-english-names/
* - http://www.census.gov/genealogy/names/names_files.html
*/
?>
diff --git a/templates/template.php b/templates/template.php
index 3629bd8..9e44683 100644
--- a/templates/template.php
+++ b/templates/template.php
@@ -1,28 +1,27 @@
<?php
class template {
- /**
- * @var Array the template parameters
- */
- var $params;
+ /**
+ * @var Array the template parameters
+ */
+ var $params;
- /**
- * @var string the template name
- */
- var $name;
+ /**
+ * @var string the template name
+ */
+ var $name;
- /**
- * Gets the wikicode string representation of the template
- *
- * @return string the template wikicode
- */
- function __toString () {
- $template = '{{' . $this->name . "\n";
- foreach ($this->params as $key => $value) {
- $template .= " | $key = $value\n";
- }
- $template .= '}}';
+ /**
+ * Gets the wikicode string representation of the template
+ *
+ * @return string the template wikicode
+ */
+ function __toString () {
+ $template = '{{' . $this->name . "\n";
+ foreach ($this->params as $key => $value) {
+ $template .= " | $key = $value\n";
+ }
+ $template .= '}}';
- return $template;
- }
+ return $template;
+ }
}
-?>

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 15, 05:44 (6 d, 18 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4255403
Default Alt Text
(4 KB)

Event Timeline