Пример #1
0
 private function createBlock(ObjectManager $em, $timetable, $typeId = BlockRepository::TEXT_TYPE)
 {
     $block = new Block();
     $block->setTimetable($timetable);
     $block->setTypeId($typeId);
     $block->setDomId('timegrid_block_1');
     $block->setContent('test');
     $block->setTitle('title');
     $em->persist($block);
     return $block;
 }
Пример #2
0
 public function process(Block $formBlock, $timetable)
 {
     $file = $formBlock->getContent();
     // convert into png if a jpeg was given
     if ($file->getMimeType() == ImgType::MIME_IMAGETYPE_JPEG) {
         $input = imagecreatefromjpeg($file->getRealPath());
         list($width, $height) = getimagesize($file->getRealPath());
         $output = imagecreatetruecolor($width, $height);
         imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
         imagepng($output, $file->getRealPath() . '.png');
         imagedestroy($output);
         imagedestroy($input);
         $pngFile = new File($file->getRealPath() . '.png');
         $media = $this->mediaManager->saveByTimetable($timetable, $pngFile, $this->block->getDomId());
     } else {
         $media = $this->mediaManager->saveByTimetable($timetable, $file, $this->block->getDomId());
     }
     // TODO: saved with domain, we should store without it. Waiting for mediaDataCollector to be updated
     $formBlock->setContent($this->mediaManager->getUrlByMedia($media) . '?' . time());
     $this->saveBlock($formBlock, $timetable);
 }
Пример #3
0
 public function copy(Block $origBlock, Block $destBlock, $destTimetable)
 {
     $origImgMediaPath = $this->findMediaPathByTimeTable($origBlock->getTimetable(), $origBlock->getDomId());
     if (!empty($origImgMediaPath)) {
         copy($origImgMediaPath, $origImgMediaPath . '.bak');
         $destMedia = $this->saveByTimetable($destTimetable, new File($origImgMediaPath), $origBlock->getDomId());
         $destBlock->setContent($this->mediaDataCollector->getUrlByMedia($destMedia));
         // no rename because of the NFS bug
         copy($origImgMediaPath . '.bak', $origImgMediaPath);
         unlink($origImgMediaPath . '.bak');
     }
 }
Пример #4
0
 private function duplicateCalendarsInterpretion($calendar, array &$calendarsSorted, Block $block)
 {
     if (in_array($calendar->id, $this->calendars)) {
         $calendar = clone $calendar;
         $calendar->id .= '-' . count($this->calendars);
         $calendarsSorted[$calendar->id] = $calendar;
         $block->setContent($calendar->id);
     }
     $this->calendars[] = $calendar->id;
     return $calendar;
 }