forked from chregu/jr_cr_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
53 lines (39 loc) · 1.33 KB
/
test.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
try {
define("JACK_PROJECT_DIR",dirname(__FILE__).'/');
ini_set("include_path",JACK_PROJECT_DIR."/inc/:".ini_get("include_path"));
spl_autoload_register('autoload');
$config = array ('transport'=> 'davex', 'url' => 'http://localhost:8080/server','user' => 'admin','pass' => 'admin');
$session = getJRSession($config);
$rn = $session->getRootNode();
print $rn->getPath() . "<br/>";
foreach($rn->getNodes() as $node) {
print $node->getPath() ."<br/>";
}
} catch (Exception $e) {
print "<pre>";
var_dump($e);
}
function getJRSession($config) {
if (empty($config['url'])) {
return false;
}
if (empty($config['workspace'])) {
$config['workspace'] = "default";
}
$repository = jr_cr::lookup($config['url'], $config['transport']);
if (isset($config['pass'])) {
$credentials = new jr_cr_simplecredentials($config['user'], $config['pass']);
return $repository->login($credentials, $config['workspace']);
} else {
return $repository->login(null, $config['workspace']);
}
}
function autoload($class) {
$incFile = str_replace("_", DIRECTORY_SEPARATOR, $class).".php";
if (@fopen($incFile, "r", TRUE)) {
include($incFile);
return $incFile;
}
return FALSE;
}