21 $this->
getConfig()->setConfigParam(
'bl_perfLoadPrice',
true );
23 $oArticle =
oxNew(
'oxArticle' );
24 $oArticle->enablePriceLoad();
26 $this->_aViewData[
'edit'] = $oArticle;
29 $sVoxId = $this->
getConfig()->getRequestParameter(
"voxid" );
30 $sOxParentId = $this->
getConfig()->getRequestParameter(
"oxparentid" );
33 if ( isset( $sVoxId ) && $sVoxId ==
"-1" && isset($sOxParentId) && $sOxParentId && $sOxParentId !=
"-1") {
34 $oParentArticle =
oxNew(
"oxArticle");
35 $oParentArticle->load( $sOxParentId);
36 $this->_aViewData[
"parentarticle"] = $oParentArticle;
37 $this->_aViewData[
"oxparentid"] = $sOxParentId;
39 $this->_aViewData[
"oxid"] = $sOxId =
"-1";
42 if ( $sOxId && $sOxId !=
"-1") {
45 $oArticle->loadInLang( $this->_iEditLang, $sOxId );
49 $oOtherLang = $oArticle->getAvailableInLangs();
50 if (!isset($oOtherLang[$this->_iEditLang])) {
52 $oArticle->loadInLang( key($oOtherLang), $sOxId );
56 if ( $oArticle->oxarticles__oxparentid->value) {
57 $oParentArticle =
oxNew(
"oxArticle");
58 $oParentArticle->load( $oArticle->oxarticles__oxparentid->value);
59 $this->_aViewData[
"parentarticle"] = $oParentArticle;
60 $this->_aViewData[
"oxparentid"] = $oArticle->oxarticles__oxparentid->value;
61 $this->_aViewData[
"issubvariant"] = 1;
68 $oArticleTagList =
oxNew(
"oxArticleTagList" );
69 $oArticleTagList->loadInLang( $this->_iEditLang, $oArticle->getId() );
70 $oArticle->tags = $oArticleTagList->get();
74 $this->_aViewData[
"posslang"] =
$aLang;
76 foreach ( $oOtherLang as $id => $language) {
77 $oLang=
new stdClass();
78 $oLang->sLangDesc = $language;
80 $this->_aViewData[
"otherlang"][$id] = clone $oLang;
84 $this->_aViewData[
"editor"] = $this->
_generateTextEditor(
"100%", 300, $oArticle,
"oxarticles__oxlongdesc",
"details.tpl.css");
85 $this->_aViewData[
"blUseTimeCheck"] = $this->
getConfig()->getConfigParam(
'blUseTimeCheck' );
87 return "article_main.tpl";
100 $sEditObjectValue =
'';
102 $oDescField = $oObject->getLongDescription();
107 return $sEditObjectValue;
121 $aParams = $oConfig->getRequestParameter(
"editval" );
127 if (isset($aParams[
'oxarticles__oxvat']) && $aParams[
'oxarticles__oxvat'] ===
'') {
128 $aParams[
'oxarticles__oxvat'] = null;
132 $soxparentId = $oConfig->getRequestParameter(
"oxparentid");
133 if ( isset( $soxparentId) && $soxparentId && $soxparentId !=
"-1") {
134 $aParams[
'oxarticles__oxparentid'] = $soxparentId;
136 unset( $aParams[
'oxarticles__oxparentid']);
139 $oArticle =
oxNew(
"oxarticle");
140 $oArticle->setLanguage($this->_iEditLang);
142 if ( $soxId !=
"-1") {
143 $oArticle->loadInLang( $this->_iEditLang, $soxId);
145 $aParams[
'oxarticles__oxid'] = null;
146 $aParams[
'oxarticles__oxissearch'] = 1;
147 $aParams[
'oxarticles__oxstockflag'] = 1;
148 if ( empty($aParams[
'oxarticles__oxstock']) ) {
149 $aParams[
'oxarticles__oxstock'] = 0;
155 if (!isset($aParams[
'oxarticles__oxactive'])) {
156 $aParams[
'oxarticles__oxactive'] = 0;
161 if ( isset( $aParams[
'oxarticles__oxartnum']) && strlen($aParams[
'oxarticles__oxartnum']) > 0 &&
162 $oConfig->getConfigParam(
'blWarnOnSameArtNums' ) &&
163 $oArticle->oxarticles__oxartnum->value != $aParams[
'oxarticles__oxartnum']
165 $sSelect =
"select oxid from ".getViewName(
'oxarticles' );
166 $sSelect .=
" where oxartnum = '".$aParams[
'oxarticles__oxartnum'].
"'";
167 $sSelect .=
" and oxid != '".$aParams[
'oxarticles__oxid'].
"'";
168 if ($oArticle->assignRecord( $sSelect ))
169 $this->_aViewData[
"errorsavingatricle"] = 1;
174 if ( isset($aParams[
"oxarticles__oxprice"]) && $aParams[
"oxarticles__oxprice"] != $oArticle->oxarticles__oxprice->value) {
175 $this->
resetCounter(
"priceCatArticle", $oArticle->oxarticles__oxprice->value );
178 $aResetIds = array();
179 if ( isset($aParams[
'oxarticles__oxactive']) && $aParams[
'oxarticles__oxactive'] != $oArticle->oxarticles__oxactive->value) {
184 $aResetIds[
'vendor'][$oArticle->oxarticles__oxvendorid->value] = 1;
185 $aResetIds[
'manufacturer'][$oArticle->oxarticles__oxmanufacturerid->value] = 1;
189 if ( isset($aParams[
'oxarticles__oxvendorid']) && $aParams[
'oxarticles__oxvendorid'] != $oArticle->oxarticles__oxvendorid->value) {
190 $aResetIds[
'vendor'][$aParams[
'oxarticles__oxvendorid']] = 1;
191 $aResetIds[
'vendor'][$oArticle->oxarticles__oxvendorid->value] = 1;
195 if ( isset($aParams[
'oxarticles__oxmanufacturerid']) && $aParams[
'oxarticles__oxmanufacturerid'] != $oArticle->oxarticles__oxmanufacturerid->value ) {
196 $aResetIds[
'manufacturer'][$aParams[
'oxarticles__oxmanufacturerid']] = 1;
197 $aResetIds[
'manufacturer'][$oArticle->oxarticles__oxmanufacturerid->value] = 1;
203 $oArticle->setLanguage(0);
206 if (isset($aParams[
'oxarticles__oxtitle'])) {
207 $aParams[
'oxarticles__oxtitle'] = trim( $aParams[
'oxarticles__oxtitle'] );
210 $oArticle->assign( $aParams );
211 $oArticle->setArticleLongDesc( $this->
_processLongDesc( $aParams[
'oxarticles__oxlongdesc'] ) );
212 $oArticle->setLanguage($this->_iEditLang);
217 if ( $soxId ==
"-1") {
218 $sFastCat = $oConfig->getRequestParameter(
"art_category");
219 if ( $sFastCat !=
"-1") {
225 if (isset($aParams[
'tags'])) {
226 $sTags = $aParams[
'tags'];
228 $sTags = $oArticle->oxarticles__oxsearchkeys->value;
230 $aInvalidTags = $this->
_setTags( $sTags, $oArticle->getId() );
231 if ( !empty( $aInvalidTags ) ) {
232 $this->_aViewData[
"invalid_tags"] = implode(
', ', $aInvalidTags );
250 $sValue = str_replace(
' ',
' ', $sValue );
251 $sValue = str_replace(
'&',
'&', $sValue );
252 $sValue = str_replace(
'"',
'"', $sValue );
253 $sValue = str_replace(
'&lang=',
'&lang=', $sValue);
254 $sValue = str_replace(
'<p> </p>',
'', $sValue);
255 $sValue = str_replace(
'<p> </p>',
'', $sValue);
270 $sQ =
"select oxcatnid from oxobject2category where oxobjectid = ".$oDb->quote( $sArticleId );
271 $oRs = $oDb->execute($sQ);
272 if ( $oRs !==
false && $oRs->recordCount() > 0 ) {
290 $oArticleTagList =
oxNew(
'oxarticletaglist');
291 $oArticleTagList->loadInLang( $this->_iEditLang, $sArticleId );
292 $oArticleTagList->set( $sTags );
293 $oArticleTagList->save();
295 return $oArticleTagList->get()->getInvalidTags();
310 $oNew =
oxNew(
"oxbase");
311 $oNew->init(
"oxobject2category" );
312 $oNew->oxobject2category__oxtime =
new oxField( 0 );
313 $oNew->oxobject2category__oxobjectid =
new oxField( $sOXID );
314 $oNew->oxobject2category__oxcatnid =
new oxField( $sCatID );
331 public function copyArticle( $sOldId = null, $sNewId = null, $sParentId = null )
338 $oArticle =
oxNew(
'oxbase' );
339 $oArticle->init(
'oxarticles' );
340 if ( $oArticle->load( $sOldId ) ) {
342 if (
$myConfig->getConfigParam(
'blDisableDublArtOnCopy' ) ) {
343 $oArticle->oxarticles__oxactive->setValue( 0 );
344 $oArticle->oxarticles__oxactivefrom->setValue( 0 );
345 $oArticle->oxarticles__oxactiveto->setValue( 0 );
350 $oArticle->oxarticles__oxparentid->setValue( $sParentId );
354 $iNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime() );
355 $oArticle->oxarticles__oxinsert =
new oxField( $iNow );
358 $oArticle->oxarticles__oxrating =
new oxField( 0 );
359 $oArticle->oxarticles__oxratingcnt =
new oxField( 0 );
361 $oArticle->setId( $sNewId );
389 $aResetIds[
'vendor'][$oArticle->oxarticles__oxvendorid->value] = 1;
390 $aResetIds[
'manufacturer'][$oArticle->oxarticles__oxmanufacturerid->value] = 1;
398 $sQ =
"select oxid from oxarticles where oxparentid = ".$oDb->quote( $sOldId );
399 $oRs = $oDb->execute( $sQ );
400 if ( $oRs !==
false && $oRs->recordCount() > 0) {
401 while ( !$oRs->EOF ) {
402 $this->
copyArticle( $oRs->fields[0], $myUtilsObject->generateUid(), $sNewId );
413 if (
$myConfig->getConfigParam(
'blWarnOnSameArtNums' ) &&
415 $sSelect =
"select oxid from ".$oArticle->getCoreTableName().
"
416 where oxartnum = ".$oDb->quote( $oArticle->oxarticles__oxartnum->value ).
" and oxid != ".$oDb->quote( $sNewId );
418 if ( $oArticle->assignRecord( $sSelect ) ) {
419 $this->_aViewData[
"errorsavingatricle"] = 1;
441 $sO2CView = getViewName(
'oxobject2category' );
442 $sQ =
"select oxcatnid, oxtime from {$sO2CView} where oxobjectid = ".$oDb->quote( $sOldId );
443 $oRs = $oDb->execute( $sQ );
444 if ( $oRs !==
false && $oRs->recordCount() > 0 ) {
445 while ( !$oRs->EOF ) {
446 $sUid = $myUtilsObject->generateUid();
447 $sCatId = $oRs->fields[0];
448 $sTime = $oRs->fields[1];
451 $oDb->execute(
"insert into oxobject2category (oxid, oxobjectid, oxcatnid, oxtime) VALUES (".$oDb->quote( $sUid ).
", ".$oDb->quote( $sNewId ).
", ".$oDb->quote( $sCatId ).
", ".$oDb->quote( $sTime ).
") ");
474 $sQ =
"select oxid from oxobject2attribute where oxobjectid = ".$oDb->quote( $sOldId );
475 $oRs = $oDb->execute($sQ);
476 if ( $oRs !==
false && $oRs->recordCount() > 0 ) {
477 while ( !$oRs->EOF ) {
479 $oAttr =
oxNew(
"oxbase" );
480 $oAttr->init(
"oxobject2attribute" );
481 $oAttr->load( $oRs->fields[0] );
482 $oAttr->setId( $myUtilsObject->generateUID() );
483 $oAttr->oxobject2attribute__oxobjectid->setValue( $sNewId );
503 $sQ =
"SELECT * FROM `oxfiles` WHERE `oxartid` = ".$oDb->quote( $sOldId );
504 $oRs = $oDb->execute($sQ);
505 if ( $oRs !==
false && $oRs->recordCount() > 0 ) {
506 while ( !$oRs->EOF ) {
508 $oFile =
oxNew(
"oxfile" );
509 $oFile->setId( $myUtilsObject->generateUID() );
510 $oFile->oxfiles__oxartid =
new oxField( $sNewId );
511 $oFile->oxfiles__oxfilename =
new oxField( $oRs->fields[
'OXFILENAME'] );
512 $oFile->oxfiles__oxfilesize =
new oxField( $oRs->fields[
'OXFILESIZE'] );
513 $oFile->oxfiles__oxstorehash =
new oxField( $oRs->fields[
'OXSTOREHASH'] );
514 $oFile->oxfiles__oxpurchasedonly =
new oxField( $oRs->fields[
'OXPURCHASEDONLY'] );
534 $sQ =
"select oxselnid from oxobject2selectlist where oxobjectid = ".$oDb->quote( $sOldId );
535 $oRs = $oDb->execute( $sQ );
536 if ( $oRs !==
false && $oRs->recordCount() > 0 ) {
537 while ( !$oRs->EOF ) {
538 $sUid = $myUtilsObject->generateUID();
539 $sId = $oRs->fields[0];
540 $oDb->execute(
"insert into oxobject2selectlist (oxid, oxobjectid, oxselnid) VALUES (".$oDb->quote( $sUid ).
", ".$oDb->quote( $sNewId ).
", ".$oDb->quote( $sId ).
") " );
559 $sQ =
"select oxobjectid from oxobject2article where oxarticlenid = ".$oDb->quote( $sOldId );
560 $oRs = $oDb->execute( $sQ );
561 if ( $oRs !==
false && $oRs->recordCount() > 0 ) {
562 while ( !$oRs->EOF ) {
563 $sUid = $myUtilsObject->generateUID();
564 $sId = $oRs->fields[0];
565 $oDb->execute(
"insert into oxobject2article (oxid, oxobjectid, oxarticlenid) VALUES (".$oDb->quote( $sUid ).
", ".$oDb->quote( $sId ).
", ".$oDb->quote( $sNewId ).
" ) ");
584 $sQ =
"select oxobjectid from oxaccessoire2article where oxarticlenid= ".$oDb->quote( $sOldId );
585 $oRs = $oDb->execute( $sQ );
586 if ( $oRs !==
false && $oRs->recordCount() > 0 ) {
587 while ( !$oRs->EOF ) {
588 $sUId = $myUtilsObject->generateUid();
589 $sId = $oRs->fields[0];
590 $oDb->execute(
"insert into oxaccessoire2article (oxid, oxobjectid, oxarticlenid) VALUES (".$oDb->quote( $sUId ).
", ".$oDb->quote( $sId ).
", ".$oDb->quote( $sNewId ).
") " );
606 $sShopId = $this->
getConfig()->getShopId();
607 $oPriceList =
oxNew(
"oxlist" );
608 $oPriceList->init(
"oxbase",
"oxprice2article" );
609 $sQ =
"select * from oxprice2article where oxartid = '$sOldId' and oxshopid = '$sShopId' and (oxamount > 0 or oxamountto > 0) order by oxamount ";
610 $oPriceList->selectString( $sQ );
611 if ( $oPriceList->count() ) {
612 foreach ( $oPriceList as $oItem ) {
613 $oItem->oxprice2article__oxid->setValue( $oItem->setId() );
614 $oItem->oxprice2article__oxartid->setValue( $sNewId );
630 $oExt =
oxNew(
"oxbase");
631 $oExt->init(
"oxartextends" );
632 $oExt->load( $sOldId );
633 $oExt->setId( $sNewId );
671 $aJumpList = array();
673 if ( isset( $oParentArticle ) ) {
674 $aJumpList[] = array( $oParentArticle->oxarticles__oxid->value, $this->_getTitle( $oParentArticle ) );
676 if ( $oParentVariants->count()) {
677 foreach ( $oParentVariants as $oVar) {
678 $aJumpList[] = array( $oVar->oxarticles__oxid->value,
" - ".$this->_getTitle( $oVar ) );
679 if ( $oVar->oxarticles__oxid->value == $oArticle->oxarticles__oxid->value ) {
681 if ( $oVariants->count() ) {
682 foreach ( $oVariants as $oVVar) {
683 $aJumpList[] = array( $oVVar->oxarticles__oxid->value,
" -- ".$this->_getTitle( $oVVar));
690 $aJumpList[] = array( $oArticle->oxarticles__oxid->value, $this->_getTitle( $oArticle));
693 if ( $oVariants && $oVariants->count())
694 foreach ($oVariants as $oVar) {
695 $aJumpList[] = array( $oVar->oxarticles__oxid->value,
" - ".$this->_getTitle( $oVar));
698 if ( count($aJumpList) > 1)
699 $this->_aViewData[
"thisvariantlist"] = $aJumpList;
711 $sTitle = $oObj->oxarticles__oxtitle->value;
712 if ( !strlen( $sTitle ) ) {
713 $sTitle = $oObj->oxarticles__oxvarselect->value;
726 $oCatTree =
oxNew(
"oxCategoryList");
727 $oCatTree->loadList();
738 $oVendorlist =
oxNew(
"oxvendorlist" );
739 $oVendorlist->loadVendorList();
751 $oManufacturerList =
oxNew(
"oxmanufacturerlist" );
752 $oManufacturerList->loadManufacturerList();
754 return $oManufacturerList;