From: Matthias Schmidt Date: Wed, 6 Apr 2016 16:13:47 +0000 (+0200) Subject: Remove unused erroneous methods X-Git-Tag: 3.0.0_Beta_1~1960 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9ed904923d1683382a5704fdad81b674e3ec0a46;p=GitHub%2FWoltLab%2FWCF.git Remove unused erroneous methods --- diff --git a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php index 8d525f31e5..90c012382a 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php @@ -491,106 +491,6 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje LanguageCacheBuilder::getInstance()->reset(); } - /** - * Searches in language items. - * - * @param string $search search query - * @param string $replace - * @param integer $languageID - * @param integer $useRegex - * @param integer $searchVariableName - * @return array - */ - public static function search($search, $replace = null, $languageID = null, $useRegex = 0, $searchVariableName = 0) { - $results = array(); - - // build condition - $conditionBuilder = new PreparedStatementConditionBuilder(); - - // search field - $statementParameters = array(); - if ($searchVariableName) $searchCondition = 'languageItem '; - else $searchCondition = 'languageItemValue '; - - // regex - if ($useRegex) { - $searchCondition .= "REGEXP ?"; - $statementParameters[] = $search; - } - else { - $searchCondition .= "LIKE ?"; - $statementParameters[] = '%'.$search.'%'; - } - - if (!$searchVariableName) { - $searchCondition .= ' OR languageCustomItemValue '; - // regex - if ($useRegex) { - $searchCondition .= "REGEXP ?"; - $statementParameters[] = $search; - } - else { - $searchCondition .= "LIKE ?"; - $statementParameters[] = '%'.$search.'%'; - } - } - - $conditionBuilder->add($searchCondition, $statementParameters); - if ($languageID !== null) $conditionBuilder->add("languageID = ?", array($languageID)); - - // search - $updatedItems = array(); - $sql = "SELECT * - FROM wcf".WCF_N."_language_item - ".$conditionBuilder; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditionBuilder->getParameters()); - - while ($row = $statement->fetchArray()) { - if ($replace !== null) { - // search and replace - $matches = 0; - if ($useRegex) { - $newValue = preg_replace('~'.$search.'~s', $replace, ($row['languageCustomItemValue'] ?: $row['languageItemValue']), -1, $matches); - } - else { - $newValue = StringUtil::replaceIgnoreCase($search, $replace, ($row['languageCustomItemValue'] ?: $row['languageItemValue']), $matches); - } - - if ($matches > 0) { - // update value - if (!isset($updatedItems[$row['languageID']])) $updatedItems[$row['languageID']] = array(); - if (!isset($updatedItems[$row['languageID']][$row['languageCategoryID']])) $updatedItems[$row['languageID']][$row['languageCategoryID']] = array(); - $updatedItems[$row['languageID']][$row['languageCategoryID']][$row['languageItem']] = $newValue; - - // save matches - $row['matches'] = $matches; - } - } - - $results[] = $row; - } - - // save updates - if (!empty($updatedItems)) { - foreach ($updatedItems as $languageID => $categories) { - $language = new LanguageEditor($languageID); - - foreach ($categories as $categoryID => $items) { - $useCustom = array(); - foreach (array_keys($items) as $item) { - $useCustom[$item] = 1; - } - - $category = new LanguageCategory($categoryID); - $language->updateItems($items, $category, PACKAGE_ID, $useCustom); - } - } - } - - return $results; - } - /** * Enables the multilingualism feature for given languages. * diff --git a/wcfsetup/install/files/lib/data/template/Template.class.php b/wcfsetup/install/files/lib/data/template/Template.class.php index 92af1e47c5..386b83d94e 100644 --- a/wcfsetup/install/files/lib/data/template/Template.class.php +++ b/wcfsetup/install/files/lib/data/template/Template.class.php @@ -3,10 +3,8 @@ namespace wcf\data\template; use wcf\data\package\PackageCache; use wcf\data\DatabaseObject; use wcf\system\application\ApplicationHandler; -use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\WCF; use wcf\util\FileUtil; -use wcf\util\StringUtil; /** * Represents a template. @@ -93,85 +91,4 @@ class Template extends DatabaseObject { public function getSource() { return @file_get_contents($this->getPath()); } - - /** - * Searches in templates. - * - * @param string $search search query - * @param string $replace - * @param array $templateIDs - * @param integer $invertTemplates - * @param integer $useRegex - * @param integer $caseSensitive - * @param integer $invertSearch - * @return array - */ - 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 = (mb_strpos($template->getSource(), $search) !== false); - else $matches = (mb_strripos($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 = str_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; - } }