123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- use yii\helpers\Html;
- Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
- header('Content-Type: application/rss+xml; charset=utf-8');
- ?>
- <?php echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
- <rss version="2.0"
- xmlns:yandex="http://news.yandex.ru"
- xmlns:media="http://search.yahoo.com/mrss/"
- >
- <channel>
- <?php if (isset($channel['title'])) : ?>
- <title><?= $channel['title']; ?></title>
- <?php endif; ?>
- <?php if (isset($channel['link'])) : ?>
- <link><?= Html::encode($channel['link']); ?></link>
- <?php endif; ?>
- <description>Новости amic.ru для rnews</description>
- <?php if (isset($channel['language'])) : ?>
- <language><?= $channel['language']; ?></language>
- <?php endif; ?>
- <generator>CMS amic.ru</generator>
- <?php foreach ($items as $item): ?>
- <?php
- if ( $item['export_rss'] & 1 ) continue;
- //1 - неотдавать в новости
- //2- неотдавать в канал
- ?>
- <?php if (isset($item['url']) ) : ?>
- <item>
- <link><?= rtrim(Html::encode($channel['link']),'/'); ?><?= Html::encode($item['url']); ?></link>
- <?php if (isset($item['title']) ) : ?>
- <title><![CDATA[<?= trim( $item['title'] ); ?>]]></title>
- <?php endif; ?>
- <?php if (isset($item['description']) ) : ?>
- <description><![CDATA[<?= trim($item['description']); ?>]]></description>
- <?php endif; ?>
- <pubDate><?= date( "r", strtotime( $item['updated_at'] ) ); ?></pubDate>
- <?php if (isset($item['newscontent']) ) : ?>
- <yandex:full-text>
- <![CDATA[
- <?/*<h1><?= ($item['title']) ? $item['title'] : ''; ?></h1>*/?>
- <p><?= ($item['description']) ? $item['description'] : ''; ?></p>
- <?= $item['newscontent']; ?>
- ]]>
- </yandex:full-text>
- <?php endif; ?>
- <?php if (isset($item['image'])) :?>
- <?
- $r = explode(".", $item['image']);
- if( is_array($r) ){
- if( array_pop($r) == 'webp' ){
- $mtype = "image/webp";
- }else{
- $mtype = "image/jpeg";
- }
- }
- ?>
- <enclosure url="<?=$item['image']?>" type="<?=$mtype?>" />
- <?php endif; ?>
- <?
- preg_match_all('/src="([^"]+\.(jpg|png)).*"/i', $item['content'], $ax );
- foreach ( $ax[1] as $aa ){
- if( !preg_match( "/(\/manager\/|small)/", $aa) ){
- $r = explode(".", $aa);
- if( is_array($r) ){
- if( array_pop($r) == 'png' ){
- $mtype = "image/png";
- }else{
- $mtype = "image/jpeg";
- }
- }
- ?>
- <enclosure url="<?=$aa?>" type="<?=$mtype?>" />
- <?
- }
- }
- if( count( $item['topics'] ) > 0 ){
- ?>
- <metrics>
- <yandex schema_identifier="<?=$item['uid']?>">
- <breadcrumblist>
- <?
- foreach ( $item['topics'] as $topics ){
- ?>
- <breadcrumb url="<?=$topics['url']?>" text='<?=str_replace("'",'`',$topics['title'])?>'/>
- <?
- }
- ?>
- </breadcrumblist>
- </yandex>
- </metrics>
- <?
- }
- switch( $item['type'] ){
- case 2:
- case 6:
- // статья
- $ganre = "article";
- case 7:
- case 5:
- // статья
- $ganre = "article";
- default:
- $ganre = "message";
- break;
- }
- ?>
- <yandex:genre><?=$ganre?></yandex:genre>
- <?php if (isset($item['story'])) : ?>
- <yandex:theme_tags><?=$item['story'];?></yandex:theme_tags>
- <?php endif; ?>
- <?php if (isset($item['category'])) : ?>
- <category><?=$item['category'];?></category>
- <?php endif; ?>
- <?php if (isset($item['riatop']) && $item['riatop']) : ?>
- <category>main_article</category>
- <?php endif; ?>
- <author><?=$item['author'];?></author>
- </item>
- <?php endif; ?><?php endforeach; ?>
- </channel>
- </rss>
|