Пример #1
0
function unapiExplainResponse($unapiID)
{
    global $contentTypeCharset;
    // these variables are specified in 'ini.inc.php'
    $unapiCollectionDoc = new XMLDocument();
    $unapiCollectionDoc->setEncoding($contentTypeCharset);
    $unapiCollection = new XML("formats");
    if (!empty($unapiID)) {
        $unapiCollection->setTagAttribute("id", $unapiID);
    }
    // Recommended format names are given at <http://unapi.stikipad.com/unapi/show/existing+formats>
    // TODO: add 'ISI', 'ODF XML' and 'Word XML'
    addNewBranch($unapiCollection, "format", array("name" => "bibtex", "type" => "text/plain", "docs" => "http://en.wikipedia.org/wiki/BibTeX"), "");
    // function 'addNewBranch()' is defined in 'webservice.inc.php'
    addNewBranch($unapiCollection, "format", array("name" => "endnote", "type" => "text/plain", "docs" => "http://www.ecst.csuchico.edu/~jacobsd/bib/formats/endnote.html"), "");
    addNewBranch($unapiCollection, "format", array("name" => "ris", "type" => "text/plain", "docs" => "http://www.adeptscience.co.uk/kb/article/A626"), "");
    addNewBranch($unapiCollection, "format", array("name" => "atom", "type" => "application/atom+xml", "docs" => "http://www.atomenabled.org/developers/syndication/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "mods", "type" => "application/xml", "docs" => "http://www.loc.gov/standards/mods/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "oai_dc", "type" => "application/xml", "docs" => "http://www.openarchives.org/OAI/openarchivesprotocol.html#dublincore"), "");
    addNewBranch($unapiCollection, "format", array("name" => "srw_dc", "type" => "application/xml", "docs" => "http://www.loc.gov/standards/sru/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "srw_mods", "type" => "application/xml", "docs" => "http://www.loc.gov/standards/sru/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "html", "type" => "text/html", "docs" => "http://www.w3.org/MarkUp/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "rtf", "type" => "application/rtf", "docs" => "http://en.wikipedia.org/wiki/Rich_Text_Format"), "");
    addNewBranch($unapiCollection, "format", array("name" => "pdf", "type" => "application/pdf", "docs" => "http://partners.adobe.com/public/developer/pdf/index_reference.html"), "");
    addNewBranch($unapiCollection, "format", array("name" => "latex", "type" => "application/x-latex", "docs" => "http://en.wikipedia.org/wiki/LaTeX"), "");
    addNewBranch($unapiCollection, "format", array("name" => "markdown", "type" => "text/plain", "docs" => "http://daringfireball.net/projects/markdown/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "text", "type" => "text/plain"), "");
    $unapiCollectionDoc->setXML($unapiCollection);
    $unapiCollectionString = $unapiCollectionDoc->getXMLString();
    return $unapiCollectionString;
}
 public function setTitle($value, $position = null)
 {
     $doc = new XMLDocument();
     $doc->loadHTML("<title>{$value}</title>");
     $node = $this->importNode($doc->xpath('//title')->item(0), true);
     return $this->insertNodeIntoHead($node, $position);
 }
Пример #3
0
 /**
  * Gets line number for where the node is defined.
  *
  * The method `DOMNode::getLineNo()` does not return the correct line number for text nodes. So this method
  * can return either the original line number returned by libxml or the fixed and correct line number
  * created by the `XMLDocument::fixLineNumbers()` method.
  *
  * @return int Either the original line number returned by libxml or the fixed and correct line number
  * created by the `XMLDocument::fixLineNumbers()` method.
  */
 public function getLineNo()
 {
     $container = $this->ownerDocument->getLineNumberContainer();
     if ($container && $container->contains($this)) {
         return $container->offsetGet($this);
     }
     return parent::getLineNo();
 }
Пример #4
0
 public function render(Register $ParameterOutput)
 {
     $doc = new XMLDocument();
     $root = $doc->createElement($this->parameters()->{'root-element'});
     try {
         $static = new XMLDocument();
         $node = $static->loadXML($this->parameters()->xml);
         $root->appendChild($doc->importNode($static->documentElement, true));
     } catch (FrontendPageNotFoundException $error) {
         FrontendPageNotFoundExceptionHandler::render($error);
     } catch (Exception $error) {
         $root->appendChild($doc->createElement('error', General::sanitize($error->getMessage())));
     }
     $doc->appendChild($root);
     return $doc;
 }
Пример #5
0
 protected function &_buildFragTree($fragmentName)
 {
     //$xmlPath = __ROOT_PATH.DS."view".DS.Registry::get( "viewName" ).DS."fragments".DS.$fragmentName.".xml";
     $xmlPath = __ROOT_PATH . DS . "view" . DS . substr(get_class($this), 4) . DS . "fragments" . DS . $fragmentName . ".xml";
     $compTree = XMLDocument::buildTree($xmlPath);
     return $compTree;
 }
Пример #6
0
 public function __construct($version = '1.0', $encoding = 'utf-8', $dtd = 'html')
 {
     //}, DOMDocumentType $dtd=NULL){
     parent::__construct($version, $encoding);
     $this->registerNodeClass('DOMDocument', 'HTMLDocument');
     $this->registerNodeClass('DOMElement', 'SymphonyDOMElement');
     $this->appendChild($this->createElement('html'));
     /*$this->loadHTML(
     			sprintf("%s\n<html/>", '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
     		));
     		*/
     $this->Headers = new DocumentHeaders(array('Content-Type', "text/html; charset={$encoding}"));
     $this->dtd = $dtd;
     //if(is_null($dtd)){
     //	$dtd = DOMImplementation::createDocumentType('html');
     //}
     //$this->Document = DOMImplementation::createDocument(NULL, 'html', $dtd);
     //$this->version = $version;
     //$this->encoding = $encoding;
     $this->preserveWhitespace = false;
     $this->formatOutput = true;
     $this->Html = $this->documentElement;
     $this->Head = $this->createElement('head');
     $this->Html->appendChild($this->Head);
     $this->Body = $this->createElement('body');
     $this->Html->appendChild($this->Body);
 }
 public function getEntities()
 {
     REST::requireRequestMethod('GET');
     $db = new MySQL();
     $entitiesNode = new XMLNode('entities');
     foreach (Model::getEntities() as $entity) {
         $entityNode = new XMLNode('entity');
         $entityNode->setAttribute('identifier', $entity['IDENTIFIER']);
         $entityNode->setAttribute('friendlyname', $entity['FRIENDLYNAME']);
         $entityNode->setAttribute('lat', $entity['LATITUDE']);
         $entityNode->setAttribute('lon', $entity['LONGITUDE']);
         $entityNode->setAttribute('date', strtotime($entity['DATETIME']));
         $entitiesNode->addNode($entityNode);
     }
     $xmlDoc = new XMLDocument();
     $xmlDoc->setRootNode($entitiesNode);
     REST::sendResponse(200, $xmlDoc, 'application/xml');
 }
Пример #8
0
function oaidcCollection($result)
{
    global $contentTypeCharset;
    // these variables are defined in 'ini.inc.php'
    global $convertExportDataToUTF8;
    global $citeKeysArray;
    // '$citeKeysArray' is made globally available from
    // within this function
    // Individual records are objects and collections of records are strings
    $oaidcCollectionDoc = new XMLDocument();
    if ($convertExportDataToUTF8 == "yes" and $contentTypeCharset != "UTF-8") {
        $oaidcCollectionDoc->setEncoding("UTF-8");
    } else {
        $oaidcCollectionDoc->setEncoding($contentTypeCharset);
    }
    $oaidcCollection = new XML("dcCollection");
    $oaidcCollection->setTagAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
    $oaidcCollection->setTagAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
    $oaidcCollection->setTagAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    $oaidcCollection->setTagAttribute("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd");
    // ----------------------------------------------------------
    // Add OAI_DC XML entries:
    $exportArray = array();
    // array for individually exported records
    $citeKeysArray = array();
    // array of cite keys (used to ensure uniqueness of cite keys among all exported records)
    // Generate the export for each record and push them onto an array:
    while ($row = @mysql_fetch_array($result)) {
        // Export the current record as OAI_DC XML:
        $record = oaidcRecord($row, "oai_dc");
        if (!empty($record)) {
            // unless the record buffer is empty...
            array_push($exportArray, $record);
        }
        // ...add it to an array of exports
    }
    // for each of the OAI_DC XML entries in the result set...
    foreach ($exportArray as $oaidc) {
        $oaidcCollection->addXMLasBranch($oaidc);
    }
    $oaidcCollectionDoc->setXML($oaidcCollection);
    $oaidcCollectionString = $oaidcCollectionDoc->getXMLString();
    return $oaidcCollectionString;
}
Пример #9
0
 public function getTileUrl()
 {
     REST::requireRequestMethod('GET');
     $requiredParameters = array('lat', 'lon', 'zoom');
     if (Util::isValid($requiredParameters, $values, $this->params)) {
         extract($values);
         $url = "http://tile.openstreetmap.org/" . Map::getTileNumber($lat, $lon, $zoom) . ".png";
         $urlNode = new XMLNode('url');
         $urlNode->setAttribute('href', $url);
         $mapNode = new XMLNode('map');
         $mapNode->setAttributes($values);
         $mapNode->addNode($urlNode);
         $xmlDoc = new XMLDocument();
         $xmlDoc->setRootNode($mapNode);
         REST::sendResponse(200, $xmlDoc, 'application/xml');
     } else {
         REST::sendResponse(400);
     }
 }
Пример #10
0
 public function getTree($attr = NULL)
 {
     $delta = mktime(19, 0, 0, 10, 1, 2011) - time();
     $day = (int) ($delta / (60 * 60 * 24));
     $hour = "X";
     $minute = "X";
     $saltAndPepper = array("day" => $day, "hour" => $hour, "minute" => $minute);
     $content = $this->_compileTemplate("item.template.php", $saltAndPepper);
     $tree = XMLDocument::buildTree($content, XMLDocument::BUILD_MODE_FROM_TEXT);
     return $tree;
 }
Пример #11
0
 private function getFormatDocumentLevel($aLevel, $aSpace)
 {
     $tSpace1 = str_repeat($aSpace, $aLevel + 1);
     $tTagName = $this->getFirstTagName();
     if ($tTagName === null) {
         return $this;
     }
     $tXMLString = "\n";
     $tXMLDocument = new XMLDocument($this->iXMLString);
     while (($tTagName = $tXMLDocument->getFirstTagName()) !== null) {
         $tTemp = $tXMLDocument->getValue($tTagName);
         $tSpace = "";
         if ($tTemp->getFirstTagName() !== null) {
             $tSpace = $tSpace1;
         }
         $tXMLString = "{$tXMLString}{$tSpace1}<{$tTagName}>" . $tTemp->getFormatDocumentLevel($aLevel + 1, $aSpace) . "{$tSpace}</{$tTagName}>\n";
         $tXMLDocument = $tXMLDocument->deleteFirstTagDocument();
     }
     return new XMLDocument($tXMLString);
 }
Пример #12
0
 public function getTree($attr = NULL)
 {
     if ($this->_isValid) {
         $fotki = Filesystem::getFilesFromDir("img/photo", "jpg");
         $content = "";
         for ($i = 0; is_array($fotki) && $i < count($fotki); $i++) {
             $saltAndPepper = array("src" => $fotki[$i], "class" => "v");
             $content .= $this->_compileTemplate("item.template.php", $saltAndPepper);
         }
         $tree = XMLDocument::buildTree($content, XMLDocument::BUILD_MODE_FROM_TEXT);
     }
     return $tree;
 }
Пример #13
0
 public function getTree($attr = NULL)
 {
     //print_r( $this->_params ); die;
     if ($this->_isValid) {
         $content = "";
         for ($i = 0; is_array($this->_params) && $i < count($this->_params); $i++) {
             $saltAndPepper = $this->_params[$i];
             $saltAndPepper["checked"] = $i == 0 ? "checked=\"\"" : "";
             $content .= $this->_compileTemplate("item.template.php", $saltAndPepper);
         }
         //echo $content; die;
         $tree = XMLDocument::buildTree($content, XMLDocument::BUILD_MODE_FROM_TEXT);
     }
     return $tree;
 }
Пример #14
0
 public function getZones()
 {
     REST::requireRequestMethod('GET');
     $zonesNode = new XMLNode('zones');
     foreach (Model::getZones() as $zone) {
         $zoneNode = new XMLNode('zone');
         $zoneNode->setAttribute('id', $zone['ID']);
         $zoneNode->setAttribute('type', $zone['TYPE']);
         $zoneNode->setAttribute('date', strtotime($zone['CREATED_ON']));
         $zoneNode->setAttribute('deleted', $zone['DELETED_ON'] != '0000-00-00 00:00:00' ? 'true' : 'false');
         $waypointsNode = new XMLNode('waypoints');
         foreach (Model::getWaypoints($zone['ID']) as $waypoint) {
             $waypointNode = new XMLNode('waypoint');
             $waypointNode->setAttribute('latitude', $waypoint['LATITUDE']);
             $waypointNode->setAttribute('longitude', $waypoint['LONGITUDE']);
             $waypointsNode->addNode($waypointNode);
         }
         $zoneNode->addNode($waypointsNode);
         $zonesNode->addNode($zoneNode);
     }
     $xmlDoc = new XMLDocument();
     $xmlDoc->setRootNode($zonesNode);
     REST::sendResponse(200, $xmlDoc, 'application/xml');
 }
 public function getTree($attr = NULL)
 {
     //print_r( $this->_params ); die;
     if ($this->_isValid) {
         $content = "";
         for ($i = 0; is_array($this->_params) && $i < count($this->_params); $i++) {
             $saltAndPepper = $this->_params[$i];
             $saltAndPepper["title"] = htmlspecialchars($saltAndPepper["title"], ENT_QUOTES);
             $saltAndPepper["guest"] = htmlspecialchars($saltAndPepper["guest"], ENT_QUOTES);
             $content .= $saltAndPepper["guestN"] > 0 ? $this->_compileTemplate("item-busy.template.php", $saltAndPepper) : $this->_compileTemplate("item.template.php", $saltAndPepper);
         }
         //echo $content; die;
         $tree = XMLDocument::buildTree($content, XMLDocument::BUILD_MODE_FROM_TEXT);
     }
     return $tree;
 }
 public function getTree($attr = NULL)
 {
     //print_r( $this->_params ); die;
     if ($this->_isValid) {
         $content = "";
         if (count($this->_params) % 2 != 0) {
             $this->_params[] = array("n" => "", "guest" => "");
         }
         for ($i = 0; is_array($this->_params) && $i < count($this->_params); $i = $i + 2) {
             $saltAndPepper = array("guest1" => $this->_params[$i]["guest"], "guest2" => $this->_params[$i + 1]["guest"], "n1" => $this->_params[$i]["n"], "n2" => $this->_params[$i + 1]["n"]);
             $content .= $this->_compileTemplate("row.template.php", $saltAndPepper);
         }
         //echo $content; die;
         $tree = XMLDocument::buildTree($content, XMLDocument::BUILD_MODE_FROM_TEXT);
     }
     return $tree;
 }
Пример #17
0
 public function getTree($attr = NULL)
 {
     if (isset($this->_params)) {
         $tree = new xmlTree();
         $text = new xmlNode("#text");
         $text->text($this->_params[0]["dsc"]);
         $div = new xmlNode("div");
         $div->addChild($text);
         $div->setAttribute("class", "error-dsc");
         $tree->addChild($div);
         //echo $tree; die;
         return XMLDocument::buildTree("<div class=\"error-dsc\">{$this->_params[0]["dsc"]}</div>", XMLDocument::BUILD_MODE_FROM_TEXT);
         //return $tree;
     } else {
         return new xmlTree();
     }
 }
 public function getTree($attr = NULL)
 {
     if ($this->_isValid) {
         $t = "item.template.php";
         $content = "";
         for ($i = 0; is_array($this->_params) && $i < count($this->_params); $i++) {
             //if ( $i == 0 ) $content .= "<input type=\"hidden\" id=\"__L\" value=\"{$this->_params[$i]["n"]}\"/>";
             $saltAndPepper = $this->_params[$i];
             $saltAndPepper["admin_answer"] = strlen($this->_params[$i]["admin_answer"]) > 0 ? $this->_compileTemplate("admin.template.php", array("date" => $this->_params[$i]["admin_answer_date"], "answer" => $this->_params[$i]["admin_answer"])) : "";
             $content .= $this->_compileTemplate($t, $saltAndPepper);
         }
         $tree = XMLDocument::buildTree($content, XMLDocument::BUILD_MODE_FROM_TEXT);
     } else {
         $tree = new xmlTree();
     }
     return $tree;
 }
Пример #19
0
 public function render(Register $Parameters, XMLDocument &$Document = NULL, DocumentHeaders &$Headers = NULL)
 {
     $ParameterOutput = new Register();
     if (!is_null($Headers)) {
         $Headers->append('Content-Type', $this->{'content-type'});
     } else {
         header('Content-Type: ' . $this->{'content-type'});
     }
     if (is_null($Document)) {
         $Document = new XMLDocument();
         $Document->appendChild($Document->createElement('data'));
     }
     $root = $Document->documentElement;
     $datasources = $events = array();
     $events_wrapper = $Document->createElement('events');
     $root->appendChild($events_wrapper);
     if (is_array($this->about()->{'events'}) && !empty($this->about()->{'events'})) {
         $events = $this->about()->{'events'};
     }
     if (is_array($this->about()->{'data-sources'}) && !empty($this->about()->{'data-sources'})) {
         $datasources = $this->about()->{'data-sources'};
     }
     ####
     # Delegate: FrontendEventsAppend
     # Description: Append additional Events.
     # Global: Yes
     Extension::notify('FrontendEventsAppend', '/frontend/', array('events' => &$events));
     if (!empty($events)) {
         $postdata = General::getPostData();
         $events_ordered = array();
         foreach ($events as $handle) {
             $events_ordered[] = Event::loadFromHandle($handle);
         }
         uasort($events_ordered, array($this, '__cbSortEventsByPriority'));
         foreach ($events_ordered as $e) {
             if (!$e->canTrigger($postdata)) {
                 continue;
             }
             $fragment = $e->trigger($ParameterOutput, $postdata);
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $Document->importNode($fragment->documentElement, true);
                 $events_wrapper->appendChild($node);
             }
         }
     }
     ####
     # Delegate: FrontendDataSourceAppend
     # Description: Append additional DataSources.
     # Global: Yes
     Extension::notify('FrontendDataSourcesAppend', '/frontend/', array('datasources' => &$datasources));
     //	Find dependancies and order accordingly
     $datasource_pool = array();
     $dependency_list = array();
     $datasources_ordered = array();
     $all_dependencies = array();
     foreach ($datasources as $handle) {
         $datasource_pool[$handle] = Datasource::loadFromHandle($handle);
         $dependency_list[$handle] = $datasource_pool[$handle]->parameters()->dependencies;
     }
     $datasources_ordered = $this->__sortByDependencies($dependency_list);
     if (!empty($datasources_ordered)) {
         foreach ($datasources_ordered as $handle) {
             $ds = $datasource_pool[$handle];
             try {
                 $fragment = $ds->render($ParameterOutput);
             } catch (FrontendPageNotFoundException $e) {
                 FrontendPageNotFoundExceptionHandler::render($e);
             }
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $Document->importNode($fragment->documentElement, true);
                 $root->appendChild($node);
             }
         }
     }
     if ($ParameterOutput->length() > 0) {
         foreach ($ParameterOutput as $p) {
             $Parameters->{$p->key} = $p->value;
         }
     }
     ####
     # Delegate: FrontendParamsPostResolve
     # Description: Access to the resolved param pool, including additional parameters provided by Data Source outputs
     # Global: Yes
     Extension::notify('FrontendParamsPostResolve', '/frontend/', array('params' => $Parameters));
     $element = $Document->createElement('parameters');
     $root->appendChild($element);
     foreach ($Parameters as $key => $parameter) {
         if (is_array($parameter->value) && count($parameter->value) > 1) {
             $p = $Document->createElement($key);
             $p->setAttribute('value', (string) $parameter);
             foreach ($parameter->value as $v) {
                 $p->appendChild($Document->createElement('item', (string) $v));
             }
             $element->appendChild($p);
         } else {
             $element->appendChild($Document->createElement($key, (string) $parameter));
         }
     }
     $template = $this->template;
     ####
     # Delegate: FrontendTemplatePreRender
     # Description: Access to the template source, before it is rendered.
     # Global: Yes
     Extension::notify('FrontendTemplatePreRender', '/frontend/', array('document' => $Document, 'template' => &$template));
     $this->template = $template;
     // When the XSLT executes, it uses the CWD as set here
     $cwd = getcwd();
     chdir(WORKSPACE);
     $output = XSLProc::transform($Document, $this->template, XSLProc::XML, $Parameters->toArray(), array());
     chdir($cwd);
     if (XSLProc::hasErrors()) {
         throw new XSLProcException('Transformation Failed');
     }
     /*
     header('Content-Type: text/plain; charset=utf-8');
     $Document->formatOutput = true;
     print $Document->saveXML();
     die();
     */
     return $output;
 }
Пример #20
0
 /**
  * Get a single item from the server.
  *
  * @param string $url The URL to PROPFIND on
  */
 function DoPROPFINDRequest($url, $props, $depth = 0)
 {
     $this->SetDepth($depth);
     $xml = new XMLDocument(array('DAV:' => '', 'urn:ietf:params:xml:ns:caldav' => 'C'));
     $prop = new XMLElement('prop');
     foreach ($props as $v) {
         $xml->NSElement($prop, $v);
     }
     $this->body = $xml->Render('propfind', $prop);
     $this->requestMethod = 'PROPFIND';
     $this->SetContentType('text/xml');
     $this->DoRequest($url);
     return $this->GetXmlResponse();
 }
Пример #21
0
 /**
  * Send a need-privileges error response.  This function will only return
  * if the $href is not supplied and the current user has the specified
  * permission for the request path.
  *
  * @param string $privilege The name of the needed privilege.
  * @param string $href The unconstructed URI where we needed the privilege.
  */
 function NeedPrivilege($privileges, $href = null)
 {
     if (is_string($privileges)) {
         $privileges = array($privileges);
     }
     if (!isset($href)) {
         if ($this->HavePrivilegeTo($privileges)) {
             return;
         }
         $href = $this->path;
     }
     $reply = new XMLDocument(array('DAV:' => ''));
     $privnodes = array($reply->href(ConstructURL($href)), new XMLElement('privilege'));
     // RFC3744 specifies that we can only respond with one needed privilege, so we pick the first.
     $reply->NSElement($privnodes[1], $privileges[0]);
     $xml = new XMLElement('need-privileges', new XMLElement('resource', $privnodes));
     $xmldoc = $reply->Render('error', $xml);
     $this->DoResponse(403, $xmldoc, 'text/xml; charset="utf-8"');
     exit(0);
     // Unecessary, but might clarify things
 }
Пример #22
0
 public function trigger(Register $parameter_output, array $data)
 {
     $errors = new MessageStack();
     $result = new XMLDocument();
     $result->appendChild($result->createElement($this->parameters()->{'root-element'}));
     $result->formatOutput = true;
     $root = $result->documentElement;
     try {
         $this->root = $root;
         $status = $this->login($errors, $parameter_output, $data);
         $root->setAttribute('result', 'success');
     } catch (Exception $error) {
         $root->setAttribute('result', 'error');
         $root->appendChild($result->createElement('message', $error->getMessage()));
         if ($errors->valid()) {
             $element = $result->createElement('errors');
             $this->appendMessages($element, $errors);
             $root->appendChild($element);
         }
         //echo '<pre>', htmlentities($result->saveXML()), '</pre>'; exit;
     }
     return $result;
 }
Пример #23
0
function srwDiagnostics($diagCode, $diagDetails, $exportStylesheet)
{
    global $contentTypeCharset;
    // defined in 'ini.inc.php'
    // Map SRU/W diagnostic numbers to their corresponding messages:
    $diagMessages = mapSRWDiagnostics();
    // function 'mapSRWDiagnostics()' is defined in 'webservice.inc.php'
    if (isset($diagMessages[$diagCode])) {
        $diagMessage = $diagMessages[$diagCode];
    } else {
        $diagMessage = "Unknown error";
    }
    $srwCollectionDoc = new XMLDocument();
    $srwCollectionDoc->setEncoding($contentTypeCharset);
    $srwCollection = srwGenerateBaseTags("searchRetrieveResponse");
    $diagnosticsBranch = new XMLBranch("srw:diagnostics");
    // since we've defined the 'diag' namespace in the <searchRetrieveResponse> element (see function 'srwGenerateBaseTags()'),
    // we can simply use '<diag:diagnostic>' below; otherwise we should use '<diagnostic xmlns="http://www.loc.gov/zing/srw/diagnostic/">':
    // addNewBranch($diagnosticsBranch, "diagnostic", array("xmlns" => "http://www.loc.gov/zing/srw/diagnostic/"), "");
    $diagnosticsBranch->setTagContent("info:srw/diagnostic/1/" . $diagCode, "srw:diagnostics/diag:diagnostic/uri");
    $diagnosticsBranch->setTagContent($diagMessage, "srw:diagnostics/diag:diagnostic/message");
    if (!empty($diagDetails)) {
        $diagnosticsBranch->setTagContent(encodeHTMLspecialchars($diagDetails), "srw:diagnostics/diag:diagnostic/details");
    }
    $srwCollection->addXMLBranch($diagnosticsBranch);
    $srwCollectionDoc->setXML($srwCollection);
    $srwCollectionString = $srwCollectionDoc->getXMLString();
    // Add the XML Stylesheet definition:
    // Note that this is just a hack (that should get fixed) since I don't know how to do it properly using the ActiveLink PHP XML Package ?:-/
    if (!empty($exportStylesheet)) {
        $srwCollectionString = preg_replace("/(?=\\<srw:searchRetrieveResponse)/i", "<?xml-stylesheet type=\"text/xsl\" href=\"" . $exportStylesheet . "\"?>\n", $srwCollectionString);
    }
    return $srwCollectionString;
}
Пример #24
0
 public function toDoc()
 {
     $doc = new XMLDocument();
     $root = $doc->createElement('field');
     $root->setAttribute('guid', $this->guid);
     foreach ($this->properties as $name => $value) {
         if ($name == 'guid') {
             continue;
         }
         $element = $doc->createElement($name);
         $element->setValue($value);
         $root->appendChild($element);
     }
     $doc->appendChild($root);
     return $doc;
 }
Пример #25
0
 public function __buildPageXML($view, View $parent = null)
 {
     $result = new XMLDocument();
     $xView = $result->createElement('view');
     $xView->setAttribute('handle', $view->handle);
     $xView->appendChild($result->createElement('title', $view->title));
     ##	Types
     if (is_array($view->types) && count($view->types) > 0) {
         $types = $result->createElement('types');
         foreach ($view->types as $t) {
             $types->appendChild($result->createElement('item', General::sanitize($t)));
         }
         $xView->appendChild($types);
     }
     ##	Children
     foreach ($view->children() as $child) {
         $node = $this->__buildPageXML($child, $view);
         if (!is_null($node)) {
             $xView->appendChild($result->importNode($node, true));
         }
     }
     return $xView;
 }
Пример #26
0
* inventing our own.  As well as Xythos, Cosmo follows this specification,
* with some documented variations, which we will also follow.  In particular
* we use the xmlns="http://www.xythos.com/namespaces/StorageServer" rather
* than the DAV: namespace.
*
* @package   davical
* @subpackage   caldav
* @author    Andrew McMillan <*****@*****.**>
* @copyright Morphoss Ltd - http://www.morphoss.com/
* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
*/
dbg_error_log('MKTICKET', 'method handler');
require_once 'DAVResource.php';
$request->NeedPrivilege('DAV::bind');
require_once 'XMLDocument.php';
$reply = new XMLDocument(array('DAV:' => '', 'http://www.xythos.com/namespaces/StorageServer' => 'T'));
$target = new DAVResource($request->path);
if (!$target->Exists()) {
    $request->XMLResponse(404, new XMLElement('error', new XMLElement('resource-must-not-be-null'), $reply->GetXmlNsArray()));
}
if (!isset($request->xml_tags)) {
    $request->XMLResponse(400, new XMLElement('error', new XMLElement('missing-xml-for-request'), $reply->GetXmlNsArray()));
}
$xmltree = BuildXMLTree($request->xml_tags, $position);
if ($xmltree->GetTag() != 'http://www.xythos.com/namespaces/StorageServer:ticketinfo' && $xmltree->GetTag() != 'DAV::ticketinfo') {
    $request->XMLResponse(400, new XMLElement('error', new XMLElement('invalid-xml-for-request'), $reply->GetXmlNsArray()));
}
$ticket_timeout = 'Seconds-3600';
$ticket_privs_array = array('read-free-busy');
foreach ($xmltree->GetContent() as $k => $v) {
    // <!ELEMENT ticketinfo (id?, owner?, timeout, visits, privilege)>
Пример #27
0
 /**
  * Get a single item from the server.
  *
  * @param string $url The URL to PROPFIND on
  */
 function DoPROPFINDRequest($url, $props, $depth = 0)
 {
     $this->SetDepth($depth);
     $xml = new XMLDocument(array('DAV:' => '', 'urn:ietf:params:xml:ns:caldav' => 'C'));
     $prop = new XMLElement('prop');
     foreach ($props as $v) {
         $xml->NSElement($prop, $v);
     }
     $this->DoRequest($url, "PROPFIND", $xml->Render('propfind', $prop), "text/xml");
     return $this->xmlResponse;
 }
 /**
  * Build the navigation XML and append it to the root element
  * Copied method -- TODO cleanup
  */
 public function buildNavigationXML($root)
 {
     $xpath = new DOMXPath($this->document);
     $template = new XMLDocument();
     $template->preserveWhiteSpace = false;
     $template->load(TEMPLATES . '/navigation.xml');
     $navigation = $this->document->importNode($template->documentElement, true);
     $first_child = $navigation->firstChild;
     // Force visible to be set:
     foreach ($xpath->query('group//item[not(@visible)]', $navigation) as $item) {
         $item->setAttribute('visible', 'yes');
     }
     // Set all items as inactive:
     foreach ($xpath->query('group//item', $navigation) as $item) {
         $item->setAttribute('active', 'no');
     }
     // Add section navigation:
     foreach (new SectionIterator() as $section) {
         // Find the navigation group:
         $group = $xpath->query(sprintf('group[@name = "%s"]', htmlentities($section->{'navigation-group'})), $navigation);
         $group = $group->item(0);
         if (is_null($group)) {
             $group = $this->document->createElement('group');
             $group->setAttribute('name', $section->{'navigation-group'});
             $group->setAttribute('type', 'sections');
             $first_child->parentNode->insertBefore($group, $first_child);
         }
         $item = $this->document->createElement('item');
         $item->setAttribute('link', 'publish/' . $section->handle);
         $item->setAttribute('name', $section->name);
         $item->setAttribute('type', 'section');
         $item->setAttribute('visible', $section->{'hidden-from-publish-menu'} == 'no' ? 'yes' : 'no');
         $item->setAttribute('active', 'no');
         $group->appendChild($item);
         // New link:
         $sub_item = clone $item;
         $sub_item->setAttribute('link', 'publish/' . $section->handle . '/new');
         $sub_item->setAttribute('name', __('New'));
         $item->appendChild($sub_item);
         // Edit link:
         $sub_item = clone $sub_item;
         $sub_item->setAttribute('link', 'publish/' . $section->handle . '/edit');
         $sub_item->setAttribute('name', __('Edit'));
         $sub_item->setAttribute('visible', 'no');
         $item->appendChild($sub_item);
     }
     // Remove empty groups:
     foreach ($xpath->query('group[not(item)]', $navigation) as $group) {
         $group->parentNode->removeChild($group);
     }
     // Assign handles to all groups:
     foreach ($xpath->query('group[not(@handle)]', $navigation) as $group) {
         $group->setAttribute('handle', Lang::createHandle($group->getAttribute('name')));
     }
     // Find active page:
     $active = $xpath->query(sprintf('group//item[@link = "%s"]', htmlentities($this->path)), $navigation);
     $active = $active->item(0);
     if ($active instanceof DOMElement) {
         $active->setAttribute('active', 'yes');
     }
     //$this->document->formatOutput = true;
     //echo '<pre>', htmlentities($this->document->saveXML($navigation)); exit;
     $root->appendChild($navigation);
 }
Пример #29
0
<?php

/**
* We support both LOCK and UNLOCK methods in this function
*/
require_once 'XMLDocument.php';
$reply = new XMLDocument(array('DAV:' => ''));
if (!$request->AllowedTo('write')) {
    $request->NeedPrivilege('write', $request->path);
}
if (!isset($request->xml_tags)) {
    if (isset($request->lock_token)) {
        // It's OK for LOCK refresh requests to be empty.
        $request->xml_tags = array();
    } else {
        $request->XMLResponse(400, new XMLElement('error', new XMLElement('missing-xml-for-request'), $reply->GetXmlNsArray()));
    }
}
$unsupported = array();
$lockinfo = array();
$inside = array();
foreach ($request->xml_tags as $k => $v) {
    $tag = $v['tag'];
    dbg_error_log("LOCK", " Handling Tag '%s' => '%s' ", $k, $v);
    switch ($tag) {
        case 'DAV::lockinfo':
            dbg_error_log("LOCK", ":Request: %s -> %s", $v['type'], $tag);
            if ($v['type'] == "open") {
                $lockscope = "";
                $locktype = "";
                $lockowner = "";
Пример #30
0
function modsCollection($result)
{
    global $contentTypeCharset;
    // these variables are defined in 'ini.inc.php'
    global $convertExportDataToUTF8;
    global $citeKeysArray;
    // '$citeKeysArray' is made globally available from
    // within this function
    // The array '$transtab_refbase_unicode' contains search & replace patterns
    // for conversion from refbase markup to Unicode entities.
    global $transtab_refbase_unicode;
    // defined in 'transtab_refbase_unicode.inc.php'
    global $fieldSpecificSearchReplaceActionsArray;
    // Individual records are objects and collections of records are strings
    $exportArray = array();
    // array for individually exported records
    $citeKeysArray = array();
    // array of cite keys (used to ensure uniqueness of
    // cite keys among all exported records)
    // Defines field-specific search & replace 'actions' that will be applied to all
    // those refbase fields that are listed in the corresponding 'fields' element:
    // (If you don't want to perform any search and replace actions, specify an empty
    //  array, like: '$fieldSpecificSearchReplaceActionsArray = array();'.
    //  Note that the search patterns MUST include the leading & trailing slashes --
    //  which is done to allow for mode modifiers such as 'imsxU'.)
    $fieldSpecificSearchReplaceActionsArray = array();
    if ($convertExportDataToUTF8 == "yes") {
        $fieldSpecificSearchReplaceActionsArray[] = array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_unicode);
    }
    // Generate the export for each record and push them onto an array:
    while ($row = @mysql_fetch_array($result)) {
        // Export the current record as MODS XML
        $record = modsRecord($row);
        if (!empty($record)) {
            // unless the record buffer is empty...
            array_push($exportArray, $record);
        }
        // ...add it to an array of exports
    }
    $modsCollectionDoc = new XMLDocument();
    if ($convertExportDataToUTF8 == "yes" and $contentTypeCharset != "UTF-8") {
        $modsCollectionDoc->setEncoding("UTF-8");
    } else {
        $modsCollectionDoc->setEncoding($contentTypeCharset);
    }
    $modsCollection = new XML("modsCollection");
    $modsCollection->setTagAttribute("xmlns", "http://www.loc.gov/mods/v3");
    foreach ($exportArray as $mods) {
        $modsCollection->addXMLasBranch($mods);
    }
    $modsCollectionDoc->setXML($modsCollection);
    $modsCollectionString = $modsCollectionDoc->getXMLString();
    return $modsCollectionString;
}