00001 <?php
00002
00009 class oxCategory extends oxI18n implements oxIUrl
00010 {
00011
00017 protected $_aSubCats = array();
00018
00024 protected $_aContentCats = array();
00025
00031 protected $_sClassName = 'oxcategory';
00032
00038 protected $_iNrOfArticles;
00039
00045 protected $_blIsVisible;
00046
00052 protected $_blExpanded;
00053
00059 protected $_blHasSubCats;
00060
00066 protected $_blHasVisibleSubCats;
00067
00073 protected $_blIsSeoObject = true;
00074
00080 protected $_blUseLazyLoading = false;
00081
00087 protected $_sDynImageDir = null;
00088
00094 protected $_blTopCategory = null;
00095
00101 protected $_aStdUrls = array();
00102
00108 protected $_aSeoUrls = array();
00109
00115 protected static $_aCatAttributes = array();
00116
00122 protected $_oParent = null;
00123
00127 public function __construct()
00128 {
00129 parent::__construct();
00130 $this->init('oxcategories');
00131 }
00132
00138 public function getDefaultSorting()
00139 {
00140 return $this->oxcategories__oxdefsort->value;
00141 }
00142
00148 public function getDefaultSortingMode()
00149 {
00150 return $this->oxcategories__oxdefsortmode->value;
00151 }
00152
00160 public function __get($sName)
00161 {
00162 switch ($sName) {
00163 case 'aSubCats':
00164 return $this->_aSubCats;
00165 break;
00166 case 'aContent':
00167 return $this->_aContentCats;
00168 break;
00169 case 'iArtCnt':
00170 return $this->getNrOfArticles();
00171 break;
00172 case 'isVisible':
00173 return $this->getIsVisible();
00174 break;
00175 case 'expanded':
00176 return $this->getExpanded();
00177 break;
00178 case 'hasSubCats':
00179 return $this->getHasSubCats();
00180 break;
00181 case 'hasVisibleSubCats':
00182 return $this->getHasVisibleSubCats();
00183 break;
00184 case 'openlink':
00185 case 'closelink':
00186 case 'link':
00187
00188
00189 return $this->getLink();
00190 break;
00191 case 'dimagedir':
00192 return $this->getPictureUrl();
00193 break;
00194 }
00195 return parent::__get($sName);
00196 }
00197
00198
00206 protected function _loadFromDb($sOXID)
00207 {
00208 $sSelect = $this->buildSelectString(array("`{$this->getViewName()}`.`oxid`" => $sOXID));
00209 $aData = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getRow($sSelect);
00210
00211 return $aData;
00212 }
00213
00221 public function load($sOXID)
00222 {
00223
00224 $aData = $this->_loadFromDb($sOXID);
00225
00226 if ($aData) {
00227 $this->assign($aData);
00228
00229 return true;
00230 }
00231
00232 return false;
00233 }
00234
00235
00243 public function assign($dbRecord)
00244 {
00245 $this->_iNrOfArticles = null;
00246
00247 return parent::assign($dbRecord);
00248 }
00249
00257 public function delete($sOXID = null)
00258 {
00259 if (!$this->getId()) {
00260 $this->load($sOXID);
00261 }
00262
00263 $sOXID = isset($sOXID) ? $sOXID : $this->getId();
00264
00265
00266 $myConfig = $this->getConfig();
00267 $oDb = oxDb::getDb();
00268 $blRet = false;
00269
00270 if ($this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value + 1)) {
00271 $myUtilsPic = oxRegistry::get("oxUtilsPic");
00272 $sDir = $myConfig->getPictureDir(false);
00273
00274
00275
00276 $myUtilsPic->safePictureDelete($this->oxcategories__oxthumb->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('TC'), 'oxcategories', 'oxthumb');
00277 $myUtilsPic->safePictureDelete($this->oxcategories__oxicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('CICO'), 'oxcategories', 'oxicon');
00278 $myUtilsPic->safePictureDelete($this->oxcategories__oxpromoicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('PICO'), 'oxcategories', 'oxpromoicon');
00279
00280 $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00281
00282 $oDb->execute(
00283 "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
00284 WHERE OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
00285 AND OXLEFT > " . ((int) $this->oxcategories__oxleft->value) . $sAdd
00286 );
00287
00288 $oDb->execute(
00289 "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
00290 WHERE OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
00291 AND OXRIGHT > " . ((int) $this->oxcategories__oxright->value) . $sAdd
00292 );
00293
00294
00295 $blRet = parent::delete($sOXID);
00296
00297 $sOxidQuoted = $oDb->quote($sOXID);
00298
00299 $oDb->execute("delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");
00300
00301
00302 $oDb->execute("delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");
00303
00304
00305
00306 $oDb->execute("delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
00307
00308 $oDb->execute("delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted ");
00309
00310 oxRegistry::get("oxSeoEncoderCategory")->onDeleteCategory($this);
00311 }
00312
00313 return $blRet;
00314 }
00315
00321 public function getSubCats()
00322 {
00323 return $this->_aSubCats;
00324 }
00325
00333 public function getSubCat($sKey)
00334 {
00335 return $this->_aSubCats[$sKey];
00336 }
00337
00343 public function setSubCats($aCats)
00344 {
00345 $this->_aSubCats = $aCats;
00346
00347 foreach ($aCats as $oCat) {
00348
00349
00350 $oCat->setParentCategory($this);
00351
00352 if ($oCat->getIsVisible()) {
00353 $this->setHasVisibleSubCats(true);
00354 }
00355 }
00356 }
00357
00364 public function setSubCat($oCat, $sKey = null)
00365 {
00366 if ($sKey) {
00367 $this->_aSubCats[$sKey] = $oCat;
00368 } else {
00369 $this->_aSubCats[] = $oCat;
00370 }
00371
00372
00373 $oCat->setParentCategory($this);
00374
00375 if ($oCat->getIsVisible()) {
00376 $this->setHasVisibleSubCats(true);
00377 }
00378 }
00379
00385 public function getContentCats()
00386 {
00387 return $this->_aContentCats;
00388 }
00389
00395 public function setContentCats($aContent)
00396 {
00397 $this->_aContentCats = $aContent;
00398 }
00399
00406 public function setContentCat($oContent, $sKey = null)
00407 {
00408 if ($sKey) {
00409 $this->_aContentCats[$sKey] = $oContent;
00410 } else {
00411 $this->_aContentCats[] = $oContent;
00412 }
00413 }
00414
00420 public function getNrOfArticles()
00421 {
00422 $myConfig = $this->getConfig();
00423
00424 if (!isset($this->_iNrOfArticles)
00425 && !$this->isAdmin()
00426 && (
00427 $myConfig->getConfigParam('bl_perfShowActionCatArticleCnt')
00428 || $myConfig->getConfigParam('blDontShowEmptyCategories')
00429 )
00430 ) {
00431
00432 if ($this->isPriceCategory()) {
00433 $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getPriceCatArticleCount($this->getId(), $this->oxcategories__oxpricefrom->value, $this->oxcategories__oxpriceto->value);
00434 } else {
00435 $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getCatArticleCount($this->getId());
00436 }
00437 }
00438
00439 return (int) $this->_iNrOfArticles;
00440 }
00441
00447 public function setNrOfArticles($iNum)
00448 {
00449 $this->_iNrOfArticles = $iNum;
00450 }
00451
00457 public function getIsVisible()
00458 {
00459 if (!isset($this->_blIsVisible)) {
00460
00461 if ($this->getConfig()->getConfigParam('blDontShowEmptyCategories')) {
00462 $blEmpty = ($this->getNrOfArticles() < 1) && !$this->getHasVisibleSubCats();
00463 } else {
00464 $blEmpty = false;
00465 }
00466
00467 $this->_blIsVisible = !($blEmpty || $this->oxcategories__oxhidden->value);
00468 }
00469
00470 return $this->_blIsVisible;
00471 }
00472
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
00495 return $this->_sDynImageDir;
00496 }
00497
00506 public function getBaseSeoLink($iLang, $iPage = 0)
00507 {
00508 $oEncoder = oxRegistry::get("oxSeoEncoderCategory");
00509 if (!$iPage) {
00510 return $oEncoder->getCategoryUrl($this, $iLang);
00511 }
00512
00513 return $oEncoder->getCategoryPageUrl($this, $iPage, $iLang);
00514 }
00515
00523 public function getLink($iLang = null)
00524 {
00525 if (!oxRegistry::getUtils()->seoIsActive() ||
00526 (isset($this->oxcategories__oxextlink) && $this->oxcategories__oxextlink->value)
00527 ) {
00528 return $this->getStdLink($iLang);
00529 }
00530
00531 if ($iLang === null) {
00532 $iLang = $this->getLanguage();
00533 }
00534
00535 if (!isset($this->_aSeoUrls[$iLang])) {
00536 $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink($iLang);
00537 }
00538
00539 return $this->_aSeoUrls[$iLang];
00540 }
00541
00547 public function setLink($sLink)
00548 {
00549 $iLang = $this->getLanguage();
00550 if (oxRegistry::getUtils()->seoIsActive()) {
00551 $this->_aSeoUrls[$iLang] = $sLink;
00552 } else {
00553 $this->_aStdUrls[$iLang] = $sLink;
00554 }
00555 }
00556
00564 public function getSqlActiveSnippet($blForceCoreTable = null)
00565 {
00566 $sQ = parent::getSqlActiveSnippet($blForceCoreTable);
00567
00568 $sTable = $this->getViewName($blForceCoreTable);
00569 $sQ .= (strlen($sQ) ? ' and ' : '') . " $sTable.oxhidden = '0' ";
00570
00571
00572 return "( $sQ ) ";
00573 }
00574
00584 public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
00585 {
00586 if (isset($this->oxcategories__oxextlink) && $this->oxcategories__oxextlink->value) {
00587 return $this->oxcategories__oxextlink->value;
00588 }
00589
00590 $sUrl = '';
00591 if ($blFull) {
00592
00593 $sUrl = $this->getConfig()->getShopUrl($iLang, false);
00594 }
00595
00596
00597 return $sUrl . "index.php?cl=alist" . ($blAddId ? "&cnid=" . $this->getId() : "");
00598 }
00599
00608 public function getStdLink($iLang = null, $aParams = array())
00609 {
00610 if (isset($this->oxcategories__oxextlink) && $this->oxcategories__oxextlink->value) {
00611 return oxRegistry::get("oxUtilsUrl")->processUrl($this->oxcategories__oxextlink->value, false);
00612 }
00613
00614 if ($iLang === null) {
00615 $iLang = $this->getLanguage();
00616 }
00617
00618 if (!isset($this->_aStdUrls[$iLang])) {
00619 $this->_aStdUrls[$iLang] = $this->getBaseStdLink($iLang);
00620 }
00621
00622 return oxRegistry::get("oxUtilsUrl")->processUrl($this->_aStdUrls[$iLang], true, $aParams, $iLang);
00623 }
00624
00630 public function getExpanded()
00631 {
00632 return $this->_blExpanded;
00633 }
00634
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
00678 public function setHasVisibleSubCats($blHasVisibleSubcats)
00679 {
00680 if ($blHasVisibleSubcats && !$this->_blHasVisibleSubCats) {
00681 unset($this->_blIsVisible);
00682 if ($this->_oParent instanceof oxCategory) {
00683 $this->_oParent->setHasVisibleSubCats(true);
00684 }
00685 }
00686 $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00687 }
00688
00694 public function getAttributes()
00695 {
00696 $sActCat = $this->getId();
00697
00698 $sKey = md5($sActCat . serialize(oxRegistry::getSession()->getVariable('session_attrfilter')));
00699 if (!isset(self::$_aCatAttributes[$sKey])) {
00700 $oAttrList = oxNew("oxAttributeList");
00701 $oAttrList->getCategoryAttributes($sActCat, $this->getLanguage());
00702 self::$_aCatAttributes[$sKey] = $oAttrList;
00703 }
00704
00705 return self::$_aCatAttributes[$sKey];
00706 }
00707
00715 public function getCatInLang($oActCategory = null)
00716 {
00717 $oCategoryInDefaultLanguage = oxNew("oxCategory");
00718 if ($this->isPriceCategory()) {
00719
00720 $oCategoryInDefaultLanguage = oxNew("oxCategory");
00721 $oCategoryInDefaultLanguage->loadInLang(0, $this->getId());
00722 } else {
00723 $oCategoryInDefaultLanguage = oxNew("oxCategory");
00724 $oCategoryInDefaultLanguage->loadInLang(0, $oActCategory->getId());
00725 }
00726
00727 return $oCategoryInDefaultLanguage;
00728 }
00729
00735 public function setParentCategory($oCategory)
00736 {
00737 $this->_oParent = $oCategory;
00738 }
00739
00745 public function getParentCategory()
00746 {
00747 $oCat = null;
00748
00749
00750 if ($this->oxcategories__oxparentid->value && $this->oxcategories__oxparentid->value != 'oxrootid') {
00751
00752
00753 if ($this->_oParent) {
00754 $oCat = $this->_oParent;
00755 } else {
00756 $oCat = oxNew('oxCategory');
00757 if (!$oCat->load($this->oxcategories__oxparentid->value)) {
00758 $oCat = null;
00759 } else {
00760 $this->_oParent = $oCat;
00761 }
00762 }
00763 }
00764
00765 return $oCat;
00766 }
00767
00775 public static function getRootId($sCategoryId)
00776 {
00777 if (!isset($sCategoryId)) {
00778 return;
00779 }
00780 $oDb = oxDb::getDb();
00781
00782 return $oDb->getOne('select oxrootid from ' . getViewName('oxcategories') . ' where oxid = ' . $oDb->quote($sCategoryId));
00783 }
00784
00785
00793 public function assignViewableRecord($sSelect)
00794 {
00795 if ($this->assignRecord($sSelect)) {
00796 return true;
00797 }
00798
00799
00800 return false;
00801 }
00802
00808 protected function _insert()
00809 {
00810
00811
00812
00813 if ($this->oxcategories__oxparentid->value != "oxrootid") {
00814
00815 $oParent = oxNew("oxCategory");
00816
00817 if (!$oParent->load($this->oxcategories__oxparentid->value)) {
00818 return false;
00819 }
00820
00821 $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
00822
00823
00824 $oDb = oxDb::getDb();
00825 $oDb->execute(
00826 "UPDATE oxcategories SET OXLEFT = OXLEFT + 2
00827 WHERE OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "
00828 AND OXLEFT > " . ((int) $oParent->oxcategories__oxright->value) . "
00829 AND OXRIGHT >= " . ((int) $oParent->oxcategories__oxright->value) . $sAdd
00830 );
00831
00832
00833 $oDb->execute(
00834 "UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2
00835 WHERE OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "
00836 AND OXRIGHT >= " . ((int) $oParent->oxcategories__oxright->value) . $sAdd
00837 );
00838
00839 if (!$this->getId()) {
00840 $this->setId();
00841 }
00842
00843 $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW);
00844 $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW);
00845 $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW);
00846
00847 return parent::_insert();
00848 } else {
00849
00850 if (!$this->getId()) {
00851 $this->setId();
00852 }
00853
00854 $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW);
00855 $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW);
00856 $this->oxcategories__oxright = new oxField(2, oxField::T_RAW);
00857
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
00919 return false;
00920 }
00921
00922
00923 if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
00924 $sOldParentLeft += $iTreeSize;
00925 $sOldParentRight += $iTreeSize;
00926 }
00927
00928 $iDelta = $iMoveAfter - $sOldParentLeft;
00929
00930
00931
00932 $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . ";";
00933 $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = " . $oDb->quote($sNewRootID) . ";";
00934
00935
00936 $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT + " . $iTreeSize . ") WHERE OXLEFT >= " . $iMoveAfter . $sAddNew);
00937 $oDb->execute("UPDATE oxcategories SET OXRIGHT = (OXRIGHT + " . $iTreeSize . ") WHERE OXRIGHT >= " . $iMoveAfter . $sAddNew);
00938
00939
00940 $sChangeRootID = "";
00941 if ($this->oxcategories__oxrootid->value != $sNewRootID) {
00942
00943 $sChangeRootID = ", OXROOTID=" . $oDb->quote($sNewRootID);
00944 }
00945
00946
00947 $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT + " . $iDelta . "), OXRIGHT = (OXRIGHT + " . $iDelta . ") " . $sChangeRootID . " WHERE OXLEFT >= " . $sOldParentLeft . " AND OXRIGHT <= " . $sOldParentRight . $sAddOld);
00948
00949
00950
00951 $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT - " . $iTreeSize . ") WHERE OXLEFT >= " . ($sOldParentRight + 1) . $sAddOld);
00952 $oDb->execute("UPDATE oxcategories SET OXRIGHT = (OXRIGHT - " . $iTreeSize . ") WHERE OXRIGHT >= " . ($sOldParentRight + 1) . $sAddOld);
00953
00954 }
00955
00956 if ($blRes && $this->_blIsSeoObject && $this->isAdmin()) {
00957 oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
00958 }
00959
00960 return $blRes;
00961 }
00962
00972 protected function _setFieldData($sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00973 {
00974
00975 if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L'))) {
00976 if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
00977 $iDataType = oxField::T_RAW;
00978 }
00979 }
00980
00981 return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00982 }
00983
00984
00990 public function getIconUrl()
00991 {
00992 if (($sIcon = $this->oxcategories__oxicon->value)) {
00993 $oConfig = $this->getConfig();
00994 $sSize = $oConfig->getConfigParam('sCatIconsize');
00995 if (!isset($sSize)) {
00996 $sSize = $oConfig->getConfigParam('sIconsize');
00997 }
00998
00999 return oxRegistry::get("oxPictureHandler")->getPicUrl("category/icon/", $sIcon, $sSize);
01000 }
01001 }
01002
01008 public function getThumbUrl()
01009 {
01010 if (($sIcon = $this->oxcategories__oxthumb->value)) {
01011 $sSize = $this->getConfig()->getConfigParam('sCatThumbnailsize');
01012
01013 return oxRegistry::get("oxPictureHandler")->getPicUrl("category/thumb/", $sIcon, $sSize);
01014 }
01015 }
01016
01022 public function getPromotionIconUrl()
01023 {
01024 if (($sIcon = $this->oxcategories__oxpromoicon->value)) {
01025 $sSize = $this->getConfig()->getConfigParam('sCatPromotionsize');
01026
01027 return oxRegistry::get("oxPictureHandler")->getPicUrl("category/promo_icon/", $sIcon, $sSize);
01028 }
01029 }
01030
01039 public function getPictureUrlForType($sPicName, $sPicType)
01040 {
01041 if ($sPicName) {
01042 return $this->getPictureUrl() . $sPicType . '/' . $sPicName;
01043 } else {
01044 return false;
01045 }
01046 }
01047
01053 public function isTopCategory()
01054 {
01055 if ($this->_blTopCategory == null) {
01056 $this->_blTopCategory = $this->oxcategories__oxparentid->value == 'oxrootid';
01057 }
01058
01059 return $this->_blTopCategory;
01060 }
01061
01067 public function isPriceCategory()
01068 {
01069 return (bool) ($this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value);
01070 }
01071
01078 public function getLongDesc()
01079 {
01080 if (isset($this->oxcategories__oxlongdesc) && $this->oxcategories__oxlongdesc instanceof oxField) {
01081 return oxRegistry::get("oxUtilsView")->parseThroughSmarty($this->oxcategories__oxlongdesc->getRawValue(), $this->getId() . $this->getLanguage());
01082 }
01083 }
01084
01090 public function getShortDescription()
01091 {
01092 return $this->oxcategories__oxdesc->value;
01093 }
01094
01100 public function getTitle()
01101 {
01102 return $this->oxcategories__oxtitle->value;
01103 }
01104
01114 public function getFieldFromSubCategories($sField = 'OXID', $sOXID = null)
01115 {
01116 if (!$sOXID) {
01117 $sOXID = $this->getId();
01118 }
01119 if (!$sOXID) {
01120 return false;
01121 }
01122
01123 $sTable = $this->getViewName();
01124 $sField = "`{$sTable}`.`{$sField}`";
01125 $sSql = "SELECT $sField FROM `{$sTable}` WHERE `OXROOTID` = ? AND `OXPARENTID` != 'oxrootid'";
01126 $aResult = oxDb::getDb()->getCol($sSql, array($sOXID));
01127
01128 return $aResult;
01129 }
01130 }