本文整理汇总了PHP中PhrictionDocument::getPHID方法的典型用法代码示例。如果您正苦于以下问题:PHP PhrictionDocument::getPHID方法的具体用法?PHP PhrictionDocument::getPHID怎么用?PHP PhrictionDocument::getPHID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhrictionDocument
的用法示例。
在下文中一共展示了PhrictionDocument::getPHID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildDocumentContentDictionary
protected final function buildDocumentContentDictionary(PhrictionDocument $doc, PhrictionContent $content)
{
$uri = PhrictionDocument::getSlugURI($content->getSlug());
$uri = PhabricatorEnv::getProductionURI($uri);
$doc_status = $doc->getStatus();
return array('phid' => $doc->getPHID(), 'uri' => $uri, 'slug' => $content->getSlug(), 'version' => $content->getVersion(), 'authorPHID' => $content->getAuthorPHID(), 'title' => $content->getTitle(), 'content' => $content->getContent(), 'status' => PhrictionDocumentStatus::getConduitConstant($doc_status), 'description' => $content->getDescription(), 'dateCreated' => $content->getDateCreated());
}
示例2: indexDocument
public static function indexDocument(PhrictionDocument $document)
{
$content = $document->getContent();
$doc = new PhabricatorSearchAbstractDocument();
$doc->setPHID($document->getPHID());
$doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_WIKI);
$doc->setDocumentTitle($content->getTitle());
// TODO: This isn't precisely correct, denormalize into the Document table?
$doc->setDocumentCreated($content->getDateCreated());
$doc->setDocumentModified($content->getDateModified());
$doc->addField(PhabricatorSearchField::FIELD_BODY, $content->getContent());
$doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $content->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $content->getDateCreated());
self::reindexAbstractDocument($doc);
}
示例3: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
if ($this->id) {
$document = id(new PhrictionDocument())->load($this->id);
if (!$document) {
return new Aphront404Response();
}
$revert = $request->getInt('revert');
if ($revert) {
$content = id(new PhrictionContent())->loadOneWhere('documentID = %d AND version = %d', $document->getID(), $revert);
if (!$content) {
return new Aphront404Response();
}
} else {
$content = id(new PhrictionContent())->load($document->getContentID());
}
} else {
$slug = $request->getStr('slug');
$slug = PhabricatorSlug::normalize($slug);
if (!$slug) {
return new Aphront404Response();
}
$document = id(new PhrictionDocument())->loadOneWhere('slug = %s', $slug);
if ($document) {
$content = id(new PhrictionContent())->load($document->getContentID());
} else {
$document = new PhrictionDocument();
$document->setSlug($slug);
$content = new PhrictionContent();
$content->setSlug($slug);
$default_title = PhabricatorSlug::getDefaultTitle($slug);
$content->setTitle($default_title);
}
}
if ($request->getBool('nodraft')) {
$draft = null;
$draft_key = null;
} else {
if ($document->getPHID()) {
$draft_key = $document->getPHID() . ':' . $content->getVersion();
} else {
$draft_key = 'phriction:' . $content->getSlug();
}
$draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), $draft_key);
}
require_celerity_resource('phriction-document-css');
$e_title = true;
$errors = array();
if ($request->isFormPost()) {
$title = $request->getStr('title');
if (!strlen($title)) {
$e_title = 'Required';
$errors[] = 'Document title is required.';
} else {
$e_title = null;
}
if (!count($errors)) {
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))->setUser($user)->setTitle($title)->setContent($request->getStr('content'))->setDescription($request->getStr('description'));
$editor->save();
if ($draft) {
$draft->delete();
}
$uri = PhrictionDocument::getSlugURI($document->getSlug());
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$error_view = null;
if ($errors) {
$error_view = id(new AphrontErrorView())->setTitle('Form Errors')->setErrors($errors);
}
if ($document->getID()) {
$panel_header = 'Edit Phriction Document';
$submit_button = 'Save Changes';
$delete_button = phutil_render_tag('a', array('href' => '/phriction/delete/' . $document->getID() . '/', 'class' => 'grey button'), 'Delete Document');
} else {
$panel_header = 'Create New Phriction Document';
$submit_button = 'Create Document';
$delete_button = null;
}
$uri = $document->getSlug();
$uri = PhrictionDocument::getSlugURI($uri);
$uri = PhabricatorEnv::getProductionURI($uri);
$remarkup_reference = phutil_render_tag('a', array('href' => PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'), 'tabindex' => '-1', 'target' => '_blank'), 'Formatting Reference');
$cancel_uri = PhrictionDocument::getSlugURI($document->getSlug());
if ($draft && strlen($draft->getDraft()) && $draft->getDraft() != $content->getContent()) {
$content_text = $draft->getDraft();
$discard = phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('nodraft', true)), 'discard this draft');
$draft_note = new AphrontErrorView();
$draft_note->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$draft_note->setTitle('Recovered Draft');
$draft_note->appendChild('<p>Showing a saved draft of your edits, you can ' . $discard . '.</p>');
} else {
$content_text = $content->getContent();
$draft_note = null;
}
$form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->getPath())->addHiddenInput('slug', $document->getSlug())->addHiddenInput('nodraft', $request->getBool('nodraft'))->appendChild(id(new AphrontFormTextControl())->setLabel('Title')->setValue($content->getTitle())->setError($e_title)->setName('title'))->appendChild(id(new AphrontFormStaticControl())->setLabel('URI')->setValue($uri))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Content')->setValue($content_text)->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)->setName('content')->setID('document-textarea')->setEnableDragAndDropFileUploads(true)->setCaption($remarkup_reference))->appendChild(id(new AphrontFormTextControl())->setLabel('Edit Notes')->setValue($content->getDescription())->setError(null)->setName('description'))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($submit_button));
$panel = id(new AphrontPanelView())->setWidth(AphrontPanelView::WIDTH_WIDE)->setHeader($panel_header)->appendChild($form);
if ($delete_button) {
//.........这里部分代码省略.........
示例4: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$current_version = null;
if ($this->id) {
$document = id(new PhrictionDocumentQuery())->setViewer($user)->withIDs(array($this->id))->needContent(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$document) {
return new Aphront404Response();
}
$current_version = $document->getContent()->getVersion();
$revert = $request->getInt('revert');
if ($revert) {
$content = id(new PhrictionContent())->loadOneWhere('documentID = %d AND version = %d', $document->getID(), $revert);
if (!$content) {
return new Aphront404Response();
}
} else {
$content = $document->getContent();
}
} else {
$slug = $request->getStr('slug');
$slug = PhabricatorSlug::normalize($slug);
if (!$slug) {
return new Aphront404Response();
}
$document = id(new PhrictionDocumentQuery())->setViewer($user)->withSlugs(array($slug))->needContent(true)->executeOne();
if ($document) {
$content = $document->getContent();
$current_version = $content->getVersion();
} else {
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProjectQuery())->setViewer($user)->withPhrictionSlugs(array(PhrictionDocument::getProjectSlugIdentifier($slug)))->executeOne();
if (!$project) {
return new Aphront404Response();
}
}
$document = new PhrictionDocument();
$document->setSlug($slug);
$content = new PhrictionContent();
$content->setSlug($slug);
$default_title = PhabricatorSlug::getDefaultTitle($slug);
$content->setTitle($default_title);
}
}
if ($request->getBool('nodraft')) {
$draft = null;
$draft_key = null;
} else {
if ($document->getPHID()) {
$draft_key = $document->getPHID() . ':' . $content->getVersion();
} else {
$draft_key = 'phriction:' . $content->getSlug();
}
$draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), $draft_key);
}
require_celerity_resource('phriction-document-css');
$e_title = true;
$notes = null;
$errors = array();
if ($request->isFormPost()) {
$overwrite = $request->getBool('overwrite');
if (!$overwrite) {
$edit_version = $request->getStr('contentVersion');
if ($edit_version != $current_version) {
$dialog = $this->newDialog()->setTitle(pht('Edit Conflict!'))->appendParagraph(pht('Another user made changes to this document after you began ' . 'editing it. Do you want to overwrite their changes?'))->appendParagraph(pht('If you choose to overwrite their changes, you should review ' . 'the document edit history to see what you overwrote, and ' . 'then make another edit to merge the changes if necessary.'))->addSubmitButton(pht('Overwrite Changes'))->addCancelButton($request->getRequestURI());
$dialog->addHiddenInput('overwrite', 'true');
foreach ($request->getPassthroughRequestData() as $key => $value) {
$dialog->addHiddenInput($key, $value);
}
return $dialog;
}
}
$title = $request->getStr('title');
$notes = $request->getStr('description');
if (!strlen($title)) {
$e_title = pht('Required');
$errors[] = pht('Document title is required.');
} else {
$e_title = null;
}
if ($document->getID()) {
if ($content->getTitle() == $title && $content->getContent() == $request->getStr('content')) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle(pht('No Edits'));
$dialog->appendChild(phutil_tag('p', array(), pht('You did not make any changes to the document.')));
$dialog->addCancelButton($request->getRequestURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
} else {
if (!strlen($request->getStr('content'))) {
// We trigger this only for new pages. For existing pages, deleting
// all the content counts as deleting the page.
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle(pht('Empty Page'));
$dialog->appendChild(phutil_tag('p', array(), pht('You can not create an empty document.')));
$dialog->addCancelButton($request->getRequestURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
//.........这里部分代码省略.........