Esempio n. 1
0
 protected static function getLocationStringByCondition($condition, $behaviour = array('INVERSE' => false, 'DELIMITER' => ', ', 'LANGUAGE_ID' => LANGUAGE_ID))
 {
     if (isset($behaviour) && !is_array($behaviour)) {
         $behaviour = array();
     }
     if (!isset($behaviour['DELIMITER'])) {
         $behaviour['DELIMITER'] = ', ';
     }
     if (!isset($behaviour['LANGUAGE_ID'])) {
         $behaviour['LANGUAGE_ID'] = LANGUAGE_ID;
     }
     try {
         $res = Location\LocationTable::getPathToNodeByCondition($condition, array('select' => array('LNAME' => 'NAME.NAME'), 'filter' => array('=NAME.LANGUAGE_ID' => $behaviour['LANGUAGE_ID'])));
         $path = array();
         while ($item = $res->fetch()) {
             $path[] = $item['LNAME'];
         }
         if ($behaviour['INVERSE']) {
             $path = array_reverse($path);
         }
         return implode($behaviour['DELIMITER'], $path);
     } catch (\Bitrix\Main\SystemException $e) {
         return '';
     }
 }
Esempio n. 2
0
	protected function obtainDataTreeTrunk(&$cachedData)
	{
		// check for static tree
		$forkItemFilter = false;

		$res = Location\LocationTable::getList(array(
			'group' => array('DEPTH_LEVEL'),
			'select' => array('DEPTH_LEVEL', 'CNT'),
			'order' => array('DEPTH_LEVEL' => 'asc')
		));
		$forkAtLevel = 0;
		while($item = $res->fetch())
		{
			if($item['CNT'] < 2)
				$forkAtLevel = $item['DEPTH_LEVEL'];
			else
				break;
		}

		if($forkAtLevel > 0)
			$forkItemFilter = array('DEPTH_LEVEL' => $forkAtLevel);

		// check for tree filtered by site

		if($this->filterBySite && is_array($cachedData['TEMP']['CONNECTORS']) && !empty($cachedData['TEMP']['CONNECTORS']))
		{
			$dcp = Location\LocationTable::getDeepestCommonParent($cachedData['TEMP']['CONNECTORS'], array('select' => array('ID')))->fetch();

			if(is_array($dcp) && intval($dcp['ID']))
				$forkItemFilter = array('ID' => intval($dcp['ID']));
		}

		$cachedData['TREE_TRUNK'] = array();
		if(is_array($forkItemFilter) && !empty($forkItemFilter)) // get fork item id
		{
			$res = Location\LocationTable::getPathToNodeByCondition($forkItemFilter, array(
				'select' => array_merge($this->getNodeSelectFields(), array('LNAME' => 'NAME.NAME')),
				'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID)
			));
			$res->addReplacedAliases(array('LNAME' => 'NAME'));
			while($item = $res->fetch())
			{
				$cachedData['TREE_TRUNK'][] = $item;
			}
		}
	}