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


PHP StringUtil::indexOf方法代码示例

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


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

示例1: 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:ZerGabriel,项目名称:WCF,代码行数:15,代码来源:PagesFunctionTemplatePlugin.class.php

示例2: setURL

 /**
  * Sets the target url, by default appends appropriate session id.
  * May be left empty to disable url functionality.
  * 
  * @param	string		$url
  * @param	boolean		$appendSession
  */
 public function setURL($url, $appendSession = false)
 {
     // append session id
     if ($appendSession) {
         if (StringUtil::indexOf($url, '?') === false) {
             $url .= SID_ARG_1ST;
         } else {
             $url .= SID_ARG_2ND_NOT_ENCODED;
         }
     }
     $this->url = $url;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:19,代码来源:Breadcrumb.class.php

示例3: __construct

	/**
	 * @see	\Exception::__construct()
	 */
	public function __construct($fieldName, $errorMessage = 'empty', array $variables = array()) {
		$this->errorMessage = $errorMessage;
		if (StringUtil::indexOf($this->errorMessage, '.') === false) {
			$this->errorMessage = WCF::getLanguage()->get('wcf.global.form.error.'.$this->errorMessage);
		}
		else {
			$this->errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, $variables);
		}
		
		$this->fieldName = $fieldName;
		$this->message = WCF::getLanguage()->getDynamicVariable('wcf.ajax.error.invalidParameter', array('fieldName' => $this->fieldName));
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:15,代码来源:ValidateActionException.class.php

示例4: getRanges

 /**
  * Parses a possible range of values including a step value.
  * 
  * @param	string		$value
  * @return	array
  */
 protected static function getRanges($value)
 {
     // this is a single value
     if (StringUtil::indexOf($value, '-') === false) {
         return array($value);
     }
     $step = 1;
     if (StringUtil::indexOf($value, '/') !== false) {
         $data = explode('/', $value);
         $step = $data[1];
         $value = $data[0];
     }
     $data = explode('-', $value);
     return self::calculateRange($data[0], $data[1], $step);
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:21,代码来源:CronjobUtil.class.php

示例5: setCookie

	/**
	 * Alias to php setcookie() function.
	 */
	public static function setCookie($name, $value = '', $expire = 0) {
		$application = ApplicationHandler::getInstance()->getActiveApplication();
		$addDomain = (StringUtil::indexOf($application->cookieDomain, '.') === false || StringUtil::endsWith($application->cookieDomain, '.lan') || StringUtil::endsWith($application->cookieDomain, '.local')) ? false : true;
		
		@header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX.$name).'='.rawurlencode($value).($expire ? '; expires='.gmdate('D, d-M-Y H:i:s', $expire).' GMT; max-age='.($expire - TIME_NOW) : '').'; path='.$application->cookiePath.($addDomain ? '; domain='.$application->cookieDomain : '').(RouteHandler::secureConnection() ? '; secure' : '').'; HttpOnly', false);
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:9,代码来源:HeaderUtil.class.php

示例6: save

	/**
	 * @see	wcf\form\IForm::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 {
			$application = ApplicationHandler::getInstance()->getActiveApplication();
			$path = $application->getPageURL() . 'acp/' . SID_ARG_1ST;
			HeaderUtil::redirect($path);
		}
		exit;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:23,代码来源:LoginForm.class.php

示例7: save

 /**
  * @see wcf\form\IForm::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' . SID_ARG_1ST);
     }
     exit;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:22,代码来源:LoginForm.class.php

示例8: handleRequest

 /**
  * Handles request input variables.
  */
 public function handleRequest()
 {
     $variables = array();
     foreach ($_REQUEST as $key => $value) {
         if (StringUtil::indexOf($key, $this->getName() . '_') !== false) {
             $key = StringUtil::replace($this->getName() . '_', '', $key);
             $variables[$key] = $value;
         }
     }
     if (!empty($variables)) {
         foreach ($this->containers as $container) {
             $container->handleRequest($variables);
         }
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:18,代码来源:FormDocument.class.php

示例9: search

	/**
	 * Searches in templates.
	 * 
	 * @param	string		$search		search query
	 * @param	string		$replace
	 * @param	array		$templateIDs
	 * @param	boolean		$invertTemplates
	 * @param	boolean		$useRegex
	 * @param	boolean		$caseSensitive
	 * @param	boolean		$invertSearch
	 * @return	array		results 
	 */
	public static function search($search, $replace = null, $templateIDs = null, $invertTemplates = 0, $useRegex = 0, $caseSensitive = 0, $invertSearch = 0) {
		// get available template ids
		$results = array();
		$availableTemplateIDs = array();
		$sql = "SELECT		templateName, templateID, templateGroupID, packageID
			FROM		wcf".WCF_N."_template
					".($replace !== null ? "WHERE templateGroupID <> 0" : "");
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute();
		while ($row = $statement->fetchArray()) {
			if (!isset($availableTemplateIDs[$row['templateName'].'-'.$row['templateGroupID']]) || PACKAGE_ID == $row['packageID']) {
				$availableTemplateIDs[$row['templateName'].'-'.$row['templateGroupID']] = $row['templateID'];
			}
		}
		
		// get templates
		if (empty($availableTemplateIDs)) return $results;
		
		$conditions = new PreparedStatementConditionBuilder();
		$conditions->add("template.templateID IN (?)", array($availableTemplateIDs));
		if ($templateIDs !== null) $conditions->add("template.templateID ".($invertTemplates ? "NOT " : "")." IN (?)", array($templateIDs));
		
		$sql = "SELECT		template.*, group.templateGroupFolderName, package.packageDir
			FROM		wcf".WCF_N."_template template
			LEFT JOIN	wcf".WCF_N."_template_group group
			ON		(group.templateGroupID = template.templateGroupID)
			LEFT JOIN	wcf".WCF_N."_package package
			ON		(package.packageID = template.packageID)
			".$conditions."
			ORDER BY	templateName ASC";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute($conditions->getParameters());
		unset($availableTemplateIDs);
		while ($row = $statement->fetchArray()) {
			$template = new TemplateEditor(null, $row);
			if ($replace === null) {
				// search
				if ($useRegex) $matches = (intval(preg_match('/'.$search.'/s'.(!$caseSensitive ? 'i' : ''), $template->getSource())) !== 0);
				else {
					if ($caseSensitive) $matches = (StringUtil::indexOf($template->getSource(), $search) !== false);
					else $matches = (StringUtil::indexOfIgnoreCase($template->getSource(), $search) !== false);
				}
				
				if (($matches && !$invertSearch) || (!$matches && $invertSearch)) {
					$results[] = $row;
				}
			}
			else {
				// search and replace
				$matches = 0;
				if ($useRegex) {
					$newSource = preg_replace('/'.$search.'/s'.(!$caseSensitive ? 'i' : ''), $replace, $template->getSource(), -1, $matches);
				}
				else {
					if ($caseSensitive) $newSource = StringUtil::replace($search, $replace, $template->getSource(), $matches);
					else $newSource = StringUtil::replaceIgnoreCase($search, $replace, $template->getSource(), $matches);
				}
				
				if ($matches > 0) {
					$template->setSource($newSource);
					$row['matches'] = $matches;
					$results[] = $row;
				}
			}
		}
		
		return $results;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:80,代码来源:Template.class.php

示例10: checkFromversion

	/**
	 * Checks the version number of the installed package against the "fromversion"
	 * number of the update.
	 * 
	 * The "fromversion" number may contain wildcards (asterisks) which means
	 * that the update covers the whole range of release numbers where the asterisk
	 * wildcards digits from 0 to 9.
	 * For example, if "fromversion" is "1.1.*" and this package updates to
	 * version 1.2.0, all releases from 1.1.0 to  1.1.9 may be updated using
	 * this package.
	 * 
	 * @param	string		$currentVersion
	 * @param	string		$fromVersion
	 * @return	boolean
	 */
	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:0xLeon,项目名称:WCF,代码行数:32,代码来源:Package.class.php

示例11: search

 /**
  * Searches in templates.
  * 
  * @param	string		$search		search query
  * @param	string		$replace
  * @param	array		$templateIDs
  * @param	boolean		$invertTemplates
  * @param	boolean		$useRegex
  * @param	boolean		$caseSensitive
  * @param	boolean		$invertSearch
  * @return	array		results 
  */
 public static function search($search, $replace = null, $templateIDs = null, $invertTemplates = 0, $useRegex = 0, $caseSensitive = 0, $invertSearch = 0)
 {
     // get available template ids
     $results = array();
     $availableTemplateIDs = array();
     $sql = "SELECT\t\ttemplate.templateName, template.templateID, template.templateGroupID, template.packageID\n\t\t\tFROM\t\twcf" . WCF_N . "_template template\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tON\t\t(package_dependency.dependency = template.packageID)\n\t\t\tWHERE \t\tpackage_dependency.packageID = ?\n\t\t\t\t\t" . ($replace !== null ? "AND template.templateGroupID <> 0" : "") . "\n\t\t\tORDER BY\tpackage_dependency.priority ASC";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(PACKAGE_ID));
     while ($row = $statement->fetchArray()) {
         if (!isset($availableTemplateIDs[$row['templateName'] . '-' . $row['templateGroupID']]) || PACKAGE_ID == $row['packageID']) {
             $availableTemplateIDs[$row['templateName'] . '-' . $row['templateGroupID']] = $row['templateID'];
         }
     }
     // get templates
     if (!count($availableTemplateIDs)) {
         return $results;
     }
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("template.templateID IN (?)", array($availableTemplateIDs));
     if ($templateIDs !== null) {
         $conditions->add("template.templateID " . ($invertTemplates ? "NOT " : "") . " IN (?)", array($templateIDs));
     }
     $sql = "SELECT\t\ttemplate.*, group.templateGroupFolderName, package.packageDir\n\t\t\tFROM\t\twcf" . WCF_N . "_template template\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_template_group group\n\t\t\tON\t\t(group.templateGroupID = template.templateGroupID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = template.packageID)\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\ttemplateName ASC";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     unset($availableTemplateIDs);
     while ($row = $statement->fetchArray()) {
         $template = new TemplateEditor(null, $row);
         if ($replace === null) {
             // search
             if ($useRegex) {
                 $matches = intval(preg_match('/' . $search . '/s' . (!$caseSensitive ? 'i' : ''), $template->getSource())) !== 0;
             } else {
                 if ($caseSensitive) {
                     $matches = StringUtil::indexOf($template->getSource(), $search) !== false;
                 } else {
                     $matches = StringUtil::indexOfIgnoreCase($template->getSource(), $search) !== false;
                 }
             }
             if ($matches && !$invertSearch || !$matches && $invertSearch) {
                 $results[] = $row;
             }
         } else {
             // search and replace
             $matches = 0;
             if ($useRegex) {
                 $newSource = preg_replace('/' . $search . '/s' . (!$caseSensitive ? 'i' : ''), $replace, $template->getSource(), -1, $matches);
             } else {
                 if ($caseSensitive) {
                     $newSource = StringUtil::replace($search, $replace, $template->getSource(), $matches);
                 } else {
                     $newSource = StringUtil::replaceIgnoreCase($search, $replace, $template->getSource(), $matches);
                 }
             }
             if ($matches > 0) {
                 $template->setSource($newSource);
                 $row['matches'] = $matches;
                 $results[] = $row;
             }
         }
     }
     return $results;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:75,代码来源:Template.class.php

示例12: getPackageName

 /**
  * Gets the package name of the first application in WCFSetup.tar.gz.
  */
 protected static function getPackageName()
 {
     // get package name
     $tar = new Tar(SETUP_FILE);
     foreach ($tar->getContentList() as $file) {
         if ($file['type'] != 'folder' && StringUtil::indexOf($file['filename'], 'install/packages/') === 0) {
             $packageFile = basename($file['filename']);
             $packageName = preg_replace('!\\.(tar\\.gz|tgz|tar)$!', '', $packageFile);
             if ($packageName != 'com.woltlab.wcf') {
                 try {
                     $archive = new PackageArchive(TMP_DIR . 'install/packages/' . $packageFile);
                     $archive->openArchive();
                     self::$setupPackageName = $archive->getLocalizedPackageInfo('packageName');
                     $archive->getTar()->close();
                     break;
                 } catch (SystemException $e) {
                 }
             }
         }
     }
     $tar->close();
     // assign package name
     WCF::getTPL()->assign(array('setupPackageName' => self::$setupPackageName));
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:27,代码来源:WCFSetup.class.php

示例13: parseMultipleEnableOptions

	/**
	 * Returns a list of the enable options.
	 * 
	 * @return	array
	 */
	public function parseMultipleEnableOptions() {
		$result = array();
		if (!empty($this->enableOptions)) {
			$options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($this->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:0xLeon,项目名称:WCF,代码行数:27,代码来源:Option.class.php

示例14: getRequestURI

	/**
	 * Returns the URI of the current page.
	 *
	 * @return	string
	 */
	public static function getRequestURI() {
		// resolve path and query components
		$scriptName = $_SERVER['SCRIPT_NAME'];
		if (empty($_SERVER['PATH_INFO'])) {
			// bug fix if URL omits script name and path
			$scriptName = substr($scriptName, 0, strrpos($scriptName, '/'));
		}
		
		$path = str_replace('/index.php', '', str_replace($scriptName, '', $_SERVER['REQUEST_URI']));
		if (!StringUtil::isASCII($path) && !StringUtil::isUTF8($path)) {
			$path = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $path);
		}
		$path = FileUtil::removeLeadingSlash($path);
		$baseHref = self::getTPL()->get('baseHref');
		
		if (!empty($path) && StringUtil::indexOf($path, '?') !== 0) {
			$baseHref .= 'index.php/';
		}
		
		return $baseHref . $path;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:26,代码来源:WCF.class.php

示例15: replacePHPTags

	/**
	 * Replaces all php tags.
	 * 
	 * @param	string		$string
	 * @return	string
	 */
	public function replacePHPTags($string) {
		if (StringUtil::indexOf($string, '<?') !== false) {
			$string = StringUtil::replace('<?php', '@@PHP_START_TAG@@', $string);
			$string = StringUtil::replace('<?', '@@PHP_SHORT_START_TAG@@', $string);
			$string = StringUtil::replace('?>', '@@PHP_END_TAG@@', $string);
			$string = StringUtil::replace('@@PHP_END_TAG@@', "<?php echo '?>'; ?>\n", $string);
			$string = StringUtil::replace('@@PHP_SHORT_START_TAG@@', "<?php echo '<?'; ?>\n", $string);
			$string = StringUtil::replace('@@PHP_START_TAG@@', "<?php echo '<?php'; ?>\n", $string);
		}
		
		return $string;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:18,代码来源:TemplateScriptingCompiler.class.php


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