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


PHP StringUtil::indexOf方法代码示例

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


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

示例1: checkCondition

 /**
  * Checks the condition.
  *
  * @param	PMRuleCondition		$condition
  * @param	string			$string
  * @return	boolean
  */
 protected function checkCondition(PMRuleCondition $condition, $string)
 {
     $value = StringUtil::toLowerCase($condition->ruleConditionValue);
     $string = StringUtil::toLowerCase($string);
     switch ($condition->ruleCondition) {
         case 'contains':
             if (StringUtil::indexOf($string, $value) !== false) {
                 return true;
             }
             break;
         case 'dontContains':
             if (StringUtil::indexOf($string, $value) === false) {
                 return true;
             }
             break;
         case 'beginsWith':
             if (StringUtil::indexOf($string, $value) === 0) {
                 return true;
             }
             break;
         case 'endsWith':
             if (StringUtil::substring($string, -1 * StringUtil::length($value)) == $value) {
                 return true;
             }
             break;
         case 'isEqualTo':
             if ($value == $string) {
                 return true;
             }
             break;
     }
     return false;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:40,代码来源:SenderPMRuleConditionType.class.php

示例2: readParameters

 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     // get available letters
     $defaultLetters = WCF::getLanguage()->get('wcf.user.membersList.letters');
     if (!empty($defaultLetters) && $defaultLetters != 'wcf.user.membersList.letters') {
         self::$defaultLetters = $defaultLetters;
     }
     // get user options
     $this->userOptions = new UserOptions('medium');
     // letter
     if (isset($_REQUEST['letter']) && StringUtil::length($_REQUEST['letter']) == 1 && StringUtil::indexOf(self::$defaultLetters, $_REQUEST['letter']) !== false) {
         $this->letter = $_REQUEST['letter'];
     }
     // active fields
     $this->activeFields = explode(',', MEMBERS_LIST_COLUMNS);
     if (MODULE_AVATAR != 1 && ($key = array_search('avatar', $this->activeFields)) !== false) {
         unset($this->activeFields[$key]);
     }
     // search id
     if (isset($_REQUEST['searchID'])) {
         $this->searchID = intval($_REQUEST['searchID']);
         if ($this->searchID != 0) {
             $this->getSearchResult();
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:30,代码来源:MembersListPage.class.php

示例3: insertPageNumber

 /**
  * Inserts the page number into the link.
  * 
  * @param 	string		$link
  * @param 	integer		$pageNo
  * @return	string		final link
  */
 protected static function insertPageNumber($link, $pageNo)
 {
     $startPos = StringUtil::indexOf($link, '%d');
     if ($startPos !== null) {
         $link = StringUtil::substring($link, 0, $startPos) . $pageNo . StringUtil::substring($link, $startPos + 2);
     }
     return $link;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:15,代码来源:TemplatePluginFunctionSmallpages.class.php

示例4: getParsedTag

 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if (StringUtil::indexOf($content, '[*]') !== false) {
         // get list elements
         $listElements = preg_split('/\\[\\*\\]/', StringUtil::trim($content), -1, PREG_SPLIT_NO_EMPTY);
         // remove empty elements
         foreach ($listElements as $key => $val) {
             $listElements[$key] = StringUtil::trim($val);
             if (empty($listElements[$key]) || $listElements[$key] == '<br />') {
                 unset($listElements[$key]);
             }
         }
         if (count($listElements) > 0) {
             // get list style type
             $listType = 'disc';
             if (isset($openingTag['attributes'][0])) {
                 $listType = $openingTag['attributes'][0];
             }
             $listType = strtolower($listType);
             // replace old types
             if ($listType == '1') {
                 $listType = 'decimal';
             }
             if ($listType == 'a') {
                 $listType = 'lower-latin';
             }
             if ($parser->getOutputType() == 'text/html') {
                 // build list html
                 $listHTML = 'ol';
                 if ($listType == 'none' || $listType == 'circle' || $listType == 'square' || $listType == 'disc') {
                     $listHTML = 'ul';
                 }
                 return '<' . $listHTML . ' style="list-style-type: ' . $listType . '"><li>' . implode('</li><li>', $listElements) . '</li></' . $listHTML . '>';
             } else {
                 if ($parser->getOutputType() == 'text/plain') {
                     $result = '';
                     $i = 1;
                     foreach ($listElements as $listElement) {
                         switch ($listType) {
                             case 'decimal':
                                 $result .= $i . '. ';
                                 break;
                             default:
                                 $result .= '- ';
                         }
                         $result .= $listElement . "\n";
                         $i++;
                     }
                     return $result;
                 }
             }
         }
     }
     // no valid list
     // return bbcode as text
     return $openingTag['source'] . $content . $closingTag['source'];
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:60,代码来源:ListBBCode.class.php

示例5: reinsertStrings

	/**
	 * Reinserts strings that have been replaced by unique hash values.
	 *
	 * @param	string		$string
	 * @param	string		$type
	 * @return	string
	 */
	public static function reinsertStrings($string, $type = 'default') {
		if (isset(self::$stringStack[$type])) {
			foreach (self::$stringStack[$type] as $hash => $value) {
				if (StringUtil::indexOf($string, $hash) !== false) {
					$string = StringUtil::replace($hash, $value, $string);
					unset(self::$stringStack[$type][$hash]);
				}
			}
		}
		
		return $string;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:19,代码来源:StringStack.class.php

示例6: install

 /**
  * Starts the extracting of the files.
  */
 protected function install()
 {
     $this->checkTargetDir();
     $this->createTargetDir();
     // open source archive
     $tar = new Tar($this->source);
     // distinct directories and files
     $directories = array();
     $files = array();
     foreach ($tar->getContentList() as $index => $file) {
         if (empty($this->folder) || StringUtil::indexOf($file['filename'], $this->folder) === 0) {
             if (!empty($this->folder)) {
                 $file['filename'] = StringUtil::replace($this->folder, '', $file['filename']);
             }
             // remove leading slash
             $file['filename'] = FileUtil::removeLeadingSlash($file['filename']);
             if ($file['type'] == 'folder') {
                 // remove trailing slash
                 $directories[] = FileUtil::removeTrailingSlash($file['filename']);
             } else {
                 $files[$index] = $file['filename'];
             }
         }
     }
     $this->checkFiles($files);
     // now create the directories
     $errors = array();
     foreach ($directories as $dir) {
         try {
             $this->createDir($dir);
         } catch (SystemException $e) {
             $errors[] = array('file' => $dir, 'code' => $e->getCode(), 'message' => $e->getMessage());
         }
     }
     // now untar all files
     foreach ($files as $index => $file) {
         try {
             $this->createFile($file, $index, $tar);
         } catch (SystemException $e) {
             $errors[] = array('file' => $file, 'code' => $e->getCode(), 'message' => $e->getMessage());
         }
     }
     if (count($errors) > 0) {
         throw new SystemException('error(s) during the installation of the files.', 11111, $errors);
     }
     $this->logFiles($files);
     // close tar
     $tar->close();
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:52,代码来源:Installer.class.php

示例7: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (!empty($this->filename)) {
         // import style
         $this->style = StyleEditor::import($this->filename, PACKAGE_ID, $this->destinationStyle !== null && $this->destinationStyle->styleID ? $this->destinationStyle : null);
     } else {
         // import destination
         if ($this->destinationStyle !== null && !$this->destinationStyle->styleID) {
             throw new UserInputException('destinationStyleID');
         }
         // upload style
         if ($this->styleUpload && $this->styleUpload['error'] != 4) {
             if ($this->styleUpload['error'] != 0) {
                 throw new UserInputException('styleUpload', 'uploadFailed');
             }
             $this->newFilename = $this->styleUpload['tmp_name'];
             try {
                 $this->styleData = StyleEditor::getStyleData($this->styleUpload['tmp_name']);
             } catch (SystemException $e) {
                 throw new UserInputException('styleUpload', 'invalid');
             }
             // copy file
             $newFilename = FileUtil::getTemporaryFilename('style_');
             if (@move_uploaded_file($this->styleUpload['tmp_name'], $newFilename)) {
                 $this->newFilename = $newFilename;
             }
         } else {
             if ($this->styleURL != 'http://') {
                 if (StringUtil::indexOf($this->styleURL, 'http://') !== 0) {
                     throw new UserInputException('styleURL', 'downloadFailed');
                 }
                 try {
                     $this->newFilename = FileUtil::downloadFileFromHttp($this->styleURL, 'style');
                 } catch (SystemException $e) {
                     throw new UserInputException('styleURL', 'downloadFailed');
                 }
                 try {
                     $this->styleData = StyleEditor::getStyleData($this->newFilename);
                 } catch (SystemException $e) {
                     throw new UserInputException('styleURL', 'invalid');
                 }
             } else {
                 throw new UserInputException('styleUpload');
             }
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:51,代码来源:StyleImportForm.class.php

示例8: parse

    /**
     * Adds the url and email bbcode tags in a text automatically.
     */
    public static function parse($text)
    {
        self::$text = $text;
        // cache codes
        self::$text = self::cacheCodes(self::$text);
        // call event
        EventHandler::fireAction('URLParser', 'shouldParse');
        // define pattern
        $urlPattern = '~(?<!\\B|"|\'|=|/|\\]|,|\\?)
			(?:						# hostname
				(?:ftp|https?)://' . self::$illegalChars . '(?:\\.' . self::$illegalChars . ')*
				|
				www\\.(?:' . self::$illegalChars . '\\.)+
				(?:[a-z]{2,4}(?=\\b))
			)

			(?::\\d+)?					# port

			(?:
				/
				[^!.,?;"\'<>()\\[\\]{}\\s]*
				(?:
					[!.,?;(){}]+ [^!.,?;"\'<>()\\[\\]{}\\s]+
				)*
			)?
			~ix';
        $emailPattern = '~(?<!\\B|"|\'|=|/|\\]|,|:)
			(?:)
			\\w+(?:[\\.\\-]\\w+)*
			@
			(?:' . self::$illegalChars . '\\.)+		# hostname
			(?:[a-z]{2,4}(?=\\b))
			(?!"|\'|\\[|\\-|\\.[a-z])
			~ix';
        // add url tags
        self::$text = preg_replace($urlPattern, '[url]\\0[/url]', self::$text);
        if (StringUtil::indexOf(self::$text, '@') !== false) {
            self::$text = preg_replace($emailPattern, '[email]\\0[/email]', self::$text);
        }
        // call event
        EventHandler::fireAction('URLParser', 'didParse');
        if (count(self::$cachedCodes) > 0) {
            // insert cached codes
            self::$text = self::insertCachedCodes(self::$text);
        }
        return self::$text;
    }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:50,代码来源:URLParser.class.php

示例9: parseMultipleEnableOptions

 /**
  * Returns a list of the enable options.
  * 
  * @param 	string		$enableOptions
  * @return	array
  */
 public static function parseMultipleEnableOptions($enableOptions)
 {
     $result = array();
     if (!empty($enableOptions)) {
         $options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($enableOptions)));
         $key = -1;
         foreach ($options as $option) {
             if (StringUtil::indexOf($option, ':') !== false) {
                 $optionData = explode(':', $option);
                 $key = array_shift($optionData);
                 $value = implode(':', $optionData);
             } else {
                 $key++;
                 $value = $option;
             }
             $result[$key] = $value;
         }
     }
     return $result;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:26,代码来源:OptionUtil.class.php

示例10: getResult

 protected static function getResult($optionData, $value)
 {
     $options = OptionUtil::parseSelectOptions($optionData['selectOptions']);
     // multiselect
     if (StringUtil::indexOf($value, "\n") !== false) {
         $values = explode("\n", $value);
         $result = array();
         foreach ($values as $value) {
             if (isset($options[$value])) {
                 $result[] = $options[$value];
             }
         }
         return $result;
     } else {
         if (!empty($value) && isset($options[$value])) {
             return $options[$value];
         }
         return null;
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:20,代码来源:UserOptionOutputSelectOptions.class.php

示例11: execute

	/**
	 * @see EventListener::execute()
	 */
	public function execute($eventObj, $className, $eventName) {
		if (!MODULE_ROUTER) return;
		
		// get base
		$segments = explode('/', FileUtil::addTrailingSlash(PAGE_URL), 4);
		if (!empty($segments[3])) $this->base .= $segments[3];
		
		// load routes
		WCF::getCache()->addResource(
			'routes-'.PACKAGE_ID,
			WCF_DIR.'cache/cache.routes-'.PACKAGE_ID.'.php',
			WCF_DIR.'lib/system/cache/CacheBuilderRoutes.class.php'
		);
		$this->routes = WCF::getCache()->get('routes-'.PACKAGE_ID);
		
		// get request
		$request = $_SERVER['REQUEST_URI'];
		$_ = explode($this->base, $request, 2);
		$request = $_[count($_)-1];
		
		if (StringUtil::indexOf($request, 'index.php') === 0)
			return false;
		
		// get route which suits best for the request
		if (!$route = $this->getRouteByRequest($request))
			throw new SystemException('No route');
		
		// set variables
		foreach ($route[0][1] as $isset) {
			if (!isset($route[0][2][$isset]) && isset($route[1][$isset])) {
				$_GET[$isset] = $route[1][$isset];
				$_REQUEST[$isset] = $route[1][$isset];
			}
		}
		
		// set predefined variables
		foreach ($route[0][2] as $key => $value) {
			$_GET[$key] = $value;
			$_REQUEST[$key] = $value;
		}
	}
开发者ID:nachteule,项目名称:nachteule.wcf.router,代码行数:44,代码来源:RouterListener.class.php

示例12: execute

 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (MODULE_AVATAR == 1) {
         if ($eventName == 'readFormParameters') {
             if (isset($_POST['avatarID'])) {
                 $this->avatarID = intval($_POST['avatarID']);
             }
             if (isset($_POST['disableAvatar'])) {
                 $this->disableAvatar = intval($_POST['disableAvatar']);
             }
             if (isset($_POST['disableAvatarReason'])) {
                 $this->disableAvatarReason = $_POST['disableAvatarReason'];
             }
             if (isset($_POST['useAvatar'])) {
                 $this->useAvatar = intval($_POST['useAvatar']);
             }
             if (isset($_POST['avatarURL'])) {
                 $this->avatarURL = StringUtil::trim($_POST['avatarURL']);
             }
             if (isset($_FILES['avatarUpload'])) {
                 $this->avatarUpload = $_FILES['avatarUpload'];
             }
             if (MODULE_GRAVATAR == 1 && isset($_POST['gravatar'])) {
                 $this->gravatar = StringUtil::trim($_POST['gravatar']);
             }
         } else {
             if ($eventName == 'validate') {
                 try {
                     if ($this->useAvatar == 1) {
                         if (empty($this->gravatar)) {
                             // upload or download avatar
                             if ($this->avatarUpload && $this->avatarUpload['error'] != 4) {
                                 if ($this->avatarUpload['error'] != 0) {
                                     throw new UserInputException('avatarUpload', 'uploadFailed');
                                 }
                                 $this->avatarID = AvatarEditor::create($this->avatarUpload['tmp_name'], $this->avatarUpload['name'], 'avatarUpload', $eventObj->userID);
                             } else {
                                 if ($this->avatarURL != 'http://') {
                                     if (StringUtil::indexOf($this->avatarURL, 'http://') !== 0) {
                                         throw new UserInputException('avatarURL', 'downloadFailed');
                                     }
                                     try {
                                         $tmpName = FileUtil::downloadFileFromHttp($this->avatarURL, 'avatar');
                                     } catch (SystemException $e) {
                                         throw new UserInputException('avatarURL', 'downloadFailed');
                                     }
                                     $this->avatarID = AvatarEditor::create($tmpName, $this->avatarURL, 'avatarURL', $eventObj->userID);
                                 } else {
                                     $this->avatarID = $eventObj->user->avatarID;
                                 }
                             }
                         }
                     } else {
                         if ($this->useAvatar == 2) {
                             // use a default avatar
                             $avatar = new AvatarEditor($this->avatarID);
                             if (!$avatar->avatarID || $avatar->userID || $avatar->groupID && !in_array($avatar->groupID, $eventObj->user->getGroupIDs()) || $avatar->neededPoints > $eventObj->user->activityPoints) {
                                 throw new UserInputException('availableAvatars', 'invalid');
                             }
                         } else {
                             $this->avatarID = 0;
                         }
                     }
                 } catch (UserInputException $e) {
                     $eventObj->errorType[$e->getField()] = $e->getType();
                 }
             } else {
                 if ($eventName == 'save') {
                     // delete old avatar if necessary
                     if ($eventObj->user->avatarID) {
                         $currentAvatar = new AvatarEditor($eventObj->user->avatarID);
                         if ($currentAvatar->userID && $this->avatarID != $currentAvatar->avatarID) {
                             $currentAvatar->delete();
                         }
                     }
                     // update user
                     $eventObj->additionalFields['avatarID'] = $this->avatarID;
                     $eventObj->additionalFields['disableAvatar'] = $this->disableAvatar;
                     $eventObj->additionalFields['disableAvatarReason'] = $this->disableAvatarReason;
                     $eventObj->additionalFields['gravatar'] = $this->gravatar;
                 } else {
                     if ($eventName == 'show') {
                         // get default values
                         if (!count($_POST)) {
                             $this->avatarID = $eventObj->user->avatarID;
                             $this->disableAvatar = $eventObj->user->disableAvatar;
                             $this->disableAvatarReason = $eventObj->user->disableAvatarReason;
                             $this->gravatar = $eventObj->user->gravatar;
                         }
                         $currentAvatar = null;
                         if ($this->avatarID) {
                             $currentAvatar = new AvatarEditor($this->avatarID);
                             $this->useAvatar = $currentAvatar->userID ? 1 : 2;
                         } else {
                             if ($this->gravatar) {
                                 require_once WCF_DIR . 'lib/data/user/avatar/Gravatar.class.php';
                                 $currentAvatar = new Gravatar($this->gravatar);
//.........这里部分代码省略.........
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:101,代码来源:UserEditFormAvatarListener.class.php

示例13: parseURLs

    /**
     * Parses urls.
     * 
     * @param	string		$text
     * @return	string		text
     */
    public static function parseURLs($text)
    {
        // define pattern
        $urlPattern = '~(?<!\\B|"|\'|=|/|\\]|,|\\?)
			(?:						# hostname
				(?:ftp|https?)://' . self::$illegalChars . '(?:\\.' . self::$illegalChars . ')*
				|
				www\\.(?:' . self::$illegalChars . '\\.)+
				(?:[a-z]{2,4}(?=\\b))
			)

			(?::\\d+)?					# port

			(?:
				/
				[^!.,?;"\'<>()\\[\\]{}\\s]*
				(?:
					[!.,?;(){}]+ [^!.,?;"\'<>()\\[\\]{}\\s]+
				)*
			)?
			~ix';
        $emailPattern = '~(?<!\\B|"|\'|=|/|\\]|,|:)
			(?:)
			\\w+(?:[\\.\\-]\\w+)*
			@
			(?:' . self::$illegalChars . '\\.)+		# hostname
			(?:[a-z]{2,4}(?=\\b))
			(?!"|\'|\\[|\\-)
			~ix';
        // parse urls
        $text = preg_replace_callback($urlPattern, array('self', 'parseURLsCallback'), $text);
        // parse emails
        if (StringUtil::indexOf($text, '@') !== false) {
            $text = preg_replace($emailPattern, '<a href="mailto:\\0">\\0</a>', $text);
        }
        return $text;
    }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:43,代码来源:SimpleMessageParser.class.php

示例14: checkFromversion

 public static function checkFromversion($currentVersion, $fromversion)
 {
     if (StringUtil::indexOf($fromversion, '*') !== false) {
         // from version with wildcard
         // use regular expression
         $fromversion = StringUtil::replace('\\*', '.*', preg_quote($fromversion, '!'));
         if (preg_match('!^' . $fromversion . '$!i', $currentVersion)) {
             return true;
         }
     } else {
         if (self::compareVersion($currentVersion, $fromversion, '=')) {
             return true;
         }
     }
     return false;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:16,代码来源:Package.class.php

示例15: save

 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // change user
     WCF::getSession()->changeUser($this->user);
     $this->saved();
     if (!empty($this->url)) {
         // append session
         if (StringUtil::indexOf($this->url, '?') !== false) {
             $this->url .= SID_ARG_2ND_NOT_ENCODED;
         } else {
             $this->url .= SID_ARG_1ST;
         }
         HeaderUtil::redirect($this->url);
     } else {
         HeaderUtil::redirect('index.php?packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     }
     exit;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:22,代码来源:LoginForm.class.php


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