本文整理汇总了PHP中CIBlock::ResizePicture方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlock::ResizePicture方法的具体用法?PHP CIBlock::ResizePicture怎么用?PHP CIBlock::ResizePicture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlock
的用法示例。
在下文中一共展示了CIBlock::ResizePicture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
function Update($ID, $arFields, $bWorkFlow = false, $bUpdateSearch = true, $bResizePictures = false, $bCheckDiskQuota = true)
{
global $DB, $USER;
$ID = intval($ID);
$db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "TIMESTAMP_X", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_NEW", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID"));
if (!($ar_element = $db_element->Fetch())) {
return false;
}
$arIBlock = CIBlock::GetArrayByID($ar_element["IBLOCK_ID"]);
$bWorkFlow = $bWorkFlow && is_array($arIBlock) && $arIBlock["WORKFLOW"] != "N" && CModule::IncludeModule("workflow");
$ar_wf_element = $ar_element;
$LAST_ID = 0;
if ($bWorkFlow) {
$LAST_ID = CIBlockElement::WF_GetLast($ID);
if ($LAST_ID != $ID) {
$db_element = CIBlockElement::GetByID($LAST_ID);
if (!($ar_wf_element = $db_element->Fetch())) {
return false;
}
}
$arFields["WF_PARENT_ELEMENT_ID"] = $ID;
if (!array_key_exists("PROPERTY_VALUES", $arFields) || !is_array($arFields["PROPERTY_VALUES"])) {
$arFields["PROPERTY_VALUES"] = array();
}
$bFieldProps = array();
foreach ($arFields["PROPERTY_VALUES"] as $k => $v) {
$bFieldProps[$k] = true;
}
$arFieldProps =& $arFields['PROPERTY_VALUES'];
$props = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_wf_element["ID"]);
while ($arProp = $props->Fetch()) {
$pr_val_id = $arProp['PROPERTY_VALUE_ID'];
if ($arProp['PROPERTY_TYPE'] == 'F' && strlen($pr_val_id) > 0) {
if (strlen($arProp["CODE"]) > 0 && is_set($arFieldProps, $arProp["CODE"])) {
$pr_id = $arProp["CODE"];
} else {
$pr_id = $arProp['ID'];
}
if (array_key_exists($pr_id, $arFieldProps) && array_key_exists($pr_val_id, $arFieldProps[$pr_id]) && is_array($arFieldProps[$pr_id][$pr_val_id])) {
$new_value = $arFieldProps[$pr_id][$pr_val_id];
if (strlen($new_value['name']) <= 0 && $new_value['del'] != "Y" && strlen($new_value['VALUE']['name']) <= 0 && $new_value['VALUE']['del'] != "Y") {
if (array_key_exists('DESCRIPTION', $new_value) && $new_value['DESCRIPTION'] != $arProp['DESCRIPTION']) {
$p = array("VALUE" => CFile::MakeFileArray($arProp['VALUE']));
$p["DESCRIPTION"] = $new_value["DESCRIPTION"];
$p["MODULE_ID"] = "iblock";
$arFieldProps[$pr_id][$pr_val_id] = $p;
} elseif ($arProp['VALUE'] > 0) {
$arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]);
}
}
} else {
$arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]);
}
continue;
}
if (strlen($pr_val_id) <= 0 || array_key_exists($arProp["ID"], $bFieldProps) || strlen($arProp["CODE"]) > 0 && array_key_exists($arProp["CODE"], $bFieldProps)) {
continue;
}
$arFieldProps[$arProp["ID"]][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]);
}
if ($ar_wf_element["IN_SECTIONS"] == "Y") {
$ar_wf_element["IBLOCK_SECTION"] = array();
$rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID'));
while ($arSection = $rsSections->Fetch()) {
$ar_wf_element["IBLOCK_SECTION"][] = $arSection["ID"];
}
}
unset($ar_wf_element["DATE_ACTIVE_FROM"]);
unset($ar_wf_element["DATE_ACTIVE_TO"]);
unset($ar_wf_element["EXTERNAL_ID"]);
unset($ar_wf_element["TIMESTAMP_X"]);
unset($ar_wf_element["ID"]);
$arFields = $arFields + $ar_wf_element;
}
$arFields["WF"] = $bWorkFlow ? "Y" : "N";
$bBizProc = is_array($arIBlock) && $arIBlock["BIZPROC"] == "Y" && IsModuleInstalled("bizproc");
if (array_key_exists("BP_PUBLISHED", $arFields)) {
if ($bBizProc) {
if ($arFields["BP_PUBLISHED"] == "Y") {
$arFields["WF_STATUS_ID"] = 1;
$arFields["WF_NEW"] = false;
} else {
$arFields["WF_STATUS_ID"] = 2;
$arFields["WF_NEW"] = "Y";
$arFields["BP_PUBLISHED"] = "N";
}
} else {
$arFields["WF_NEW"] = false;
unset($arFields["BP_PUBLISHED"]);
}
} else {
$arFields["WF_NEW"] = false;
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") {
$arFields["PREVIEW_TEXT_TYPE"] = "text";
}
if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") {
//.........这里部分代码省略.........
示例2: Add
function Add($arFields, $bWorkFlow = false, $bUpdateSearch = true, $bResizePictures = false)
{
global $DB, $USER;
$arIBlock = CIBlock::GetArrayByID($arFields["IBLOCK_ID"]);
$bWorkFlow = $bWorkFlow && is_array($arIBlock) && $arIBlock["WORKFLOW"] != "N" && CModule::IncludeModule("workflow");
$bBizProc = is_array($arIBlock) && $arIBlock["BIZPROC"] == "Y" && IsModuleInstalled("bizproc");
if (array_key_exists("BP_PUBLISHED", $arFields)) {
if ($bBizProc) {
if ($arFields["BP_PUBLISHED"] == "Y") {
$arFields["WF_STATUS_ID"] = 1;
$arFields["WF_NEW"] = false;
} else {
$arFields["WF_STATUS_ID"] = 2;
$arFields["WF_NEW"] = "Y";
$arFields["BP_PUBLISHED"] = "N";
}
} else {
unset($arFields["BP_PUBLISHED"]);
}
}
if (array_key_exists("IBLOCK_SECTION_ID", $arFields)) {
if (!array_key_exists("IBLOCK_SECTION", $arFields)) {
$arFields["IBLOCK_SECTION"] = array($arFields["IBLOCK_SECTION_ID"]);
} elseif (is_array($arFields["IBLOCK_SECTION"]) && !in_array($arFields["IBLOCK_SECTION_ID"], $arFields["IBLOCK_SECTION"])) {
unset($arFields["IBLOCK_SECTION_ID"]);
}
}
$strWarning = "";
if ($bResizePictures) {
$arDef = $arIBlock["FIELDS"]["PREVIEW_PICTURE"]["DEFAULT_VALUE"];
if ($arDef["FROM_DETAIL"] === "Y" && is_array($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["size"] > 0 && ($arDef["UPDATE_WITH_DETAIL"] === "Y" || $arFields["PREVIEW_PICTURE"]["size"] <= 0)) {
$arNewPreview = $arFields["DETAIL_PICTURE"];
$arNewPreview["COPY_FILE"] = "Y";
if (isset($arFields["PREVIEW_PICTURE"]) && is_array($arFields["PREVIEW_PICTURE"]) && isset($arFields["PREVIEW_PICTURE"]["description"])) {
$arNewPreview["description"] = $arFields["PREVIEW_PICTURE"]["description"];
}
$arFields["PREVIEW_PICTURE"] = $arNewPreview;
}
if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["SCALE"] === "Y") {
$arNewPicture = CIBlock::ResizePicture($arFields["PREVIEW_PICTURE"], $arDef);
if (is_array($arNewPicture)) {
$arNewPicture["description"] = $arFields["PREVIEW_PICTURE"]["description"];
$arFields["PREVIEW_PICTURE"] = $arNewPicture;
} elseif ($arDef["IGNORE_ERRORS"] !== "Y") {
unset($arFields["PREVIEW_PICTURE"]);
$strWarning .= GetMessage("IBLOCK_FIELD_PREVIEW_PICTURE") . ": " . $arNewPicture . "<br>";
}
}
if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") {
if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) {
$tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"]));
CheckDirPath($tmp_name);
copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name);
$arFields["PREVIEW_PICTURE"]["copy"] = true;
$arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name;
}
CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"])));
}
if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") {
if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) {
$tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"]));
CheckDirPath($tmp_name);
copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name);
$arFields["PREVIEW_PICTURE"]["copy"] = true;
$arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name;
}
CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"]));
}
$arDef = $arIBlock["FIELDS"]["DETAIL_PICTURE"]["DEFAULT_VALUE"];
if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["SCALE"] === "Y") {
$arNewPicture = CIBlock::ResizePicture($arFields["DETAIL_PICTURE"], $arDef);
if (is_array($arNewPicture)) {
$arNewPicture["description"] = $arFields["DETAIL_PICTURE"]["description"];
$arFields["DETAIL_PICTURE"] = $arNewPicture;
} elseif ($arDef["IGNORE_ERRORS"] !== "Y") {
unset($arFields["DETAIL_PICTURE"]);
$strWarning .= GetMessage("IBLOCK_FIELD_DETAIL_PICTURE") . ": " . $arNewPicture . "<br>";
}
}
if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") {
if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) {
$tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"]));
CheckDirPath($tmp_name);
copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name);
$arFields["DETAIL_PICTURE"]["copy"] = true;
$arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name;
}
CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"])));
}
if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") {
if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) {
$tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"]));
CheckDirPath($tmp_name);
copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name);
$arFields["DETAIL_PICTURE"]["copy"] = true;
$arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name;
}
CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"]));
}
}
//.........这里部分代码省略.........