/**
  * (non-PHPdoc)
  * @see \Doctrine\DBAL\Migrations\AbstractMigration::up()
  */
 public function up(Schema $schema)
 {
     // copy images for example items
     $this->fs->mirror($this->source, $this->target);
     // create storage
     $storage = (new Storage())->setDescription('Storage on local computer')->setName('Local')->setPath(Filesystem::getUserHomeDir())->setType(Storage::TYPE_FOLDER);
     $this->em->persist($storage);
     // create items
     $this->persist($this->getItemOnePiece($storage));
     $this->persist($this->getItemFullmetalAlchemist($storage));
     $this->persist($this->getItemSpiritedAway($storage));
     $this->em->flush();
 }
 /**
  * Return list folders for path.
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function localPathFoldersAction(Request $request)
 {
     $form = $this->createForm(new ChoiceLocalPath());
     $form->handleRequest($request);
     $path = $form->get('path')->getData() ?: Filesystem::getUserHomeDir();
     if (($root = $request->get('root')) && strpos($path, $root) !== 0) {
         $path = $root;
     }
     /* @var $response JsonResponse */
     $response = $this->getCacheTimeKeeper()->getResponse([(new \DateTime())->setTimestamp(filemtime($path))], -1, new JsonResponse());
     // response was not modified for this request
     if ($response->isNotModified($request)) {
         return $response;
     }
     return $response->setData(['path' => $path, 'folders' => Filesystem::scandir($path, Filesystem::DIRECTORY)]);
 }
 /**
  * (non-PHPdoc)
  * @see \Doctrine\DBAL\Migrations\AbstractMigration::up()
  */
 public function up(Schema $schema)
 {
     // copy images for example items
     $this->fs->mirror($this->source, $this->target);
     // create storage
     $storage = (new Storage())->setDescription('Storage on local computer')->setName('Local')->setPath(Filesystem::getUserHomeDir())->setType(Storage::TYPE_FOLDER);
     $this->em->persist($storage);
     // create items
     $this->persist($this->getItemSamuraiChamploo($storage));
     $this->persist($this->getItemGreatTeacherOnizuka($storage));
     $this->persist($this->getItemBeck($storage));
     $this->persist($this->getItemSamuraiXTrustAndBetrayal($storage));
     $this->persist($this->getItemMyNeighborTotoro($storage));
     $this->persist($this->getItemHellsing($storage));
     $this->persist($this->getItemGintama($storage));
     $this->persist($this->getItemBakuman($storage));
     $this->persist($this->getItemTengenToppaGurrenLagann($storage));
     $this->em->flush();
 }
Exemple #4
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('path', 'text', ['label' => 'Path', 'required' => true, 'attr' => ['placeholder' => Filesystem::getUserHomeDir()]])->setMethod('GET');
     // choice the disc letter in Windows
     if (defined('PHP_WINDOWS_VERSION_BUILD') && extension_loaded('com_dotnet') && ($fs = new \COM('Scripting.FileSystemObject'))) {
         // types: Unknown, Removable, Fixed, Network, CD-ROM, RAM Disk
         $choices = [];
         foreach ($fs->Drives as $drive) {
             $drive = $fs->GetDrive($drive);
             if ($drive->DriveType == 3) {
                 $name = $drive->Sharename;
             } elseif ($drive->IsReady) {
                 $name = $drive->VolumeName;
             } else {
                 $name = '[Drive not ready]';
             }
             $choices[$drive->DriveLetter] = $drive->DriveLetter . ': ' . $name;
         }
         $builder->add('letter', 'choice', ['choices' => $choices]);
     }
 }
 /**
  * Add storage (Stap #2).
  *
  * @param Request $request
  *
  * @return Response
  */
 public function addStorageAction(Request $request)
 {
     // app already installed
     if ($this->container->getParameter('anime_db.catalog.installed')) {
         return $this->redirect($this->generateUrl('home'));
     }
     $response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Storage');
     // response was not modified for this request
     if ($response->isNotModified($request)) {
         return $response;
     }
     // get last storage
     $storage = $this->getRepository()->getLast();
     if (!$storage) {
         $storage = new Storage();
         $storage->setPath(Filesystem::getUserHomeDir());
     }
     $form = $this->createForm(new StorageForm(), $storage)->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($storage);
         $em->flush();
         // redirect to step 3
         return $this->redirect($this->generateUrl('install_what_you_want'));
     }
     return $this->render('AnimeDbCatalogBundle:Install:add_storage.html.twig', ['form' => $form->createView(), 'is_new' => !$storage->getId(), 'guide' => $this->get('anime_db.api.client')->getSiteUrl(StorageController::GUIDE_LINK)], $response);
 }
Exemple #6
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', null, ['label' => 'Main name'])->add('names', 'collection', ['type' => new Name(), 'allow_add' => true, 'by_reference' => false, 'allow_delete' => true, 'required' => false, 'label' => 'Other names', 'options' => ['required' => false], 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_NAMES, $options['data'])])->add('cover', new ImageField(), ['required' => false])->add('rating', new RatingField())->add('date_premiere', 'date', ['format' => 'yyyy-MM-dd', 'widget' => 'single_text', 'required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_DATE_PREMIERE, $options['data'])])->add('date_end', 'date', ['format' => 'yyyy-MM-dd', 'widget' => 'single_text', 'required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_DATE_END, $options['data']), 'help' => 'Specify for completed series'])->add('episodes_number', null, ['required' => false, 'label' => 'Number of episodes', 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_EPISODES_NUMBER, $options['data']), 'help' => 'For releasing the series, you can specify the actual number of episodes with a plus at the end. Example: 123+'])->add('duration', null, ['attr' => $this->getRefillAttr(RefillerInterface::FIELD_DURATION, $options['data'])])->add('type', 'entity', ['class' => 'AnimeDbCatalogBundle:Type', 'property' => 'name'])->add('genres', 'entity', ['class' => 'AnimeDbCatalogBundle:Genre', 'property' => 'name', 'multiple' => true, 'expanded' => true, 'required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_GENRES, $options['data'])])->add('labels', 'entity', ['class' => 'AnimeDbCatalogBundle:Label', 'property' => 'name', 'multiple' => true, 'expanded' => true, 'required' => false])->add('studio', 'entity', ['class' => 'AnimeDbCatalogBundle:Studio', 'property' => 'name', 'required' => false, 'label' => 'Animation studio', 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_STUDIO, $options['data'])])->add('country', 'entity', ['class' => 'AnimeDbCatalogBundle:Country', 'property' => 'name', 'required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_COUNTRY, $options['data'])])->add('storage', 'entity', ['class' => 'AnimeDbCatalogBundle:Storage', 'property' => 'name', 'required' => false, 'attr' => ['class' => 'f-storage', 'data-source' => $this->router->generate('storage_path'), 'data-target' => '#' . $this->getName() . '_path']])->add('path', new LocalPathField(), ['required' => false, 'attr' => ['placeholder' => Filesystem::getUserHomeDir()]])->add('translate', 'textarea', ['required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_TRANSLATE, $options['data']) + ['rows' => 2], 'help' => 'Description language soundtracks and subtitles in free form'])->add('summary', null, ['required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_SUMMARY, $options['data'])])->add('episodes', null, ['required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_EPISODES, $options['data'])])->add('file_info', null, ['required' => false, 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_FILE_INFO, $options['data'])])->add('sources', 'collection', ['type' => new Source(), 'allow_add' => true, 'by_reference' => false, 'allow_delete' => true, 'required' => false, 'label' => 'External sources', 'options' => ['required' => false], 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_SOURCES, $options['data'])])->add('images', 'collection', ['type' => new Image(), 'allow_add' => true, 'by_reference' => false, 'allow_delete' => true, 'required' => false, 'label' => 'Other images', 'options' => ['required' => false], 'attr' => $this->getRefillAttr(RefillerInterface::FIELD_IMAGES, $options['data'])]);
 }
Exemple #7
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', null, ['label' => 'Name'])->add('path', new LocalPathField(), ['label' => 'Path', 'required' => false, 'attr' => ['placeholder' => Filesystem::getUserHomeDir()]])->add('type', 'choice', ['choices' => StorageEntity::getTypeTitles(), 'label' => 'Type'])->add('description', null, ['label' => 'Description']);
 }