KT_atom_server.default_dms_services.inc.php
3.76 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/**
* AtomPub Service: fulltree
*
* Returns a full tree listing starting at the root document
* Tree structure obtained by referencing parent id
*
*/
class KT_atom_service_fulltree extends KT_atom_service {
public function GET_action(){
//Create a new response feed
$feed=new KT_atom_ResponseFeed_GET(KT_APP_BASE_URI);
//Invoke the KtAPI to get detail about the referenced document
$tree=KT_atom_service_helper::getFullTree();
//Create the atom response feed
foreach($tree as $item){
$id=$item['id'];
$entry=$feed->newEntry();
$feed->newField('id',$id,$entry);
foreach($item as $property=>$value){
$feed->newField($property,$value,$entry);
}
}
$this->setStatus(self::STATUS_OK);
//Expose the responseFeed
$this->responseFeed=$feed;
}
public function DELETE_action(){
$feed = new KT_atom_ResponseFeed_DELETE();
$this->responseFeed=$feed;
}
}
/**
* AtomPub Service: folder
*
* Returns detail on a particular folder
*
*/
class KT_atom_service_folder extends KT_atom_service {
public function GET_action(){
//Create a new response feed
$feed=new KT_atom_Response_GET(KT_APP_BASE_URI);
//Invoke the KtAPI to get detail about the referenced document
$folderDetail=KT_atom_service_helper::getFolderDetail($this->params[0]?$this->params[0]:1);
//Create the atom response feed
$entry=$feed->newEntry();
foreach($folderDetail as $property=>$value){
$feed->newField($property,$value,$entry);
}
//Expose the responseFeed
$this->responseFeed=$feed;
}
}
/**
* AtomPub Service: document
*
* Returns detail on a particular document
*
*/
class KT_atom_service_document extends KT_atom_service {
public function GET_action(){
//Create a new response feed
$feed=new KT_atom_responseFeed(KT_APP_BASE_URI);
//Invoke the KtAPI to get detail about the referenced document
$docDetail=KT_atom_service_helper::getDocumentDetail($this->params[0]);
//Create the atom response feed
$entry=$feed->newEntry();
foreach($docDetail['results'] as $property=>$value){
$feed->newField($property,$value,$entry);
}
//Add a downloaduri field manually
$feed->newField('downloaduri',urlencode(KT_APP_SYSTEM_URI.'/action.php?kt_path_info=ktcore.actions.document.view&fDocumentId='.$docDetail['results']['document_id']),$entry);
//Expose the responseFeed
$this->responseFeed=$feed;
}
}
class KT_atom_service_test extends KT_atom_service{
public function GET_action(){
$feed=new KT_atom_ResponseFeed_GET(KT_APP_BASE_URI);
$elem=$feed->newElement('test','Responding to a GET request');
$feed->DOM->appendChild($elem);
$this->setStatus(self::STATUS_OK);
$this->responseFeed=$feed;
}
public function PUT_action(){
$feed=new KT_atom_ResponseFeed_GET(KT_APP_BASE_URI);
$elem=$feed->newElement('test','Responding to a PUT request');
$feed->DOM->appendChild($elem);
$this->setStatus(self::STATUS_OK);
$this->responseFeed=$feed;
}
public function POST_action(){
$feed=new KT_atom_ResponseFeed_GET(KT_APP_BASE_URI);
$elem=$feed->newElement('test','Responding to a POST request');
$feed->DOM->appendChild($elem);
$this->setStatus(self::STATUS_OK);
$this->responseFeed=$feed;
}
public function DELETE_action(){
$feed=new KT_atom_ResponseFeed_GET(KT_APP_BASE_URI);
$elem=$feed->newElement('test','Responding to a DELETE request');
$feed->DOM->appendChild($elem);
$this->setStatus(self::STATUS_OK);
$this->responseFeed=$feed;
}
}
class KT_atom_service_logout extends KT_atom_service{
public function GET_action(){
//$this->setStatus(self::STATUS_OK);
KT_atom_HTTPauth::logout();
ob_end_clean();
KT_atom_HTTPauth::login('KnowledgeTree AtomPub','You are not allowed on this realm');
exit;
}
public function PUT_action(){}
public function POST_action(){}
public function DELETE_action(){}
}
?>