Пример #1
0
 /**
  * @param ContentEntity $contentEntity
  * @return string|null
  */
 public function getPublicURL($contentEntity)
 {
     $contentClass = $this->cm()->getContentClass($contentEntity->getType(), $contentEntity->getSchema());
     return $contentClass->getPublicURL($contentEntity);
 }
Пример #2
0
 /**
  * @param ContentEntity $contentEntity
  * @param int $width
  * @param int $height
  * @return string|null
  */
 public function getContentThumbURL($contentEntity, $width = 128, $height = 128)
 {
     $contentClass = $this->cm()->getContentClass($contentEntity->getType(), $contentEntity->getSchema());
     if (!$contentClass->isUploadEnabled()) {
         $thumbURL = $this->getThumbService()->open($contentClass->getImage())->resize($width, $height)->cacheFile('guess');
         return $thumbURL;
     }
     if (!$this->isMedia($contentEntity)) {
         return null;
     }
     $media = $contentEntity->getMedia()->first();
     $this->checkAndCreateMediaCacheFile($media);
     if ($this->isImage($contentEntity)) {
         $thumbURL = $this->getThumbService()->open($this->getMediaCachePath($media))->resize($width, $height)->cacheFile('guess');
     } else {
         $thumbURL = $this->getThumbService()->open($this->getMimeResourceImage($media->getMime()))->resize($width, $height)->cacheFile('guess');
     }
     return $thumbURL;
 }
Пример #3
0
 /**
  * @param ContentEntity $contentEntity
  * @return array
  */
 public function getContentAllMeta($contentEntity)
 {
     $returnValue = array();
     $classInstance = $this->getContentClass($contentEntity->getType(), $contentEntity->getSchema());
     $loadedMeta = $contentEntity->getLoadedMeta();
     if (!is_null($loadedMeta)) {
         return $loadedMeta;
     }
     $existingMeta = $contentEntity->getMeta();
     if (!empty($existingMeta)) {
         /**
          * @var ContentMetaEntity $meta
          */
         foreach ($existingMeta as $meta) {
             $metaField = $meta->getField();
             $metaValue = $meta->getValue();
             $metaType = $meta->getFieldType();
             $metaValue = $this->decodeDataFromDB($metaType, $metaField, $metaValue, $classInstance);
             if ($metaType == ContentFieldType::Content) {
                 if (!is_array($metaValue) && !is_null($metaValue)) {
                     $metaValue = $this->getContentRepository()->find($metaValue);
                 }
             }
             if ($metaType == ContentFieldType::Custom) {
                 $metaValue = $classInstance->loadCustomField($metaField, $metaValue);
             }
             $returnValue[$metaField] = $metaValue;
         }
     }
     $contentEntity->setLoadedMeta($returnValue);
     return $returnValue;
 }