本文整理汇总了PHP中StringUtil::trim方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::trim方法的具体用法?PHP StringUtil::trim怎么用?PHP StringUtil::trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::trim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearchQuery
/**
* Gets the search query keywords.
*/
protected static function getSearchQuery()
{
self::$searchQuery = false;
if (isset($_GET['highlight'])) {
$keywordString = $_GET['highlight'];
// remove search operators
$keywordString = preg_replace('/[\\+\\-><()~\\*]+/', '', $keywordString);
if (StringUtil::substring($keywordString, 0, 1) == '"' && StringUtil::substring($keywordString, -1) == '"') {
// phrases search
$keywordString = StringUtil::trim(StringUtil::substring($keywordString, 1, -1));
if (!empty($keywordString)) {
self::$searchQuery = $keywordString;
}
} else {
self::$searchQuery = ArrayUtil::trim(explode(' ', $keywordString));
if (count(self::$searchQuery) == 0) {
self::$searchQuery = false;
} else {
if (count(self::$searchQuery) == 1) {
self::$searchQuery = reset(self::$searchQuery);
}
}
}
}
}
示例2: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['path'])) {
$this->path = StringUtil::trim($_POST['path']);
}
}
示例3: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['title'])) {
$this->title = StringUtil::trim($_POST['title']);
}
if (isset($_POST['points'])) {
$this->points = abs(intval($_POST['points']));
}
if (isset($_POST['expiresWeek'])) {
$this->expiresWeek = intval($_POST['expiresWeek']);
}
if (isset($_POST['expiresDay'])) {
$this->expiresDay = intval($_POST['expiresDay']);
}
if (isset($_POST['expiresHour'])) {
$this->expiresHour = intval($_POST['expiresHour']);
}
if (isset($_POST['suspensionType'])) {
$this->suspensionType = $_POST['suspensionType'];
}
if (isset($_POST['send'])) {
$this->send = (bool) $_POST['send'];
}
// get type object
if ($this->suspensionType && isset($this->availableSuspensionTypes[$this->suspensionType])) {
$this->suspensionTypeObject = $this->availableSuspensionTypes[$this->suspensionType];
}
if ($this->suspensionTypeObject !== null && $this->send) {
$this->suspensionTypeObject->readFormParameters();
}
}
示例4: parseKeywords
/**
* Parses search keywords.
*
* @param string $keywordString
*/
protected static function parseKeywords($keywordString)
{
// convert encoding if necessary
if (CHARSET == 'UTF-8' && !StringUtil::isASCII($keywordString) && !StringUtil::isUTF8($keywordString)) {
$keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
}
// remove bad wildcards
$keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString);
// remove search operators
$keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString);
if (StringUtil::substring($keywordString, 0, 1) == '"' && StringUtil::substring($keywordString, -1) == '"') {
// phrases search
$keywordString = StringUtil::trim(StringUtil::substring($keywordString, 1, -1));
if (!empty($keywordString)) {
self::$keywords = array_merge(self::$keywords, array(StringUtil::encodeHTML($keywordString)));
}
} else {
// replace word delimiters by space
$keywordString = preg_replace('/[.,]/', ' ', $keywordString);
$keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
if (count($keywords) > 0) {
self::$keywords = array_merge(self::$keywords, $keywords);
}
}
}
示例5: readParameters
/**
* @see Page::readParameters()
*/
public function readParameters()
{
parent::readParameters();
if (isset($_REQUEST['type'])) {
$this->type = StringUtil::trim($_REQUEST['type']);
}
if (isset($_REQUEST['name'])) {
$this->name = StringUtil::trim($_REQUEST['name']);
}
if (isset($_REQUEST['startInput']) && !empty($_REQUEST['startInput'])) {
$this->start = LWUtil::checkInt($_REQUEST['startInput'], 1);
if ($this->start >= 1 && $this->start <= 99) {
// e.g. 5 => 501; 14 => 1401
$this->start *= 100;
$this->start++;
}
} else {
if (isset($_REQUEST['start'])) {
$this->start = LWUtil::checkInt($_REQUEST['start'], 0);
} else {
if (isset($_REQUEST['relationalID'])) {
$this->relationalID = LWUtil::checkInt($_REQUEST['relationalID']);
}
}
}
if (isset($_REQUEST['rowCount'])) {
$this->rowCount = LWUtil::checkInt($_REQUEST['rowCount'], 10, 500);
}
}
示例6: readParameters
/**
* @see Page::readParameters()
*/
public function readParameters()
{
parent::readParameters();
if (isset($_REQUEST['q'])) {
$this->input = StringUtil::trim($_REQUEST['q']);
}
}
示例7: readParameters
/**
* @see Action::readParameters()
*/
public function readParameters()
{
parent::readParameters();
if (isset($_REQUEST['production'])) {
$this->production = StringUtil::trim($_REQUEST['production']);
}
}
示例8: readData
/**
* @see Page::readData
*/
public function readData()
{
parent::readData();
//echo ".";
$this->fleetQueue = new FleetQueue(0);
$this->readTarget();
$this->specs = Spec::getBySpecType(3);
$this->fleets = Fleet::getByUserID(WCF::getUser()->userID);
foreach ($this->fleets as $fleetID => $fleet) {
$this->fleets[$fleetID]->navalFormation = NavalFormation::getByFleetID($fleetID);
}
// backlink
if (isset($_REQUEST['backlink'])) {
$this->backlink = StringUtil::trim($_REQUEST['backlink']);
}
$array = array();
preg_match('/^(https?:\\/\\/[^\\/]*\\/)?(.*)$/i', $this->backlink, $array);
$this->fleetQueue->backlink = $this->backlink = isset($array[2]) ? $array[2] : '';
//echo ".";
// TODO: clean this one up
$sql = "DELETE FROM ugml_galactic_jump_queue\n\t\t\t\tWHERE userID = " . WCF::getUser()->userID;
WCF::getDB()->registerShutdownUpdate($sql);
$sql = "INSERT INTO ugml_galactic_jump_queue (userID, startPlanetID, state, time)\n\t\t\t\tVALUES(" . WCF::getUser()->userID . ", " . LWCore::getPlanet()->planetID . ", 1, " . TIME_NOW . ")";
WCF::getDB()->registerShutdownUpdate($sql);
}
示例9: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
$this->languageID = $this->useRegex = $this->caseSensitive = $this->replace = $this->searchVariableName = 0;
if (isset($_POST['languageID'])) {
$this->languageID = intval($_POST['languageID']);
}
if (isset($_POST['useRegex'])) {
$this->useRegex = intval($_POST['useRegex']);
}
if (isset($_POST['caseSensitive'])) {
$this->caseSensitive = intval($_POST['caseSensitive']);
}
if (isset($_POST['replace'])) {
$this->replace = intval($_POST['replace']);
}
if (isset($_POST['searchVariableName'])) {
$this->searchVariableName = intval($_POST['searchVariableName']);
}
if (isset($_POST['replaceBy'])) {
$this->replaceBy = $_POST['replaceBy'];
}
if (isset($_POST['query'])) {
$this->query = StringUtil::trim($_POST['query']);
}
}
示例10: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
// data
if (isset($_POST['name'])) {
$this->name = StringUtil::trim($_POST['name']);
}
if (isset($_POST['link'])) {
$this->link = StringUtil::trim($_POST['link']);
}
if (isset($_POST['iconS'])) {
$this->iconS = StringUtil::trim($_POST['iconS']);
}
if (isset($_POST['iconM'])) {
$this->iconM = StringUtil::trim($_POST['iconM']);
}
if (isset($_POST['position'])) {
$this->position = StringUtil::trim($_POST['position']);
}
if ($this->position != 'header' && $this->position != 'footer') {
$this->position = "header";
}
if (isset($_POST['showOrder'])) {
$this->showOrder = intval($_POST['showOrder']);
}
}
示例11: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['applicationText'])) {
$this->applicationText = StringUtil::trim($_POST['applicationText']);
}
}
示例12: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['username'])) {
$this->username = StringUtil::trim($_POST['username']);
}
if (isset($_POST['email'])) {
$this->email = StringUtil::trim($_POST['email']);
}
if (isset($_POST['confirmEmail'])) {
$this->confirmEmail = StringUtil::trim($_POST['confirmEmail']);
}
if (isset($_POST['password'])) {
$this->password = $_POST['password'];
}
if (isset($_POST['confirmPassword'])) {
$this->confirmPassword = $_POST['confirmPassword'];
}
if (isset($_POST['groupIDs']) && is_array($_POST['groupIDs'])) {
$this->groupIDs = ArrayUtil::toIntegerArray($_POST['groupIDs']);
}
if (isset($_POST['visibleLanguages']) && is_array($_POST['visibleLanguages'])) {
$this->visibleLanguages = ArrayUtil::toIntegerArray($_POST['visibleLanguages']);
}
if (isset($_POST['languageID'])) {
$this->languageID = intval($_POST['languageID']);
}
}
示例13: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['warningID'])) {
$this->warningID = intval($_POST['warningID']);
}
if (isset($_POST['title'])) {
$this->title = StringUtil::trim($_POST['title']);
}
if (isset($_POST['points'])) {
$this->points = abs(intval($_POST['points']));
}
if (isset($_POST['reason'])) {
$this->reason = StringUtil::trim($_POST['reason']);
}
if (isset($_POST['expiresDay'])) {
$this->expiresDay = intval($_POST['expiresDay']);
}
if (isset($_POST['expiresMonth'])) {
$this->expiresMonth = intval($_POST['expiresMonth']);
}
if (isset($_POST['expiresYear'])) {
$this->expiresYear = intval($_POST['expiresYear']);
}
if (isset($_POST['expiresHour'])) {
$this->expiresHour = intval($_POST['expiresHour']);
}
if (isset($_POST['expiresMinute'])) {
$this->expiresMinute = intval($_POST['expiresMinute']);
}
}
示例14: __construct
/**
* Creates a new MemcacheAdapter object.
*/
private function __construct()
{
if (!class_exists('Memcache')) {
throw new SystemException('memcache support is not enabled.');
}
// init memcache
$this->memcache = new Memcache();
// add servers
$servers = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHE_HOST));
foreach ($servers as $server) {
$server = StringUtil::trim($server);
if (!empty($server)) {
$host = $server;
$port = 11211;
// default memcache port
// get port
if (strpos($host, ':')) {
$parsedHost = explode(':', $host);
$host = $parsedHost[0];
$port = $parsedHost[1];
}
$this->memcache->addServer($host, $port, CACHE_SOURCE_MEMCACHE_USE_PCONNECT);
}
}
// test connection
$this->memcache->get('testing');
}
示例15: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
$this->ignoreUniques = $this->plugin = $this->standalone = 0;
if (isset($_POST['packageUpdateServerIDs']) && is_array($_POST['packageUpdateServerIDs'])) {
$this->packageUpdateServerIDs = ArrayUtil::toIntegerArray($_POST['packageUpdateServerIDs']);
}
if (isset($_POST['packageName'])) {
$this->packageName = StringUtil::trim($_POST['packageName']);
}
if (isset($_POST['author'])) {
$this->author = StringUtil::trim($_POST['author']);
}
if (isset($_POST['searchDescription'])) {
$this->searchDescription = intval($_POST['searchDescription']);
}
if (isset($_POST['plugin'])) {
$this->plugin = intval($_POST['plugin']);
}
if (isset($_POST['standalone'])) {
$this->standalone = intval($_POST['standalone']);
}
if (isset($_POST['other'])) {
$this->other = intval($_POST['other']);
}
if (isset($_POST['ignoreUniques'])) {
$this->ignoreUniques = intval($_POST['ignoreUniques']);
}
}