$arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~GALLERY_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"])); } elseif (intVal($arResult["SECTION"]["IBLOCK_SECTION_ID"]) > 0) { $arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~SECTION_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $arResult["SECTION"]["IBLOCK_SECTION_ID"])); } else { $arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~INDEX_URL"], array()); } $arResultFields = array("ID" => $arResult["SECTION"]["ID"], "error" => "", "url" => $arResult["URL"]); } elseif ($e = $APPLICATION->GetException()) { $strWarning .= $e->GetString(); } else { $strWarning .= GetMessage("IBSEC_A_DELERR_REFERERS"); } } if (!$bVarsFromForm) { CIBlockSection::ReSort($arParams["IBLOCK_ID"]); PClearComponentCache(array("search.page", "search.tags.cloud", "photogallery.detail", "photogallery.detail.comment", "photogallery.detail.edit", "photogallery.detail.list", "photogallery.gallery.edit", "photogallery.gallery.list", "photogallery.section", "photogallery.section.edit", "photogallery.section.edit.icon", "photogallery.section.list", "photogallery.upload", "photogallery.user")); if ($arParams["AJAX_CALL"] == "Y") { $APPLICATION->RestartBuffer(); echo CUtil::PhpToJSObject($arResultFields); die; } else { LocalRedirect($arResult["URL"]); } } $arResult["ERROR_MESSAGE"] = $strWarning; } /******************************************************************** /Actions ********************************************************************/ /******************************************************************** Data
} elseif ($arParams["SECTION_ID"] != $_REQUEST["TO_SECTION_ID"]) { $result = array("url" => CComponentEngine::MakePathFromTemplate($arParams["~DETAIL_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $_REQUEST["TO_SECTION_ID"], "ELEMENT_ID" => $arResult["ELEMENT"]["ID"]))); } else { $arSelect = array("ID", "NAME", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "TAGS", "DATE_CREATE", "CREATED_BY"); $db_res = CIBlockElement::GetList(array(), array("ID" => $arParams["ELEMENT_ID"]), false, false, $arSelect); if ($db_res && ($res = $db_res->GetNext())) { $result = array("TAGS" => $res["TAGS"], "TITLE" => $res["NAME"], "DESCRIPTION" => $res["DETAIL_TEXT"], "DATE" => $res["DATE_CREATE"]); } else { $result = array("TAGS" => htmlspecialcharsEx($_REQUEST["TAGS"]), "TITLE" => htmlspecialcharsEx($_REQUEST["TITLE"]), "DESCRIPTION" => htmlspecialcharsEx($_REQUEST["DESCRIPTION"]), "DATE" => htmlspecialcharsEx($_REQUEST["DATE_CREATE"])); } } $arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~DETAIL_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $_REQUEST["TO_SECTION_ID"], "ELEMENT_ID" => $arResult["ELEMENT"]["ID"])); } } if (empty($arError)) { PClearComponentCache(array("search.page", "search.tags.cloud", "photogallery.detail/" . $arParams["IBLOCK_ID"] . "/detail/" . $_REQUEST["TO_SECTION_ID"] . "/", "photogallery.detail/" . $arParams["IBLOCK_ID"] . "/detail/" . $arResult["SECTION"]["ID"] . "/", "photogallery.detail.comment", "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/0", "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/" . $_REQUEST["TO_SECTION_ID"], "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/" . $arResult["SECTION"]["ID"], "photogallery.section/" . $arParams["IBLOCK_ID"] . "/section" . $arResult["SECTION"]["ID"], "photogallery.section/" . $arParams["IBLOCK_ID"] . "/section" . $arResult["SECTION"]["IBLOCK_SECTION_ID"], "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/section" . $arResult["SECTION"]["ID"], "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/sections" . $arResult["SECTION"]["IBLOCK_SECTION_ID"])); if ($arParams["AJAX_CALL"] == "Y") { $APPLICATION->RestartBuffer(); $result["DATE"] = PhotoDateFormat($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($result["DATE"], CSite::GetDateFormat())); echo CUtil::PhpToJSObject($result); die; } else { LocalRedirect($arResult["URL"]); } } else { $bVarsFromForm = true; $e = new CAdminException($arError); $arResult["ERROR_MESSAGE"] = $e->GetString(); } } elseif ($_REQUEST["edit"] == "cancel") { LocalRedirect($arResult["~DETAIL_LINK"]);
} PClearComponentCache(array("photogallery.detail.list", "photogallery.detail", "photogallery.detail.comment")); } if ($_REQUEST["ACTION"] == "active" || $_REQUEST["ACTION"] == "drop") { if ($_REQUEST["ACTION"] == "active") { $arFields = array("ACTIVE" => "Y"); $be = new CIBlockElement(); $be->Update($item, $arFields); } else { CIBlockElement::Delete($item); } // section if (is_set($arSections, $res["IBLOCK_SECTION_ID"])) { $res = $arSections[$res["IBLOCK_SECTION_ID"]]; } PClearComponentCache(array("search.page", "search.tags.cloud", "photogallery.detail", "photogallery.detail.comment", "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/0", "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/" . $res["ID"], "photogallery.section/" . $arParams["IBLOCK_ID"] . "/section" . $res["ID"], "photogallery.section/" . $arParams["IBLOCK_ID"] . "/section" . $res["IBLOCK_SECTION_ID"], "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/sections0", "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/sections" . $res["IBLOCK_SECTION_ID"])); } } LocalRedirect($_REQUEST["from_detail_list"]); } } $file = trim(preg_replace("'[\\\\/]+'", "/", dirname(__FILE__) . "/lang/" . LANGUAGE_ID . "/result_modifier.php")); __IncludeLang($file); $arParams["SHOW_BEST_ELEMENT"] = $arParams["SHOW_BEST_ELEMENT"] == "N" ? "N" : "Y"; $arResult["MENU_VARIABLES"] = array(); if ($this->__page !== "menu") { $sTempatePage = $this->__page; $sTempateFile = $this->__file; $this->__component->IncludeComponentTemplate("menu"); $this->__page = $sTempatePage; $this->__file = $sTempateFile;
} } /******************************************************************** /Input params ********************************************************************/ $arResult = array("~URL_TEMPLATES" => $arUrlTemplates, "URL_TEMPLATES" => $arResult["URL_TEMPLATES"], "VARIABLES" => $arVariables, "ALIASES" => is_array($arVariableAliases) ? $arVariableAliases : array(), "PAGE_NAME" => strToUpper($componentPage)); /******************************************************************** Actions ********************************************************************/ if ($_REQUEST["ACTION"] == "public" && $arParams["PERMISSION"] >= "W" && check_bitrix_sessid() && is_array($_REQUEST["items"])) { CModule::IncludeModule("iblock"); foreach ($_REQUEST["items"] as $res) { CIBlockElement::SetPropertyValues($res, $arParams["IBLOCK_ID"], "Y", "APPROVE_ELEMENT"); CIBlockElement::SetPropertyValues($res, $arParams["IBLOCK_ID"], "Y", "PUBLIC_ELEMENT"); } PClearComponentCache(array("photogallery.detail.comment", "photogallery.detail/" . $arParams["IBLOCK_ID"], "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/0")); $url = $arParams["DETAIL_LIST_URL"]; if (empty($url)) { $url = $APPLICATION->GetCurPageParam("PAGE_NAME=detail_list", array("PAGE_NAME", "SECTION_ID", "ELEMENT_ID", "ACTION", "sessid", "edit")); } $url = CComponentEngine::MakePathFromTemplate($url, array()); if (strpos($url, "?") === false) { $url .= "?"; } $url .= "&moderate=Y"; LocalRedirect($url); } if ($arParams["PERMISSION"] >= "W" && $_REQUEST["galleries_recalc"] == "Y") { $componentPage = "galleries_recalc"; } /********************************************************************
imagecopyresized($thumbnail, $picture, 0, 0, 0, 0, $arParams["ALBUM_PHOTO_THUMBS"]["WIDTH"], $arParams["ALBUM_PHOTO_THUMBS"]["HEIGHT"], $arParams["ALBUM_PHOTO"]["HEIGHT"], $arParams["ALBUM_PHOTO"]["HEIGHT"]); } CheckDirPath($arParams["PATH_TMP"]); imagejpeg($picture, $arParams["PATH_TMP"] . "iblock_section_" . $arResult["SECTION"]["ID"] . ".jpg", 95); imagejpeg($thumbnail, $arParams["PATH_TMP"] . "iblock_section_thumbnail_" . $arResult["SECTION"]["ID"] . ".jpg", 95); imagedestroy($picture); imagedestroy($thumbnail); $arFields = array("PICTURE" => array("name" => "iblock_section_thumbnail_" . $arResult["SECTION"]["ID"] . ".jpg", "type" => "image/jpeg", "tmp_name" => $arParams["PATH_TMP"] . "iblock_section_thumbnail_" . $arResult["SECTION"]["ID"] . ".jpg", "size" => filesize($arParams["PATH_TMP"] . "iblock_section_thumbnail_" . $arResult["SECTION"]["ID"] . ".jpg"), "MODULE_ID" => "iblock"), "DETAIL_PICTURE" => array("name" => "iblock_section_" . $arResult["SECTION"]["ID"] . ".jpg", "type" => "image/jpeg", "tmp_name" => $arParams["PATH_TMP"] . "iblock_section_" . $arResult["SECTION"]["ID"] . ".jpg", "size" => filesize($arParams["PATH_TMP"] . "iblock_section_" . $arResult["SECTION"]["ID"] . ".jpg"), "MODULE_ID" => "iblock")); $bs = new CIBlockSection(); $res = $bs->Update($arResult["SECTION"]["ID"], $arFields); @unlink($arFields["PICTURE"]["tmp_name"]); @unlink($arFields["DETAIL_PICTURE"]["tmp_name"]); if (!$res) { $arError[] = array("id" => "bad_update", "text" => $bs->LAST_ERROR); } else { PClearComponentCache(array("photogallery.section", "photogallery.section.list")); if ($arParams["AJAX_CALL"] == "Y") { $rsSection = CIBlockSection::GetList(array(), array("ID" => $arResult["SECTION"]["ID"])); $arResult["SECTION"] = $rsSection->Fetch(); $arResult["SECTION"]["DETAIL_PICTURE"] = CFile::GetFileArray($arResult["SECTION"]["DETAIL_PICTURE"]); $arFields = array("ID" => $arResult["SECTION"]["ID"], "SRC" => $arResult["SECTION"]["DETAIL_PICTURE"]["SRC"], "error" => ""); $APPLICATION->RestartBuffer(); echo CUtil::PhpToJSObject($arFields); die; } else { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams["SECTION_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $arResult["SECTION"]["ID"]))); } } } } if (!empty($arError)) {
function PClearComponentCacheEx($iblockId = false, $arSections = array(), $arGalleries = array(), $arUsers = array(), $clearCommon = true) { if (!$iblockId) { return; } $arCache = array(); $arCache[] = "photogallery"; if ($clearCommon) { $arCache[] = "search.page"; $arCache[] = "search.tags.cloud"; $arCache[] = "photogallery/" . $iblockId; $arCache[] = "photogallery/" . $iblockId . "/pemission"; $arCache[] = "photogallery.detail.comment/" . $iblockId; $arCache[] = "photogallery.gallery.list/" . $iblockId; } if (is_array($arSections)) { $arSections = array_unique($arSections); foreach ($arSections as $sectionId) { $arCache[] = "photogallery/" . $iblockId . "/section" . intVal($sectionId); } } $arCache[] = "photogallery/" . $iblockId . "/section" . intVal($sectionId); if (is_array($arGalleries)) { $arGalleries = array_unique($arGalleries); foreach ($arGalleries as $galleryCode) { $arCache[] = "photogallery/" . $iblockId . "/gallery" . $galleryCode; } // todo: secure galleryCode!!!! } if (is_array($arUsers)) { $arUsers = array_unique($arUsers); foreach ($arUsers as $userId) { $arCache[] = "photogallery/" . $iblockId . "/user" . intVal($userId); } } PClearComponentCache($arCache); }
/******************************************************************** /Default values ********************************************************************/ if ($arParams["COMMENTS_TYPE"] == "forum") { $this->IncludeComponentTemplate(); return true; } /************************************************************************* Caching *************************************************************************/ /************************************************************************* Before caching *************************************************************************/ // Clear cache. if (isset($_REQUEST["parentId"]) || $_REQUEST["save_product_review"] == "Y" || isset($_REQUEST["delete_comment_id"])) { PClearComponentCache(array("photogallery.detail.comment/" . $arParams["IBLOCK_ID"])); } /************************************************************************* /Before caching *************************************************************************/ $arResult["ELEMENT"] = array(); $cache = new CPHPCache(); $cache_path_main = str_replace(array(":", "//"), "/", "/" . SITE_ID . "/" . $componentName . "/" . $arParams["IBLOCK_ID"] . "/"); $cache_id = serialize(array("TYPE" => $arParams["COMMENTS_TYPE"], "USER" => $USER->GetGroups(), "ELEMENT_ID" => $arParams["ELEMENT_ID"])); $cache_path = $cache_path_main . "gallery" . $arParams["USER_ALIAS"]; if ($arParams["CACHE_TIME"] > 0 && $cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path)) { $res = $cache->GetVars(); $arResult["ELEMENT"] = $res["ELEMENT"]; $arResult["COMMENT_ID"] = $res["COMMENT_ID"]; } else { CModule::IncludeModule("iblock");