本文整理汇总了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;
}
示例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;
}
示例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;
}