示例#1
0
文件: Render.php 项目: visapi/amun
 /**
  * Renders the content as html markup
  *
  * @httpMethod POST
  * @path /
  * @nickname doRender
  * @responseClass PSX_Data_ResultSet
  */
 public function doRender()
 {
     if ($this->user->hasRight('content_page_preview')) {
         try {
             $oembed = $this->get->oembed('boolean');
             $markdown = $this->get->markdown('boolean');
             $input = Base::getRawInput();
             $filter = new Filter\Html($this->registry, $this->user, $oembed);
             if ($markdown) {
                 $input = Markdown::decode($input);
             }
             header('Content-Type: text/html');
             echo $filter->apply($input);
             exit;
         } catch (\Exception $e) {
             $msg = new Message($e->getMessage(), false);
             $this->setResponse($msg);
         }
     } else {
         $msg = new Message('Access not allowed', false);
         $this->setResponse($msg, null, $this->user->isAnonymous() ? 401 : 403);
     }
 }
示例#2
0
文件: Record.php 项目: visapi/amun
 public function setText($text)
 {
     $text = Markdown::decode($text);
     $text = $this->_validate->apply($text, 'string', array(new Filter\Length(3, 4096), new AmunFilter\Html($this->_registry, $this->_user)), 'text', 'Text');
     if (!$this->_validate->hasError()) {
         $this->text = $text;
     } else {
         throw new Exception($this->_validate->getLastError());
     }
 }
示例#3
0
文件: Markdown.php 项目: visapi/amun
 public function process($file)
 {
     return \PSX\Util\Markdown::decode(file_get_contents($file));
 }
示例#4
0
文件: Record.php 项目: visapi/amun
 public function setSummary($summary)
 {
     $summary = Markdown::decode($summary);
     $summary = $this->_validate->apply($summary, 'string', array(new Filter\Length(3, 4096), new AmunFilter\Html($this->_registry, $this->_user, true)), 'summary', 'Summary');
     if (!$this->_validate->hasError()) {
         $this->summary = $summary;
     } else {
         throw new Exception($this->_validate->getLastError());
     }
 }