Esempio n. 1
0
 public function addAjaxActionAuth(Param\AjaxString $title, Param\AjaxSafeHTML $text, Param\AjaxString $tags = null)
 {
     $userId = Difra\Auth::getInstance()->getEmail();
     if ($group = Blogs\Group::current()) {
         if (!$group->hasUser($userId)) {
             \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('blogs/notifies/add_post_denied'), true);
             $this->view->redirect('/');
         }
         $blog = Blogs\Blog::touchByGroup($group->getId());
     } else {
         $blog = Blogs\Blog::touchByUser($userId);
     }
     if ($post = $blog->addPost($userId, $title->val(), $text->val())) {
         $post = $blog->getPost($post->getId());
         if (class_exists('Difra\\Plugins\\Tags')) {
             $tagsArray = Difra\Plugins\Tags::getInstance()->tagsFromString($tags);
             Difra\Plugins\Tags::getInstance()->update('posts', $post->getId(), $tagsArray);
         }
         $this->ajax->redirect($post->getUrl());
     } else {
         $this->ajax->error(\Difra\Locales::getInstance()->getXPath('blogs/notifies/add_post_failed'));
     }
 }
Esempio n. 2
0
 public function tagsAction(Param\NamedInt $page = null, Param\AnyString $tagName = null)
 {
     $page = $page ? $page->val() : 1;
     /** @var \DOMElement $blogsViewNode */
     $blogsViewNode = $this->root->appendChild($this->xml->createElement('blogsTagsView'));
     $blogsViewNode->setAttribute('left', 1);
     $Tags = Difra\Plugins\Tags::getInstance();
     if ($tagName) {
         /** @var \DOMElement $currentTagNode */
         $currentTagNode = $this->root->appendChild($this->xml->createElement('currentTag', $tagName->val()));
         $blogsViewNode->setAttribute('link', '/blogs/tags/' . $tagName->val());
         $tagName = rawurldecode($tagName->val());
         $currentTagNode->setAttribute('name', $Tags->getTagByLink('posts', $tagName));
         $tagItems = $Tags->getItemsByLink('posts', $tagName);
         Difra\Plugins\Blogs::getInstance()->getAllPostsXML($blogsViewNode, $page, $tagItems);
     } else {
         $blogsViewNode->setAttribute('link', '/blogs/tags');
         Difra\Plugins\Blogs::getInstance()->getAllPostsXML($blogsViewNode, $page);
     }
     if (Difra\Auth::getInstance()->isAuthorized()) {
         /** @var \DOMElement $mypageWidgetNode */
         $mypageWidgetNode = $this->root->appendChild($this->xml->createElement('myPageWidget'));
         $mypageWidgetNode->setAttribute('right', 1);
     }
     /** @var \DOMElement $controlNode */
     $controlNode = $this->root->appendChild($this->xml->createElement('artistControl'));
     $controlNode->setAttribute('right', 1);
     if ($Tags->getCloudXml('posts', $this->root)) {
         /** @var \DOMElement $tagsNode */
         $tagsNode = $this->root->appendChild($this->xml->createElement('postsTags'));
         $tagsNode->setAttribute('right', 1);
     }
 }