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


PHP StringUtil::indexOfIgnoreCase方法代码示例

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


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

示例1: 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

示例2: getList

 /**
  * Returns a list of users and -groups based upon given search criteria.
  * 
  * @return	array<array>
  */
 public function getList()
 {
     $searchString = $this->parameters['data']['searchString'];
     $excludedSearchValues = array();
     if (isset($this->parameters['data']['excludedSearchValues'])) {
         $excludedSearchValues = $this->parameters['data']['excludedSearchValues'];
     }
     $list = array();
     if ($this->parameters['data']['includeUserGroups']) {
         $accessibleGroups = UserGroup::getAccessibleGroups();
         foreach ($accessibleGroups as $group) {
             $groupName = $group->getName();
             if (!in_array($groupName, $excludedSearchValues)) {
                 $pos = StringUtil::indexOfIgnoreCase($groupName, $searchString);
                 if ($pos !== false && $pos == 0) {
                     $list[] = array('label' => $groupName, 'objectID' => $group->groupID, 'type' => 'group');
                 }
             }
         }
     }
     $conditionBuilder = new PreparedStatementConditionBuilder();
     $conditionBuilder->add("username LIKE ?", array($searchString . '%'));
     if (count($excludedSearchValues)) {
         $conditionBuilder->add("username NOT IN (?)", array($excludedSearchValues));
     }
     // find users
     $sql = "SELECT\tuserID, username\n\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t" . $conditionBuilder;
     $statement = WCF::getDB()->prepareStatement($sql, 10);
     /* TODO: add limit parameter */
     $statement->execute($conditionBuilder->getParameters());
     while ($row = $statement->fetchArray()) {
         $list[] = array('label' => $row['username'], 'objectID' => $row['userID'], 'type' => 'user');
     }
     return $list;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:40,代码来源:UserAction.class.php

示例3: 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


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