Go to the documentation of this file.00001 <?php
00002
00010 class Article_Extend extends oxAdminDetails
00011 {
00016 protected $_aUnitsArray = null;
00017
00024 public function render()
00025 {
00026 parent::render();
00027
00028 $this->_aViewData['edit'] = $oArticle = oxNew( 'oxArticle' );
00029
00030 $soxId = $this->getEditObjectId();
00031
00032 $this->_createCategoryTree( "artcattree");
00033
00034
00035 if ( $soxId != "-1" && isset( $soxId ) ) {
00036
00037 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00038
00039
00040
00041 $oOtherLang = $oArticle->getAvailableInLangs();
00042 if (!isset($oOtherLang[$this->_iEditLang])) {
00043
00044 $oArticle->loadInLang( key($oOtherLang), $soxId );
00045 }
00046
00047 foreach ( $oOtherLang as $id => $language) {
00048 $oLang= new stdClass();
00049 $oLang->sLangDesc = $language;
00050 $oLang->selected = ($id == $this->_iEditLang);
00051 $this->_aViewData["otherlang"][$id] = clone $oLang;
00052 }
00053
00054
00055 if ( $oArticle->oxarticles__oxparentid->value) {
00056 $oParentArticle = oxNew( 'oxArticle' );
00057 $oParentArticle->load( $oArticle->oxarticles__oxparentid->value);
00058 $this->_aViewData["parentarticle"] = $oParentArticle;
00059 $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
00060 }
00061 }
00062
00063
00064 $oDB = oxDb::getDB();
00065 $myConfig = $this->getConfig();
00066
00067 $sArticleTable = getViewName( 'oxarticles', $this->_iEditLang );
00068 $sSelect = "select $sArticleTable.oxtitle, $sArticleTable.oxartnum, $sArticleTable.oxvarselect from $sArticleTable where 1 ";
00069
00070 $sSelect .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00071 $sSelect .= " and $sArticleTable.oxid = ".$oDB->quote( $oArticle->oxarticles__oxbundleid->value );
00072
00073 $rs = $oDB->Execute( $sSelect);
00074 if ($rs != false && $rs->RecordCount() > 0) {
00075 while (!$rs->EOF) {
00076 $sArtNum = new oxField($rs->fields[1]);
00077 $sArtTitle = new oxField($rs->fields[0]." ".$rs->fields[2]);
00078 $rs->MoveNext();
00079 }
00080 }
00081 $this->_aViewData['bundle_artnum'] = $sArtNum;
00082 $this->_aViewData['bundle_title'] = $sArtTitle;
00083
00084
00085 $iAoc = $this->getConfig()->getRequestParameter("aoc");
00086 if ( $iAoc == 1 ) {
00087 $oArticleExtendAjax = oxNew( 'article_extend_ajax' );
00088 $this->_aViewData['oxajax'] = $oArticleExtendAjax->getColumns();
00089
00090 return "popups/article_extend.tpl";
00091 } elseif ( $iAoc == 2 ) {
00092 $oArticleBundleAjax = oxNew( 'article_bundle_ajax' );
00093 $this->_aViewData['oxajax'] = $oArticleBundleAjax->getColumns();
00094
00095 return "popups/article_bundle.tpl";
00096 }
00097
00098
00099 $this->_aViewData['aMediaUrls'] = $oArticle->getMediaUrls();
00100
00101 return "article_extend.tpl";
00102 }
00103
00109 public function save()
00110 {
00111 parent::save();
00112
00113 $aMyFile = $this->getConfig()->getUploadedFile( "myfile" );
00114 $aMediaFile = $this->getConfig()->getUploadedFile( "mediaFile" );
00115 if ( is_array( $aMyFile['name'] ) && reset( $aMyFile['name'] ) || $aMediaFile['name'] ) {
00116 $myConfig = $this->getConfig();
00117 if ( $myConfig->isDemoShop() ) {
00118 $oEx = oxNew( "oxExceptionToDisplay" );
00119 $oEx->setMessage( 'ARTICLE_EXTEND_UPLOADISDISABLED' );
00120 oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx, false );
00121
00122 return;
00123 }
00124 }
00125
00126 $soxId = $this->getEditObjectId();
00127 $aParams = oxRegistry::getConfig()->getRequestParameter( "editval");
00128
00129 if ( !isset( $aParams['oxarticles__oxissearch'])) {
00130 $aParams['oxarticles__oxissearch'] = 0;
00131 }
00132 if ( !isset( $aParams['oxarticles__oxblfixedprice'])) {
00133 $aParams['oxarticles__oxblfixedprice'] = 0;
00134 }
00135
00136
00137
00138
00139
00140
00141 $aParams = $this->addDefaultValues( $aParams);
00142
00143 $oArticle = oxNew( "oxarticle" );
00144 $oArticle->loadInLang( $this->_iEditLang, $soxId);
00145
00146 if ( $aParams['oxarticles__oxtprice'] != $oArticle->oxarticles__oxtprice->value && $aParams['oxarticles__oxtprice'] && $aParams['oxarticles__oxtprice'] <= $oArticle->oxarticles__oxprice->value) {
00147 $this->_aViewData["errorsavingtprice"] = 1;
00148 }
00149
00150 $oArticle->setLanguage(0);
00151 $oArticle->assign( $aParams);
00152 $oArticle->setLanguage($this->_iEditLang);
00153 $oArticle = oxRegistry::get("oxUtilsFile")->processFiles( $oArticle );
00154 $oArticle->save();
00155
00156
00157 $sMediaUrl = $this->getConfig()->getRequestParameter( "mediaUrl" );
00158 $sMediaDesc = $this->getConfig()->getRequestParameter( "mediaDesc");
00159
00160 if ( ( $sMediaUrl && $sMediaUrl != 'http://' ) || $aMediaFile['name'] || $sMediaDesc ) {
00161
00162 if ( !$sMediaDesc ) {
00163 return oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'EXCEPTION_NODESCRIPTIONADDED' );
00164 }
00165
00166 if ( ( !$sMediaUrl || $sMediaUrl == 'http://' ) && !$aMediaFile['name'] ) {
00167 return oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'EXCEPTION_NOMEDIAADDED' );
00168 }
00169
00170 $oMediaUrl = oxNew( "oxMediaUrl" );
00171 $oMediaUrl->setLanguage( $this->_iEditLang );
00172 $oMediaUrl->oxmediaurls__oxisuploaded = new oxField( 0, oxField::T_RAW );
00173
00174
00175 if ($aMediaFile['name']) {
00176 try {
00177 $sMediaUrl = oxRegistry::get("oxUtilsFile")->processFile( 'mediaFile', 'out/media/' );
00178 $oMediaUrl->oxmediaurls__oxisuploaded = new oxField(1, oxField::T_RAW);
00179 } catch (Exception $e) {
00180 return oxRegistry::get("oxUtilsView")->addErrorToDisplay( $e->getMessage() );
00181 }
00182 }
00183
00184
00185 $oMediaUrl->oxmediaurls__oxobjectid = new oxField($soxId, oxField::T_RAW);
00186 $oMediaUrl->oxmediaurls__oxurl = new oxField($sMediaUrl, oxField::T_RAW);
00187 $oMediaUrl->oxmediaurls__oxdesc = new oxField($sMediaDesc, oxField::T_RAW);
00188 $oMediaUrl->save();
00189 }
00190
00191
00192 oxNew( "oxArticleList" )->renewPriceUpdateTime();
00193 }
00194
00200 public function deletemedia()
00201 {
00202 $soxId = $this->getEditObjectId();
00203 $sMediaId = $this->getConfig()->getRequestParameter( "mediaid" );
00204 if ($sMediaId && $soxId) {
00205 $oMediaUrl = oxNew("oxMediaUrl");
00206 $oMediaUrl->load($sMediaId);
00207 $oMediaUrl->delete();
00208 }
00209 }
00210
00219 public function addDefaultValues( $aParams)
00220 {
00221 $aParams['oxarticles__oxexturl'] = str_replace( "http://", "", $aParams['oxarticles__oxexturl']);
00222
00223 return $aParams;
00224 }
00225
00231 public function updateMedia()
00232 {
00233 $aMediaUrls = $this->getConfig()->getRequestParameter( 'aMediaUrls' );
00234 if ( is_array( $aMediaUrls ) ) {
00235 foreach ( $aMediaUrls as $sMediaId => $aMediaParams ) {
00236 $oMedia = oxNew("oxMediaUrl");
00237 if ( $oMedia->load( $sMediaId ) ) {
00238 $oMedia->setLanguage(0);
00239 $oMedia->assign( $aMediaParams );
00240 $oMedia->setLanguage( $this->_iEditLang );
00241 $oMedia->save();
00242 }
00243 }
00244 }
00245 }
00246
00252 public function getUnitsArray()
00253 {
00254 if ( $this->_aUnitsArray === null ) {
00255 $this->_aUnitsArray = oxRegistry::getLang()->getSimilarByKey( "_UNIT_", $this->_iEditLang, false );
00256 }
00257 return $this->_aUnitsArray;
00258 }
00259 }