本文整理匯總了PHP中Document類的典型用法代碼示例。如果您正苦於以下問題:PHP Document類的具體用法?PHP Document怎麽用?PHP Document使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Document類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initForm
/**
* The function shows edit form and saves data on submit.
*
* @access private
* @param object $Page The Content Page object.
* @return string The HTML code.
*/
protected function initForm(Content_Page $Page)
{
if (isset($_POST['submit'])) {
$Page->setPost($_POST);
$fields = Error::test($Page);
if (count($fields)) {
$this->getView()->set('Error', 'Неверно заполены поля: ' . implode(', ', $fields));
} else {
if ($Page->save()) {
if ($Page->Module && $Page->Link) {
Router::attachPage($Page);
} else {
Router::detachPage($Page);
}
return $this->halt('', true);
} else {
$this->getView()->set('Error', 'Ошибка записи данных: ' . $Page->getError() . "\n" . Database::getInstance()->getLastQuery());
}
}
}
$Document = new Document();
$this->getView()->set('Documents', $Document->findList(array(), 'Position asc'));
$this->getView()->set('Page', $Page);
return $this->getView()->render();
}
示例2: testDocumentPdf
function testDocumentPdf()
{
$o = new Document();
$o->slug = 'imagick-pdf';
$o->suffixe = 'pdf';
$o->storeFile(dirname(__FILE__) . '/images/multipage.pdf');
}
示例3: saveFile
function saveFile($document, $portal = false)
{
global $sugar_config;
$focus = new Document();
if (!empty($document['id'])) {
$focus->retrieve($document['id']);
} else {
return '-1';
}
if (!empty($document['file'])) {
$decodedFile = base64_decode($document['file']);
$this->upload_file->set_for_soap($document['filename'], $decodedFile);
$ext_pos = strrpos($this->upload_file->stored_file_name, ".");
$this->upload_file->file_ext = substr($this->upload_file->stored_file_name, $ext_pos + 1);
if (in_array($this->upload_file->file_ext, $sugar_config['upload_badext'])) {
$this->upload_file->stored_file_name .= ".txt";
$this->upload_file->file_ext = "txt";
}
$revision = new DocumentRevision();
$revision->filename = $this->upload_file->get_stored_file_name();
$revision->file_mime_type = $this->upload_file->getMimeSoap($revision->filename);
$revision->file_ext = $this->upload_file->file_ext;
//$revision->document_name = ;
$revision->revision = $document['revision'];
$revision->document_id = $document['id'];
$revision->save();
$focus->document_revision_id = $revision->id;
$focus->save();
$return_id = $revision->id;
$this->upload_file->final_move($revision->id);
} else {
return '-1';
}
return $return_id;
}
示例4: testRevisionSave
function testRevisionSave()
{
$ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['rowcount1'], 0, 'We created an empty revision');
$ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertTrue(empty($row['document_revision_id']), 'We linked the document to a fake document_revision');
$ds = new DocumentSoap();
$revision_stuff = array('file' => base64_encode('Pickles has an extravagant beard of pine fur.'), 'filename' => 'a_file_about_pickles.txt', 'id' => $this->doc->id, 'revision' => '1');
$revisionId = $ds->saveFile($revision_stuff);
$ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['rowcount1'], 1, 'We didn\'t create a revision when we should have');
$ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['document_revision_id'], $revisionId, 'We didn\'t link the newly created document revision to the document');
// Double saving doesn't work because save doesn't reset the new_with_id
$newDoc = new Document();
$newDoc->retrieve($this->doc->id);
$newDoc->document_revision_id = $revisionId;
$newDoc->save(FALSE);
$ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['rowcount1'], 1, 'We didn\'t create a revision when we should have');
$ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['document_revision_id'], $revisionId, 'We didn\'t link the newly created document revision to the document');
}
示例5: generate
/**
* Generates document using specified data
*
* @param array $data data for template
* @return Document generated document
*/
public function generate($data)
{
$document = new Document();
$document->setFilename("document." . $this->template->getExtension());
$document->setContents($this->replace($this->template->getContents(), $data));
return $document;
}
示例6: getList
public function getList($order = "didascalia")
{
$order = trim(filter_var($order, FILTER_SANITIZE_STRING));
//interrogazione tabella
$sql = "SELECT * FROM upload ORDER BY {$order}";
$auth = $this->connector->query($sql);
$list = array();
// controllo sul risultato dell'interrogazione
if (mysql_num_rows($auth) > 0) {
$doc = new Document();
$doc->setConnector($this->connector);
$course = new Course();
$course->setConnector($this->connector);
while ($res = $this->connector->getObjectResult($auth)) {
$doc = new Document($res->id, $res->path, $res->tipo, $res->didascalia);
//Calcolo le informazioni di servizio
if ($res->tipo == 1) {
$doc->course_name = "TUTTI";
} else {
$doc->course_name = $course->getById($res->tipo)->name;
}
$list[] = $doc;
}
}
return $list;
}
示例7: sendForBilling
function sendForBilling()
{
$response = new Response();
try {
$projectId = $this->input->post("project-id");
$amount = $this->input->post("project-bill-amount");
$billDoc = $this->input->post("bill-doc");
$project = $this->findById("Project", $projectId);
if ($project == null) {
throw new RuntimeException("Invalid Project..!");
}
$project->setStatus(Project::PROJECT_BILL);
$project->getWorkOrder()->setStatus(Workorder::STATUS_COMPLETED);
$project->getWorkOrder()->setApprovedBy($this->getLoggedInUser());
$bill = new Bill();
$bill->setAmount($amount);
$bill->setProject($project);
$bill->setCreated(new DateTime());
$bill->setStatus(Bill::STATUS_PENDING);
if ($billDoc != null && $billDoc != "") {
foreach ($billDoc as $file) {
$doc = new Document();
$doc->setName($file);
$doc->setCreated(new DateTime());
$bill->getBillDoc()->add($doc);
}
}
$this->save($bill);
$response->setData(Project::PROJECT_BILL);
} catch (Exception $e) {
$response->setStatus(false);
$response->setErrorMessage($e->getMessage());
}
$this->output->set_content_type('application/json')->set_output(json_encode($response));
}
示例8: matchDoc
/**
* Match a document to percolator queries
*
* @param \Elastica\Document $doc
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
* are executed.
* @param string $type
* @param array $params Supports setting additional request body options to the percolate request.
* [ Percolator::EXTRA_FILTER,
* Percolator::EXTRA_QUERY,
* Percolator::EXTRA_SIZE,
* Percolator::EXTRA_TRACK_SCORES,
* Percolator::EXTRA_SORT,
* Percolator::EXTRA_FACETS,
* Percolator::EXTRA_AGGS,
* Percolator::EXTRA_HIGHLIGHT ]
* @return array With matching registered queries.
*/
public function matchDoc(Document $doc, $query = null, $type = 'type', $params = array())
{
$path = $this->_index->getName() . '/' . $type . '/_percolate';
$data = array('doc' => $doc->getData());
$this->_applyAdditionalRequestBodyOptions($params, $data);
return $this->_percolate($path, $query, $data, $params);
}
示例9: create_from_pptxn
static function create_from_pptxn($pptxn_id)
{
$t = new PayPalTxn($pptxn_id);
# if it already has a payment_id, stop here and just return that id
if ($t->payment_id() > 0) {
return $t->payment_id();
}
$student_id = $t->student_id();
if ($student_id === false) {
return false;
}
$set = array('student_id' => $student_id, 'created_at' => 'NOW()');
$money = $t->money();
$set['currency'] = $money->code;
$set['millicents'] = $money->millicents;
$info = $t->infoarray();
if (!isset($info['item_number'])) {
return false;
}
$d = new Document($info['item_number']);
if ($d->failed()) {
return false;
}
$set['document_id'] = $d->id;
$p = new Payment(false);
$payment_id = $p->add($set);
$t->set(array('payment_id' => $payment_id));
return $payment_id;
}
示例10: findEntity
function findEntity()
{
$document = new Document();
// Dokument wiederfinden -> Todo: anhand der field_defs generisch suchen
$result = $document->get_list('', 'document_name = "' . $_REQUEST['document_name'] . '"');
return $result['list'][0];
}
示例11: getDocument
/**
* @param mixed $accessor
* @param bool $retrieve
* @return Document|null
*/
public function getDocument($accessor = null, $retrieve = false)
{
if ($accessor === null) {
$accessor = static::DEFAULT_ACCESSOR;
}
if ($accessor === null) {
// the value contains the document itself
$doc = $this->value;
// if the view didn't emit the actual doc as value but was called with include_docs=true
if (!$doc || !isset($doc->_id) && !isset($doc['_id'])) {
$doc = $this->doc;
}
} elseif (is_callable($accessor)) {
// an anonymous function or another kind of callback that will grab the value for us
$doc = call_user_func($accessor, $this);
} elseif (is_array($this->value) && isset($this->value[$accessor])) {
// value is an array
$doc = $this->value[$accessor];
} elseif (isset($this->value->{$accessor})) {
// it's the name of a property
$doc = $this->value->{$accessor};
} else {
// exception
}
if ($doc) {
$retval = new Document($this->getViewResult()->getDatabase());
$retval->hydrate($doc);
return $retval;
} elseif ($retrieve) {
// the view didn't emit the actual doc as value and the view wasn't called with include_docs=true
return $this->viewResult->getDatabase()->retrieveDocument($this->id);
} else {
return null;
}
}
示例12: getTokenIssues
function getTokenIssues($tokenID)
{
$paraID = false;
$context = false;
$place = false;
$db = $this->startDB();
$sql = "SELECT * FROM gap_issues WHERE tokenID = {$tokenID} AND active = 1 ORDER BY updated DESC;";
$result = $db->fetchAll($sql, 2);
$sql = "SELECT * FROM gap_issues WHERE tokenID = {$tokenID} AND active = 0 ORDER BY updated DESC;";
$resultOld = $db->fetchAll($sql, 2);
$tokensObj = new Tokens();
$tokenData = $tokensObj->getTokenByID($tokenID);
$tokensObj->highlightToken = $tokenID;
if (is_array($tokenData)) {
$token = $tokenData["token"];
$paraID = $tokenData["paraID"];
$pageID = $tokenData["pageID"];
$docID = $tokenData["docID"];
$context = $tokensObj->getGapVisDocPage($docID, $pageID, $paraID, $tokenID);
$place = $tokensObj->getPlaceByTokensID($tokenID);
$related = false;
$relatedPlaceTokens = false;
if (is_array($place)) {
$related = $tokensObj->getTokenIDsBySharedPlaceURIid($tokenID, $place["uriID"], $token);
$relatedPlaceTokens = $tokensObj->getUniqueTokensFromPlaceURI($place["uri"]);
}
$docObj = new Document();
$document = $docObj->getByID($docID);
}
$output = array("tokenID" => $tokenID, "token" => $token, "docID" => $docID, "document" => $document, "pageID" => $pageID, "context" => $context, "place" => $place, "related" => $related, "relatedPlaceTokens" => $relatedPlaceTokens, "issues" => $result, "oldIssues" => $resultOld, "oldPlaces" => $tokensObj->getTokenDeactivatedPlaceRefs($tokenID));
return $output;
}
示例13: get_all_linked_attachment_revisions
function get_all_linked_attachment_revisions($attachmentsequence)
{
$attachmentIds = explode(' ', trim($attachmentsequence));
$attachments = array();
foreach ($attachmentIds as $id) {
$revision = new DocumentRevision();
if (!$revision->retrieve($id)) {
// if in old format try to recover by document id
$attachment = new Document();
if ($attachment->retrieve($id)) {
$attachment->revision = '';
$attachment->doc_rev_id = '';
$attachments[] = $attachment;
}
} else {
$attachment = new Document();
if ($attachment->retrieve($revision->document_id)) {
$attachment->revision = $revision->revision;
$attachment->doc_rev_id = $revision->id;
$attachments[] = $attachment;
}
}
}
return $attachments;
}
示例14: addNews
public function addNews()
{
foreach ($this->fileArray as $file) {
$title = explode(".", $file)[0];
$book = new Document($this->path, $file, $title);
$book->save();
}
}
示例15: export
public static function export(Document $document)
{
$json = db::query('SELECT creation_date, data FROM snapshots WHERE document = ' . db::value($document->getId()) . ' ORDER BY creation_date DESC');
foreach ($json as $i => $row) {
$json[$i]['data'] = json_decode($row['data']);
}
return $json;
}