当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils::cleanString方法代码示例

本文整理汇总了PHP中Utils::cleanString方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::cleanString方法的具体用法?PHP Utils::cleanString怎么用?PHP Utils::cleanString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils的用法示例。


在下文中一共展示了Utils::cleanString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

// Closure to get extra parameters set
$get_option = function ($option) use($request) {
    $value = 0;
    if (isset($request->extra_parameters[$option]) && (int) $request->extra_parameters[$option] != 0) {
        $value = (int) $request->extra_parameters[$option];
    }
    return $value;
};
$repositories = $request->parameters[2] == 'global' ? Project::getLocaleRepositories($request->parameters[4]) : [$request->parameters[2]];
// This is the filtered data we will send to getTranslationMemoryResults()
$output = [];
// The search
$initial_search = Utils::cleanString($request->parameters[5]);
$terms = Utils::uniqueWords($initial_search);
// Define our regex
$search = (new Search())->setSearchTerms(Utils::cleanString($initial_search))->setRegexWholeWords($get_option('whole_word'))->setRegexCaseInsensitive($get_option('case_sensitive'))->setRegexPerfectMatch($get_option('perfect_match'));
// We loop through all repositories and merge the results
foreach ($repositories as $repository) {
    $source_strings = Utils::getRepoStrings($request->parameters[3], $repository);
    foreach ($terms as $word) {
        $search->setRegexSearchTerms($word);
        $source_strings = preg_grep($search->getRegex(), $source_strings);
    }
    /*
        If we don't have any match for a repo, no need to do heavy calculations,
        just skip to the next repo.
    */
    if (empty($source_strings)) {
        continue;
    }
    /*
开发者ID:hellosct1,项目名称:transvision,代码行数:31,代码来源:translation_memory.php

示例2: isset

<?php

namespace Transvision;

// get all strings
$source_strings = Utils::getRepoStrings($request->parameters[3], $request->parameters[2]);
$target_strings = Utils::getRepoStrings($request->parameters[4], $request->parameters[2]);
// The search
$initial_search = Utils::cleanString($request->parameters[5]);
$terms = Utils::uniqueWords($initial_search);
// Regex options (not currenty used)
$delimiter = '~';
$whole_word = isset($check['whole_word']) ? '\\b' : '';
$case_sensitive = isset($check['case_sensitive']) ? '' : 'i';
$regex = $delimiter . $whole_word . $initial_search . $whole_word . $delimiter . $case_sensitive . 'u';
// Closure to get extra parameters set
$get_option = function ($option) use($request) {
    $value = 0;
    if (isset($request->extra_parameters[$option]) && (int) $request->extra_parameters[$option] != 0) {
        $value = (int) $request->extra_parameters[$option];
    }
    return $value;
};
foreach ($terms as $word) {
    $regex = $delimiter . $whole_word . preg_quote($word, $delimiter) . $whole_word . $delimiter . $case_sensitive . 'u';
    $source_strings = preg_grep($regex, $source_strings);
}
return $json = ShowResults::getTranslationMemoryResults(array_keys($source_strings), [$source_strings, $target_strings], $initial_search, $get_option('max_results'), $get_option('min_quality'));
开发者ID:rohankhakurel,项目名称:transvision,代码行数:28,代码来源:translation_memory.php

示例3: function

<?php

namespace Transvision;

// Closure to use extra parameters
$get_option = function ($option) use($request) {
    if (isset($request->extra_parameters[$option])) {
        return $request->extra_parameters[$option];
    }
    return false;
};
// Get all strings
$initial_search = urldecode(Utils::cleanString($request->parameters[6]));
$source_strings = Utils::getRepoStrings($request->parameters[4], $request->parameters[3]);
// Regex options
$whole_word = $get_option('whole_word') ? '\\b' : '';
$case_sensitive = $get_option('case_sensitive') ? '' : 'i';
if ($get_option('perfect_match')) {
    $regex = '~' . $whole_word . trim('^' . preg_quote($initial_search, '~') . '$') . $whole_word . '~' . $case_sensitive . 'u';
    if ($request->parameters[2] == 'entities') {
        $entities = ShowResults::searchEntities($source_strings, $regex);
        $source_strings = array_intersect_key($source_strings, array_flip($entities));
    } else {
        $source_strings = preg_grep($regex, $source_strings);
        $entities = array_keys($source_strings);
    }
} else {
    foreach (Utils::uniqueWords($initial_search) as $word) {
        $regex = '~' . $whole_word . preg_quote($word, '~') . $whole_word . '~' . $case_sensitive . 'u';
        if ($request->parameters[2] == 'entities') {
            $entities = ShowResults::searchEntities($source_strings, $regex);
开发者ID:rohankhakurel,项目名称:transvision,代码行数:31,代码来源:repository_search.php

示例4: foreach

     continue;
 }
 foreach ($quarters as $quarter_id => $quarter_name) {
     if (strpos($value, $quarter_name) !== false) {
         if (empty($files[$quarter_id])) {
             $files[$quarter_id] = array();
         }
         $find_type = false;
         foreach ($types as $type_name => $type_id) {
             if (strpos($value, $type_name) !== false) {
                 $find_type = true;
                 if (empty($files[$quarter_id][$type_id])) {
                     $files[$quarter_id][$type_id] = array();
                 }
                 $sub_folder = trim(str_replace($folder . '/' . $quarter_name . '/' . $type_name, '', $value), '/');
                 $sub_folder = ucwords(Utils::cleanString(dirname($sub_folder), ' '));
                 if (empty($sub_folder)) {
                     $files[$quarter_id][$type_id][0][] = $value;
                     continue;
                 }
                 $info = Db::selectOne('SELECT id, name FROM info WHERE name LIKE :name', array('name' => '%' . $sub_folder . '%'));
                 if (!empty($info)) {
                     //echo $sub_folder.' => '.print_r($info['id'], true).'<br>';
                     if (empty($files[$quarter_id][$type_id][$info['id']])) {
                         $files[$quarter_id][$type_id][$info['id']] = array();
                     }
                     $files[$quarter_id][$type_id][$info['id']][] = $value;
                 } else {
                     $errors[] = $sub_folder;
                 }
             }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:31,代码来源:moulinette.php

示例5: getSlug

 public function getSlug()
 {
     return $this->id . '-' . strtolower(Utils::cleanString($this->name));
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:4,代码来源:Info.class.php

示例6: isset

<?php

namespace Transvision;

// Default search value
$_GET['recherche'] = isset($_GET['recherche']) ? $_GET['recherche'] : '';
$my_search = Utils::cleanString($_GET['recherche']);
// Cloned value for reference
$initial_search = $my_search;
$initial_search_decoded = htmlentities($initial_search);
// Checkboxes states
$check = [];
foreach ($form_checkboxes as $val) {
    $check[$val] = isset($_GET[$val]) ? true : false;
}
// Check for default_repository cookie, if not set default repo to 'central'
if (isset($_COOKIE['default_repository'])) {
    $check['repo'] = $_COOKIE['default_repository'];
} else {
    $check['repo'] = 'aurora';
}
if (isset($_GET['repo']) && in_array($_GET['repo'], $repos)) {
    $check['repo'] = $_GET['repo'];
}
// Default search type: strings
$check['search_type'] = 'strings';
if (isset($_GET['search_type']) && in_array($_GET['search_type'], ['strings', 'entities', 'strings_entities'])) {
    $check['search_type'] = $_GET['search_type'];
} elseif (isset($_COOKIE['default_search_type'])) {
    $check['search_type'] = $_COOKIE['default_search_type'];
}
开发者ID:rohankhakurel,项目名称:transvision,代码行数:31,代码来源:search_options.php

示例7: getSlug

 public function getSlug()
 {
     return $this->id . '-' . strtolower(Utils::cleanString(Info::getTypeLabel($this->type)));
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:4,代码来源:Elements.class.php

示例8: elseif

    $check['repo'] = 'aurora';
}
if (isset($_GET['repo']) && in_array($_GET['repo'], $repos)) {
    $check['repo'] = $_GET['repo'];
}
// Default search type: strings
$check['search_type'] = 'strings';
if (isset($_GET['search_type']) && in_array($_GET['search_type'], ['strings', 'entities', 'strings_entities'])) {
    $check['search_type'] = $_GET['search_type'];
} elseif (isset($_COOKIE['default_search_type'])) {
    $check['search_type'] = $_COOKIE['default_search_type'];
}
// Locales list for the select boxes
$loc_list = Project::getRepositoryLocales($check['repo']);
// Define our regex
$search = (new Search())->setSearchTerms(Utils::cleanString($_GET['recherche']))->setRegexWholeWords($check['whole_word'])->setRegexCaseInsensitive($check['case_sensitive'])->setRegexPerfectMatch($check['perfect_match']);
// Build the repository switcher
$repo_list = Utils::getHtmlSelectOptions($repos_nice_names, $check['repo'], true);
// Get the locale list for every repo and build his target/source locale switcher values.
$loc_list = [];
$source_locales_list = [];
$target_locales_list = [];
$repositories = Project::getRepositories();
foreach ($repositories as $repository) {
    $loc_list[$repository] = Project::getRepositoryLocales($repository);
    // Build the source locale switcher
    $source_locales_list[$repository] = Utils::getHtmlSelectOptions($loc_list[$repository], Project::getLocaleInContext($source_locale, $repository));
    // Build the target locale switcher
    $target_locales_list[$repository] = Utils::getHtmlSelectOptions($loc_list[$repository], Project::getLocaleInContext($locale, $repository));
    // 3locales view: build the target locale switcher for a second locale
    $target_locales_list2[$repository] = Utils::getHtmlSelectOptions($loc_list[$repository], Project::getLocaleInContext($locale2, $repository));
开发者ID:benoit-l,项目名称:transvision,代码行数:31,代码来源:search_options.php

示例9: getLink

 public function getLink()
 {
     return 'recipe/' . $this->getId() . '-' . Utils::cleanString($this->getTitle());
 }
开发者ID:vincenthib,项目名称:cooking,代码行数:4,代码来源:Recipe.class.php

示例10: dirname

<?php

require_once '../../lib/Utils.php';
$__ROOT__ = dirname(__FILE__) . "/../..";
if (isset($_POST["k"])) {
    if (Utils::apiKeyExist($_POST["k"])) {
        $filename = Utils::cleanString(basename($_FILES["img"]["name"]));
        $outpath = $__ROOT__ . "/img/" . $_POST["k"] . "/";
        if (!file_exists($outpath . $filename)) {
            if (filesize($_FILES["img"]["tmp_name"]) < __MAX_SIZE__) {
                if (move_uploaded_file($_FILES["img"]["tmp_name"], $outpath . $filename)) {
                    echo Utils::createThumbnail($outpath, $filename);
                    echo Utils::createShortLink("img/" . $_POST["k"] . "/" . $filename, $_POST['k']);
                } else {
                    echo "-1\n";
                }
            } else {
                echo "-4\n";
            }
        } else {
            echo "-2\n";
        }
    } else {
        echo "-5\n";
    }
} else {
    echo "-3\n";
}
开发者ID:Konosprod,项目名称:ciconia,代码行数:28,代码来源:index.php

示例11: count

     $done_files .= "  <a href='#{$current_filename}' class='file_done{$status}'>{$current_filename}</a>\n";
 } else {
     $todo_files .= "  <div class='file_container' id='{$current_filename}'>\n" . "    <h3 class='filename'><a href='#{$current_filename}'>{$current_filename}</a></h3>\n" . "    <table class='sidetable'>\n" . "      <thead>\n" . "        <tr>\n" . "          <th>Identical</th>\n" . "          <th>Trans.</th>\n" . "          <th>Missing</th>\n" . "          <th>Errors</th>\n" . "        </tr>\n" . "      </thead>\n" . "      <tbody>\n" . "        <tr>\n" . "          <td>{$count_identical}</td>" . "          <td>" . count($locale_analysis['Translated']) . "</td>" . "          <td>{$count_missing}</td>" . "          <td>{$count_errors}</td>" . "        </tr>\n" . "        <tr>\n" . "          <td colspan='4'>\n" . "            <a href='{$reference_url}'>Original English source file</a>\n" . "          </td>\n" . "        </tr>\n" . "        <tr>\n" . "          <td colspan='4'>\n" . "            <a href='{$locale_url}'>Your translated file</a>\n" . "          </td>\n" . "        </tr>\n" . "        <tr>\n" . "          <td colspan='4'>\n" . "            <a href='{$bugzilla_link}'>Attach your updated file to Bugzilla</a>\n" . "          </td>\n" . "        </tr>\n" . "      </tbody>\n" . "    </table>\n";
     if ($count_identical > 0) {
         $todo_files .= "\n    <h3>Strings identical to English:</h3>\n";
         $todo_files .= "    <ul>\n";
         foreach ($locale_analysis['Identical'] as $identical_string) {
             $todo_files .= "      <li>" . htmlspecialchars(Utils::cleanString($identical_string)) . "</li>\n";
         }
         $todo_files .= "    </ul>\n";
     }
     if ($count_missing > 0) {
         $todo_files .= "\n    <h3>Missing strings:</h3>\n";
         $todo_files .= "    <ul>\n";
         foreach ($locale_analysis['Missing'] as $missing_string) {
             $todo_files .= "      <li>" . htmlspecialchars(Utils::cleanString($missing_string)) . "</li>\n";
         }
         $todo_files .= "    </ul>\n";
     }
     if (LangManager::countErrors($locale_analysis['errors'])) {
         if (LangManager::countErrors($locale_analysis['errors'], 'python')) {
             $todo_files .= "\n    <h3>Errors in variables in the sentence:</h3>\n";
             $todo_files .= "    <ul>\n";
             foreach ($locale_analysis['errors']['python'] as $stringid => $python_error) {
                 $todo_files .= "              <table class='python'>\n                        <tr>\n                          <th>Check the following variables: <strong style='color:red'>{$python_error['var']}</strong></th>\n                        </tr>\n                        <tr>\n                          <td>" . Utils::highlightPythonVar($stringid) . "</td>\n                        </tr>\n                        <tr>\n                          <td>" . Utils::highlightPythonVar($python_error['text']) . "</td>\n                        </tr>\n                      </table>\n";
             }
             $todo_files .= "    </ul>\n";
         }
         if (LangManager::countErrors($locale_analysis['errors'], 'length')) {
             $todo_files .= "\n    <h3>Some strings are longer than allowed:</h3>\n";
             $todo_files .= "    <ul>\n";
开发者ID:Jobava,项目名称:mirror-langchecker,代码行数:31,代码来源:listsitesforlocale.inc.php

示例12: urlencode

        if (isset($_GET[$value])) {
            // 'strings_entities' search is now called 'all' in new API
            return $_GET[$value] == 'strings_entities' ? 'all' : Utils::secureText($_GET[$value]);
        }
        return $fallback;
    };
    $repo = $get_value('repo', 'release');
    $type = $get_value('search_type', 'strings');
    $source = $get_value('sourcelocale', Project::getReferenceLocale($repo));
    $target = $get_value('locale', 'fr');
    /*
       We need to urlencode() twice because Apache doesn't allow urls with
       escaped slashes, it gives a 404 instead of going through mod_rewrite
       see: http://www.leakon.com/archives/865
    */
    $terms = urlencode(urlencode(Utils::cleanString($_GET['recherche'])));
    $regex = [];
    $regex['whole'] = isset($_GET['whole_word']) ? 'whole_word=1' : '';
    $regex['case'] = isset($_GET['case_sensitive']) ? 'case_sensitive=1' : '';
    $regex['perfect'] = isset($_GET['perfect_match']) ? 'perfect_match=1' : '';
    $regex = array_filter($regex);
    $regex = count($regex) > 0 ? '?' . implode('&', $regex) : '';
    header('Status: 301 Moved Permanently', false, 301);
    header('Location:' . APP_SCHEME . "{$_SERVER['HTTP_HOST']}/api/v1/search/" . "{$type}/{$repo}/{$source}/{$target}/{$terms}/{$regex}");
    exit;
}
// Bootstrap l10n
require_once INC . 'l10n-init.php';
// Include Search Options
require_once INC . 'search_options.php';
// Prepare extra data for the 3 locales view
开发者ID:lester-shu,项目名称:transvision,代码行数:31,代码来源:mainsearch.php


注:本文中的Utils::cleanString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。