当前位置: 首页>>代码示例>>PHP>>正文


PHP PhrictionDocument类代码示例

本文整理汇总了PHP中PhrictionDocument的典型用法代码示例。如果您正苦于以下问题:PHP PhrictionDocument类的具体用法?PHP PhrictionDocument怎么用?PHP PhrictionDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PhrictionDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadPage

 protected function loadPage()
 {
     $table = new PhrictionDocument();
     $conn_r = $table->establishConnection('r');
     $rows = queryfx_all($conn_r, 'SELECT d.* FROM %T d %Q %Q %Q %Q', $table->getTableName(), $this->buildJoinClause($conn_r), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
     $documents = $table->loadAllFromArray($rows);
     if ($documents) {
         $ancestor_slugs = array();
         foreach ($documents as $key => $document) {
             $document_slug = $document->getSlug();
             foreach (PhabricatorSlug::getAncestry($document_slug) as $ancestor) {
                 $ancestor_slugs[$ancestor][] = $key;
             }
         }
         if ($ancestor_slugs) {
             $ancestors = queryfx_all($conn_r, 'SELECT * FROM %T WHERE slug IN (%Ls)', $document->getTableName(), array_keys($ancestor_slugs));
             $ancestors = $table->loadAllFromArray($ancestors);
             $ancestors = mpull($ancestors, null, 'getSlug');
             foreach ($ancestor_slugs as $ancestor_slug => $document_keys) {
                 $ancestor = idx($ancestors, $ancestor_slug);
                 foreach ($document_keys as $document_key) {
                     $documents[$document_key]->attachAncestor($ancestor_slug, $ancestor);
                 }
             }
         }
     }
     return $documents;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:28,代码来源:PhrictionDocumentQuery.php

示例2: loadDocuments

 private function loadDocuments(AphrontPagerView $pager)
 {
     // TODO: Do we want/need a query object for this?
     $document_dao = new PhrictionDocument();
     $content_dao = new PhrictionContent();
     $conn = $document_dao->establishConnection('r');
     switch ($this->view) {
         case 'all':
             $data = queryfx_all($conn, 'SELECT * FROM %T ORDER BY id DESC LIMIT %d, %d', $document_dao->getTableName(), $pager->getOffset(), $pager->getPageSize() + 1);
             break;
         case 'updates':
             // TODO: This query is a little suspicious, verify we don't need to key
             // or change it once we get more data.
             $data = queryfx_all($conn, 'SELECT d.* FROM %T d JOIN %T c ON c.documentID = d.id
         GROUP BY c.documentID
         ORDER BY MAX(c.id) DESC LIMIT %d, %d', $document_dao->getTableName(), $content_dao->getTableName(), $pager->getOffset(), $pager->getPageSize() + 1);
             break;
         default:
             throw new Exception("Unknown view '{$this->view}'!");
     }
     $data = $pager->sliceResults($data);
     $documents = $document_dao->loadAllFromArray($data);
     if ($documents) {
         $content = $content_dao->loadAllWhere('documentID IN (%Ld)', mpull($documents, 'getID'));
         $content = mpull($content, null, 'getDocumentID');
         foreach ($documents as $document) {
             $document->attachContent($content[$document->getID()]);
         }
     }
     return $documents;
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:31,代码来源:PhrictionListController.php

示例3: 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());
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhrictionConduitAPIMethod.php

示例4: 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);
 }
开发者ID:hwang36,项目名称:phabricator,代码行数:14,代码来源:PhabricatorSearchPhrictionIndexer.php

示例5: initializeNewDocument

 public static function initializeNewDocument(PhabricatorUser $actor, $slug)
 {
     $document = new PhrictionDocument();
     $document->setSlug($slug);
     $content = new PhrictionContent();
     $content->setSlug($slug);
     $default_title = PhabricatorSlug::getDefaultTitle($slug);
     $content->setTitle($default_title);
     $document->attachContent($content);
     $parent_doc = null;
     $ancestral_slugs = PhabricatorSlug::getAncestry($slug);
     if ($ancestral_slugs) {
         $parent = end($ancestral_slugs);
         $parent_doc = id(new PhrictionDocumentQuery())->setViewer($actor)->withSlugs(array($parent))->executeOne();
     }
     if ($parent_doc) {
         $document->setViewPolicy($parent_doc->getViewPolicy());
         $document->setEditPolicy($parent_doc->getEditPolicy());
     } else {
         $default_view_policy = PhabricatorPolicies::getMostOpenPolicy();
         $document->setViewPolicy($default_view_policy);
         $document->setEditPolicy(PhabricatorPolicies::POLICY_USER);
     }
     return $document;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:PhrictionDocument.php

示例6: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $slug = PhabricatorSlug::normalize($request->getStr('slug'));
     if ($request->isFormPost()) {
         $document = id(new PhrictionDocumentQuery())->setViewer($user)->withSlugs(array($slug))->executeOne();
         $prompt = $request->getStr('prompt', 'no');
         $document_exists = $document && $document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS;
         if ($document_exists && $prompt == 'no') {
             $dialog = new AphrontDialogView();
             $dialog->setSubmitURI('/phriction/new/')->setTitle(pht('Edit Existing Document?'))->setUser($user)->appendChild(pht('The document %s already exists. Do you want to edit it instead?', phutil_tag('tt', array(), $slug)))->addHiddenInput('slug', $slug)->addHiddenInput('prompt', 'yes')->addCancelButton('/w/')->addSubmitButton(pht('Edit Document'));
             return id(new AphrontDialogResponse())->setDialog($dialog);
         } else {
             if (PhrictionDocument::isProjectSlug($slug)) {
                 $project = id(new PhabricatorProjectQuery())->setViewer($user)->withPhrictionSlugs(array(PhrictionDocument::getProjectSlugIdentifier($slug)))->executeOne();
                 if (!$project) {
                     $dialog = new AphrontDialogView();
                     $dialog->setSubmitURI('/w/')->setTitle(pht('Oops!'))->setUser($user)->appendChild(pht('You cannot create wiki pages under "projects/",
               because they are reserved as project pages.
               Create a new project with this name first.'))->addCancelButton('/w/', 'Okay');
                     return id(new AphrontDialogResponse())->setDialog($dialog);
                 }
             }
         }
         $uri = '/phriction/edit/?slug=' . $slug;
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     if ($slug == '/') {
         $slug = '';
     }
     $view = id(new PHUIFormLayoutView())->appendChild(id(new AphrontFormTextControl())->setLabel('/w/')->setValue($slug)->setName('slug'));
     $dialog = id(new AphrontDialogView())->setUser($user)->setTitle(pht('New Document'))->setSubmitURI('/phriction/new/')->appendChild(phutil_tag('p', array(), pht('Create a new document at')))->appendChild($view)->addSubmitButton(pht('Create'))->addCancelButton('/w/');
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhrictionNewController.php

示例7: markupDocumentLink

 public function markupDocumentLink($matches)
 {
     $link = trim($matches[1]);
     $name = trim(idx($matches, 2, $link));
     if (empty($matches[2])) {
         $name = explode('/', trim($name, '/'));
         $name = end($name);
     }
     $uri = new PhutilURI($link);
     $slug = $uri->getPath();
     $fragment = $uri->getFragment();
     $slug = PhabricatorSlug::normalize($slug);
     $slug = PhrictionDocument::getSlugURI($slug);
     $href = (string) id(new PhutilURI($slug))->setFragment($fragment);
     if ($this->getEngine()->getState('toc')) {
         $text = $name;
     } else {
         if ($this->getEngine()->isTextMode()) {
             return PhabricatorEnv::getProductionURI($href);
         } else {
             $text = $this->newTag('a', array('href' => $href, 'class' => 'phriction-link'), $name);
         }
     }
     return $this->getEngine()->storeText($text);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:PhrictionRemarkupRule.php

示例8: testSlugDepth

 public function testSlugDepth()
 {
     $slugs = array('/' => 0, 'a/' => 1, 'a/b/' => 2, 'a////b/' => 2);
     foreach ($slugs as $slug => $depth) {
         $this->assertEqual($depth, PhrictionDocument::getSlugDepth($slug), "Depth of '{$slug}'");
     }
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:7,代码来源:PhrictionDocumentTestCase.php

示例9: renderBreadcrumbs

 public function renderBreadcrumbs($slug)
 {
     $ancestor_handles = array();
     $ancestral_slugs = PhabricatorSlug::getAncestry($slug);
     $ancestral_slugs[] = $slug;
     if ($ancestral_slugs) {
         $empty_slugs = array_fill_keys($ancestral_slugs, null);
         $ancestors = id(new PhrictionDocumentQuery())->setViewer($this->getRequest()->getUser())->withSlugs($ancestral_slugs)->execute();
         $ancestors = mpull($ancestors, null, 'getSlug');
         $ancestor_phids = mpull($ancestors, 'getPHID');
         $handles = array();
         if ($ancestor_phids) {
             $handles = $this->loadViewerHandles($ancestor_phids);
         }
         $ancestor_handles = array();
         foreach ($ancestral_slugs as $slug) {
             if (isset($ancestors[$slug])) {
                 $ancestor_handles[] = $handles[$ancestors[$slug]->getPHID()];
             } else {
                 $handle = new PhabricatorObjectHandle();
                 $handle->setName(PhabricatorSlug::getDefaultTitle($slug));
                 $handle->setURI(PhrictionDocument::getSlugURI($slug));
                 $ancestor_handles[] = $handle;
             }
         }
     }
     $breadcrumbs = array();
     foreach ($ancestor_handles as $ancestor_handle) {
         $breadcrumbs[] = id(new PHUICrumbView())->setName($ancestor_handle->getName())->setHref($ancestor_handle->getUri());
     }
     return $breadcrumbs;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:32,代码来源:PhrictionController.php

示例10: markupDocumentLink

 public function markupDocumentLink($matches)
 {
     $slug = trim($matches[1]);
     $name = trim(idx($matches, 2, $slug));
     // If whatever is being linked to begins with "/" or has "://", treat it
     // as a URI instead of a wiki page.
     $is_uri = preg_match('@(^/)|(://)@', $slug);
     if ($is_uri) {
         $protocols = $this->getEngine()->getConfig('uri.allowed-protocols', array());
         $protocol = id(new PhutilURI($slug))->getProtocol();
         if (!idx($protocols, $protocol)) {
             // Don't treat this as a URI if it's not an allowed protocol.
             $is_uri = false;
         }
     }
     if ($is_uri) {
         $uri = $slug;
         // Leave the name unchanged, i.e. link the whole URI if there's no
         // explicit name.
     } else {
         $name = explode('/', trim($name, '/'));
         $name = end($name);
         $slug = PhrictionDocument::normalizeSlug($slug);
         $uri = PhrictionDocument::getSlugURI($slug);
     }
     return $this->getEngine()->storeText(phutil_render_tag('a', array('href' => $uri, 'class' => $is_uri ? null : 'phriction-link'), phutil_escape_html($name)));
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:27,代码来源:PhabricatorRemarkupRulePhriction.php

示例11: renderResultList

 protected function renderResultList(array $documents, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($documents, 'PhrictionDocument');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($documents as $document) {
         $content = $document->getContent();
         $slug = $document->getSlug();
         $author_phid = $content->getAuthorPHID();
         $slug_uri = PhrictionDocument::getSlugURI($slug);
         $byline = pht('Edited by %s', $handles[$author_phid]->renderLink());
         $updated = phabricator_datetime($content->getDateCreated(), $viewer);
         $item = id(new PHUIObjectItemView())->setHeader($content->getTitle())->setHref($slug_uri)->addByline($byline)->addIcon('none', $updated);
         $item->addAttribute($slug_uri);
         switch ($document->getStatus()) {
             case PhrictionDocumentStatus::STATUS_DELETED:
                 $item->setDisabled(true);
                 $item->addIcon('delete', pht('Deleted'));
                 break;
             case PhrictionDocumentStatus::STATUS_MOVED:
                 $item->setDisabled(true);
                 $item->addIcon('arrow-right', pht('Moved Away'));
                 break;
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No documents found.'));
     return $result;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:32,代码来源:PhrictionSearchEngine.php

示例12: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $document = id(new PhrictionDocumentQuery())->setViewer($user)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
     if (!$document) {
         return new Aphront404Response();
     }
     $e_text = null;
     $disallowed_states = array(PhrictionDocumentStatus::STATUS_DELETED => true, PhrictionDocumentStatus::STATUS_MOVED => true, PhrictionDocumentStatus::STATUS_STUB => true);
     if (isset($disallowed_states[$document->getStatus()])) {
         $e_text = pht('An already moved or deleted document can not be deleted');
     }
     $document_uri = PhrictionDocument::getSlugURI($document->getSlug());
     if (!$e_text && $request->isFormPost()) {
         $editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))->setActor($user)->delete();
         return id(new AphrontRedirectResponse())->setURI($document_uri);
     }
     if ($e_text) {
         $dialog = id(new AphrontDialogView())->setUser($user)->setTitle(pht('Can not delete document!'))->appendChild($e_text)->addCancelButton($document_uri);
     } else {
         $dialog = id(new AphrontDialogView())->setUser($user)->setTitle(pht('Delete Document?'))->appendChild(pht('Really delete this document? You can recover it later by ' . 'reverting to a previous version.'))->addSubmitButton(pht('Delete'))->addCancelButton($document_uri);
     }
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:PhrictionDeleteController.php

示例13: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $document = id(new PhrictionDocumentQuery())->setViewer($user)->withIDs(array($this->id))->needContent(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
     if (!$document) {
         return new Aphront404Response();
     }
     $document_uri = PhrictionDocument::getSlugURI($document->getSlug());
     $e_text = null;
     if ($request->isFormPost()) {
         $xactions = array();
         $xactions[] = id(new PhrictionTransaction())->setTransactionType(PhrictionTransaction::TYPE_DELETE)->setNewValue(true);
         $editor = id(new PhrictionTransactionEditor())->setActor($user)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
         try {
             $editor->applyTransactions($document, $xactions);
             return id(new AphrontRedirectResponse())->setURI($document_uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $e_text = phutil_implode_html("\n", $ex->getErrorMessages());
         }
     }
     if ($e_text) {
         $dialog = id(new AphrontDialogView())->setUser($user)->setTitle(pht('Can Not Delete Document!'))->appendChild($e_text)->addCancelButton($document_uri);
     } else {
         $dialog = id(new AphrontDialogView())->setUser($user)->setTitle(pht('Delete Document?'))->appendChild(pht('Really delete this document? You can recover it later by ' . 'reverting to a previous version.'))->addSubmitButton(pht('Delete'))->addCancelButton($document_uri);
     }
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:28,代码来源:PhrictionDeleteController.php

示例14: markupDocumentLink

 public function markupDocumentLink($matches)
 {
     $slug = trim($matches[1]);
     $name = trim(idx($matches, 2, $slug));
     $name = explode('/', $name);
     $name = end($name);
     $slug = PhrictionDocument::normalizeSlug($slug);
     $uri = PhrictionDocument::getSlugURI($slug);
     return $this->getEngine()->storeText(phutil_render_tag('a', array('href' => $uri, 'class' => 'phriction-link'), phutil_escape_html($name)));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:10,代码来源:PhabricatorRemarkupRulePhriction.php

示例15: execute

 protected function execute(ConduitAPIRequest $request)
 {
     $slug = $request->getValue('slug');
     $doc = id(new PhrictionDocument())->loadOneWhere('slug = %s', PhrictionDocument::normalizeSlug($slug));
     if (!$doc) {
         throw new ConduitException('ERR-BAD-DOCUMENT');
     }
     $content = id(new PhrictionContent())->load($doc->getContentID());
     $doc->attachContent($content);
     return $this->buildDocumentInfoDictionary($doc);
 }
开发者ID:hwang36,项目名称:phabricator,代码行数:11,代码来源:ConduitAPI_phriction_info_Method.php


注:本文中的PhrictionDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。