Example #1
0
 /**
  * @Route("/editfooter/{id}",name="editfooter")
  * @ParamConverter("article", class="hkgbiWebBundle:Article")
  * @Method({"POST","GET"})
  */
 public function editFooter(Article $article, Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     $content = $article->getContent();
     $form = $this->createForm(new FooterType(), $article);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em->flush();
         return new Response("<script>alert('修改成功');window.location.href='/admin/footerlist'</script>");
     }
     return $this->render('hkgbiWebBundle:backend/footer:editfooter.html.twig', array('form' => $form->createView(), 'id' => $id, 'content' => $content));
 }
Example #2
0
 /**
  * @Route("/{identifier}/edit/{id}", name="edit_article")
  * @ParamConverter("article", class="hkgbiWebBundle:Article")
  */
 public function editArticle(Article $article, Request $request, $identifier, $id)
 {
     $em = $this->getDoctrine()->getManager();
     if ($identifier == "about_us" || $identifier == "service") {
         if ($identifier == "about_us") {
             $this->deleteMem("article_3");
         } else {
             $this->deleteMem("article_14");
         }
     }
     $module_obj = $em->getRepository('hkgbiWebBundle:Module')->findBy(array('identifier' => $identifier));
     $categories = $module_obj[0]->getCategories();
     $cate_id = null;
     $thumb = $article->getImageFile();
     $thumb_name = $article->getImageName();
     if ($article->getCategory()) {
         $cate_id = $article->getCategory()->getId();
     }
     $form = $this->createForm(new ArticleType($module_obj[0]), $article);
     $form->handleRequest($request);
     if ($form->isSubmitted()) {
         //写入选择的分类对象
         if (isset($_POST['article']['categories'])) {
             $category = $em->getRepository('hkgbiWebBundle:Category')->find($_POST['article']['categories']);
             $article->setCategory($category);
         }
         //检查是否有上传缩略图动作,如无,则使用原来的图
         if (!isset($_POST['product']['imageFile']['file'])) {
             $article->setImageName($thumb_name);
         }
         $em->flush();
         $article_list_url = $this->generateUrl('article_list', array('identifier' => $identifier));
         return new Response("<script>alert('修改成功!');window.location.href='{$article_list_url}'</script>");
     }
     return $this->render('hkgbiWebBundle:backend:edit_article.html.twig', array('article' => $article, 'form' => $form->createView(), 'id' => $id, 'categories' => $categories, 'cate_id' => $cate_id, 'identifier' => $identifier, 'thumb' => $thumb));
 }
Example #3
0
 /**
  * @Route("getmodule/article/{id}",name="article")
  * @ParamConverter("article", class="hkgbiWebBundle:Article")
  */
 public function getArticleAction(Article $article, $id)
 {
     if ($article->getModule()->getIdentifier() == "about_us") {
         $mem_obj = $this->mem();
         if ($mem_obj->doFetch("article_{$id}")) {
             $content = $mem_obj->doFetch("article_{$id}");
         } else {
             $content = $article->getContent();
             $mem_obj->doSave("article_{$id}", $content, 0);
         }
     } else {
         $content = $article->getContent();
     }
     return new Response("{$content}");
 }