/include/config.php

Description

Configuration functions for the framework.

$Id: config.php 610 2006-06-29 10:04:36Z stijn $

Constants
CONFIGFILE = 'sws' (line 20)

The name of the configuration file. Primarily used to override it when running tests.

SWSCONFIGDIR = '.sws' (line 14)

The path to the SWS configuration directory, relative to subsite roots.

Functions
addSlash (line 55)

Make sure that a string ends in a slash.

  • return: the string with a slash appended if necessary
  • see: stripSlash()
string addSlash (string $str)
  • string $str: the string to check
configPath (line 30)

Determine the path to the framework wide configuration files.

The return value of this function can be used to prefix framework wide configuration values in cookies or sessions.

  • return: the absolute filesystem path to the SWS configuration directory
string configPath ()
determineVhost (line 126)

Determine the correct SWS vhost for a request.

  • return: the vhost identifier for the current request
string determineVhost ()
findBaseURL (line 186)

Returns the computed base URL for a subsite.

This function tries to determine the base URL for a subsite, in case no base URL was configured. This is done by repeatedly stripping pathname components from both the URL and the request directory, in order to find the common request basis.

Currently, in the following cases, the base URL can be computed.

Site definition Request directory Request URL Base URL /site1 /site1 / / /site1 /site1/foo /foo/ / /site1/site2 /site1/site2 /site2/ /site2/ /site1/site2 /site1/site2/bar /site2/bar/ /site2/ /subsites/[^/]+ /subsites/site3 /site3/ /site3/ /subsites/[^/]+ /subsites/site3/baz /site3/baz/ /site3/ /subsites/[^/]+/s /subsites/site3/s /site3/s/ /site3/s/ /subsites/[^/]+/s /subsites/site3/s/2 /site3/s/2/ /site3/s/ /foo /foo /xyzzy/ /xyzzy/ /foo /foo/bar /xyzzy/bar/ /xyzzy/

The function will not be able to determine base URLs in case of multiple Alias'es. Those subsites need to explicitly define the base URL in their configuration file.

  • return: the found base URL, or "" if none was found
string findBaseURL (string $site, string $dir, string $request)
  • string $site: the site definition for the current site
  • string $dir: the directory of the current request
  • string $request: the current request directory
parseConfig (line 95)

Parse a configuration file into a hash.

The configuration file is expected to look like this:

 # Line comments
 key=1	# number value
 string="foo"	# string value

This function will return a hash with key 'key', value 1 and key 'string' value "foo" in this case.

  • return: hash of configuation values
array parseConfig (string $file)
  • string $file: the filename to read
setConfig (line 526)

Process the configuration for a specific page request.

This function is called on every page view to set the configuration variables for that request. It makes sure that $_SESSION["conf-$config"]['sws'] points to the correct configuration hash for the requested vhost/site combination.

The static configuration for the framework install is read on startup and everytime we detect that the main configuration file has changed. Note that this means that changes in the vhost configuration files will NOT be detected unless a user restarts the browser, or the main configuration file is rewritten also.

Notable keys in the $_SESSION["conf-$config"]['sws'] configuration hash:

  • host: the current virtual host
  • basedir: the filesystem path to the current site
  • baseurl: the URL path to the current site
  • debug: 1 if debugging is enabled, 0 otherwise

void setConfig ()
stripSlash (line 70)

Make sure that a string does not end in a slash.

  • return: the string with the ending slash removed if necessary
  • see: addSlash()
string stripSlash (string $str)
  • string $str: the string to check

Documentation generated on Fri, 30 Jun 2006 10:31:37 +0200 by phpDocumentor 1.3.0RC3