Exemplo n.º 1
0
 /**
  * Returns image utils instance
  *
  * @return oxUtilsPic
  */
 public static function getInstance()
 {
     // disable caching for test modules
     if (defined('OXID_PHP_UNIT')) {
         self::$_instance = modInstances::getMod(__CLASS__);
     }
     if (!self::$_instance instanceof oxUtilsPic) {
         self::$_instance = oxNew('oxUtilsPic');
         if (defined('OXID_PHP_UNIT')) {
             modInstances::addMod(__CLASS__, self::$_instance);
         }
     }
     return self::$_instance;
 }
 /**
  * Saves article category data.
  *
  * @return mixed
  */
 public function save()
 {
     parent::save();
     $myConfig = $this->getConfig();
     $soxId = $this->getEditObjectId();
     $aParams = oxConfig::getParameter("editval");
     // checkbox handling
     if (!isset($aParams['oxcategories__oxactive'])) {
         $aParams['oxcategories__oxactive'] = 0;
     }
     if (!isset($aParams['oxcategories__oxhidden'])) {
         $aParams['oxcategories__oxhidden'] = 0;
     }
     if (!isset($aParams['oxcategories__oxdefsortmode'])) {
         $aParams['oxcategories__oxdefsortmode'] = 0;
     }
     // null values
     if ($aParams['oxcategories__oxvat'] === '') {
         $aParams['oxcategories__oxvat'] = null;
     }
     // shopid
     $aParams['oxcategories__oxshopid'] = oxSession::getVar("actshop");
     $oCategory = oxNew("oxcategory");
     if ($soxId != "-1") {
         $this->resetCounter("catArticle", $soxId);
         $oCategory->load($soxId);
         $oCategory->loadInLang($this->_iEditLang, $soxId);
         $myUtilsPic = oxUtilsPic::getInstance();
         // #1173M - not all pic are deleted, after article is removed
         $myUtilsPic->overwritePic($oCategory, 'oxcategories', 'oxthumb', 'TC', '0', $aParams, $myConfig->getPictureDir(false));
         $myUtilsPic->overwritePic($oCategory, 'oxcategories', 'oxicon', 'CICO', 'icon', $aParams, $myConfig->getPictureDir(false));
         $myUtilsPic->overwritePic($oCategory, 'oxcategories', 'oxpromoicon', 'PICO', 'icon', $aParams, $myConfig->getPictureDir(false));
     } else {
         //#550A - if new category is made then is must be default activ
         //#4051: Impossible to create inactive category
         //$aParams['oxcategories__oxactive'] = 1;
         $aParams['oxcategories__oxid'] = null;
     }
     $oCategory->setLanguage(0);
     if (isset($aParams["oxcategories__oxlongdesc"])) {
         $aParams["oxcategories__oxlongdesc"] = $this->_processLongDesc($aParams["oxcategories__oxlongdesc"]);
     }
     $oCategory->assign($aParams);
     $oCategory->setLanguage($this->_iEditLang);
     $oCategory = oxUtilsFile::getInstance()->processFiles($oCategory);
     $oCategory->save();
     $this->setEditObjectId($oCategory->getId());
 }
 /**
  * Saves Promotions
  *
  * @return mixed
  */
 public function save()
 {
     $myConfig = $this->getConfig();
     parent::save();
     $soxId = $this->getEditObjectId();
     $aParams = oxConfig::getParameter("editval");
     $oPromotion = oxNew("oxactions");
     if ($soxId != "-1") {
         $oPromotion->load($soxId);
         oxUtilsPic::getInstance()->overwritePic($oPromotion, 'oxactions', 'oxpic', 'PROMO', oxUtilsFile::PROMO_PICTURE_DIR, $aParams, $myConfig->getPictureDir(false));
     } else {
         $aParams['oxactions__oxid'] = null;
     }
     if (!$aParams['oxactions__oxactive']) {
         $aParams['oxactions__oxactive'] = 0;
     }
     $oPromotion->setLanguage(0);
     $oPromotion->assign($aParams);
     $oPromotion->setLanguage($this->_iEditLang);
     $oPromotion = oxUtilsFile::getInstance()->processFiles($oPromotion);
     $oPromotion->save();
     // set oxid if inserted
     $this->setEditObjectId($oPromotion->getId());
 }
Exemplo n.º 4
0
 /**
  * Delete empty categories, returns true on success.
  *
  * @param string $sOXID Object ID
  *
  * @return bool
  */
 public function delete($sOXID = null)
 {
     if (!$this->getId()) {
         $this->load($sOXID);
     }
     $sOXID = isset($sOXID) ? $sOXID : $this->getId();
     $myConfig = $this->getConfig();
     $oDB = oxDb::getDb();
     $blRet = false;
     if ($this->oxcategories__oxright->value == $this->oxcategories__oxleft->value + 1) {
         $myUtilsPic = oxUtilsPic::getInstance();
         $sDir = $myConfig->getPictureDir(false);
         // only delete empty categories
         // #1173M - not all pic are deleted, after article is removed
         $myUtilsPic->safePictureDelete($this->oxcategories__oxthumb->value, $sDir . '/master/thumb', 'oxcategories', 'oxthumb');
         $myUtilsPic->safePictureDelete($this->oxcategories__oxicon->value, $sDir . '/master/icon', 'oxcategories', 'oxicon');
         $myUtilsPic->safePictureDelete($this->oxcategories__oxpromoicon->value, $sDir . '/master/promo_icon', 'oxcategories', 'oxpromoicon');
         $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
         $oDB->execute("UPDATE oxcategories SET OXLEFT = OXLEFT - 2\n                            WHERE  OXROOTID = " . $oDB->quote($this->oxcategories__oxrootid->value) . "\n                            AND OXLEFT >   " . (int) $this->oxcategories__oxleft->value . $sAdd);
         $oDB->execute("UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2\n                            WHERE  OXROOTID = " . $oDB->quote($this->oxcategories__oxrootid->value) . "\n                            AND OXRIGHT >   " . (int) $this->oxcategories__oxright->value . $sAdd);
         // delete entry
         $blRet = parent::delete($sOXID);
         $sOxidQuoted = $oDB->quote($sOXID);
         // delete links to articles
         $oDB->execute("delete from oxobject2category where oxobject2category.oxcatnid={$sOxidQuoted} ");
         // #657 ADDITIONAL delete links to attributes
         $oDB->execute("delete from oxcategory2attribute where oxcategory2attribute.oxobjectid={$sOxidQuoted} ");
         // A. removing assigned:
         // - deliveries
         $oDB->execute("delete from oxobject2delivery where oxobject2delivery.oxobjectid={$sOxidQuoted} ");
         // - discounts
         $oDB->execute("delete from oxobject2discount where oxobject2discount.oxobjectid={$sOxidQuoted} ");
         oxSeoEncoderCategory::getInstance()->onDeleteCategory($this);
     }
     return $blRet;
 }
 /**
  * Deletes custom zoom picture, which name is specified in oxzoom field.
  *
  * @param oxArticle $oObject article object
  * @param int       $iIndex  zoom picture index
  *
  * @return null
  */
 public function deleteZoomPicture($oObject, $iIndex)
 {
     // checking if oxzoom field exists
     $oDbHandler = oxNew("oxDbMetaDataHandler");
     $iZoomPicCount = (int) $this->getConfig()->getConfigParam('iZoomPicCount');
     if ($iIndex > $iZoomPicCount || !$oDbHandler->fieldExists("oxzoom" . $iIndex, "oxarticles")) {
         if ($sZoomPicName = $this->getZoomName($oObject->{"oxarticles__oxpic" . $iIndex}->value, $iIndex)) {
             $sFieldToCheck = "oxpic" . $iIndex;
         } else {
             return;
         }
     } else {
         $sZoomPicName = basename($oObject->{"oxarticles__oxzoom" . $iIndex}->value);
         $sFieldToCheck = "oxzoom" . $iIndex;
     }
     if ($sZoomPicName && $sZoomPicName != "nopic.jpg") {
         // deleting zoom picture
         $sPath = $this->getConfig()->getPictureDir(false) . oxUtilsFile::getInstance()->getImageDirByType("Z" . $iIndex);
         oxUtilsPic::getInstance()->safePictureDelete($sZoomPicName, $sPath, "oxarticles", $sFieldToCheck);
     }
 }
 /**
  * Saves main wrapping parameters.
  *
  * @return null
  */
 public function save()
 {
     parent::save();
     $soxId = $this->getEditObjectId();
     $aParams = oxConfig::getParameter("editval");
     // checkbox handling
     if (!isset($aParams['oxwrapping__oxactive'])) {
         $aParams['oxwrapping__oxactive'] = 0;
     }
     // shopid
     $aParams['oxwrapping__oxshopid'] = oxSession::getVar("actshop");
     $oWrapping = oxNew("oxwrapping");
     if ($soxId != "-1") {
         $oWrapping->loadInLang($this->_iEditLang, $soxId);
         // #1173M - not all pic are deleted, after article is removed
         oxUtilsPic::getInstance()->overwritePic($oWrapping, 'oxwrapping', 'oxpic', 'WP', '0', $aParams, $this->getConfig()->getPictureDir(false));
     } else {
         $aParams['oxwrapping__oxid'] = null;
     }
     //$aParams = $oWrapping->ConvertNameArray2Idx( $aParams);
     $oWrapping->setLanguage(0);
     $oWrapping->assign($aParams);
     $oWrapping->setLanguage($this->_iEditLang);
     $oWrapping = oxUtilsFile::getInstance()->processFiles($oWrapping);
     $oWrapping->save();
     // set oxid if inserted
     $this->setEditObjectId($oWrapping->getId());
 }
Exemplo n.º 7
0
 /**
  * Returns the OXID picture utilities object.
  *
  * @return oxUtilsPic
  */
 public function getUtilsPic()
 {
     return oxUtilsPic::getInstance();
 }
Exemplo n.º 8
0
 /**
  * Delete pics
  *
  * @return null
  */
 protected function _deletePics()
 {
     $myUtilsPic = oxUtilsPic::getInstance();
     $myConfig = $this->getConfig();
     $oPictureHandler = oxPictureHandler::getInstance();
     //deleting custom main icon
     $oPictureHandler->deleteMainIcon($this);
     //deleting custom thumbnail
     $oPictureHandler->deleteThumbnail($this);
     $sAbsDynImageDir = $myConfig->getPictureDir(false);
     // deleting master image and all generated images
     $iPicCount = $myConfig->getConfigParam('iPicCount');
     for ($i = 1; $i <= $iPicCount; $i++) {
         $oPictureHandler->deleteArticleMasterPicture($this, $i);
     }
 }