22         $this->
getConfig()->setConfigParam(
'bl_perfLoadPrice', 
true);
 
   24         $oArticle = 
oxNew(
'oxArticle');
 
   25         $oArticle->enablePriceLoad();
 
   27         $this->_aViewData[
'edit'] = $oArticle;
 
   30         $sVoxId = $this->
getConfig()->getRequestParameter(
"voxid");
 
   31         $sOxParentId = $this->
getConfig()->getRequestParameter(
"oxparentid");
 
   34         if (isset($sVoxId) && $sVoxId == 
"-1" && isset($sOxParentId) && $sOxParentId && $sOxParentId != 
"-1") {
 
   35             $oParentArticle = 
oxNew(
"oxArticle");
 
   36             $oParentArticle->load($sOxParentId);
 
   37             $this->_aViewData[
"parentarticle"] = $oParentArticle;
 
   38             $this->_aViewData[
"oxparentid"] = $sOxParentId;
 
   40             $this->_aViewData[
"oxid"] = $sOxId = 
"-1";
 
   43         if ($sOxId && $sOxId != 
"-1") {
 
   46             $oArticle->loadInLang($this->_iEditLang, $sOxId);
 
   50             $oOtherLang = $oArticle->getAvailableInLangs();
 
   51             if (!isset($oOtherLang[$this->_iEditLang])) {
 
   53                 $oArticle->loadInLang(key($oOtherLang), $sOxId);
 
   57             if ($oArticle->oxarticles__oxparentid->value) {
 
   58                 $oParentArticle = 
oxNew(
"oxArticle");
 
   59                 $oParentArticle->load($oArticle->oxarticles__oxparentid->value);
 
   60                 $this->_aViewData[
"parentarticle"] = $oParentArticle;
 
   61                 $this->_aViewData[
"oxparentid"] = $oArticle->oxarticles__oxparentid->value;
 
   62                 $this->_aViewData[
"issubvariant"] = 1;
 
   70             $oArticleTagList = 
oxNew(
"oxArticleTagList");
 
   71             $oArticleTagList->loadInLang($this->_iEditLang, $oArticle->getId());
 
   72             $oArticle->tags = $oArticleTagList->get();
 
   77                 $this->_aViewData[
"posslang"] = 
$aLang;
 
   80             foreach ($oOtherLang as $id => $language) {
 
   81                 $oLang = 
new stdClass();
 
   82                 $oLang->sLangDesc = $language;
 
   84                 $this->_aViewData[
"otherlang"][$id] = clone $oLang;
 
   92             "oxarticles__oxlongdesc",
 
   95         $this->_aViewData[
"blUseTimeCheck"] = $this->
getConfig()->getConfigParam(
'blUseTimeCheck');
 
   97         return "article_main.tpl";
 
  110         $sEditObjectValue = 
'';
 
  112             $oDescField = $oObject->getLongDescription();
 
  117         return $sEditObjectValue;
 
  129         $aParams = $oConfig->getRequestParameter(
"editval");
 
  135         if (isset($aParams[
'oxarticles__oxvat']) && $aParams[
'oxarticles__oxvat'] === 
'') {
 
  136             $aParams[
'oxarticles__oxvat'] = null;
 
  140         $soxparentId = $oConfig->getRequestParameter(
"oxparentid");
 
  141         if (isset($soxparentId) && $soxparentId && $soxparentId != 
"-1") {
 
  142             $aParams[
'oxarticles__oxparentid'] = $soxparentId;
 
  144             unset($aParams[
'oxarticles__oxparentid']);
 
  147         $oArticle = 
oxNew(
"oxarticle");
 
  148         $oArticle->setLanguage($this->_iEditLang);
 
  150         if ($soxId != 
"-1") {
 
  151             $oArticle->loadInLang($this->_iEditLang, $soxId);
 
  153             $aParams[
'oxarticles__oxid'] = null;
 
  154             $aParams[
'oxarticles__oxissearch'] = 1;
 
  155             $aParams[
'oxarticles__oxstockflag'] = 1;
 
  156             if (empty($aParams[
'oxarticles__oxstock'])) {
 
  157                 $aParams[
'oxarticles__oxstock'] = 0;
 
  163             if (!isset($aParams[
'oxarticles__oxactive'])) {
 
  164                 $aParams[
'oxarticles__oxactive'] = 0;
 
  169         if (isset($aParams[
'oxarticles__oxartnum']) && strlen($aParams[
'oxarticles__oxartnum']) > 0 &&
 
  170             $oConfig->getConfigParam(
'blWarnOnSameArtNums') &&
 
  171             $oArticle->oxarticles__oxartnum->value != $aParams[
'oxarticles__oxartnum']
 
  173             $sSelect = 
"select oxid from " . getViewName(
'oxarticles');
 
  174             $sSelect .= 
" where oxartnum = '" . $aParams[
'oxarticles__oxartnum'] . 
"'";
 
  175             $sSelect .= 
" and oxid != '" . $aParams[
'oxarticles__oxid'] . 
"'";
 
  176             if ($oArticle->assignRecord($sSelect)) {
 
  177                 $this->_aViewData[
"errorsavingatricle"] = 1;
 
  183         $sOxIdField = 
'oxarticles__oxid';
 
  184         $sPriceField = 
'oxarticles__oxprice';
 
  185         $sActiveField = 
'oxarticles__oxactive';
 
  186         $sVendorField = 
'oxarticles__oxvendorid';
 
  187         $sManufacturerField = 
'oxarticles__oxmanufacturerid';
 
  188         if (isset($aParams[$sPriceField]) && $aParams[$sPriceField] != $oArticle->$sPriceField->value) {
 
  189             $this->
resetCounter(
"priceCatArticle", $oArticle->$sPriceField->value);
 
  192         $aResetIds = array();
 
  193         if (isset($aParams[$sActiveField]) && $aParams[$sActiveField] != $oArticle->$sActiveField->value) {
 
  198             $aResetIds[
'vendor'][$oArticle->$sVendorField->value] = 1;
 
  199             $aResetIds[
'manufacturer'][$oArticle->$sManufacturerField->value] = 1;
 
  203         if (isset($aParams[$sVendorField]) && $aParams[$sVendorField] != $oArticle->$sVendorField->value) {
 
  204             $aResetIds[
'vendor'][$aParams[$sVendorField]] = 1;
 
  205             $aResetIds[
'vendor'][$oArticle->$sVendorField->value] = 1;
 
  209         if (isset($aParams[$sManufacturerField]) &&
 
  210             $aParams[$sManufacturerField] != $oArticle->$sManufacturerField->value) {
 
  212             $aResetIds[
'manufacturer'][$aParams[$sManufacturerField]] = 1;
 
  213             $aResetIds[
'manufacturer'][$oArticle->$sManufacturerField->value] = 1;
 
  219         $oArticle->setLanguage(0);
 
  222         if (isset($aParams[
'oxarticles__oxtitle'])) {
 
  223             $aParams[
'oxarticles__oxtitle'] = trim($aParams[
'oxarticles__oxtitle']);
 
  226         $oArticle->assign($aParams);
 
  227         $oArticle->setArticleLongDesc($this->
_processLongDesc($aParams[
'oxarticles__oxlongdesc']));
 
  228         $oArticle->setLanguage($this->_iEditLang);
 
  233         if ($soxId == 
"-1") {
 
  234             $sFastCat = $oConfig->getRequestParameter(
"art_category");
 
  235             if ($sFastCat != 
"-1") {
 
  242         if (isset($aParams[
'tags'])) {
 
  243             $sTags = $aParams[
'tags'];
 
  245                 $sTags = $oArticle->oxarticles__oxsearchkeys->value;
 
  247             $aInvalidTags = $this->
_setTags($sTags, $oArticle->getId());
 
  248             if (!empty($aInvalidTags)) {
 
  249                 $this->_aViewData[
"invalid_tags"] = implode(
', ', $aInvalidTags);
 
  268         $sValue = str_replace(
' ', 
' ', $sValue);
 
  269         $sValue = str_replace(
'&', 
'&', $sValue);
 
  270         $sValue = str_replace(
'"', 
'"', $sValue);
 
  271         $sValue = str_replace(
'&lang=', 
'&lang=', $sValue);
 
  272         $sValue = str_replace(
'<p> </p>', 
'', $sValue);
 
  273         $sValue = str_replace(
'<p>  </p>', 
'', $sValue);
 
  286         $sQ = 
"select oxcatnid from oxobject2category where oxobjectid = " . $oDb->quote($sArticleId);
 
  287         $oRs = $oDb->execute($sQ);
 
  288         if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  308         $oArticleTagList = 
oxNew(
'oxarticletaglist');
 
  309         $oArticleTagList->loadInLang($this->_iEditLang, $sArticleId);
 
  310         $oArticleTagList->set($sTags);
 
  311         $oArticleTagList->save();
 
  313         return $oArticleTagList->get()->getInvalidTags();
 
  326         $oNew = 
oxNew(
"oxbase");
 
  327         $oNew->init(
"oxobject2category");
 
  328         $oNew->oxobject2category__oxtime = 
new oxField(0);
 
  329         $oNew->oxobject2category__oxobjectid = 
new oxField($sOXID);
 
  330         $oNew->oxobject2category__oxcatnid = 
new oxField($sCatID);
 
  345     public function copyArticle($sOldId = null, $sNewId = null, $sParentId = null)
 
  352         $oArticle = 
oxNew(
'oxbase');
 
  353         $oArticle->init(
'oxarticles');
 
  354         if ($oArticle->load($sOldId)) {
 
  356             if (
$myConfig->getConfigParam(
'blDisableDublArtOnCopy')) {
 
  357                 $oArticle->oxarticles__oxactive->setValue(0);
 
  358                 $oArticle->oxarticles__oxactivefrom->setValue(0);
 
  359                 $oArticle->oxarticles__oxactiveto->setValue(0);
 
  364                 $oArticle->oxarticles__oxparentid->setValue($sParentId);
 
  368             $iNow = date(
'Y-m-d H:i:s', 
oxRegistry::get(
"oxUtilsDate")->getTime());
 
  369             $oArticle->oxarticles__oxinsert = 
new oxField($iNow);
 
  372             $oArticle->oxarticles__oxrating = 
new oxField(0);
 
  373             $oArticle->oxarticles__oxratingcnt = 
new oxField(0);
 
  375             $oArticle->setId($sNewId);
 
  403             $aResetIds[
'vendor'][$oArticle->oxarticles__oxvendorid->value] = 1;
 
  404             $aResetIds[
'manufacturer'][$oArticle->oxarticles__oxmanufacturerid->value] = 1;
 
  413             $sQ = 
"select oxid from oxarticles where oxparentid = " . $oDb->quote($sOldId);
 
  414             $oRs = $oDb->execute($sQ);
 
  415             if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  417                     $this->
copyArticle($oRs->fields[0], $myUtilsObject->generateUid(), $sNewId);
 
  429                 $sArtNumField = 
'oxarticles__oxartnum';
 
  430                 if (
$myConfig->getConfigParam(
'blWarnOnSameArtNums') &&
 
  431                     $oArticle->$sArtNumField->value && $sFncParameter == 
'copyArticle' 
  433                     $sSelect = 
"select oxid from " . $oArticle->getCoreTableName() .
 
  434                                " where oxartnum = " . $oDb->quote($oArticle->$sArtNumField->value) .
 
  435                                " and oxid != " . $oDb->quote($sNewId);
 
  437                     if ($oArticle->assignRecord($sSelect)) {
 
  438                         $this->_aViewData[
"errorsavingatricle"] = 1;
 
  456         $sO2CView = getViewName(
'oxobject2category');
 
  457         $sQ = 
"select oxcatnid, oxtime from {$sO2CView} where oxobjectid = " . $oDb->quote($sOldId);
 
  458         $oRs = $oDb->execute($sQ);
 
  459         if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  461                 $sUid = $myUtilsObject->generateUid();
 
  462                 $sCatId = $oRs->fields[0];
 
  463                 $sTime = $oRs->fields[1];
 
  466                 $sSql = 
"insert into oxobject2category (oxid, oxobjectid, oxcatnid, oxtime) " .
 
  467                         "VALUES (" . $oDb->quote($sUid) . 
", " . $oDb->quote($sNewId) . 
", " .
 
  468                         $oDb->quote($sCatId) . 
", " . $oDb->quote($sTime) . 
") ";
 
  469                 $oDb->execute($sSql);
 
  490         $sQ = 
"select oxid from oxobject2attribute where oxobjectid = " . $oDb->quote($sOldId);
 
  491         $oRs = $oDb->execute($sQ);
 
  492         if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  495                 $oAttr = 
oxNew(
"oxbase");
 
  496                 $oAttr->init(
"oxobject2attribute");
 
  497                 $oAttr->load($oRs->fields[0]);
 
  498                 $oAttr->setId($myUtilsObject->generateUID());
 
  499                 $oAttr->oxobject2attribute__oxobjectid->setValue($sNewId);
 
  517         $sQ = 
"SELECT * FROM `oxfiles` WHERE `oxartid` = " . $oDb->quote($sOldId);
 
  518         $oRs = $oDb->execute($sQ);
 
  519         if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  522                 $oFile = 
oxNew(
"oxfile");
 
  523                 $oFile->setId($myUtilsObject->generateUID());
 
  524                 $oFile->oxfiles__oxartid = 
new oxField($sNewId);
 
  525                 $oFile->oxfiles__oxfilename = 
new oxField($oRs->fields[
'OXFILENAME']);
 
  526                 $oFile->oxfiles__oxfilesize = 
new oxField($oRs->fields[
'OXFILESIZE']);
 
  527                 $oFile->oxfiles__oxstorehash = 
new oxField($oRs->fields[
'OXSTOREHASH']);
 
  528                 $oFile->oxfiles__oxpurchasedonly = 
new oxField($oRs->fields[
'OXPURCHASEDONLY']);
 
  546         $sQ = 
"select oxselnid from oxobject2selectlist where oxobjectid = " . $oDb->quote($sOldId);
 
  547         $oRs = $oDb->execute($sQ);
 
  548         if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  550                 $sUid = $myUtilsObject->generateUID();
 
  551                 $sId = $oRs->fields[0];
 
  552                 $sSql = 
"insert into oxobject2selectlist (oxid, oxobjectid, oxselnid) " .
 
  553                         "VALUES (" . $oDb->quote($sUid) . 
", " . $oDb->quote($sNewId) . 
", " . $oDb->quote($sId) . 
") ";
 
  554                 $oDb->execute($sSql);
 
  571         $sQ = 
"select oxobjectid from oxobject2article where oxarticlenid = " . $oDb->quote($sOldId);
 
  572         $oRs = $oDb->execute($sQ);
 
  573         if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  575                 $sUid = $myUtilsObject->generateUID();
 
  576                 $sId = $oRs->fields[0];
 
  577                 $sSql = 
"insert into oxobject2article (oxid, oxobjectid, oxarticlenid) " .
 
  578                        "VALUES (" . $oDb->quote($sUid) . 
", " . $oDb->quote($sId) . 
", " . $oDb->quote($sNewId) . 
" ) ";
 
  579                 $oDb->execute($sSql);
 
  596         $sQ = 
"select oxobjectid from oxaccessoire2article where oxarticlenid= " . $oDb->quote($sOldId);
 
  597         $oRs = $oDb->execute($sQ);
 
  598         if ($oRs !== 
false && $oRs->recordCount() > 0) {
 
  600                 $sUId = $myUtilsObject->generateUid();
 
  601                 $sId = $oRs->fields[0];
 
  602                 $sSql = 
"insert into oxaccessoire2article (oxid, oxobjectid, oxarticlenid) " .
 
  603                         "VALUES (" . $oDb->quote($sUId) . 
", " . $oDb->quote($sId) . 
", " . $oDb->quote($sNewId) . 
") ";
 
  604                 $oDb->execute($sSql);
 
  618         $sShopId = $this->
getConfig()->getShopId();
 
  619         $oPriceList = 
oxNew(
"oxlist");
 
  620         $oPriceList->init(
"oxbase", 
"oxprice2article");
 
  621         $sQ = 
"select * from oxprice2article where oxartid = '{$sOldId}' and oxshopid = '{$sShopId}' " .
 
  622               "and (oxamount > 0 or oxamountto > 0) order by oxamount ";
 
  623         $oPriceList->selectString($sQ);
 
  624         if ($oPriceList->count()) {
 
  625             foreach ($oPriceList as $oItem) {
 
  626                 $oItem->oxprice2article__oxid->setValue($oItem->setId());
 
  627                 $oItem->oxprice2article__oxartid->setValue($sNewId);
 
  641         $oExt = 
oxNew(
"oxbase");
 
  642         $oExt->init(
"oxartextends");
 
  643         $oExt->load($sOldId);
 
  644         $oExt->setId($sNewId);
 
  678         $aJumpList = array();
 
  680         $sOxIdField = 
'oxarticles__oxid';
 
  681         if (isset($oParentArticle)) {
 
  682             $aJumpList[] = array($oParentArticle->$sOxIdField->value, $this->_getTitle($oParentArticle));
 
  684             $oParentVariants = $oParentArticle->getAdminVariants($sEditLanguageParameter);
 
  685             if ($oParentVariants->count()) {
 
  686                 foreach ($oParentVariants as $oVar) {
 
  687                     $aJumpList[] = array($oVar->$sOxIdField->value, 
" - " . $this->_getTitle($oVar));
 
  688                     if ($oVar->$sOxIdField->value == $oArticle->$sOxIdField->value) {
 
  689                         $oVariants = $oArticle->getAdminVariants($sEditLanguageParameter);
 
  690                         if ($oVariants->count()) {
 
  691                             foreach ($oVariants as $oVVar) {
 
  692                                 $aJumpList[] = array($oVVar->$sOxIdField->value, 
" -- " . $this->_getTitle($oVVar));
 
  699             $aJumpList[] = array($oArticle->$sOxIdField->value, $this->_getTitle($oArticle));
 
  701             $oVariants = $oArticle->getAdminVariants(
oxRegistry::getConfig()->getRequestParameter(
"editlanguage"));
 
  702             if ($oVariants && $oVariants->count()) {
 
  703                 foreach ($oVariants as $oVar) {
 
  704                     $aJumpList[] = array($oVar->$sOxIdField->value, 
" - " . $this->_getTitle($oVar));
 
  708         if (count($aJumpList) > 1) {
 
  709             $this->_aViewData[
"thisvariantlist"] = $aJumpList;
 
  722         $sTitle = $oObj->oxarticles__oxtitle->value;
 
  723         if (!strlen($sTitle)) {
 
  724             $sTitle = $oObj->oxarticles__oxvarselect->value;
 
  737         $oCatTree = 
oxNew(
"oxCategoryList");
 
  738         $oCatTree->loadList();
 
  750         $oVendorlist = 
oxNew(
"oxvendorlist");
 
  751         $oVendorlist->loadVendorList();
 
  763         $oManufacturerList = 
oxNew(
"oxmanufacturerlist");
 
  764         $oManufacturerList->loadManufacturerList();
 
  766         return $oManufacturerList;