コード例 #1
0
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('Gallery');
     $mediaType = new MediaSource('gallery', $_ARRAYLANG['TXT_THUMBNAIL_GALLERY'], array($this->cx->getWebsiteImagesGalleryPath(), $this->cx->getWebsiteImagesGalleryWebPath(), array(12, 67)));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #2
0
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('Contact');
     $mediaType = new MediaSource('attach', $_ARRAYLANG['TXT_CONTACT_UPLOADS'], array($this->cx->getWebsiteImagesAttachPath(), $this->cx->getWebsiteImagesAttachWebPath()));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #3
0
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaBrowser');
     $mediaType = new MediaSource('files', $_ARRAYLANG['TXT_FILEBROWSER_FILES'], array($this->cx->getWebsiteImagesContentPath(), $this->cx->getWebsiteImagesContentWebPath()), array(), 1);
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #4
0
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaDir');
     $mediaType = new MediaSource('mediadir', $_ARRAYLANG['TXT_FILEBROWSER_MEDIADIR'], array($this->cx->getWebsiteImagesMediaDirPath(), $this->cx->getWebsiteImagesMediaDirWebPath()), array(153));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #5
0
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaBrowser');
     $mediaType = new MediaSource('shop', $_ARRAYLANG['TXT_FILEBROWSER_SHOP'], array($this->cx->getWebsiteImagesShopPath(), $this->cx->getWebsiteImagesShopWebPath()));
     $mediaType->setAccessIds(array(13));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #6
0
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('Media');
     for ($i = 1; $i < 5; $i++) {
         $mediaType = new MediaSource('media' . $i, $_ARRAYLANG['TXT_MEDIA_ARCHIVE'] . ' ' . $i, array(call_user_func(array($this->cx, 'getWebsiteMediaarchive' . $i . 'Path')), call_user_func(array($this->cx, 'getWebsiteMediaarchive' . $i . 'WebPath'))), array(7, 39, 38));
         $mediaBrowserConfiguration->addMediaType($mediaType);
     }
 }
コード例 #7
0
 public function testMediaSourceManager()
 {
     $testCx = new TestCx();
     $name = "Test";
     $testCx->getEvents()->addMediaSource(new MediaSource($name, "test", array(self::$cx->getWebsiteImagesContentPath(), self::$cx->getWebsiteImagesContentWebPath())));
     $mediaSourceManger = new MediaSourceManager($testCx);
     $mediaTypes = $mediaSourceManger->getMediaTypes();
     $this->assertEquals($name, $mediaTypes['Test']->getName());
     $this->assertTrue(count($mediaSourceManger->getMediaTypes()) == 1);
 }
コード例 #8
0
 /**
  * Test the subdirectory check in the filesystem class
  */
 public function testSubdirectoryCheck()
 {
     $cx = Cx::instanciate();
     $this->assertTrue(MediaSourceManager::isSubdirectory($cx->getWebsitePath() . '/images', 'files/'));
     $this->assertFalse(MediaSourceManager::isSubdirectory($cx->getWebsitePath() . '/media', 'files/'));
     $this->assertFalse(MediaSourceManager::isSubdirectory($cx->getWebsitePath() . '/images', 'media5/'));
 }
コード例 #9
0
 /**
  * Create all the thumbnails for a picture.
  *
  * @param string        $path Path to the file. This can be a virtual path or a absolute path.
  * @param string        $fileNamePlain Plain file name without extension
  * @param string        $fileExtension Extension of the file
  * @param \ImageManager $imageManager
  *
  * <code>
  * <?php
  * \Cx\Core_Modules\MediaBrowser\Model\FileSystem::createThumbnail(
  *      'files/',
  *      'Django,
  *      'jpg',
  *      new ImageManager() // Please recycle the instance and don't create a new anonymous instance for each call.
  *                         // This is just a simple example.
  * );
  * ?>
  * </code>
  *
  * @return array With all thumbnail types and if they were generated successfully.
  */
 public static function createThumbnail($path, $fileNamePlain, $fileExtension, \ImageManager $imageManager, $generateThumbnailByRatio = false)
 {
     $success = array();
     foreach (UploaderConfiguration::getInstance()->getThumbnails() as $thumbnail) {
         if (\Cx\Lib\FileSystem\FileSystem::exists(MediaSourceManager::getAbsolutePath($path) . $fileNamePlain . $thumbnail['value'] . '.' . $fileExtension)) {
             $success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_NEUTRAL;
             continue;
         }
         if ($imageManager->_createThumb(MediaSourceManager::getAbsolutePath($path) . '/', '', $fileNamePlain . '.' . $fileExtension, $thumbnail['size'], $thumbnail['quality'], $fileNamePlain . $thumbnail['value'] . '.' . $fileExtension, $generateThumbnailByRatio)) {
             $success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_SUCCESS;
             continue;
         }
         $success[$thumbnail['value']] = self::THUMBNAIL_GENERATOR_FAIL;
     }
     return $success;
 }
コード例 #10
0
 /**
  * @param MediaSourceManager $mediaSourceManager
  */
 public function mediasourceLoad(MediaSourceManager $mediaSourceManager)
 {
     global $_ARRAYLANG;
     $mediaType = new MediaSource('themes', $_ARRAYLANG['TXT_THEME_THEMES'], array($this->cx->getWebsiteThemesPath(), $this->cx->getWebsiteThemesWebPath()), array(), '', new ViewManagerFileSystem($this->cx->getWebsiteThemesPath()));
     $mediaSourceManager->addMediaType($mediaType);
 }
コード例 #11
0
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     $mediaType = new MediaSource('calendar', $_ARRAYLANG['TXT_CALENDAR'], array($this->cx->getWebsiteImagesCalendarPath(), $this->cx->getWebsiteImagesCalendarWebPath()), array(16));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #12
0
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     $mediaType = new MediaSource('blog', $_ARRAYLANG['TXT_BLOG_MODULE'], array($this->cx->getWebsiteImagesBlogPath(), $this->cx->getWebsiteImagesBlogWebPath()), array(119));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #13
0
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     $mediaType = new MediaSource('downloads', $_ARRAYLANG['TXT_FILEBROWSER_DOWNLOADS'], array($this->cx->getWebsiteImagesDownloadsPath(), $this->cx->getWebsiteImagesDownloadsWebPath()), array(141));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #14
0
 /**
  * Returns the smallest thumbnail for a file.
  *
  * @param $filename
  *
  * @return string Thumbnail Name
  */
 public function getThumbnailFilename($filename)
 {
     // legacy fallback for older calls.
     if (preg_match('/\\.thumb$/', $filename)) {
         return $filename;
     }
     if (!file_exists($filename) && !file_exists($this->cx->getWebsitePath() . '/' . ltrim($filename, '/'))) {
         return $filename . '.thumb';
     }
     $webpath = pathinfo($filename, PATHINFO_DIRNAME);
     if (!file_exists($filename)) {
         $filename = $this->cx->getWebsitePath() . $filename;
     }
     if (file_exists($filename) && MediaSourceManager::isSubdirectory($this->cx->getWebsitePath(), $filename)) {
         $this->createThumbnailFromPath($filename);
     }
     $extension = pathinfo($filename, PATHINFO_EXTENSION);
     $filename = pathinfo($filename, PATHINFO_FILENAME);
     $this->getThumbnails();
     $thumbnailType = $this->thumbnails[0];
     $thumbnail = preg_replace('/\\.' . lcfirst($extension) . '$/', $thumbnailType['value'] . '.' . lcfirst($extension), $webpath . '/' . $filename . '.' . $extension);
     return $thumbnail;
 }
コード例 #15
0
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     $mediaType = new MediaSource('access', $_ARRAYLANG['TXT_USER_ADMINISTRATION'], array($this->cx->getWebsiteImagesAccessPath(), $this->cx->getWebsiteImagesAccessWebPath()), array(18));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #16
0
 public function moveFile(File $file, $destination)
 {
     global $_ARRAYLANG;
     if (!empty($destination) || !\FWValidator::is_file_ending_harmless($destination)) {
         if (is_dir($this->getFullPath($file) . $file->getFullName())) {
             $fileName = $this->getFullPath($file) . $file->getFullName();
             $destinationFileName = $this->getFullPath($file) . $destination;
         } else {
             $fileName = $this->getFullPath($file) . $file->getFullName();
             $destinationFileName = $this->getFullPath($file) . $destination . '.' . $file->getExtension();
         }
         if ($fileName == $destinationFileName) {
             return sprintf($_ARRAYLANG['TXT_FILEBROWSER_FILE_SUCCESSFULLY_RENAMED'], $file->getName());
         }
         $destinationFolder = realpath(pathinfo($this->getFullPath($file) . $destination, PATHINFO_DIRNAME));
         if (!MediaSourceManager::isSubdirectory($this->rootPath, $destinationFolder)) {
             return sprintf($_ARRAYLANG['TXT_FILEBROWSER_FILE_UNSUCCESSFULLY_RENAMED'], $file->getName());
         }
         $this->removeThumbnails($file);
         if (!\Cx\Lib\FileSystem\FileSystem::move($fileName, $destinationFileName, false)) {
             return sprintf($_ARRAYLANG['TXT_FILEBROWSER_FILE_UNSUCCESSFULLY_RENAMED'], $file->getName());
         }
         return sprintf($_ARRAYLANG['TXT_FILEBROWSER_FILE_SUCCESSFULLY_RENAMED'], $file->getName());
     } else {
         return sprintf($_ARRAYLANG['TXT_FILEBROWSER_FILE_UNSUCCESSFULLY_RENAMED'], $file->getName());
     }
 }
コード例 #17
0
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     $mediaType = new MediaSource('podcast', $_ARRAYLANG['TXT_FILEBROWSER_PODCAST'], array($this->cx->getWebsiteImagesPodcastPath(), $this->cx->getWebsiteImagesPodcastWebPath()), array(87));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
コード例 #18
0
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     $mediaType = new MediaSource('wysiwyg', $_ARRAYLANG['TXT_FILEBROWSER_WYSIWYG'], array($this->cx->getWebsiteImagesPath() . '/Wysiwyg', $this->cx->getWebsiteImagesWebPath() . '/Wysiwyg'), array(16));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }