Message sidebar improvements
authorMarcel Werk <burntime@woltlab.com>
Mon, 3 Jun 2013 18:22:24 +0000 (20:22 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 3 Jun 2013 18:22:24 +0000 (20:22 +0200)
com.woltlab.wcf/template/messageSidebar.tpl
wcfsetup/install/files/lib/data/user/UserProfile.class.php
wcfsetup/install/files/lib/data/user/option/ViewableUserOption.class.php
wcfsetup/install/files/lib/system/option/UseroptionsOptionType.class.php
wcfsetup/install/files/style/message.less

index 2192df9c38a9c47dd0373ac2d4b7405410bdf411..475f48fd70e40451a15e92554d09fba4fce8bcc0 100644 (file)
@@ -85,7 +85,7 @@
                                                                {foreach from=$__sidebarUserOptions item='__sidebarUserOption'}
                                                                        {if $userProfile->getUserOption($__sidebarUserOption)}
                                                                                <dt>{lang}wcf.user.option.{$__sidebarUserOption}{/lang}</dt>
-                                                                               <dd{if $__sidebarUserOption == 'location'} itemprop="locality"{/if}>{$userProfile->getUserOption($__sidebarUserOption)}</dd>
+                                                                               <dd{if $__sidebarUserOption == 'location'} itemprop="locality"{/if}>{@$userProfile->getFormattedUserOption($__sidebarUserOption)}</dd>
                                                                        {/if}
                                                                {/foreach}
                                                        {/if}
index da7b8acea5f70d05c25647ebfbfa778b562f5c32..9fb2b8c9f2d3e95f06b91da0d5d276f9eb618714 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\data\user;
 use wcf\data\user\avatar\DefaultAvatar;
 use wcf\data\user\avatar\Gravatar;
 use wcf\data\user\avatar\UserAvatar;
+use wcf\data\user\option\ViewableUserOption;
 use wcf\data\user\online\UserOnline;
 use wcf\data\user\rank\UserRank;
 use wcf\data\DatabaseObjectDecorator;
@@ -694,4 +695,20 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider
        public function getSignature() {
                return SignatureCache::getInstance()->getSignature($this->getDecoratedObject());
        }
+       
+       /**
+        * Returns the formatted value of the user option with the given name.
+        *
+        * @param       string          $name
+        * @return      mixed
+        */
+       public function getFormattedUserOption($name) {
+               // get value
+               $value = $this->getUserOption($name);
+               if (!$value) return '';
+               
+               $option = ViewableUserOption::getUserOption($name);
+               $option->setOptionValue($this->getDecoratedObject());
+               return $option->optionValue;
+       }
 }
index bed564e892710da77a051bf006c41e2f212d54f1..e2f0e09258db38da04f087071ea7c323574d2dfc 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\data\user\option;
 use wcf\data\user\User;
 use wcf\data\DatabaseObjectDecorator;
+use wcf\system\cache\builder\UserOptionCacheBuilder;
 use wcf\system\exception\SystemException;
 use wcf\util\ClassUtil;
 use wcf\util\StringUtil;
@@ -28,6 +29,12 @@ class ViewableUserOption extends DatabaseObjectDecorator {
         */
        public static $outputObjects = array();
        
+       /**
+        * cached user options
+        * @var array<wcf\data\user\option\ViewableUserOption>
+        */
+       public static $userOptions = array();
+       
        /**
         * user option value
         * @var string
@@ -75,4 +82,19 @@ class ViewableUserOption extends DatabaseObjectDecorator {
                
                return self::$outputObjects[$this->outputClass];
        }
+       
+       /**
+        * Gets user option by name
+        * 
+        * @param       string          $name
+        * @return      wcf\data\user\option\ViewableUserOption
+        */
+       public static function getUserOption($name) {
+               if (!isset(self::$userOptions[$name])) {
+                       $options = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
+                       self::$userOptions[$name] = new ViewableUserOption($options[$name]);
+               }
+               
+               return self::$userOptions[$name];
+       }
 }
index 33240446612dd51f68cb5797b522dd6482e8648b..00416274bea20fdddf167622f74c42476d340611 100644 (file)
@@ -67,8 +67,7 @@ class UseroptionsOptionType extends AbstractOptionType {
                        $sql = "SELECT  optionName
                                FROM    wcf".WCF_N."_user_option
                                WHERE   categoryName LIKE 'profile%'
-                                       AND optionType <> 'boolean'
-                                       AND outputClass = ''";
+                                       AND optionType <> 'boolean'";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute();
                        while ($row = $statement->fetchArray()) {
index 8e6636525d9f50d31625fc01e5fd4871b054e898..2e021c3185729bf24012e93ba0803cf3f29148d4 100644 (file)
                
                .dataList {
                        > dt {
-                               width: 50%;
+                               width: 45%;
                        }
                        
                        > dd {
-                               margin-left: 53%;
+                               margin-left: 48%;
+                               word-wrap: break-word;
                        }
                }
        }