本文整理汇总了PHP中phutil_utf8_strtolower函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_utf8_strtolower函数的具体用法?PHP phutil_utf8_strtolower怎么用?PHP phutil_utf8_strtolower使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phutil_utf8_strtolower函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadPHIDsByTypes
private function loadPHIDsByTypes($type)
{
$objects = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorFulltextInterface')->execute();
$normalized_type = phutil_utf8_strtolower($type);
$matches = array();
foreach ($objects as $object) {
$object_class = get_class($object);
$normalized_class = phutil_utf8_strtolower($object_class);
if (!strlen($type) || strpos($normalized_class, $normalized_type) !== false) {
$matches[$object_class] = $object;
}
}
if (!$matches) {
$all_types = array();
foreach ($objects as $object) {
$all_types[] = get_class($object);
}
sort($all_types);
throw new PhutilArgumentUsageException(pht('Type "%s" matches no indexable objects. Supported types are: %s.', $type, implode(', ', $all_types)));
}
if (count($matches) > 1 && strlen($type)) {
throw new PhutilArgumentUsageException(pht('Type "%s" matches multiple indexable objects. Use a more ' . 'specific string. Matching object types are: %s.', $type, implode(', ', array_keys($matches))));
}
$phids = array();
foreach ($matches as $match) {
$iterator = new LiskMigrationIterator($match);
foreach ($iterator as $object) {
$phids[] = $object->getPHID();
}
}
return $phids;
}
示例2: normalize
public static function normalize($slug, $hashtag = false)
{
$slug = preg_replace('@/+@', '/', $slug);
$slug = trim($slug, '/');
$slug = phutil_utf8_strtolower($slug);
$ban = "\\x00-\\x19" . "#%&+=?" . " " . "\\\\" . "<>{}\\[\\]" . "'" . '"';
// In hashtag mode (used for Project hashtags), ban additional characters
// which cause parsing problems.
if ($hashtag) {
$ban .= '`~!@$^*,:;(|)';
}
$slug = preg_replace('([' . $ban . ']+)', '_', $slug);
$slug = preg_replace('@_+@', '_', $slug);
$parts = explode('/', $slug);
// Remove leading and trailing underscores from each component, if the
// component has not been reduced to a single underscore. For example, "a?"
// converts to "a", but "??" converts to "_".
foreach ($parts as $key => $part) {
if ($part != '_') {
$parts[$key] = trim($part, '_');
}
}
$slug = implode('/', $parts);
// Specifically rewrite these slugs. It's OK to have a slug like "a..b",
// but not a slug which is only "..".
// NOTE: These are explicitly not pht()'d, because they should be stable
// across languages.
$replace = array('.' => 'dot', '..' => 'dotdot');
foreach ($replace as $pattern => $replacement) {
$pattern = preg_quote($pattern, '@');
$slug = preg_replace('@(^|/)' . $pattern . '(\\z|/)@', '\\1' . $replacement . '\\2', $slug);
}
return $slug . '/';
}
示例3: processMailCommands
private function processMailCommands(PhabricatorMetaMTAReceivedMail $mail, array $command_list)
{
$viewer = $this->getActor();
$object = $this->getMailReceiver();
$list = MetaMTAEmailTransactionCommand::getAllCommandsForObject($object);
$map = MetaMTAEmailTransactionCommand::getCommandMap($list);
$xactions = array();
foreach ($command_list as $command_argv) {
$command = head($command_argv);
$argv = array_slice($command_argv, 1);
$handler = idx($map, phutil_utf8_strtolower($command));
if ($handler) {
$results = $handler->buildTransactions($viewer, $object, $mail, $command, $argv);
foreach ($results as $result) {
$xactions[] = $result;
}
} else {
$valid_commands = array();
foreach ($list as $valid_command) {
$aliases = $valid_command->getCommandAliases();
if ($aliases) {
foreach ($aliases as $key => $alias) {
$aliases[$key] = '!' . $alias;
}
$aliases = implode(', ', $aliases);
$valid_commands[] = pht('!%s (or %s)', $valid_command->getCommand(), $aliases);
} else {
$valid_commands[] = '!' . $valid_command->getCommand();
}
}
throw new Exception(pht('The command "!%s" is not a supported mail command. Valid ' . 'commands for this object are: %s.', $command, implode(', ', $valid_commands)));
}
}
return $xactions;
}
示例4: normalize
public static function normalize($slug)
{
$slug = preg_replace('@/+@', '/', $slug);
$slug = trim($slug, '/');
$slug = phutil_utf8_strtolower($slug);
$slug = preg_replace("@[\\x00-\\x19#%&+=\\\\?<> ]+@", '_', $slug);
$slug = preg_replace('@_+@', '_', $slug);
// Remove leading and trailing underscores from each component, if the
// component has not been reduced to a single underscore. For example, "a?"
// converts to "a", but "??" converts to "_".
$parts = explode('/', $slug);
foreach ($parts as $key => $part) {
if ($part != '_') {
$parts[$key] = trim($part, '_');
}
}
$slug = implode('/', $parts);
// Specifically rewrite these slugs. It's OK to have a slug like "a..b",
// but not a slug which is only "..".
// NOTE: These are explicitly not pht()'d, because they should be stable
// across languages.
$replace = array('.' => 'dot', '..' => 'dotdot');
foreach ($replace as $pattern => $replacement) {
$pattern = preg_quote($pattern, '@');
$slug = preg_replace('@(^|/)' . $pattern . '(\\z|/)@', '\\1' . $replacement . '\\2', $slug);
}
return $slug . '/';
}
示例5: buildWhereClauseParts
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn)
{
$where = parent::buildWhereClauseParts($conn);
if ($this->phids !== null) {
$where[] = qsprintf($conn, 'p.phid IN (%Ls)', $this->phids);
}
if ($this->ids !== null) {
$where[] = qsprintf($conn, 'p.id IN (%Ld)', $this->ids);
}
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf($conn, 'rpath.repositoryPHID IN (%Ls)', $this->repositoryPHIDs);
}
if ($this->ownerPHIDs !== null) {
$base_phids = $this->ownerPHIDs;
$projects = id(new PhabricatorProjectQuery())->setViewer($this->getViewer())->withMemberPHIDs($base_phids)->execute();
$project_phids = mpull($projects, 'getPHID');
$all_phids = array_merge($base_phids, $project_phids);
$where[] = qsprintf($conn, 'o.userPHID IN (%Ls)', $all_phids);
}
if (strlen($this->namePrefix)) {
// NOTE: This is a hacky mess, but this column is currently case
// sensitive and unique.
$where[] = qsprintf($conn, 'LOWER(p.name) LIKE %>', phutil_utf8_strtolower($this->namePrefix));
}
return $where;
}
示例6: markupText
public function markupText($text, $children)
{
$matches = array();
preg_match($this->getRegEx(), $text, $matches);
if (idx($matches, 'showword')) {
$word = $matches['showword'];
$show = true;
} else {
$word = $matches['hideword'];
$show = false;
}
$class_suffix = phutil_utf8_strtolower($word);
// This is the "(IMPORTANT)" or "NOTE:" part.
$word_part = rtrim(substr($text, 0, strlen($matches[0])));
// This is the actual text.
$text_part = substr($text, strlen($matches[0]));
$text_part = $this->applyRules(rtrim($text_part));
$text_mode = $this->getEngine()->isTextMode();
if ($text_mode) {
return $word_part . ' ' . $text_part;
}
if ($show) {
$content = array(phutil_tag('span', array('class' => 'remarkup-note-word'), $word_part), ' ', $text_part);
} else {
$content = $text_part;
}
return phutil_tag('div', array('class' => 'remarkup-' . $class_suffix), $content);
}
示例7: getNgramsFromString
public final function getNgramsFromString($value, $mode)
{
$tokens = $this->tokenizeString($value);
$ngrams = array();
foreach ($tokens as $token) {
$token = phutil_utf8_strtolower($token);
switch ($mode) {
case 'query':
break;
case 'index':
$token = ' ' . $token . ' ';
break;
case 'prefix':
$token = ' ' . $token;
break;
}
$len = strlen($token) - 2;
for ($ii = 0; $ii < $len; $ii++) {
$ngram = substr($token, $ii, 3);
$ngrams[$ngram] = $ngram;
}
}
ksort($ngrams);
return array_keys($ngrams);
}
示例8: process
public function process(XHPASTNode $root)
{
$aliases = $this->getFunctionAliases();
$functions = $this->getFunctionCalls($root, array_keys($aliases));
foreach ($functions as $function) {
$function_name = $function->getChildByIndex(0);
$this->raiseLintAtNode($function_name, pht('Alias functions should be avoided.'), $aliases[phutil_utf8_strtolower($function_name->getConcreteString())]);
}
}
示例9: normalizeSlug
private function normalizeSlug($slug)
{
// NOTE: We're using phutil_utf8_strtolower() (and not PhabricatorSlug's
// normalize() method) because this normalization should be only somewhat
// liberal. We want "#YOLO" to match against "#yolo", but "#\\yo!!lo"
// should not. normalize() strips out most punctuation and leads to
// excessively aggressive matches.
return phutil_utf8_strtolower($slug);
}
示例10: tokenizeString
public static function tokenizeString($string)
{
$string = phutil_utf8_strtolower($string);
$string = trim($string);
if (!strlen($string)) {
return array();
}
$tokens = preg_split('/\\s+|-/', $string);
return array_unique($tokens);
}
示例11: markupKeystrokes
public function markupKeystrokes(array $matches)
{
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}
$keys = explode(' ', $matches[1]);
foreach ($keys as $k => $v) {
$v = trim($v, " \n");
$v = preg_replace('/\\\\(.)/', '\\1', $v);
if (!strlen($v)) {
unset($keys[$k]);
continue;
}
$keys[$k] = $v;
}
$special = array(array('name' => pht('Command'), 'symbol' => "⌘", 'aliases' => array('cmd', 'command')), array('name' => pht('Option'), 'symbol' => "⌥", 'aliases' => array('opt', 'option')), array('name' => pht('Shift'), 'symbol' => "⇧", 'aliases' => array('shift')), array('name' => pht('Escape'), 'symbol' => "⎋", 'aliases' => array('esc', 'escape')), array('name' => pht('Up'), 'symbol' => "↑", 'heavy' => "⬆", 'aliases' => array('up', 'arrow-up', 'up-arrow', 'north')), array('name' => pht('Tab'), 'symbol' => "⇥", 'aliases' => array('tab')), array('name' => pht('Right'), 'symbol' => "→", 'heavy' => "➡", 'aliases' => array('right', 'right-arrow', 'arrow-right', 'east')), array('name' => pht('Left'), 'symbol' => "←", 'heavy' => "⬅", 'aliases' => array('left', 'left-arrow', 'arrow-left', 'west')), array('name' => pht('Down'), 'symbol' => "↓", 'heavy' => "⬇", 'aliases' => array('down', 'down-arrow', 'arrow-down', 'south')), array('name' => pht('Up Right'), 'symbol' => "↗", 'heavy' => "⬈", 'aliases' => array('up-right', 'upright', 'up-right-arrow', 'upright-arrow', 'arrow-up-right', 'arrow-upright', 'northeast', 'north-east')), array('name' => pht('Down Right'), 'symbol' => "↘", 'heavy' => "⬊", 'aliases' => array('down-right', 'downright', 'down-right-arrow', 'downright-arrow', 'arrow-down-right', 'arrow-downright', 'southeast', 'south-east')), array('name' => pht('Down Left'), 'symbol' => "↙", 'heavy' => "⬋", 'aliases' => array('down-left', 'downleft', 'down-left-arrow', 'downleft-arrow', 'arrow-down-left', 'arrow-downleft', 'southwest', 'south-west')), array('name' => pht('Up Left'), 'symbol' => "↖", 'heavy' => "⬉", 'aliases' => array('up-left', 'upleft', 'up-left-arrow', 'upleft-arrow', 'arrow-up-left', 'arrow-upleft', 'northwest', 'north-west')));
$map = array();
foreach ($special as $spec) {
foreach ($spec['aliases'] as $alias) {
$map[$alias] = $spec;
}
}
$is_text = $this->getEngine()->isTextMode();
$is_html_mail = $this->getEngine()->isHTMLMailMode();
if ($is_html_mail) {
$key_style = array('display: inline-block;', 'min-width: 1em;', 'padding: 4px 5px 5px;', 'font-weight: normal;', 'font-size: 0.8rem;', 'text-align: center;', 'text-decoration: none;', 'line-height: 0.6rem;', 'border-radius: 3px;', 'box-shadow: inset 0 -1px 0 rgba(71, 87, 120, 0.08);', 'user-select: none;', 'background: #f7f7f7;', 'border: 1px solid #C7CCD9;');
$key_style = implode(' ', $key_style);
$join_style = array('padding: 0 4px;', 'color: #92969D;');
$join_style = implode(' ', $join_style);
} else {
$key_style = null;
$join_style = null;
}
$parts = array();
foreach ($keys as $k => $v) {
$normal = phutil_utf8_strtolower($v);
if (isset($map[$normal])) {
$spec = $map[$normal];
} else {
$spec = array('name' => null, 'symbol' => $v);
}
if ($is_text) {
$parts[] = '[' . $spec['symbol'] . ']';
} else {
$parts[] = phutil_tag('kbd', array('title' => $spec['name'], 'style' => $key_style), $spec['symbol']);
}
}
if ($is_text) {
$parts = implode(' + ', $parts);
} else {
$glue = phutil_tag('span', array('class' => 'kbd-join', 'style' => $join_style), '+');
$parts = phutil_implode_html($glue, $parts);
}
return $this->getEngine()->storeText($parts);
}
示例12: getLintCodeFromLinterConfigurationKey
protected function getLintCodeFromLinterConfigurationKey($code)
{
switch (phutil_utf8_strtolower($code)) {
case 'parse':
return self::LINT_PARSE_ERROR;
case 'fatal':
return self::LINT_FATAL_ERROR;
default:
throw new Exception(pht('Unrecognized lint message code: "%s"', $code));
}
}
示例13: getHeaderValue
public function getHeaderValue($key, $default = null)
{
$key = phutil_utf8_strtolower($key);
foreach ($this->headers as $header) {
list($hkey, $value) = $header;
if (phutil_utf8_strtolower($hkey) === $key) {
return $value;
}
}
return $default;
}
示例14: markupText
public function markupText($text, $children)
{
$matches = array();
preg_match($this->getRegEx(), $text, $matches);
if (idx($matches, 'showword')) {
$word = $matches['showword'];
$show = true;
} else {
$word = $matches['hideword'];
$show = false;
}
$class_suffix = phutil_utf8_strtolower($word);
// This is the "(IMPORTANT)" or "NOTE:" part.
$word_part = rtrim(substr($text, 0, strlen($matches[0])));
// This is the actual text.
$text_part = substr($text, strlen($matches[0]));
$text_part = $this->applyRules(rtrim($text_part));
$text_mode = $this->getEngine()->isTextMode();
$html_mail_mode = $this->getEngine()->isHTMLMailMode();
if ($text_mode) {
return $word_part . ' ' . $text_part;
}
if ($show) {
$content = array(phutil_tag('span', array('class' => 'remarkup-note-word'), $word_part), ' ', $text_part);
} else {
$content = $text_part;
}
if ($html_mail_mode) {
if ($class_suffix == 'important') {
$attributes = array('style' => 'margin: 16px 0;
padding: 12px;
border-left: 3px solid #c0392b;
background: #f4dddb;');
} else {
if ($class_suffix == 'note') {
$attributes = array('style' => 'margin: 16px 0;
padding: 12px;
border-left: 3px solid #2980b9;
background: #daeaf3;');
} else {
if ($class_suffix == 'warning') {
$attributes = array('style' => 'margin: 16px 0;
padding: 12px;
border-left: 3px solid #f1c40f;
background: #fdf5d4;');
}
}
}
} else {
$attributes = array('class' => 'remarkup-' . $class_suffix);
}
return phutil_tag('div', $attributes, $content);
}
示例15: filterMethods
private function filterMethods(array $methods)
{
foreach ($methods as $key => $method) {
$application = $method->getApplication();
if (!$application) {
continue;
}
if (!$application->isInstalled()) {
unset($methods[$key]);
}
}
$status = array(ConduitAPIMethod::METHOD_STATUS_STABLE => $this->isStable, ConduitAPIMethod::METHOD_STATUS_DEPRECATED => $this->isDeprecated, ConduitAPIMethod::METHOD_STATUS_UNSTABLE => $this->isUnstable);
// Only apply status filters if any of them are set.
if (array_filter($status)) {
foreach ($methods as $key => $method) {
$keep = idx($status, $method->getMethodStatus());
if (!$keep) {
unset($methods[$key]);
}
}
}
if ($this->applicationNames) {
$map = array_fuse($this->applicationNames);
foreach ($methods as $key => $method) {
$needle = $method->getApplicationName();
$needle = phutil_utf8_strtolower($needle);
if (empty($map[$needle])) {
unset($methods[$key]);
}
}
}
if ($this->nameContains) {
$needle = phutil_utf8_strtolower($this->nameContains);
foreach ($methods as $key => $method) {
$haystack = $method->getAPIMethodName();
$haystack = phutil_utf8_strtolower($haystack);
if (strpos($haystack, $needle) === false) {
unset($methods[$key]);
}
}
}
if ($this->methods) {
$map = array_fuse($this->methods);
foreach ($methods as $key => $method) {
$needle = $method->getAPIMethodName();
if (empty($map[$needle])) {
unset($methods[$key]);
}
}
}
return $methods;
}