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 
00134     public function getDefaultSorting()
00135     {
00136         return $this->oxcategories__oxdefsort->value;
00137     }
00138 
00144     public function getDefaultSortingMode()
00145     {
00146         return $this->oxcategories__oxdefsortmode->value;
00147     }
00148 
00156     public function __get( $sName )
00157     {
00158         switch ( $sName ) {
00159             case 'aSubCats':
00160                 return $this->_aSubCats;
00161                 break;
00162             case 'aContent':
00163                 return $this->_aContentCats;
00164                 break;
00165             case 'iArtCnt':
00166                 return $this->getNrOfArticles();
00167                 break;
00168             case 'isVisible':
00169                 return $this->getIsVisible();
00170                 break;
00171             case 'expanded':
00172                 return $this->getExpanded();
00173                 break;
00174             case 'hasSubCats':
00175                 return $this->getHasSubCats();
00176                 break;
00177             case 'hasVisibleSubCats':
00178                 return $this->getHasVisibleSubCats();
00179                 break;
00180             case 'openlink':
00181             case 'closelink':
00182             case 'link':
00183                 //case 'toListLink':
00184                 //case 'noparamlink':
00185                 return $this->getLink();
00186                 break;
00187             case 'dimagedir':
00188                 return $this->getPictureUrl();
00189                 break;
00190         }
00191         return parent::__get($sName);
00192     }
00193 
00194 
00202     protected function _loadFromDb( $sOXID )
00203     {
00204         $sSelect = $this->buildSelectString( array( $this->getViewName().".oxid" => $sOXID ));
00205         $aData = oxDb::getDb( oxDb::FETCH_MODE_ASSOC )->getRow( $sSelect );
00206         return $aData;
00207     }
00208 
00216     public function load( $sOXID )
00217     {
00218 
00219             $aData = $this->_loadFromDb( $sOXID );
00220 
00221         if ( $aData ) {
00222             $this->assign( $aData );
00223             return true;
00224         }
00225 
00226         return false;
00227     }
00228 
00229 
00237     public function assign( $dbRecord )
00238     {
00239         $this->_iNrOfArticles = null;
00240         return parent::assign( $dbRecord );
00241     }
00242 
00250     public function delete( $sOXID = null )
00251     {
00252         if ( !$this->getId() ) {
00253             $this->load( $sOXID );
00254         }
00255 
00256         $sOXID = isset( $sOXID ) ? $sOXID : $this->getId();
00257 
00258 
00259         $myConfig = $this->getConfig();
00260         $oDb      = oxDb::getDb();
00261         $blRet    = false;
00262 
00263         if ( $this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value+1) ) {
00264             $myUtilsPic = oxRegistry::get("oxUtilsPic");
00265             $sDir = $myConfig->getPictureDir(false);
00266 
00267             // only delete empty categories
00268             // #1173M - not all pic are deleted, after article is removed
00269             $myUtilsPic->safePictureDelete( $this->oxcategories__oxthumb->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('TC'), 'oxcategories', 'oxthumb' );
00270             $myUtilsPic->safePictureDelete( $this->oxcategories__oxicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('CICO'), 'oxcategories', 'oxicon' );
00271             $myUtilsPic->safePictureDelete( $this->oxcategories__oxpromoicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('PICO'), 'oxcategories', 'oxpromoicon' );
00272 
00273             $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00274 
00275             $oDb->execute( "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
00276                             WHERE  OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value)."
00277                             AND OXLEFT >   ".((int) $this->oxcategories__oxleft->value).$sAdd );
00278 
00279             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
00280                             WHERE  OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value)."
00281                             AND OXRIGHT >   ".((int) $this->oxcategories__oxright->value).$sAdd );
00282 
00283             // delete entry
00284             $blRet = parent::delete( $sOXID );
00285 
00286             $sOxidQuoted = $oDb->quote( $sOXID );
00287             // delete links to articles
00288             $oDb->execute( "delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");
00289 
00290             // #657 ADDITIONAL delete links to attributes
00291             $oDb->execute( "delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");
00292 
00293             // A. removing assigned:
00294             // - deliveries
00295             $oDb->execute( "delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
00296             // - discounts
00297             $oDb->execute( "delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted ");
00298 
00299             oxRegistry::get("oxSeoEncoderCategory")->onDeleteCategory($this);
00300         }
00301 
00302         return $blRet;
00303     }
00304 
00310     public function getSubCats()
00311     {
00312         return $this->_aSubCats;
00313     }
00314 
00322     public function getSubCat($sKey)
00323     {
00324         return $this->_aSubCats[$sKey];
00325     }
00326 
00334     public function setSubCats( $aCats )
00335     {
00336         $this->_aSubCats = $aCats;
00337 
00338         foreach ( $aCats as $oCat ) {
00339 
00340             // keeping ref. to parent
00341             $oCat->setParentCategory( $this );
00342 
00343             if ( $oCat->getIsVisible() ) {
00344                 $this->setHasVisibleSubCats( true );
00345             }
00346         }
00347     }
00348 
00357     public function setSubCat( $oCat, $sKey=null )
00358     {
00359         if ( $sKey ) {
00360             $this->_aSubCats[$sKey] = $oCat;
00361         } else {
00362             $this->_aSubCats[] = $oCat;
00363         }
00364 
00365         // keeping ref. to parent
00366         $oCat->setParentCategory( $this );
00367 
00368         if ( $oCat->getIsVisible() ) {
00369             $this->setHasVisibleSubCats( true );
00370         }
00371     }
00372 
00378     public function getContentCats()
00379     {
00380         return $this->_aContentCats;
00381     }
00382 
00390     public function setContentCats( $aContent )
00391     {
00392         $this->_aContentCats = $aContent;
00393     }
00394 
00403     public function setContentCat( $oContent, $sKey=null )
00404     {
00405         if ( $sKey ) {
00406             $this->_aContentCats[$sKey] = $oContent;
00407         } else {
00408             $this->_aContentCats[] = $oContent;
00409         }
00410     }
00411 
00417     public function getNrOfArticles()
00418     {
00419         $myConfig = $this->getConfig();
00420 
00421         if ( !isset($this->_iNrOfArticles)
00422           && !$this->isAdmin()
00423           && (
00424                  $myConfig->getConfigParam( 'bl_perfShowActionCatArticleCnt' )
00425               || $myConfig->getConfigParam('blDontShowEmptyCategories')
00426              ) ) {
00427 
00428             if ( $this->isPriceCategory() ) {
00429                 $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getPriceCatArticleCount( $this->getId(), $this->oxcategories__oxpricefrom->value, $this->oxcategories__oxpriceto->value );
00430             } else {
00431                 $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getCatArticleCount( $this->getId() );
00432             }
00433         }
00434 
00435         return (int)$this->_iNrOfArticles;
00436     }
00437 
00445     public function setNrOfArticles( $iNum )
00446     {
00447         $this->_iNrOfArticles = $iNum;
00448     }
00449 
00455     public function getIsVisible()
00456     {
00457         if (!isset( $this->_blIsVisible ) ) {
00458 
00459             if ( $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00460                 $blEmpty = ($this->getNrOfArticles() < 1) && !$this->getHasVisibleSubCats();
00461             } else {
00462                 $blEmpty = false;
00463             }
00464 
00465             $this->_blIsVisible = !($blEmpty || $this->oxcategories__oxhidden->value);
00466         }
00467 
00468         return $this->_blIsVisible;
00469     }
00470 
00478     public function setIsVisible( $blVisible )
00479     {
00480         $this->_blIsVisible = $blVisible;
00481     }
00482 
00488     public function getPictureUrl()
00489     {
00490         if ( $this->_sDynImageDir === null ) {
00491             $sThisShop = $this->oxcategories__oxshopid->value;
00492             $this->_sDynImageDir = $this->getConfig()->getPictureUrl( null, false, null, null, $sThisShop);
00493         }
00494         return $this->_sDynImageDir;
00495     }
00496 
00505     public function getBaseSeoLink( $iLang, $iPage = 0 )
00506     {
00507         $oEncoder = oxRegistry::get("oxSeoEncoderCategory");
00508         if ( !$iPage ) {
00509             return $oEncoder->getCategoryUrl( $this, $iLang );
00510         }
00511         return $oEncoder->getCategoryPageUrl( $this, $iPage, $iLang );
00512     }
00513 
00521     public function getLink( $iLang = null )
00522     {
00523         if ( !oxRegistry::getUtils()->seoIsActive() ||
00524              ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) ) {
00525             return $this->getStdLink( $iLang );
00526         }
00527 
00528         if ( $iLang === null ) {
00529             $iLang = $this->getLanguage();
00530         }
00531 
00532         if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
00533             $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
00534         }
00535         return $this->_aSeoUrls[$iLang];
00536     }
00537 
00545     public function setLink( $sLink )
00546     {
00547         $iLang = $this->getLanguage();
00548         if ( oxRegistry::getUtils()->seoIsActive() ) {
00549             $this->_aSeoUrls[$iLang] = $sLink;
00550         } else {
00551             $this->_aStdUrls[$iLang] = $sLink;
00552         }
00553     }
00554 
00562     public function getSqlActiveSnippet( $blForceCoreTable = null )
00563     {
00564         $sQ  = parent::getSqlActiveSnippet( $blForceCoreTable );
00565 
00566         $sTable = $this->getViewName($blForceCoreTable);
00567         $sQ .= ( strlen( $sQ )? ' and ' : '' ) . " $sTable.oxhidden = '0' ";
00568 
00569 
00570         return "( $sQ ) ";
00571     }
00572 
00582     public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00583     {
00584         if ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) {
00585             return  $this->oxcategories__oxextlink->value;
00586         }
00587 
00588         $sUrl = '';
00589         if ( $blFull ) {
00590             //always returns shop url, not admin
00591             $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00592         }
00593 
00594         //always returns shop url, not admin
00595         return $sUrl . "index.php?cl=alist" . ( $blAddId ? "&amp;cnid=".$this->getId() : "" );
00596     }
00597 
00606     public function getStdLink( $iLang = null, $aParams = array() )
00607     {
00608         if ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) {
00609             return  oxRegistry::get("oxUtilsUrl")->processUrl( $this->oxcategories__oxextlink->value, false );
00610         }
00611 
00612         if ( $iLang === null ) {
00613             $iLang = $this->getLanguage();
00614         }
00615 
00616         if ( !isset( $this->_aStdUrls[$iLang] ) ) {
00617             $this->_aStdUrls[$iLang] = $this->getBaseStdLink( $iLang );
00618         }
00619 
00620         return oxRegistry::get("oxUtilsUrl")->processUrl( $this->_aStdUrls[$iLang], true, $aParams, $iLang );
00621     }
00622 
00628     public function getExpanded()
00629     {
00630         return $this->_blExpanded;
00631     }
00632 
00640     public function setExpanded( $blExpanded )
00641     {
00642         $this->_blExpanded = $blExpanded;
00643     }
00644 
00650     public function getHasSubCats()
00651     {
00652         if ( !isset( $this->_blHasSubCats ) ) {
00653             $this->_blHasSubCats = $this->oxcategories__oxright->value > $this->oxcategories__oxleft->value + 1 ;
00654         }
00655 
00656         return $this->_blHasSubCats;
00657     }
00658 
00664     public function getHasVisibleSubCats()
00665     {
00666         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00667             $this->_blHasVisibleSubCats = false;
00668         }
00669 
00670         return $this->_blHasVisibleSubCats;
00671     }
00672 
00680     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00681     {
00682         if ( $blHasVisibleSubcats && !$this->_blHasVisibleSubCats ) {
00683             unset( $this->_blIsVisible );
00684             if ($this->_oParent instanceof oxCategory) {
00685                 $this->_oParent->setHasVisibleSubCats( true );
00686             }
00687         }
00688         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00689     }
00690 
00696     public function getAttributes()
00697     {
00698         $sActCat = $this->getId();
00699 
00700         $sKey = md5( $sActCat . serialize( oxSession::getVar( 'session_attrfilter' ) ) );
00701         if ( !isset( self::$_aCatAttributes[$sKey] ) ) {
00702             $oAttrList = oxNew( "oxAttributeList" );
00703             $oAttrList->getCategoryAttributes( $sActCat, $this->getLanguage() );
00704             self::$_aCatAttributes[$sKey] = $oAttrList;
00705         }
00706 
00707         return self::$_aCatAttributes[$sKey];
00708     }
00709 
00717     public function getCatInLang( $oActCategory = null )
00718     {
00719         $oCategoryInDefaultLanguage= oxNew( "oxCategory" );
00720         if ( $this->isPriceCategory() ) {
00721             // get it in base language
00722             $oCategoryInDefaultLanguage= oxNew( "oxCategory" );
00723             $oCategoryInDefaultLanguage->loadInLang( 0, $this->getId());
00724         } else {
00725             $oCategoryInDefaultLanguage= oxNew( "oxCategory" );
00726             $oCategoryInDefaultLanguage->loadInLang( 0, $oActCategory->getId());
00727         }
00728         return $oCategoryInDefaultLanguage;
00729     }
00730 
00738     public function setParentCategory( $oCategory )
00739     {
00740         $this->_oParent = $oCategory;
00741     }
00742 
00748     public function getParentCategory()
00749     {
00750         $oCat = null;
00751 
00752         // loading only if parent id is not rootid
00753         if ( $this->oxcategories__oxparentid->value && $this->oxcategories__oxparentid->value != 'oxrootid' ) {
00754 
00755             // checking if object itself has ref to parent
00756             if ( $this->_oParent ) {
00757                 $oCat = $this->_oParent;
00758             } else {
00759                 $oCat = oxNew( 'oxCategory' );
00760                 if ( !$oCat->load( $this->oxcategories__oxparentid->value ) ) {
00761                     $oCat = null;
00762                 } else {
00763                     $this->_oParent = $oCat;
00764                 }
00765             }
00766         }
00767         return $oCat;
00768     }
00769 
00777     public static function getRootId($sCategoryId)
00778     {
00779         if ( !isset( $sCategoryId ) ) {
00780             return;
00781         }
00782         $oDb = oxDb::getDb();
00783 
00784         return $oDb->getOne( 'select oxrootid from '.getViewName('oxcategories').' where oxid = ' . $oDb->quote( $sCategoryId ) );
00785     }
00786 
00787 
00795     public function assignViewableRecord($sSelect)
00796     {
00797             if ( $this->assignRecord( $sSelect ) ) {
00798                 return  true;
00799             }
00800 
00801 
00802         return false;
00803     }
00804 
00810     protected function _insert()
00811     {
00812 
00813 
00814 
00815         if ( $this->oxcategories__oxparentid->value != "oxrootid") {
00816             // load parent
00817             $oParent = oxNew( "oxCategory" );
00818             //#M317 check if parent is loaded
00819             if ( !$oParent->load( $this->oxcategories__oxparentid->value) ) {
00820                 return false;
00821             }
00822 
00823             $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00824 
00825             // update existing nodes
00826             $oDb = oxDb::getDb();
00827             $oDb->execute( "UPDATE oxcategories SET OXLEFT = OXLEFT + 2
00828                             WHERE  OXROOTID = ".$oDb->quote($oParent->oxcategories__oxrootid->value)."
00829                             AND OXLEFT >   ".((int) $oParent->oxcategories__oxright->value)."
00830                             AND OXRIGHT >= ".((int) $oParent->oxcategories__oxright->value).$sAdd);
00831 
00832 
00833             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2
00834                             WHERE  OXROOTID = ".$oDb->quote($oParent->oxcategories__oxrootid->value)."
00835                             AND OXRIGHT >= ".((int) $oParent->oxcategories__oxright->value).$sAdd );
00836 
00837             if ( !$this->getId() ) {
00838                 $this->setId();
00839             }
00840 
00841             $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW);
00842             $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW);
00843             $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW);
00844             return parent::_insert();
00845         } else {
00846             // root entry
00847             if ( !$this->getId() ) {
00848                 $this->setId();
00849             }
00850 
00851             $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW);
00852             $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW);
00853             $this->oxcategories__oxright = new oxField(2, oxField::T_RAW);
00854             return parent::_insert();
00855         }
00856     }
00857 
00863     protected function _update()
00864     {
00865 
00866         $oDb = oxDb::getDb();
00867         $sOldParentID = $oDb->getOne( "select oxparentid from oxcategories where oxid = ".$oDb->quote( $this->getId() ), false, false );
00868 
00869         if ( $this->_blIsSeoObject && $this->isAdmin() ) {
00870             oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00871         }
00872 
00873         $blRes = parent::_update();
00874 
00875         // #872C - need to update category tree oxleft and oxright values (nested sets),
00876         // then sub trees are moved inside one root, or to another root.
00877         // this is done in 3 basic steps
00878         // 1. increase oxleft and oxright values of target root tree by $iTreeSize, where oxleft>=$iMoveAfter , oxright>=$iMoveAfter
00879         // 2. modify current subtree, we want to move by adding $iDelta to it's oxleft and oxright,  where oxleft>=$sOldParentLeft and oxright<=$sOldParentRight values,
00880         //    in this step we also modify rootid's if they were changed
00881         // 3. decreasing oxleft and oxright values of current root tree, where oxleft >= $sOldParentRight+1 , oxright >= $sOldParentRight+1
00882 
00883         // did we change position in tree ?
00884         if ( $this->oxcategories__oxparentid->value != $sOldParentID) {
00885             $sOldParentLeft = $this->oxcategories__oxleft->value;
00886             $sOldParentRight = $this->oxcategories__oxright->value;
00887 
00888             $iTreeSize = $sOldParentRight-$sOldParentLeft+1;
00889 
00890             $sNewRootID = $oDb->getOne( "select oxrootid from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00891 
00892             //If empty rootID, we set it to categorys oxid
00893             if ( $sNewRootID == "") {
00894                 //echo "<br>* ) Creating new root tree ( {$this->_sOXID} )";
00895                 $sNewRootID = $this->getId();
00896             }
00897 
00898             $sNewParentLeft = $oDb->getOne( "select oxleft from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00899 
00900             //if(!$sNewParentLeft){
00901                 //the current node has become root node, (oxrootid == "oxrootid")
00902             //    $sNewParentLeft = 0;
00903             //}
00904 
00905             $iMoveAfter = $sNewParentLeft+1;
00906 
00907             //New parentid can not be set to it's child
00908             if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) {
00909                 //echo "<br>* ) Can't asign category to it's child";
00910 
00911                 //Restoring old parentid, stoping further actions
00912                 $sRestoreOld = "UPDATE oxcategories SET OXPARENTID = ".$oDb->quote($sOldParentID)." WHERE oxid = ".$oDb->quote($this->getId());
00913                 $oDb->execute( $sRestoreOld );
00914                 return false;
00915             }
00916 
00917             //Old parent will be shifted too, if it is in the same tree
00918             if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
00919                 $sOldParentLeft += $iTreeSize;
00920                 $sOldParentRight += $iTreeSize;
00921             }
00922 
00923             $iDelta = $iMoveAfter-$sOldParentLeft;
00924 
00925             //echo "Size=$iTreeSize, NewStart=$iMoveAfter, delta=$iDelta";
00926 
00927             $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value).";";
00928             $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($sNewRootID).";";
00929 
00930             //Updating everything after new position
00931             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iTreeSize.") WHERE OXLEFT >= ".$iMoveAfter.$sAddNew );
00932             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT + ".$iTreeSize.") WHERE OXRIGHT >= ".$iMoveAfter.$sAddNew );
00933             //echo "<br>1.) + $iTreeSize, >= $iMoveAfter";
00934 
00935             $sChangeRootID = "";
00936             if ($this->oxcategories__oxrootid->value != $sNewRootID) {
00937                 //echo "<br>* ) changing root IDs ( {$this->oxcategories__oxrootid->value} -> {$sNewRootID} )";
00938                 $sChangeRootID = ", OXROOTID=".$oDb->quote($sNewRootID);
00939             }
00940 
00941             //Updating subtree
00942             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iDelta."), OXRIGHT = (OXRIGHT + ".$iDelta.") ".$sChangeRootID." WHERE OXLEFT >= ".$sOldParentLeft." AND OXRIGHT <= ".$sOldParentRight.$sAddOld );
00943             //echo "<br>2.) + $iDelta, >= $sOldParentLeft and <= $sOldParentRight";
00944 
00945             //Updating everything after old position
00946             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT - ".$iTreeSize.") WHERE OXLEFT >=   ".($sOldParentRight+1).$sAddOld );
00947             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT - ".$iTreeSize.") WHERE OXRIGHT >=   ".($sOldParentRight+1).$sAddOld );
00948             //echo "<br>3.) - $iTreeSize, >= ".($sOldParentRight+1);
00949         }
00950 
00951         if ( $blRes && $this->_blIsSeoObject && $this->isAdmin() ) {
00952             oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00953         }
00954 
00955         return $blRes;
00956     }
00957 
00967     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00968     {
00969         //preliminary quick check saves 3% of execution time in category lists by avoiding redundant strtolower() call
00970         if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L') ) ) {
00971             if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
00972                 $iDataType = oxField::T_RAW;
00973             }
00974         }
00975         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00976     }
00977 
00978 
00984     public function getIconUrl()
00985     {
00986         if ( ( $sIcon = $this->oxcategories__oxicon->value ) ) {
00987             $oConfig = $this->getConfig();
00988             $sSize = $oConfig->getConfigParam( 'sCatIconsize' );
00989             if ( !isset( $sSize ) ) {
00990                 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00991             }
00992 
00993             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/icon/", $sIcon, $sSize );
00994         }
00995     }
00996 
01002     public function getThumbUrl()
01003     {
01004         if ( ( $sIcon = $this->oxcategories__oxthumb->value ) ) {
01005             $sSize = $this->getConfig()->getConfigParam( 'sCatThumbnailsize' );
01006             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/thumb/", $sIcon, $sSize );
01007         }
01008     }
01009 
01015     public function getPromotionIconUrl()
01016     {
01017         if ( ( $sIcon = $this->oxcategories__oxpromoicon->value ) ) {
01018             $sSize = $this->getConfig()->getConfigParam( 'sCatPromotionsize' );
01019             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/promo_icon/", $sIcon, $sSize );
01020         }
01021     }
01022 
01031     public function getPictureUrlForType( $sPicName, $sPicType )
01032     {
01033         if ( $sPicName ) {
01034             return $this->getPictureUrl() . $sPicType . '/' . $sPicName;
01035         } else {
01036             return false;
01037         }
01038     }
01039 
01045     public function isTopCategory()
01046     {
01047         if ( $this->_blTopCategory == null ) {
01048             $this->_blTopCategory = $this->oxcategories__oxparentid->value == 'oxrootid';
01049         }
01050         return $this->_blTopCategory;
01051     }
01052 
01058     public function isPriceCategory()
01059     {
01060         return (bool) ( $this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value );
01061     }
01062 
01069     public function getLongDesc()
01070     {
01071         if ( isset( $this->oxcategories__oxlongdesc ) && $this->oxcategories__oxlongdesc instanceof oxField ) {
01072            return oxRegistry::get("oxUtilsView")->parseThroughSmarty( $this->oxcategories__oxlongdesc->getRawValue(), $this->getId().$this->getLanguage() );
01073         }
01074     }
01075 
01081     public function getShortDescription()
01082     {
01083         return $this->oxcategories__oxdesc->value;
01084     }
01085 
01091     public function getTitle()
01092     {
01093         return $this->oxcategories__oxtitle->value;
01094     }
01095 }