/** * Save an array of fields and values for a single node by URN */ public function save_by_urn($urn, $array = array(), $g = 'urn:scalar') { $conf = array('ns' => $this->ns); $resource = ARC2::getResource($conf); $resource->setURI($urn); foreach ($array as $field => $valueArray) { if (!isNS($field) && !isURL($field)) { continue; } $field = toURL($field, $this->ns); if (!is_array($valueArray)) { $valueArray = array($valueArray); } $insert_values = array(); foreach ($valueArray as $value) { if (empty($value)) { continue; } if (is_string($value)) { if (substr($value, -1, 1) == '"') { $value .= ' '; } // ARC bug fix //$value = closeOpenTags($value); } if (is_array($value)) { if (empty($value['value'])) { continue; } $insert_values[] = $value; } else { $insert_values[] = array('value' => $value, 'type' => isURL($value) || isNS($value, $this->ns) ? 'uri' : 'literal'); } } if (!empty($insert_values)) { $resource->setProp($field, $insert_values); } } $this->store->insert($resource->index, $g); if ($errs = $this->store->getErrors()) { print_r($errs); } return true; }
function pageErr($url, $errType = "Unknown") { function toURL($url) { if (substr($url, 0, 5) !== "http:" and substr($url, 0, 6) !== "https:") { return "//" . $url; } else { return $url; } } global $pHost; header('HTTP/1.1 404 Not Found'); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> <title>Invaild</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"> body {font-size:10px; color:#777777; font-family:arial; text-align:center;} h1 {font-size:64px; color:#555555; margin: 70px 0 50px 0;} p {width:320px; text-align:center; margin-left:auto;margin-right:auto; margin-top: 30px } div {width:320px; text-align:center; margin-left:auto;margin-right:auto;} a:link {color: #34536A;} a:visited {color: #34536A;} a:active {color: #34536A;} a:hover {color: #34536A;} </style> </head> <body> <h1>Invaild</h1> <div>(Error: ' . $errType . ')</div> <p><div>The resource requested: <U><I><a href="' . toURL($url) . '">' . $url . '</a></I></U> cannot be fetched.</div> </p> <div> <a href="//' . $pHost . '">Powered by Gowe.</a> </div> </body> </html>'; exit; }