本文整理汇总了PHP中MultiByte::strtolower方法的典型用法代码示例。如果您正苦于以下问题:PHP MultiByte::strtolower方法的具体用法?PHP MultiByte::strtolower怎么用?PHP MultiByte::strtolower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiByte
的用法示例。
在下文中一共展示了MultiByte::strtolower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_strtolower
function test_strtolower()
{
$this->assert_equal(MultiByte::strtolower(self::$test_str), mb_strtolower(mb_convert_encoding(self::$test_str, 'UTF-8', mb_detect_encoding(self::$test_str)), 'UTF-8'));
printf("Test string: %s <br>", self::$test_str);
printf("MultiByte strtolower: %s <br>", MultiByte::strtolower(self::$test_str));
printf("mbstring strtolower without detecting encoding: %s <br>", mb_strtolower(self::$test_str));
printf("mstring strtolower with detecting encoding: %s <br><br>", mb_strtolower(self::$test_str, mb_detect_encoding(self::$test_str)));
}
示例2: filter_user_authenticate
public function filter_user_authenticate($user, $username, $password)
{
$passwdfile = Options::get('passwdlogins__file');
if (!$passwdfile) {
EventLog::log(_t('No passwd file configured!'), 'err', 'passwdlogins', 'passwdlogins');
return false;
}
if (!file_exists($passwdfile)) {
EventLog::log(_t('Passwd file does not exist: %1$s', array($passwdfile)), 'err', 'passwdlogins', 'passwdlogins');
return false;
}
// go ahead and trim the user and password
$username = trim($username);
$password = trim($password);
// blank usernames and passwords are not allowed
if ($username == '' || $password == '') {
return false;
}
$users = $this->parse_htpasswd($passwdfile);
if (isset($users[$username])) {
$crypt_pass = $users[$username];
if ($crypt_pass[0] == '{') {
// figure out the algorithm used for this password
$algo = MultiByte::strtolower(MultiByte::substr($crypt_pass, 1, MultiByte::strpos($crypt_pass, '}', 1) - 1));
$passok = false;
switch ($algo) {
case 'ssha':
$hash = base64_decode(MultiByte::substr($crypt_pass, 6));
$passok = MultiByte::substr($hash, 0, 20) == pack("H*", sha1($password . MultiByte::substr($hash, 20)));
break;
case 'sha':
$passok = '{SHA}' . base64_encode(pack("H*", sha1($password))) == $crypt_pass;
break;
}
} else {
// it's plain crypt
$passok = crypt($password, MultiByte::substr($crypt_pass, 0, CRYPT_SALT_LENGTH)) == $crypt_pass;
}
if ($passok == true) {
return $this->get_user($username);
}
}
// returning $user would continue the login check through other plugins and core - we want to force passwd logins
return false;
}
示例3: get
//.........这里部分代码省略.........
$joins['terms_vocabulary'] = ' JOIN {vocabularies} ON {terms}.vocabulary_id = {vocabularies}.id';
$where[] = '{vocabularies}.name = ? AND {terms}.' . $field . ' IN ( ' . Utils::placeholder_string($terms) . ' ) AND {object_terms}.object_type_id = ?';
$params[] = $vocab;
$params = array_merge($params, $terms);
$params[] = $object_id;
}
}
foreach ($not as $vocab => $value) {
foreach ($value as $field => $terms) {
// we only support these fields to search by
if (!in_array($field, array('id', 'term', 'term_display'))) {
continue;
}
$where[] = 'NOT EXISTS ( SELECT 1
FROM {object_terms}
JOIN {terms} ON {terms}.id = {object_terms}.term_id
JOIN {vocabularies} ON {terms}.vocabulary_id = {vocabularies}.id
WHERE {terms}.' . $field . ' IN (' . Utils::placeholder_string($terms) . ')
AND {object_terms}.object_id = {posts}.id
AND {object_terms}.object_type_id = ?
AND {vocabularies}.name = ?
)';
$params = array_merge($params, array_values($terms));
$params[] = $object_id;
$params[] = $vocab;
}
}
}
if (isset($paramset['criteria'])) {
// this regex matches any unicode letters (\p{L}) or numbers (\p{N}) inside a set of quotes (but strips the quotes) OR not in a set of quotes
preg_match_all('/(?<=")([\\p{L}\\p{N}]+[^"]*)(?=")|([\\p{L}\\p{N}]+)/u', $paramset['criteria'], $matches);
foreach ($matches[0] as $word) {
$where[] .= "( LOWER( {posts}.title ) LIKE ? OR LOWER( {posts}.content ) LIKE ?)";
$params[] = '%' . MultiByte::strtolower($word) . '%';
$params[] = '%' . MultiByte::strtolower($word) . '%';
// Not a typo (there are two ? in the above statement)
}
}
if (isset($paramset['title'])) {
$where[] .= "LOWER( {posts}.title ) LIKE ?";
$params[] = MultiByte::strtolower($paramset['title']);
}
if (isset($paramset['title_search'])) {
// this regex matches any unicode letters (\p{L}) or numbers (\p{N}) inside a set of quotes (but strips the quotes) OR not in a set of quotes
preg_match_all('/(?<=")([\\p{L}\\p{N}]+[^"]*)(?=")|([\\p{L}\\p{N}]+)/u', $paramset['title_search'], $matches);
foreach ($matches[0] as $word) {
$where[] .= " LOWER( {posts}.title ) LIKE ? ";
$params[] = '%' . MultiByte::strtolower($word) . '%';
}
}
if (isset($paramset['all:info']) || isset($paramset['info'])) {
// merge the two possibile calls together
$infos = array_merge(isset($paramset['all:info']) ? $paramset['all:info'] : array(), isset($paramset['info']) ? $paramset['info'] : array());
if (Utils::is_traversable($infos)) {
$pi_count = 0;
foreach ($infos as $info_key => $info_value) {
$pi_count++;
$joins['info_' . $info_key] = " LEFT JOIN {postinfo} ipi{$pi_count} ON {posts}.id = ipi{$pi_count}.post_id AND ipi{$pi_count}.name = ? AND ipi{$pi_count}.value = ?";
$join_params[] = $info_key;
$join_params[] = $info_value;
$where[] = "ipi{$pi_count}.name <> ''";
$select_ary["info_{$info_key}_value"] = "ipi{$pi_count}.value AS info_{$info_key}_value";
$select_distinct["info_{$info_key}_value"] = "info_{$info_key}_value";
}
}
}
示例4: get
//.........这里部分代码省略.........
$andwhere->in($join_group . '_ot.object_type_id', $object_id);
}
$orwhere->add($andwhere);
// @todo this seems like it's in the wrong place
}
$where->add($orwhere);
}
if (isset($paramset['vocabulary']['not'])) {
$not = $paramset['vocabulary']['not'];
foreach ($not as $vocab => $value) {
foreach ($value as $field => $terms) {
// we only support these fields to search by
if (!in_array($field, array('id', 'term', 'term_display'))) {
continue;
}
$subquery_alias = Query::new_param_name('subquery');
$subquery = Query::create('{object_terms}')->select('object_id');
$subquery->join('JOIN {terms} ON {terms}.id = {object_terms}.term_id');
$subquery->join('JOIN {vocabularies} ON {terms}.vocabulary_id = {vocabularies}.id');
$subquery->where()->in("{terms}.{$field}", $terms);
$subquery->where()->in('{object_terms}.object_type_id', $object_id);
$subquery->where()->in('{vocabularies}.name', $vocab);
$query->join('LEFT JOIN (' . $subquery->get() . ') ' . $subquery_alias . ' ON ' . $subquery_alias . '.object_id = {posts}.id', $subquery->params(), $subquery_alias);
$where->add('COALESCE(' . $subquery_alias . '.object_id, 0) = 0');
}
}
}
}
if (isset($paramset['criteria'])) {
// this regex matches any unicode letters (\p{L}) or numbers (\p{N}) inside a set of quotes (but strips the quotes) OR not in a set of quotes
preg_match_all('/(?<=")([\\p{L}\\p{N}]+[^"]*)(?=")|([\\p{L}\\p{N}]+)/u', $paramset['criteria'], $matches);
foreach ($matches[0] as $word) {
$crit_placeholder = $query->new_param_name('criteria');
$where->add("( LOWER( {posts}.title ) LIKE :{$crit_placeholder} OR LOWER( {posts}.content ) LIKE :{$crit_placeholder})", array($crit_placeholder => '%' . MultiByte::strtolower($word) . '%'));
}
}
if (isset($paramset['title'])) {
$where->add("LOWER( {posts}.title ) LIKE :title_match", array('title_match' => MultiByte::strtolower($paramset['title'])));
}
if (isset($paramset['title_search'])) {
// this regex matches any unicode letters (\p{L}) or numbers (\p{N}) inside a set of quotes (but strips the quotes) OR not in a set of quotes
preg_match_all('/(?<=")([\\p{L}\\p{N}]+[^"]*)(?=")|([\\p{L}\\p{N}]+)/u', $paramset['title_search'], $matches);
foreach ($matches[0] as $word) {
$crit_placeholder = $query->new_param_name('title_search');
$where->add("LOWER( {posts}.title ) LIKE :{$crit_placeholder}", array($crit_placeholder => '%' . MultiByte::strtolower($word) . '%'));
}
}
// Handle field queries on posts and joined tables
foreach ($select_ary as $field => $aliasing) {
if (in_array($field, array('id', 'title', 'slug', 'status', 'content_type', 'user_id'))) {
// skip fields that we're handling a different way
continue;
}
if (isset($paramset[$field])) {
if (is_callable($paramset[$field])) {
$paramset[$field]($where, $paramset);
} else {
$where->in($field, $paramset[$field], 'posts_field_' . $field);
}
}
}
//Done
if (isset($paramset['all:info']) || isset($paramset['info'])) {
// merge the two possibile calls together
$infos = array_merge(isset($paramset['all:info']) ? $paramset['all:info'] : array(), isset($paramset['info']) ? $paramset['info'] : array());
if (Utils::is_traversable($infos)) {
示例5: get
/**
* Returns a user or users based on supplied parameters.
* @todo This class should cache query results!
*
* @param array $paramarray An associated array of parameters, or a querystring
* @return array An array of User objects, or a single User object, depending on request
*/
public static function get( $paramarray = array() )
{
$params = array();
$fns = array( 'get_results', 'get_row', 'get_value' );
$select = '';
// what to select -- by default, everything
foreach ( User::default_fields() as $field => $value ) {
$select .= ( '' == $select )
? "{users}.$field"
: ", {users}.$field";
}
// defaults
$orderby = 'id ASC';
$nolimit = true;
// Put incoming parameters into the local scope
$paramarray = Utils::get_params( $paramarray );
// Transact on possible multiple sets of where information that is to be OR'ed
if ( isset( $paramarray['where'] ) && is_array( $paramarray['where'] ) ) {
$wheresets = $paramarray['where'];
}
else {
$wheresets = array( array() );
}
$wheres = array();
$join = '';
if ( isset( $paramarray['where'] ) && is_string( $paramarray['where'] ) ) {
$wheres[] = $paramarray['where'];
}
else {
foreach ( $wheresets as $paramset ) {
// safety mechanism to prevent empty queries
$where = array();
$paramset = array_merge( (array) $paramarray, (array) $paramset );
$default_fields = User::default_fields();
foreach ( User::default_fields() as $field => $scrap ) {
if ( !isset( $paramset[$field] ) ) {
continue;
}
switch ( $field ) {
case 'id':
if ( !is_numeric( $paramset[$field] ) ) {
continue;
}
default:
$where[] = "{$field} = ?";
$params[] = $paramset[$field];
}
}
if ( isset( $paramset['info'] ) && is_array( $paramset['info'] ) ) {
$join .= 'INNER JOIN {userinfo} ON {users}.id = {userinfo}.user_id';
foreach ( $paramset['info'] as $info_name => $info_value ) {
$where[] = '{userinfo}.name = ? AND {userinfo}.value = ?';
$params[] = $info_name;
$params[] = $info_value;
}
}
if ( isset( $paramset['criteria'] ) ) {
if ( isset( $paramset['criteria_fields'] ) ) {
// Support 'criteria_fields' => 'author,ip' rather than 'criteria_fields' => array( 'author', 'ip' )
if ( !is_array( $paramset['criteria_fields'] ) && is_string( $paramset['criteria_fields'] ) ) {
$paramset['criteria_fields'] = explode( ',', $paramset['criteria_fields'] );
}
}
else {
$paramset['criteria_fields'] = array( 'username' );
}
$paramset['criteria_fields'] = array_unique( $paramset['criteria_fields'] );
// this regex matches any unicode letters (\p{L}) or numbers (\p{N}) inside a set of quotes (but strips the quotes) OR not in a set of quotes
preg_match_all( '/(?<=")([\p{L}\p{N}]+[^"]*)(?=")|([\p{L}\p{N}]+)/u', $paramset['criteria'], $matches );
$where_search = array();
foreach ( $matches[0] as $word ) {
foreach ( $paramset['criteria_fields'] as $criteria_field ) {
$where_search[] .= "( LOWER( {users}.$criteria_field ) LIKE ? )";
$params[] = '%' . MultiByte::strtolower( $word ) . '%';
}
}
if ( count( $where_search ) > 0 ) {
$where[] = '(' . implode( " \nOR\n ", $where_search ).')';
}
}
if ( count( $where ) > 0 ) {
$wheres[] = ' (' . implode( ' AND ', $where ) . ') ';
}
}
}
//.........这里部分代码省略.........
示例6: get
//.........这里部分代码省略.........
$where->in('{log}.severity_id', $paramset['severity'], 'log_severity_id', function ($a) {
return LogEntry::severity($a);
});
}
if (isset($paramset['type_id'])) {
$where->in('{log}.type_id', $paramset['type_id'], 'log_type_id', 'intval');
}
if (isset($paramset['module'])) {
$paramset['module'] = Utils::single_array($paramset['module']);
$qry = Query::create('{log_types}');
$qry->select('{log_types}.id')->distinct();
$qry->where()->in('{log_types}.module', $paramset['module'], 'log_subquery_module');
$where->in('{log}.type_id', $qry, 'log_module');
}
if (isset($paramset['type'])) {
$paramset['type'] = Utils::single_array($paramset['type']);
$qry = Query::create('{log_types}');
$qry->select('{log_types}.id')->distinct();
$qry->where()->in('{log_types}.type', $paramset['type'], 'log_subquery_type');
$where->in('{log}.type_id', $qry, 'log_type');
}
if (isset($paramset['ip'])) {
$where->in('{log}.ip', $paramset['ip']);
}
/* do searching */
if (isset($paramset['criteria'])) {
// this regex matches any unicode letters (\p{L}) or numbers (\p{N}) inside a set of quotes (but strips the quotes) OR not in a set of quotes
preg_match_all('/(?<=")(\\w[^"]*)(?=")|([:\\w]+)/u', $paramset['criteria'], $matches);
foreach ($matches[0] as $word) {
if (preg_match('%^id:(\\d+)$%i', $word, $special_crit)) {
$where->in('{log}.id', $special_crit[1], 'log_special_criteria');
} else {
$crit_placeholder = $query->new_param_name('criteria');
$where->add("( LOWER( {log}.message ) LIKE :{$crit_placeholder}", array($crit_placeholder => '%' . MultiByte::strtolower($word) . '%'));
}
}
}
/**
* Build the pubdate
* If we've got the day, then get the date.
* If we've got the month, but no date, get the month.
* If we've only got the year, get the whole year.
*
* @todo Ensure that we've actually got all the needed parts when we query on them
*/
if (isset($paramset['day']) && isset($paramset['month']) && isset($paramset['year'])) {
$start_date = sprintf('%d-%02d-%02d', $paramset['year'], $paramset['month'], $paramset['day']);
$start_date = DateTime::create($start_date);
$where->add('timestamp BETWEEN :start_date AND :end_date', array('start_date' => $start_date->sql, 'end_date' => $start_date->modify('+1 day -1 second')->sql));
} elseif (isset($paramset['month']) && isset($paramset['year'])) {
$start_date = sprintf('%d-%02d-%02d', $paramset['year'], $paramset['month'], 1);
$start_date = DateTime::create($start_date);
$where->add('timestamp BETWEEN :start_date AND :end_date', array('start_date' => $start_date->sql, 'end_date' => $start_date->modify('+1 month -1 second')->sql));
} elseif (isset($paramset['year'])) {
$start_date = sprintf('%d-%02d-%02d', $paramset['year'], 1, 1);
$start_date = DateTime::create($start_date);
$where->add('timestamp BETWEEN :start_date AND :end_date', array('start_date' => $start_date->sql, 'end_date' => $start_date->modify('+1 year -1 second')->sql));
}
// Concatenate the WHERE clauses
$query->where()->add($where);
}
// Default parameters.
$orderby = 'timestamp DESC, id DESC';
// $limit = Options::get( 'pagination' );
// Get any full-query parameters
$paramarray = new SuperGlobal($paramarray);
示例7: test_strtolower
public function test_strtolower()
{
$this->assert_equal(MultiByte::strtolower($this->test_strings['ucfirst']), $this->test_strings['lowercase']);
}
示例8: type
/**
* returns the integer value of the specified post type, or false
* @param mixed a post type name or number
* @return mixed an integer or boolean false
*/
public static function type( $name )
{
$types = Post::list_active_post_types();
if ( is_numeric( $name ) && ( false !== in_array( $name, $types ) ) ) {
return $name;
}
if ( isset( $types[ MultiByte::strtolower( $name ) ] ) ) {
return $types[ MultiByte::strtolower( $name ) ];
}
return false;
}
示例9: generate_title
private function generate_title($min = 2, $max = 8)
{
// get a fake paragraph of text that's 1 line long
$text = $this->generate_paragraph(1, 1);
$text = MultiByte::strtolower($text);
// remove commas and periods
$text = MultiByte::str_replace(array('.', ','), '', $text);
$words = explode(' ', $text);
// randomize the words list
shuffle($words);
// we can only get the max number of words the paragraph generated
if ($min > count($words)) {
$min = count($words);
}
if ($max > count($words)) {
$max = count($words);
}
// decide how many words we want
$how_many_words = mt_rand($min, $max);
$title = array();
for ($i = 0; $i < $how_many_words; $i++) {
// snag a random word
$title[] = array_pop($words);
}
$title = implode(' ', $title);
// capitalize the first letter of each word
$title = MultiByte::ucwords($title);
return $title;
}
示例10: compare_names
protected function compare_names($a, $b)
{
$aname = isset($a['info']) ? $a['info']->name : '';
$bname = isset($b['info']) ? $b['info']->name : '';
return strcmp(MultiByte::strtolower($aname), MultiByte::strtolower($bname));
}
示例11: compare_names
protected function compare_names( $a, $b )
{
return strcmp( MultiByte::strtolower( $a['info']->name), MultiByte::strtolower( $b['info']->name ) );
}
示例12: _filter_token_description_display
/**
* function _filter_token_description_display
* Filter to localize token descriptions
* @param string Token to get the description of
* @return string The localized token description
*/
public static function _filter_token_description_display($token)
{
$desc = array('super_user' => _t('Permissions for super users'), 'manage_all_comments' => _t('Manage comments on all posts'), 'manage_own_post_comments' => _t('Manage comments on one\'s own posts'), 'manage_tags' => _t('Manage tags'), 'manage_options' => _t('Manage options'), 'manage_theme' => _t('Change theme'), 'manage_theme_config' => _t('Configure the active theme'), 'manage_plugins' => _t('Activate/deactivate plugins'), 'manage_plugins_config' => _t('Configure active plugins'), 'manage_import' => _t('Use the importer'), 'manage_users' => _t('Add, remove, and edit users'), 'manage_self' => _t('Edit own profile'), 'manage_groups' => _t('Manage groups and permissions'), 'manage_logs' => _t('Manage logs'), 'manage_dash_modules' => _t('Manage dashboard modules'), 'own_posts' => _t('Permissions on one\'s own posts'), 'post_any' => _t('Permissions to all posts'), 'post_unpublished' => _t('Permissions to other user\'s unpublished posts'), 'comment' => _t('Make comments on any post'));
// content tokens
foreach (Post::list_active_post_types() as $name => $posttype) {
$label = MultiByte::strtolower(Plugins::filter('post_type_display', $name, 'singular'));
$desc['post_' . Utils::slugify($name)] = _t('Permissions to posts of type "%s"', array($label));
}
return isset($desc[$token]) ? $desc[$token] : $token;
}
示例13: testStrtolower
public function testStrtolower()
{
$this->assertEquals(MultiByte::strtolower(self::$test_str), mb_strtolower(mb_convert_encoding(self::$test_str, 'UTF-8', mb_detect_encoding(self::$test_str)), 'UTF-8'));
}
示例14: slugify
/**
* Return a sanitized slug, replacing non-alphanumeric characters to dashes
* @param string $string The string to sanitize. Non-alphanumeric characters will be replaced by dashes
* @param string $separator The slug separator, '-' by default
* @return string The sanitized slug
*/
public static function slugify($string, $separator = '-')
{
// Decode HTML entities
// Replace non-alphanumeric characters to dashes. Exceptions: %, _, -
// Note that multiple separators are collapsed automatically by the preg_replace.
// Convert all characters to lowercase.
// Trim spaces on both sides.
$slug = rtrim(MultiByte::strtolower(preg_replace('/[^\\p{L}\\p{N}_]+/u', $separator, preg_replace('/\\p{Po}/u', '', html_entity_decode($string)))), $separator);
// Let people change the behavior.
$slug = Plugins::filter('slugify', $slug, $string);
return $slug;
}
示例15: search_to_get
/**
* Parses a search string for status, type, author, and tag keywords. Returns
* an associative array which can be passed to Comments::get(). If multiple
* authors, statuses, or types are specified, we assume an implicit OR
* such that (e.g.) any author that matches would be returned.
*
* @param string $search_string The search string
* @return array An associative array which can be passed to Comments::get()
*/
public static function search_to_get($search_string)
{
$statuses = array_flip(Comment::list_comment_statuses());
$types = array_flip(Comment::list_comment_types());
$arguments = array('name' => array(), 'status' => array(), 'type' => array());
$criteria = '';
$tokens = explode(' ', $search_string);
foreach ($tokens as $token) {
// check for a keyword:value pair
if (preg_match('/^\\w+:\\S+$/u', $token)) {
list($keyword, $value) = explode(':', $token);
$keyword = strtolower($keyword);
$value = MultiByte::strtolower($value);
switch ($keyword) {
case 'author':
$arguments['name'][] = $value;
break;
case 'status':
if (isset($statuses[$value])) {
$arguments['status'][] = (int) $statuses[$value];
}
break;
case 'type':
if (isset($types[$value])) {
$arguments['type'][] = (int) $types[$value];
}
break;
}
} else {
$criteria .= $token . ' ';
}
}
// flatten keys that have single-element or no-element arrays
foreach ($arguments as $key => $arg) {
switch (count($arg)) {
case 0:
unset($arguments[$key]);
break;
case 1:
$arguments[$key] = $arg[0];
break;
}
}
if ($criteria != '') {
$arguments['criteria'] = $criteria;
}
return $arguments;
}