public function editPostAction($id)
 {
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         return $this->redirect($this->generateUrl('_admin_productpic_list'));
     }
     $em = $this->getEntityManager();
     try {
         $productpic = $em->getRepository('AllucoDataBundle:Productpic')->find($id);
         if (null == $productpic) {
             $this->flashMsgSession('warning', 'Productpic.edit.notfound');
         } else {
             $productpicUpdateContentForm = $this->createForm(new ProductpicUpdateContentTForm(), $productpic);
             $productpicUpdateRankForm = $this->createForm(new ProductpicUpdateRankTForm(), $productpic);
             $productpicUpdateInfoForm = $this->createForm(new ProductpicUpdateInfoTForm(), $productpic);
             $langs = $em->getRepository('AllucoDataBundle:Lang')->getAll();
             $this->gvars['langs'] = $langs;
             foreach ($langs as $lang) {
                 $productpicTrans = $em->getRepository('AllucoDataBundle:ProductpicTrans')->findOneBy(array('lang' => $lang, 'productpic' => $productpic));
                 if (null == $productpicTrans) {
                     $productpicTrans = new ProductpicTrans();
                     $productpicTrans->setProductpic($productpic);
                     $productpicTrans->setLang($lang);
                     $productpicTrans->setAlt($productpic->getAlt());
                     $productpicTrans->setTitle($productpic->getTitle());
                     try {
                         $em->persist($productpicTrans);
                         $em->flush();
                     } catch (\Exception $e) {
                         // ne rien faire
                     }
                 }
             }
             $em->refresh($productpic);
             $this->gvars['tabActive'] = $this->getSession()->get('tabActive', 2);
             $this->getSession()->remove('tabActive');
             $request = $this->getRequest();
             $reqData = $request->request->all();
             if (isset($reqData['ProductpicUpdateContentForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productpicUpdateContentForm->handleRequest($request);
                 if ($productpicUpdateContentForm->isValid()) {
                     $productpicUrl = $productpicUpdateContentForm['filename']->getData();
                     $productpicDir = $this->getParameter('kernel.root_dir') . '/../web/res/pics';
                     $fileName = sha1(uniqid(mt_rand(), true)) . '.' . strtolower($productpicUrl->getClientOriginalExtension());
                     $productpicUrl->move($productpicDir, $fileName);
                     $productpic->setFilename($fileName);
                     $em->persist($productpic);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Productpic.edit.success', array('%productpic%' => $productpic->getFilename())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($productpic);
                     $this->flashMsgSession('error', $this->translate('Productpic.edit.failure', array('%productpic%' => $productpic->getFilename())));
                 }
             } elseif (isset($reqData['ProductpicUpdateRankForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productpicUpdateRankForm->handleRequest($request);
                 if ($productpicUpdateRankForm->isValid()) {
                     $em->persist($productpic);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Productpic.edit.success', array('%productpic%' => $productpic->getFilename())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($productpic);
                     $this->flashMsgSession('error', $this->translate('Productpic.edit.failure', array('%productpic%' => $productpic->getFilename())));
                 }
             } elseif (isset($reqData['ProductpicUpdateInfoForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productpicUpdateInfoForm->handleRequest($request);
                 if ($productpicUpdateInfoForm->isValid()) {
                     $em->persist($productpic);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Productpic.edit.success', array('%productpic%' => $productpic->getFilename())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($productpic);
                     $this->flashMsgSession('error', $this->translate('Productpic.edit.failure', array('%productpic%' => $productpic->getFilename())));
                 }
             }
             foreach ($productpic->getI18ns() as $productpicTrans) {
                 $em->refresh($productpicTrans);
                 $productpicTransUpdateInfoForm = $this->createForm(new ProductpicTransUpdateInfoTForm($productpicTrans->getLang()->getLocale()), $productpicTrans);
                 if (isset($reqData['ProductpicTransUpdateInfoForm_' . $productpicTrans->getLang()->getLocale()])) {
                     $this->gvars['tabActive'] = $productpicTrans->getLang()->getLocale();
                     $this->getSession()->set('tabActive', $productpicTrans->getLang()->getLocale());
                     $productpicTransUpdateInfoForm->handleRequest($request);
                     if ($productpicTransUpdateInfoForm->isValid()) {
                         $em->persist($productpicTrans);
                         $em->flush();
                         $this->flashMsgSession('success', $this->translate('ProductpicTrans.edit.success', array('%productpic%' => $productpic->getFilename())));
                         return $this->redirect($urlFrom);
                     } else {
                         $em->refresh($productpic);
                         $this->flashMsgSession('error', $this->translate('ProductpicTrans.edit.failure', array('%productpic%' => $productpic->getFilename())));
                     }
                 }
                 $this->gvars['ProductpicTransUpdateInfoForm'][$productpicTrans->getLang()->getLocale()] = $productpicTransUpdateInfoForm->createView();
             }
             $this->gvars['productpic'] = $productpic;
             $this->gvars['ProductpicUpdateContentForm'] = $productpicUpdateContentForm->createView();
             $this->gvars['ProductpicUpdateRankForm'] = $productpicUpdateRankForm->createView();
             $this->gvars['ProductpicUpdateInfoForm'] = $productpicUpdateInfoForm->createView();
             $this->gvars['pagetitle'] = $this->translate('Pagetitle.productpic.edit', array('%productpic%' => $productpic->getFilename()));
             $this->gvars['pagetitle_txt'] = $this->translate('Pagetitle.productpic.edit.txt', array('%productpic%' => $productpic->getFilename()));
             return $this->renderResponse('AllucoAdminBundle:Productpic:edit.html.twig', $this->gvars);
         }
     } catch (\Exception $e) {
         $logger = $this->getLogger();
         $logger->addCritical($e->getLine() . ' ' . $e->getMessage() . ' ' . $e->getTraceAsString());
     }
     return $this->redirect($urlFrom);
 }
Beispiel #2
0
 public function editPostAction($id)
 {
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         return $this->redirect($this->generateUrl('_admin_product_list'));
     }
     $em = $this->getEntityManager();
     try {
         $product = $em->getRepository('AllucoDataBundle:Product')->find($id);
         if (null == $product) {
             $this->flashMsgSession('warning', 'Product.edit.notfound');
         } else {
             $productUpdateForm = $this->createForm(new ProductUpdateTForm(), $product);
             $productUpdatePageUrlForm = $this->createForm(new ProductUpdatePageUrlTForm(), $product);
             $productUpdateThumbForm = $this->createForm(new ProductUpdateThumbTForm(), $product);
             $productUpdateThumbInfoForm = $this->createForm(new ProductUpdateThumbInfoTForm(), $product);
             $productUpdateRankForm = $this->createForm(new ProductUpdateRankTForm(), $product);
             $productUpdateNameForm = $this->createForm(new ProductUpdateNameTForm(), $product);
             $productUpdateParentForm = $this->createForm(new ProductUpdateParentTForm($product->getPageUrlFull()), $product);
             $productpic = new Productpic();
             $productpic->setProduct($product);
             $productpicNewForm = $this->createForm(new ProductpicNewTForm($product), $productpic);
             $productdoc = new Productdoc();
             $productdoc->setProduct($product);
             $productdocNewForm = $this->createForm(new ProductdocNewTForm($product), $productdoc);
             $langs = $em->getRepository('AllucoDataBundle:Lang')->getAll();
             $this->gvars['langs'] = $langs;
             foreach ($langs as $lang) {
                 $productTrans = $em->getRepository('AllucoDataBundle:ProductTrans')->findOneBy(array('lang' => $lang, 'product' => $product));
                 if (null == $productTrans) {
                     $productTrans = new ProductTrans();
                     $productTrans->setLang($lang);
                     $productTrans->setProduct($product);
                     $productTrans->setName($product->getName());
                     $productTrans->setMetaTitle($product->getMetaTitle());
                     $productTrans->setMetaKeywords($product->getMetaKeywords());
                     $productTrans->setMetaDescription($product->getMetaDescription());
                     $productTrans->setPageTitle($product->getPageTitle());
                     $productTrans->setBreadcrumb($product->getBreadcrumb());
                     $productTrans->setPageContent($product->getPageContent());
                     $productTrans->setThumbAlt($product->getThumbAlt());
                     $productTrans->setThumbTitle($product->getThumbTitle());
                     try {
                         $em->persist($productTrans);
                         $em->flush();
                     } catch (\Exception $e) {
                         // ne rien faire
                     }
                 }
             }
             $em->refresh($product);
             $this->gvars['tabActive'] = $this->getSession()->get('tabActive', 2);
             $this->getSession()->remove('tabActive');
             $request = $this->getRequest();
             $reqData = $request->request->all();
             if (isset($reqData['ProductUpdateNameForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productUpdateNameForm->handleRequest($request);
                 if ($productUpdateNameForm->isValid()) {
                     $em->persist($product);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Product.edit.success', array('%product%' => $product->getName())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductUpdatePageUrlForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productUpdatePageUrlForm->handleRequest($request);
                 if ($productUpdatePageUrlForm->isValid()) {
                     $slug = $this->get('cocur_slugify')->slugify($productUpdatePageUrlForm['pageUrl']->getData(), '_');
                     $foundSlug = false;
                     do {
                         $productTest = $em->getRepository('AllucoDataBundle:Product')->findOneBy(array('pageUrl' => $slug));
                         if (null != $productTest && $productTest->getId() != $product->getId()) {
                             $foundSlug = true;
                             $slug = $slug . '_1';
                         } else {
                             $foundSlug = false;
                         }
                     } while ($foundSlug == true);
                     $product->setPageUrl($slug);
                     $em->persist($product);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Product.edit.success', array('%product%' => $product->getName())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductUpdateForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productUpdateForm->handleRequest($request);
                 if ($productUpdateForm->isValid()) {
                     $em->persist($product);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Product.edit.success', array('%product%' => $product->getName())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductUpdateThumbForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productUpdateThumbForm->handleRequest($request);
                 if ($productUpdateThumbForm->isValid()) {
                     $productUrl = $productUpdateThumbForm['thumb']->getData();
                     $productDir = $this->getParameter('kernel.root_dir') . '/../web/res/prods';
                     $fileName = sha1(uniqid(mt_rand(), true)) . '.' . strtolower($productUrl->getClientOriginalExtension());
                     $productUrl->move($productDir, $fileName);
                     $product->setThumb($fileName);
                     $em->persist($product);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Product.edit.success', array('%product%' => $product->getName())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductUpdateThumbInfoForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productUpdateThumbInfoForm->handleRequest($request);
                 if ($productUpdateThumbInfoForm->isValid()) {
                     $em->persist($product);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Product.edit.success', array('%product%' => $product->getName())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductUpdateRankForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productUpdateRankForm->handleRequest($request);
                 if ($productUpdateRankForm->isValid()) {
                     $em->persist($product);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Product.edit.success', array('%product%' => $product->getName())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductpicNewForm'])) {
                 $this->gvars['tabActive'] = 3;
                 $this->getSession()->set('tabActive', 3);
                 $productpicNewForm->handleRequest($request);
                 if ($productpicNewForm->isValid()) {
                     $productpicUrl = $productpicNewForm['filename']->getData();
                     $productpicDir = $this->getParameter('kernel.root_dir') . '/../web/res/pics';
                     $fileName = sha1(uniqid(mt_rand(), true)) . '.' . strtolower($productpicUrl->getClientOriginalExtension());
                     $productpicUrl->move($productpicDir, $fileName);
                     $productpic->setFilename($fileName);
                     $em->persist($productpic);
                     $em->flush();
                     foreach ($langs as $lang) {
                         $productpicTrans = new ProductpicTrans();
                         $productpicTrans->setLang($lang);
                         $productpicTrans->setProductpic($productpic);
                         $productpicTrans->setAlt($productpic->getAlt());
                         $productpicTrans->setTitle($productpic->getTitle());
                         try {
                             $em->persist($productpicTrans);
                             $em->flush();
                         } catch (\Exception $e) {
                             // ne rien faire
                         }
                     }
                     $this->flashMsgSession('success', $this->translate('Productpic.add.success', array('%productpic%' => $productpic->getFilename())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductdocNewForm'])) {
                 $this->gvars['tabActive'] = 4;
                 $this->getSession()->set('tabActive', 4);
                 $productdocNewForm->handleRequest($request);
                 if ($productdocNewForm->isValid()) {
                     $productdocUrl = $productdocNewForm['filename']->getData();
                     $productdocDir = $this->getParameter('kernel.root_dir') . '/../web/res/docs';
                     $originalName = $productdocUrl->getClientOriginalName();
                     $fileName = sha1(uniqid(mt_rand(), true)) . '.' . strtolower($productdocUrl->getClientOriginalExtension());
                     $mimeType = $productdocUrl->getMimeType();
                     $productdocUrl->move($productdocDir, $fileName);
                     $size = filesize($productdocDir . '/' . $fileName);
                     $md5 = md5_file($productdocDir . '/' . $fileName);
                     $productdoc->setFilename($fileName);
                     $productdoc->setOriginalName($originalName);
                     $productdoc->setSize($size);
                     $productdoc->setMimeType($mimeType);
                     $productdoc->setMd5($md5);
                     $em->persist($productdoc);
                     $em->flush();
                     foreach ($langs as $lang) {
                         $productdocTrans = new ProductdocTrans();
                         $productdocTrans->setLang($lang);
                         $productdocTrans->setProductdoc($productdoc);
                         $productdocTrans->setTitle($productdoc->getTitle());
                         try {
                             $em->persist($productdocTrans);
                             $em->flush();
                         } catch (\Exception $ex) {
                             // ne rien faire
                         }
                     }
                     $this->flashMsgSession('success', $this->translate('Productdoc.add.success', array('%productdoc%' => $productdoc->getFilename())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             } elseif (isset($reqData['ProductUpdateParentForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $productUpdateParentForm->handleRequest($request);
                 if ($productUpdateParentForm->isValid()) {
                     $em->persist($product);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Product.edit.success', array('%product%' => $product->getName())));
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($product);
                     $this->flashMsgSession('error', $this->translate('Product.edit.failure', array('%product%' => $product->getName())));
                 }
             }
             //*/
             foreach ($product->getI18ns() as $productTrans) {
                 $em->refresh($productTrans);
                 $productTransUpdateNameForm = $this->createForm(new ProductTransUpdateNameTForm($productTrans->getLang()->getLocale()), $productTrans);
                 $productTransUpdateForm = $this->createForm(new ProductTransUpdateTForm($productTrans->getLang()->getLocale()), $productTrans);
                 $productTransUpdateThumbInfoForm = $this->createForm(new ProductTransUpdateThumbInfoTForm($productTrans->getLang()->getLocale()), $productTrans);
                 if (isset($reqData['ProductTransUpdateForm_' . $productTrans->getLang()->getLocale()])) {
                     $this->gvars['tabActive'] = $productTrans->getLang()->getLocale();
                     $this->getSession()->set('tabActive', $productTrans->getLang()->getLocale());
                     $productTransUpdateForm->handleRequest($request);
                     if ($productTransUpdateForm->isValid()) {
                         $em->persist($productTrans);
                         $em->flush();
                         $this->flashMsgSession('success', $this->translate('ProductTrans.edit.success', array('%product%' => $product->getName())));
                         return $this->redirect($urlFrom);
                     } else {
                         $em->refresh($product);
                         $this->flashMsgSession('error', $this->translate('ProductTrans.edit.failure', array('%product%' => $product->getName())));
                     }
                 } elseif (isset($reqData['ProductTransUpdateThumbInfoForm_' . $productTrans->getLang()->getLocale()])) {
                     $this->gvars['tabActive'] = $productTrans->getLang()->getLocale();
                     $this->getSession()->set('tabActive', $productTrans->getLang()->getLocale());
                     $productTransUpdateThumbInfoForm->handleRequest($request);
                     if ($productTransUpdateThumbInfoForm->isValid()) {
                         $em->persist($productTrans);
                         $em->flush();
                         $this->flashMsgSession('success', $this->translate('ProductTrans.edit.success', array('%product%' => $product->getName())));
                         return $this->redirect($urlFrom);
                     } else {
                         $em->refresh($product);
                         $this->flashMsgSession('error', $this->translate('ProductTrans.edit.failure', array('%product%' => $product->getName())));
                     }
                 } elseif (isset($reqData['ProductTransUpdateNameForm_' . $productTrans->getLang()->getLocale()])) {
                     $this->gvars['tabActive'] = $productTrans->getLang()->getLocale();
                     $this->getSession()->set('tabActive', $productTrans->getLang()->getLocale());
                     $productTransUpdateNameForm->handleRequest($request);
                     if ($productTransUpdateNameForm->isValid()) {
                         $em->persist($productTrans);
                         $em->flush();
                         $this->flashMsgSession('success', $this->translate('ProductTrans.edit.success', array('%product%' => $product->getName())));
                         return $this->redirect($urlFrom);
                     } else {
                         $em->refresh($product);
                         $this->flashMsgSession('error', $this->translate('ProductTrans.edit.failure', array('%product%' => $product->getName())));
                     }
                 }
                 $this->gvars['ProductTransUpdateNameForm'][$productTrans->getLang()->getLocale()] = $productTransUpdateNameForm->createView();
                 $this->gvars['ProductTransUpdateForm'][$productTrans->getLang()->getLocale()] = $productTransUpdateForm->createView();
                 $this->gvars['ProductTransUpdateThumbInfoForm'][$productTrans->getLang()->getLocale()] = $productTransUpdateThumbInfoForm->createView();
             }
             $this->gvars['product'] = $product;
             $this->gvars['ProductUpdateForm'] = $productUpdateForm->createView();
             $this->gvars['ProductUpdatePageUrlForm'] = $productUpdatePageUrlForm->createView();
             $this->gvars['ProductUpdateThumbForm'] = $productUpdateThumbForm->createView();
             $this->gvars['ProductUpdateThumbInfoForm'] = $productUpdateThumbInfoForm->createView();
             $this->gvars['ProductUpdateRankForm'] = $productUpdateRankForm->createView();
             $this->gvars['ProductUpdateNameForm'] = $productUpdateNameForm->createView();
             $this->gvars['ProductpicNewForm'] = $productpicNewForm->createView();
             $this->gvars['ProductdocNewForm'] = $productdocNewForm->createView();
             $this->gvars['ProductUpdateParentForm'] = $productUpdateParentForm->createView();
             $this->gvars['pagetitle'] = $this->translate('Pagetitle.product.edit', array('%product%' => $product->getName()));
             $this->gvars['pagetitle_txt'] = $this->translate('Pagetitle.product.edit.txt', array('%product%' => $product->getName()));
             return $this->renderResponse('AllucoAdminBundle:Product:edit.html.twig', $this->gvars);
         }
     } catch (\Exception $e) {
         $logger = $this->getLogger();
         $logger->addCritical($e->getLine() . ' ' . $e->getMessage() . ' ' . $e->getTraceAsString());
     }
     return $this->redirect($urlFrom);
 }
Beispiel #3
0
 public function addPostAction()
 {
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         return $this->redirect($this->generateUrl('_admin_lang_addGet'));
     }
     $lang = new Lang();
     $langNewForm = $this->createForm(new LangNewTForm(), $lang);
     $request = $this->getRequest();
     $reqData = $request->request->all();
     if (isset($reqData['LangNewForm'])) {
         $langNewForm->handleRequest($request);
         if ($langNewForm->isValid()) {
             $em = $this->getEntityManager();
             $em->persist($lang);
             $em->flush();
             $jobs = $em->getRepository('AllucoDataBundle:Job')->getAll();
             foreach ($jobs as $job) {
                 $jobTrans = new JobTrans();
                 $jobTrans->setLang($lang);
                 $jobTrans->setJob($job);
                 $jobTrans->setName($job->getName());
                 $em->persist($jobTrans);
             }
             $banners = $em->getRepository('AllucoDataBundle:Banner')->getAll();
             foreach ($banners as $banner) {
                 $bannerTrans = new BannerTrans();
                 $bannerTrans->setLang($lang);
                 $bannerTrans->setBanner($banner);
                 $bannerTrans->setAlt($banner->getAlt());
                 $bannerTrans->setTitle($banner->getTitle());
                 $em->persist($bannerTrans);
             }
             $certifs = $em->getRepository('AllucoDataBundle:Certif')->getAll();
             foreach ($certifs as $certif) {
                 $certifTrans = new CertifTrans();
                 $certifTrans->setLang($lang);
                 $certifTrans->setCertif($certif);
                 $certifTrans->setTitle($certif->getTitle());
                 $em->persist($certifTrans);
             }
             $staticpages = $em->getRepository('AllucoDataBundle:Staticpage')->getAll();
             foreach ($staticpages as $staticpage) {
                 $staticpageTrans = new StaticpageTrans();
                 $staticpageTrans->setLang($lang);
                 $staticpageTrans->setStaticpage($staticpage);
                 $staticpageTrans->setMetaTitle($staticpage->getMetaTitle());
                 $staticpageTrans->setMetaKeywords($staticpage->getMetaKeywords());
                 $staticpageTrans->setMetaDescription($staticpage->getMetaDescription());
                 $staticpageTrans->setPageTitle($staticpage->getPageTitle());
                 $staticpageTrans->setBreadcrumb($staticpage->getBreadcrumb());
                 $staticpageTrans->setPageContent($staticpage->getPageContent());
                 $em->persist($staticpageTrans);
             }
             $sitenews = $em->getRepository('AllucoDataBundle:Sitenew')->getAll();
             foreach ($sitenews as $sitenew) {
                 $sitenewTrans = new SitenewTrans();
                 $sitenewTrans->setLang($lang);
                 $sitenewTrans->setSitenew($sitenew);
                 $sitenewTrans->setMetaTitle($sitenew->getMetaTitle());
                 $sitenewTrans->setMetaKeywords($sitenew->getMetaKeywords());
                 $sitenewTrans->setMetaDescription($sitenew->getMetaDescription());
                 $sitenewTrans->setPageTitle($sitenew->getPageTitle());
                 $sitenewTrans->setBreadcrumb($sitenew->getBreadcrumb());
                 $sitenewTrans->setPageContent($sitenew->getPageContent());
                 $sitenewTrans->setThumbAlt($sitenew->getThumbAlt());
                 $sitenewTrans->setThumbTitle($sitenew->getThumbTitle());
                 $em->persist($sitenewTrans);
             }
             $products = $em->getRepository('AllucoDataBundle:Product')->getAll();
             foreach ($products as $product) {
                 $productTrans = new ProductTrans();
                 $productTrans->setLang($lang);
                 $productTrans->setProduct($product);
                 $productTrans->setName($product->getName());
                 $productTrans->setMetaTitle($product->getMetaTitle());
                 $productTrans->setMetaKeywords($product->getMetaKeywords());
                 $productTrans->setMetaDescription($product->getMetaDescription());
                 $productTrans->setPageTitle($product->getPageTitle());
                 $productTrans->setBreadcrumb($product->getBreadcrumb());
                 $productTrans->setPageContent($product->getPageContent());
                 $productTrans->setThumbAlt($product->getThumbAlt());
                 $productTrans->setThumbTitle($product->getThumbTitle());
                 $em->persist($productTrans);
             }
             $productpics = $em->getRepository('AllucoDataBundle:Productpic')->getAll();
             foreach ($productpics as $productpic) {
                 $productpicTrans = new ProductpicTrans();
                 $productpicTrans->setLang($lang);
                 $productpicTrans->setProductpic($productpic);
                 $productpicTrans->setAlt($productpic->getAlt());
                 $productpicTrans->setTitle($productpic->getTitle());
                 $em->persist($productpicTrans);
             }
             $productdocs = $em->getRepository('AllucoDataBundle:Productdoc')->getAll();
             foreach ($productdocs as $productdoc) {
                 $productdocTrans = new ProductdocTrans();
                 $productdocTrans->setLang($lang);
                 $productdocTrans->setProductdoc($productdoc);
                 $productdocTrans->setTitle($productdoc->getTitle());
                 $em->persist($productdocTrans);
             }
             $em->flush();
             $this->flashMsgSession('success', $this->translate('Lang.add.success', array('%lang%' => $lang->getName())));
             return $this->redirect($this->generateUrl('_admin_lang_editGet', array('id' => $lang->getId())));
         } else {
             $this->flashMsgSession('error', $this->translate('Lang.add.failure', array('%lang%' => $langNewForm['locale']->getData())));
         }
     }
     $this->gvars['lang'] = $lang;
     $this->gvars['LangNewForm'] = $langNewForm->createView();
     $this->gvars['pagetitle'] = $this->translate('Pagetitle.lang.add');
     $this->gvars['pagetitle_txt'] = $this->translate('Pagetitle.lang.add.txt');
     $this->gvars['smenu_active'] = 'add';
     return $this->renderResponse('AllucoAdminBundle:Lang:add.html.twig', $this->gvars);
 }