forked from chregu/jr_cr_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
55 lines (41 loc) · 1.49 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
define("JACK_PROJECT_DIR", dirname(__FILE__) . '/');
define("JACK_WEBROOT", "http://" . $_SERVER['HTTP_HOST'] . str_replace("/index.php", "", $_SERVER['SCRIPT_NAME']));
include_once (JACK_PROJECT_DIR . "/inc/demoinit.php");
/* traditionally without dependency injection */
/*
$config = array('transport' => 'davex', 'url' => 'http://localhost:8080/server', 'workspace' => 'default', 'user' => 'admin', 'pass' => 'admin');
$session = demoinit::initAppAndGetSession($config);
*/
/* With dependency injection */
include_once (JACK_PROJECT_DIR . "/inc/demoinitWithDI.php");
$config = 'conf/config.xml';
$session = demoinitWithDI::initAppAndGetSession($config);
try {
$wiki = new demowiki($session);
if (isset($_SERVER['PATH_INFO'])) {
$path = "/" . trim($_SERVER['PATH_INFO'], "/");
} else {
$path = "";
}
include (JACK_PROJECT_DIR . "tmpl/head.php");
try {
if (! isset($_GET['action'])) {
print $wiki->viewAction($path);
} else {
$method = $_GET['action'] . "Action";
if (method_exists($wiki, $method)) {
print $wiki->$method($path);
} else {
print $wiki->viewAction($path);
}
}
} catch (phpCR_PathNotFoundException $e) {
$wiki->initPages($path);
header("Location: " . JACK_WEBROOT . $path . '?action=edit');
}
include (JACK_PROJECT_DIR . "tmpl/foot.php");
} catch (Exception $e) {
print "<pre>";
var_dump($e);
}