OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
oxcategory.php
Go to the documentation of this file.
1 <?php
2 
9 class oxCategory extends oxI18n implements oxIUrl
10 {
11 
17  protected $_aSubCats = array();
18 
24  protected $_aContentCats = array();
25 
31  protected $_sClassName = 'oxcategory';
32 
38  protected $_iNrOfArticles;
39 
45  protected $_blIsVisible;
46 
52  protected $_blExpanded;
53 
59  protected $_blHasSubCats;
60 
67 
73  protected $_blIsSeoObject = true;
74 
80  protected $_blUseLazyLoading = false;
81 
87  protected $_sDynImageDir = null;
88 
94  protected $_blTopCategory = null;
95 
101  protected $_aStdUrls = array();
102 
108  protected $_aSeoUrls = array();
109 
115  protected static $_aCatAttributes = array();
116 
122  protected $_oParent = null;
123 
127  public function __construct()
128  {
130  $this->init('oxcategories');
131  }
132 
138  public function getDefaultSorting()
139  {
140  return $this->oxcategories__oxdefsort->value;
141  }
142 
148  public function getDefaultSortingMode()
149  {
150  return $this->oxcategories__oxdefsortmode->value;
151  }
152 
160  public function __get($sName)
161  {
162  switch ($sName) {
163  case 'aSubCats':
164  return $this->_aSubCats;
165  break;
166  case 'aContent':
167  return $this->_aContentCats;
168  break;
169  case 'iArtCnt':
170  return $this->getNrOfArticles();
171  break;
172  case 'isVisible':
173  return $this->getIsVisible();
174  break;
175  case 'expanded':
176  return $this->getExpanded();
177  break;
178  case 'hasSubCats':
179  return $this->getHasSubCats();
180  break;
181  case 'hasVisibleSubCats':
182  return $this->getHasVisibleSubCats();
183  break;
184  case 'openlink':
185  case 'closelink':
186  case 'link':
187  //case 'toListLink':
188  //case 'noparamlink':
189  return $this->getLink();
190  break;
191  case 'dimagedir':
192  return $this->getPictureUrl();
193  break;
194  }
195  return parent::__get($sName);
196  }
197 
198 
206  protected function _loadFromDb($sOXID)
207  {
208  $sSelect = $this->buildSelectString(array("`{$this->getViewName()}`.`oxid`" => $sOXID));
209  $aData = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getRow($sSelect);
210 
211  return $aData;
212  }
213 
221  public function load($sOXID)
222  {
223 
224  $aData = $this->_loadFromDb($sOXID);
225 
226  if ($aData) {
227  $this->assign($aData);
228  $this->_isLoaded = true;
229  return true;
230  }
231 
232  return false;
233  }
234 
235 
243  public function assign($dbRecord)
244  {
245  $this->_iNrOfArticles = null;
246 
247  return parent::assign($dbRecord);
248  }
249 
257  public function delete($sOXID = null)
258  {
259  if (!$this->getId()) {
260  $this->load($sOXID);
261  }
262 
263  $sOXID = isset($sOXID) ? $sOXID : $this->getId();
264 
265 
266  $myConfig = $this->getConfig();
267  $oDb = oxDb::getDb();
268  $blRet = false;
269 
270  if ($this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value + 1)) {
271  $myUtilsPic = oxRegistry::get("oxUtilsPic");
272  $sDir = $myConfig->getPictureDir(false);
273 
274  // only delete empty categories
275  // #1173M - not all pic are deleted, after article is removed
276  $myUtilsPic->safePictureDelete($this->oxcategories__oxthumb->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('TC'), 'oxcategories', 'oxthumb');
277  $myUtilsPic->safePictureDelete($this->oxcategories__oxicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('CICO'), 'oxcategories', 'oxicon');
278  $myUtilsPic->safePictureDelete($this->oxcategories__oxpromoicon->value, $sDir . oxRegistry::get("oxUtilsFile")->getImageDirByType('PICO'), 'oxcategories', 'oxpromoicon');
279 
280  $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
281 
282  $oDb->execute(
283  "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
284  WHERE OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
285  AND OXLEFT > " . ((int) $this->oxcategories__oxleft->value) . $sAdd
286  );
287 
288  $oDb->execute(
289  "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
290  WHERE OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
291  AND OXRIGHT > " . ((int) $this->oxcategories__oxright->value) . $sAdd
292  );
293 
294  // delete entry
295  $blRet = parent::delete($sOXID);
296 
297  $sOxidQuoted = $oDb->quote($sOXID);
298  // delete links to articles
299  $oDb->execute("delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");
300 
301  // #657 ADDITIONAL delete links to attributes
302  $oDb->execute("delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");
303 
304  // A. removing assigned:
305  // - deliveries
306  $oDb->execute("delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
307  // - discounts
308  $oDb->execute("delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted ");
309 
310  oxRegistry::get("oxSeoEncoderCategory")->onDeleteCategory($this);
311  }
312 
313  return $blRet;
314  }
315 
321  public function getSubCats()
322  {
323  return $this->_aSubCats;
324  }
325 
333  public function getSubCat($sKey)
334  {
335  return $this->_aSubCats[$sKey];
336  }
337 
343  public function setSubCats($aCats)
344  {
345  $this->_aSubCats = $aCats;
346 
347  foreach ($aCats as $oCat) {
348 
349  // keeping ref. to parent
350  $oCat->setParentCategory($this);
351 
352  if ($oCat->getIsVisible()) {
353  $this->setHasVisibleSubCats(true);
354  }
355  }
356  }
357 
364  public function setSubCat($oCat, $sKey = null)
365  {
366  if ($sKey) {
367  $this->_aSubCats[$sKey] = $oCat;
368  } else {
369  $this->_aSubCats[] = $oCat;
370  }
371 
372  // keeping ref. to parent
373  $oCat->setParentCategory($this);
374 
375  if ($oCat->getIsVisible()) {
376  $this->setHasVisibleSubCats(true);
377  }
378  }
379 
385  public function getContentCats()
386  {
387  return $this->_aContentCats;
388  }
389 
395  public function setContentCats($aContent)
396  {
397  $this->_aContentCats = $aContent;
398  }
399 
406  public function setContentCat($oContent, $sKey = null)
407  {
408  if ($sKey) {
409  $this->_aContentCats[$sKey] = $oContent;
410  } else {
411  $this->_aContentCats[] = $oContent;
412  }
413  }
414 
420  public function getNrOfArticles()
421  {
422  $myConfig = $this->getConfig();
423 
424  if (!isset($this->_iNrOfArticles)
425  && !$this->isAdmin()
426  && (
427  $myConfig->getConfigParam('bl_perfShowActionCatArticleCnt')
428  || $myConfig->getConfigParam('blDontShowEmptyCategories')
429  )
430  ) {
431 
432  if ($this->isPriceCategory()) {
433  $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getPriceCatArticleCount($this->getId(), $this->oxcategories__oxpricefrom->value, $this->oxcategories__oxpriceto->value);
434  } else {
435  $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getCatArticleCount($this->getId());
436  }
437  }
438 
439  return (int) $this->_iNrOfArticles;
440  }
441 
447  public function setNrOfArticles($iNum)
448  {
449  $this->_iNrOfArticles = $iNum;
450  }
451 
457  public function getIsVisible()
458  {
459  if (!isset($this->_blIsVisible)) {
460 
461  if ($this->getConfig()->getConfigParam('blDontShowEmptyCategories')) {
462  $blEmpty = ($this->getNrOfArticles() < 1) && !$this->getHasVisibleSubCats();
463  } else {
464  $blEmpty = false;
465  }
466 
467  $this->_blIsVisible = !($blEmpty || $this->oxcategories__oxhidden->value);
468  }
469 
470  return $this->_blIsVisible;
471  }
472 
478  public function setIsVisible($blVisible)
479  {
480  $this->_blIsVisible = $blVisible;
481  }
482 
488  public function getPictureUrl()
489  {
490  if ($this->_sDynImageDir === null) {
491  $sThisShop = $this->oxcategories__oxshopid->value;
492  $this->_sDynImageDir = $this->getConfig()->getPictureUrl(null, false, null, null, $sThisShop);
493  }
494 
495  return $this->_sDynImageDir;
496  }
497 
506  public function getBaseSeoLink($iLang, $iPage = 0)
507  {
508  $oEncoder = oxRegistry::get("oxSeoEncoderCategory");
509  if (!$iPage) {
510  return $oEncoder->getCategoryUrl($this, $iLang);
511  }
512 
513  return $oEncoder->getCategoryPageUrl($this, $iPage, $iLang);
514  }
515 
523  public function getLink($iLang = null)
524  {
525  if (!oxRegistry::getUtils()->seoIsActive() ||
526  (isset($this->oxcategories__oxextlink) && $this->oxcategories__oxextlink->value)
527  ) {
528  return $this->getStdLink($iLang);
529  }
530 
531  if ($iLang === null) {
532  $iLang = $this->getLanguage();
533  }
534 
535  if (!isset($this->_aSeoUrls[$iLang])) {
536  $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink($iLang);
537  }
538 
539  return $this->_aSeoUrls[$iLang];
540  }
541 
547  public function setLink($sLink)
548  {
549  $iLang = $this->getLanguage();
550  if (oxRegistry::getUtils()->seoIsActive()) {
551  $this->_aSeoUrls[$iLang] = $sLink;
552  } else {
553  $this->_aStdUrls[$iLang] = $sLink;
554  }
555  }
556 
564  public function getSqlActiveSnippet($blForceCoreTable = null)
565  {
566  $sQ = parent::getSqlActiveSnippet($blForceCoreTable);
567 
568  $sTable = $this->getViewName($blForceCoreTable);
569  $sQ .= (strlen($sQ) ? ' and ' : '') . " $sTable.oxhidden = '0' ";
570 
571 
572  return "( $sQ ) ";
573  }
574 
584  public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
585  {
586  if (isset($this->oxcategories__oxextlink) && $this->oxcategories__oxextlink->value) {
587  return $this->oxcategories__oxextlink->value;
588  }
589 
590  $sUrl = '';
591  if ($blFull) {
592  //always returns shop url, not admin
593  $sUrl = $this->getConfig()->getShopUrl($iLang, false);
594  }
595 
596  //always returns shop url, not admin
597  return $sUrl . "index.php?cl=alist" . ($blAddId ? "&amp;cnid=" . $this->getId() : "");
598  }
599 
608  public function getStdLink($iLang = null, $aParams = array())
609  {
610  if (isset($this->oxcategories__oxextlink) && $this->oxcategories__oxextlink->value) {
611  return oxRegistry::get("oxUtilsUrl")->processUrl($this->oxcategories__oxextlink->value, true);
612  }
613 
614  if ($iLang === null) {
615  $iLang = $this->getLanguage();
616  }
617 
618  if (!isset($this->_aStdUrls[$iLang])) {
619  $this->_aStdUrls[$iLang] = $this->getBaseStdLink($iLang);
620  }
621 
622  return oxRegistry::get("oxUtilsUrl")->processUrl($this->_aStdUrls[$iLang], true, $aParams, $iLang);
623  }
624 
630  public function getExpanded()
631  {
632  return $this->_blExpanded;
633  }
634 
640  public function setExpanded($blExpanded)
641  {
642  $this->_blExpanded = $blExpanded;
643  }
644 
650  public function getHasSubCats()
651  {
652  if (!isset($this->_blHasSubCats)) {
653  $this->_blHasSubCats = $this->oxcategories__oxright->value > $this->oxcategories__oxleft->value + 1;
654  }
655 
656  return $this->_blHasSubCats;
657  }
658 
664  public function getHasVisibleSubCats()
665  {
666  if (!isset($this->_blHasVisibleSubCats)) {
667  $this->_blHasVisibleSubCats = false;
668  }
669 
671  }
672 
678  public function setHasVisibleSubCats($blHasVisibleSubcats)
679  {
680  if ($blHasVisibleSubcats && !$this->_blHasVisibleSubCats) {
681  unset($this->_blIsVisible);
682  if ($this->_oParent instanceof oxCategory) {
683  $this->_oParent->setHasVisibleSubCats(true);
684  }
685  }
686  $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
687  }
688 
694  public function getAttributes()
695  {
696  $sActCat = $this->getId();
697 
698  $sKey = md5($sActCat . serialize(oxRegistry::getSession()->getVariable('session_attrfilter')));
699  if (!isset(self::$_aCatAttributes[$sKey])) {
700  $oAttrList = oxNew("oxAttributeList");
701  $oAttrList->getCategoryAttributes($sActCat, $this->getLanguage());
702  self::$_aCatAttributes[$sKey] = $oAttrList;
703  }
704 
705  return self::$_aCatAttributes[$sKey];
706  }
707 
715  public function getCatInLang($oActCategory = null)
716  {
717  $oCategoryInDefaultLanguage = oxNew("oxCategory");
718  if ($this->isPriceCategory()) {
719  // get it in base language
720  $oCategoryInDefaultLanguage = oxNew("oxCategory");
721  $oCategoryInDefaultLanguage->loadInLang(0, $this->getId());
722  } else {
723  $oCategoryInDefaultLanguage = oxNew("oxCategory");
724  $oCategoryInDefaultLanguage->loadInLang(0, $oActCategory->getId());
725  }
726 
727  return $oCategoryInDefaultLanguage;
728  }
729 
735  public function setParentCategory($oCategory)
736  {
737  $this->_oParent = $oCategory;
738  }
739 
745  public function getParentCategory()
746  {
747  $oCat = null;
748 
749  // loading only if parent id is not rootid
750  if ($this->oxcategories__oxparentid->value && $this->oxcategories__oxparentid->value != 'oxrootid') {
751 
752  // checking if object itself has ref to parent
753  if ($this->_oParent) {
754  $oCat = $this->_oParent;
755  } else {
756  $oCat = oxNew('oxCategory');
757  if (!$oCat->load($this->oxcategories__oxparentid->value)) {
758  $oCat = null;
759  } else {
760  $this->_oParent = $oCat;
761  }
762  }
763  }
764 
765  return $oCat;
766  }
767 
775  public static function getRootId($sCategoryId)
776  {
777  if (!isset($sCategoryId)) {
778  return;
779  }
780  $oDb = oxDb::getDb();
781 
782  return $oDb->getOne('select oxrootid from ' . getViewName('oxcategories') . ' where oxid = ' . $oDb->quote($sCategoryId));
783  }
784 
785 
793  public function assignViewableRecord($sSelect)
794  {
795  if ($this->assignRecord($sSelect)) {
796  return true;
797  }
798 
799 
800  return false;
801  }
802 
808  protected function _insert()
809  {
810 
811 
812 
813  if ($this->oxcategories__oxparentid->value != "oxrootid") {
814  // load parent
815  $oParent = oxNew("oxCategory");
816  //#M317 check if parent is loaded
817  if (!$oParent->load($this->oxcategories__oxparentid->value)) {
818  return false;
819  }
820 
821  $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";
822 
823  // update existing nodes
824  $oDb = oxDb::getDb();
825  $oDb->execute(
826  "UPDATE oxcategories SET OXLEFT = OXLEFT + 2
827  WHERE OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "
828  AND OXLEFT > " . ((int) $oParent->oxcategories__oxright->value) . "
829  AND OXRIGHT >= " . ((int) $oParent->oxcategories__oxright->value) . $sAdd
830  );
831 
832 
833  $oDb->execute(
834  "UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2
835  WHERE OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "
836  AND OXRIGHT >= " . ((int) $oParent->oxcategories__oxright->value) . $sAdd
837  );
838 
839  if (!$this->getId()) {
840  $this->setId();
841  }
842 
843  $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW);
844  $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW);
845  $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW);
846 
847  return parent::_insert();
848  } else {
849  // root entry
850  if (!$this->getId()) {
851  $this->setId();
852  }
853 
854  $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW);
855  $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW);
856  $this->oxcategories__oxright = new oxField(2, oxField::T_RAW);
857 
858  return parent::_insert();
859  }
860  }
861 
867  protected function _update()
868  {
869 
870  $this->setUpdateSeo(true);
871  $this->_setUpdateSeoOnFieldChange('oxtitle');
872 
873  $oDb = oxDb::getDb();
874  $sOldParentID = $oDb->getOne("select oxparentid from oxcategories where oxid = " . $oDb->quote($this->getId()), false, false);
875 
876  if ($this->_blIsSeoObject && $this->isAdmin()) {
877  oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
878  }
879 
880  $blRes = parent::_update();
881 
882  // #872C - need to update category tree oxleft and oxright values (nested sets),
883  // then sub trees are moved inside one root, or to another root.
884  // this is done in 3 basic steps
885  // 1. increase oxleft and oxright values of target root tree by $iTreeSize, where oxleft>=$iMoveAfter , oxright>=$iMoveAfter
886  // 2. modify current subtree, we want to move by adding $iDelta to it's oxleft and oxright, where oxleft>=$sOldParentLeft and oxright<=$sOldParentRight values,
887  // in this step we also modify rootid's if they were changed
888  // 3. decreasing oxleft and oxright values of current root tree, where oxleft >= $sOldParentRight+1 , oxright >= $sOldParentRight+1
889 
890  // did we change position in tree ?
891  if ($this->oxcategories__oxparentid->value != $sOldParentID) {
892  $sOldParentLeft = $this->oxcategories__oxleft->value;
893  $sOldParentRight = $this->oxcategories__oxright->value;
894 
895  $iTreeSize = $sOldParentRight - $sOldParentLeft + 1;
896 
897  $sNewRootID = $oDb->getOne("select oxrootid from oxcategories where oxid = " . $oDb->quote($this->oxcategories__oxparentid->value), false, false);
898 
899  //If empty rootID, we set it to categorys oxid
900  if ($sNewRootID == "") {
901  //echo "<br>* ) Creating new root tree ( {$this->_sOXID} )";
902  $sNewRootID = $this->getId();
903  }
904 
905  $sNewParentLeft = $oDb->getOne("select oxleft from oxcategories where oxid = " . $oDb->quote($this->oxcategories__oxparentid->value), false, false);
906 
907  //if(!$sNewParentLeft){
908  //the current node has become root node, (oxrootid == "oxrootid")
909  // $sNewParentLeft = 0;
910  //}
911 
912  $iMoveAfter = $sNewParentLeft + 1;
913 
914  //New parentid can not be set to it's child
915  if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) {
916  //echo "<br>* ) Can't asign category to it's child";
917 
918  //Restoring old parentid, stoping further actions
919  $sRestoreOld = "UPDATE oxcategories SET OXPARENTID = " . $oDb->quote($sOldParentID) . " WHERE oxid = " . $oDb->quote($this->getId());
920  $oDb->execute($sRestoreOld);
921 
922  return false;
923  }
924 
925  //Old parent will be shifted too, if it is in the same tree
926  if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) {
927  $sOldParentLeft += $iTreeSize;
928  $sOldParentRight += $iTreeSize;
929  }
930 
931  $iDelta = $iMoveAfter - $sOldParentLeft;
932 
933  //echo "Size=$iTreeSize, NewStart=$iMoveAfter, delta=$iDelta";
934 
935  $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . ";";
936  $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = " . $oDb->quote($sNewRootID) . ";";
937 
938  //Updating everything after new position
939  $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT + " . $iTreeSize . ") WHERE OXLEFT >= " . $iMoveAfter . $sAddNew);
940  $oDb->execute("UPDATE oxcategories SET OXRIGHT = (OXRIGHT + " . $iTreeSize . ") WHERE OXRIGHT >= " . $iMoveAfter . $sAddNew);
941  //echo "<br>1.) + $iTreeSize, >= $iMoveAfter";
942 
943  $sChangeRootID = "";
944  if ($this->oxcategories__oxrootid->value != $sNewRootID) {
945  //echo "<br>* ) changing root IDs ( {$this->oxcategories__oxrootid->value} -> {$sNewRootID} )";
946  $sChangeRootID = ", OXROOTID=" . $oDb->quote($sNewRootID);
947  }
948 
949  //Updating subtree
950  $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT + " . $iDelta . "), OXRIGHT = (OXRIGHT + " . $iDelta . ") " . $sChangeRootID . " WHERE OXLEFT >= " . $sOldParentLeft . " AND OXRIGHT <= " . $sOldParentRight . $sAddOld);
951  //echo "<br>2.) + $iDelta, >= $sOldParentLeft and <= $sOldParentRight";
952 
953  //Updating everything after old position
954  $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT - " . $iTreeSize . ") WHERE OXLEFT >= " . ($sOldParentRight + 1) . $sAddOld);
955  $oDb->execute("UPDATE oxcategories SET OXRIGHT = (OXRIGHT - " . $iTreeSize . ") WHERE OXRIGHT >= " . ($sOldParentRight + 1) . $sAddOld);
956  //echo "<br>3.) - $iTreeSize, >= ".($sOldParentRight+1);
957  }
958 
959  if ($blRes && $this->_blIsSeoObject && $this->isAdmin()) {
960  oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this);
961  }
962 
963  return $blRes;
964  }
965 
975  protected function _setFieldData($sFieldName, $sValue, $iDataType = oxField::T_TEXT)
976  {
977  //preliminary quick check saves 3% of execution time in category lists by avoiding redundant strtolower() call
978  if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L'))) {
979  if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
980  $iDataType = oxField::T_RAW;
981  }
982  }
983 
984  return parent::_setFieldData($sFieldName, $sValue, $iDataType);
985  }
986 
987 
993  public function getIconUrl()
994  {
995  if (($sIcon = $this->oxcategories__oxicon->value)) {
996  $oConfig = $this->getConfig();
997  $sSize = $oConfig->getConfigParam('sCatIconsize');
998  if (!isset($sSize)) {
999  $sSize = $oConfig->getConfigParam('sIconsize');
1000  }
1001 
1002  return oxRegistry::get("oxPictureHandler")->getPicUrl("category/icon/", $sIcon, $sSize);
1003  }
1004  }
1005 
1011  public function getThumbUrl()
1012  {
1013  if (($sIcon = $this->oxcategories__oxthumb->value)) {
1014  $sSize = $this->getConfig()->getConfigParam('sCatThumbnailsize');
1015 
1016  return oxRegistry::get("oxPictureHandler")->getPicUrl("category/thumb/", $sIcon, $sSize);
1017  }
1018  }
1019 
1025  public function getPromotionIconUrl()
1026  {
1027  if (($sIcon = $this->oxcategories__oxpromoicon->value)) {
1028  $sSize = $this->getConfig()->getConfigParam('sCatPromotionsize');
1029 
1030  return oxRegistry::get("oxPictureHandler")->getPicUrl("category/promo_icon/", $sIcon, $sSize);
1031  }
1032  }
1033 
1042  public function getPictureUrlForType($sPicName, $sPicType)
1043  {
1044  if ($sPicName) {
1045  return $this->getPictureUrl() . $sPicType . '/' . $sPicName;
1046  } else {
1047  return false;
1048  }
1049  }
1050 
1056  public function isTopCategory()
1057  {
1058  if ($this->_blTopCategory == null) {
1059  $this->_blTopCategory = $this->oxcategories__oxparentid->value == 'oxrootid';
1060  }
1061 
1062  return $this->_blTopCategory;
1063  }
1064 
1070  public function isPriceCategory()
1071  {
1072  return (bool) ($this->oxcategories__oxpricefrom->value || $this->oxcategories__oxpriceto->value);
1073  }
1074 
1081  public function getLongDesc()
1082  {
1083  if (isset($this->oxcategories__oxlongdesc) && $this->oxcategories__oxlongdesc instanceof oxField) {
1085  $oUtilsView = oxRegistry::get("oxUtilsView");
1086  return oxRegistry::get("oxUtilsView")->parseThroughSmarty($this->oxcategories__oxlongdesc->getRawValue(), $this->getId() . $this->getLanguage(), null, true);
1087  }
1088  }
1089 
1095  public function getShortDescription()
1096  {
1097  return $this->oxcategories__oxdesc->value;
1098  }
1099 
1105  public function getTitle()
1106  {
1107  return $this->oxcategories__oxtitle->value;
1108  }
1109 
1119  public function getFieldFromSubCategories($sField = 'OXID', $sOXID = null)
1120  {
1121  if (!$sOXID) {
1122  $sOXID = $this->getId();
1123  }
1124  if (!$sOXID) {
1125  return false;
1126  }
1127 
1128  $sTable = $this->getViewName();
1129  $sField = "`{$sTable}`.`{$sField}`";
1130  $sSql = "SELECT $sField FROM `{$sTable}` WHERE `OXROOTID` = ? AND `OXPARENTID` != 'oxrootid'";
1131  $aResult = oxDb::getDb()->getCol($sSql, array($sOXID));
1132 
1133  return $aResult;
1134  }
1135 }