protected function build($slug, Request $request, Application $app) { $this->parameters = array(); $mr = new MediaRepository(); $this->parameters['media'] = $mr->loadBySlug($app['currentSite'], $slug); if (!$this->parameters['media']) { return false; } if ($this->parameters['media']->getIsDeleted()) { return false; } return true; }
function index($siteid, $slug, Request $request, Application $app) { $this->build($siteid, $slug, $request, $app); $form = $app['form.factory']->create(new ActionForm()); if ('POST' == $request->getMethod()) { $form->bind($request); if ($form->isValid()) { $data = $form->getData(); $action = new ActionParser($data['action']); if ($action->getCommand() == 'delete' && !$this->parameters['media']->getIsDeleted()) { $mr = new MediaRepository(); $mr->delete($this->parameters['media'], $app['currentUser']); return $app->redirect('/sysadmin/site/' . $this->parameters['site']->getId() . '/media/' . $this->parameters['media']->getSlug()); } } } $this->parameters['form'] = $form->createView(); return $app['twig']->render('sysadmin/media/index.html.twig', $this->parameters); }
function editMediaAddExisting($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Venue does not exist."); } if ($request->request->get('addMedia') && $request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) { $mediaRepository = new MediaRepository(); $media = $mediaRepository->loadBySlug($app['currentSite'], $request->request->get('addMedia')); if ($media) { $mediaInVenueRepo = new MediaInVenueRepository(); $mediaInVenueRepo->add($media, $this->parameters['venue'], $app['currentUser']); $app['flashmessages']->addMessage('Added!'); return $app->redirect("/venue/" . $this->parameters['venue']->getSlugForURL() . '/'); } } $mrb = new MediaRepositoryBuilder(); $mrb->setIncludeDeleted(false); $mrb->setSite($app['currentSite']); $mrb->setNotInVenue($this->parameters['venue']); $this->parameters['medias'] = $mrb->fetchAll(); return $app['twig']->render('site/venue/edit.media.add.existing.html.twig', $this->parameters); }
} else { if ($site->getIsClosedBySysAdmin()) { // TODO print "closed"; } else { function writeFile($fileName, $mimeType) { global $CONFIG; $fp = fopen($fileName, 'rb'); header("Content-Type: " . $mimeType); if ($CONFIG->cacheSiteLogoInSeconds > 0) { header("Cache-Control: cache"); header("Expires: " . date("r", time() + $CONFIG->cacheSiteLogoInSeconds)); } fpassthru($fp); exit; } if ($site->getLogoMediaId()) { $mediaRepository = new MediaRepository(); $media = $mediaRepository->loadByID($site->getLogoMediaId()); if ($media && !$media->getIsDeleted()) { if ($media->writeThumbnailImageToWebBrowser($CONFIG->cacheSiteLogoInSeconds)) { // done! We can die happy, our mission achieved! die; } } } // send standard logo if we can't send another writeFile(dirname(__FILE__) . '/theme/default/img/logo.png', 'image/png'); } }
function profile(Request $request, Application $app) { $form = $app['form.factory']->create(new SiteEditProfileForm($app['config']), $app['currentSite']); if ('POST' == $request->getMethod()) { $form->bind($request); if ($form->isValid()) { $siteRepository = new SiteRepository(); $siteRepository->edit($app['currentSite'], $app['currentUser']); if ($app['config']->isFileStore()) { $newLogo = $form['logo']->getData(); if ($newLogo) { $mediaRepository = new MediaRepository(); $media = $mediaRepository->createFromFile($newLogo, $app['currentSite'], $app['currentUser']); if ($media) { $app['currentSite']->setLogoMediaId($media->getId()); $siteProfileMediaRepository = new SiteProfileMediaRepository(); $siteProfileMediaRepository->createOrEdit($app['currentSite'], $app['currentUser']); } } } $app['flashmessages']->addMessage("Details saved."); return $app->redirect("/admin/"); } } return $app['twig']->render('site/admin/profile.html.twig', array('form' => $form->createView())); }