/** * @param String $url * @return XMLHandler */ function __construct($url) { $allowUrlFopenAvailable = ini_get('allow_url_fopen') == "1" || ini_get('allow_url_fopen') == "On"; $cUrlAvailable = function_exists('curl_version'); if (!$allowUrlFopenAvailable && !$cUrlAvailable) { $report = implode(", ", array(sprintf("allow_url_fopen is %s", $allowUrlFopenAvailable ? "On" : "Off"), sprintf("cURL is %s", $cUrlAvailable ? "enabled" : "disabled"))); throw new Exception(sprintf("No feed loading mechanism available - PHP reported %s", $report), ""); } $this->doc = new DOMDocument(); if ($allowUrlFopenAvailable) { if (!@$this->doc->load($url)) { throw new XMLLoadException('(allow_url_fopen method) ' . $url); } } else { if ($cUrlAvailable) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $xml = curl_exec($ch); curl_close($ch); if (!@$this->doc->loadXML($xml)) { throw new XMLLoadException('(cURL method) ' . $url); } } } }
/** * @param String $url * @return XMLHandler */ function __construct($url) { $this->doc = new DOMDocument(); if (!@$this->doc->load($url)) { throw new XMLLoadException($url); } }
public function place($id, $options = array()) { $_options = array(); if ($options) { if ($options == '*') { $_options['package'] = '*'; } elseif (is_numeric($options)) { $_options['package'] = $options; } else { $_options = array_merge(array('package' => 1), $options); } } else { $_options = array('package' => 1); } $options = $_options; App::import("Model", "Document"); $Document = new Document(); $doc = $Document->load($id, $options); return $this->_View->element('Document/view', array('document' => $doc, 'toolbar' => isset($options['toolbar']) ? $options['toolbar'] : true)); }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/config/common.inc.php"; if (isset($_REQUEST["document_id"])) { // Parse response body $xml = simplexml_load_string($GLOBALS['HTTP_RAW_POST_DATA']); // Loads up document by document_id $document = new Document(); if ($document->load("id=" . mysql_escape_string(trim($_REQUEST["document_id"])))) { // Compares XML's GUID with the GUID in database to authenicate request if ($document->rs_document_id == $xml->guid) { // checks status of Document and do a different action switch ((string) $xml->status) { case "created": $document->createdCallback($GLOBALS['HTTP_RAW_POST_DATA']); break; case "viewed": $document->viewedCallback($GLOBALS['HTTP_RAW_POST_DATA']); break; case "signed": $document->completeCallback($GLOBALS['HTTP_RAW_POST_DATA']); break; } } else { error_log("Local Document and XML rs_document_id do not match, ignoring request:"); error_log($GLOBALS['HTTP_RAW_POST_DATA']); } } else { error_log("Cannot find document from 'document_id' params, ignoring request:"); error_log($GLOBALS['HTTP_RAW_POST_DATA']); }
/** * load a document in a Document object and return it * * @static * @param Client $client Client instance * @param string $id id of the document to load * @return Document couch document loaded with data of document $id */ public static function getInstance(Client $client, $id) { $back = new Document($client); return $back->load($id); }
<?php // // Imports RightSignature's Documents into local documents in database // ob_start(); require_once $_SERVER['DOCUMENT_ROOT'] . "/config/common.inc.php"; // Calls API to get documents XML and parses it $documents_xml = simplexml_load_string($rightsignature->getDocuments()); // Loops through each document node and copies guid foreach ($documents_xml->documents->document as $document_node) { $document = new Document(); if ($document->load("rs_document_id=\"" . mysql_escape_string(trim((string) $document_node->guid)) . "\"")) { error_log("Found document with RS guid of" . (string) $document_node->guid . " will just update data"); } else { error_log("Cannot find document with RS guid of" . (string) $document_node->guid . " importing..."); $document->rs_document_id = (string) $document_node->guid; if ($document->save()) { error_log("successfully saved to {$document->id}"); } else { error_log("cannot save document"); } } // gets Document Details from RS for values in document components (Text fields, Date fields, etc...) and merge fields $document_details = $rightsignature->getDocumentDetails($document->rs_document_id); $xml = simplexml_load_string($document_details); // Process Details as necessary print_r($xml); } ob_flush();
public function extract_budget_spendings() { App::import("Model", "Document"); $Document = new Document(); $id = $Document->doc_id_from_attach($this->request->params['id']); $doc = $Document->load($id['doc_id'], false); $xml = $this->S3->getObject('docs.sejmometr.pl', 'xml/' . $id['doc_id'] . '.xml'); $xml = strip_tags($xml->body, '<page><text>'); $xml = str_ireplace(array('<page', '<text', '/text>', '/page>'), array('<div class="page"', '<p', '/p>', '/div>'), $xml); $this->set('doc', $doc); $this->set('xml', $xml); $this->set('_serialize', 'doc'); $this->set('title_for_layout', $doc['Document']['filename']); if ($this->hasUserRole('2')) { $isAdmin = true; } else { $this->redirect('' . $this->request->params['id']); } $this->set('isAdmin', $isAdmin); if (isset($this->request->params['ext']) && in_array($this->request->params['ext'], array('html', 'htm'))) { $this->layout = 'doc'; $this->render('view-html'); } else { $this->render('attachment'); } }
/** * load() should return true if */ public function testLoad_returnsTrue_ifSuccess() { $filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo.rtf'; $contents = '{\\b foo\\b0}'; file_put_contents($filename, $contents); $document = new Document(); try { $this->assertTrue($document->load($filename)); $this->assertEquals(3, $document->getRoot()->getLength()); unlink($filename); } catch (Exception $e) { unlink($filename); throw $e; } return; }