Example #1
0
function wiki_wiki_name($wikiname)
{
    /// Return the passed in string in Wiki name format.
    /// Remove any leading and trailing whitespace, capitalize all the words
    /// and then remove any internal whitespace.
    if (wiki_is_wiki_name($wikiname)) {
        return $wikiname;
    } else {
        /// Create uppercase words and remove whitespace.
        $wikiname = preg_replace("/(\\w+)\\s/", "\$1", ucwords(trim($wikiname)));
        /// Check again - there may only be one word.
        if (wiki_is_wiki_name($wikiname)) {
            return $wikiname;
        } else {
            return $wikiname . get_string('wikidefaultpagename', 'wiki');
        }
    }
}
Example #2
0
/**
 * Return the passed in string in Wiki name format.
 * Remove any leading and trailing whitespace, capitalize all the words
 * and then remove any internal whitespace.
 *
 * @param string $wikinane
 * @return string
 */
function wiki_wiki_name($wikiname)
{
    if (wiki_is_wiki_name($wikiname)) {
        return $wikiname;
    } else {
        /// Create uppercase words and remove whitespace.
        $wikiname = preg_replace("/(\\w+)\\s/", "\$1", ucwords(trim($wikiname)));
        /// Check again - there may only be one word.
        if (wiki_is_wiki_name($wikiname)) {
            return $wikiname;
        } else {
            return $wikiname . get_string('wikidefaultpagename', 'wiki');
        }
    }
}