Esempio n. 1
0
 public function updateContent($id, $fields)
 {
     $content = $this->getContent($id);
     if (empty($content)) {
         throw $this->createServiceException('内容不存在,更新失败!');
     }
     $type = ContentTypeFactory::create($content['type']);
     $fields = $type->convert($fields);
     $fields = ArrayToolkit::parts($fields, $type->getFields());
     // if(isset($fields['body'])){
     //     $fields['body'] = $this->purifyHtml($fields['body']);
     // }
     $this->getContentDao()->updateContent($id, ContentSerialize::serialize($fields));
     $content = $this->getContent($id);
     $this->getLogService()->info('content', 'update', "内容《({$content['title']})》({$content['id']})更新", $content);
     return $content;
 }
Esempio n. 2
0
 public function editAction(Request $request, $id)
 {
     $content = $this->getContentService()->getContent($id);
     $type = ContentTypeFactory::create($content['type']);
     $record = array();
     if ($request->getMethod() == 'POST') {
         $file = $request->files->get('picture');
         if (!empty($file)) {
             $record = $this->getFileService()->uploadFile('default', $file);
         }
         $content = $request->request->all();
         if (isset($record['uri'])) {
             $content['picture'] = $record['uri'];
         }
         $content = $this->filterEditorField($content);
         $content = $this->getContentService()->updateContent($id, $this->convertContent($content));
         return $this->render('TopxiaAdminBundle:Content:content-tr.html.twig', array('content' => $content, 'category' => $this->getCategoryService()->getCategory($content['categoryId']), 'user' => $this->getCurrentUser()));
     }
     return $this->render('TopxiaAdminBundle:Content:content-modal.html.twig', array('type' => $type, 'content' => $content));
 }
 public function editAction(Request $request, $id)
 {
     $content = $this->getContentService()->getContent($id);
     $type = ContentTypeFactory::create($content['type']);
     $record = array();
     if ($request->getMethod() == 'POST') {
         $response = array();
         $file = $request->files->get('picture');
         if (!empty($file)) {
             $record = $this->getFileService()->uploadFile('default', $file);
         }
         $content = $request->request->all();
         if (isset($record['uri'])) {
             $content['picture'] = $record['uri'];
         }
         $content = $this->getContentService()->updateContent($id, $this->convertContent($content));
         $response = array('success' => true, 'message' => '页面编辑成功');
         return $this->createJsonResponse($response);
     }
     return $this->render('TopxiaAdminBundle:Content:content-edit.html.twig', array('type' => $type, 'content' => $content));
 }