2007-04-16 11:58:25 +00:00
|
|
|
<?php
|
2009-07-21 03:18:40 +00:00
|
|
|
/**
|
|
|
|
* \mainpage Shimmie2 / SCore Documentation
|
2009-07-21 06:36:12 +00:00
|
|
|
*
|
|
|
|
* SCore is a framework designed for writing flexible, extendable applications.
|
2013-11-28 05:34:31 +00:00
|
|
|
* Whereas most PHP apps are built monolithically, score's event-based nature
|
2009-07-21 06:36:12 +00:00
|
|
|
* allows parts to be mixed and matched. For instance, the most famous
|
|
|
|
* collection of score extensions is the Shimmie image board, which includes
|
|
|
|
* user management, a wiki, a private messaging system, etc. But one could
|
|
|
|
* easily remove the image board bits and simply have a wiki with users and
|
|
|
|
* PMs; or one could replace it with a blog module; or one could have a blog
|
|
|
|
* which links to images on an image board, with no wiki or messaging, and so
|
|
|
|
* on and so on...
|
2009-07-21 03:18:40 +00:00
|
|
|
*
|
2009-07-21 06:36:12 +00:00
|
|
|
* Dijkstra will kill me for personifying my architecture, but I can't think
|
|
|
|
* of a better way without going into all the little details.
|
2013-11-28 05:34:31 +00:00
|
|
|
* There are a bunch of Extension subclasses, they talk to each other by sending
|
|
|
|
* and receiving Event subclasses. The primary driver for each conversation is the
|
2012-03-05 13:56:36 +00:00
|
|
|
* initial PageRequestEvent. If an Extension wants to display something to the
|
|
|
|
* user, it adds a block to the Page data store. Once the conversation is over, the Page is passed to the
|
2009-07-21 03:18:40 +00:00
|
|
|
* current theme's Layout class which will tidy up the data and present it to
|
2012-03-05 13:56:36 +00:00
|
|
|
* the user. To see this in a more practical sense, see \ref hello.
|
2009-07-21 03:18:40 +00:00
|
|
|
*
|
2009-07-21 06:36:12 +00:00
|
|
|
* To learn more about the architecture:
|
|
|
|
*
|
|
|
|
* \li \ref eande
|
|
|
|
* \li \ref themes
|
|
|
|
*
|
|
|
|
* To learn more about practical development:
|
|
|
|
*
|
|
|
|
* \li \ref scglobals
|
|
|
|
* \li \ref unittests
|
|
|
|
*
|
|
|
|
* \page scglobals SCore Globals
|
2009-07-21 03:18:40 +00:00
|
|
|
*
|
|
|
|
* There are four global variables which are pretty essential to most extensions:
|
|
|
|
*
|
|
|
|
* \li $config -- some variety of Config subclass
|
|
|
|
* \li $database -- a Database object used to get raw SQL access
|
|
|
|
* \li $page -- a Page to holds all the loose bits of extension output
|
|
|
|
* \li $user -- the currently logged in User
|
2009-07-21 06:36:12 +00:00
|
|
|
*
|
|
|
|
* Each of these can be imported at the start of a function with eg "global $page, $user;"
|
2009-07-21 03:18:40 +00:00
|
|
|
*/
|
|
|
|
|
2012-03-30 17:03:55 +00:00
|
|
|
if(!file_exists("data/config/shimmie.conf.php")) {
|
2011-12-24 21:56:26 +00:00
|
|
|
header("Location: install.php");
|
|
|
|
exit;
|
|
|
|
}
|
2012-03-31 17:59:28 +00:00
|
|
|
require_once "core/sys_config.inc.php";
|
2009-01-04 16:24:06 +00:00
|
|
|
require_once "core/util.inc.php";
|
2012-02-01 15:07:03 +00:00
|
|
|
|
|
|
|
// set up and purify the environment
|
2009-07-21 03:18:40 +00:00
|
|
|
_version_check();
|
|
|
|
_sanitise_environment();
|
2007-10-27 19:38:13 +00:00
|
|
|
|
2009-01-04 16:24:06 +00:00
|
|
|
try {
|
|
|
|
// load base files
|
2011-10-09 11:01:48 +00:00
|
|
|
ctx_log_start("Opening files");
|
2012-05-23 10:35:30 +00:00
|
|
|
$files = array_merge(zglob("core/*.php"), zglob("ext/{".ENABLED_EXTS."}/main.php"));
|
2009-01-04 16:24:06 +00:00
|
|
|
foreach($files as $filename) {
|
|
|
|
require_once $filename;
|
|
|
|
}
|
2011-10-09 11:01:48 +00:00
|
|
|
ctx_log_endok();
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2011-10-09 11:01:48 +00:00
|
|
|
ctx_log_start("Connecting to DB");
|
2009-01-04 16:24:06 +00:00
|
|
|
// connect to the database
|
|
|
|
$database = new Database();
|
|
|
|
$config = new DatabaseConfig($database);
|
2011-10-09 11:01:48 +00:00
|
|
|
ctx_log_endok();
|
2007-10-27 19:38:13 +00:00
|
|
|
|
2009-01-04 16:24:06 +00:00
|
|
|
// load the theme parts
|
2012-02-01 16:41:18 +00:00
|
|
|
ctx_log_start("Loading themelets");
|
2012-06-17 23:00:21 +00:00
|
|
|
foreach(_get_themelet_files(get_theme()) as $themelet) {
|
2012-02-01 16:41:18 +00:00
|
|
|
require_once $themelet;
|
|
|
|
}
|
|
|
|
ctx_log_endok();
|
2007-10-27 19:38:13 +00:00
|
|
|
|
2012-02-01 15:07:03 +00:00
|
|
|
_load_extensions();
|
2009-05-11 21:08:32 +00:00
|
|
|
|
2009-01-04 16:24:06 +00:00
|
|
|
// start the page generation waterfall
|
2009-07-21 06:36:12 +00:00
|
|
|
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
2012-02-02 05:25:17 +00:00
|
|
|
$user = _get_user();
|
2009-05-11 14:04:33 +00:00
|
|
|
send_event(new InitExtEvent());
|
2012-06-17 19:05:16 +00:00
|
|
|
if(!is_cli()) { // web request
|
2012-06-17 23:00:21 +00:00
|
|
|
send_event(new PageRequestEvent(@$_GET["q"]));
|
2012-06-17 19:05:16 +00:00
|
|
|
$page->display();
|
|
|
|
}
|
|
|
|
else { // command line request
|
|
|
|
send_event(new CommandEvent($argv));
|
|
|
|
}
|
2008-01-02 21:49:12 +00:00
|
|
|
|
2012-03-11 00:37:08 +00:00
|
|
|
// saving cache data and profiling data to disk can happen later
|
|
|
|
if(function_exists("fastcgi_finish_request")) fastcgi_finish_request();
|
2012-06-23 23:27:53 +00:00
|
|
|
$database->commit();
|
2011-10-09 11:01:48 +00:00
|
|
|
ctx_log_endok();
|
2009-01-04 16:24:06 +00:00
|
|
|
}
|
|
|
|
catch(Exception $e) {
|
2012-06-23 23:27:53 +00:00
|
|
|
if($database) $database->rollback();
|
2012-02-01 15:07:03 +00:00
|
|
|
_fatal_error($e);
|
2011-10-09 11:01:48 +00:00
|
|
|
ctx_log_ender();
|
2009-01-04 16:24:06 +00:00
|
|
|
}
|
2007-04-16 11:58:25 +00:00
|
|
|
?>
|