From 17c1413d736e559e04122681a5b2b0e21bdddda5 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Thu, 31 Jul 2014 16:14:55 +0200 Subject: [PATCH] add "not use mobile browser" condition --- .../UserMobileBrowserCondition.class.php | 62 ++++++++++++++----- wcfsetup/install/lang/de.xml | 5 +- wcfsetup/install/lang/en.xml | 5 +- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php index 715cc682ff..2f6f58219c 100644 --- a/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php @@ -1,33 +1,47 @@ * @package com.woltlab.wcf * @subpackage system.condition * @category Community Framework */ -class UserMobileBrowserCondition extends AbstractCondition implements IContentCondition { +class UserMobileBrowserCondition extends AbstractSingleFieldCondition implements IContentCondition { + /** + * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + */ + protected $label = 'wcf.user.condition.mobileBrowser'; + /** * 1 if mobile browser checkbox is checked * @var integer */ protected $usesMobileBrowser = 0; + /** + * 1 if not use mobile browser checkbox is checked + * @var integer + */ + protected $usesNoMobileBrowser = 0; + /** * @see \wcf\system\condition\ICondition::getData() */ public function getData() { - if ($this->usesMobileBrowser) { + if ($this->usesMobileBrowser || $this->usesNoMobileBrowser) { return array( - 'usesMobileBrowser' => 1 + // if notUseMobileBrowser is selected usesMobileBrowser is 0 + // otherwise notUseMobileBrowser is 1 + 'usesMobileBrowser' => $this->usesMobileBrowser ); } @@ -37,20 +51,22 @@ class UserMobileBrowserCondition extends AbstractCondition implements IContentCo /** * @see \wcf\system\condition\ICondition::getHTML() */ - public function getHTML() { - $label = WCF::getLanguage()->get('wcf.user.condition.usesMobileBrowser'); - $checked = ''; + public function getFieldElement() { + $usesMobileBrowserLabel = WCF::getLanguage()->get('wcf.user.condition.mobileBrowser.usesMobileBrowser'); + $usesNoMobileBrowserLabel = WCF::getLanguage()->get('wcf.user.condition.mobileBrowser.usesNoMobileBrowser'); + $usesMobileBrowserChecked = ''; if ($this->usesMobileBrowser) { - $checked = ' checked="checked"'; + $usesMobileBrowserChecked = ' checked="checked"'; + } + + $usesNoMobileBrowserChecked = ''; + if ($this->usesNoMobileBrowser) { + $usesNoMobileBrowserChecked = ' checked="checked"'; } return << -
-
- -
- + + HTML; } @@ -59,6 +75,7 @@ HTML; */ public function readFormParameters() { if (isset($_POST['usesMobileBrowser'])) $this->usesMobileBrowser = 1; + if (isset($_POST['usesNoMobileBrowser'])) $this->usesNoMobileBrowser = 1; } /** @@ -66,19 +83,32 @@ HTML; */ public function reset() { $this->usesMobileBrowser = 0; + $this->usesNoMobileBrowser = 0; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @see \wcf\system\condition\ICondition::setData() */ public function setData(Condition $condition) { $this->usesMobileBrowser = $condition->usesMobileBrowser; + $this->usesNoMobileBrowser = !$condition->usesMobileBrowser; + } + + /** + * @see \wcf\system\condition\ICondition::validate() + */ + public function validate() { + if ($this->usesMobileBrowser && $this->usesNoMobileBrowser) { + $this->errorMessage = 'wcf.user.condition.mobileBrowser.usesMobileBrowser.error.conflict'; + + throw new UserInputException('mobileBrowser', 'conflict'); + } } /** * @see \wcf\system\condition\IContentCondition::showContent() */ public function showContent(Condition $condition) { - return UserUtil::usesMobileBrowser(); + return (($condition->usesMobileBrowser && UserUtil::usesMobileBrowser()) || (!$condition->usesMobileBrowser && !UserUtil::usesMobileBrowser())); } } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 49d6c4dc5b..c7a332e3ab 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2896,6 +2896,10 @@ Sollten Sie sich nicht auf der Website: {@PAGE_TITLE|language} angemeldet haben, + + + + @@ -2911,7 +2915,6 @@ Sollten Sie sich nicht auf der Website: {@PAGE_TITLE|language} angemeldet haben, - diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 6467b5c46f..b9f9663fb7 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2755,6 +2755,10 @@ You can safely ignore this email if you did not register with the website: {@PAG + + + + @@ -2770,7 +2774,6 @@ You can safely ignore this email if you did not register with the website: {@PAG - -- 2.20.1