3 require_once(
"swordapplink.php");
4 require_once(
"utils.php");
88 $this->sac_status = $sac_newstatus;
91 $this->sac_xml = $sac_thexml;
94 switch($this->sac_status) {
96 $this->sac_statusmessage =
"OK";
99 $this->sac_statusmessage =
"Created";
102 $this->sac_statusmessage =
"Accepted";
105 $this->sac_statusmessage =
"Bad request";
108 $this->sac_statusmessage =
"Unauthorized";
111 $this->sac_statusmessage =
"Forbidden";
114 $this->sac_statusmessage =
"Precondition failed";
117 $this->sac_statusmessage =
"Request entity too large";
120 $this->sac_statusmessage =
"Unsupported media type";
123 $this->sac_statusmessage =
"Unknown error (status code " . $this->sac_status .
")";
128 $this->sac_authors = array();
129 $this->sac_contributors = array();
130 $this->sac_links = array();
131 $this->sac_dcterms = array();
134 $this->sac_noOp =
false;
140 $sac_dr->registerXPathNamespace(
'atom',
'http://www.w3.org/2005/Atom');
141 if (!isset($sac_ns[
'atom'])) $sac_ns[
'atom'] =
'http://www.w3.org/2005/Atom';
142 if (!isset($sac_ns[
'dcterms'])) $sac_ns[
'dcterms'] =
'http://purl.org/dc/terms/';
143 if (!isset($sac_ns[
'sword'])) $sac_ns[
'sword'] =
'http://purl.org/net/sword/';
146 $this->sac_id = $sac_dr->children($sac_ns[
'atom'])->id;
147 $sac_contentbits = $sac_dr->xpath(
"atom:content");
148 if (!empty($sac_contentbits)) {
149 $this->sac_content_src = $sac_contentbits[0]->attributes()->src;
150 $this->sac_content_type = $sac_contentbits[0]->attributes()->type;
154 foreach ($sac_dr->children($sac_ns[
'atom'])->author as $sac_author) {
155 $sac_theauthor = $sac_author->children($sac_ns[
'atom'])->name .
"";
156 $this->sac_authors[] = $sac_theauthor;
160 foreach ($sac_dr->children($sac_ns[
'atom'])->contributor as $sac_contributor) {
161 $sac_thecontributor = $sac_contributor->children($sac_ns[
'atom'])->name .
"";
162 $this->sac_contributors[] = $sac_thecontributor;
166 foreach ($sac_dr->xpath(
"atom:link") as $sac_link) {
167 $sac_linkobject =
new SWORDAPPLink($sac_link->attributes()->rel, $sac_link->attributes()->href, $sac_link->attributes()->type);
168 array_push($this->sac_links, $sac_linkobject);
171 if ($sac_linkobject->sac_linkrel ==
'edit') $this->sac_edit_iri = $sac_linkobject->sac_linkhref;
174 if ($sac_linkobject->sac_linkrel ==
'http://purl.org/net/sword/terms/add') $this->sac_se_iri = $sac_linkobject->sac_linkhref;
177 if ($sac_linkobject->sac_linkrel ==
'http://purl.org/net/sword/terms/statement') {
178 if (($sac_linkobject->sac_linktype ==
'application/atom+xml;type=feed') ||
179 ($sac_linkobject->sac_linktype ==
'application/atom+xml; type=feed')) {
180 $this->sac_state_iri_atom = $sac_linkobject->sac_linkhref;
181 }
else if ($sac_linkobject->sac_linktype ==
'application/rdf+xml') {
182 $this->sac_state_iri_ore = $sac_linkobject->sac_linkhref;
186 if ($sac_linkobject->sac_linkrel ==
'edit-media') {
188 if (($sac_linkobject->sac_linktype ==
'application/atom+xml;type=feed') ||
189 ($sac_linkobject->sac_linktype ==
'application/atom+xml; type=feed')) {
190 $this->sac_edit_media_iri_atom = $sac_linkobject->sac_linkhref;
194 $this->sac_edit_media_iri = $sac_linkobject->sac_linkhref;
200 $this->sac_title = sac_clean($sac_dr->children($sac_ns[
'atom'])->title);
201 $this->sac_summary = sac_clean($sac_dr->children($sac_ns[
'atom'])->summary);
204 $this->sac_updated = $sac_dr->children($sac_ns[
'atom'])->updated;
207 $this->sac_rights = sac_clean($sac_dr->children($sac_ns[
'atom'])->rights);
210 $this->sac_treatment = sac_clean($sac_dr->children($sac_ns[
'sword'])->treatment);
213 $this->sac_verbose_treatment = sac_clean($sac_dr->children($sac_ns[
'sword'])->verboseDescription);
216 $this->sac_packaging = $sac_dr->children($sac_ns[
'sword'])->packaging;
219 $this->sac_generator = sac_clean($sac_dr->children($sac_ns[
'atom'])->generator);
220 $sac_gen = $sac_dr->xpath(
"atom:generator");
221 if (!empty($sac_gen)) { $this->sac_generator_uri = $sac_gen[0]->attributes()->uri; }
224 $this->sac_useragent = sac_clean($sac_dr->children($sac_ns[
'sword'])->userAgent);
227 foreach ($sac_dr->children($sac_ns[
'dcterms']) as $sac_dcterm) {
228 if (!isset($this->sac_dcterms[$sac_dcterm->getName()])) {
229 $this->sac_dcterms[$sac_dcterm->getName()] = array();
231 array_push($this->sac_dcterms[$sac_dcterm->getName()], $sac_dcterm);
235 if (strtolower((
string)$sac_dr->children($sac_ns[
'sword'])->noOp) ==
'true') {
236 $this->sac_noOp =
true;
241 print
" - ID: " . $this->sac_id .
"\n";
242 print
" - Title: " . $this->sac_title .
"\n";
243 print
" - Content: " . $this->sac_content_src .
" (" . $this->sac_content_type .
")\n";
244 foreach ($this->sac_authors as $author) {
245 print
" - Author: " . $author .
"\n";
247 foreach ($this->sac_contributors as $contributor) {
248 print
" - Contributor: " . $contributor .
"\n";
250 foreach ($this->sac_links as $links) {
251 print
' - Link: rel=' . $links->sac_linkrel .
' ';
252 print
'href=' . $links->sac_linkhref .
' ';
253 if (isset($links->sac_linktype)) {
254 print
'type=' . $links->sac_linktype;
258 print
" - Summary: " . $this->sac_summary .
"\n";
259 print
" - Updated: " . $this->sac_updated .
"\n";
260 print
" - Rights: " . $this->sac_rights .
"\n";
261 print
" - Treatment: " . $this->sac_treatment .
"\n";
262 print
" - Verbose description: " . $this->sac_verbose_treatment .
"\n";
263 print
" - Packaging: " . $this->sac_packaging .
"\n";
264 print
" - Generator: " . $this->sac_generator .
" (" . $this->sac_generator_uri .
")\n";
265 print
" - User agent: " . $this->sac_useragent .
"\n";
266 if (!empty($this->sac_noOp)) { print
" - noOp: " . $this->sac_noOp .
"\n"; }
268 foreach ($this->sac_dcterms as $dcterm => $dcvalues) {
269 print
' - Dublin Core Metadata: ' . $dcterm .
"\n";
270 foreach ($dcvalues as $dcvalue) {
271 print
' - ' . $dcvalue .
"\n";