當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。