示例#1
0
文件: Publish.php 项目: Nyco/movim
 function ajaxPublish($form)
 {
     RPC::call('Publish.disableSend');
     if ($form->content->value != '') {
         $content = Markdown::defaultTransform($form->content->value);
         $p = new PostPublish();
         $p->setFrom($this->user->getLogin())->setTo($form->to->value)->setNode($form->node->value);
         //->setLocation($geo)
         //->enableComments()
         if ($form->node->value == 'urn:xmpp:microblog:0') {
             $p->enableComments();
         }
         if ($form->title->value != '') {
             $p->setTitle($form->title->value);
         }
         if ($form->embed->value != '' && filter_var($form->embed->value, FILTER_VALIDATE_URL)) {
             $embed = Embed\Embed::create($form->embed->value);
             $content .= $this->prepareEmbed($embed);
             $p->setLink($form->embed->value);
             if ($embed->type == 'photo') {
                 $key = key($embed->images);
                 $p->setImage($embed->images[0]['value'], $embed->title, $embed->images[0]['mime']);
             }
         }
         $p->setContentHtml(rawurldecode($content))->request();
     } else {
         RPC::call('Publish.enableSend');
         Notification::append(false, $this->__('publish.no_content'));
     }
 }