From c58b9b43d32afc4a4da5af55c93fb9f4e0253feb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 16 Mar 2017 13:42:58 +0100 Subject: [PATCH] Filter by recently disabled, added warning to package list See #2221 --- .../files/acp/templates/languageItemList.tpl | 1 + .../install/files/acp/templates/packageList.tpl | 4 ++++ .../lib/acp/page/LanguageItemListPage.class.php | 13 +++++++++++-- .../files/lib/acp/page/PackageListPage.class.php | 2 ++ .../lib/data/language/item/LanguageItem.class.php | 2 ++ .../lib/system/language/LanguageFactory.class.php | 15 +++++++++++++++ wcfsetup/install/lang/de.xml | 2 ++ wcfsetup/install/lang/en.xml | 2 ++ 8 files changed, 39 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/languageItemList.tpl b/wcfsetup/install/files/acp/templates/languageItemList.tpl index 0fd882169d..68cc68b7d6 100644 --- a/wcfsetup/install/files/acp/templates/languageItemList.tpl +++ b/wcfsetup/install/files/acp/templates/languageItemList.tpl @@ -65,6 +65,7 @@ + diff --git a/wcfsetup/install/files/acp/templates/packageList.tpl b/wcfsetup/install/files/acp/templates/packageList.tpl index 4a18c12020..6e82db6c1b 100644 --- a/wcfsetup/install/files/acp/templates/packageList.tpl +++ b/wcfsetup/install/files/acp/templates/packageList.tpl @@ -54,6 +54,10 @@ {/hascontent} +{if $recentlyDisabledCustomValues > 0} +

{lang}wcf.acp.language.item.hasRecentlyDisabledCustomValues{/lang}

+{/if} + {hascontent}
{content}{pages print=true assign=pagesLinks controller='PackageList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content} diff --git a/wcfsetup/install/files/lib/acp/page/LanguageItemListPage.class.php b/wcfsetup/install/files/lib/acp/page/LanguageItemListPage.class.php index b5f1a4111a..dbabb6d339 100644 --- a/wcfsetup/install/files/lib/acp/page/LanguageItemListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/LanguageItemListPage.class.php @@ -77,6 +77,12 @@ class LanguageItemListPage extends SortablePage { */ public $hasDisabledCustomValue = 0; + /** + * search for disabled custom values that have been automatically disabled in the past 7 days + * @var boolean + */ + public $hasRecentlyDisabledCustomValue = 0; + /** * available languages * @var array @@ -101,6 +107,7 @@ class LanguageItemListPage extends SortablePage { if (isset($_REQUEST['languageItemValue'])) $this->languageItemValue = $_REQUEST['languageItemValue']; if (!empty($_REQUEST['hasCustomValue'])) $this->hasCustomValue = 1; if (!empty($_REQUEST['hasDisabledCustomValue'])) $this->hasDisabledCustomValue = 1; + if (!empty($_REQUEST['hasRecentlyDisabledCustomValue'])) $this->hasRecentlyDisabledCustomValue = 1; } /** @@ -112,8 +119,9 @@ class LanguageItemListPage extends SortablePage { if ($this->languageCategoryID) $this->objectList->getConditionBuilder()->add('languageCategoryID = ?', [$this->languageCategoryID]); if ($this->languageItem) $this->objectList->getConditionBuilder()->add('languageItem LIKE ?', ['%'.$this->languageItem.'%']); if ($this->languageItemValue) $this->objectList->getConditionBuilder()->add('((languageUseCustomValue = 0 AND languageItemValue LIKE ?) OR languageCustomItemValue LIKE ?)', ['%'.$this->languageItemValue.'%', '%'.$this->languageItemValue.'%']); - if ($this->hasCustomValue || $this->hasDisabledCustomValue) $this->objectList->getConditionBuilder()->add("languageCustomItemValue IS NOT NULL"); - if ($this->hasDisabledCustomValue) $this->objectList->getConditionBuilder()->add("languageUseCustomValue = ?", [0]); + if ($this->hasCustomValue || $this->hasDisabledCustomValue || $this->hasRecentlyDisabledCustomValue) $this->objectList->getConditionBuilder()->add("languageCustomItemValue IS NOT NULL"); + if ($this->hasDisabledCustomValue || $this->hasRecentlyDisabledCustomValue) $this->objectList->getConditionBuilder()->add("languageUseCustomValue = ?", [0]); + if ($this->hasRecentlyDisabledCustomValue) $this->objectList->getConditionBuilder()->add("languageCustomItemDisableTime >= ?", [TIME_NOW - 86400 * 7]); } /** @@ -152,6 +160,7 @@ class LanguageItemListPage extends SortablePage { 'languageItemValue' => $this->languageItemValue, 'hasCustomValue' => $this->hasCustomValue, 'hasDisabledCustomValue' => $this->hasDisabledCustomValue, + 'hasRecentlyDisabledCustomValue' => $this->hasRecentlyDisabledCustomValue, 'availableLanguages' => $this->availableLanguages, 'availableLanguageCategories' => $this->availableLanguageCategories ]); diff --git a/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php b/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php index 14778c63a0..c8819c2b8d 100644 --- a/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php @@ -2,6 +2,7 @@ namespace wcf\acp\page; use wcf\data\package\PackageList; use wcf\page\SortablePage; +use wcf\system\language\LanguageFactory; use wcf\system\WCF; /** @@ -72,6 +73,7 @@ class PackageListPage extends SortablePage { parent::assignVariables(); WCF::getTPL()->assign([ + 'recentlyDisabledCustomValues' => LanguageFactory::getInstance()->countRecentlyDisabledCustomValues(), 'packageID' => $this->packageID ]); } diff --git a/wcfsetup/install/files/lib/data/language/item/LanguageItem.class.php b/wcfsetup/install/files/lib/data/language/item/LanguageItem.class.php index db334b7b44..c4c5a0c659 100644 --- a/wcfsetup/install/files/lib/data/language/item/LanguageItem.class.php +++ b/wcfsetup/install/files/lib/data/language/item/LanguageItem.class.php @@ -19,6 +19,8 @@ use wcf\data\DatabaseObject; * @property-read integer $languageItemOriginIsSystem is `1` if the language item has been delivered by a package, otherwise `0` (for example, if language item has been created for i18n content) * @property-read integer $languageCategoryID id of the language category the language item belongs to * @property-read integer|null $packageID id of the package the which delivers the language item or with which the language item is associated + * @property-read string $languageItemOldValue previous default value of the language item + * @property-read integer $languageCustomItemDisableTime the timestamp at which the custom version has been disabled due to a change to the original value */ class LanguageItem extends DatabaseObject { /** diff --git a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php index 091086e981..4f3a675a33 100644 --- a/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php +++ b/wcfsetup/install/files/lib/system/language/LanguageFactory.class.php @@ -324,4 +324,19 @@ class LanguageFactory extends SingletonFactory { public function multilingualismEnabled() { return $this->cache['multilingualismEnabled']; } + + /** + * Returns the number of phrases that have been automatically disabled in the past 7 days. + * + * @return integer + */ + public function countRecentlyDisabledCustomValues() { + $sql = "SELECT COUNT(*) AS count + FROM wcf".WCF_N."_language_item + WHERE languageCustomItemDisableTime >= ?"; + $statement = WCF::getDB()->prepareStatement($sql, 1); + $statement->execute([TIME_NOW - 86400 * 7]); + + return $statement->fetchColumn(); + } } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 2b5ed05647..5245a0f9c3 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -662,6 +662,8 @@ languageCustomItemDisableTime|date}.]]> + + automatisch deaktiviert.]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 4cce6256bb..4e73ed810f 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -658,6 +658,8 @@ Examples for medium ID detection: languageCustomItemDisableTime|date}.]]> + + automatically disabled recently.]]> -- 2.20.1