STARTge.flash')->setMessage('system_success', '', $this->generateUrl('media')); return $this->redirect($this->generateUrl('media_edit', array('id'=>$media->getId()))); } else { $this->get('ec.message.flash')->setMessage('system_error'); } } return array('form' => $form->createView()); } /** * @Route("/upload", name="media_upload") */ public function uploadAction() { $request = $this->get('request'); $return_array = array(); $entity = new Resource(); $webPath = $this->container->getParameter('kernel.root_dir').DIRECTORY_SEPARATOR.'..'.Resource::DEFAULT_WEB_PATH; if ($this->container->hasParameter('root_web_dir')) { $webPath = $this->container->getParameter('root_web_dir'); if (!Utils::startsWith($webPath, DIRECTORY_SEPARATOR)) { $webPath = $this->container->getParameter('kernel.root_dir').DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$webPath; } else if (Utils::endsWith($webPath, DIRECTORY_SEPARATOR)) { $webPath = substr($webPath, 0, -1); } else { $webPath = $webPath; } } $mediaUploadPath = Resource::DEFAULT_UPLOAD_PATH; if ($this->container->hasParameter('lc_media_upload_path')) { $mediaUploadPath = $this->container->getParameter('lc_media_upload_path'); } $entity->setWeb($webPath); $entity->setFolder($mediaUploadPath); $entity->setFile($request->files->get('qqfile')); if ($entity->upload()) { $return_array = $entity->toArray(); $return_array["success"] = true; } $response = new Response(json_encode($return_array)); $response->headers->set('Content-Type', 'application/json; charset=UTF-8'); return $response; } /** * @Route("/new_popup", name="media_new_popup") * @Template() */ public function newPopupAction() { $media = new Media(); $form = $this->createForm(new MediaType(true), $media); $request = $this->get('request'); if ($request->getMethod() === 'POST') { $form->bind($request); if ($form->isValid()) { $entityManager = $this->get('doctrine') ->getManager(); $entityManager->persist($media); $entityManager->flush(); $this->uploadToAWS($media); $this->get('ec.message.flash')->setMessage('system_success', '', $this->generateUrl('media')); return $this->redirect($this->generateUrl('media_list_popup')); } else { $this->get('ec.message.flash')->setMessage('system_error'); } } return array('form' => $form->createView()); } /** * @Route("/list_popup/{page}", defaults={"page"=1}, requirements={"page" = "\d+"}, name="media_list_popup") * @Template() */ public function listPopupAction($page) { //@@ 未使用関数?? $request = $this->get('request'); $session = $this->get('session'); $em = $this->get('doctrine')->getManager(); $securityContext = $this->get('security.context'); $display_items = array( 'name', 'size', 'type', 'update_at' /* "{{ 'admin.order_group.set_order.consumer_name'|trans }}", 'サイズ', 'タイプ', "{{ 'admin.product.updated_at'|trans }}",*/ ); if ($session->has('popup_media_display_items')) { $display_items = $session->get('popup_media_display_items'); } else { $session->set('popup_media_display_items', $display_items); } // 検索用フォーム $sql = 'SELECT m.type from MediaCoreBundle:Media m GROUP BY m.type'; $query = $em->createQuery($sql); $media_type_result = $query->getResult(); $media_type_list = array(); if (count($media_type_result) > 0) { foreach ($media_type_result as $mediaType) { $media_type_list[$mediaType['type']] = $mediaType['type']; } } $form = $this->createForm(new MediaSearchType($media_type_list)); // 検索 // session // media_search_params $params = array();// 検索パラメーター $showSelectBox = false; if ($session->has('popup_media_search_params')) { // postであれば、sessionを上書き if ($request->getMethod() === 'POST') { $form->bind($request); $params = $form->getData(); // 更新日時のfromとtoの位置交換 if ((isset($params['updated_at_from']) && $params['updated_at_from'] != '') && (isset($params['updated_at_to']) && $params['updated_at_to'] != '')) { if (strtotime($params['updated_at_fEND