Restricting collapsible sidebar to right sidebars
authorAlexander Ebert <ebert@woltlab.com>
Mon, 22 Oct 2012 15:18:24 +0000 (17:18 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 22 Oct 2012 15:18:24 +0000 (17:18 +0200)
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/template/header.tpl
wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php

index b2c3b19e2ef9a19af402910d53633633681d0bf6..f3f26309ee1e52679625c8d99ac48d13dae28127 100644 (file)
@@ -6,5 +6,10 @@
                        <definitionname>com.woltlab.wcf.clipboardItem</definitionname>
                        <listclassname>wcf\data\user\UserList</listclassname>
                </type>
+               
+               <type>
+                       <name>com.woltlab.wcf.collapsibleSidebar</name>
+                       <definitionname>com.woltlab.wcf.collapsibleContent</definitionname>
+               </type>
        </import>
 </data>
\ No newline at end of file
index 2bf8862ba30b0735a2e71cdb495abd78e56033e2..f206a4793f03d1b511564e5aba2337e44b0a4aa7 100644 (file)
 <div id="main" class="layoutFluid{if $sidebarOrientation|isset && $sidebar|isset} sidebarOrientation{@$sidebarOrientation|ucfirst} clearfix{/if}">
        <div>
                {if $sidebar|isset}
-                       <aside class="sidebar">
+                       <aside class="sidebar"{if $sidebarOrientation|isset && $sidebarOrientation == 'right'} data-is-open="{if $sidebarCollapsed}0{else}1{/if}" data-sidebar-name="{$sidebarName}"{/if}>
                                {@$sidebar}
                        </aside>
+                       
+                       {if $sidebarOrientation|isset && $sidebarOrientation == 'right'}
+                               <script type="text/javascript">
+                                       //<![CDATA[
+                                       $(function() {
+                                               new WCF.Collapsible.Sidebar();
+                                       });
+                                       //]]>
+                               </script>
+                       {/if}
                {/if}
                                
                <section id="content" class="content clearfix">
index fa0e4de513f0b4fd62e73e986d158573116d6d57..a6736aaabf12fd61ac1d69c57ecf5a770010a4c5 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\user\collapsible\content;
 use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\exception\SystemException;
 use wcf\system\user\storage\UserStorageHandler;
 use wcf\system\SingletonFactory;
 use wcf\system\WCF;
@@ -44,6 +45,22 @@ class UserCollapsibleContentHandler extends SingletonFactory {
                }
        }
        
+       /**
+        * Returns true if given object is collapsed.
+        * 
+        * @param       string          $objectType
+        * @param       string          $objectID
+        * @return      boolean
+        */
+       public function isCollapsed($objectType, $objectID) {
+               $objectTypeID = $this->getObjectTypeID($objectType);
+               if ($objectTypeID === null) {
+                       throw new SystemException("Unknown object type '".$objectType."' for definition 'com.woltlab.wcf.collapsibleContent'");
+               }
+               
+               return in_array($objectID, $this->getCollapsedContent($objectTypeID));
+       }
+       
        /**
         * Returns the object type id based upon specified object type name. Returns
         * null, if object type is unknown.
@@ -115,7 +132,7 @@ class UserCollapsibleContentHandler extends SingletonFactory {
         * Marks content as collapsed.
         * 
         * @param       integer         $objectTypeID
-        * @param       integer         $objectID
+        * @param       string          $objectID
         */
        public function markAsCollapsed($objectTypeID, $objectID) {
                if (WCF::getUser()->userID) {
@@ -166,7 +183,7 @@ class UserCollapsibleContentHandler extends SingletonFactory {
         * Marks content as opened, thus removing the collapsed marking.
         * 
         * @param       integer         $objectTypeID
-        * @param       integer         $objectID
+        * @param       string          $objectID
         */
        public function markAsOpened($objectTypeID, $objectID) {
                if (WCF::getUser()->userID) {