69     public function __construct($sObjectsInListName = 
'oxcategory')
 
   71         $this->_blHideEmpty = $this->
getConfig()->getConfigParam(
'blDontShowEmptyCategories');
 
   82         $this->_blForceFull = $blForceFull;
 
  102         if ($iForceLevel > 2) {
 
  104         } elseif ($iForceLevel < 1) {
 
  107         $this->_iForceLevel = $iForceLevel;
 
  130         if ($aColumns && 
count($aColumns)) {
 
  131             foreach ($aColumns as $key => $val) {
 
  132                 $aColumns[$key] .= 
' as ' . $val;
 
  135             return "$sTable." . implode(
", $sTable.", $aColumns);
 
  138         $sFieldList = 
"$sTable.oxid as oxid, $sTable.oxactive as oxactive," 
  139                       . 
" $sTable.oxhidden as oxhidden, $sTable.oxparentid as oxparentid," 
  140                       . 
" $sTable.oxdefsort as oxdefsort, $sTable.oxdefsortmode as oxdefsortmode," 
  141                       . 
" $sTable.oxleft as oxleft, $sTable.oxright as oxright," 
  142                       . 
" $sTable.oxrootid as oxrootid, $sTable.oxsort as oxsort," 
  143                       . 
" $sTable.oxtitle as oxtitle, $sTable.oxdesc as oxdesc," 
  144                       . 
" $sTable.oxpricefrom as oxpricefrom, $sTable.oxpriceto as oxpriceto," 
  145                       . 
" $sTable.oxicon as oxicon, $sTable.oxextlink as oxextlink," 
  146                       . 
" $sTable.oxthumb as oxthumb, $sTable.oxpromoicon as oxpromoicon";
 
  148         $sFieldList .= 
",not $sTable.oxactive as oxppremove";
 
  170             $oCat = 
oxNew(
'oxCategory');
 
  171             if (!($this->_sActCat && $oCat->load($this->_sActCat) && $oCat->oxcategories__oxrootid->value)) {
 
  173                 $this->_sActCat = null;
 
  184             $sOrdDir = $blReverse ? 
'desc' : 
'asc';
 
  185             $sOrder = 
"oxrootid $sOrdDir, oxleft $sOrdDir";
 
  188         return "select $sFieldList from $sViewName where $sWhere $sUnion order by $sOrder";
 
  202         $sDepthSnippet = 
' ( 0';
 
  207             $sDepthSnippet .= 
" or ($sViewName.oxparentid = " . 
oxDb::getDb()->quote($oCat->oxcategories__oxid->value) . 
")";
 
  212             $sDepthSnippet .= 
" or $sViewName.oxparentid = 'oxrootid'";
 
  217             $sDepthSnippet .= 
" or $sViewName.oxrootid = $sViewName.oxparentid or $sViewName.oxid = $sViewName.oxrootid";
 
  220         $sDepthSnippet .= 
' ) ';
 
  222         return $sDepthSnippet;
 
  244                . 
" FROM oxcategories AS subcats" 
  245                . 
" LEFT JOIN $sViewName AS maincats on maincats.oxparentid = subcats.oxparentid" 
  246                . 
" WHERE subcats.oxrootid = " . 
oxDb::getDb()->quote($oCat->oxcategories__oxrootid->value)
 
  247                . 
" AND subcats.oxleft <= " . (int) $oCat->oxcategories__oxleft->value
 
  248                . 
" AND subcats.oxright >= " . (
int) $oCat->oxcategories__oxright->value;
 
  260         $sSql = $this->
_getSelectString(
false, null, 
'oxparentid, oxsort, oxtitle');
 
  287         startProfile(
"buildTree");
 
  289         $this->_sActCat = $sActCat;
 
  311         stopProfile(
"buildTree");
 
  321         if (isset($this->_aArray[$sId])) {
 
  322             $oNewCat = 
oxNew(
'oxCategory');
 
  323             if ($oNewCat->load($sId)) {
 
  325                 $this->_aArray[$sId] = $oNewCat;
 
  328             $this->_sActCat = null;
 
  337         startProfile(
'buildCategoryList');
 
  348         stopProfile(
'buildCategoryList');
 
  358         $this->_sShopID = $sShopID;
 
  378         if (
count($this->_aPath)) {
 
  379             return end($this->_aPath);
 
  390         if (
count($this->_aPath)) {
 
  391             return array(reset($this->_aPath));
 
  401         $aRemoveList = array();
 
  402         foreach ($this->_aArray as $sId => $oCat) {
 
  403             if ($oCat->oxcategories__oxppremove->value) {
 
  404                 if (!isset($aRemoveList[$oCat->oxcategories__oxrootid->value])) {
 
  405                     $aRemoveList[$oCat->oxcategories__oxrootid->value] = array();
 
  407                 $aRemoveList[$oCat->oxcategories__oxrootid->value][$oCat->oxcategories__oxleft->value] = $oCat->oxcategories__oxright->value;
 
  408                 unset($this->_aArray[$sId]);
 
  410                 unset($oCat->oxcategories__oxppremove);
 
  415         foreach ($this->_aArray as $sId => $oCat) {
 
  416             if (isset($aRemoveList[$oCat->oxcategories__oxrootid->value]) &&
 
  417                 is_array($aRemoveList[$oCat->oxcategories__oxrootid->value])
 
  419                 foreach ($aRemoveList[$oCat->oxcategories__oxrootid->value] as $iLeft => $iRight) {
 
  421                         ($iLeft <= $oCat->oxcategories__oxleft->value)
 
  422                         && ($iRight >= $oCat->oxcategories__oxleft->value)
 
  425                         unset($this->_aArray[$sId]);
 
  440         if (is_null($this->_sActCat)) {
 
  447         while ($sCurrentCat != 
'oxrootid' && isset($this[$sCurrentCat])) {
 
  448             $oCat = $this[$sCurrentCat];
 
  449             $oCat->setExpanded(
true);
 
  450             $aPath[$sCurrentCat] = $oCat;
 
  451             $sCurrentCat = $oCat->oxcategories__oxparentid->value;
 
  454         $this->_aPath = array_reverse($aPath);
 
  463         $oContentList = 
oxNew(
"oxContentList");
 
  464         $oContentList->loadCatMenues();
 
  466         foreach ($oContentList as $sCatId => $aContent) {
 
  467             if (array_key_exists($sCatId, $this->_aArray)) {
 
  468                 $this[$sCatId]->setContentCats($aContent);
 
  480         foreach ($this->_aArray as $oCat) {
 
  481             $sParentId = $oCat->oxcategories__oxparentid->value;
 
  482             if ($sParentId != 
'oxrootid') {
 
  483                 if (isset($this->_aArray[$sParentId])) {
 
  484                     $this->_aArray[$sParentId]->setSubCat($oCat, $oCat->getId());
 
  487                 $aTree[$oCat->getId()] = $oCat;
 
  505         foreach ($this->_aArray as $oCat) {
 
  507             $aTree[$oCat->getId()] = $oCat;
 
  508             $aSubCats = $oCat->getSubCats();
 
  509             if (
count($aSubCats) > 0) {
 
  510                 foreach ($aSubCats as $oSubCat) {
 
  530         $oCat->oxcategories__oxtitle->setValue($sDepth . 
' ' . $oCat->oxcategories__oxtitle->value);
 
  531         $aTree[$oCat->getId()] = $oCat;
 
  532         $aSubCats = $oCat->getSubCats();
 
  533         if (
count($aSubCats) > 0) {
 
  534             foreach ($aSubCats as $oSubCat) {
 
  554         $oDb->execute(
"update oxcategories set oxleft = 0, oxright = 0 where $sWhere");
 
  555         $oDb->execute(
"update oxcategories set oxleft = 1, oxright = 2 where oxparentid = 'oxrootid' and $sWhere");
 
  558         $rs = $oDb->select(
"select oxid, oxtitle from oxcategories where oxparentid = 'oxrootid' and $sWhere order by oxsort", 
false, 
false);
 
  559         if ($rs != 
false && $rs->recordCount() > 0) {
 
  561                 $this->_aUpdateInfo[] = 
"<b>Processing : " . $rs->fields[1] . 
"</b>(" . $rs->fields[0] . 
")<br>";
 
  563                     echo 
next($this->_aUpdateInfo);
 
  565                 $oxRootId = $rs->fields[0];
 
  595             $thisRoot = $oxRootId;
 
  599         $rs = $oDb->execute(
"update oxcategories set oxrootid = " . $oDb->quote($thisRoot) . 
" where oxparentid = " . $oDb->quote($oxRootId));
 
  600         $rs = $oDb->select(
"select oxid, oxparentid from oxcategories where oxparentid = " . $oDb->quote($oxRootId) . 
" order by oxsort", 
false, 
false);
 
  602         if ($rs != 
false && $rs->recordCount() > 0) {
 
  604                 $parentId = $rs->fields[1];
 
  605                 $actOxid = $rs->fields[0];
 
  606                 $sActOxidQuoted = $oDb->quote($actOxid);
 
  609                 $rs3 = $oDb->select(
"select oxrootid, oxright from oxcategories where oxid = " . $oDb->quote($parentId), 
false, 
false);
 
  611                     $parentOxRootId = $rs3->fields[0];
 
  612                     $parentRight = (int) $rs3->fields[1];
 
  615                 $sParentOxRootIdQuoted = $oDb->quote($parentOxRootId);
 
  616                 $oDb->execute(
"update oxcategories set oxleft = oxleft + 2 where oxrootid = $sParentOxRootIdQuoted and oxleft > '$parentRight' and oxright >= '$parentRight' and oxid != $sActOxidQuoted");
 
  617                 $oDb->execute(
"update oxcategories set oxright = oxright + 2 where oxrootid = $sParentOxRootIdQuoted and oxright >= '$parentRight' and oxid != $sActOxidQuoted");
 
  618                 $oDb->execute(
"update oxcategories set oxleft = $parentRight, oxright = ($parentRight + 1) where oxid = $sActOxidQuoted");