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


PHP StringUtil::trim方法代码示例

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


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

示例1: readFormParameters

	/**
	 * @see	wcf\form\IForm::readFormParameters()
	 */
	public function readFormParameters() {
		parent::readFormParameters();
		
		if (isset($_POST['serverURL'])) $this->serverURL = StringUtil::trim($_POST['serverURL']);
		if (isset($_POST['loginUsername'])) $this->loginUsername = $_POST['loginUsername'];
		if (isset($_POST['loginPassword'])) $this->loginPassword = $_POST['loginPassword'];
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:10,代码来源:PackageUpdateServerAddForm.class.php

示例2: readFormParameters

 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['server'])) {
         $this->server = StringUtil::trim($_POST['server']);
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:10,代码来源:LanguageServerAddForm.class.php

示例3: checkAccessToken

	/**
	 * Validates the access-token and performs the login.
	 */
	protected function checkAccessToken() {
		if (isset($_REQUEST['at'])) {
			list($userID, $token) = explode('-', StringUtil::trim($_REQUEST['at']));
			
			if (WCF::getUser()->userID) {
				if ($userID == WCF::getUser()->userID && PasswordUtil::secureCompare(WCF::getUser()->accessToken, $token)) {
					// everything is fine, but we are already logged in
					return;
				}
				else {
					// token is invalid
					throw new IllegalLinkException();
				}
			}
			else {
				$user = new User($userID);
				if (PasswordUtil::secureCompare($user->accessToken, $token)) {
					// token is valid -> change user
					SessionHandler::getInstance()->changeUser($user, true);
				}
				else {
					// token is invalid
					throw new IllegalLinkException();
				}
			}
		}
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:30,代码来源:AbstractAuthedPage.class.php

示例4: readParameters

 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['search'])) {
         $this->search = StringUtil::trim($_REQUEST['search']);
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:10,代码来源:TagListPage.class.php

示例5: parseKeywords

 /**
  * Parses search keywords.
  * 
  * @param	string		$keywordString
  */
 protected function parseKeywords($keywordString)
 {
     // convert encoding if necessary
     if (!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 (mb_substr($keywordString, 0, 1) == '"' && mb_substr($keywordString, -1) == '"') {
         // phrases search
         $keywordString = StringUtil::trim(mb_substr($keywordString, 1, -1));
         if (!empty($keywordString)) {
             $this->keywords = array_merge($this->keywords, array(StringUtil::encodeHTML($keywordString)));
         }
     } else {
         // replace word delimiters by space
         $keywordString = str_replace(array('.', ','), ' ', $keywordString);
         $keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
         if (!empty($keywords)) {
             $this->keywords = array_merge($this->keywords, $keywords);
         }
     }
 }
开发者ID:jacboy,项目名称:WCF,代码行数:30,代码来源:KeywordHighlighter.class.php

示例6: readFormParameters

 /**
  * @see wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['className'])) {
         $this->className = StringUtil::trim($_POST['className']);
     }
     if (isset($_POST['description'])) {
         $this->description = StringUtil::trim($_POST['description']);
     }
     if (isset($_POST['startMinute'])) {
         $this->startMinute = StringUtil::replace(' ', '', $_POST['startMinute']);
     }
     if (isset($_POST['startHour'])) {
         $this->startHour = StringUtil::replace(' ', '', $_POST['startHour']);
     }
     if (isset($_POST['startDom'])) {
         $this->startDom = StringUtil::replace(' ', '', $_POST['startDom']);
     }
     if (isset($_POST['startMonth'])) {
         $this->startMonth = StringUtil::replace(' ', '', $_POST['startMonth']);
     }
     if (isset($_POST['startDow'])) {
         $this->startDow = StringUtil::replace(' ', '', $_POST['startDow']);
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:28,代码来源:CronjobAddForm.class.php

示例7: getCondition

	/**
	 * @see	wcf\system\option\ISearchableUserOption::getCondition()
	 */
	public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
		$value = StringUtil::trim($value);
		if (!$value) return false;
		
		$conditions->add("option_value.userOption".$option->optionID." = ?", array($value));
		return true;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:10,代码来源:RadioButtonOptionType.class.php

示例8: setValue

 /**
  * Sets element value.
  * 
  * @param	string		$value
  */
 public function setValue($value)
 {
     if (!is_string($value)) {
         die(print_r($value, true));
     }
     $this->value = StringUtil::trim($value);
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:12,代码来源:AbstractNamedFormElement.class.php

示例9: readFormParameters

 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['title'])) {
         $this->title = StringUtil::trim($_POST['title']);
     }
 }
开发者ID:joshuaruesweg,项目名称:de.voolia.news,代码行数:10,代码来源:NewsPictureAddForm.class.php

示例10: getCondition

	/**
	 * @see	wcf\system\option\ISearchableUserOption::getCondition()
	 */
	public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
		$value = StringUtil::trim($value);
		if (empty($value)) return false;
		
		$conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%'));
		return true;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:10,代码来源:TextOptionType.class.php

示例11: readParameters

 /**
  * @see	\wcf\action\IAction::readParameters()
  */
 public function readParameters()
 {
     if (!MODULE_POLL) {
         throw new IllegalLinkException();
     }
     AbstractSecureAction::readParameters();
     if (isset($_POST['actionName'])) {
         $this->actionName = StringUtil::trim($_POST['actionName']);
     }
     if (isset($_POST['pollID'])) {
         $this->pollID = intval($_POST['pollID']);
     }
     $polls = PollManager::getInstance()->getPolls(array($this->pollID));
     if (!isset($polls[$this->pollID])) {
         throw new UserInputException('pollID');
     }
     $this->poll = $polls[$this->pollID];
     // load related object
     $this->relatedObject = PollManager::getInstance()->getRelatedObject($this->poll);
     if ($this->relatedObject === null) {
         if ($this->poll->objectID) {
             throw new SystemException("Missing related object for poll id '" . $this->poll->pollID . "'");
         }
     } else {
         $this->poll->setRelatedObject($this->relatedObject);
     }
     // validate action
     switch ($this->actionName) {
         case 'getResult':
             if (!$this->poll->canSeeResult()) {
                 throw new PermissionDeniedException();
             }
             break;
         case 'getVote':
         case 'vote':
             if (!$this->poll->canVote()) {
                 throw new PermissionDeniedException();
             }
             break;
         default:
             throw new SystemException("Unknown action '" . $this->actionName . "'");
             break;
     }
     if (isset($_POST['optionIDs']) && is_array($_POST['optionIDs'])) {
         $this->optionIDs = ArrayUtil::toIntegerArray($_POST['optionIDs']);
         if (count($this->optionIDs) > $this->poll->maxVotes) {
             throw new PermissionDeniedException();
         }
         $optionIDs = array();
         foreach ($this->poll->getOptions() as $option) {
             $optionIDs[] = $option->optionID;
         }
         foreach ($this->optionIDs as $optionID) {
             if (!in_array($optionID, $optionIDs)) {
                 throw new PermissionDeniedException();
             }
         }
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:62,代码来源:PollAction.class.php

示例12: prepareImport

 /**
  * @see	\wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
  */
 protected function prepareImport(array $data)
 {
     $data = array('bbcodeTag' => mb_strtolower(StringUtil::trim($data['attributes']['name'])), 'htmlOpen' => !empty($data['elements']['htmlopen']) ? $data['elements']['htmlopen'] : '', 'htmlClose' => !empty($data['elements']['htmlclose']) ? $data['elements']['htmlclose'] : '', 'allowedChildren' => !empty($data['elements']['allowedchildren']) ? $data['elements']['allowedchildren'] : 'all', 'wysiwygIcon' => !empty($data['elements']['wysiwygicon']) ? $data['elements']['wysiwygicon'] : '', 'attributes' => isset($data['elements']['attributes']) ? $data['elements']['attributes'] : array(), 'className' => !empty($data['elements']['classname']) ? $data['elements']['classname'] : '', 'isSourceCode' => !empty($data['elements']['sourcecode']) ? 1 : 0, 'buttonLabel' => isset($data['elements']['buttonlabel']) ? $data['elements']['buttonlabel'] : '', 'originIsSystem' => 1);
     if ($data['wysiwygIcon'] && $data['buttonLabel']) {
         $data['showButton'] = 1;
     }
     return $data;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:11,代码来源:BBCodePackageInstallationPlugin.class.php

示例13: readFormParameters

 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     // call readFormParameters event
     EventHandler::getInstance()->fireAction($this, 'readFormParameters');
     if (isset($_POST['activeTabMenuItem'])) {
         $this->activeTabMenuItem = StringUtil::trim($_POST['activeTabMenuItem']);
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:11,代码来源:AbstractForm.class.php

示例14: readParameters

	/**
	 * @see	wcf\action\Action::readParameters()
	 */
	public function readParameters() {
		AbstractSecureAction::readParameters();
		
		if (isset($_POST['action'])) $this->action = StringUtil::trim($_POST['action']);
		if (isset($_POST['containerData']) && is_array($_POST['containerData'])) $this->containerData = $_POST['containerData'];
		if (isset($_POST['objectIDs']) && is_array($_POST['objectIDs'])) $this->objectIDs = ArrayUtil::toIntegerArray($_POST['objectIDs']);
		if (isset($_POST['pageClassName'])) $this->pageClassName = StringUtil::trim($_POST['pageClassName']);
		if (isset($_POST['type'])) $this->type = StringUtil::trim($_POST['type']);
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:12,代码来源:ClipboardAction.class.php

示例15: __construct

	/**
	 * Creates a new instance of memcached.
	 */
	public function __construct() {
		if (!class_exists('Memcached')) {
			throw new SystemException('memcached support is not enabled.');
		}
		
		// init memcached
		$this->memcached = new \Memcached();
		
		// add servers
		$tmp = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHED_HOST));
		$servers = array();
		$defaultWeight = floor(100 / count($tmp));
		$regex = new Regex('^\[([a-z0-9\:\.]+)\](?::([0-9]{1,5}))?(?::([0-9]{1,3}))?$', Regex::CASE_INSENSITIVE);
		
		foreach ($tmp as $server) {
			$server = StringUtil::trim($server);
			if (!empty($server)) {
				$host = $server;
				$port = 11211; // default memcached port
				$weight = $defaultWeight;
				
				// check for IPv6
				if ($regex->match($host)) {
					$matches = $regex->getMatches();
					$host = $matches[1];
					if (isset($matches[2])) {
						$port = $matches[2];
					}
					if (isset($matches[3])) {
						$weight = $matches[3];
					}
				}
				else {
					// IPv4, try to get port and weight
					if (strpos($host, ':')) {
						$parsedHost = explode(':', $host);
						$host = $parsedHost[0];
						$port = $parsedHost[1];
						
						if (isset($parsedHost[2])) {
							$weight = $parsedHost[2];
						}
					}
				}
				
				$servers[] = array($host, $port, $weight);
			}
		}
		
		$this->memcached->addServers($servers);
		
		// test connection
		$this->memcached->get('testing');
		
		// set variable prefix to prevent collision
		$this->prefix = substr(sha1(WCF_DIR), 0, 8) . '_';
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:60,代码来源:MemcachedCacheSource.class.php


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