{include file='footerMenu'}
<ul>
- <li id="toTopLink" class="toTopLink"><a href="{@$__wcf->getAnchor('top')}" title="{lang}wcf.global.scrollUp{/lang}" class="jsTooltip"><img src="{icon size='S'}toTop{/icon}" alt="" /> <span class="invisible">{lang}wcf.global.scrollUp{/lang}</span></a></li>
+ <li id="toTopLink" class="toTopLink"><a href="{$__wcf->getAnchor('top')}" title="{lang}wcf.global.scrollUp{/lang}" class="jsTooltip"><img src="{icon size='S'}toTop{/icon}" alt="" /> <span class="invisible">{lang}wcf.global.scrollUp{/lang}</span></a></li>
{if SHOW_CLOCK}
<li><p><img src="{icon size='S'}time1{/icon}" alt="" /> <span>{@TIME_NOW|plainTime}</span></p></li>
{/if}
{include file='mainMenuSubMenu'}
<ul>
- <li id="toBottomLink" class="wcf-toBottomLink"><a href="{@$__wcf->getAnchor('bottom')}" title="{lang}wcf.global.scrollDown{/lang}" class="jsTooltip"><img src="{icon size='S'}toBottom{/icon}" alt="" /> <span class="invisible">{lang}wcf.global.scrollDown{/lang}</span></a></li>
+ <li id="toBottomLink" class="wcf-toBottomLink"><a href="{$__wcf->getAnchor('bottom')}" title="{lang}wcf.global.scrollDown{/lang}" class="jsTooltip"><img src="{icon size='S'}toBottom{/icon}" alt="" /> <span class="invisible">{lang}wcf.global.scrollDown{/lang}</span></a></li>
{event name='headerNavigation'}
</ul>
</nav>
* Sets option values for a specific user.
*
* @param wcf\data\user\User $user
+ * @param string $outputType
*/
- public function setOptionValue(User $user) {
+ public function setOptionValue(User $user, $outputType = 'normal') {
$userOption = 'userOption' . $this->optionID;
$optionValue = $user->{$userOption};
$this->outputData = $outputObj->getOutputData($user, $this->getDecoratedObject(), $optionValue);
}
- if ($this->outputType == 'normal') $this->optionValue = $outputObj->getOutput($user, $this->getDecoratedObject(), $optionValue);
- else if ($this->outputType == 'short') $this->optionValue = $outputObj->getShortOutput($user, $this->getDecoratedObject(), $optionValue);
- else $this->optionValue = $outputObj->getMediumOutput($user, $this->getDecoratedObject(), $optionValue);
+ if ($outputType == 'normal') $this->optionValue = $outputObj->getOutput($user, $this->getDecoratedObject(), $optionValue);
+ else if ($outputType == 'short') $this->optionValue = $outputObj->getShortOutput($user, $this->getDecoratedObject(), $optionValue);
+ else $outputType = $outputObj->getMediumOutput($user, $this->getDecoratedObject(), $optionValue);
}
else {
$this->optionValue = StringUtil::encodeHTML($optionValue);
public function validate(Option $option, $newValue) {
if (empty($newValue)) return;
- if (!preg_match('^(\d{4})-(\d{2})-(\d{2})$', $newValue, $match)) {
+ if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $newValue, $match)) {
throw new UserInputException($option->optionName, 'validationFailed');
}
public static function getAvailableTimezones() {
return self::$availableTimezones;
}
+
+ /**
+ * Calculates the age of a given date.
+ *
+ * @param string $date format YYYY-MM-DD
+ * @return integer
+ */
+ public static function getAge($date) {
+ // split date
+ $year = $month = $day = 0;
+ $value = explode('-', $date);
+ if (isset($value[0])) $year = intval($value[0]);
+ if (isset($value[1])) $month = intval($value[1]);
+ if (isset($value[2])) $day = intval($value[2]);
+
+ // calc
+ if ($year) {
+ $age = self::format(null, 'Y') - $year;
+ if (intval(self::format(null, 'n')) < intval($month)) $age--;
+ else if (intval(self::formatDate(null, 'j')) == intval($month) && self::formatDate(null, 'n') < intval($day)) $age--;
+ return $age;
+ }
+
+ return 0;
+ }
}