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