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
00184
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
00268
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
00284 $blRet = parent::delete( $sOXID );
00285
00286 $sOxidQuoted = $oDb->quote( $sOXID );
00287
00288 $oDb->execute( "delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");
00289
00290
00291 $oDb->execute( "delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");
00292
00293
00294
00295 $oDb->execute( "delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
00296
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
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
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
00591 $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00592 }
00593
00594
00595 return $sUrl . "index.php?cl=alist" . ( $blAddId ? "&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
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
00753 if ( $this->oxcategories__oxparentid->value && $this->oxcategories__oxparentid->value != 'oxrootid' ) {
00754
00755
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
00817 $oParent = oxNew( "oxcategory" );
00818
00819 if ( !$oParent->load( $this->oxcategories__oxparentid->value) ) {
00820 return false;
00821 }
00822
00823 $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00824
00825
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
00838
00839
00840
00841 if ( !$this->getId() ) {
00842 $this->setId();
00843 }
00844
00845 $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW);
00846 $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW);
00847 $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW);
00848 return parent::_insert();
00849 } else {
00850
00851 if ( !$this->getId() ) {
00852 $this->setId();
00853 }
00854
00855 $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW);
00856 $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW);
00857 $this->oxcategories__oxright = new oxField(2, oxField::T_RAW);
00858 return parent::_insert();
00859 }
00860 }
00861
00867 protected function _update()
00868 {
00869
00870 $oDb = oxDb::getDb();
00871 $sOldParentID = $oDb->getOne( "select oxparentid from oxcategories where oxid = ".$oDb->quote( $this->getId() ), false, false );
00872
00873 if ( $this->_blIsSeoObject && $this->isAdmin() ) {
00874 oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00875 }
00876
00877 $blRes = parent::_update();
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888 if ( $this->oxcategories__oxparentid->value != $sOldParentID) {
00889 $sOldParentLeft = $this->oxcategories__oxleft->value;
00890 $sOldParentRight = $this->oxcategories__oxright->value;
00891
00892 $iTreeSize = $sOldParentRight-$sOldParentLeft+1;
00893
00894 $sNewRootID = $oDb->getOne( "select oxrootid from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00895
00896
00897 if ( $sNewRootID == "") {
00898
00899 $sNewRootID = $this->getId();
00900 }
00901
00902 $sNewParentLeft = $oDb->getOne( "select oxleft from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value), false, false);
00903
00904
00905
00906
00907
00908
00909 $iMoveAfter = $sNewParentLeft+1;
00910
00911
00912 if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) {
00913
00914
00915
00916 $sRestoreOld = "UPDATE oxcategories SET OXPARENTID = ".$oDb->quote($sOldParentID)." WHERE oxid = ".$oDb->quote($this->getId());
00917 $oDb->execute( $sRestoreOld );
00918 return false;
00919 }
00920
00921
00922 if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
00923 $sOldParentLeft += $iTreeSize;
00924 $sOldParentRight += $iTreeSize;
00925 }
00926
00927 $iDelta = $iMoveAfter-$sOldParentLeft;
00928
00929
00930
00931 $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value).";";
00932 $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = ".$oDb->quote($sNewRootID).";";
00933
00934
00935 $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iTreeSize.") WHERE OXLEFT >= ".$iMoveAfter.$sAddNew );
00936 $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT + ".$iTreeSize.") WHERE OXRIGHT >= ".$iMoveAfter.$sAddNew );
00937
00938
00939 $sChangeRootID = "";
00940 if ($this->oxcategories__oxrootid->value != $sNewRootID) {
00941
00942 $sChangeRootID = ", OXROOTID=".$oDb->quote($sNewRootID);
00943 }
00944
00945
00946 $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iDelta."), OXRIGHT = (OXRIGHT + ".$iDelta.") ".$sChangeRootID." WHERE OXLEFT >= ".$sOldParentLeft." AND OXRIGHT <= ".$sOldParentRight.$sAddOld );
00947
00948
00949
00950 $oDb->execute( "UPDATE oxcategories SET OXLEFT = (OXLEFT - ".$iTreeSize.") WHERE OXLEFT >= ".($sOldParentRight+1).$sAddOld );
00951 $oDb->execute( "UPDATE oxcategories SET OXRIGHT = (OXRIGHT - ".$iTreeSize.") WHERE OXRIGHT >= ".($sOldParentRight+1).$sAddOld );
00952
00953 }
00954
00955 if ( $blRes && $this->_blIsSeoObject && $this->isAdmin() ) {
00956 oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00957 }
00958
00959 return $blRes;
00960 }
00961
00971 protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00972 {
00973
00974 if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L') ) ) {
00975 if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
00976 $iDataType = oxField::T_RAW;
00977 }
00978 }
00979 return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00980 }
00981
00982
00988 public function getIconUrl()
00989 {
00990 if ( ( $sIcon = $this->oxcategories__oxicon->value ) ) {
00991 $oConfig = $this->getConfig();
00992 $sSize = $oConfig->getConfigParam( 'sCatIconsize' );
00993 if ( !isset( $sSize ) ) {
00994 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00995 }
00996
00997 return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/icon/", $sIcon, $sSize );
00998 }
00999 }
01000
01006 public function getThumbUrl()
01007 {
01008 if ( ( $sIcon = $this->oxcategories__oxthumb->value ) ) {
01009 $sSize = $this->getConfig()->getConfigParam( 'sCatThumbnailsize' );
01010 return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/thumb/", $sIcon, $sSize );
01011 }
01012 }
01013
01019 public function getPromotionIconUrl()
01020 {
01021 if ( ( $sIcon = $this->oxcategories__oxpromoicon->value ) ) {
01022 $sSize = $this->getConfig()->getConfigParam( 'sCatPromotionsize' );
01023 return oxRegistry::get("oxPictureHandler")->getPicUrl( "category/promo_icon/", $sIcon, $sSize );
01024 }
01025 }
01026
01035 public function getPictureUrlForType( $sPicName, $sPicType )
01036 {
01037 if ( $sPicName ) {
01038 return $this->getPictureUrl() . $sPicType . '/' . $sPicName;
01039 } else {
01040 return false;
01041 }
01042 }
01043
01049 public function isTopCategory()
01050 {
01051 if ( $this->_blTopCategory == null ) {
01052 $this->_blTopCategory = $this->oxcategories__oxparentid->value == 'oxrootid';
01053 }
01054 return $this->_blTopCategory;
01055 }
01056
01062 public function isPriceCategory()
01063 {
01064 return (bool) ( $this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value );
01065 }
01066
01073 public function getLongDesc()
01074 {
01075 if ( isset( $this->oxcategories__oxlongdesc ) && $this->oxcategories__oxlongdesc instanceof oxField ) {
01076 return oxRegistry::get("oxUtilsView")->parseThroughSmarty( $this->oxcategories__oxlongdesc->getRawValue(), $this->getId().$this->getLanguage() );
01077 }
01078 }
01079
01085 public function getShortDescription()
01086 {
01087 return $this->oxcategories__oxdesc->value;
01088 }
01089
01095 public function getTitle()
01096 {
01097 return $this->oxcategories__oxtitle->value;
01098 }
01099 }