Fixed multiple issues
authorMarcel Werk <burntime@woltlab.com>
Thu, 1 Mar 2012 13:34:39 +0000 (14:34 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 1 Mar 2012 13:34:39 +0000 (14:34 +0100)
com.woltlab.wcf/template/footer.tpl
com.woltlab.wcf/template/header.tpl
wcfsetup/install/files/lib/data/user/option/ViewableUserOption.class.php
wcfsetup/install/files/lib/system/option/DateOptionType.class.php
wcfsetup/install/files/lib/util/DateUtil.class.php

index 9c7ae20221edea0ff288731d4c7d73af92a8c66d..b1732bf3d94db0666429abd2987d301e9ea2fd05 100644 (file)
@@ -14,7 +14,7 @@
                                {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}
index 3f84461a9167c819024065a3f97585810f711f62..03abcb10f2bc69cabca05d2b52be1ab93a7e3c9b 100644 (file)
@@ -38,7 +38,7 @@
                        {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>
index fa1cfab9724146b8f34585d908eaff17115af749..e1c1765f14c4115fb9fca39360c66a1c9f12757b 100644 (file)
@@ -35,8 +35,9 @@ class ViewableUserOption extends DatabaseObjectDecorator {
         * 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};
                
@@ -48,9 +49,9 @@ class ViewableUserOption extends DatabaseObjectDecorator {
                                $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);
index d18dd5fc71eae3d7cc22db4c05bcfdbbe5370ab4..dffe972f2b3ec01f60c72b215ae632fc842cecf6 100644 (file)
@@ -31,7 +31,7 @@ class DateOptionType extends TextOptionType {
        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');
                }
                
index 2a367060fa6097ab7312ed9a62922cb87e5734a6..06e1a490f10fa65fc478f2d7b79d329e480876e8 100644 (file)
@@ -250,4 +250,29 @@ class DateUtil {
        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;
+       }
 }