Added offline mode
authorMarcel Werk <burntime@woltlab.com>
Mon, 19 Nov 2012 16:51:10 +0000 (17:51 +0100)
committerMarcel Werk <burntime@woltlab.com>
Mon, 19 Nov 2012 16:51:10 +0000 (17:51 +0100)
com.woltlab.wcf/template/offline.tpl [new file with mode: 0644]
com.woltlab.wcf/template/userNotice.tpl
com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/lib/system/request/Request.class.php
wcfsetup/install/files/lib/system/request/RequestHandler.class.php
wcfsetup/install/lang/de.xml

diff --git a/com.woltlab.wcf/template/offline.tpl b/com.woltlab.wcf/template/offline.tpl
new file mode 100644 (file)
index 0000000..fe6eed5
--- /dev/null
@@ -0,0 +1,21 @@
+{include file='documentHeader'}
+
+<head>
+       <title>{lang}wcf.global.error.title{/lang} - {PAGE_TITLE|language}</title>
+       
+       {include file='headInclude'}
+</head>
+
+<body{if $templateName|isset} id="tpl{$templateName|ucfirst}"{/if}>
+
+{include file='header'}
+       
+<div class="warning">
+       <p><strong>{lang}wcf.page.offline{/lang}</strong></p>
+       <p>{if OFFLINE_MESSAGE_ALLOW_HTML}{@OFFLINE_MESSAGE}{else}{@OFFLINE_MESSAGE|htmlspecialchars|nl2br}{/if}</p>
+</div>
+       
+{include file='footer'}
+
+</body>
+</html>
\ No newline at end of file
index 24f7638205afeea75bba9e7f73eea88bcc3c07f4..782c83e4240f4cef373a653cf1d73ce01d99a357 100644 (file)
@@ -1,3 +1,10 @@
 <div class="userNotice">
+       {if OFFLINE && $__wcf->session->getPermission('admin.general.canViewPageDuringOfflineMode')}
+               <div class="warning">
+                       <p><strong>{lang}wcf.page.offline{/lang}</strong></p>
+                       <p>{if OFFLINE_MESSAGE_ALLOW_HTML}{@OFFLINE_MESSAGE}{else}{@OFFLINE_MESSAGE|htmlspecialchars|nl2br}{/if}</p>
+               </div>
+       {/if}
+       
        {event name='userNotice'}
 </div>
\ No newline at end of file
index 45c703cf7554e849b8eb00dba67ad7bf3072596f..91ad710dc43372ed1439a64f378e6dcd62caf0bd 100644 (file)
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                        </option>
+                       <option name="admin.general.canViewPageDuringOfflineMode">
+                               <categoryname>admin.general</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <admindefaultvalue>1</admindefaultvalue>
+                       </option>
                        <option name="admin.system.canEditOption">
                                <categoryname>admin.system</categoryname>
                                <optiontype>boolean</optiontype>
index 9562a0cfd975e272f1b8212c05fd4a9b55426955..0455a4260b8d8ac5b015cdd7c882153fb4f64bcb 100644 (file)
@@ -103,4 +103,17 @@ class Request {
        public function getRequestObject() {
                return $this->requestObject;
        }
+       
+       /**
+        * Returns true, if the requested page is avaiable during the offline mode.
+        * 
+        * @return      boolean
+        */
+       public function isAvailableDuringOfflineMode() {
+               if (defined($this->className . '::AVAILABLE_DURING_OFFLINE_MODE') && constant($this->className . '::AVAILABLE_DURING_OFFLINE_MODE')) {
+                       return true;
+               }
+               
+               return false;
+       }
 }
index 43c3f0a064cbac73b3ac437599f6cf83d736ff96..0a50d541823b9510419ce23ed246a1309f2e5735 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\system\request;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\SystemException;
 use wcf\system\SingletonFactory;
+use wcf\system\WCF;
 
 /**
  * Handles http requests.
@@ -43,6 +44,14 @@ class RequestHandler extends SingletonFactory {
                // build request
                $this->buildRequest($application);
                
+               // handle offline mode
+               if (!$isACPRequest && defined('OFFLINE') && OFFLINE) {
+                       if (!WCF::getSession()->getPermission('admin.general.canViewPageDuringOfflineMode') && !$this->activeRequest->isAvailableDuringOfflineMode()) {
+                               WCF::getTPL()->display('offline');
+                               exit;
+                       }
+               }
+               
                // start request
                $this->activeRequest->execute();
        }
index 3e1add820baaf429c843c306568a8870aafdb43e..d7d1a68de8cd564f3222455a7442dbaf506e9af1 100644 (file)
                
        <category name="wcf.page">
                <item name="wcf.page.pageNo"><![CDATA[Seite {#$pageNo}]]></item>
+               <item name="wcf.page.offline"><![CDATA[Die Seite befindet sich zur Zeit {if OFFLINE_MESSAGE != ''}aus folgenden GrĂ¼nden im Wartungsmodus:{else}im Wartungsmodus.{/if}]]></item>
        </category>
        
        <category name="wcf.sitemap">