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


PHP ArrayUtil::trim方法代码示例

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


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

示例1: 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);
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:30,代码来源:KeywordHighlighter.class.php

示例2: 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);
                 }
             }
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:28,代码来源:SearchResultTextParser.class.php

示例3: parseFlags

 public static function parseFlags($input)
 {
     $flags = array();
     $parts = ArrayUtil::trim(explode(',', $input));
     foreach ($parts as $part) {
         $flag = ArrayUtil::trim(explode('=', $part, 2));
         $flags[$flag[0]] = isset($flag[1]) ? $flag[1] : true;
     }
     return $flags;
 }
开发者ID:nachteule,项目名称:nachteule.wcf.sketchbook,代码行数:10,代码来源:SketchbookUtil.class.php

示例4: getCondition

 /**
  * @see SearchableUserOption::getCondition()
  */
 public function getCondition($optionData, $value, $matchesExactly = true)
 {
     if (!is_array($value) || !count($value)) {
         return false;
     }
     $value = ArrayUtil::trim($value);
     if (!count($value)) {
         return false;
     }
     return "option_value.userOption" . $optionData['optionID'] . " = '" . implode("\n", array_map('escapeString', $value)) . "'";
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:14,代码来源:OptionTypeMultiselect.class.php

示例5: readParameters

 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['query'])) {
         $queryString = $_REQUEST['query'];
         if (CHARSET != 'UTF-8') {
             $queryString = StringUtil::convertEncoding('UTF-8', CHARSET, $queryString);
         }
         $this->query = ArrayUtil::trim(explode(',', $queryString));
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:14,代码来源:ContestJuryObjectsPage.class.php

示例6: onRead

 /**
  * @see	SocketServerClient::onRead()
  */
 public function onRead()
 {
     $string = StringUtil::unifyNewlines($this->readBuffer);
     echo '#~->', strlen($string) > 500 ? substr($string, 0, 500) : $string;
     if (!$this->isValidString($string)) {
         return;
     }
     $lines = ArrayUtil::trim(explode("\n", $string));
     $this->handleRequest($lines);
     $this->read_buffer = '';
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:14,代码来源:WOTAPIServerClient.class.php

示例7: hasBuddy

 /**
  * Returns true, if the active user has a buddy with the given user.
  *
  * @param	int		user id
  * @return	bool
  */
 public function hasBuddy($userID)
 {
     if ($this->buddies === null) {
         if ($this->buddy) {
             $this->buddies = ArrayUtil::trim(explode(',', $this->buddy));
         } else {
             $this->buddies = array();
         }
     }
     return in_array($userID, $this->buddies);
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:17,代码来源:LWUserSession.class.php

示例8: getIconPath

	public static function getIconPath($icons) {
		if (self::$iconCache === null)
			self::$iconCache = WCF::getCache()->get('icon-'.PACKAGE_ID.'-'.StyleManager::getStyle()->styleID);
		
		$icon = '';
		
		$icons = ArrayUtil::trim(explode(',', $icons));
		foreach ($icons as $icon) {
			if (isset(self::$iconCache[$icon]))
				return self::$iconCache[$icon];
		}
		
		return RELATIVE_WCF_DIR.'icon/'.$icon;
	}
开发者ID:nachteule,项目名称:nachteule.wcf.template.plugin.icons,代码行数:14,代码来源:IconsUtil.class.php

示例9: readParameters

 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     // get object id
     if (isset($_REQUEST['objectID'])) {
         $this->objectID = intval($_REQUEST['objectID']);
     }
     // get quote(s)
     if (isset($_REQUEST['text'])) {
         $this->text = $_REQUEST['text'];
     }
     if (is_array($this->text)) {
         $this->text = ArrayUtil::unifyNewlines(ArrayUtil::trim($this->text));
         if (CHARSET != 'UTF-8') {
             $this->text = ArrayUtil::convertEncoding('UTF-8', CHARSET, $this->text);
         }
     } else {
         $this->text = StringUtil::unifyNewlines(StringUtil::trim($this->text));
         if (CHARSET != 'UTF-8') {
             $this->text = StringUtil::convertEncoding('UTF-8', CHARSET, $this->text);
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:26,代码来源:AbstractMessageQuoteAction.class.php

示例10: getPageURLs

 /**
  * Gets the page URLs.
  * 
  * @return	array
  */
 protected static function getPageURLs()
 {
     $urlString = '';
     if (defined('PAGE_URL')) {
         $urlString .= PAGE_URL;
     }
     if (defined('PAGE_URLS')) {
         $urlString .= "\n" . PAGE_URLS;
     }
     $urlString = StringUtil::unifyNewlines($urlString);
     self::$pageURLs = ArrayUtil::trim(explode("\n", $urlString));
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:17,代码来源:SimpleMessageParser.class.php

示例11: execute

 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (MODULE_MODERATED_USER_GROUP == 1) {
         if ($eventObj instanceof GroupEditForm && $eventObj->group->groupType < 4) {
             // a default group can't be a moderated group
             return;
         }
         if ($eventName == 'readFormParameters') {
             if (isset($_POST['groupDescription'])) {
                 $this->groupDescription = StringUtil::trim($_POST['groupDescription']);
             }
             if (isset($_POST['groupType'])) {
                 $this->groupType = intval($_POST['groupType']);
             }
             if (isset($_POST['groupLeaders'])) {
                 $this->groupLeaders = StringUtil::trim($_POST['groupLeaders']);
             }
         } else {
             if ($eventName == 'validate') {
                 try {
                     // group type
                     if ($this->groupType < 4 || $this->groupType > 7) {
                         throw new UserInputException('groupType');
                     }
                     // group leaders
                     // explode multiple names to an array
                     $nameArray = ArrayUtil::trim(explode(',', $this->groupLeaders));
                     $error = array();
                     // loop through names
                     foreach ($nameArray as $name) {
                         try {
                             // get user group
                             $sql = "SELECT\tgroupID, groupName\n\t\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_group\n\t\t\t\t\t\t\t\tWHERE\tgroupName = '" . escapeString($name) . "'";
                             $row = WCF::getDB()->getFirstRow($sql);
                             if (!empty($row['groupID']) && (!$eventObj instanceof GroupEditForm || $row['groupID'] != $eventObj->groupID)) {
                                 $this->leaders[] = new Group($row['groupID']);
                             } else {
                                 // get user
                                 $user = new User(null, null, $name);
                                 if (!$user->userID) {
                                     throw new UserInputException('username', 'notFound');
                                 }
                                 $this->leaders[] = $user;
                             }
                         } catch (UserInputException $e) {
                             $error[] = array('type' => $e->getType(), 'username' => $name);
                         }
                     }
                     if (count($error)) {
                         throw new UserInputException('groupLeaders', $error);
                     }
                 } catch (UserInputException $e) {
                     $eventObj->errorType[$e->getField()] = $e->getType();
                 }
             } else {
                 if ($eventName == 'save') {
                     // save
                     $eventObj->additionalFields['groupDescription'] = $this->groupDescription;
                     $eventObj->additionalFields['groupType'] = $this->groupType;
                     // reset values
                     if (!$eventObj instanceof GroupEditForm) {
                         $this->groupDescription = '';
                         $this->groupType = 4;
                     }
                 } else {
                     if ($eventName == 'saved') {
                         if ($eventObj instanceof GroupEditForm) {
                             // delete old group leaders
                             $sql = "DELETE FROM\twcf" . WCF_N . "_group_leader\n\t\t\t\t\t\tWHERE\t\tgroupID = " . $eventObj->group->groupID;
                             WCF::getDB()->sendQuery($sql);
                             // deleted old applications
                             if ($this->groupType != 6 && $this->groupType != 7) {
                                 $sql = "DELETE FROM\twcf" . WCF_N . "_group_application\n\t\t\t\t\t\t\tWHERE\t\tgroupID = " . $eventObj->group->groupID;
                                 WCF::getDB()->sendQuery($sql);
                             }
                         }
                         // save group leaders
                         $inserts = '';
                         foreach ($this->leaders as $leader) {
                             if (!empty($inserts)) {
                                 $inserts .= ',';
                             }
                             $inserts .= '(' . $eventObj->group->groupID . ', ' . ($leader instanceof User ? $leader->userID : 0) . ', ' . ($leader instanceof Group ? $leader->groupID : 0) . ')';
                         }
                         if (!empty($inserts)) {
                             $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_group_leader\n\t\t\t\t\t\t\t\t\t(groupID, leaderUserID, leaderGroupID)\n\t\t\t\t\t\tVALUES\t\t\t" . $inserts;
                             WCF::getDB()->sendQuery($sql);
                         }
                         // reset values
                         if (!$eventObj instanceof GroupEditForm) {
                             $this->groupLeaders = '';
                         }
                     } else {
                         if ($eventName == 'assignVariables') {
                             if (!count($_POST) && $eventObj instanceof GroupEditForm) {
                                 // get default values
                                 $this->groupDescription = $eventObj->group->groupDescription;
//.........这里部分代码省略.........
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:101,代码来源:GroupAddFormModeratedGroupsListener.class.php

示例12: checkSQL

 /**
  * Checks a sql string.
  * 
  * @param 	integer 	$packageID
  * @param 	string 		$action 
  */
 protected function checkSQL($packageID, $action)
 {
     // checked tables should be overwritten
     $this->checkedTables = isset($_POST['checkedTables']) ? ArrayUtil::trim($_POST['checkedTables']) : array();
     // delete comments
     $this->sqlStr = QueryParser::deleteComments($this->sqlStr);
     /* 
     Before installing,updating or alter any table, it will be checked if any statement 
     from the sql file is illegal. 
     Not the  MySQL Syntax will be checked but the woltlab package philosophy.
     No table will be installed,  altered or dropped until all statements are proved.
     */
     // get existing tables from database
     $this->existingTables = WCF::getDB()->getTableNames();
     // get logged and external tables
     $this->getTableConditions($packageID);
     // get IDs from packages which got logged tables and are in the same package environment
     $this->getMandatoryPackageIDs($packageID);
     /* 
      The following "preg_match-parts" are checking if the actual package got the rights 
      to install or update the tables which are in the sql file (i.e. install.sql).
      An exception will be thrown if illegal operations appear. 
      If overwriting is allowed (external tables) the "overwrite-template" will be shown 
      and the user can decide which tables should be overwritten or not.
     */
     // ckeck "DATABASE"-statements. don't allow any DATABASE manipulation
     $matches = array();
     if (preg_match_all("%(DROP|ALTER|CREATE)\\s+DATABASE%i", $this->sqlStr, $matches)) {
         throw new SystemException("Illegal statement '" . $matches[1] . " DATABASE ...'.", 13017);
     }
     // check other statements
     $this->checkDropTables($packageID, $action);
     $this->checkAlterTables($packageID, $action);
     $this->checkCreateTables($packageID, $action);
     $this->checkRenameTables($packageID, $action);
     $this->checkCreateIndeces($packageID, $action);
     $this->checkDropIndeces($packageID, $action);
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:44,代码来源:SqlPackageInstallationPlugin.class.php

示例13: splitString

 /**
  * Takes a string of comma separated tags and splits it into an array.
  *
  * @param	string		$tags
  * @param	string		$separators
  * @return	array
  */
 public static function splitString($tags, $separators = ',;')
 {
     return array_unique(ArrayUtil::trim(preg_split('/[' . preg_quote($separators) . ']/', $tags)));
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:11,代码来源:TaggingUtil.class.php

示例14: validateText

 /**
  * @see MessageForm::validateText()
  */
 protected function validateText()
 {
     if (empty($this->text)) {
         return;
     }
     parent::validateText();
     // check image count
     $imageCount = preg_match_all('!\\[img=.+?\\]!i', $this->text, $m) + preg_match_all('!\\[img\\].+?(\\[/img\\]|$)!is', $this->text, $m);
     if ($imageCount > WCF::getUser()->getPermission('user.profile.signature.maxImages')) {
         throw new UserInputException('text', 'tooManyImages');
     }
     if (WCF::getUser()->getPermission('user.profile.signature.maxImageSize') > 0 || WCF::getUser()->getPermission('user.profile.signature.maxImageWidth') > 0 || WCF::getUser()->getPermission('user.profile.signature.maxImageHeight') > 0) {
         // get images
         $images = array();
         // [img=path][/img] syntax
         preg_match_all("!\\[img=(?:'([^'\\\\]+|\\\\.)*'|(.+?))(?:,(?:'(?:left|right)'|(?:left|right)))?\\]!i", $this->text, $matches);
         $images = array_merge($images, ArrayUtil::trim($matches[1]), ArrayUtil::trim($matches[2]));
         // [img]path[/img] syntax
         preg_match_all("!\\[img\\](.+?)(\\[/img\\]|\$)!is", $this->text, $matches);
         $images = array_merge($images, ArrayUtil::trim($matches[1]));
         $errors = array();
         foreach ($images as $image) {
             // download file
             try {
                 if (@($tmpFile = FileUtil::downloadFileFromHttp($image, 'image_'))) {
                     if (WCF::getUser()->getPermission('user.profile.signature.maxImageSize') > 0) {
                         // get remote image size (byte)
                         if (filesize($tmpFile) > WCF::getUser()->getPermission('user.profile.signature.maxImageSize')) {
                             $errors[] = array('errorType' => 'tooLarge', 'image' => $image);
                             continue;
                         }
                     }
                     // get remote image size (pixel)
                     if (WCF::getUser()->getPermission('user.profile.signature.maxImageWidth') > 0 || WCF::getUser()->getPermission('user.profile.signature.maxImageHeight') > 0) {
                         if ($size = @getImageSize($tmpFile)) {
                             $width = $size[0];
                             $height = $size[1];
                             if ($width > WCF::getUser()->getPermission('user.profile.signature.maxImageWidth') || $height > WCF::getUser()->getPermission('user.profile.signature.maxImageHeight')) {
                                 $errors[] = array('errorType' => 'tooLarge', 'image' => $image);
                             }
                         }
                     }
                 }
             } catch (SystemException $e) {
             }
         }
         if (count($errors) > 0) {
             throw new UserInputException('text', $errors);
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:54,代码来源:SignatureEditForm.class.php

示例15: readFormParameters

 /**
  * reads the parameters the user entered in the form
  */
 protected function readFormParameters()
 {
     if (isset($_POST['permissions']) && is_array($_POST['permissions'])) {
         $this->selectedPermissions = ArrayUtil::trim($_POST['permissions']);
     }
 }
开发者ID:Fighter456,项目名称:de.fighter456.wcf.pageMenuPermission,代码行数:9,代码来源:PageMenuItemAddFormPermissionListener.class.php


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