-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcr.php
executable file
·64 lines (48 loc) · 1.68 KB
/
cr.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
53
54
55
56
57
58
59
60
61
62
63
64
<?php
class jr_cr {
/** All instances loaded so far by api_db::factory(). */
protected static $instances = array();
//FIXME: api_config is okapi specific, we have to remove that later ...
public static function api_factory ($name = "default", $force = false) {
$jcr = api_config::getInstance()->jcr;
if (empty($jcr[$name])) {
return false;
}
return self::factory($jcr[$name],$name,$force);
}
public static function factory( $config, $name = "default", $force = false) {
if (isset(self::$instances[$name]) && $force == false) {
return self::$instances[$name];
}
self::$instances[$name] = self::get($config);
return self::$instances[$name];
}
private static function get($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']);
}
}
/**
*
* @param unknown_type $repo
* @return lx_cr_repository the created repository
*/
static function lookup($storage, $transport = '') {
return new jr_cr_repository($storage, $transport);
}
/**
* Constructor. Private according to the singleton pattern.
*/
private function __construct() {
}
}