• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/logger.php
  • Класс: BitrixSaleTradingPlatformVkLogger
  • Вызов: Logger::getErrorsList
public function getErrorsList($flagCritical = false)
{
	$errorsConverted = array();
	$errorsConvertedStrings = array();
	$result = '';
	$errorsExistings = $this->getExistingErrors();
	$errorsDescriptions = $this->getErrorsDescriptions();
	
	if ($errorsExistings)
	{
		foreach ($errorsExistings as $err)
		{
//				only described and not ignored errors
			if (
				array_key_exists($err['ERROR_CODE'], $errorsDescriptions) &&
				!$errorsDescriptions[$err['ERROR_CODE']]['IGNORE']
			)
			{
//					if first error with this code - create new item
				$errorsConverted[$err['ERROR_CODE']]['MESSAGE'] = $errorsDescriptions[$err['ERROR_CODE']]['MESSAGE'];
				if ($err['ITEM_ID'])
					$errorsConverted[$err['ERROR_CODE']]['ITEMS'][$err['ITEM_ID']] = $err['ITEM_ID'];
			}

//				unknown errors (if not ignored)
			elseif (!$errorsDescriptions[$err['ERROR_CODE']]['IGNORE'])
			{
				$errorsConverted['UNKNOWN']['MESSAGE'] = Loc::getMessage("SALE_VK_ERRORS__UNKNOWN") . '. ' . Loc::getMessage("SALE_VK_ERRORS__ERRORS_CODES");
//					add codes as items to show in future
				if ($err['ERROR_CODE'])
					$errorsConverted['UNKNOWN']['ITEMS'][$err['ERROR_CODE']] = $err['ERROR_CODE'];
			}
		}

//			implode converted errors to one string for showing
		foreach ($errorsConverted as $errCode => $err)
		{
			$errCritical = $errorsDescriptions[$errCode]['CRITICAL'];
//				get errors by CRITICAL flag
			
			if ($errCritical == $flagCritical)
			{
				$itemsConvertedString = '';
				$itemsConverted = array();
				$itemsConvertedHide = array();
//					create strings for every item
				if (array_key_exists('ITEMS', $err) && !empty($err['ITEMS']))
				{
					$itemsCount = 0;
					foreach ($err['ITEMS'] as $item)
					{
						$itemConverted = $this->createItemErrorString(
							$item,
							$errCode
						);
						$itemsCount++;
						
						if ($itemConverted <> '')
							if ($itemsCount <= self::MAX_SHOWING_ERRORS_ITEMS)
								$itemsConverted[] = $itemConverted;
							else
								$itemsConvertedHide[] = $itemConverted;
					}
					if (!empty($itemsConverted))
						$itemsConvertedString = ': ' . implode(', ', $itemsConverted);
					if (!empty($itemsConvertedHide))
					{
						$itemsConvertedString .= ', 
						';
						$itemsConvertedString .= '
						
							' .
							Loc::getMessage('SALE_VK_ERRORS__MORE_ELEMENTS',
								array('#C1' => $itemsCount - self::MAX_SHOWING_ERRORS_ITEMS)) .
							'
							
							
						
					';
					}
				}

//					create common string for one error
				$errorsConvertedStrings[$errCode] =
					'

' . $err['MESSAGE'] . $itemsConvertedString . '

'; } // for critical errors show message just once - clean after get message if ($errCritical && $flagCritical) { $criticalErrors = $this->getExistingErrors($errCode); foreach ($criticalErrors as $error) $resDelete = LogTable::delete($error['ID']); } } $errorsConvertedString = implode('', $errorsConvertedStrings); // add intro before errors if ($errorsConvertedString <> '') { $result = $flagCritical ? Loc::getMessage("SALE_VK_ERRORS__INTRO_CRITICAL") : Loc::getMessage("SALE_VK_ERRORS__INTRO_NORMAL"); $result .= ':
' . $errorsConvertedString; } // check if need download log file if ($result <> '') { $vk = Vk::getInstance(); if ($richLog = $vk->getRichLog($this->exportId)) { $href = '/bitrix/admin/sale_vk_export_edit.php' . '?ID=' . $this->exportId . '&lang=' . LANG . '&download_log=Y'; $result .= '

' . Loc::getMessage("SALE_VK_ERRORS__LOG_TITLE") . ': ' . Loc::getMessage("SALE_VK_ERRORS__LOG_DOWNLOAD") . '.

'; } } return $result; } // not errors else { return ''; } }