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         $this->setUpdateSeo(true);
00867         $this->_setUpdateSeoOnFieldChange('oxtitle');
00868 
00869         $oDb = oxDb::getDb();
00870         $sOldParentID = $oDb->getOne( "select oxparentid from oxcategories where oxid = ".$oDb->quote( $this->getId() ), false, false );
00871 
00872         if ( $this->_blIsSeoObject && $this->isAdmin() ) {
00873             oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00874         }
00875 
00876         $blRes = parent::_update();
00877 
00878         // #872C - need to update category tree oxleft and oxright values (nested sets),
00879         // then sub trees are moved inside one root, or to another root.
00880         // this is done in 3 basic steps
00881         // 1. increase oxleft and oxright values of target root tree by $iTreeSize, where oxleft>=$iMoveAfter , oxright>=$iMoveAfter
00882         // 2. modify current subtree, we want to move by adding $iDelta to it's oxleft and oxright,  where oxleft>=$sOldParentLeft and oxright<=$sOldParentRight values,
00883         //    in this step we also modify rootid's if they were changed
00884         // 3. decreasing oxleft and oxright values of current root tree, where oxleft >= $sOldParentRight+1 , oxright >= $sOldParentRight+1
00885 
00886         // did we change position in tree ?
00887         if ( $this->oxcategories__oxparentid->value != $sOldParentID) {
00888             $sOldParentLeft = $this->oxcategories__oxleft->value;
00889             $sOldParentRight = $this->oxcategories__oxright->value;
00890 
00891             $iTreeSize = $sOldParentRight-$sOldParentLeft+1;
00892 
00893             $sNewRootID = $oDb->getOne( "select oxrootid from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00894 
00895             //If empty rootID, we set it to categorys oxid
00896             if ( $sNewRootID == "") {
00897                 //echo "<br>* ) Creating new root tree ( {$this->_sOXID} )";
00898                 $sNewRootID = $this->getId();
00899             }
00900 
00901             $sNewParentLeft = $oDb->getOne( "select oxleft from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00902 
00903             //if(!$sNewParentLeft){
00904                 //the current node has become root node, (oxrootid == "oxrootid")
00905             //    $sNewParentLeft = 0;
00906             //}
00907 
00908             $iMoveAfter = $sNewParentLeft+1;
00909 
00910             //New parentid can not be set to it's child
00911             if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) {
00912                 //echo "<br>* ) Can't asign category to it's child";
00913 
00914                 //Restoring old parentid, stoping further actions
00915                 $sRestoreOld = "UPDATE oxcategories SET OXPARENTID = ".$oDb->quote($sOldParentID)." WHERE oxid = ".$oDb->quote($this->getId());
00916                 $oDb->execute( $sRestoreOld );
00917                 return false;
00918             }
00919 
00920             //Old parent will be shifted too, if it is in the same tree
00921             if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
00922                 $sOldParentLeft += $iTreeSize;
00923                 $sOldParentRight += $iTreeSize;
00924             }
00925 
00926             $iDelta = $iMoveAfter-$sOldParentLeft;
00927 
00928             //echo "Size=$iTreeSize, NewStart=$iMoveAfter, delta=$iDelta";
00929 
00930             $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value).";";
00931             $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($sNewRootID).";";
00932 
00933             //Updating everything after new position
00934             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iTreeSize.") WHERE OXLEFT >= ".$iMoveAfter.$sAddNew );
00935             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT + ".$iTreeSize.") WHERE OXRIGHT >= ".$iMoveAfter.$sAddNew );
00936             //echo "<br>1.) + $iTreeSize, >= $iMoveAfter";
00937 
00938             $sChangeRootID = "";
00939             if ($this->oxcategories__oxrootid->value != $sNewRootID) {
00940                 //echo "<br>* ) changing root IDs ( {$this->oxcategories__oxrootid->value} -> {$sNewRootID} )";
00941                 $sChangeRootID = ", OXROOTID=".$oDb->quote($sNewRootID);
00942             }
00943 
00944             //Updating subtree
00945             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iDelta."), OXRIGHT = (OXRIGHT + ".$iDelta.") ".$sChangeRootID." WHERE OXLEFT >= ".$sOldParentLeft." AND OXRIGHT <= ".$sOldParentRight.$sAddOld );
00946             //echo "<br>2.) + $iDelta, >= $sOldParentLeft and <= $sOldParentRight";
00947 
00948             //Updating everything after old position
00949             $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT - ".$iTreeSize.") WHERE OXLEFT >=   ".($sOldParentRight+1).$sAddOld );
00950             $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT - ".$iTreeSize.") WHERE OXRIGHT >=   ".($sOldParentRight+1).$sAddOld );
00951             //echo "<br>3.) - $iTreeSize, >= ".($sOldParentRight+1);
00952         }
00953 
00954         if ( $blRes && $this->_blIsSeoObject && $this->isAdmin() ) {
00955             oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00956         }
00957 
00958         return $blRes;
00959     }
00960 
00970     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00971     {
00972         //preliminary quick check saves 3% of execution time in category lists by avoiding redundant strtolower() call
00973         if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L') ) ) {
00974             if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
00975                 $iDataType = oxField::T_RAW;
00976             }
00977         }
00978         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00979     }
00980 
00981 
00987     public function getIconUrl()
00988     {
00989         if ( ( $sIcon = $this->oxcategories__oxicon->value ) ) {
00990             $oConfig = $this->getConfig();
00991             $sSize = $oConfig->getConfigParam( 'sCatIconsize' );
00992             if ( !isset( $sSize ) ) {
00993                 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00994             }
00995 
00996             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/icon/", $sIcon, $sSize );
00997         }
00998     }
00999 
01005     public function getThumbUrl()
01006     {
01007         if ( ( $sIcon = $this->oxcategories__oxthumb->value ) ) {
01008             $sSize = $this->getConfig()->getConfigParam( 'sCatThumbnailsize' );
01009             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/thumb/", $sIcon, $sSize );
01010         }
01011     }
01012 
01018     public function getPromotionIconUrl()
01019     {
01020         if ( ( $sIcon = $this->oxcategories__oxpromoicon->value ) ) {
01021             $sSize = $this->getConfig()->getConfigParam( 'sCatPromotionsize' );
01022             return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/promo_icon/", $sIcon, $sSize );
01023         }
01024     }
01025 
01034     public function getPictureUrlForType( $sPicName, $sPicType )
01035     {
01036         if ( $sPicName ) {
01037             return $this->getPictureUrl() . $sPicType . '/' . $sPicName;
01038         } else {
01039             return false;
01040         }
01041     }
01042 
01048     public function isTopCategory()
01049     {
01050         if ( $this->_blTopCategory == null ) {
01051             $this->_blTopCategory = $this->oxcategories__oxparentid->value == 'oxrootid';
01052         }
01053         return $this->_blTopCategory;
01054     }
01055 
01061     public function isPriceCategory()
01062     {
01063         return (bool) ( $this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value );
01064     }
01065 
01072     public function getLongDesc()
01073     {
01074         if ( isset( $this->oxcategories__oxlongdesc ) && $this->oxcategories__oxlongdesc instanceof oxField ) {
01075            return oxRegistry::get("oxUtilsView")->parseThroughSmarty( $this->oxcategories__oxlongdesc->getRawValue(), $this->getId().$this->getLanguage(), null, true );
01076         }
01077     }
01078 
01084     public function getShortDescription()
01085     {
01086         return $this->oxcategories__oxdesc->value;
01087     }
01088 
01094     public function getTitle()
01095     {
01096         return $this->oxcategories__oxtitle->value;
01097     }
01098 }