baseline
[omp.pkp.sfu.ca.git] / index.php
blob2e9b28c5e01437514f5ece086a894ecefc3e285e
1 <?php
3 /**
4 * @mainpage OMP API Reference
5 *
6 * Welcome to the OMP API Reference. This resource contains documentation
7 * generated automatically from the OMP source code.
8 *
9 * The design of Open Monograph press is heavily structured for maintainability,
10 * flexibility and robustness. For this reason it may seem complex when first
11 * approached. Those familiar with Sun's Enterprise Java Beans technology or the
12 * Model-View-Controller (MVC) pattern will note many similarities.
14 * As in a MVC structure, data storage and representation, user interface
15 * presentation, and control are separated into different layers. The major
16 * categories, roughly ordered from "front-end" to "back-end," follow:
17 * - Smarty templates, which are responsible for assembling HTML pages to
18 * display to users;
19 * - Page classes, which receive requests from users' web browsers, delegate any
20 * required processing to various other classes, and call up the appropriate
21 * Smarty template to generate a response;
22 * - Action classes, which are used by the Page classes to perform non-trivial
23 * processing of user requests;
24 * - Model classes, which implement PHP objects representing the system's
25 * various entities, such as Users, Monographs, and Presses;
26 * - Data Access Objects (DAOs), which generally provide (amongst others)
27 * update, create, and delete functions for their associated Model classes, are
28 * responsible for all database interaction;
29 * - Support classes, which provide core functionalities, miscellaneous common
31 * As the system makes use of inheritance and has consistent class naming
32 * conventionsl it is generally easy to tell what category a particular class falls into.
33 * For example, a Data Access Object class always inherits from the DAO class, has a
34 * Class name of the form [Something]%DAO, and has a filename of the form
35 * [Something]%DAO.inc.php.
37 * To learn more about developing OMP, there are several additional resources that may be useful:
38 * - The docs/README document
39 * - The PKP support forum at http://pkp.sfu.ca/support/forum
40 * - The technical reference (and other documents), available at http://pkp.sfu.ca/omp_documentation
42 * @file index.php
44 * Copyright (c) 2003-2008 John Willinsky
45 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
47 * @ingroup index
49 * Front controller for OMP site. Loads required files and dispatches requests to the appropriate handler.
52 ini_set('display_errors', '2');
53 ERROR_REPORTING(E_ALL);
55 define('INDEX_FILE_LOCATION', __FILE__);
56 /**
57 * Handle a new request.
59 function handleRequest() {
60 if (!Config::getVar('general', 'installed')) {
61 define('SESSION_DISABLE_INIT', 1);
62 if (pageRequiresInstall()) {
63 // Redirect to installer if application has not been installed
64 Request::redirect(null, 'install');
68 // Determine the handler for this request
69 $page = Request::getRequestedPage();
70 $op = Request::getRequestedOp();
72 $sourceFile = sprintf('pages/%s/index.php', $page);
74 // If a hook has been registered to handle this page, give it the
75 // opportunity to load required resources and set HANDLER_CLASS.
76 if (!HookRegistry::call('LoadHandler', array(&$page, &$op, &$sourceFile))) {
77 if (file_exists($sourceFile) || file_exists('lib/pkp/'.$sourceFile)) require($sourceFile);
78 elseif (empty($page)) require('pages/index/index.php');
79 else PKPRequest::handle404();
82 if (!defined('SESSION_DISABLE_INIT')) {
83 // Initialize session
84 $sessionManager =& SessionManager::getManager();
85 $session =& $sessionManager->getUserSession();
88 $methods = array_map('strtolower', get_class_methods(HANDLER_CLASS));
90 if (in_array(strtolower($op), $methods)) {
91 // Call a specific operation
92 $HandlerClass = HANDLER_CLASS;
93 $handler = new $HandlerClass;
94 $handler->$op(Request::getRequestedArgs());
96 } elseif (empty($op)) {
97 // Call the selected handler's index operation
98 $HandlerClass = HANDLER_CLASS;
99 $handler = new $HandlerClass;
100 $handler->index(Request::getRequestedArgs());
101 } else PKPRequest::handle404();
104 // Initialize system and handle the current request
105 require('includes/driver.inc.php');
106 initSystem();
107 handleRequest();