コード例 #1
0
ファイル: collection.php プロジェクト: nlegoff/Phraseanet
 public static function mount_collection(Application $app, databox $databox, $coll_id, User $user)
 {
     $sql = "INSERT INTO bas (base_id, active, server_coll_id, sbas_id, aliases, ord)\n            VALUES\n            (null, 1, :server_coll_id, :sbas_id, '', :ord)";
     $stmt = $databox->get_appbox()->get_connection()->prepare($sql);
     $stmt->execute([':server_coll_id' => $coll_id, ':sbas_id' => $databox->get_sbas_id(), ':ord' => self::getNewOrder($databox->get_appbox()->get_connection(), $databox->get_sbas_id())]);
     $stmt->closeCursor();
     $new_bas = $databox->get_appbox()->get_connection()->lastInsertId();
     $databox->get_appbox()->delete_data_from_cache(appbox::CACHE_LIST_BASES);
     $databox->delete_data_from_cache(databox::CACHE_COLLECTIONS);
     cache_databox::update($app, $databox->get_sbas_id(), 'structure');
     phrasea::reset_baseDatas($databox->get_appbox());
     $coll = self::get_from_base_id($app, $new_bas);
     $coll->set_admin($new_bas, $user);
     return $new_bas;
 }
コード例 #2
0
ファイル: Adapter.php プロジェクト: romainneutron/Phraseanet
 public function delete_data_from_cache($option = null)
 {
     return $this->databox->delete_data_from_cache($this->get_cache_key($option));
 }
コード例 #3
0
ファイル: appbox.php プロジェクト: romainneutron/Phraseanet
 public function write_databox_pic(Alchemyst $alchemyst, Filesystem $filesystem, databox $databox, SymfoFile $pathfile = null, $pic_type)
 {
     $filename = null;
     if (!is_null($pathfile)) {
         if (!in_array(mb_strtolower($pathfile->getMimeType()), ['image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png', 'image/gif'])) {
             throw new \InvalidArgumentException('Invalid file format');
         }
     }
     if (!in_array($pic_type, [databox::PIC_PDF])) {
         throw new \InvalidArgumentException('unknown pic_type');
     }
     if ($pathfile) {
         $filename = $pathfile->getPathname();
         $imageSpec = new ImageSpecification();
         $imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
         $imageSpec->setDimensions(120, 35);
         $tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox') . '.jpg';
         try {
             $alchemyst->turninto($pathfile->getPathname(), $tmp, $imageSpec);
             $filename = $tmp;
         } catch (\MediaAlchemyst\Exception $e) {
         }
     }
     $file = $this->app['root.path'] . '/config/minilogos/' . $pic_type . '_' . $databox->get_sbas_id() . '.jpg';
     $custom_path = $this->app['root.path'] . '/www/custom/minilogos/' . $pic_type . '_' . $databox->get_sbas_id() . '.jpg';
     foreach ([$file, $custom_path] as $target) {
         if (is_file($target)) {
             $filesystem->remove($target);
         }
         if (is_null($filename)) {
             continue;
         }
         $filesystem->mkdir(dirname($target));
         $filesystem->copy($filename, $target);
         $filesystem->chmod($target, 0760);
     }
     $databox->delete_data_from_cache('printLogo');
     return $this;
 }