Filter by recently disabled, added warning to package list
authorAlexander Ebert <ebert@woltlab.com>
Thu, 16 Mar 2017 12:42:58 +0000 (13:42 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 16 Mar 2017 12:42:58 +0000 (13:42 +0100)
See #2221

wcfsetup/install/files/acp/templates/languageItemList.tpl
wcfsetup/install/files/acp/templates/packageList.tpl
wcfsetup/install/files/lib/acp/page/LanguageItemListPage.class.php
wcfsetup/install/files/lib/acp/page/PackageListPage.class.php
wcfsetup/install/files/lib/data/language/item/LanguageItem.class.php
wcfsetup/install/files/lib/system/language/LanguageFactory.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 0fd882169d8543c4e262320bba014ce18f7c8fad..68cc68b7d6e9ea16318b850614b86ac85c99dd8f 100644 (file)
@@ -65,6 +65,7 @@
                                        <input type="text" id="languageItemValue" name="languageItemValue" value="{$languageItemValue}" placeholder="{lang}wcf.acp.language.item.value{/lang}" class="long">
                                        <label><input type="checkbox" name="hasCustomValue" value="1"{if $hasCustomValue == 1} checked{/if}> {lang}wcf.acp.language.item.customValues{/lang}</label>
                                        <label><input type="checkbox" name="hasDisabledCustomValue" value="1"{if $hasDisabledCustomValue == 1} checked{/if}> {lang}wcf.acp.language.item.disabledCustomValues{/lang}</label>
+                                       <label><input type="checkbox" name="hasRecentlyDisabledCustomValue" value="1"{if $hasRecentlyDisabledCustomValue == 1} checked{/if}> {lang}wcf.acp.language.item.recentlyDisabledCustomValues{/lang}</label>
                                </dd>
                        </dl>
                        
index 4a18c120204ef5f3d12716caccf56e3286d8a53c..6e82db6c1b534fef094656b1db7fd7a9e1e753d4 100644 (file)
        {/hascontent}
 </header>
 
+{if $recentlyDisabledCustomValues > 0}
+       <p class="warning">{lang}wcf.acp.language.item.hasRecentlyDisabledCustomValues{/lang}</p>
+{/if}
+
 {hascontent}
        <div class="paginationTop">
                {content}{pages print=true assign=pagesLinks controller='PackageList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content}
index b5f1a4111afa443e381c249915c51c0c2c46f30b..dbabb6d3390f9e91939e26def7c499ca479266af 100644 (file)
@@ -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
                ]);
index 14778c63a0cd6b5047dbee241aeb005754b70a8b..c8819c2b8de4eea5dfd8f278b8c3ec12a9ce797d 100644 (file)
@@ -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
                ]);
        }
index db334b7b441b9fa0785d1cfaf397474e2df4c0ce..c4c5a0c6599cf6d4aa60052f74d12270d0a0f217 100644 (file)
@@ -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 {
        /**
index 091086e981fdfdfee3e86f3223756d7791eb1a6c..4f3a675a330a51a63f2bbbb73299657be25c4876 100644 (file)
@@ -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();
+       }
 }
index 2b5ed056470ac8e8d71a5b3b87db1020048de9a5..5245a0f9c3622234661de3378f69344bb6b66d53 100644 (file)
                <item name="wcf.acp.language.add.source.description"><![CDATA[Die ausgewählte Sprache wird als Vorlage benutzt. Alle Sprachvariablen werden in die neue Sprache kopiert.]]></item>
                <item name="wcf.acp.language.item.oldValue"><![CDATA[Ursprünglicher Inhalt]]></item>
                <item name="wcf.acp.language.item.oldValue.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} veränderte Fassung basierte auf dem unten stehenden Stand vom {$item->languageCustomItemDisableTime|date}.]]></item>
+               <item name="wcf.acp.language.item.recentlyDisabledCustomValues"><![CDATA[Kürzlich deaktivierte Inhalte finden (Letzten 7 Tagen)]]></item>
+               <item name="wcf.acp.language.item.hasRecentlyDisabledCustomValues"><![CDATA[{if $recentlyDisabledCustomValues == 1}Eine{else}{#$recentlyDisabledCustomValues}{/if} individuell angepasste {if $recentlyDisabledCustomValues == 1}Sprachvariable wurde{else}Sprachvariablen wurden{/if} vor Kurzem <a href="{link controller='LanguageItemList' hasRecentlyDisabledCustomValue=1}{/link}">automatisch deaktiviert</a>.]]></item>
        </category>
        
        <category name="wcf.acp.masterPassword">
index 4cce6256bb7f6ae6e89a82d4d04ed2fa1302ee68..4e73ed810f8d2e2ef0dd147a0d98568aea40bd46 100644 (file)
@@ -658,6 +658,8 @@ Examples for medium ID detection:
                <item name="wcf.acp.language.add.source.description"><![CDATA[The selected language will be used as origin, all phrases will be copied into the new language.]]></item>
                <item name="wcf.acp.language.item.oldValue"><![CDATA[Original Content]]></item>
                <item name="wcf.acp.language.item.oldValue.description"><![CDATA[Your custom value was based on the original content that has changed on {$item->languageCustomItemDisableTime|date}.]]></item>
+               <item name="wcf.acp.language.item.recentlyDisabledCustomValues"><![CDATA[Recently disabled customized values (past 7 days)]]></item>
+               <item name="wcf.acp.language.item.hasRecentlyDisabledCustomValues"><![CDATA[{if $recentlyDisabledCustomValues == 1}One{else}{#$recentlyDisabledCustomValues}{/if} customized {if $recentlyDisabledCustomValues == 1}phrase has been{else}phrases have been{/if} <a href="{link controller='LanguageItemList' hasRecentlyDisabledCustomValue=1}{/link}">automatically disabled</a> recently.]]></item>
        </category>
        
        <category name="wcf.acp.masterPassword">