本文整理汇总了PHP中UTIL_String::splitWord方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_String::splitWord方法的具体用法?PHP UTIL_String::splitWord怎么用?PHP UTIL_String::splitWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_String
的用法示例。
在下文中一共展示了UTIL_String::splitWord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
$service = PostService::getInstance();
$count = $params->customParamList['count'];
$previewLength = $params->customParamList['previewLength'];
$list = $service->findList(0, $count);
if ((empty($list) || false && !OW::getUser()->isAuthorized('blogs', 'add') && !OW::getUser()->isAuthorized('blogs', 'view')) && !$params->customizeMode) {
$this->setVisible(false);
return;
}
$posts = array();
$userService = BOL_UserService::getInstance();
$postIdList = array();
foreach ($list as $dto) {
/* @var $dto Post */
if (mb_strlen($dto->getTitle()) > 50) {
$dto->setTitle(UTIL_String::splitWord(UTIL_String::truncate($dto->getTitle(), 50, '...')));
}
$text = $service->processPostText($dto->getPost());
$posts[] = array('dto' => $dto, 'text' => UTIL_String::splitWord(UTIL_String::truncate($text, $previewLength)), 'truncated' => mb_strlen($text) > $previewLength, 'url' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())));
$idList[] = $dto->getAuthorId();
$postIdList[] = $dto->id;
}
$commentInfo = array();
if (!empty($idList)) {
$avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false);
$this->assign('avatars', $avatars);
$urls = BOL_UserService::getInstance()->getUserUrlsForList($idList);
$commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $postIdList);
$toolbars = array();
foreach ($list as $dto) {
$toolbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($urls[$dto->getAuthorId()]) ? $urls[$dto->getAuthorId()] : '#', 'label' => isset($avatars[$dto->getAuthorId()]['title']) ? $avatars[$dto->getAuthorId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp())));
}
$this->assign('tbars', $toolbars);
}
$this->assign('commentInfo', $commentInfo);
$this->assign('list', $posts);
if ($service->countPosts() > 0) {
$toolbar = array();
if (OW::getUser()->isAuthorized('blogs', 'add')) {
$toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'add_new'), 'href' => OW::getRouter()->urlForRoute('post-save-new'));
}
if (OW::getUser()->isAuthorized('blogs', 'view')) {
$toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'go_to_blog'), 'href' => Ow::getRouter()->urlForRoute('blogs'));
}
if (!empty($toolbar)) {
$this->setSettingValue(self::SETTING_TOOLBAR, $toolbar);
}
}
}
示例2: __construct
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
$service = PostService::getInstance();
if (empty($params->additionalParamList['entityId'])) {
}
$userId = $params->additionalParamList['entityId'];
if ($userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs', 'view')) {
$this->setVisible(false);
return;
}
/* Check privacy permissions */
$eventParams = array('action' => PostService::PRIVACY_ACTION_VIEW_BLOG_POSTS, 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $ex) {
$this->setVisible(false);
return;
}
/* */
if ($service->countUserPost($userId) == 0 && !$params->customizeMode) {
$this->setVisible(false);
return;
}
$this->assign('displayname', BOL_UserService::getInstance()->getDisplayName($userId));
$this->assign('username', BOL_UserService::getInstance()->getUsername($userId));
$list = array();
$count = $params->customParamList['count'];
$userPostList = $service->findUserPostList($userId, 0, $count);
foreach ($userPostList as $id => $item) {
/* Check privacy permissions */
if ($item->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs')) {
$eventParams = array('action' => PostService::PRIVACY_ACTION_VIEW_BLOG_POSTS, 'ownerId' => $item->authorId, 'viewerId' => OW::getUser()->getId());
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $ex) {
continue;
}
}
/* */
$list[$id] = $item;
$list[$id]->setPost(strip_tags($item->getPost()));
$idList[] = $item->id;
}
$commentInfo = array();
if (!empty($idList)) {
$commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $idList);
$tb = array();
foreach ($list as $key => $item) {
if (mb_strlen($item->getPost()) > 100) {
$list[$key]->setPost(UTIL_String::splitWord(UTIL_String::truncate($item->getPost(), 100, '...')));
}
if (mb_strlen($item->getTitle()) > 50) {
$list[$key]->setTitle(UTIL_String::splitWord(UTIL_String::truncate($item->getTitle(), 50, '...')));
}
if ($commentInfo[$item->getId()] == 0) {
$comments_tb_link = array('label' => '', 'href' => '');
} else {
$comments_tb_link = array('label' => '<span class="ow_txt_value">' . $commentInfo[$item->getId()] . '</span> ' . OW::getLanguage()->text('blogs', 'toolbar_comments'), 'href' => OW::getRouter()->urlForRoute('post', array('id' => $item->getId())));
}
$tb[$item->getId()] = array($comments_tb_link, array('label' => UTIL_DateTime::formatDate($item->getTimestamp()), 'class' => 'ow_ic_date'));
}
$this->assign('tb', $tb);
}
$itemList = array();
foreach ($list as $post) {
$itemList[] = array('dto' => $post, 'titleHref' => OW::getRouter()->urlForRoute('user-post', array('id' => $post->getId())));
}
$this->assign('list', $itemList);
$user = BOL_UserService::getInstance()->findUserById($userId);
$this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('blogs', 'view_all'), 'href' => OW::getRouter()->urlForRoute('user-blog', array('user' => $user->getUsername())))));
}