2011-07-17 03:25:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-01-06 18:08:59 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-07-17 03:25:45 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2011-09-14 17:02:31 +02:00
|
|
|
/**
|
|
|
|
* @group phriction
|
|
|
|
*/
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhrictionDocumentPreviewController
|
2011-07-17 03:25:45 +02:00
|
|
|
extends PhrictionController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$document = $request->getStr('document');
|
|
|
|
|
2012-01-12 20:57:22 +01:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
2012-01-06 18:08:59 +01:00
|
|
|
$content_obj = new PhrictionContent();
|
|
|
|
$content_obj->setContent($document);
|
|
|
|
|
2011-07-17 03:25:45 +02:00
|
|
|
$engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine();
|
2012-01-06 18:08:59 +01:00
|
|
|
$content = $content_obj->renderContent();
|
2011-07-17 03:25:45 +02:00
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($content);
|
|
|
|
}
|
|
|
|
}
|