126 $this->
init(
'oxcategories' );
136 return $this->oxcategories__oxdefsort->value;
146 return $this->oxcategories__oxdefsortmode->value;
177 case 'hasVisibleSubCats':
239 $this->_iNrOfArticles = null;
250 public function delete( $sOXID = null )
252 if ( !$this->
getId() ) {
253 $this->
load( $sOXID );
256 $sOXID = isset( $sOXID ) ? $sOXID : $this->
getId();
263 if ( $this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value+1) ) {
269 $myUtilsPic->safePictureDelete( $this->oxcategories__oxthumb->value, $sDir .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
'TC'),
'oxcategories',
'oxthumb' );
270 $myUtilsPic->safePictureDelete( $this->oxcategories__oxicon->value, $sDir .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
'CICO'),
'oxcategories',
'oxicon' );
271 $myUtilsPic->safePictureDelete( $this->oxcategories__oxpromoicon->value, $sDir .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
'PICO'),
'oxcategories',
'oxpromoicon' );
273 $sAdd =
" and oxshopid = '" . $this->
getShopId() .
"' ";
275 $oDb->execute(
"UPDATE oxcategories SET OXLEFT = OXLEFT - 2
276 WHERE OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value).
"
277 AND OXLEFT > ".((int) $this->oxcategories__oxleft->value).$sAdd );
279 $oDb->execute(
"UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
280 WHERE OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value).
"
281 AND OXRIGHT > ".((int) $this->oxcategories__oxright->value).$sAdd );
286 $sOxidQuoted = $oDb->quote( $sOXID );
288 $oDb->execute(
"delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");
291 $oDb->execute(
"delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");
295 $oDb->execute(
"delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
297 $oDb->execute(
"delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted ");
324 return $this->_aSubCats[$sKey];
336 $this->_aSubCats = $aCats;
338 foreach ( $aCats as $oCat ) {
341 $oCat->setParentCategory( $this );
343 if ( $oCat->getIsVisible() ) {
360 $this->_aSubCats[$sKey] = $oCat;
362 $this->_aSubCats[] = $oCat;
366 $oCat->setParentCategory( $this );
368 if ( $oCat->getIsVisible() ) {
392 $this->_aContentCats = $aContent;
406 $this->_aContentCats[$sKey] = $oContent;
408 $this->_aContentCats[] = $oContent;
421 if ( !isset($this->_iNrOfArticles)
424 $myConfig->getConfigParam(
'bl_perfShowActionCatArticleCnt' )
425 ||
$myConfig->getConfigParam(
'blDontShowEmptyCategories')
429 $this->_iNrOfArticles =
oxRegistry::get(
"oxUtilsCount")->getPriceCatArticleCount( $this->
getId(), $this->oxcategories__oxpricefrom->value, $this->oxcategories__oxpriceto->value );
447 $this->_iNrOfArticles = $iNum;
457 if (!isset( $this->_blIsVisible ) ) {
459 if ( $this->
getConfig()->getConfigParam(
'blDontShowEmptyCategories' ) ) {
465 $this->_blIsVisible = !($blEmpty || $this->oxcategories__oxhidden->value);
480 $this->_blIsVisible = $blVisible;
490 if ( $this->_sDynImageDir === null ) {
491 $sThisShop = $this->oxcategories__oxshopid->value;
492 $this->_sDynImageDir = $this->
getConfig()->getPictureUrl( null,
false, null, null, $sThisShop);
509 return $oEncoder->getCategoryUrl( $this, $iLang );
511 return $oEncoder->getCategoryPageUrl( $this, $iPage, $iLang );
524 ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) ) {
528 if ( $iLang === null ) {
532 if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
535 return $this->_aSeoUrls[$iLang];
549 $this->_aSeoUrls[$iLang] = $sLink;
551 $this->_aStdUrls[$iLang] = $sLink;
567 $sQ .= ( strlen( $sQ )?
' and ' :
'' ) .
" $sTable.oxhidden = '0' ";
584 if ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) {
585 return $this->oxcategories__oxextlink->value;
591 $sUrl = $this->
getConfig()->getShopUrl( $iLang,
false );
595 return $sUrl .
"index.php?cl=alist" . ( $blAddId ?
"&cnid=".$this->getId() :
"" );
606 public function getStdLink( $iLang = null, $aParams = array() )
608 if ( isset( $this->oxcategories__oxextlink ) && $this->oxcategories__oxextlink->value ) {
609 return oxRegistry::get(
"oxUtilsUrl")->processUrl( $this->oxcategories__oxextlink->value,
false );
612 if ( $iLang === null ) {
616 if ( !isset( $this->_aStdUrls[$iLang] ) ) {
620 return oxRegistry::get(
"oxUtilsUrl")->processUrl( $this->_aStdUrls[$iLang],
true, $aParams, $iLang );
642 $this->_blExpanded = $blExpanded;
652 if ( !isset( $this->_blHasSubCats ) ) {
653 $this->_blHasSubCats = $this->oxcategories__oxright->value > $this->oxcategories__oxleft->value + 1 ;
666 if ( !isset( $this->_blHasVisibleSubCats ) ) {
667 $this->_blHasVisibleSubCats =
false;
682 if ( $blHasVisibleSubcats && !$this->_blHasVisibleSubCats ) {
683 unset( $this->_blIsVisible );
685 $this->_oParent->setHasVisibleSubCats(
true );
688 $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
698 $sActCat = $this->
getId();
700 $sKey = md5( $sActCat . serialize(
oxSession::getVar(
'session_attrfilter' ) ) );
701 if ( !isset( self::$_aCatAttributes[$sKey] ) ) {
702 $oAttrList =
oxNew(
"oxAttributeList" );
703 $oAttrList->getCategoryAttributes( $sActCat, $this->
getLanguage() );
704 self::$_aCatAttributes[$sKey] = $oAttrList;
707 return self::$_aCatAttributes[$sKey];
719 $oCategoryInDefaultLanguage=
oxNew(
"oxCategory" );
722 $oCategoryInDefaultLanguage=
oxNew(
"oxCategory" );
723 $oCategoryInDefaultLanguage->loadInLang( 0, $this->
getId());
725 $oCategoryInDefaultLanguage=
oxNew(
"oxCategory" );
726 $oCategoryInDefaultLanguage->loadInLang( 0, $oActCategory->getId());
728 return $oCategoryInDefaultLanguage;
740 $this->_oParent = $oCategory;
753 if ( $this->oxcategories__oxparentid->value && $this->oxcategories__oxparentid->value !=
'oxrootid' ) {
756 if ( $this->_oParent ) {
759 $oCat =
oxNew(
'oxCategory' );
760 if ( !$oCat->load( $this->oxcategories__oxparentid->value ) ) {
763 $this->_oParent = $oCat;
779 if ( !isset( $sCategoryId ) ) {
784 return $oDb->getOne(
'select oxrootid from '.
getViewName(
'oxcategories').
' where oxid = ' . $oDb->quote( $sCategoryId ) );
815 if ( $this->oxcategories__oxparentid->value !=
"oxrootid") {
817 $oParent =
oxNew(
"oxCategory" );
819 if ( !$oParent->load( $this->oxcategories__oxparentid->value) ) {
823 $sAdd =
" and oxshopid = '" . $this->
getShopId() .
"' ";
827 $oDb->execute(
"UPDATE oxcategories SET OXLEFT = OXLEFT + 2
828 WHERE OXROOTID = ".$oDb->quote($oParent->oxcategories__oxrootid->value).
"
829 AND OXLEFT > ".((int) $oParent->oxcategories__oxright->value).
"
830 AND OXRIGHT >= ".((int) $oParent->oxcategories__oxright->value).$sAdd);
833 $oDb->execute(
"UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2
834 WHERE OXROOTID = ".$oDb->quote($oParent->oxcategories__oxrootid->value).
"
835 AND OXRIGHT >= ".((int) $oParent->oxcategories__oxright->value).$sAdd );
837 if ( !$this->
getId() ) {
841 $this->oxcategories__oxrootid =
new oxField($oParent->oxcategories__oxrootid->value,
oxField::T_RAW);
843 $this->oxcategories__oxright =
new oxField($oParent->oxcategories__oxright->value + 1,
oxField::T_RAW);
847 if ( !$this->
getId() ) {
870 $sOldParentID = $oDb->getOne(
"select oxparentid from oxcategories where oxid = ".$oDb->quote( $this->getId() ),
false,
false );
872 if ( $this->_blIsSeoObject && $this->
isAdmin() ) {
887 if ( $this->oxcategories__oxparentid->value != $sOldParentID) {
888 $sOldParentLeft = $this->oxcategories__oxleft->value;
889 $sOldParentRight = $this->oxcategories__oxright->value;
891 $iTreeSize = $sOldParentRight-$sOldParentLeft+1;
893 $sNewRootID = $oDb->getOne(
"select oxrootid from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value),
false,
false);
896 if ( $sNewRootID ==
"") {
898 $sNewRootID = $this->
getId();
901 $sNewParentLeft = $oDb->getOne(
"select oxleft from oxcategories where oxid = ".$oDb->quote($this->oxcategories__oxparentid->value),
false,
false);
908 $iMoveAfter = $sNewParentLeft+1;
911 if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) {
915 $sRestoreOld =
"UPDATE oxcategories SET OXPARENTID = ".$oDb->quote($sOldParentID).
" WHERE oxid = ".$oDb->quote($this->
getId());
916 $oDb->execute( $sRestoreOld );
921 if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
922 $sOldParentLeft += $iTreeSize;
923 $sOldParentRight += $iTreeSize;
926 $iDelta = $iMoveAfter-$sOldParentLeft;
930 $sAddOld =
" and oxshopid = '" . $this->
getShopId() .
"' and OXROOTID = ".$oDb->quote($this->oxcategories__oxrootid->value).
";";
931 $sAddNew =
" and oxshopid = '" . $this->
getShopId() .
"' and OXROOTID = ".$oDb->quote($sNewRootID).
";";
934 $oDb->execute(
"UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iTreeSize.
") WHERE OXLEFT >= ".$iMoveAfter.$sAddNew );
935 $oDb->execute(
"UPDATE oxcategories SET OXRIGHT = (OXRIGHT + ".$iTreeSize.
") WHERE OXRIGHT >= ".$iMoveAfter.$sAddNew );
939 if ($this->oxcategories__oxrootid->value != $sNewRootID) {
941 $sChangeRootID =
", OXROOTID=".$oDb->quote($sNewRootID);
945 $oDb->execute(
"UPDATE oxcategories SET OXLEFT = (OXLEFT + ".$iDelta.
"), OXRIGHT = (OXRIGHT + ".$iDelta.
") ".$sChangeRootID.
" WHERE OXLEFT >= ".$sOldParentLeft.
" AND OXRIGHT <= ".$sOldParentRight.$sAddOld );
949 $oDb->execute(
"UPDATE oxcategories SET OXLEFT = (OXLEFT - ".$iTreeSize.
") WHERE OXLEFT >= ".($sOldParentRight+1).$sAddOld );
950 $oDb->execute(
"UPDATE oxcategories SET OXRIGHT = (OXRIGHT - ".$iTreeSize.
") WHERE OXRIGHT >= ".($sOldParentRight+1).$sAddOld );
954 if ( $blRes && $this->_blIsSeoObject && $this->
isAdmin() ) {
973 if ($sFieldName[2] ==
'l' || $sFieldName[2] ==
'L' || (isset($sFieldName[16]) && ($sFieldName[16] ==
'l' || $sFieldName[16] ==
'L') ) ) {
974 if (
'oxlongdesc' === strtolower($sFieldName) ||
'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
989 if ( ( $sIcon = $this->oxcategories__oxicon->value ) ) {
991 $sSize = $oConfig->getConfigParam(
'sCatIconsize' );
992 if ( !isset( $sSize ) ) {
993 $sSize = $oConfig->getConfigParam(
'sIconsize' );
996 return oxRegistry::get(
"oxPictureHandler")->getPicUrl(
"category/icon/", $sIcon, $sSize );
1007 if ( ( $sIcon = $this->oxcategories__oxthumb->value ) ) {
1008 $sSize = $this->
getConfig()->getConfigParam(
'sCatThumbnailsize' );
1009 return oxRegistry::get(
"oxPictureHandler")->getPicUrl(
"category/thumb/", $sIcon, $sSize );
1020 if ( ( $sIcon = $this->oxcategories__oxpromoicon->value ) ) {
1021 $sSize = $this->
getConfig()->getConfigParam(
'sCatPromotionsize' );
1022 return oxRegistry::get(
"oxPictureHandler")->getPicUrl(
"category/promo_icon/", $sIcon, $sSize );
1037 return $this->
getPictureUrl() . $sPicType .
'/' . $sPicName;
1050 if ( $this->_blTopCategory == null ) {
1051 $this->_blTopCategory = $this->oxcategories__oxparentid->value ==
'oxrootid';
1063 return (
bool) ( $this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value );
1074 if ( isset( $this->oxcategories__oxlongdesc ) && $this->oxcategories__oxlongdesc instanceof
oxField ) {
1075 return oxRegistry::get(
"oxUtilsView")->parseThroughSmarty( $this->oxcategories__oxlongdesc->getRawValue(), $this->
getId().$this->getLanguage(), null, true );
1086 return $this->oxcategories__oxdesc->value;
1096 return $this->oxcategories__oxtitle->value;