/**
  * Gets the HTML for the provided asset
  * @param \ride\service\AssetService $assetService
  * @param \ride\application\orm\asset\entry\AssetEntry $asset
  * @param string $style Name of the style
  * @return string HTML for the provided asset
  */
 public function getAssetHtml(AssetService $assetService, AssetEntry $asset, $style = null)
 {
     if ($asset->isImage()) {
         $result = '<img src="' . $assetService->getAssetUrl($asset, $style) . '" title="' . htmlentities($asset->getName()) . '"';
         if ($this->imageClass) {
             $result .= ' class="' . $this->imageClass . '"';
         }
         if ($asset->getAlt()) {
             $result .= ' alt="' . $asset->getAlt() . '"';
         }
         $result .= '>';
     } elseif ($asset->isAudio()) {
         switch ($asset->getSource()) {
             case 'soundcloud':
                 $result = '<iframe frameborder="0" src="' . $assetService->getAssetUrl($asset) . '"></iframe>';
                 break;
             default:
                 $result = '<audio src="' . $assetService->getAssetUrl($asset) . '" controls></audio>';
         }
     } elseif ($asset->isVideo()) {
         switch ($asset->getSource()) {
             case 'youtube':
             case 'vimeo':
                 $result = '<div class="iframe iframe--16-9"><iframe frameborder="0" src="' . $asset->getEmbedUrl() . '"></iframe></div>';
                 break;
             default:
                 $result = '<video src="' . $assetService->getAssetUrl($asset) . '" controls></video>';
                 break;
         }
     } else {
         $result = '<a href="' . $assetService->getAssetUrl($asset) . '">' . $asset->getName() . '</a>';
     }
     return $result;
 }
Exemple #2
0
 /**
  * @param \ride\application\orm\asset\entry\AssetEntry $pdf 
  * @return null
  */
 public function setPdf(AliasAssetEntry $pdf = NULL)
 {
     $isClean = false;
     if (!$this->pdf && !$pdf || $this->pdf && $pdf && $this->pdf->getId() === $pdf->getId()) {
         $isClean = true;
     }
     $this->pdf = $pdf;
     if (!$isClean && $this->entryState === self::STATE_CLEAN) {
         $this->entryState = self::STATE_DIRTY;
     }
 }
Exemple #3
0
 /**
  * @param \ride\application\orm\asset\entry\AssetEntry $entry 
  * @return null
  */
 public function setEntry(AliasAssetEntry $entry = NULL)
 {
     $isClean = false;
     if (!$this->entry && !$entry || $this->entry && $entry && $this->entry->getId() === $entry->getId()) {
         $isClean = true;
     }
     $this->entry = $entry;
     if (!$isClean && $this->entryState === self::STATE_CLEAN) {
         $this->entryState = self::STATE_DIRTY;
     }
 }
 /**
  * @param \ride\application\orm\asset\entry\AssetEntry $asset 
  * @return null
  */
 public function setAsset(AliasAssetEntry $asset = NULL)
 {
     $isClean = false;
     if (!$this->asset && !$asset || $this->asset && $asset && $this->asset->getId() === $asset->getId()) {
         $isClean = true;
     }
     $this->asset = $asset;
     if (!$isClean && $this->entryState === self::STATE_CLEAN) {
         $this->entryState = self::STATE_DIRTY;
     }
 }
 /**
  * Gets the HTML for the provided asset
  * @param \ride\service\AssetService $assetService
  * @param \ride\application\orm\asset\entry\AssetEntry $asset
  * @param string $style Name of the style
  * @return string HTML for the provided asset
  */
 public function getAssetHtml(AssetService $assetService, AssetEntry $asset, $style = null)
 {
     if (!$asset->isImage()) {
         return parent::getAssetHtml($assetService, $asset, $style);
     }
     $anchor = '<a href="' . $assetService->getAssetUrl($asset) . '"';
     if ($this->anchorClass) {
         $anchor .= ' class="' . $this->anchorClass . '"';
     }
     if ($this->anchorRelationship) {
         $anchor .= ' rel="' . $this->anchorRelationship . '"';
     }
     $anchor .= '>';
     $anchor .= parent::getAssetHtml($assetService, $asset, $style);
     $anchor .= '</a>';
     return $anchor;
 }
 /**
  * @param \ride\application\orm\asset\entry\AssetEntry $asset 
  * @return null
  */
 public function setAsset(AssetEntry $asset = NULL)
 {
     if (!isset($this->loadedFields['asset'])) {
         $this->loadProperties();
     }
     $oldValue = null;
     if (array_key_exists('asset', $this->loadedValues)) {
         $oldValue = $this->loadedValues['asset'];
     }
     if (!$oldValue && !$asset || $oldValue && $asset && $oldValue->getId() === $asset->getId()) {
         $this->asset = $asset;
         return;
     }
     return parent::setAsset($asset);
 }
Exemple #7
0
 /**
  * @param \ride\application\orm\asset\entry\AssetEntry $pdf 
  * @return null
  */
 public function setPdf(AssetEntry $pdf = NULL)
 {
     if (!isset($this->loadedFields['pdf'])) {
         $this->loadProperties();
     }
     $oldValue = null;
     if (array_key_exists('pdf', $this->loadedValues)) {
         $oldValue = $this->loadedValues['pdf'];
     }
     if (!$oldValue && !$pdf || $oldValue && $pdf && $oldValue->getId() === $pdf->getId()) {
         $this->pdf = $pdf;
         return;
     }
     return parent::setPdf($pdf);
 }
 /**
  * @param \ride\application\orm\asset\entry\AssetEntry $entry 
  * @return null
  */
 public function setEntry(AssetEntry $entry = NULL)
 {
     if (!isset($this->loadedFields['entry'])) {
         $this->loadProperties();
     }
     $oldValue = null;
     if (array_key_exists('entry', $this->loadedValues)) {
         $oldValue = $this->loadedValues['entry'];
     }
     if (!$oldValue && !$entry || $oldValue && $entry && $oldValue->getId() === $entry->getId()) {
         $this->entry = $entry;
         return;
     }
     return parent::setEntry($entry);
 }
Exemple #9
0
 /**
  * Gets whether the entry is localized in the requested locale
  * @return boolean Flag to see if the entry is localized in the requested locale
  */
 public function isLocalized()
 {
     if (!isset($this->loadedFields['locale'])) {
         $this->loadProperties();
     }
     return parent::isLocalized();
 }
Exemple #10
0
 /**
  * @param \ride\application\orm\asset\entry\AssetEntry $entry 
  * @return null
  */
 public function removeFromAssets(AliasAssetEntry $entry)
 {
     $this->getAssets();
     $status = false;
     foreach ($this->assets as $assetsIndex => $assetsValue) {
         if ($assetsValue === $entry || $assetsValue->getId() === $entry->getId()) {
             unset($this->assets[$assetsIndex]);
             $status = true;
             break;
         }
     }
     if ($status && $this->entryState === self::STATE_CLEAN) {
         $this->entryState = self::STATE_DIRTY;
     }
     return $status;
 }