<?
include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/iblock/iblock.php");
include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include.php");
function js_write($text)
{
$s = "";
if (!isset($_GET['php']))
$s = "document.write('";
$s .= $text;
if (!isset($_GET['php']))
$s .= "');";
return $s;
}
function strlenMak($TEXT, $LIMIT, $TAGS = 0)
{
if ($TAGS == 0) return substr($TEXT, 0, $LIMIT) . "...";
else
{
$COUNTER = 0;
for ($i = 0; $i<= strlen($TEXT); $i++)
{
if ($TEXT{$i} == "<") $STOP = 1;
if ($STOP != 1)
{
$COUNTER++;
}
if ($TEXT{$i} == ">") $STOP = 0;
$RETURN .= $TEXT{$i};
if ($COUNTER >= $LIMIT && $TEXT{$i} == " ") break;
}
return $RETURN . "...";
}
}
if(CModule::IncludeModule("iblock"))
{
if(isset($_GET['cnt']))
{
$cnt = intval($_GET['cnt']);
$cnt_pagesize = array("nPageSize" => $cnt);
}
if(isset($_GET['tl']))
{
$title_length = intval($_GET['tl']);
$end = $title_length;
}
else
$end = 1200;
if(isset($_GET['id']))
{
$ID_SECTION = intval($_GET['id']);
$site = array (5021, 650, 651, 1574);
if(in_array($ID_SECTION, $site))
{
$arFilter = Array(
"SITE_ID"=>SITE_ID,
"IBLOCK_TYPE"=>"news",
"SECTION_ID"=> array($ID_SECTION),
"ACTIVE"=>"Y",
);
$res = CIBlockElement::GetList(Array("DATE_ACTIVE_FROM"=>"DESC"), $arFilter, false, $cnt_pagesize);
$LastCreateDate = '';
echo '<div style="display: block;">';
while($ar_fields = $res->GetNext())
{
$CreateDate = substr($ar_fields["ACTIVE_FROM"],0,10);
if($LastCreateDate != $CreateDate)
{
$LastCreateDate = $CreateDate;
echo $LastCreateDate.'<br />';
}
echo js_write('<a style="display: block; margin: 3px, 0, 10px;" href="'.$ar_fields["DETAIL_PAGE_URL"].'" >'.strlenMak($ar_fields["NAME"], $end).'</a>');echo '<br>';
//tpk_print_r($ar_fields,$ar_fields["ID"],'28751');
}
echo '</div>';
}
else
echo "Параметру id={$ID_SECTION} не соответсвует ни один из разделов статей.";
}
else
echo "Требуется задание параметра id.";
}
else
return 0;
?> |