$(function() {
new WCF.Action.Delete('wcf\\data\\reaction\\type\\ReactionTypeAction', '.reactionTypeRow');
- new WCF.Action.Toggle('wcf\\data\\reaction\\type\\ReactionTypeAction', '.reactionTypeRow');
});
</script>
{/if}
<span class="statusDisplay sortableButtonContainer">
<span class="icon icon16 fa-arrows sortableNodeHandle"></span>
- <span class="icon icon16 fa-{if !$reactionType->isDisabled}check-{/if}square-o jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if $reactionType->isDisabled}enable{else}disable{/if}{/lang}" data-object-id="{@$reactionType->reactionTypeID}"></span>
<a href="{link controller='ReactionTypeEdit' id=$reactionType->reactionTypeID}{/link}"><span title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip icon icon16 fa-pencil"></span></a>
<span title="{lang}wcf.global.button.delete{/lang}" class="jsDeleteButton pointer jsTooltip icon icon16 fa-times" data-object-id="{@$reactionType->reactionTypeID}" data-confirm-message-html="{lang __encode=true}wcf.acp.reactionType.delete.confirmMessage{/lang}"></span>
use wcf\data\reaction\type\ReactionTypeList;
use wcf\form\AbstractFormBuilderForm;
use wcf\system\form\builder\container\FormContainer;
-use wcf\system\form\builder\field\IsDisabledFormField;
use wcf\system\form\builder\field\ShowOrderFormField;
use wcf\system\form\builder\field\TitleFormField;
use wcf\system\form\builder\field\UploadFormField;
ShowOrderFormField::create()
->description('wcf.acp.reactionType.showOrder.description')
->required()
- ->options(new ReactionTypeList()),
- IsDisabledFormField::create()
- ->label('wcf.acp.reactionType.isDisabled')
+ ->options(new ReactionTypeList())
]);
$iconContainer = FormContainer::create('imageSection')
$data = [];
foreach ($likeList as $item) {
- if ($item->getReactionType()->isDisabled) continue;
-
// we cast the reactionTypeID to a string, so that we can sort the array
if (!isset($data[(string)$item->getReactionType()->reactionTypeID])) {
$data[(string)$item->getReactionType()->reactionTypeID] = new GroupedUserList($item->getReactionType()->renderIcon() . ' ' . StringUtil::encodeHTML($item->getReactionType()->getTitle()));
$this->reactionType = ReactionTypeCache::getInstance()->getReactionTypeByID($this->parameters['reactionTypeID']);
- if (!$this->reactionType->reactionTypeID || $this->reactionType->isDisabled) {
+ if (!$this->reactionType->reactionTypeID) {
throw new IllegalLinkException();
}
* @property-read string $title
* @property-read integer $showOrder position of the reaction type in relation to the other reaction types
* @property-read string $iconFile the file location of the icon
- * @property-read integer $isDisabled is `1` if the reaction type is disabled and thus not shown, otherwise `0`
*/
class ReactionType extends DatabaseObject implements ITitledObject {
/**
namespace wcf\data\reaction\type;
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
-use wcf\data\IToggleAction;
-use wcf\data\TDatabaseObjectToggle;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\file\upload\UploadFile;
* @method ReactionTypeEditor[] getObjects()
* @method ReactionTypeEditor getSingleObject()
*/
-class ReactionTypeAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction {
- use TDatabaseObjectToggle;
-
+class ReactionTypeAction extends AbstractDatabaseObjectAction implements ISortableAction {
/**
* @inheritDoc
*/
*/
class ReactionTypeCache extends SingletonFactory {
/**
- * Contains all reaction types.
+ * Contains reaction types.
* @var ReactionType[]
*/
protected $reactionTypes;
- /**
- * Contains all enabled reaction types.
- * @var ReactionType[]
- */
- protected $enabledReactionTypes;
-
/**
* @inheritDoc
*/
protected function init() {
$this->reactionTypes = ReactionTypeCacheBuilder::getInstance()->getData();
- $this->enabledReactionTypes = ReactionTypeCacheBuilder::getInstance()->getData(['onlyEnabled' => 1]);
}
/**
public function getReactionTypes() {
return $this->reactionTypes;
}
-
- /**
- * Return all enabled reaction types.
- *
- * @return ReactionType[]
- */
- public function getEnabledReactionTypes() {
- return $this->enabledReactionTypes;
- }
-
+
/**
* Resets the cache for the trophies.
*/
public function clearCache() {
ReactionTypeCacheBuilder::getInstance()->reset();
- ReactionTypeCacheBuilder::getInstance()->reset(['onlyEnabled' => 1]);
}
}
* @package WoltLabSuite\Core\Data\Reaction\Type
* @since 5.2
*
- * @mixin ReactionType
+ * @method static ReactionType create(array $parameters = [])
+ * @method ReactionType getDecoratedObject()
+ * @mixin ReactionType
*/
class ReactionTypeEditor extends DatabaseObjectEditor implements IEditableCachedObject {
/**
*/
public function rebuild(array $parameters) {
$reactionTypeList = new ReactionTypeList();
-
- if (isset($parameters['onlyEnabled']) && $parameters['onlyEnabled']) {
- $reactionTypeList->getConditionBuilder()->add('isDisabled = ?', [0]);
- }
-
$reactionTypeList->sqlOrderBy = 'showOrder ASC';
$reactionTypeList->readObjects();
<?php
namespace wcf\system\importer;
+use wcf\data\language\item\LanguageItemEditor;
use wcf\data\like\Like;
+use wcf\data\reaction\type\ReactionType;
+use wcf\data\reaction\type\ReactionTypeEditor;
+use wcf\system\language\LanguageFactory;
use wcf\system\reaction\ReactionHandler;
use wcf\system\WCF;
*/
protected $objectTypeID = 0;
+ /**
+ * @var integer|null
+ */
+ protected static $dislikeReactionTypeID;
+
/**
* @inheritDoc
*/
if ($data['likeValue'] == 1) {
$data['reactionTypeID'] = ReactionHandler::getInstance()->getFirstReactionTypeID();
}
+ else {
+ $data['reactionTypeID'] = self::getDislikeReactionTypeID();
+ }
}
else {
$data['reactionTypeID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.reactionType', $data['reactionTypeID']);
}
- if ($data['reactionTypeID'] === null) {
+ if (empty($data['reactionTypeID'])) {
return 0;
}
return 0;
}
+
+ /**
+ * @return integer
+ */
+ protected static function getDislikeReactionTypeID() {
+ if (self::$dislikeReactionTypeID === null) {
+ $sql = "SELECT reactionTypeID FROM wcf" . WCF_N . "_reaction_type WHERE iconFile = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(['thumbsDown.svg']);
+ $reaction = $statement->fetchObject(ReactionType::class);
+ if ($reaction === null) {
+ $sql = "SELECT MAX(showOrder) FROM wcf" . WCF_N . "_reaction_type";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute();
+ $showOrder = $statement->fetchColumn();
+
+ $reaction = ReactionTypeEditor::create(['iconFile' => 'thumbsDown.svg', 'showOrder' => $showOrder + 1]);
+
+ $sql = "SELECT languageCategoryID
+ FROM wcf".WCF_N."_language_category
+ WHERE languageCategory = ?";
+ $statement = WCF::getDB()->prepareStatement($sql, 1);
+ $statement->execute(['wcf.reactionType']);
+ $languageCategoryID = $statement->fetchSingleColumn();
+
+ foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
+ LanguageItemEditor::create([
+ 'languageID' => $language->languageID,
+ 'languageItem' => 'wcf.reactionType.title' . $reaction->reactionTypeID,
+ 'languageItemValue' => ($language->getFixedLanguageCode() === 'de' ? 'Gefällt mir nicht' : 'Dislike'),
+ 'languageCategoryID' => $languageCategoryID,
+ 'packageID' => 1,
+ ]);
+ }
+
+ $editor = new ReactionTypeEditor($reaction);
+ $editor->update(['title' => 'wcf.reactionType.title' . $reaction->reactionTypeID]);
+ }
+
+ self::$dislikeReactionTypeID = $reaction->reactionTypeID;
+ }
+
+ return self::$dislikeReactionTypeID;
+ }
}
* @return string
*/
public function getReactionsJSVariable() {
- $reactions = ReactionTypeCache::getInstance()->getEnabledReactionTypes();
+ $reactions = ReactionTypeCache::getInstance()->getReactionTypes();
$returnValues = [];
* @return ReactionType[]
*/
public function getReactionTypes() {
- return ReactionTypeCache::getInstance()->getEnabledReactionTypes();
+ return ReactionTypeCache::getInstance()->getReactionTypes();
}
/**
static $firstReactionType;
if ($firstReactionType === null) {
- $reactionTypes = ReactionTypeCache::getInstance()->getEnabledReactionTypes();
+ $reactionTypes = ReactionTypeCache::getInstance()->getReactionTypes();
ReactionType::sort($reactionTypes, 'showOrder');
$firstReactionType = reset($reactionTypes);
if (MODULE_LIKE) {
$sql = "UPDATE wcf".WCF_N."_user user_table SET";
- $reactionTypeIDs = array_keys(ReactionTypeCache::getInstance()->getEnabledReactionTypes());
+ $reactionTypeIDs = array_keys(ReactionTypeCache::getInstance()->getReactionTypes());
if (!empty($reactionTypeIDs)) {
$sql .= " likesReceived = (
SELECT COUNT(*)
<category name="wcf.acp.reactionType">
<item name="wcf.acp.reactionType.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Reaktions-Typen <span class="confirmationObject">{$reactionType->getTitle()}</span> wirklich löschen?]]></item>
<item name="wcf.acp.reactionType.type"><![CDATA[Reaktions-Typ]]></item>
- <item name="wcf.acp.reactionType.isDisabled"><![CDATA[Reaktion deaktivieren]]></item>
<item name="wcf.acp.reactionType.image"><![CDATA[Reaktions-Datei]]></item>
<item name="wcf.acp.reactionType.showOrder.description"><![CDATA[Der Reaktions-Typ wird nach dem ausgewählten Reaktions-Typ angezeigt.]]></item>
</category>
<item name="wcf.reactions.react"><![CDATA[Reagieren]]></item>
</category>
<category name="wcf.reactionType">
- <item name="wcf.reactionType.title1"><![CDATA[Gefällt mir!]]></item>
- <item name="wcf.reactionType.title2"><![CDATA[Danke!]]></item>
+ <item name="wcf.reactionType.title1"><![CDATA[Gefällt mir]]></item>
+ <item name="wcf.reactionType.title2"><![CDATA[Danke]]></item>
<item name="wcf.reactionType.title3"><![CDATA[Haha]]></item>
<item name="wcf.reactionType.title4"><![CDATA[Verwirrend]]></item>
<item name="wcf.reactionType.title5"><![CDATA[Traurig]]></item>
<category name="wcf.acp.reactionType">
<item name="wcf.acp.reactionType.delete.confirmMessage"><![CDATA[Do you really want to delete the reaction type <span class="confirmationObject">{$reactionType->getTitle()}</span>?]]></item>
<item name="wcf.acp.reactionType.type"><![CDATA[Reaction Type]]></item>
- <item name="wcf.acp.reactionType.isDisabled"><![CDATA[Disable Reaction]]></item>
<item name="wcf.acp.reactionType.image"><![CDATA[Reaction File]]></item>
<item name="wcf.acp.reactionType.showOrder.description"><![CDATA[The reaction type will be shown after the selected reaction type.]]></item>
</category>
</category>
<category name="wcf.reactionType">
<item name="wcf.reactionType.title1"><![CDATA[Like]]></item>
- <item name="wcf.reactionType.title2"><![CDATA[Thanks!]]></item>
+ <item name="wcf.reactionType.title2"><![CDATA[Thanks]]></item>
<item name="wcf.reactionType.title3"><![CDATA[Haha]]></item>
<item name="wcf.reactionType.title4"><![CDATA[Confused]]></item>
<item name="wcf.reactionType.title5"><![CDATA[Sad]]></item>
reactionTypeID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255),
showOrder INT(10) NOT NULL DEFAULT 0,
- iconFile MEDIUMTEXT,
- isDisabled TINYINT(1) NOT NULL DEFAULT 0
+ iconFile MEDIUMTEXT
);
DROP TABLE IF EXISTS wcf1_registry;