/** * {@inheritDoc} */ public function setContent($content) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setContent', array($content)); return parent::setContent($content); }
public function editstaticpageAction(Request $request) { /****** Admin session checking**********/ $response = $this->checkAdmin($request->getSession()); if ($response) { return $response; } $em = $this->getDoctrine()->getManager(); $lan = $this->container->get('request')->get('lan'); $id = $this->container->get('request')->get('id'); if (in_array($id, array(22, 23))) { return $this->redirect($this->generateUrl('mytrip_admin_staticpage')); } $checkquery = $em->createQuery("SELECT p FROM MytripAdminBundle:Language p WHERE p.lanCode='" . $lan . "'"); $checklanguage = $checkquery->getArrayResult(); if (empty($checklanguage)) { return $this->redirect($this->generateUrl('mytrip_admin_editstaticpage', array('id' => $id, 'lan' => 'en'))); } if ($request->getMethod() == "POST") { if ($lan == "en") { $repository = $em->getRepository('MytripAdminBundle:Staticpage'); $staticpage = $repository->findOneByStaticpageId($id); $url = strtolower(str_replace(' ', '-', preg_replace('/[^a-zA-Z0-9_ -]/s', ' ', $request->request->get('pagename')))); $check = $em->createQuery("SELECT p FROM MytripAdminBundle:Staticpage p WHERE p.url !='' AND p.url='" . $url . "' AND p.staticpageId NOT IN ('" . $id . "')")->getArrayResult(); if (!empty($check)) { $this->get('session')->getFlashBag()->add('error', '<div class="error msg">Content page name already exists</div>'); return $this->redirect($this->generateUrl('mytrip_admin_editstaticpage', array('id' => $id, 'lan' => $lan))); } $staticpage->setUrl($url); if ($id > 23) { $staticpage->setMenuId($request->request->get('mainmenu')); } $staticpage->setPagename($request->request->get('pagename')); $staticpage->setStatus($request->request->get('status')); } $em = $this->getDoctrine()->getManager(); $check = $em->createQuery("SELECT p FROM MytripAdminBundle:StaticpageContent p WHERE p.staticpage=" . $id . " AND p.lan='" . $lan . "'"); $check_content = $check->getArrayResult(); if (!empty($check_content)) { $repository_content = $em->getRepository('MytripAdminBundle:StaticpageContent'); $check_contents = $repository_content->findOneByStaticpageContentId($check_content['0']['staticpageContentId']); $check_contents->setName($request->request->get('pagename')); $check_contents->setPageTitle($request->request->get('pagetitle')); $check_contents->setMetaDescription($request->request->get('metadescription')); $check_contents->setMetaKeyword($request->request->get('metakeyword')); $check_contents->setContent($request->request->get('pagecontent')); } else { $staticpage_content = new StaticpageContent(); $staticpage_content->setStaticpage($this->getDoctrine()->getRepository('MytripAdminBundle:Staticpage')->find($id)); $staticpage_content->setName($request->request->get('pagename')); $staticpage_content->setPageTitle($request->request->get('pagetitle')); $staticpage_content->setMetaDescription($request->request->get('metadescription')); $staticpage_content->setMetaKeyword($request->request->get('metakeyword')); $staticpage_content->setContent($request->request->get('pagecontent')); $staticpage_content->setLan($lan); $em->persist($staticpage_content); } $em->flush(); $this->get('session')->getFlashBag()->add('error', '<div class="success msg">Content page successfully updated</div>'); return $this->redirect($this->generateUrl('mytrip_admin_editstaticpage', array('id' => $id, 'lan' => $lan))); } /******Fetch language********/ $query = $em->createQuery("SELECT p FROM MytripAdminBundle:Language p "); $language = $query->getArrayResult(); /*******Fetch Static page details*****/ $static_query = $em->createQuery("SELECT p FROM MytripAdminBundle:Staticpage p WHERE p.staticpageId=" . $id); $staticpage = $static_query->getArrayResult(); if (empty($staticpage)) { return $this->redirect($this->generateUrl('mytrip_admin_staticpage')); } /*******Fetch Static page content details*****/ $static_content_query = $em->createQuery("SELECT p FROM MytripAdminBundle:StaticpageContent p WHERE p.staticpage=" . $id . " AND p.lan='" . $lan . "'"); $static_content = $static_content_query->getArrayResult(); if (empty($static_content)) { $static_content_query = $em->createQuery("SELECT p FROM MytripAdminBundle:StaticpageContent p WHERE p.staticpage=" . $id . " AND p.lan='en'"); $static_content = $static_content_query->getArrayResult(); } return $this->render('MytripAdminBundle:Default:editstaticpage.html.php', array('language' => $language, 'staticpage' => $staticpage, 'static_content' => $static_content)); }