Ejemplo n.º 1
0
 public function orderPanelsAction(Blog $blog)
 {
     $panelInfo = $this->get('icap_blog.manager.blog')->getPanelInfos();
     $mask = $blog->getOptions()->getListWidgetBlog();
     $orderPanelsTable = array();
     for ($maskPosition = 0, $entreTableau = 0; $maskPosition < strlen($mask); $maskPosition += 2, $entreTableau++) {
         $orderPanelsTable[] = array('nameTemplate' => $panelInfo[$mask[$maskPosition]], 'visibility' => (int) $mask[$maskPosition + 1]);
     }
     return $this->render('IcapBlogBundle::aside.html.twig', array('orderPanelInfos' => $orderPanelsTable, 'blog' => $blog, 'archives' => $this->getArchiveDatas($blog)));
 }
Ejemplo n.º 2
0
 /**
  * @param Workspace $workspace
  * @param array     $files
  * @param Blog      $object
  *
  * @return array
  */
 public function exportBlog(Workspace $workspace, array &$files, Blog $object)
 {
     $data = [];
     $data['options'] = ['authorize_comment' => $object->getOptions()->getAuthorizeComment(), 'authorize_anonymous_comment' => $object->getOptions()->getAuthorizeAnonymousComment(), 'post_per_page' => $object->getOptions()->getPostPerPage(), 'auto_publish_post' => $object->getOptions()->getAutoPublishPost(), 'auto_publish_comment' => $object->getOptions()->getAutoPublishComment(), 'display_title' => $object->getOptions()->getDisplayTitle(), 'banner_activate' => $object->getOptions()->isBannerActivate(), 'display_post_view_counter' => $object->getOptions()->getDisplayPostViewCounter(), 'banner_background_color' => $object->getOptions()->getBannerBackgroundColor(), 'banner_height' => $object->getOptions()->getBannerHeight(), 'banner_background_image' => $object->getOptions()->getBannerBackgroundImage(), 'banner_background_image_position' => $object->getOptions()->getBannerBackgroundImagePosition(), 'banner_background_image_repeat' => $object->getOptions()->getBannerBackgroundImageRepeat(), 'tag_cloud' => null === $object->getOptions()->getTagCloud() ? 0 : $object->getOptions()->getTagCloud()];
     $data['posts'] = [];
     foreach ($object->getPosts() as $post) {
         $postUid = uniqid() . '.txt';
         $postTemporaryPath = $this->ch->getParameter('tmp_dir') . DIRECTORY_SEPARATOR . $postUid;
         file_put_contents($postTemporaryPath, $post->getContent());
         $files[$postUid] = $postTemporaryPath;
         $tags = [];
         foreach ($post->getTags() as $tag) {
             $tags[] = ['name' => $tag->getName()];
         }
         $comments = [];
         foreach ($post->getComments() as $comment) {
             $commentUid = uniqid() . '.txt';
             $commentTemporaryPath = $this->ch->getParameter('tmp_dir') . DIRECTORY_SEPARATOR . $commentUid;
             file_put_contents($commentTemporaryPath, $comment->getMessage());
             $files[$commentUid] = $commentTemporaryPath;
             $comments[] = ['message' => $commentUid, 'author' => $comment->getAuthor()->getMail(), 'creation_date' => $comment->getCreationDate()->format(\DateTime::ATOM), 'update_date' => null !== $comment->getUpdateDate() ? $comment->getUpdateDate()->format(\DateTime::ATOM) : null, 'publication_date' => null !== $comment->getPublicationDate() ? $comment->getPublicationDate()->format(\DateTime::ATOM) : null, 'status' => $comment->getStatus()];
         }
         $postArray = ['title' => $post->getTitle(), 'content' => $postUid, 'author' => $post->getAuthor()->getMail(), 'status' => $post->getStatus(), 'creation_date' => $post->getCreationDate()->format(\DateTime::ATOM), 'modification_date' => null !== $post->getModificationDate() ? $post->getModificationDate()->format(\DateTime::ATOM) : null, 'publication_date' => null !== $post->getPublicationDate() ? $post->getPublicationDate()->format(\DateTime::ATOM) : null, 'tags' => $tags, 'comments' => $comments];
         $data['posts'][] = $postArray;
     }
     return $data;
 }
Ejemplo n.º 3
0
 private function persistCommentUpdate(Request $request, Blog $blog, Post $post, Comment $comment, User $user, array $messages)
 {
     $form = $this->createForm($this->get('icap_blog.form.comment'), $comment);
     if ($request->isXMLHttpRequest()) {
         return $this->render('IcapBlogBundle:Comment:inlineEdit.html.twig', array('_resource' => $blog, 'post' => $post, 'comment' => $comment, 'workspace' => $blog->getResourceNode()->getWorkspace(), 'form' => $form->createView()));
     } else {
         if ("POST" === $request->getMethod()) {
             $form->handleRequest($request);
             if ($form->isValid()) {
                 $flashBag = $this->get('session')->getFlashBag();
                 $entityManager = $this->getDoctrine()->getManager();
                 try {
                     $unitOfWork = $entityManager->getUnitOfWork();
                     $unitOfWork->computeChangeSets();
                     $changeSet = $unitOfWork->getEntityChangeSet($comment);
                     $entityManager->persist($comment);
                     $entityManager->flush();
                     $this->dispatchCommentUpdateEvent($post, $comment, $changeSet);
                     $flashBag->add('success', $messages['success']);
                 } catch (\Exception $exception) {
                     $flashBag->add('error', $messages['error']);
                 }
                 return $this->redirect($this->generateUrl('icap_blog_post_view', array('blogId' => $blog->getId(), 'postSlug' => $post->getSlug())));
             }
         }
     }
     return array('_resource' => $blog, 'bannerForm' => $this->getBannerForm($blog->getOptions()), 'user' => $user, 'post' => $post, 'comment' => $comment, 'form' => $form->createView());
 }
Ejemplo n.º 4
0
 public function getBlogBannerWebPath(Blog $blog)
 {
     return $blog->getOptions()->getBannerBackgroundImage() ? $this->webDirectory . '/' . $blog->getOptions()->getBannerBackgroundImage() : null;
 }