CVS update: /cowiki/includes/cowiki/class/core/

[email protected] 15 Mar 2005 13:46:59 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: nibra   
Date: 05/03/15 05:46:59

Modified:
 /cowiki/includes/cowiki/class/core/
  class.UserPreferences.php, class.Registry.php

Log:
 Reverted changes due to introduction of PathInfo

File Changes:

Directory: /cowiki/includes/cowiki/class/core/
==============================================

File [changed]: class.UserPreferences.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/core/class.UserPreferences.php?r1=1.14&r2=1.15
Delta lines:  +24 -4
--------------------
--- class.UserPreferences.php	12 Mar 2005 02:14:31 -0000	1.14
+++ class.UserPreferences.php	15 Mar 2005 13:46:59 -0000	1.15
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.UserPreferences.php,v 1.14 2005/03/12 02:14:31 nibra Exp $
+ * $Id: class.UserPreferences.php,v 1.15 2005/03/15 13:46:59 nibra Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.14 $
+ * @version     $Revision: 1.15 $
  *
  */
 
@@ -117,8 +117,28 @@
             $aPref['TEMPLATE'] = 'default';
         }
 
-        $Registry->setTemplate($aPref['TEMPLATE']);
-        $this->set('template', $Registry->get('PATH_TEMPLATE_ACTIVE'));
+        // Tune path to fit also when cowiki is not in root
+        $sPath = $Context->getEnvironment()->get('PHP_SELF');
+        $sPath = getRequestBasePath($sPath);
+        if (substr($sPath, -1, 1) == '/') {
+            $sPath = substr($sPath, 0, -1);
+        }
+
+        $sTpl = '/tpl/';
+
+        // Concat path to active template
+        $sActTpl = $sTpl . $aPref['TEMPLATE'] . '/';
+        $this->set('template', $sActTpl);
+
+        // Set active template
+        $Registry->set('RUNTIME_TEMPLATE_ACTIVE', $aPref['TEMPLATE']);
+        $Registry->set('PATH_TEMPLATE_ACTIVE', $sActTpl);
+
+        // Set path to active images
+        $Registry->set('PATH_IMAGES', $sPath . $sActTpl . 'img/');
+
+        // Get template configuration file and define constants
+        $Registry->getTplConf($sActTpl);
 
         // ------------------------------------------------------------
 

File [changed]: class.Registry.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/core/class.Registry.php?r1=1.18&r2=1.19
Delta lines:  +23 -42
---------------------
--- class.Registry.php	15 Mar 2005 13:38:09 -0000	1.18
+++ class.Registry.php	15 Mar 2005 13:46:59 -0000	1.19
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.Registry.php,v 1.18 2005/03/15 13:38:09 nibra Exp $
+ * $Id: class.Registry.php,v 1.19 2005/03/15 13:46:59 nibra Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.18 $
+ * @version     $Revision: 1.19 $
  *
  */
 
@@ -72,10 +72,9 @@
      */
     protected function __construct() {
         $Context = RuntimeContext::getInstance();
-        $PathInfo = $Context->getPathInfo();
 
         try {
-            $sPath = $PathInfo->getPath('CONFIG') . '/core.conf';
+            $sPath = realpath(getDirName(__FILE__).'../..') . '/core.conf';
 
             $Conf = new Config();
             $aConf = $Conf->getIniConfigAsArray($sPath);
@@ -101,64 +100,46 @@
 
         // ----------------------------------------------------------------
 
-        $this->setTemplate($this->get('RUNTIME_TEMPLATE_ACTIVE'));
+        // Fetch template configuration
 
-        // This need to be the last line in this constructor
-        Registry::$bInitDone = true;
+        // Tune path to fit also when cowiki is not in root
+        $sPath = $Context->getEnvironment()->get('PHP_SELF');
+        $sPath = getRequestBasePath($sPath);
+        if (substr($sPath, -1, 1) == '/') {
+            $sPath = substr($sPath, 0, -1);
     }
 
-    // --------------------------------------------------------------------
-
-    /**
-     * Set template variables.
-     *
-     * @access  private
-     * @param   string   The template name
-     * @return  void
-     *
-     * @author      Niels Braczek <[email protected]>
-     * @since       coWiki 0.4.0
-     */
-    public function setTemplate($sTemplate) {
+        $sTpl = '/tpl/';
 
-        $Context = RuntimeContext::getInstance();
-        $PathInfo = $Context->getPathInfo();
+        // Concat path to active template
+        $sActTpl = $sTpl . $this->get('RUNTIME_TEMPLATE_ACTIVE') . '/';
 
-        // Fetch template configuration
-        $PathInfo->setTemplate($sTemplate);
+        // Concat path to default template (for fallback reasons)
+        $sDefTpl = $sTpl . 'default/';
 
         // Basic template path
-        $this->set('PATH_TEMPLATE',
-                   DIRECTORY_SEPARATOR .
-                   $PathInfo->getPath('TEMPLATE', COWIKI_RELATIVE) .
-                   DIRECTORY_SEPARATOR);
+        $this->set('PATH_TEMPLATE', $sTpl);
 
         // Active template
-        $this->set('PATH_TEMPLATE_ACTIVE',
-                   DIRECTORY_SEPARATOR .
-                   $PathInfo->getPath('TEMPLATE_ACTIVE', COWIKI_RELATIVE) .
-                   DIRECTORY_SEPARATOR);
+        $this->set('PATH_TEMPLATE_ACTIVE', $sActTpl);
 
         // Path to active images
-        $this->set('PATH_IMAGES',
-                   '/' .
-                   $PathInfo->getUri('TEMPLATE_ACTIVE_IMAGES', COWIKI_RELATIVE) .
-                   '/');
+        $this->set('PATH_IMAGES', $sPath . $sActTpl . 'img/');
 
         // Fallback template path
-        $this->set('PATH_TEMPLATE_DEFAULT',
-                   DIRECTORY_SEPARATOR .
-                   $PathInfo->getPath('TEMPLATE_DEFAULT', COWIKI_RELATIVE) .
-                   DIRECTORY_SEPARATOR);
+        $this->set('PATH_TEMPLATE_DEFAULT', $sDefTpl);
 
         // ----------------------------------------------------------------
 
         // Get template configuration file and define constants
         try {
-            $this->getTplConf($this->get('PATH_TEMPLATE_ACTIVE'));
+            $this->getTplConf($sActTpl);
         } catch (GenericException $e) {
             throw $e; // rethrow
         }
+
+        // This need to be the last line in this constructor
+        Registry::$bInitDone = true;
     }
 
     // --------------------------------------------------------------------