oxcategory.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class oxCategory extends oxI18n implements oxIUrl
00010 {
00015     protected $_aSubCats = array();
00016 
00021     protected $_aContentCats = array();
00022 
00028     protected $_sClassName = 'oxcategory';
00029 
00035     protected $_iNrOfArticles;
00036 
00042     protected $_blIsVisible;
00043 
00049     protected $_blExpanded;
00050 
00056     protected $_blHasSubCats;
00057 
00063     protected $_blHasVisibleSubCats;
00064 
00070     protected $_blIsSeoObject = true;
00071 
00077     protected $_blUseLazyLoading = false;
00078 
00084     protected $_sDynImageDir = null;
00085 
00091     protected $_blTopCategory = null;
00092     
00098     protected $_aStdUrls = array();
00099 
00105     protected $_aSeoUrls = array();
00106 
00111     protected static $_aCatAttributes = array();
00112 
00118     protected $_oParent = null;
00119 
00123     public function __construct()
00124     {
00125         parent::__construct();
00126         $this->init( 'oxcategories' );
00127     }
00128 
00136     public function __get( $sName )
00137     {
00138         switch ( $sName ) {
00139             case 'aSubCats':
00140                 return $this->_aSubCats;
00141                 break;
00142             case 'aContent':
00143                 return $this->_aContentCats;
00144                 break;
00145             case 'iArtCnt':
00146                 return $this->getNrOfArticles();
00147                 break;
00148             case 'isVisible':
00149                 return $this->getIsVisible();
00150                 break;
00151             case 'expanded':
00152                 return $this->getExpanded();
00153                 break;
00154             case 'hasSubCats':
00155                 return $this->getHasSubCats();
00156                 break;
00157             case 'hasVisibleSubCats':
00158                 return $this->getHasVisibleSubCats();
00159                 break;
00160             case 'openlink':
00161             case 'closelink':
00162             case 'link':
00163                 //case 'toListLink':
00164                 //case 'noparamlink':
00165                 return $this->getLink();
00166                 break;
00167             case 'dimagedir':
00168                 return $this->getPictureUrl();
00169                 break;
00170         }
00171         return parent::__get($sName);
00172     }
00173 
00174 
00182     protected function _loadFromDb( $sOXID )
00183     {
00184         $sSelect = $this->buildSelectString( array( $this->getViewName().".oxid" => $sOXID ));
00185         $aData = oxDb::getDb( oxDb::FETCH_MODE_ASSOC )->getRow( $sSelect );
00186         return $aData;
00187     }
00188 
00196     public function load( $sOXID )
00197     {
00198 
00199             $aData = $this->_loadFromDb( $sOXID );
00200 
00201         if ( $aData ) {
00202             $this->assign( $aData );
00203             return true;
00204         }
00205 
00206         return false;
00207     }
00208 
00209 
00217     public function assign( $dbRecord )
00218     {
00219         $this->_iNrOfArticles = null;
00220         return parent::assign( $dbRecord );
00221     }
00222 
00230     public function delete( $sOXID = null )
00231     {
00232         if ( !$this->getId() ) {
00233             $this->load( $sOXID );
00234         }
00235 
00236         $sOXID = isset( $sOXID ) ? $sOXID : $this->getId();
00237 
00238 
00239         $myConfig = $this->getConfig();
00240         $oDb      = oxDb::getDb();
00241         $blRet    = false;
00242 
00243         if ( $this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value+1) ) {
00244             $myUtilsPic = oxRegistry::get("oxUtilsPic");
00245             $sDir = $myConfig->getPictureDir(false);
00246 
00247             // only delete empty categories
00248             // #1173M - not all pic are deleted, after article is removed
00249             $myUtilsPic->safePictureDelete( $this->oxcategories__oxthumb->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('TC'), 'oxcategories', 'oxthumb' );
00250             $myUtilsPic->safePictureDelete( $this->oxcategories__oxicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('CICO'), 'oxcategories', 'oxicon' );
00251             $myUtilsPic->safePictureDelete( $this->oxcategories__oxpromoicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('PICO'), 'oxcategories', 'oxpromoicon' );
00252 
00253             $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00254 
00255             $oDb->execute( "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
00256                             WHERE  OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value)."
00257                             AND OXLEFT >   ".((int) $this->oxcategories__oxleft->value).$sAdd );
00258 
00259             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
00260                             WHERE  OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value)."
00261                             AND OXRIGHT >   ".((int) $this->oxcategories__oxright->value).$sAdd );
00262 
00263             // delete entry
00264             $blRet = parent::delete( $sOXID );
00265 
00266             $sOxidQuoted = $oDb->quote( $sOXID );
00267             // delete links to articles
00268             $oDb->execute( "delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");
00269 
00270             // #657 ADDITIONAL delete links to attributes
00271             $oDb->execute( "delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");
00272 
00273             // A. removing assigned:
00274             // - deliveries
00275             $oDb->execute( "delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
00276             // - discounts
00277             $oDb->execute( "delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted ");
00278 
00279             oxRegistry::get("oxSeoEncoderCategory")->onDeleteCategory($this);
00280         }
00281 
00282         return $blRet;
00283     }
00284 
00290     public function getSubCats()
00291     {
00292         return $this->_aSubCats;
00293     }
00294 
00302     public function getSubCat($sKey)
00303     {
00304         return $this->_aSubCats[$sKey];
00305     }
00306 
00314     public function setSubCats( $aCats )
00315     {
00316         $this->_aSubCats = $aCats;
00317 
00318         foreach ( $aCats as $oCat ) {
00319 
00320             // keeping ref. to parent
00321             $oCat->setParentCategory( $this );
00322 
00323             if ( $oCat->getIsVisible() ) {
00324                 $this->setHasVisibleSubCats( true );
00325             }
00326         }
00327     }
00328 
00337     public function setSubCat( $oCat, $sKey=null )
00338     {
00339         if ( $sKey ) {
00340             $this->_aSubCats[$sKey] = $oCat;
00341         } else {
00342             $this->_aSubCats[] = $oCat;
00343         }
00344 
00345         // keeping ref. to parent
00346         $oCat->setParentCategory( $this );
00347 
00348         if ( $oCat->getIsVisible() ) {
00349             $this->setHasVisibleSubCats( true );
00350         }
00351     }
00352 
00358     public function getContentCats()
00359     {
00360         return $this->_aContentCats;
00361     }
00362 
00370     public function setContentCats( $aContent )
00371     {
00372         $this->_aContentCats = $aContent;
00373     }
00374 
00383     public function setContentCat( $oContent, $sKey=null )
00384     {
00385         if ( $sKey ) {
00386             $this->_aContentCats[$sKey] = $oContent;
00387         } else {
00388             $this->_aContentCats[] = $oContent;
00389         }
00390     }
00391 
00397     public function getNrOfArticles()
00398     {
00399         $myConfig = $this->getConfig();
00400 
00401         if ( !isset($this->_iNrOfArticles)
00402           && !$this->isAdmin()
00403           && (
00404                  $myConfig->getConfigParam( 'bl_perfShowActionCatArticleCnt' )
00405               || $myConfig->getConfigParam('blDontShowEmptyCategories')
00406              ) ) {
00407 
00408             if ( $this->isPriceCategory() ) {
00409                 $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getPriceCatArticleCount( $this->getId(), $this->oxcategories__oxpricefrom->value, $this->oxcategories__oxpriceto->value );
00410             } else {
00411                 $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getCatArticleCount( $this->getId() );
00412             }
00413         }
00414 
00415         return (int)$this->_iNrOfArticles;
00416     }
00417 
00425     public function setNrOfArticles( $iNum )
00426     {
00427         $this->_iNrOfArticles = $iNum;
00428     }
00429 
00435     public function getIsVisible()
00436     {
00437         if (!isset( $this->_blIsVisible ) ) {
00438 
00439             if ( $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00440                 $blEmpty = ($this->getNrOfArticles() < 1) && !$this->getHasVisibleSubCats();
00441             } else {
00442                 $blEmpty = false;
00443             }
00444 
00445             $this->_blIsVisible = !($blEmpty || $this->oxcategories__oxhidden->value);
00446         }
00447 
00448         return $this->_blIsVisible;
00449     }
00450 
00458     public function setIsVisible( $blVisible )
00459     {
00460         $this->_blIsVisible = $blVisible;
00461     }
00462 
00468     public function getPictureUrl()
00469     {
00470         if ( $this->_sDynImageDir === null ) {
00471             $sThisShop = $this->oxcategories__oxshopid->value;
00472             $this->_sDynImageDir = $this->getConfig()->getPictureUrl( null, false, null, null, $sThisShop);
00473         }
00474         return $this->_sDynImageDir;
00475     }
00476 
00485     public function getBaseSeoLink( $iLang, $iPage = 0 )
00486     {
00487         $oEncoder = oxRegistry::get("oxSeoEncoderCategory");
00488         if ( !$iPage ) {
00489             return $oEncoder->getCategoryUrl( $this, $iLang );
00490         }
00491         return $oEncoder->getCategoryPageUrl( $this, $iPage, $iLang );
00492     }
00493 
00501     public function getLink( $iLang = null )
00502     {
00503         if ( !oxRegistry::getUtils()->seoIsActive() ||
00504              ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) ) {
00505             return $this->getStdLink( $iLang );
00506         }
00507 
00508         if ( $iLang === null ) {
00509             $iLang = $this->getLanguage();
00510         }
00511 
00512         if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
00513             $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
00514         }
00515         return $this->_aSeoUrls[$iLang];
00516     }
00517 
00525     public function setLink( $sLink )
00526     {
00527         $iLang = $this->getLanguage();
00528         if ( oxRegistry::getUtils()->seoIsActive() ) {
00529             $this->_aSeoUrls[$iLang] = $sLink;
00530         } else {
00531             $this->_aStdUrls[$iLang] = $sLink;
00532         }
00533     }
00534 
00542     public function getSqlActiveSnippet( $blForceCoreTable = null )
00543     {
00544         $sQ  = parent::getSqlActiveSnippet( $blForceCoreTable );
00545 
00546         $sTable = $this->getViewName($blForceCoreTable);
00547         $sQ .= ( strlen( $sQ )? ' and ' : '' ) . " $sTable.oxhidden = '0' ";
00548 
00549 
00550         return "( $sQ ) ";
00551     }
00552 
00562     public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00563     {
00564         if ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) {
00565             return  $this->oxcategories__oxextlink->value;
00566         }
00567 
00568         $sUrl = '';
00569         if ( $blFull ) {
00570             //always returns shop url, not admin
00571             $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00572         }
00573 
00574         //always returns shop url, not admin
00575         return $sUrl . "index.php?cl=alist" . ( $blAddId ? "&amp;cnid=".$this->getId() : "" );
00576     }
00577 
00586     public function getStdLink( $iLang = null, $aParams = array() )
00587     {
00588         if ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) {
00589             return  oxRegistry::get("oxUtilsUrl")->processUrl( $this->oxcategories__oxextlink->value, false );
00590         }
00591 
00592         if ( $iLang === null ) {
00593             $iLang = $this->getLanguage();
00594         }
00595 
00596         if ( !isset( $this->_aStdUrls[$iLang] ) ) {
00597             $this->_aStdUrls[$iLang] = $this->getBaseStdLink( $iLang );
00598         }
00599 
00600         return oxRegistry::get("oxUtilsUrl")->processUrl( $this->_aStdUrls[$iLang], true, $aParams, $iLang );
00601     }
00602 
00608     public function getExpanded()
00609     {
00610         return $this->_blExpanded;
00611     }
00612 
00620     public function setExpanded( $blExpanded )
00621     {
00622         $this->_blExpanded = $blExpanded;
00623     }
00624 
00630     public function getHasSubCats()
00631     {
00632         if ( !isset( $this->_blHasSubCats ) ) {
00633             $this->_blHasSubCats = $this->oxcategories__oxright->value > $this->oxcategories__oxleft->value + 1 ;
00634         }
00635 
00636         return $this->_blHasSubCats;
00637     }
00638 
00644     public function getHasVisibleSubCats()
00645     {
00646         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00647             $this->_blHasVisibleSubCats = false;
00648         }
00649 
00650         return $this->_blHasVisibleSubCats;
00651     }
00652 
00660     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00661     {
00662         if ( $blHasVisibleSubcats && !$this->_blHasVisibleSubCats ) {
00663             unset( $this->_blIsVisible );
00664             if ($this->_oParent instanceof oxCategory) {
00665                 $this->_oParent->setHasVisibleSubCats( true );
00666             }
00667         }
00668         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00669     }
00670 
00676     public function getAttributes()
00677     {
00678         $sActCat = $this->getId();
00679 
00680         $sKey = md5( $sActCat . serialize( oxSession::getVar( 'session_attrfilter' ) ) );
00681         if ( !isset( self::$_aCatAttributes[$sKey] ) ) {
00682             $oAttrList = oxNew( "oxAttributeList" );
00683             $oAttrList->getCategoryAttributes( $sActCat, $this->getLanguage() );
00684             self::$_aCatAttributes[$sKey] = $oAttrList;
00685         }
00686 
00687         return self::$_aCatAttributes[$sKey];
00688     }
00689 
00697     public function getCatInLang( $oActCategory = null )
00698     {
00699         $oCategoryInDefaultLanguage= oxNew( "oxcategory" );
00700         if ( $this->isPriceCategory() ) {
00701             // get it in base language
00702             $oCategoryInDefaultLanguage= oxNew( "oxcategory" );
00703             $oCategoryInDefaultLanguage->loadInLang( 0, $this->getId());
00704         } else {
00705             $oCategoryInDefaultLanguage= oxNew( "oxcategory" );
00706             $oCategoryInDefaultLanguage->loadInLang( 0, $oActCategory->getId());
00707         }
00708         return $oCategoryInDefaultLanguage;
00709     }
00710 
00718     public function setParentCategory( $oCategory )
00719     {
00720         $this->_oParent = $oCategory;
00721     }
00722 
00728     public function getParentCategory()
00729     {
00730         $oCat = null;
00731 
00732         // loading only if parent id is not rootid
00733         if ( $this->oxcategories__oxparentid->value && $this->oxcategories__oxparentid->value != 'oxrootid' ) {
00734 
00735             // checking if object itself has ref to parent
00736             if ( $this->_oParent ) {
00737                 $oCat = $this->_oParent;
00738             } else {
00739                 $oCat = oxNew( 'oxCategory' );
00740                 if ( !$oCat->load( $this->oxcategories__oxparentid->value ) ) {
00741                     $oCat = null;
00742                 } else {
00743                     $this->_oParent = $oCat;
00744                 }
00745             }
00746         }
00747         return $oCat;
00748     }
00749 
00757     public static function getRootId($sCategoryId)
00758     {
00759         if ( !isset( $sCategoryId ) ) {
00760             return;
00761         }
00762         $oDb = oxDb::getDb();
00763 
00764         return $oDb->getOne( 'select oxrootid from '.getViewName('oxcategories').' where oxid = ' . $oDb->quote( $sCategoryId ) );
00765     }
00766 
00767 
00775     public function assignViewableRecord($sSelect)
00776     {
00777             if ( $this->assignRecord( $sSelect ) ) {
00778                 return  true;
00779             }
00780 
00781 
00782         return false;
00783     }
00784 
00790     protected function _insert()
00791     {
00792 
00793 
00794 
00795         if ( $this->oxcategories__oxparentid->value != "oxrootid") {
00796             // load parent
00797             $oParent = oxNew( "oxcategory" );
00798             //#M317 check if parent is loaded
00799             if ( !$oParent->load( $this->oxcategories__oxparentid->value) ) {
00800                 return false;
00801             }
00802 
00803             $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00804 
00805             // update existing nodes
00806             $oDb = oxDb::getDb();
00807             $oDb->execute( "UPDATE oxcategories SET OXLEFT = OXLEFT + 2
00808                             WHERE  OXROOTID = ".$oDb->quote($oParent->oxcategories__oxrootid->value)."
00809                             AND OXLEFT >   ".((int) $oParent->oxcategories__oxright->value)."
00810                             AND OXRIGHT >= ".((int) $oParent->oxcategories__oxright->value).$sAdd);
00811 
00812 
00813             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2
00814                             WHERE  OXROOTID = ".$oDb->quote($oParent->oxcategories__oxrootid->value)."
00815                             AND OXRIGHT >= ".((int) $oParent->oxcategories__oxright->value).$sAdd );
00816 
00817             //if ( !isset( $this->_sOXID) || trim( $this->_sOXID) == "")
00818             //    $this->_sOXID = oxUtilsObject::getInstance()->generateUID();
00819             //$this->oxcategories__oxid->setValue($this->_sOXID);
00820             //refactored to:
00821             if ( !$this->getId() ) {
00822                 $this->setId();
00823             }
00824 
00825             $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW);
00826             $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW);
00827             $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW);
00828             return parent::_insert();
00829         } else {
00830             // root entry
00831             if ( !$this->getId() ) {
00832                 $this->setId();
00833             }
00834 
00835             $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW);
00836             $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW);
00837             $this->oxcategories__oxright = new oxField(2, oxField::T_RAW);
00838             return parent::_insert();
00839         }
00840     }
00841 
00847     protected function _update()
00848     {
00849 
00850         $oDb = oxDb::getDb();
00851         $sOldParentID = $oDb->getOne( "select oxparentid from oxcategories where oxid = ".$oDb->quote( $this->getId() ), false, false );
00852 
00853         if ( $this->_blIsSeoObject && $this->isAdmin() ) {
00854             oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00855         }
00856 
00857         $blRes = parent::_update();
00858 
00859         // #872C - need to update category tree oxleft and oxright values (nested sets),
00860         // then sub trees are moved inside one root, or to another root.
00861         // this is done in 3 basic steps
00862         // 1. increase oxleft and oxright values of target root tree by $iTreeSize, where oxleft>=$iMoveAfter , oxright>=$iMoveAfter
00863         // 2. modify current subtree, we want to move by adding $iDelta to it's oxleft and oxright,  where oxleft>=$sOldParentLeft and oxright<=$sOldParentRight values,
00864         //    in this step we also modify rootid's if they were changed
00865         // 3. decreasing oxleft and oxright values of current root tree, where oxleft >= $sOldParentRight+1 , oxright >= $sOldParentRight+1
00866 
00867         // did we change position in tree ?
00868         if ( $this->oxcategories__oxparentid->value != $sOldParentID) {
00869             $sOldParentLeft = $this->oxcategories__oxleft->value;
00870             $sOldParentRight = $this->oxcategories__oxright->value;
00871 
00872             $iTreeSize = $sOldParentRight-$sOldParentLeft+1;
00873 
00874             $sNewRootID = $oDb->getOne( "select oxrootid from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00875 
00876             //If empty rootID, we set it to categorys oxid
00877             if ( $sNewRootID == "") {
00878                 //echo "<br>* ) Creating new root tree ( {$this->_sOXID} )";
00879                 $sNewRootID = $this->getId();
00880             }
00881 
00882             $sNewParentLeft = $oDb->getOne( "select oxleft from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00883 
00884             //if(!$sNewParentLeft){
00885                 //the current node has become root node, (oxrootid == "oxrootid")
00886             //    $sNewParentLeft = 0;
00887             //}
00888 
00889             $iMoveAfter = $sNewParentLeft+1;
00890 
00891             //New parentid can not be set to it's child
00892             if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) {
00893                 //echo "<br>* ) Can't asign category to it's child";
00894 
00895                 //Restoring old parentid, stoping further actions
00896                 $sRestoreOld = "UPDATE oxcategories SET OXPARENTID = ".$oDb->quote($sOldParentID)." WHERE oxid = ".$oDb->quote($this->getId());
00897                 $oDb->execute( $sRestoreOld );
00898                 return false;
00899             }
00900 
00901             //Old parent will be shifted too, if it is in the same tree
00902             if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
00903                 $sOldParentLeft += $iTreeSize;
00904                 $sOldParentRight += $iTreeSize;
00905             }
00906 
00907             $iDelta = $iMoveAfter-$sOldParentLeft;
00908 
00909             //echo "Size=$iTreeSize, NewStart=$iMoveAfter, delta=$iDelta";
00910 
00911             $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value).";";
00912             $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($sNewRootID).";";
00913 
00914             //Updating everything after new position
00915             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iTreeSize.") WHERE OXLEFT >= ".$iMoveAfter.$sAddNew );
00916             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT + ".$iTreeSize.") WHERE OXRIGHT >= ".$iMoveAfter.$sAddNew );
00917             //echo "<br>1.) + $iTreeSize, >= $iMoveAfter";
00918 
00919             $sChangeRootID = "";
00920             if ($this->oxcategories__oxrootid->value != $sNewRootID) {
00921                 //echo "<br>* ) changing root IDs ( {$this->oxcategories__oxrootid->value} -> {$sNewRootID} )";
00922                 $sChangeRootID = ", OXROOTID=".$oDb->quote($sNewRootID);
00923             }
00924 
00925             //Updating subtree
00926             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iDelta."), OXRIGHT = (OXRIGHT + ".$iDelta.") ".$sChangeRootID." WHERE OXLEFT >= ".$sOldParentLeft." AND OXRIGHT <= ".$sOldParentRight.$sAddOld );
00927             //echo "<br>2.) + $iDelta, >= $sOldParentLeft and <= $sOldParentRight";
00928 
00929             //Updating everything after old position
00930             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT - ".$iTreeSize.") WHERE OXLEFT >=   ".($sOldParentRight+1).$sAddOld );
00931             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT - ".$iTreeSize.") WHERE OXRIGHT >=   ".($sOldParentRight+1).$sAddOld );
00932             //echo "<br>3.) - $iTreeSize, >= ".($sOldParentRight+1);
00933         }
00934 
00935         if ( $blRes && $this->_blIsSeoObject && $this->isAdmin() ) {
00936             oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00937         }
00938 
00939         return $blRes;
00940     }
00941 
00951     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00952     {
00953         //preliminar quick check saves 3% of execution time in category lists by avoiding redundant strtolower() call
00954         if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L') ) ) {
00955             if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
00956                 $iDataType = oxField::T_RAW;
00957             }
00958         }
00959         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00960     }
00961 
00962 
00968     public function getIconUrl()
00969     {
00970         if ( ( $sIcon = $this->oxcategories__oxicon->value ) ) {
00971             $oConfig = $this->getConfig();
00972             $sSize = $oConfig->getConfigParam( 'sCatIconsize' );
00973             if ( !isset( $sSize ) ) {
00974                 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00975             }
00976 
00977             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/icon/", $sIcon, $sSize );
00978         }
00979     }
00980 
00986     public function getThumbUrl()
00987     {
00988         if ( ( $sIcon = $this->oxcategories__oxthumb->value ) ) {
00989             $sSize = $this->getConfig()->getConfigParam( 'sCatThumbnailsize' );
00990             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/thumb/", $sIcon, $sSize );
00991         }
00992     }
00993 
00999     public function getPromotionIconUrl()
01000     {
01001         if ( ( $sIcon = $this->oxcategories__oxpromoicon->value ) ) {
01002             $sSize = $this->getConfig()->getConfigParam( 'sCatPromotionsize' );
01003             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/promo_icon/", $sIcon, $sSize );
01004         }
01005     }
01006 
01015     public function getPictureUrlForType( $sPicName, $sPicType )
01016     {
01017         if ( $sPicName ) {
01018             return $this->getPictureUrl() . $sPicType . '/' . $sPicName;
01019         } else {
01020             return false;
01021         }
01022     }
01023 
01029     public function isTopCategory()
01030     {
01031         if ( $this->_blTopCategory == null ) {
01032             $this->_blTopCategory = $this->oxcategories__oxparentid->value == 'oxrootid';
01033         }
01034         return $this->_blTopCategory;
01035     }
01036 
01042     public function isPriceCategory()
01043     {
01044         return (bool) ( $this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value );
01045     }
01046 
01053     public function getLongDesc()
01054     {
01055         if ( isset( $this->oxcategories__oxlongdesc ) && $this->oxcategories__oxlongdesc instanceof oxField ) {
01056            return oxRegistry::get("oxUtilsView")->parseThroughSmarty( $this->oxcategories__oxlongdesc->getRawValue(), $this->getId().$this->getLanguage() );
01057         }
01058     }
01059 
01065     public function getShortDescription()
01066     {
01067         return $this->oxcategories__oxdesc->value;
01068     }
01069 
01075     public function getTitle()
01076     {
01077         return $this->oxcategories__oxtitle->value;
01078     }
01079 }