Exemplo n.º 1
0
					$arPictInfo = CFile::GetFileArray($pictNo);
					if (is_array($arPictInfo))
					{
						if(substr($arPictInfo["SRC"], 0, 1) == "/")
							$strFile = "http://".$arAcc['SERVER_NAME'].CHTTP::urnEncode($arPictInfo["SRC"], 'utf-8');
						else
							$strFile = $arPictInfo["SRC"];
						$strTmpOff.="<picture>".$strFile."</picture>\n";
					}
				}

				$strTmpOff.= "<name>".yandex_text2xml($arAcc["~NAME"], true)."</name>\n";
				$strTmpOff.=
					"<description>".
					yandex_text2xml(TruncateText(
						($arAcc["PREVIEW_TEXT_TYPE"]=="html"?
						strip_tags(preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"])) : preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"])),
						255), true).
					"</description>\n";
				$strTmpOff.= "</offer>\n";
				if (100 <= $cnt)
				{
					$cnt = 0;
					CCatalogDiscount::ClearDiscountCache(array(
						'PRODUCT' => true,
						'SECTIONS' => true,
						'PROPERTIES' => true
					));
				}
			}
		}
	}
Exemplo n.º 2
0
                            $strFile = $arPictInfo["SRC"];
                        }
                        $strTmpOff .= "<picture>" . $strFile . "</picture>\n";
                    }
                }
                $strTmpOff .= "<name>" . yandex_text2xml($arAcc["~NAME"], true) . "</name>\n";
                $strTmpOff .= "<description>" . yandex_text2xml(TruncateText($arAcc["PREVIEW_TEXT_TYPE"] == "html" ? strip_tags(preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"])) : preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"]), 255), true) . "</description>\n";
                $strTmpOff .= "</offer>\n";
                if (100 <= $cnt) {
                    $cnt = 0;
                    CCatalogDiscount::ClearDiscountCache(array('PRODUCT' => true, 'SECTIONS' => true, 'PROPERTIES' => true));
                }
            }
            if ($boolNeedRootSection) {
                $iblockName = CIBlock::GetArrayByID($yvalue, 'NAME');
                $strTmpCat .= '<category id="' . $maxSections[$yvalue] . '">' . yandex_text2xml(GetMessage('YANDEX_ROOT_DIRECTORY_EXT', array('#NAME#' => $iblockName)), true) . "</category>\n";
                unset($iblockName);
            }
        }
    }
    fwrite($fp, "<categories>\n");
    fwrite($fp, $strTmpCat);
    fwrite($fp, "</categories>\n");
    fwrite($fp, "<offers>\n");
    fwrite($fp, $strTmpOff);
    fwrite($fp, "</offers>\n");
    fwrite($fp, "</shop>\n");
    fwrite($fp, "</yml_catalog>\n");
    fclose($fp);
}
CCatalogDiscountSave::Enable();
Exemplo n.º 3
0
	function yandex_get_value($arOffer, $param, $PROPERTY)
	{
		global $IBLOCK_ID;
		static $arProperties = null, $arUserTypes = null;

		if (!is_array($arProperties))
		{
			$dbRes = CIBlockProperty::GetList(
				array('ID' => 'ASC'),
				array('IBLOCK_ID' => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N')
			);

			while ($arRes = $dbRes->Fetch())
			{
				$arProperties[$arRes['ID']] = $arRes;
			}

			if (!empty($arOffer['IBLOCK_ID']) && $arOffer['IBLOCK_ID'] != $IBLOCK_ID)
			{
				$dbRes = CIBlockProperty::GetList(
					array('ID' => 'ASC'),
					array('IBLOCK_ID' => $arOffer['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N')
				);

				while ($arRes = $dbRes->Fetch())
				{
					$arProperties[$arRes['ID']] = $arRes;
				}
			}
		}

		$strProperty = '';
		$bParam = substr($param, 0, 6) == 'PARAM_';
		if (is_array($arProperties[$PROPERTY]))
		{
			$PROPERTY_CODE = $arProperties[$PROPERTY]['CODE'];

			$arProperty = $arOffer['PROPERTIES'][$PROPERTY_CODE] ? $arOffer['PROPERTIES'][$PROPERTY_CODE] : $arOffer['PROPERTIES'][$PROPERTY];

			$value = '';
			$description = '';
			switch ($arProperties[$PROPERTY]['PROPERTY_TYPE'])
			{
				case 'E':
					if (!empty($arProperty['VALUE']))
					{
						$arCheckValue = array();
						if (!is_array($arProperty['VALUE']))
						{
							$arProperty['VALUE'] = intval($arProperty['VALUE']);
							if (0 < $arProperty['VALUE'])
								$arCheckValue[] = $arProperty['VALUE'];
						}
						else
						{
							foreach ($arProperty['VALUE'] as &$intValue)
							{
								$intValue = intval($intValue);
								if (0 < $intValue)
									$arCheckValue[] = $intValue;
							}
							if (isset($intValue))
								unset($intValue);
						}
						if (!empty($arCheckValue))
						{
							$dbRes = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $arProperties[$PROPERTY]['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, false, array('NAME'));
							while ($arRes = $dbRes->Fetch())
							{
								$value .= ($value ? ', ' : '').$arRes['NAME'];
							}
						}
					}
					break;
				case 'G':
					if (!empty($arProperty['VALUE']))
					{
						$arCheckValue = array();
						if (!is_array($arProperty['VALUE']))
						{
							$arProperty['VALUE'] = intval($arProperty['VALUE']);
							if (0 < $arProperty['VALUE'])
								$arCheckValue[] = $arProperty['VALUE'];
						}
						else
						{
							foreach ($arProperty['VALUE'] as &$intValue)
							{
								$intValue = intval($intValue);
								if (0 < $intValue)
									$arCheckValue[] = $intValue;
							}
							if (isset($intValue))
								unset($intValue);
						}
						if (!empty($arCheckValue))
						{
							$dbRes = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $arProperty['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, array('NAME'));
							while ($arRes = $dbRes->Fetch())
							{
								$value .= ($value ? ', ' : '').$arRes['NAME'];
							}
						}
					}
					break;
				case 'L':
					if ($arProperty['VALUE'])
					{
						if (is_array($arProperty['VALUE']))
							$value .= implode(', ', $arProperty['VALUE']);
						else
							$value .= $arProperty['VALUE'];
					}
					break;
				default:
					if ($bParam && $arProperty['WITH_DESCRIPTION'] == 'Y')
					{
						$description = $arProperty['DESCRIPTION'];
						$value = $arProperty['VALUE'];
					}
					else
					{
						$value = is_array($arProperty['VALUE']) ? implode(', ', $arProperty['VALUE']) : $arProperty['VALUE'];
					}
			}

			// !!!! check multiple properties and properties like CML2_ATTRIBUTES

			if ($bParam)
			{
				if (is_array($description))
				{
					foreach ($value as $key => $val)
					{
						$strProperty .= $strProperty ? "\n" : "";
						$strProperty .= '<param name="'.yandex_text2xml($description[$key], true).'">'.yandex_text2xml($val, true).'</param>';
					}
				}
				else
				{
					$strProperty .= '<param name="'.yandex_text2xml($arProperties[$PROPERTY]['NAME'], true).'">'.yandex_text2xml($value, true).'</param>';
				}
			}
			else
			{
				$param_h = yandex_text2xml($param, true);
				$strProperty .= '<'.$param_h.'>'.yandex_text2xml($value, true).'</'.$param_h.'>';
			}
		}

		return $strProperty;
		//if (is_callable(array($arParams["arUserField"]["USER_TYPE"]['CLASS_NAME'], 'getlist')))
	}
Exemplo n.º 4
0
        $strTmpOff .= "<currencyId>" . $minPriceCurrency . "</currencyId>\n";
        $strTmpOff .= $strTmpOff_tmp;
        if (IntVal($arAcc["DETAIL_PICTURE"]) > 0 || IntVal($arAcc["PREVIEW_PICTURE"]) > 0) {
            $pictNo = IntVal($arAcc["DETAIL_PICTURE"]);
            if ($pictNo <= 0) {
                $pictNo = IntVal($arAcc["PREVIEW_PICTURE"]);
            }
            $db_file = CFile::GetByID($pictNo);
            if ($ar_file = $db_file->Fetch()) {
                $strFile = "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/" . $ar_file["SUBDIR"] . "/" . $ar_file["FILE_NAME"];
                $strFile = str_replace("//", "/", $strFile);
                $strTmpOff .= "<picture>http://" . COption::GetOptionString("main", "server_name", "") . $strFile . "</picture>\n";
            }
        }
        $strTmpOff .= "<name>" . yandex_text2xml($arAcc["NAME"], true) . "</name>\n";
        $strTmpOff .= "<description>" . yandex_text2xml(TruncateText($arAcc["PREVIEW_TEXT_TYPE"] == "html" ? strip_tags(preg_replace_callback("'&[^;]*;'", "replace_special", $arAcc["~PREVIEW_TEXT"])) : $arAcc["PREVIEW_TEXT"], 255), true) . "</description>\n";
        $strTmpOff .= "</offer>\n";
    }
    @fwrite($fp, "<categories>\n");
    @fwrite($fp, $strTmpCat);
    @fwrite($fp, "</categories>\n");
    @fwrite($fp, "<offers>\n");
    @fwrite($fp, $strTmpOff);
    @fwrite($fp, "</offers>\n");
    @fwrite($fp, "</shop>\n");
    @fwrite($fp, "</yml_catalog>\n");
    @fclose($fp);
}
if ($bTmpUserCreated) {
    unset($USER);
}
Exemplo n.º 5
0
function yandex_get_value($arOffer, $param, $PROPERTY, &$arProperties, &$arUserTypeFormat)
{
	global $iblockServerName;

	$strProperty = '';
	$bParam = (strncmp($param, 'PARAM_', 6) == 0);
	if (isset($arProperties[$PROPERTY]) && !empty($arProperties[$PROPERTY]))
	{
		$PROPERTY_CODE = $arProperties[$PROPERTY]['CODE'];
		$arProperty = (
			isset($arOffer['PROPERTIES'][$PROPERTY_CODE])
			? $arOffer['PROPERTIES'][$PROPERTY_CODE]
			: $arOffer['PROPERTIES'][$PROPERTY]
		);

		$value = '';
		$description = '';
		switch ($arProperties[$PROPERTY]['PROPERTY_TYPE'])
		{
			case 'USER_TYPE':
				if ($arProperty['MULTIPLE'] == 'Y')
				{
					if (!empty($arProperty['~VALUE']))
					{
						$arValues = array();
						foreach($arProperty["~VALUE"] as $oneValue)
						{
							$isArray = is_array($oneValue);
							if (
								($isArray && !empty($oneValue))
								|| (!$isArray && $oneValue != '')
							)
							{
								$arValues[] = call_user_func_array($arUserTypeFormat[$PROPERTY],
									array(
										$arProperty,
										array("VALUE" => $oneValue),
										array('MODE' => 'SIMPLE_TEXT'),
									)
								);
							}
						}
						$value = implode(', ', $arValues);
					}
				}
				else
				{
					$isArray = is_array($arProperty['~VALUE']);
					if (
						($isArray && !empty($arProperty['~VALUE']))
						|| (!$isArray && $arProperty['~VALUE'] != '')
					)
					{
						$value = call_user_func_array($arUserTypeFormat[$PROPERTY],
							array(
								$arProperty,
								array("VALUE" => $arProperty["~VALUE"]),
								array('MODE' => 'SIMPLE_TEXT'),
							)
						);
					}
				}
				break;
			case 'E':
				if (!empty($arProperty['VALUE']))
				{
					$arCheckValue = array();
					if (!is_array($arProperty['VALUE']))
					{
						$arProperty['VALUE'] = (int)$arProperty['VALUE'];
						if (0 < $arProperty['VALUE'])
							$arCheckValue[] = $arProperty['VALUE'];
					}
					else
					{
						foreach ($arProperty['VALUE'] as &$intValue)
						{
							$intValue = (int)$intValue;
							if (0 < $intValue)
								$arCheckValue[] = $intValue;
						}
						if (isset($intValue))
							unset($intValue);
					}
					if (!empty($arCheckValue))
					{
						$dbRes = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $arProperties[$PROPERTY]['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, false, array('NAME'));
						while ($arRes = $dbRes->Fetch())
						{
							$value .= ($value ? ', ' : '').$arRes['NAME'];
						}
					}
				}
				break;
			case 'G':
				if (!empty($arProperty['VALUE']))
				{
					$arCheckValue = array();
					if (!is_array($arProperty['VALUE']))
					{
						$arProperty['VALUE'] = (int)$arProperty['VALUE'];
						if (0 < $arProperty['VALUE'])
							$arCheckValue[] = $arProperty['VALUE'];
					}
					else
					{
						foreach ($arProperty['VALUE'] as &$intValue)
						{
							$intValue = (int)$intValue;
							if (0 < $intValue)
								$arCheckValue[] = $intValue;
						}
						if (isset($intValue))
							unset($intValue);
					}
					if (!empty($arCheckValue))
					{
						$dbRes = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $arProperty['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, array('NAME'));
						while ($arRes = $dbRes->Fetch())
						{
							$value .= ($value ? ', ' : '').$arRes['NAME'];
						}
					}
				}
				break;
			case 'L':
				if (!empty($arProperty['VALUE']))
				{
					if (is_array($arProperty['VALUE']))
						$value .= implode(', ', $arProperty['VALUE']);
					else
						$value .= $arProperty['VALUE'];
				}
				break;
			case 'F':
				if (!empty($arProperty['VALUE']))
				{
					if (is_array($arProperty['VALUE']))
					{
						foreach ($arProperty['VALUE'] as &$intValue)
						{
							$intValue = (int)$intValue;
							if ($intValue > 0)
							{
								if ($ar_file = CFile::GetFileArray($intValue))
								{
									if(substr($ar_file["SRC"], 0, 1) == "/")
										$strFile = "http://".$iblockServerName.CHTTP::urnEncode($ar_file['SRC'], 'utf-8');
									else
										$strFile = $ar_file["SRC"];
									$value .= ($value ? ', ' : '').$strFile;
								}
							}
						}
						if (isset($intValue))
							unset($intValue);
					}
					else
					{
						$arProperty['VALUE'] = (int)$arProperty['VALUE'];
						if ($arProperty['VALUE'] > 0)
						{
							if ($ar_file = CFile::GetFileArray($arProperty['VALUE']))
							{
								if(substr($ar_file["SRC"], 0, 1) == "/")
									$strFile = "http://".$iblockServerName.CHTTP::urnEncode($ar_file['SRC'], 'utf-8');
								else
									$strFile = $ar_file["SRC"];
								$value = $strFile;
							}
						}
					}
				}
				break;
			default:
				if ($bParam && $arProperty['WITH_DESCRIPTION'] == 'Y')
				{
					$description = $arProperty['DESCRIPTION'];
					$value = $arProperty['VALUE'];
				}
				else
				{
					$value = is_array($arProperty['VALUE']) ? implode(', ', $arProperty['VALUE']) : $arProperty['VALUE'];
				}
		}

		// !!!! check multiple properties and properties like CML2_ATTRIBUTES

		if ($bParam)
		{
			if (is_array($description))
			{
				foreach ($value as $key => $val)
				{
					$strProperty .= $strProperty ? "\n" : "";
					$strProperty .= '<param name="'.yandex_text2xml($description[$key], true).'">'.yandex_text2xml($val, true).'</param>';
				}
			}
			else
			{
				$strProperty .= '<param name="'.yandex_text2xml($arProperties[$PROPERTY]['NAME'], true).'">'.yandex_text2xml($value, true).'</param>';
			}
		}
		else
		{
			$param_h = yandex_text2xml($param, true);
			$strProperty .= '<'.$param_h.'>'.yandex_text2xml($value, true).'</'.$param_h.'>';
		}
	}

	return $strProperty;
}