本文整理汇总了PHP中Document::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::load方法的具体用法?PHP Document::load怎么用?PHP Document::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document::load方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: implode
/**
* @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);
}
}
}
}
示例2: DOMDocument
/**
* @param String $url
* @return XMLHandler
*/
function __construct($url)
{
$this->doc = new DOMDocument();
if (!@$this->doc->load($url)) {
throw new XMLLoadException($url);
}
}
示例3: place
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));
}
示例4: Document
<?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']);
}
示例5: getInstance
/**
* 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);
}
示例6: Document
<?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();
示例7: extract_budget_spendings
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');
}
}
示例8: testLoad_returnsTrue_ifSuccess
/**
* 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;
}