oxcategory.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class oxCategory extends oxI18n
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 
00096     public function __construct()
00097     {
00098         parent::__construct();
00099         $this->init( 'oxcategories' );
00100     }
00101 
00109     public function __get( $sName )
00110     {
00111         switch ( $sName ) {
00112             case 'aSubCats':
00113                 return $this->_aSubCats;
00114 
00115             case 'aContent':
00116                 return $this->_aContentCats;
00117 
00118             case 'iArtCnt':
00119                 return $this->getNrOfArticles();
00120 
00121             case 'isVisible':
00122                 return $this->getIsVisible();
00123 
00124             case 'expanded':
00125                 return $this->getExpanded();
00126 
00127             case 'hasSubCats':
00128                 return $this->getHasSubCats();
00129 
00130             case 'hasVisibleSubCats':
00131                 return $this->getHasVisibleSubCats();
00132 
00133             case 'openlink':
00134             case 'closelink':
00135             case 'link':
00136                 //case 'toListLink':
00137                 //case 'noparamlink':
00138                 return $this->getLink();
00139             case 'dimagedir':
00140                 return $this->getPictureUrl();
00141             }
00142         return parent::__get($sName);
00143     }
00144 
00152     public function assign( $dbRecord )
00153     {
00154 
00155         parent::assign( $dbRecord );
00156 
00157         // #1030C run through smarty
00158         $myConfig = $this->getConfig();
00159         if ( !$this->isAdmin() && $myConfig->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00160             $this->oxcategories__oxlongdesc = new oxField( oxUtilsView::getInstance()->parseThroughSmarty( $this->oxcategories__oxlongdesc->value, $this->getId() ), oxField::T_RAW );
00161         }
00162 
00163         if ( !$this->isAdmin() && ( $myConfig->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) || $myConfig->getConfigParam('blDontShowEmptyCategories')  ) ) {
00164             if ( $this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value ) {
00165                 $this->_iNrOfArticles = oxUtilsCount::getInstance()->getPriceCatArticleCount( $this->getId(), $this->oxcategories__oxpricefrom->value, $this->oxcategories__oxpriceto->value );
00166             } else {
00167                 $this->_iNrOfArticles = oxUtilsCount::getInstance()->getCatArticleCount( $this->getId() );
00168             }
00169         }
00170     }
00171 
00179     public function delete( $sOXID = null)
00180     {
00181         if ( !$this->getId() ) {
00182             $this->load( $sOXID);
00183         }
00184 
00185 
00186         $myConfig = $this->getConfig();
00187         $oDB      = oxDb::getDb();
00188         $blRet    = false;
00189 
00190         if ( $this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value+1) ) {
00191             // only delete empty categories
00192             // #1173M - not all pic are deleted, after article is removed
00193             oxUtilsPic::getInstance()->safePictureDelete($this->oxcategories__oxthumb->value, $myConfig->getAbsDynImageDir().'/0', 'oxcategories', 'oxthumb' );
00194 
00195             oxUtilsPic::getInstance()->safePictureDelete($this->oxcategories__oxicon->value, $myConfig->getAbsDynImageDir().'/icon', 'oxcategories', 'oxicon' );
00196 
00197             $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00198 
00199             $oDB->execute( "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
00200                             WHERE  OXROOTID = '".$this->oxcategories__oxrootid->value."'
00201                             AND OXLEFT >   ".$this->oxcategories__oxleft->value.$sAdd );
00202 
00203             $oDB->execute( "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
00204                             WHERE  OXROOTID = '".$this->oxcategories__oxrootid->value."'
00205                             AND OXRIGHT >   ".$this->oxcategories__oxright->value.$sAdd );
00206 
00207             // delete entry
00208             $blRet = parent::delete();
00209 
00210             // delete links to articles
00211             $oDB->execute( "delete from oxobject2category where oxobject2category.oxcatnid='".$this->oxcategories__oxid->value."' ");
00212 
00213             // #657 ADDITIONAL delete links to attributes
00214             $oDB->execute( "delete from oxcategory2attribute where oxcategory2attribute.oxobjectid='".$this->oxcategories__oxid->value."' ");
00215 
00216             // A. removing assigned:
00217             // - deliveries
00218             $oDB->execute( "delete from oxobject2delivery where oxobject2delivery.oxobjectid='".$this->oxcategories__oxid->value."' ");
00219             // - discounts
00220             $oDB->execute( "delete from oxobject2discount where oxobject2discount.oxobjectid='".$this->oxcategories__oxid->value."' ");
00221         }
00222         return $blRet;
00223     }
00224 
00230     public function getSubCats()
00231     {
00232         return $this->_aSubCats;
00233     }
00234 
00242     public function getSubCat($sKey)
00243     {
00244         return $this->_aSubCats[$sKey];
00245     }
00246 
00254     public function setSubCats( $aCats )
00255     {
00256         $this->_aSubCats = $aCats;
00257 
00258         foreach ( $aCats as $oCat ) {
00259             if ( $oCat->getIsVisible() ) {
00260                 $this->setHasVisibleSubCats( true );
00261             }
00262         }
00263 
00264         $this->sortSubCats();
00265     }
00266 
00275     public function setSubCat($oCat, $sKey=null)
00276     {
00277         if ( $sKey ) {
00278             $this->_aSubCats[$sKey] = $oCat;
00279         } else {
00280             $this->_aSubCats[] = $oCat;
00281         }
00282 
00283         // keeping ref. to parent
00284         $oCat->setParentCategory( $this );
00285 
00286         if ( $oCat->getIsVisible() ) {
00287             $this->setHasVisibleSubCats( true );
00288         }
00289 
00290         $this->sortSubCats();
00291     }
00292 
00298     public function sortSubCats()
00299     {
00300         uasort( $this->_aSubCats, array( $this, "cmpCat" ) );
00301     }
00302 
00308     public function getContentCats()
00309     {
00310         return $this->_aContentCats;
00311     }
00312 
00320     public function setContentCats( $aContent )
00321     {
00322         $this->_aContentCats = $aContent;
00323     }
00324 
00333     public function setContentCat( $oContent, $sKey=null )
00334     {
00335         if ( $sKey ) {
00336             $this->_aContentCats[$sKey] = $oContent;
00337         } else {
00338             $this->_aContentCats[] = $oContent;
00339         }
00340     }
00341 
00350     public function cmpCat( $a,$b )
00351     {
00352         if ( $a->oxcategories__oxsort->value == $b->oxcategories__oxsort->value ) {
00353             return strcasecmp( $a->oxcategories__oxtitle->value, $b->oxcategories__oxtitle->value );
00354         }
00355 
00356         return $a->oxcategories__oxsort->value - $b->oxcategories__oxsort->value;
00357     }
00358 
00364     public function getNrOfArticles()
00365     {
00366         if ( !$this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) && $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00367             return 0;
00368         }
00369 
00370         return $this->_iNrOfArticles;
00371     }
00372 
00380     public function setNrOfArticles( $iNum )
00381     {
00382         $this->_iNrOfArticles = $iNum;
00383     }
00384 
00390     public function getIsVisible()
00391     {
00392         if (!isset( $this->_blIsVisible ) ) {
00393 
00394             if ( $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00395                 $blEmpty = ($this->_iNrOfArticles < 1) && !$this->getHasVisibleSubCats();
00396             } else {
00397                 $blEmpty = false;
00398             }
00399 
00400             $this->_blIsVisible = !($blEmpty || $this->oxcategories__oxhidden->value);
00401         }
00402 
00403         return $this->_blIsVisible;
00404     }
00405 
00413     public function setIsVisible( $blVisible )
00414     {
00415         $this->_blIsVisible = $blVisible;
00416     }
00417 
00423     public function getPictureUrl()
00424     {
00425         if ( $this->_sDynImageDir === null ) {
00426             $sThisShop = $this->oxcategories__oxshopid->value;
00427             $this->_sDynImageDir = $this->getConfig()->getPictureUrl( null, false, null, null, $sThisShop);
00428         }
00429         return $this->_sDynImageDir;
00430     }
00431 
00439     public function getLink($iLang = null)
00440     {
00441         if (isset($iLang)) {
00442             $iLang = (int) $iLang;
00443             if ($iLang == (int) $this->getLanguage()) {
00444                 $iLang = null;
00445             }
00446         }
00447         if ( ($this->link === null ) || isset($iLang)) {
00448             if ( (!isset( $this->oxcategories__oxextlink->value ) || !$this->oxcategories__oxextlink->value ) &&
00449                  oxUtils::getInstance()->seoIsActive() ) {
00450                 $link = oxSeoEncoderCategory::getInstance()->getCategoryUrl( $this, $iLang );
00451             } else {
00452                 $link = $this->getStdLink($iLang);
00453             }
00454 
00455             if (isset($iLang)) {
00456                 return $link;
00457             } else {
00458                 $this->link = $link;
00459             }
00460         }
00461 
00462         return $this->link;
00463     }
00464 
00472     public function setLink( $sLink )
00473     {
00474         $this->link = $sLink;
00475     }
00476 
00484     public function getSqlActiveSnippet( $blForceCoreTable = false )
00485     {
00486             $sTable = $this->getCoreTableName();
00487 
00488         $sQ  = parent::getSqlActiveSnippet( $blForceCoreTable );
00489         $sQ .= ( strlen( $sQ )? ' and ' : '' ) . " $sTable.oxhidden = '0' ";
00490 
00491 
00492         return "( $sQ ) ";
00493     }
00494 
00502     public function getStdLink($iLang = null)
00503     {
00504         $sLink = '';
00505         if ( $this->oxcategories__oxextlink->value ) {
00506             return $this->getSession()->url( $this->oxcategories__oxextlink->value );
00507         } else {
00508             $sLink = $this->getConfig()->getShopHomeURL(). "cl=alist&amp;cnid=" . $this->getId();
00509         }
00510 
00511         if ( isset($iLang) && !oxUtils::getInstance()->seoIsActive() ) {
00512             $iLang = (int) $iLang;
00513             if ($iLang != (int) $this->getLanguage()) {
00514                 $sLink .= "&amp;lang={$iLang}";
00515             }
00516         }
00517 
00518         return $sLink;
00519     }
00520 
00526     public function getExpanded()
00527     {
00528         if ( !isset( $this->_blExpanded ) ) {
00529             $myConfig = $this->getConfig();
00530             $this->_blExpanded = ( $myConfig->getConfigParam( 'blLoadFullTree' ) && !$myConfig->getConfigParam( 'blTopNaviLayout' ) );
00531         }
00532 
00533         return $this->_blExpanded;
00534     }
00535 
00543     public function setExpanded( $blExpanded )
00544     {
00545         $this->_blExpanded = $blExpanded;
00546     }
00547 
00553     public function getHasSubCats()
00554     {
00555         if ( !isset( $this->_blHasSubCats ) ) {
00556             $this->_blHasSubCats = $this->oxcategories__oxright->value > $this->oxcategories__oxleft->value + 1 ;
00557         }
00558 
00559         return $this->_blHasSubCats;
00560     }
00561 
00567     public function getHasVisibleSubCats()
00568     {
00569         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00570             $this->_blHasVisibleSubCats = false;
00571         }
00572 
00573         return $this->_blHasVisibleSubCats;
00574     }
00575 
00583     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00584     {
00585         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00586     }
00587 
00593     public function getAttributes()
00594     {
00595         $sActCat        = $this->sOXID;
00596         $aAttributes    = array();
00597         $blActiveFilter = false;
00598 
00599         $aSessionFilter = oxSession::getVar( 'session_attrfilter' );
00600 
00601         $oArtList = oxNew( "oxarticlelist");
00602         $oArtList->loadCategoryIDs( $sActCat, $aSessionFilter );
00603 
00604         // Only if we have articles
00605         if (count($oArtList) > 0 ) {
00606             $sArtIds = implode("','", array_keys($oArtList->getArray()) );
00607             $sAttTbl = getViewName('oxattribute');
00608             $sO2ATbl = getViewName('oxobject2attribute');
00609             $sC2ATbl = getViewName('oxcategory2attribute');
00610             $sLngSuf = oxLang::getInstance()->getLanguageTag($this->getLanguage());
00611 
00612             $sSelect = "SELECT DISTINCT att.oxid, att.oxtitle{$sLngSuf}, o2a.oxvalue, o2a.oxvalue{$sLngSuf} ".
00613                        "FROM $sAttTbl as att, $sO2ATbl as o2a ,$sC2ATbl as c2a ".
00614                        "WHERE att.oxid = o2a.oxattrid AND c2a.oxobjectid = '{$sActCat}' AND c2a.oxattrid = att.oxid AND o2a.oxvalue{$sLngSuf} !='' AND o2a.oxobjectid IN ('$sArtIds') ".
00615                        "ORDER BY c2a.oxsort , att.oxpos, att.oxtitle{$sLngSuf}, o2a.oxvalue{$sLngSuf}";
00616 
00617             $rs = oxDb::getDb()->Execute( $sSelect);
00618             if ($rs != false && $rs->recordCount() > 0) {
00619                 while ( !$rs->EOF && list($sAttId,$sAttTitle,$sAttVid,$sAttValue) = $rs->fields ) {
00620                     if ( !isset( $aAttributes[$sAttId])) {
00621                         $oAttribute           = new stdClass();
00622                         $oAttribute->title    = $sAttTitle;
00623                         $oAttribute->aValues  = array();
00624                         $aAttributes[$sAttId] = $oAttribute;
00625                     }
00626                     $oValue             = new stdClass();
00627                     $oValue->id         = htmlspecialchars($sAttValue);
00628                     $oValue->value      = htmlspecialchars($sAttValue);
00629                     $oValue->blSelected = isset($aSessionFilter[$sActCat][$sAttId]) && $aSessionFilter[$sActCat][$sAttId] == $sAttValue;
00630 
00631                     $blActiveFilter = $blActiveFilter || $oValue->blSelected;
00632                     $aAttributes[$sAttId]->aValues[$sAttVid] = $oValue;
00633                     $rs->moveNext();
00634                 }
00635             }
00636 
00637         }
00638 
00639         if ( is_array($aSessionFilter[$sActCat]) && !$blActiveFilter ) {
00640             oxSession::setVar( "session_attrfilter", false);
00641         }
00642         return $aAttributes;
00643     }
00644 
00652     public function getCatInLang( $oActCategory = null )
00653     {
00654         $oCategoryInDefaultLanguage= oxNew( "oxcategory" );
00655         if ( $this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value) {
00656             // get it in base language
00657             $oCategoryInDefaultLanguage= oxNew( "oxcategory" );
00658             $oCategoryInDefaultLanguage->loadInLang( 0, $this->getId());
00659         } else {
00660             $oCategoryInDefaultLanguage= oxNew( "oxcategory" );
00661             $oCategoryInDefaultLanguage->loadInLang( 0, $oActCategory->getId());
00662         }
00663         return $oCategoryInDefaultLanguage;
00664     }
00665 
00673     public function setParentCategory( $oCategory )
00674     {
00675         $this->_oParent = $oCategory;
00676     }
00677 
00683     public function getParentCategory()
00684     {
00685         $oCat = null;
00686 
00687         // loading only if parent id is not rootid
00688         if ( $this->oxcategories__oxparentid->value && $this->oxcategories__oxparentid->value != 'oxrootid' ) {
00689 
00690             // checking if object itself has ref to parent
00691             if ( $this->_oParent ) {
00692                 $oCat = $this->_oParent;
00693             } else {
00694                 $oCat = oxNew( 'oxcategory' );
00695                 if ( !$oCat->loadInLang( $this->getLanguage(), $this->oxcategories__oxparentid->value ) ) {
00696                     $oCat = null;
00697                 }
00698             }
00699         }
00700         return $oCat;
00701     }
00702 
00710     public static function getRootId($sCategoryId)
00711     {
00712         if ( !isset( $sCategoryId ) ) {
00713             return;
00714         }
00715 
00716         return oxDb::getDb()->getOne( 'select oxrootid from '.getViewName('oxcategories').' where oxid = ?', array( $sCategoryId ) );
00717     }
00718 
00719 
00727     public function assignViewableRecord($sSelect)
00728     {
00729             if ( $this->assignRecord( $sSelect ) ) {
00730                 return  true;
00731             }
00732 
00733 
00734         return false;
00735     }
00736 
00742     protected function _insert()
00743     {
00744 
00745 
00746         if ( $this->oxcategories__oxparentid->value != "oxrootid") {
00747             // load parent
00748 
00749             $oParent = oxNew( "oxcategory" );
00750             //#M317 check if parent is loaded
00751             if ( !$oParent->load( $this->oxcategories__oxparentid->value) ) {
00752                 return false;
00753             }
00754 
00755             $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00756 
00757             // update existing nodes
00758             $oDB = oxDb::getDb();
00759             $oDB->execute( "UPDATE oxcategories SET OXLEFT = OXLEFT + 2
00760                             WHERE  OXROOTID = '".$oParent->oxcategories__oxrootid->value."'
00761                             AND OXLEFT >   ".$oParent->oxcategories__oxright->value."
00762                             AND OXRIGHT >= ".$oParent->oxcategories__oxright->value.$sAdd);
00763 
00764 
00765             $oDB->execute( "UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2
00766                             WHERE  OXROOTID = '".$oParent->oxcategories__oxrootid->value."'
00767                             AND OXRIGHT >= ".$oParent->oxcategories__oxright->value.$sAdd );
00768 
00769             //if ( !isset( $this->_sOXID) || trim( $this->_sOXID) == "")
00770             //    $this->_sOXID = oxUtilsObject::getInstance()->generateUID();
00771             //$this->oxcategories__oxid->setValue($this->_sOXID);
00772             //refactored to:
00773             if ( !$this->getId() ) {
00774                 $this->setId();
00775             }
00776 
00777             $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW);
00778             $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW);
00779             $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW);
00780             return parent::_insert();
00781         } else {
00782             // root entry
00783             if ( !$this->getId() ) {
00784                 $this->setId();
00785             }
00786 
00787             $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW);
00788             $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW);
00789             $this->oxcategories__oxright = new oxField(2, oxField::T_RAW);
00790             return parent::_insert();
00791         }
00792     }
00793 
00799     protected function _update()
00800     {
00801 
00802         $oDB = oxDb::getDb();
00803 
00804         $sOldParentID = $oDB->getOne( "select oxparentid from oxcategories where oxid = '".$this->getId()."'");
00805 
00806         if ( $this->_blIsSeoObject && $this->isAdmin() ) {
00807             oxSeoEncoderCategory::getInstance()->markRelatedAsExpired($this);
00808         }
00809 
00810         $blRes = parent::_update();
00811 
00812         // #872C - need to update category tree oxleft and oxright values (nested sets),
00813         // then sub trees are moved inside one root, or to another root.
00814         // this is done in 3 basic steps
00815         // 1. increase oxleft and oxright values of target root tree by $iTreeSize, where oxleft>=$iMoveAfter , oxright>=$iMoveAfter
00816         // 2. modify current subtree, we want to move by adding $iDelta to it's oxleft and oxright,  where oxleft>=$sOldParentLeft and oxright<=$sOldParentRight values,
00817         //    in this step we also modify rootid's if they were changed
00818         // 3. decreasing oxleft and oxright values of current root tree, where oxleft >= $sOldParentRight+1 , oxright >= $sOldParentRight+1
00819 
00820         // did we change position in tree ?
00821         if ( $this->oxcategories__oxparentid->value != $sOldParentID) {
00822             $sOldParentLeft = $this->oxcategories__oxleft->value;
00823             $sOldParentRight = $this->oxcategories__oxright->value;
00824 
00825             $iTreeSize = $sOldParentRight-$sOldParentLeft+1;
00826 
00827             $sNewRootID = $oDB->getOne( "select oxrootid from oxcategories where oxid = '".$this->oxcategories__oxparentid->value."'");
00828 
00829             //If empty rootID, we set it to categorys oxid
00830             if ( $sNewRootID == "") {
00831                 //echo "<br>* ) Creating new root tree ( {$this->_sOXID} )";
00832                 $sNewRootID = $this->getId();
00833             }
00834 
00835             $sNewParentLeft = $oDB->getOne( "select oxleft from oxcategories where oxid = '".$this->oxcategories__oxparentid->value."'");
00836 
00837             //if(!$sNewParentLeft){
00838                 //the current node has become root node, (oxrootid == "oxrootid")
00839             //    $sNewParentLeft = 0;
00840             //}
00841 
00842             $iMoveAfter = $sNewParentLeft+1;
00843 
00844 
00845             //New parentid can not be set to it's child
00846             if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) {
00847                 //echo "<br>* ) Can't asign category to it's child";
00848 
00849                 //Restoring old parentid, stoping further actions
00850                 $sRestoreOld = "UPDATE oxcategories SET OXPARENTID = '".$sOldParentID."' WHERE oxid = '".$this->getId()."'";
00851                 $oDB->execute( $sRestoreOld );
00852                 return false;
00853             }
00854 
00855             //Old parent will be shifted too, if it is in the same tree
00856             if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
00857                 $sOldParentLeft += $iTreeSize;
00858                 $sOldParentRight += $iTreeSize;
00859             }
00860 
00861             $iDelta = $iMoveAfter-$sOldParentLeft;
00862 
00863             //echo "Size=$iTreeSize, NewStart=$iMoveAfter, delta=$iDelta";
00864 
00865             $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = '".$this->oxcategories__oxrootid->value."';";
00866             $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = '".$sNewRootID."';";
00867 
00868             //Updating everything after new position
00869             $oDB->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iTreeSize.") WHERE OXLEFT >= ".$iMoveAfter.$sAddNew );
00870             $oDB->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT + ".$iTreeSize.") WHERE OXRIGHT >= ".$iMoveAfter.$sAddNew );
00871             //echo "<br>1.) + $iTreeSize, >= $iMoveAfter";
00872 
00873             $sChangeRootID = "";
00874             if ($this->oxcategories__oxrootid->value != $sNewRootID) {
00875                 //echo "<br>* ) changing root IDs ( {$this->oxcategories__oxrootid->value} -> {$sNewRootID} )";
00876                 $sChangeRootID = ", OXROOTID='$sNewRootID'";
00877             }
00878 
00879             //Updating subtree
00880             $oDB->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iDelta."), OXRIGHT = (OXRIGHT + ".$iDelta.") ".$sChangeRootID." WHERE OXLEFT >= ".$sOldParentLeft." AND OXRIGHT <= ".$sOldParentRight.$sAddOld );
00881             //echo "<br>2.) + $iDelta, >= $sOldParentLeft and <= $sOldParentRight";
00882 
00883             //Updating everything after old position
00884             $oDB->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT - ".$iTreeSize.") WHERE OXLEFT >=   ".($sOldParentRight+1).$sAddOld );
00885             $oDB->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT - ".$iTreeSize.") WHERE OXRIGHT >=   ".($sOldParentRight+1).$sAddOld );
00886             //echo "<br>3.) - $iTreeSize, >= ".($sOldParentRight+1);
00887         }
00888 
00889         if ( $blRes && $this->_blIsSeoObject && $this->isAdmin() ) {
00890             oxSeoEncoderCategory::getInstance()->markRelatedAsExpired($this);
00891         }
00892 
00893         return $blRes;
00894     }
00895 
00905     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00906     {
00907         //preliminar quick check saves 3% of execution time in category lists by avoiding redundant strtolower() call
00908         if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L') ) ) {
00909             if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
00910                 $iDataType = oxField::T_RAW;
00911             }
00912         }
00913         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00914     }
00915 
00916 
00922     public function getIconUrl()
00923     {
00924         return $this->getConfig()->getPictureUrl( 'icon/'.$this->oxcategories__oxicon->value );
00925     }
00926 
00932     public function isTopCategory()
00933     {
00934         if ( $this->_blTopCategory == null ) {
00935             $this->_blTopCategory = $this->oxcategories__oxparentid->value == 'oxrootid';
00936         }
00937         return $this->_blTopCategory;
00938     }
00939 }

Generated on Thu Feb 19 15:02:22 2009 for OXID eShop CE by  doxygen 1.5.5