Go to the documentation of this file.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 = true )
00050 {
00051 $sForceBlank = $blNewPage ? ' target="_blank"' : '';
00052 $sDesc = $this->oxmediaurls__oxdesc->value;
00053 $sUrl = $this->getLink();
00054
00055 $sHtmlLink = "<a href=\"$sUrl\"{$sForceBlank}>$sDesc</a>";
00056
00057 return $sHtmlLink;
00058 }
00059
00065 public function getLink()
00066 {
00067 if ( $this->oxmediaurls__oxisuploaded->value ) {
00068 $sUrl = $this->getConfig()->isSsl() ? $this->getConfig()->getSslShopUrl() : $this->getConfig()->getShopUrl();
00069 $sUrl .= 'out/media/';
00070 $sUrl .= $this->oxmediaurls__oxurl->value;
00071 } else {
00072 $sUrl = $this->oxmediaurls__oxurl->value;
00073 }
00074
00075 return $sUrl;
00076 }
00077
00085 public function delete( $sOXID = null )
00086 {
00087 $sFilePath = $this->getConfig()->getConfigParam('sShopDir') . "/out/media/" .
00088 $this->oxmediaurls__oxurl->value;
00089
00090 if ($this->oxmediaurls__oxisuploaded->value && file_exists($sFilePath)) {
00091 unlink($sFilePath);
00092 }
00093
00094 return parent::delete( $sOXID );
00095 }
00096
00102 protected function _getYoutubeHtml()
00103 {
00104 $sUrl = $this->oxmediaurls__oxurl->value;
00105 $sDesc = $this->oxmediaurls__oxdesc->value;
00106
00107
00108
00109
00110
00111 $sYoutubeUrl = str_replace("www.youtube.com/watch?v=", "www.youtube.com/v/", $sUrl);
00112
00113 $sYoutubeTemplate = '%s<br><object type="application/x-shockwave-flash" data="%s" width="425" height="344"><param name="movie" value="%s"></object>';
00114 $sYoutubeHtml = sprintf($sYoutubeTemplate, $sDesc, $sYoutubeUrl, $sYoutubeUrl);
00115
00116 return $sYoutubeHtml;
00117 }
00118
00119 }