Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHO-ACTIVITY-PHP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
hf
9 years ago
Commit
2b201e9a4e042fb16be0a24e8ab68333c0d20343
1 parent
6b07bd4c
do add yohobuy guang code
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
44 deletions
yohobuy/m.yohobuy.com/application/models/Guang/Index.php
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Rss.php
yohobuy/m.yohobuy.com/application/models/Guang/Index.php
View file @
2b201e9
...
...
@@ -4,8 +4,9 @@ namespace Guang;
use
LibModels\Wap\Guang\ListData
;
use
LibModels\Wap\Guang\DetailData
;
use
Plugin\Helpers
;
use
Configs\CacheConfig
;
use
Plugin\Helpers
;
use
Plugin\Cache
;
/**
*
...
...
@@ -223,11 +224,14 @@ class IndexModel
if
(
!
empty
(
$article
[
'data'
][
'list'
][
'artList'
]))
{
$build
=
array
();
foreach
(
$article
[
'data'
][
'list'
][
'artList'
]
as
$value
)
{
if
(
!
isset
(
$value
[
'id'
]))
{
continue
;
if
(
isset
(
$value
[
'id'
]))
{
$build
=
Helpers
::
formatArticle
(
$value
,
false
,
false
,
true
);
if
(
!
isset
(
$build
[
'author'
][
'name'
]))
{
$build
[
'author'
][
'name'
]
=
''
;
}
$build
[
'intro'
]
=
self
::
genIntro
(
$value
[
'id'
]);
$result
[]
=
$build
;
}
$build
=
Helpers
::
formatArticle
(
$value
,
false
,
false
,
false
);
$build
[
'intro'
]
=
DetailData
::
intro
(
$value
[
'id'
]);
}
}
...
...
@@ -246,34 +250,38 @@ class IndexModel
}
/**
* 构建信息内容
*
* @param array $data
* @return array
*/
private
static
function
buildIntro
(
$data
)
private
static
function
genIntro
(
$id
)
{
foreach
(
$data
as
$value
)
{
$build
=
array
();
// 文字
if
(
isset
(
$value
[
'text'
]))
{
$build
[
'text'
]
=
$value
[
'text'
][
'data'
][
'text'
];
}
// 单张图
elseif
(
isset
(
$value
[
'singleImage'
]))
{
$build
[
'bigImage'
]
=
Helpers
::
getImageUrl
(
$value
[
'singleImage'
][
'data'
][
0
][
'src'
],
640
,
640
);
}
elseif
(
isset
(
$value
[
'smallPic'
][
'data'
]))
{
$imgs
=
$value
[
'smallPic'
][
'data'
];
$build
[
'smallImage'
]
=
array
(
array
(
'src'
=>
Helpers
::
getImageUrl
(
$imgs
[
0
][
'src'
],
315
,
420
)
),
array
(
'src'
=>
Helpers
::
getImageUrl
(
$imgs
[
1
][
'src'
],
315
,
420
)
)
);
$result
=
''
;
$data
=
DetailData
::
intro
(
$id
);
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
$value
)
{
// 文字
if
(
isset
(
$value
[
'text'
]))
{
$result
.=
trim
(
strip_tags
(
htmlspecialchars_decode
(
$value
[
'text'
][
'data'
][
'text'
])
)
)
.
'<br/>'
;
}
// 单张图
elseif
(
isset
(
$value
[
'singleImage'
]))
{
$result
.=
'<img src="'
.
Helpers
::
getImageUrl
(
$value
[
'singleImage'
][
'data'
][
0
][
'src'
],
640
,
640
)
.
'"/><br/>'
;
}
// 多张小图
elseif
(
isset
(
$value
[
'smallPic'
][
'data'
]))
{
foreach
(
$value
[
'smallPic'
][
'data'
]
as
$small
)
{
$result
.=
'<img src="'
.
Helpers
::
getImageUrl
(
$small
[
'src'
],
315
,
420
)
.
'"/>'
;
}
$result
.=
'<br/>'
;
}
}
}
$data
=
array
();
return
$result
;
}
}
...
...
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Rss.php
View file @
2b201e9
<?php
use
Action\AbstractAction
;
/**
...
...
@@ -12,33 +13,49 @@ use Action\AbstractAction;
*/
class
RssController
extends
AbstractAction
{
/**
* 订阅逛最新的资讯
*/
public
function
indexAction
()
{
headers_sent
()
||
header
(
'Content-Type: text/xml; charset=utf-8'
);
$time
=
date
(
'D, d M Y H:i:s O'
);
$gender
=
$this
->
get
(
'gender'
,
'1,2,3'
);
// 输出顶部公共的信息
echo
<<<RSS
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>有货逛</title>
<link>http://guang.m.yohobuy.com</link>
<description>Yoho!Buy有货 | 年轻人潮流购物中心</description>
<atom:link href="http://guang.m.yohobuy.com/rss" rel="self"></atom:link>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/>
<language>zh-cn</language>
<copyright>2015 yoho.inc</copyright>
<lastBuildDate>{$time}</lastBuildDate>
<ttl>30</ttl>
RSS;
<title>有货逛</title>
<link>http://yohobuy.com</link>
<generator>http://m.yohobuy.com</generator>
<description>Yoho!Buy有货 | 年轻人潮流购物中心</description>
<atom:link href="http://guang.m.yohobuy.com/rss" rel="self"></atom:link>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/>
<language>zh-cn</language>
<copyright>2015 yoho.inc</copyright>
<lastBuildDate>{$time}</lastBuildDate>
<ttl>50</ttl>
RSS;
$items
=
\Guang\IndexModel
::
getRssArticle
(
$gender
);
foreach
(
$items
as
$item
)
{
echo
'<item>'
,
"
\n
"
,
'<title><![CDATA['
,
$item
[
'title'
],
']]></title>'
,
"
\n
"
,
'<link><![CDATA['
,
$item
[
'url'
],
'&ref=rss]]></link>'
,
"
\n
"
,
'<description><![CDATA['
,
$item
[
'intro'
],
']]></description>'
,
"
\n
"
,
'<pubDate>'
,
$item
[
'publishTime'
],
'</pubDate>'
,
"
\n
"
,
'<author><![CDATA['
,
$item
[
'author'
][
'name'
],
']]></author>'
,
"
\n
"
,
'<guid><![CDATA['
,
$item
[
'url'
],
'&ref=rss]]></guid>'
,
"
\n
"
,
'<source>有货</source>'
,
'</item>'
,
"
\n
"
;
}
echo
"</channel>
\n
</rss>"
;
}
}
...
...
Please
register
or
login
to post a comment