本文整理汇总了PHP中utf8_ucwords函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_ucwords函数的具体用法?PHP utf8_ucwords怎么用?PHP utf8_ucwords使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_ucwords函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pagefromtemplate
function pagefromtemplate(&$event, $param)
{
if (strlen(trim($_REQUEST['newpagetemplate'])) > 0) {
global $conf;
global $INFO;
global $ID;
$tpl = io_readFile(wikiFN($_REQUEST['newpagetemplate']));
if ($this->getConf('userreplace')) {
$stringvars = array_map(create_function('$v', 'return explode(",",$v,2);'), explode(';', $_REQUEST['newpagevars']));
foreach ($stringvars as $value) {
$tpl = str_replace(trim($value[0]), trim($value[1]), $tpl);
}
}
if ($this->getConf('standardreplace')) {
// replace placeholders
$file = noNS($ID);
$page = strtr($file, '_', ' ');
$tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($ID, getNS($ID), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], $conf['dformat']), $tpl);
// we need the callback to work around strftime's char limit
$tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
}
$event->result = $tpl;
$event->preventDefault();
}
}
示例2: actionOptions
public function actionOptions()
{
$cors = $this->_request->getHeader('Access-Control-Request-Method');
if (!empty($cors)) {
return $this->responseData('bdApi_ViewApi_Helper_Options');
}
$action = $this->_input->filterSingle('action', XenForo_Input::STRING);
$action = str_replace(array('-', '/'), ' ', utf8_strtolower($action));
$action = str_replace(' ', '', utf8_ucwords($action));
$methods = array();
/* @var $fc XenForo_FrontController */
$fc = XenForo_Application::get('_bdApi_fc');
XenForo_Application::set('_bdApi_disableBatch', true);
foreach (array('Get', 'Post', 'Put') as $method) {
$controllerMethod = sprintf('action%s%s', $method, $action);
if (is_callable(array($this, $controllerMethod))) {
$method = utf8_strtoupper($method);
$methods[$method] = array();
bdApi_Input::bdApi_resetFilters();
$routeMatch = new XenForo_RouteMatch($this->_routeMatch->getControllerName(), sprintf('%s-%s', $method, $action));
try {
$fc->dispatch($routeMatch);
} catch (Exception $e) {
// ignore
}
$params = bdApi_Input::bdApi_getFilters();
foreach (array_keys($params) as $paramKey) {
if (in_array($paramKey, array('fields_include', 'fields_exclude', 'limit', 'locale', 'page'), true)) {
// system wide params, ignore
unset($params[$paramKey]);
continue;
}
if (!isset($_GET[$paramKey]) && $this->_input->inRequest($paramKey)) {
// apparently this param is set by the route class
unset($params[$paramKey]);
continue;
}
}
ksort($params);
$methods[$method]['parameters'] = array_values($params);
}
}
$allowedMethods = array_keys($methods);
$allowedMethods[] = 'OPTIONS';
$this->_response->setHeader('Allow', implode(',', $allowedMethods));
return $this->responseData('bdApi_ViewApi_Helper_Options', $methods);
}
示例3: utf8_ucwords
if (utf8_strlen($subject) > 70) {
$errors[] = $lang_post['Too long subject'];
} else {
if ($forum_config['p_subject_all_caps'] == '0' && utf8_strtoupper($subject) == $subject && !$forum_page['is_admmod']) {
$subject = utf8_ucwords(utf8_strtolower($subject));
}
}
}
}
// Clean up message from POST
$message = forum_linebreaks(forum_trim($_POST['req_message']));
if (strlen($message) > FORUM_MAX_POSTSIZE_BYTES) {
$errors[] = sprintf($lang_post['Too long message'], forum_number_format(strlen($message)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES));
} else {
if ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($message) == $message && !$forum_page['is_admmod']) {
$message = utf8_ucwords(utf8_strtolower($message));
}
}
// Validate BBCode syntax
if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1') {
if (!defined('FORUM_PARSER_LOADED')) {
require FORUM_ROOT . 'include/parser.php';
}
$message = preparse_bbcode($message, $errors);
}
if ($message == '') {
$errors[] = $lang_post['No message'];
}
$hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0;
($hook = get_hook('ed_end_validation')) ? eval($hook) : null;
// Did everything go according to plan?
示例4: ucwords
/**
* UTF-8 aware alternative to ucwords
* Uppercase the first character of each word in a string
*
* @param string $str String to be processed
*
* @return string String with first char of each word uppercase
*
* @see http://www.php.net/ucwords
* @since 2.0
*/
public static function ucwords($str)
{
if (!function_exists('utf8_ucwords')) {
require_once __DIR__ . '/phputf8/ucwords.php';
}
return utf8_ucwords($str);
}
示例5: camelize
/**
* Returns given word as CamelCased
*
* Converts a word like "send_email" to "SendEmail". It
* will remove non alphanumeric character from the word, so
* "who's online" will be converted to "WhoSOnline"
*
* @access public
* @static
* @see variablize
* @param string $word Word to convert to camel case
* @return string UpperCamelCasedWord
*/
public static function camelize($word, $ucfirst = true)
{
$word = self::latinize($word);
if (preg_match('/[^A-Z^a-z^0-9]+/', $word) == 0) {
return $ucfirst ? utf8_ucfirst($word) : $word;
}
$word = str_replace(' ', '', utf8_ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
if (!$ucfirst) {
$word = substr_replace($word, strtolower(substr($word, 0, 1)), 0, 1);
}
return $word;
}
示例6: array
}
break;
case 'personality':
$form = array();
// Clean up signature from POST
if ($pun_config['o_signatures'] == '1') {
$form['signature'] = pun_linebreaks(pun_trim($_POST['signature']));
// Validate signature
if (pun_strlen($form['signature']) > $pun_config['p_sig_length']) {
message(sprintf($lang_prof_reg['Sig too long'], $pun_config['p_sig_length'], pun_strlen($form['signature']) - $pun_config['p_sig_length']));
} else {
if (substr_count($form['signature'], "\n") > $pun_config['p_sig_lines'] - 1) {
message(sprintf($lang_prof_reg['Sig too many lines'], $pun_config['p_sig_lines']));
} else {
if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$pun_user['is_admmod']) {
$form['signature'] = utf8_ucwords(utf8_strtolower($form['signature']));
}
}
}
// Validate BBCode syntax
if ($pun_config['p_sig_bbcode'] == '1') {
require PUN_ROOT . 'include/parser.php';
$errors = array();
$form['signature'] = preparse_bbcode($form['signature'], $errors, true);
if (count($errors) > 0) {
message('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>');
}
}
}
break;
case 'display':
示例7: _proper
/**
* Changes a wiki page id into proper case (allowing for :'s etc...)
* @param string $id page id
* @return string
*/
private function _proper($id)
{
$id = str_replace(':', ': ', $id);
// make a little whitespace before words so ucwords can work!
$id = str_replace('_', ' ', $id);
$id = utf8_ucwords($id);
$id = str_replace(': ', ':', $id);
return $id;
}
示例8: _verifyTitle
/**
* Verifies that the discussion title is valid
*
* @param string
*
* @return boolean
*/
protected function _verifyTitle(&$title)
{
// TODO: send these to callbacks to allow hookability?
switch ($this->getOption(self::OPTION_ADJUST_TITLE_CASE)) {
case 'ucfirst':
// sentence case
$title = utf8_ucfirst(utf8_strtolower($title));
break;
case 'ucwords':
// title case
$title = utf8_ucwords(utf8_strtolower($title));
break;
}
if ($this->getOption(self::OPTION_TRIM_TITLE)) {
$table = reset($this->_fields);
$title = XenForo_Helper_String::wholeWordTrim($title, $table['title']['maxLength'] - 5);
}
return true;
}
示例9: testLinefeed
function testLinefeed()
{
$str = "iñt ërn âti\n ônà liz æti øn";
$ucwords = "Iñt Ërn Âti\n Ônà Liz Æti Øn";
$this->assertEqual(utf8_ucwords($str), $ucwords);
}
示例10: _handle_ajax
function _handle_ajax($event)
{
if (strpos($event->data, 'data_page_') !== 0) {
return;
}
$event->preventDefault();
$type = substr($event->data, 10);
$aliases = $this->dthlp->_aliases();
if (!isset($aliases[$type])) {
echo 'Unknown type';
return;
}
if ($aliases[$type]['type'] !== 'page') {
echo 'AutoCompletion is only supported for page types';
return;
}
if (substr($aliases[$type]['postfix'], -1, 1) === ':') {
// Resolve namespace start page ID
global $conf;
$aliases[$type]['postfix'] .= $conf['start'];
}
$search = $_POST['search'];
$pages = ft_pageLookup($search, false, false);
$regexp = '/^';
if ($aliases[$type]['prefix'] !== '') {
$regexp .= preg_quote($aliases[$type]['prefix'], '/');
}
$regexp .= '([^:]+)';
if ($aliases[$type]['postfix'] !== '') {
$regexp .= preg_quote($aliases[$type]['postfix'], '/');
}
$regexp .= '$/';
$result = array();
foreach ($pages as $page => $title) {
$id = array();
if (!preg_match($regexp, $page, $id)) {
// Does not satisfy the postfix and prefix criteria
continue;
}
$id = $id[1];
if ($search !== '' && stripos($id, cleanID($search)) === false && stripos($title, $search) === false) {
// Search string is not in id part or title
continue;
}
if ($title === '') {
$title = utf8_ucwords(str_replace('_', ' ', $id));
}
$result[hsc($id)] = hsc($title);
}
$json = new JSON();
echo '(' . $json->encode($result) . ')';
}
示例11: ucwords
/**
* UTF-8 aware alternative to ucwords()
*
* Uppercase the first character of each word in a string.
*
* @param string $str String to be processed
*
* @return string String with first char of each word uppercase
*
* @see http://www.php.net/ucwords
* @since 1.3.0
*/
public static function ucwords($str)
{
return utf8_ucwords($str);
}
示例12: pageTemplate
/**
* Returns the pagetemplate contents for the ID's namespace
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function pageTemplate($data)
{
$id = $data[0];
global $conf;
global $INFO;
$path = dirname(wikiFN($id));
if (@file_exists($path . '/_template.txt')) {
$tpl = io_readFile($path . '/_template.txt');
} else {
// search upper namespaces for templates
$len = strlen(rtrim($conf['datadir'], '/'));
while (strlen($path) >= $len) {
if (@file_exists($path . '/__template.txt')) {
$tpl = io_readFile($path . '/__template.txt');
break;
}
$path = substr($path, 0, strrpos($path, '/'));
}
}
if (!$tpl) {
return '';
}
// replace placeholders
$file = noNS($id);
$page = strtr($file, '_', ' ');
$tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($id, getNS($id), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], $conf['dformat']), $tpl);
// we need the callback to work around strftime's char limit
$tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
return $tpl;
}
示例13: startescrow_send_message
function startescrow_send_message($body, $subject, $receiver_username, $amount, &$message_id)
{
global $lang_escrows, $forum_user, $forum_db, $forum_url, $forum_config, $forum_flash;
$errors = array();
$receiver_id = startescrow_get_receiver_id($receiver_username, $errors);
if ($receiver_id == 'NULL' && empty($errors)) {
$errors[] = $lang_escrows['Empty receiver'];
}
// Clean up body from POST
$body = forum_linebreaks($body);
if ($body == '') {
$errors[] = $lang_escrows['Empty body'];
} elseif (strlen($body) > FORUM_MAX_POSTSIZE_BYTES) {
$errors[] = sprintf($lang_escrows['Too long message'], forum_number_format(strlen($body)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES));
} elseif ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($body) == $body && !$forum_page['is_admmod']) {
$body = utf8_ucwords(utf8_strtolower($body));
}
// Validate BBCode syntax
if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1') {
global $smilies;
if (!defined('FORUM_PARSER_LOADED')) {
require FORUM_ROOT . 'include/parser.php';
}
$body = preparse_bbcode($body, $errors);
}
// Sending message to the buyer
$btcaddress = get_free_btcaddress($errors);
//book the address
if (count($errors)) {
return $errors;
}
$now = time();
// Send new message
// Save to DB
$query = array('INSERT' => 'sender_id, receiver_id, status, lastedited_at, read_at, subject, body', 'INTO' => 'pun_pm_messages', 'VALUES' => $forum_user['id'] . ', ' . $receiver_id . ', \'sent\', ' . $now . ', 0, \'' . $forum_db->escape($subject) . '\', \'' . $forum_db->escape($body) . '\'');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$endtime = $now + $forum_config['o_empty_escrow_duration'] * 3600;
$endtime = date('Y-m-d H:i:s ', $endtime);
// Send message to the buyer
$body = sprintf($lang_escrows['Escrow buyer message'], $endtime, $amount, $btcaddress);
// Save to DB
$query = array('INSERT' => 'receiver_id, sender_id, status, lastedited_at, read_at, subject, body', 'INTO' => 'pun_pm_messages', 'VALUES' => $forum_user['id'] . ', ' . $receiver_id . ', \'sent\', ' . $now . ', 0, \'' . $forum_db->escape($subject) . '\', \'' . $forum_db->escape($body) . '\'');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
// ########### Add to escrows table
$query = array('INSERT' => 'time, buyerid, sellerid, amount, subject, status, recivedtime, btcaddress', 'INTO' => 'escrows', 'VALUES' => $now . ', ' . $forum_user['id'] . ', ' . $receiver_id . ', ' . $amount . ', \'' . $forum_db->escape($subject) . '\', 0, 0, \'' . $btcaddress . '\'');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
startescrow_clear_cache($receiver_id);
// Clear cached 'New messages' in the user table
$forum_flash->add_info($lang_escrows['Escrow started']);
redirect(forum_link($forum_url['pun_pm_inbox']), $lang_escrows['Message sent']);
}
示例14: get_std_replacements
function get_std_replacements()
{
if (!$this->getConf('stdreplace')) {
return array();
}
global $conf;
global $INFO;
global $ID;
$file = noNS($ID);
$page = cleanID($file);
$names = array('ID', 'NS', 'FILE', '!FILE', '!FILE!', 'PAGE', '!PAGE', '!!PAGE', '!PAGE!', 'USER', 'DATE', 'EVENT');
$values = array($ID, getNS($ID), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], strftime($conf['dformat'], time()), $event->name);
$std_replacements = array();
for ($i = 0; $i < count($names); $i++) {
$std_replacements[$names[$i]] = $values[$i];
}
return $std_replacements;
}
示例15: update_profile
public function update_profile($id, $info, $section)
{
$info = Container::get('hooks')->fire('model.profile.update_profile_start', $info, $id, $section);
$username_updated = false;
$section = Container::get('hooks')->fire('model.profile.update_profile_section', $section, $id, $info);
// Validate input depending on section
switch ($section) {
case 'essentials':
$form = array('timezone' => floatval(Input::post('form_timezone')), 'dst' => Input::post('form_dst') ? '1' : '0', 'time_format' => intval(Input::post('form_time_format')), 'date_format' => intval(Input::post('form_date_format')));
// Make sure we got a valid language string
if (Input::post('form_language')) {
$languages = \FeatherBB\Core\Lister::getLangs();
$form['language'] = Utils::trim(Input::post('form_language'));
if (!in_array($form['language'], $languages)) {
throw new Error(__('Bad request'), 404);
}
}
if (User::get()->is_admmod) {
$form['admin_note'] = Utils::trim(Input::post('admin_note'));
// Are we allowed to change usernames?
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || User::get()->g_moderator == '1' && User::get()->g_mod_rename_users == '1') {
$form['username'] = Utils::trim(Input::post('req_username'));
if ($form['username'] != $info['old_username']) {
$errors = '';
$errors = $this->check_username($form['username'], $errors, $id);
if (!empty($errors)) {
throw new Error($errors[0]);
}
$username_updated = true;
}
}
// We only allow administrators to update the post count
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) {
$form['num_posts'] = intval(Input::post('num_posts'));
}
}
if (ForumSettings::get('o_regs_verify') == '0' || User::get()->is_admmod) {
// Validate the email address
$form['email'] = strtolower(Utils::trim(Input::post('req_email')));
if (!Container::get('email')->is_valid_email($form['email'])) {
throw new Error(__('Invalid email'));
}
}
break;
case 'personal':
$form = array('realname' => Input::post('form_realname') ? Utils::trim(Input::post('form_realname')) : '', 'url' => Input::post('form_url') ? Utils::trim(Input::post('form_url')) : '', 'location' => Input::post('form_location') ? Utils::trim(Input::post('form_location')) : '');
// Add http:// if the URL doesn't contain it already (while allowing https://, too)
if (User::get()->g_post_links == '1') {
if ($form['url'] != '') {
$url = Url::is_valid($form['url']);
if ($url === false) {
throw new Error(__('Invalid website URL'));
}
$form['url'] = $url['url'];
}
} else {
if (!empty($form['url'])) {
throw new Error(__('Website not allowed'));
}
$form['url'] = '';
}
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) {
$form['title'] = Utils::trim(Input::post('title'));
} elseif (User::get()->g_set_title == '1') {
$form['title'] = Utils::trim(Input::post('title'));
if ($form['title'] != '') {
// A list of words that the title may not contain
// If the language is English, there will be some duplicates, but it's not the end of the world
$forbidden = array('member', 'moderator', 'administrator', 'banned', 'guest', utf8_strtolower(__('Member')), utf8_strtolower(__('Moderator')), utf8_strtolower(__('Administrator')), utf8_strtolower(__('Banned')), utf8_strtolower(__('Guest')));
if (in_array(utf8_strtolower($form['title']), $forbidden)) {
throw new Error(__('Forbidden title'));
}
}
}
break;
case 'messaging':
$form = array('jabber' => Utils::trim(Input::post('form_jabber')), 'icq' => Utils::trim(Input::post('form_icq')), 'msn' => Utils::trim(Input::post('form_msn')), 'aim' => Utils::trim(Input::post('form_aim')), 'yahoo' => Utils::trim(Input::post('form_yahoo')));
// If the ICQ UIN contains anything other than digits it's invalid
if (preg_match('%[^0-9]%', $form['icq'])) {
throw new Error(__('Bad ICQ'));
}
break;
case 'personality':
$form = array();
// Clean up signature from POST
if (ForumSettings::get('o_signatures') == '1') {
$form['signature'] = Utils::linebreaks(Utils::trim(Input::post('signature')));
// Validate signature
if (Utils::strlen($form['signature']) > ForumSettings::get('p_sig_length')) {
throw new Error(sprintf(__('Sig too long'), ForumSettings::get('p_sig_length'), Utils::strlen($form['signature']) - ForumSettings::get('p_sig_length')));
} elseif (substr_count($form['signature'], "\n") > ForumSettings::get('p_sig_lines') - 1) {
throw new Error(sprintf(__('Sig too many lines'), ForumSettings::get('p_sig_lines')));
} elseif ($form['signature'] && ForumSettings::get('p_sig_all_caps') == '0' && Utils::is_all_uppercase($form['signature']) && !User::get()->is_admmod) {
$form['signature'] = utf8_ucwords(utf8_strtolower($form['signature']));
}
// Validate BBCode syntax
if (ForumSettings::get('p_sig_bbcode') == '1') {
$errors = array();
$form['signature'] = Container::get('parser')->preparse_bbcode($form['signature'], $errors, true);
if (count($errors) > 0) {
//.........这里部分代码省略.........