root/trunk/index.php

Revision 67 (checked in by hspath, 3 years ago)

- added "view source" link to example page template
- changed time:countdown christmas example to year 2005 (example3.xml)
- changed require/include statements to fit new directory structure
- moved inclusions to the files where there are needed

(e.g. "require 'patTemplate.php' was in /index.php, but patTemplate is used
in pat/patXMLRenderer.php)

- added page-level DocBlocks? where missing
- reformatted most code to come near PEAR Coding Standards
- fixed several E_NOTICEs
- merged some features from patSite
- optimized referer filtering for logging
- added function for creating directories recursively
- created /pat/patXMLRenderer/Extension

  • Property 0 set to
  • Property 1 set to
Line 
1 <?php
2 /**
3  * Main script for example site
4  *
5  * @package     patXMLRenderer
6  * @subpackage  Example
7  * @version     $Id$
8  * @author      Stephan Schmidt <schst@php-tools.de>
9  * @author      Hans Spath <dev-pat@hans-spath.de>
10  */
11
12 // include config (file locations)
13 require_once 'config/patXMLRenderer.php';
14
15 // include list of known extensions (file is generated by admin)
16 include_once $extDir.'/knownExtensions.php';
17
18 // renderer
19 require_once 'pat/patXMLRenderer.php';
20
21 // include logging class for text files
22 require_once 'pat/patXMLRenderer/TxtLogger.php';
23
24 // get requested file
25 $file = isset( $_GET['file'] )
26       ? $_GET['file']
27       : false;
28
29 // instantiate renderer
30 $randy = new patXMLRenderer;
31
32 // tell renderer where extensions are stored
33 $randy->setExtensionDir( $extDir );
34
35 // tell renderer the the names and locations of all known extensions
36 $randy->setKnownExtensions( $knownExtensions );
37
38 // set list of skins
39 $randy->setSkins( $skins );
40 // select a skin used for rendering
41 $randy->selectSkin( 'pat' );
42
43 // this file is called, when no file is specified
44 $randy->setDefaultFile( $defaultFile );
45 // this file is displayed, when specified file does not exist
46 $randy->setErrorFile( $errorFile );
47
48 // automatically add an extension if the namespace is known
49 $randy->setOption( 'autoadd', 'on' );
50
51 // set cache to auto
52 $randy->setOption( 'cache', 'off' );
53
54 // enable logging
55 $randy->setOption( 'log', 'off' );
56
57 /* // {{{  The following lines are only needed for logging
58
59 // if the referer is from one of these domains do not log the referer
60 $randy->setRefererBlocks( array( 'php-tools.de', 'php-application-tools.de' ) );
61
62 // instantiate a text logger (no other loggers available yet)
63 $logger = new patXMLRendererTxtLogger;
64 $logger->setLogDir( $logDir );
65
66 // hand logger over to renderer
67 $randy->setLogger( $logger );
68
69 // }}} */
70
71 // all xml files are located in this directory
72 $randy->setXMLDir( $xmlDir );
73
74 // display this file
75 $randy->setXMLFile( $file );
76
77 // init Template
78 $template = new patTemplate();
79 // hand template object to renderer
80 $randy->setTemplate( $template );
81
82 // append session id to internal links
83 $randy->useSessions();
84
85 // load templates and do some other important things
86 $randy->initRenderer();
87
88 // load templates that are needed everywhere
89 foreach( $baseTemplates as $tmplFile )
90     $randy->addTemplateFile( $tmplFile );
91
92 // parse xml file and send the result to browser...
93 $randy->displayRenderedContent();
94 ?>
95
Note: See TracBrowser for help on using the browser.