Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions PWD.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?

class PWD {
public static function getElems($sort = array(),$filter = array(),$select = array()){
$arResult = array();
$obCache = new CPHPCache();
$cache_time = 60 * 60 * 24;
$m = array_merge($sort,$filter,$select);
$cache_id = md5(implode(',',array_merge(array_keys($m),$m)));
if ($cache_time > 0 && $obCache->InitCache($cache_time, $cache_id,"/")){
$vars = $obCache->GetVars();
$arResult = $vars[$cache_id];
} elseif ($obCache->StartDataCache() && CModule::IncludeModule("iblock")) {
$res = CIBlockElement::GetList(
$sort,
$filter,
false,
false,
$select
);
while ($ob = $res->Fetch()) {
if ($ob["PREVIEW_PICTURE"]) $ob["PREVIEW_PICTURE"] = CFile::GetPath($ob["PREVIEW_PICTURE"]);
if ($ob["DETAIL_PICTURE"]) $ob["DETAIL_PICTURE"] = CFile::GetPath($ob["DETAIL_PICTURE"]);
if ($ob["DETAIL_PAGE_URL"]) $ob["DETAIL_PAGE_URL"] = CIblock::ReplaceDetailUrl($ob['DETAIL_PAGE_URL'], $ob, false, 'E');
$arResult[$ob["ID"]] = $ob;
}
$obCache->EndDataCache(array($cache_id => $arResult));
}
return $arResult;
}
}

//$res = PWD::getElems(array(),array("IBLOCK_ID"=>1));
?>
1 change: 1 addition & 0 deletions developerTest
Submodule developerTest added at dc10fb
42 changes: 42 additions & 0 deletions getLastNews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?/*
Можно вот так http://joxi.ru/GrqDpEHQdKQZAz

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");

$APPLICATION->IncludeComponent("bitrix:rss.show","",Array(
"URL" => "https://lenta.ru/rss",
"OUT_CHANNEL" => "N",
"PROCESS" => "NONE",
"NUM_NEWS" => "5",
"CACHE_TYPE" => "A",
"CACHE_TIME" => "3600"
)
);
*/


//Но мне нравится вот так
// http://joxi.ru/YmEdMOi0z69Rr6

$url = "https://lenta.ru/rss";

$rss = simplexml_load_file($url);
if ( $rss === false ) die('Error parse RSS: '.$url);
$c = 1;
$dm = str_repeat('-',100);
foreach ($rss->channel->item as $item) {
if ($c <= 5) {
$ar = [
$c.'. '.$item->title,
$dm,
$item->link,
$dm,
$item->description,
$dm,
''
];
echo implode(PHP_EOL,$ar);//PHP_EOL т.к. вызов будет из консоли
$c++;
} else break;
}
?>