Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
郝肖肖
9 years ago
Commit
65ce5b473f80bbadbc4fcbf5d57486f077866c7b
1 parent
e3d89155
店铺装修 经典推荐字符限制
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
library/WebPlugin/Helpers.php
yohobuy/www.yohobuy.com/application/models/Product/Shop.php
library/WebPlugin/Helpers.php
View file @
65ce5b4
...
...
@@ -1069,4 +1069,25 @@ class Helpers
'item'
);
}
/**
* 截取字符串长度,超过用省略号表示
* @param type string $str 字符串
* @param type int $len 要截取的长度
* @return type string
*/
public
static
function
substrEllipsis
(
$str
,
$len
)
{
return
mb_substr
(
$str
,
0
,
$len
,
'utf-8'
)
.
(
$len
>=
mb_strlen
(
$str
,
'utf-8'
)
?
''
:
'...'
);
}
/**
* 判断字符串是否包含中文
* @param type string $str 字符串
* @return type boolean
*/
public
static
function
isChinese
(
$str
)
{
return
preg_match
(
"/[
\x7f
-
\xff
]/"
,
$str
);
}
}
...
...
yohobuy/www.yohobuy.com/application/models/Product/Shop.php
View file @
65ce5b4
...
...
@@ -378,8 +378,10 @@ class ShopModel
foreach
(
$data
[
'resource_data'
]
as
$resource
)
{
$result
[]
=
array
(
'enName'
=>
$resource
[
'enName'
],
'name'
=>
$resource
[
'name'
],
'enName'
=>
Helpers
::
isChinese
(
$resource
[
'enName'
])
?
Helpers
::
substrEllipsis
(
$resource
[
'enName'
],
5
)
:
Helpers
::
substrEllipsis
(
$resource
[
'enName'
],
10
),
'name'
=>
Helpers
::
isChinese
(
$resource
[
'name'
])
?
Helpers
::
substrEllipsis
(
$resource
[
'name'
],
5
)
:
Helpers
::
substrEllipsis
(
$resource
[
'name'
],
6
),
'img'
=>
self
::
imageView2
(
$resource
[
'src'
],
50
,
50
),
'title'
=>
$resource
[
'title'
],
'url'
=>
$resource
[
'url'
],
...
...
Please
register
or
login
to post a comment