oxmediaurl.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxMediaUrl extends oxI18n
00009 {
00015     protected $_sClassName = 'oxmediaurls';
00016 
00020     public function __construct()
00021     {
00022         parent::__construct();
00023         $this->init( 'oxmediaurls' );
00024     }
00025 
00031     public function getHtml()
00032     {
00033         $sUrl = $this->oxmediaurls__oxurl->value;
00034         //youtube link
00035         if (strpos($sUrl, 'youtube.com')) {
00036             return $this->_getYoutubeHtml();
00037         }
00038 
00039         //simple link
00040         return $this->getHtmlLink();
00041     }
00042 
00050     public function getHtmlLink($blNewPage = false)
00051     {
00052         $sUrl = $this->oxmediaurls__oxurl->value;
00053         $sDesc = $this->oxmediaurls__oxdesc->value;
00054 
00055         $sForceBlank = $blNewPage?'target=_blank':'';
00056         
00057         $sHtmlLink = "<a href='$sUrl' $sForceBlank >$sDesc</a>";
00058         return $sHtmlLink;
00059     }
00060 
00068     public function delete( $sOXID = null )
00069     {
00070         $sFilePath = $this->getConfig()->getConfigParam('sShopDir') . "/out/media/" .
00071                      $this->oxmediaurls__oxurl->value;
00072         if ($this->oxmediaurls__oxisuploaded->value && file_exists($sFilePath)) {
00073             unlink($sFilePath);
00074         }
00075 
00076         return parent::delete( $sOXID );
00077     }
00078 
00084     protected function _getYoutubeHtml()
00085     {
00086         $sUrl = $this->oxmediaurls__oxurl->value;
00087         $sDesc = $this->oxmediaurls__oxdesc->value;
00088 
00089         //http://www.youtube.com/watch?v=Fx--jNQYNgA&feature=related
00090         //to
00091         //<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Fx--jNQYNgA&hl=en"></param><embed src="http://www.youtube.com/v/Fx--jNQYNgA&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>
00092 
00093         $sYoutubeUrl = str_replace("www.youtube.com/watch?v=", "www.youtube.com/v/", $sUrl);
00094 
00095         $sYoutubeTemplate = '%s<br><object type="application/x-shockwave-flash" data="%s" width="425" height="344"><param name="movie" value="%s"></object>';
00096         $sYoutubeHtml = sprintf($sYoutubeTemplate, $sDesc, $sYoutubeUrl, $sYoutubeUrl);
00097 
00098         return $sYoutubeHtml;
00099     }
00100 
00101 }

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5