public function processRequest() { $request = $this->getRequest(); $document = $request->getStr('document'); $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $content = '<div class="phabricator-remarkup">' . $engine->markupText($document) . '</div>'; return id(new AphrontAjaxResponse())->setContent($content); }
public function processRequest() { $request = $this->getRequest(); $document = $request->getStr('document'); $content_obj = new PhrictionContent(); $content_obj->setContent($document); $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $content = $content_obj->renderContent(); return id(new AphrontAjaxResponse())->setContent($content); }
public function renderContent() { $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $markup = $engine->markupText($this->getContent()); $toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::renderTableOfContents($engine); if ($toc) { $toc = '<div class="phabricator-remarkup-toc">' . '<div class="phabricator-remarkup-toc-header">' . 'Table of Contents' . '</div>' . $toc . '</div>'; } return '<div class="phabricator-remarkup">' . $toc . $markup . '</div>'; }
public function processRequest() { $request = $this->getRequest(); $document = $request->getStr('document'); $draft_key = $request->getStr('draftkey'); if ($draft_key) { $table = new PhabricatorDraft(); queryfx($table->establishConnection('w'), 'INSERT INTO %T (authorPHID, draftKey, draft) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE draft = VALUES(draft)', $table->getTableName(), $request->getUser()->getPHID(), $draft_key, $document); } $content_obj = new PhrictionContent(); $content_obj->setContent($document); $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $content = $content_obj->renderContent(); return id(new AphrontAjaxResponse())->setContent($content); }
/** * @task markup */ public function newMarkupEngine($field) { return PhabricatorMarkupEngine::newPhrictionMarkupEngine(); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $slug = PhrictionDocument::normalizeSlug($this->slug); if ($slug != $this->slug) { $uri = PhrictionDocument::getSlugURI($slug); // Canonicalize pages to their one true URI. return id(new AphrontRedirectResponse())->setURI($uri); } require_celerity_resource('phriction-document-css'); $document = id(new PhrictionDocument())->loadOneWhere('slug = %s', $slug); $breadcrumbs = $this->renderBreadcrumbs($slug); $version_note = null; if (!$document) { $create_uri = '/phriction/edit/?slug=' . $slug; $page_content = '<div class="phriction-content">' . '<em>No content here!</em><br />' . 'No document found at <tt>' . phutil_escape_html($slug) . '</tt>. ' . 'You can <strong>' . phutil_render_tag('a', array('href' => $create_uri), 'create a new document') . '</strong>.' . '</div>'; $page_title = 'Page Not Found'; $button = phutil_render_tag('a', array('href' => $create_uri, 'class' => 'green button'), 'Create Page'); } else { $version = $request->getInt('v'); if ($version) { $content = id(new PhrictionContent())->loadOneWhere('documentID = %d AND version = %d', $document->getID(), $version); if (!$content) { return new Aphront404Response(); } if ($content->getID() != $document->getContentID()) { $version_note = new AphrontErrorView(); $version_note->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $version_note->setTitle('Older Version'); $version_note->appendChild('You are viewing an older version of this document, as it ' . 'appeared on ' . phabricator_datetime($content->getDateCreated(), $user) . '.'); } } else { $content = id(new PhrictionContent())->load($document->getContentID()); } $page_title = $content->getTitle(); $phids = array($content->getAuthorPHID()); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $age = time() - $content->getDateCreated(); $age = floor($age / (60 * 60 * 24)); if ($age < 1) { $when = 'today'; } else { if ($age == 1) { $when = 'yesterday'; } else { $when = "{$age} days ago"; } } $byline = '<div class="phriction-byline">' . "Last updated {$when} by " . $handles[$content->getAuthorPHID()]->renderLink() . '.' . '</div>'; $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $page_content = '<div class="phriction-content">' . $byline . '<div class="phabricator-remarkup">' . $engine->markupText($content->getContent()) . '</div>' . '</div>'; $button = phutil_render_tag('a', array('href' => '/phriction/edit/' . $document->getID() . '/', 'class' => 'button'), 'Edit Page'); } if ($version_note) { $version_note = $version_note->render(); } $children = $this->renderChildren($slug); $page = '<div class="phriction-header">' . $button . '<h1>' . phutil_escape_html($page_title) . '</h1>' . $breadcrumbs . '</div>' . $version_note . $page_content . $children; return $this->buildStandardPageResponse($page, array('title' => 'Phriction - ' . $page_title, 'history' => PhrictionDocument::getSlugURI($slug, 'history'))); }