示例#1
0
 function ajaxPublish($form)
 {
     RPC::call('Publish.disableSend');
     if ($form->title->value != '') {
         $p = new PostPublish();
         $p->setFrom($this->user->getLogin())->setTo($form->to->value)->setTitle(htmlspecialchars($form->title->value))->setNode($form->node->value);
         //->setLocation($geo)
         //->enableComments()
         // Still usefull ? Check line 44
         if ($form->node->value == 'urn:xmpp:microblog:0') {
             $p->enableComments();
         }
         $content = $content_xhtml = '';
         if ($form->content->value != '') {
             $content = $form->content->value;
             $content_xhtml = Markdown::defaultTransform($content);
         }
         if ($form->id->value != '') {
             $p->setId($form->id->value);
             $pd = new \modl\PostnDAO();
             $post = $pd->getItem($form->id->value);
             if (isset($post)) {
                 $p->setPublished(strtotime($post->published));
             }
         }
         if (Validator::stringType()->notEmpty()->alnum(',')->validate($form->tags->value)) {
             $p->setTags(array_unique(array_filter(array_map(function ($value) {
                 return trim(strtolower($value));
             }, explode(',', $form->tags->value)))));
         }
         if ($form->embed->value != '' && filter_var($form->embed->value, FILTER_VALIDATE_URL)) {
             try {
                 $embed = Embed\Embed::create($form->embed->value);
                 $p->setLink($form->embed->value);
                 if (in_array($embed->type, array('photo', 'rich'))) {
                     $key = key($embed->images);
                     $p->setImage($embed->images[0]['value'], $embed->title, $embed->images[0]['mime']);
                 }
                 if ($embed->type !== 'photo') {
                     $content_xhtml .= $this->prepareEmbed($embed);
                 }
             } catch (Exception $e) {
                 error_log($e->getMessage());
             }
         }
         if ($content != '') {
             $p->setContent(htmlspecialchars($content));
         }
         if ($content_xhtml != '') {
             $p->setContentXhtml($content_xhtml);
         }
         $p->request();
     } else {
         RPC::call('Publish.enableSend');
         Notification::append(false, $this->__('publish.no_title'));
     }
 }
示例#2
0
文件: Publish.php 项目: Trim/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)->setContent($form->content->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);
             $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']);
             } else {
                 $content .= $this->prepareEmbed($embed);
             }
         }
         $p->setContentXhtml(rawurldecode($content))->request();
     } else {
         RPC::call('Publish.enableSend');
         Notification::append(false, $this->__('publish.no_content'));
     }
 }
示例#3
0
文件: Publish.php 项目: Anon215/movim
 function ajaxPublish($form)
 {
     RPC::call('Publish.disableSend');
     if ($form->title->value != '') {
         $p = new PostPublish();
         $p->setFrom($this->user->getLogin())->setTo($form->to->value)->setTitle(htmlspecialchars($form->title->value))->setNode($form->node->value);
         //->setLocation($geo)
         // Still usefull ? Check line 44
         //if($form->node->value == 'urn:xmpp:microblog:0') {
         $p->enableComments();
         //}
         $content = $content_xhtml = '';
         if ($form->content->value != '') {
             $content = $form->content->value;
             $content_xhtml = addHFR(Markdown::defaultTransform($content));
         }
         if ($form->id->value != '') {
             $p->setId($form->id->value);
             $pd = new \modl\PostnDAO();
             $post = $pd->get($form->to->value, $form->node->value, $form->id->value);
             if (isset($post)) {
                 $p->setPublished(strtotime($post->published));
             }
         }
         if (Validator::stringType()->notEmpty()->validate($form->tags->value)) {
             $p->setTags(array_unique(array_filter(array_map(function ($value) {
                 if (Validator::stringType()->notEmpty()->validate($value)) {
                     preg_match('/([^\\s[:punct:]]|_|-){3,30}/', trim($value), $matches);
                     if (isset($matches[0])) {
                         return strtolower($matches[0]);
                     }
                 }
             }, explode(',', $form->tags->value)))));
         }
         if (Validator::notEmpty()->url()->validate($form->embed->value)) {
             try {
                 $embed = Embed\Embed::create($form->embed->value);
                 $p->setLink($form->embed->value);
                 if (in_array($embed->type, array('photo', 'rich'))) {
                     $p->setImage($embed->images[0]['value'], $embed->title, $embed->images[0]['mime']);
                 }
                 if ($embed->type !== 'photo') {
                     $content_xhtml .= $this->prepareEmbed($embed);
                 }
             } catch (Exception $e) {
                 error_log($e->getMessage());
             }
         }
         if ($form->open->value === true) {
             $p->isOpen();
         }
         if ($content != '') {
             $p->setContent(htmlspecialchars($content));
         }
         if ($content_xhtml != '') {
             $p->setContentXhtml($content_xhtml);
         }
         if ($form->reply->value) {
             $pd = new \modl\PostnDAO();
             $post = $pd->get($form->replyorigin->value, $form->replynode->value, $form->replynodeid->value);
             $p->setReply($post->getRef());
         }
         $p->request();
     } else {
         RPC::call('Publish.enableSend');
         Notification::append(false, $this->__('publish.no_title'));
     }
 }