Removed PAGE_URL option
authorAlexander Ebert <ebert@woltlab.com>
Wed, 17 Oct 2012 15:35:44 +0000 (17:35 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 17 Oct 2012 15:35:44 +0000 (17:35 +0200)
com.woltlab.wcf/option.xml
wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php
wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php
wcfsetup/install/files/lib/data/application/Application.class.php
wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php
wcfsetup/install/files/lib/system/request/LinkHandler.class.php
wcfsetup/install/files/lib/system/request/RouteHandler.class.php
wcfsetup/install/files/lib/util/HeaderUtil.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index e9579f2f030c22c6c3307f738c956952c5c319d9..ad3391db82e3d4f897fd48c27f6fbfc067bbd831 100644 (file)
                                <supporti18n>1</supporti18n>
                                <requirei18n>0</requirei18n>
                        </option>
-                       <option name="page_url">
-                               <categoryname>general.page</categoryname>
-                               <optiontype>text</optiontype>
-                       </option>
                        <option name="page_urls">
                                <categoryname>general.page</categoryname>
                                <optiontype>textarea</optiontype>
index efd00b7ad213607e9b1b228cc7e7ebc32380b9d9..314251b25bfe2f78f7c3131daf5619b9a6104ab2 100755 (executable)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\acp\action;
 use wcf\action\AbstractDialogAction;
+use wcf\data\application\Application;
 use wcf\data\package\installation\queue\PackageInstallationQueue;
 use wcf\system\cache\CacheHandler;
 use wcf\system\exception\IllegalLinkException;
@@ -111,15 +112,15 @@ class InstallPackageAction extends AbstractDialogAction {
                                }
                                        
                                // get domain path
-                               $sql = "SELECT  domainName, domainPath
+                               $sql = "SELECT  *
                                        FROM    wcf".WCF_N."_application
                                        WHERE   packageID = ?";
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute(array($packageID));
-                               $row = $statement->fetchArray();
+                               $application = new Application(null, $statement->fetchArray());
                                
                                // build redirect location
-                               $location = $row['domainName'] . $row['domainPath'] . 'acp/index.php/PackageList/' . SID_ARG_1ST;
+                               $location = $application->getPageURL() . 'acp/index.php/PackageList/' . SID_ARG_1ST;
                                
                                // show success
                                $this->data = array(
index bf96e4b3809d1034a2e585669e6b2a7718ba6049..266482f96f1b6185c67d5163435a2bde3edfd552 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\acp\action;
 use wcf\action\AbstractDialogAction;
+use wcf\data\application\Application;
 use wcf\data\package\installation\queue\PackageInstallationQueue;
 use wcf\data\package\installation\queue\PackageInstallationQueueEditor;
 use wcf\data\package\Package;
@@ -129,15 +130,15 @@ class UninstallPackageAction extends InstallPackageAction {
                        }
                                
                        // get domain path
-                       $sql = "SELECT  domainName, domainPath
+                       $sql = "SELECT  *
                                FROM    wcf".WCF_N."_application
                                WHERE   packageID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute(array($packageID));
-                       $row = $statement->fetchArray();
+                       $application = new Application(null, $statement->fetchArray());
                        
                        // build redirect location
-                       $location = $row['domainName'] . $row['domainPath'] . 'acp/index.php/PackageList/' . SID_ARG_1ST;
+                       $location = $application->getPageURL() . 'acp/index.php/PackageList/' . SID_ARG_1ST;
                        
                        // show success
                        $this->data = array(
index f31e465e93dd60ec433f9c4646a1ebca579de926..23916d4861e5587135e4bc64b531c2decc9a1c34 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\application;
 use wcf\data\DatabaseObject;
+use wcf\system\request\RouteHandler;
 
 /**
  * Represents an application.
@@ -27,4 +28,23 @@ class Application extends DatabaseObject {
         * @see wcf\data\DatabaseObject::$databaseTableIndexIsIdentity
         */
        protected static $databaseTableIndexIsIdentity = false;
+       
+       /**
+        * absolute page URL
+        * @var string
+        */
+       protected $pageURL = '';
+       
+       /**
+        * Returns absolute page URL.
+        * 
+        * @return      string
+        */
+       public function getPageURL() {
+               if (empty($this->pageURL)) {
+                       $this->pageURL = RouteHandler::getProtocol() . $this->domainName . $this->domainPath;
+               }
+               
+               return $this->pageURL;
+       }
 }
index 9041840629d438819b436b289ea9c09cd2125462..f4739f4bfa4c6236b26122f04aca455678a8a16b 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 namespace wcf\system\cache\builder;
 use wcf\data\application\group\ApplicationGroup;
+use wcf\data\application\Application;
+use wcf\data\application\ApplicationList;
 use wcf\data\package\Package;
 use wcf\data\package\PackageList;
-use wcf\data\application;
 use wcf\system\WCF;
 
 /**
@@ -40,11 +41,11 @@ class ApplicationCacheBuilder implements ICacheBuilder {
                
                // current application is not part of an application group
                if (!$row || ($row['groupID'] == 0) || $row['groupID'] === null) {
-                       $data['application'] = array($packageID => new application\Application($packageID));
+                       $data['application'] = array($packageID => new Application($packageID));
                }
                else {
                        // fetch applications
-                       $applicationList = new application\ApplicationList();
+                       $applicationList = new ApplicationList();
                        $applicationList->getConditionBuilder()->add("application.groupID = ?", array($row['groupID']));
                        $applicationList->sqlLimit = 0;
                        $applicationList->readObjects();
@@ -72,7 +73,7 @@ class ApplicationCacheBuilder implements ICacheBuilder {
                }
                
                // fetch wcf pseudo-application
-               $data['wcf'] = new application\Application(1);
+               $data['wcf'] = new Application(1);
                
                return $data;
        }
index e5b9d141a8b468a9a70b343ee7dff2d12d154d57..dc49a2a67ce9bfb6fb168f1552cfadefb5f1ad65 100644 (file)
@@ -279,7 +279,7 @@ class PackageInstallationDispatcher {
                        $this->package = null;
                        
                        if ($package->isApplication) {
-                               $host = RouteHandler::getHost();
+                               $host = StringUtil::replace(RouteHandler::getProtocol(), '', RouteHandler::getHost());
                                $path = RouteHandler::getPath(array('acp'));
                                
                                // insert as application
index 2e6ea02a68e9e85e51719ed7c711ccf20bca1eec..81c5a4076733bef1c572251cc327cab6b65fb5d5 100644 (file)
@@ -88,7 +88,7 @@ class LinkHandler extends SingletonFactory {
                                $application = ApplicationHandler::getInstance()->getPrimaryApplication();
                        }
                        
-                       $url = $application->domainName.$application->domainPath.(RequestHandler::getInstance()->isACPRequest() ? 'acp/' : '').$url;
+                       $url = $application->getPageURL() . (RequestHandler::getInstance()->isACPRequest() ? 'acp/' : '') . $url;
                }
                
                // append previously removed anchor
index a3e12a1dc8943fe7efd905527a430f5dd38624d5..e67879477eb3ccb6a47a56611ac8b53d69af5df6 100644 (file)
@@ -31,6 +31,18 @@ class RouteHandler extends SingletonFactory {
         */
        protected static $path = '';
        
+       /**
+        * HTTP protocol, either 'http://' or 'https://'
+        * @var string
+        */
+       protected static $protocol = '';
+       
+       /**
+        * HTTP encryption
+        * @var boolean
+        */
+       protected static $secure = null;
+       
        /**
         * list of available routes
         * @var array<wcf\system\request\Route>
@@ -153,6 +165,36 @@ class RouteHandler extends SingletonFactory {
                throw new SystemException("Unable to build route, no available route is satisfied.");
        }
        
+       /**
+        * Returns true, if this is a secure connection.
+        * 
+        * @return      true
+        */
+       public static function secureConnection() {
+               if (self::$secure === null) {
+                       self::$secure = false;
+                       
+                       if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443) {
+                               self::$secure = true;
+                       }
+               }
+               
+               return self::$secure;
+       }
+       
+       /**
+        * Returns HTTP protocol, either 'http://' or 'https://'.
+        * 
+        * @return      string
+        */
+       public static function getProtocol() {
+               if (empty(self::$protocol)) {
+                       self::$protocol = 'http' . (self::secureConnection() ? 's' : '') . '://';
+               }
+               
+               return self::$protocol;
+       }
+       
        /**
         * Returns protocol and domain name.
         * 
@@ -160,13 +202,7 @@ class RouteHandler extends SingletonFactory {
         */
        public static function getHost() {
                if (empty(self::$host)) {
-                       // get protocol and domain name
-                       $protocol = 'http://';
-                       if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443) {
-                               $protocol = 'https://';
-                       }
-                       
-                       self::$host = $protocol . $_SERVER['HTTP_HOST'];
+                       self::$host = self::getProtocol() . $_SERVER['HTTP_HOST'];
                }
                
                return self::$host;
index 1348d1b4f4458186bc4de626b72680d1e223d1fb..4444f07f2b7d56b5efac6d0248bd7cd9514af423 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\util;
+use wcf\system\request\RouteHandler;
 use wcf\system\WCF;
 
 /**
@@ -17,7 +18,8 @@ final class HeaderUtil {
         * Alias to php setcookie() function.
         */
        public static function setCookie($name, $value = '', $expire = 0) {
-               @header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX.$name).'='.rawurlencode($value).($expire ? '; expires='.gmdate('D, d-M-Y H:i:s', $expire).' GMT' : '').(COOKIE_PATH ? '; path='.COOKIE_PATH : '').(COOKIE_DOMAIN ? '; domain='.COOKIE_DOMAIN : '').((isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') ? '; secure' : '').'; HttpOnly', false);
+               // TODO: COOKIE_PATH is static and does not always reflect the application's domain and path
+               @header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX.$name).'='.rawurlencode($value).($expire ? '; expires='.gmdate('D, d-M-Y H:i:s', $expire).' GMT' : '').(COOKIE_PATH ? '; path='.COOKIE_PATH : '').(COOKIE_DOMAIN ? '; domain='.COOKIE_DOMAIN : '').(RouteHandler::secureConnection() ? '; secure' : '').'; HttpOnly', false);
        }
        
        /**
@@ -67,12 +69,6 @@ final class HeaderUtil {
         * Outputs the compressed page content.
         */
        public static function getCompressedOutput($output) {
-               if (defined('LESS_FILES') && LESS_FILES) {
-                       // remove .css files
-                       $output = preg_replace('~\\@import url\("((?!burningBoard).)*.css"\) screen;~U', '', $output);
-                       $output = str_replace(array('<!-- LESS_FILES', 'LESS_FILES -->'), array('', ''), $output);
-               }
-               
                $size = strlen($output);
                $crc = crc32($output);
                
index 4de4840a4b06d1e6a2ad76c5ed9b239c41f78cd2..2b353a6f2e2e0964a11f34389ba20e8692599fa6 100644 (file)
                <item name="wcf.acp.option.page_description"><![CDATA[Seitenbeschreibung]]></item>
                <item name="wcf.acp.option.page_title"><![CDATA[Titel der Seite]]></item>
                <item name="wcf.acp.option.page_title.description"><![CDATA[Dieser Titel wird im Seitenkopf dargestellt, wenn Sie die Anzeige dieses Textes im Stileditor aktiviert haben.]]></item>
-               <item name="wcf.acp.option.page_url"><![CDATA[Adresse (URL) der Seite]]></item>
-               <item name="wcf.acp.option.page_url.description"><![CDATA[Adresse (URL) unter der die Seite aufzurufen ist (ohne abschließenden Slash).]]></item>
                <item name="wcf.acp.option.page_urls"><![CDATA[Weitere Adressen (URLs)]]></item>
                <item name="wcf.acp.option.page_urls.description"><![CDATA[Weitere Adressen (URLs) unter denen Ihre Seite erreichbar ist.]]></item>
                <item name="wcf.acp.option.proxy_server_http"><![CDATA[Proxy-Server (HTTP)]]></item>
index c9d36055986e9934a54a1f58109d7a43a9cc9bd1..f84321c77e194392f02a35f86d159cffb587024c 100644 (file)
                <item name="wcf.acp.option.page_description"><![CDATA[Page description]]></item>
                <item name="wcf.acp.option.page_title"><![CDATA[Page title]]></item>
                <item name="wcf.acp.option.page_title.description"><![CDATA[That title will show up inside the page header, if you have enabled it with the style editor.]]></item>
-               <item name="wcf.acp.option.page_url"><![CDATA[Page adress (URL)]]></item>
-               <item name="wcf.acp.option.page_url.description"><![CDATA[Please enter the adress (URL) of the page (without trailing slash).]]></item>
                <item name="wcf.acp.option.page_urls"><![CDATA[Further adresses (URLs)]]></item>
                <item name="wcf.acp.option.page_urls.description"><![CDATA[Enter further adresses (URLs) which also link to your site.]]></item>
                <item name="wcf.acp.option.proxy_server_http"><![CDATA[Proxy-Server (HTTP)]]></item>