ob_start(); $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:iblock.vote", "ajax", array("IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "ELEMENT_ID" => $key, "READ_ONLY" => $arParams["READ_ONLY"], "MAX_VOTE" => $arParams["MAX_VOTE"], "VOTE_NAMES" => $arParams["VOTE_NAMES"], "DISPLAY_AS_RATING" => $arParams["DISPLAY_AS_RATING"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"]), $this->__component->__parent ? $this->__component->__parent : $component, array("HIDE_ICONS" => "Y")); $text = ob_get_clean(); $arResult["ELEMENTS_LIST_JS"][$key]["rating"] = preg_replace(array("/\\<script([^>]+)\\>/is", "/\\<\\/script([^>]*)\\>/is", "/(?<=)([^]+)(?=)/is", "/[\n\t]/", "/\\s\\s/"), array("", "", "", "", " "), $text); } $arResult["ELEMENTS_LIST_JS"][$key]["comments"] = ''; if ($arParams["USE_COMMENTS"] == "Y") { $arResult["ELEMENTS_LIST_JS"][$key]["comments"] = intVal($arParams["COMMENTS_TYPE"] != "blog" ? $arResult["ELEMENTS_LIST"][$key]["PROPERTIES"]["FORUM_MESSAGE_CNT"]["VALUE"] : $arResult["ELEMENTS_LIST"][$key]["PROPERTIES"]["BLOG_COMMENTS_CNT"]["VALUE"]); if ($arResult["ELEMENTS_LIST_JS"][$key]["comments"] > 0) { $arResult["ELEMENTS_LIST_JS"][$key]["comments"] = $arResult["ELEMENTS_LIST_JS"][$key]["comments"] . " " . __photo_template_default_comments_ending($arResult["ELEMENTS_LIST_JS"][$key]["comments"]); } else { $arResult["ELEMENTS_LIST_JS"][$key]["comments"] = GetMessage("P_TO_COMMENT"); } } if ($arResult["ELEMENTS_LIST_JS"][$key]["shows"] > 0) { $arResult["ELEMENTS_LIST_JS"][$key]["shows"] = $arResult["ELEMENTS_LIST_JS"][$key]["shows"] . " " . __photo_template_default_shows_ending($arResult["ELEMENTS_LIST_JS"][$key]["shows"]); } $arResult["ELEMENTS_LIST_JS"][$key]["width"] = $arResult["ELEMENTS_LIST"][$key]["REAL_PICTURE"]["WIDTH"]; $arResult["ELEMENTS_LIST_JS"][$key]["height"] = $arResult["ELEMENTS_LIST"][$key]["REAL_PICTURE"]["HEIGHT"]; $arResult["ELEMENTS_LIST_JS"][$key]["src"] = $arResult["ELEMENTS_LIST"][$key]["REAL_PICTURE"]["SRC"]; } $res = array("elements" => array_values($arResult["ELEMENTS_LIST_JS"]), "start_number" => 1, "elements_count" => count($arResult['ELEMENTS_LIST_JS']), "status" => "end"); if ($arResult["NAV_RESULT"]->bNavStart) { $number_element = ($arResult["NAV_RESULT"]->NavPageNomer - 1) * $arResult["NAV_RESULT"]->NavPageSize + 1; if ($arResult["NAV_RESULT"]->bDescPageNumbering) { $number_element = 1; if ($arResult["NAV_RESULT"]->NavPageNomer < $arResult["NAV_RESULT"]->NavPageCount) { $number_element += $arResult["NAV_RESULT"]->NavRecordCount % $arResult["NAV_RESULT"]->NavPageSize + $arResult["NAV_RESULT"]->NavPageSize; $number_element += $arResult["NAV_RESULT"]->NavPageSize * ($arResult["NAV_RESULT"]->NavPageCount - $arResult["NAV_RESULT"]->NavPageNomer - 1); } }
function __photo_template_default($arItem, $arParams = array()) { if (!function_exists("__photo_template_default_comments_ending")) { function __photo_template_default_comments_ending($count) { $text = GetMessage("P_COMMENTS"); $count = intVal($count); $iCount = intVal($count % 100); if (!(10 < $iCount && $iCount < 20)) { $count = intVal($count % 10); if ($count == 1) { $text = GetMessage("P_COMMENT"); } elseif ($count > 1 && $count < 5) { $text = GetMessage("P_COMMENTS_2"); } } return $text; } } if (!function_exists("__photo_template_default_shows_ending")) { function __photo_template_default_shows_ending($count) { $text = GetMessage("P_SHOWS"); $count = intVal($count); $iCount = intVal($count % 100); if (!(10 < $iCount && $iCount < 20)) { $count = intVal($count % 10); if ($count == 1) { $text = GetMessage("P_SHOW"); } elseif ($count > 1 && $count < 5) { $text = GetMessage("P_SHOWS_2"); } } return $text; } } static $bFirstOnPage = true; $arParams = is_array($arParams) ? $arParams : array(); $arParams["mode"] = $arParams["mode"] == "edit" ? "edit" : "read"; // $arParams["view"] = ($arParams["view"] == "square" ? "square" : "default"); // $arParams["percent"] = intval(intval($arParams["percent"]) > 0 ? $arParams["percent"] : 70); $arParams["MAX_HEIGHT"] = intval($arParams["MAX_HEIGHT"]); $arParams["MAX_WIDTH"] = intval($arParams["MAX_WIDTH"]); $bActiveElement = $arItem["ACTIVE"] != "Y" ? false : true; if (is_array($arItem["PICTURE"])) { $coeff = max($arItem["PICTURE"]["WIDTH"] / $arParams["MAX_WIDTH"], $arItem["PICTURE"]["HEIGHT"] / $arParams["MAX_HEIGHT"]); if ($coeff > 1) { $arItem["PICTURE"]["WIDTH"] = intval(roundEx($arItem["PICTURE"]["WIDTH"] / $coeff)); $arItem["PICTURE"]["HEIGHT"] = intval(roundEx($arItem["PICTURE"]["HEIGHT"] / $coeff)); } $sImage = "<img src=\"" . $arItem["PICTURE"]["SRC"] . "\" " . "border=\"0\" vspace=\"0\" hspace=\"0\" alt=\"" . $arItem["TITLE"] . "\" title=\"" . $arItem["TITLE"] . "\" " . "width=\"" . $arItem["PICTURE"]["WIDTH"] . "\" height=\"" . $arItem["PICTURE"]["HEIGHT"] . "\" />"; } else { $sImage = "<div style='width:" . $arParams["MAX_WIDTH"] . "px; height:" . $arParams["MAX_HEIGHT"] . "px;' title='" . $arItem["TITLE"] . "'></div>"; $arItem["PICTURE"] = array("WIDTH" => $arParams["MAX_WIDTH"], "HEIGHT" => $arParams["MAX_HEIGHT"]); } ?> <table border="0" cellpadding="0" class="photo-photo-item photo-photo-item-default <?php echo $arParams["mode"] == "edit" ? " photo-photo-item-edit" : ""; echo !$bActiveElement ? " photo-photo-item-notapproved" : ""; echo in_array($arItem["ID"], $_REQUEST["items"]) ? " photo-photo-item-checked" : ""; ?> " id="table_<?php echo $arItem["ID"]; ?> "> <tr> <td class="photo-photo-item" style="height:<?php echo $arParams["MAX_HEIGHT"]; ?> px;"> <div style="padding-top:<?php echo intval($arParams["MAX_HEIGHT"] - $arItem["PICTURE"]["HEIGHT"]); ?> px;"> <div class="photo-photo-item-inner"><?php ?> <div style="position:relative;"><?php if ($arParams["mode"] == "edit") { ?> <input type="checkbox" value="<?php echo $arItem["ID"]; ?> " <?php ?> name="items[]" <?php ?> id="items_<?php echo $arItem["ID"]; ?> " <?php echo in_array($arItem["ID"], $_REQUEST["items"]) ? " checked='checked'" : ""; ?> style="position:absolute;" <?php ?> onclick="var res=document.getElementById('table_<?php echo $arItem["ID"]; ?> '); <?php ?> if (this.checked){res.className+=' photo-photo-item-checked'} <?php ?> else {res.className=res.className.replace(/photo\-photo\-item\-checked/g, ' ').replace(/\s\s/g, ' ');}" /><?php } if ($arParams["SHOW_ANCHOR"] != "Y") { echo $sImage; } else { ?> <a href="<?php echo $arItem["URL"]; ?> " id="photo_<?php echo $arItem["ID"]; ?> " style="display:block; width: <?php echo $arItem["PICTURE"]["WIDTH"]; ?> px; height: <?php echo $arItem["PICTURE"]["HEIGHT"]; ?> px;"<?php if (!empty($arItem["EVENTS"])) { foreach ($arItem["EVENTS"] as $key => $val) { ?> on<?php echo $key; ?> ="<?php echo $val; ?> " <?php } } ?> ><?php echo $sImage; ?> </a><?php } ?> </div><?php ?> </div> </div> </td> </tr> <?php if ($arParams["SHOW_COMMENTS"] == "Y") { ?> <tr> <td class="photo-photo-info"> <div class="photo-photo-comments"> <?php if ($arItem["COMMENTS"] > 0) { $sText = $arItem["COMMENTS"] . " " . __photo_template_default_comments_ending($arItem["COMMENTS"]); if ($arParams["SHOW_ANCHOR"] != "Y") { echo $sText; } else { ?> <a href="<?php echo $arItem["URL"]; ?> "><?php echo $sText; ?> </a><?php } } ?> </div> </td> </tr> <?php } elseif ($arParams["SHOW_SHOWS"] == "Y") { ?> <tr> <td class="photo-photo-info"> <div class="photo-photo-comments"> <?php if ($arItem["SHOW_COUNTER"] > 0) { $sText = $arItem["SHOW_COUNTER"] . " " . __photo_template_default_shows_ending($arItem["SHOW_COUNTER"]); if ($arParams["SHOW_ANCHOR"] != "Y") { echo $sText; } else { ?> <a href="<?php echo $arItem["URL"]; ?> "><?php echo $sText; ?> </a><?php } } ?> </div> </td> </tr> <?php } elseif ($arParams["SHOW_RATING"] == "Y") { ?> <tr> <td class="photo-photo-info"> <div class="photo-photo-comments"> <?php $DISPLAY_VALUE = doubleval($arItem["PROPERTIES"]["rating"]["VALUE"]); if ($arParams["DISPLAY_AS_RATING"] == "vote_avg") { if ($arItem["PROPERTIES"]["vote_count"]["VALUE"]) { $DISPLAY_VALUE = round($arItem["PROPERTIES"]["vote_sum"]["VALUE"] / $arItem["PROPERTIES"]["vote_count"]["VALUE"], 2); } else { $DISPLAY_VALUE = 0; } } if ($DISPLAY_VALUE > 0) { $sText = GetMessage("P_RATING") . ": " . $DISPLAY_VALUE; $sTitle = ""; if ($arParams["DISPLAY_AS_RATING"] == "vote_avg") { $sTitle = $sText . ", " . GetMessage("P_VOTES") . ": " . $arItem["PROPERTIES"]["vote_count"]["VALUE"]; } if ($arParams["SHOW_ANCHOR"] != "Y") { ?> <span <?php echo !empty($sTitle) ? ' title="' . $sTitle . '"' : ''; ?> ><?php echo $sText; ?> </span><?php } else { ?> <a href="<?php echo $arItem["URL"]; ?> "<?php echo !empty($sTitle) ? ' title="' . $sTitle . '"' : ''; ?> ><?php echo $sText; ?> </a><?php } } ?> </div> </td> </tr> <?php } ?> </table> <?php }