Exemple #1
0
	protected function obtainCacheDependentData()
	{
		parent::obtainCacheDependentData();

		if(!is_array($this->dbResult['PRECACHED_POOL']))
			$this->dbResult['PRECACHED_POOL'] = array();

		$this->dbResult['BUNDLES_INCOMPLETE'] = array();

		// all bundles that are in PATH are incomplete by the way there were obtained, so ...
		if(is_array($this->dbResult['PATH']))
		{
			foreach($this->dbResult['PATH'] as $levelId => $level)
				$this->dbResult['BUNDLES_INCOMPLETE'][$levelId] = true;
		}

		if($this->arParams['PRECACHE_LAST_LEVEL'])
		{
			$parameters = $this->getLocationListParameters();
			if(!is_array($parameters))
				$parameters = array();
			if(!is_array($parameters['filter']))
				$parameters['filter'] = array();

			$parentId = false;
			if(is_array($this->dbResult['LOCATION']) && intval($this->dbResult['LOCATION']['ID']))
			{
				if($this->dbResult['LOCATION']['CHILD_CNT'] > 0)
					$parentId = intval($this->dbResult['LOCATION']['ID']);
				else
					$parentId = intval($this->dbResult['LOCATION']['PARENT_ID']);
			}
			else
			{
				// actually, we must find the last of TREE_TRUNK
				$lastId = false;
				foreach($this->dbResult['TREE_TRUNK'] as $id => $node)
				{
					$lastId = $node['ID'];
				}

				if($lastId != false)
					$parentId = $lastId;
			}

			if($parentId !== false)
			{
				// ... but if we get some bundle here, then it becomes complete
				unset($this->dbResult['BUNDLES_INCOMPLETE'][$parentId]);

				$parameters['filter']['=PARENT_ID'] = $parentId;
				$res = Location\LocationTable::getList($parameters);
				$res->addReplacedAliases(array('LNAME' => 'NAME'));
				while($item = $res->fetch())
				{
					$this->dbResult['PRECACHED_POOL'][$item['PARENT_ID']][$item['ID']] = $item;
				}
			}
		}
	}
Exemple #2
0
 protected function obtainCacheDependentData()
 {
     parent::obtainCacheDependentData();
     if (!is_array($this->dbResult['PRECACHED_POOL'])) {
         $this->dbResult['PRECACHED_POOL'] = array();
     }
     $this->dbResult['BUNDLES_INCOMPLETE'] = array();
     // all bundles that are in PATH are incomplete by the way there were obtained, so ...
     $this->dbResult['BUNDLES_INCOMPLETE'][0] = true;
     // first level incomplete
     if (is_array($this->dbResult['PATH'])) {
         foreach ($this->dbResult['PATH'] as $levelId => $level) {
             $this->dbResult['BUNDLES_INCOMPLETE'][$levelId] = true;
         }
     }
     if ($this->arParams['PRECACHE_LAST_LEVEL']) {
         $parameters = $this->getLocationListParameters();
         if (!is_array($parameters)) {
             $parameters = array();
         }
         if (!is_array($parameters['filter'])) {
             $parameters['filter'] = array();
         }
         if (!is_array($parameters['order'])) {
             $parameters['order'] = array('SORT' => 'asc', 'NAME.NAME' => 'asc');
         }
         $parentId = false;
         // if smth is selected
         if (is_array($this->dbResult['LOCATION']) && intval($this->dbResult['LOCATION']['ID'])) {
             // then last level is
             if ($this->dbResult['LOCATION']['CHILD_CNT'] > 0) {
                 $parentId = intval($this->dbResult['LOCATION']['ID']);
             } else {
                 $parentId = intval($this->dbResult['LOCATION']['PARENT_ID']);
             }
             // or the level of a selected node
         } else {
             if (!empty($this->dbResult['TREE_TRUNK'])) {
                 // get the last element of TREE_TRUNK
                 $lastId = false;
                 foreach ($this->dbResult['TREE_TRUNK'] as $id => $node) {
                     $lastId = $node['ID'];
                 }
                 if ($lastId != false) {
                     $parentId = $lastId;
                 }
             } else {
                 $parentId = 0;
                 // just root
             }
         }
         if ($parentId !== false) {
             // ... but if we get some bundle here, then it becomes complete
             unset($this->dbResult['BUNDLES_INCOMPLETE'][$parentId]);
             $parameters['filter']['=PARENT_ID'] = $parentId;
             $res = Location\LocationTable::getList($parameters);
             $res->addReplacedAliases(array('LNAME' => 'NAME'));
             while ($item = $res->fetch()) {
                 $this->dbResult['PRECACHED_POOL'][$item['PARENT_ID']][$item['ID']] = $item;
             }
         }
     }
     // filter through site link, if needed
     foreach ($this->dbResult['PRECACHED_POOL'] as $parent => &$items) {
         if (is_array($items)) {
             $this->identifyLinkType($items);
             foreach ($items as $k => &$item) {
                 if (isset($item['LINK_TYPE'])) {
                     if ($item['LINK_TYPE'] != Location\SiteLocationTable::LSTAT_IS_CONNECTOR && $item['LINK_TYPE'] != Location\SiteLocationTable::LSTAT_BELOW_CONNECTOR) {
                         $items[$k]['IS_UNCHOOSABLE'] = true;
                     }
                     if ($item['LINK_TYPE'] == Location\SiteLocationTable::LSTAT_IN_NOT_CONNECTED_BRANCH) {
                         unset($items[$k]);
                         continue;
                     }
                     unset($item['LINK_TYPE']);
                 }
             }
         }
     }
 }