当前位置: 首页>>代码示例>>PHP>>正文


PHP UTIL_String::truncate方法代码示例

本文整理汇总了PHP中UTIL_String::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_String::truncate方法的具体用法?PHP UTIL_String::truncate怎么用?PHP UTIL_String::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UTIL_String的用法示例。


在下文中一共展示了UTIL_String::truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAboutMeContent

 protected function getAboutMeContent()
 {
     $settings = BOL_ComponentEntityService::getInstance()->findSettingList('profile-BASE_CMP_AboutMeWidget', $this->user->id, array('content'));
     if (empty($settings['content'])) {
         return null;
     }
     return $this->length === null ? $settings['content'] : UTIL_String::truncate($settings['content'], $this->length, "...");
 }
开发者ID:vazahat,项目名称:dudex,代码行数:8,代码来源:profile_about.php

示例2: __construct

 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = LinkService::getInstance();
     $userId = $params->additionalParamList['entityId'];
     if ($userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links', 'view')) {
         $this->setVisible(false);
         return;
     }
     /* Check privacy permissions */
     $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
     try {
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $ex) {
         $this->setVisible(false);
         return;
     }
     /* */
     if ($service->countUserLinks($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'];
     $userLinkList = $service->findUserLinkList($userId, 0, $count);
     $idList = array();
     foreach ($userLinkList as $item) {
         /* Check privacy permissions */
         if ($item->userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links')) {
             $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $item->userId, 'viewerId' => OW::getUser()->getId());
             try {
                 OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
             } catch (RedirectException $ex) {
                 continue;
             }
         }
         /* */
         $list[] = $item;
         $idList[] = $item->id;
     }
     $commentInfo = array();
     if (!empty($idList)) {
         $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList);
         $tb = array();
         foreach ($list as $key => $item) {
             if (mb_strlen($item->getDescription()) > 100) {
                 $item->setDescription(UTIL_String::truncate($item->getDescription(), 100, '...'));
             }
             $list[$key]->setDescription(strip_tags($item->getDescription()));
             $tb[$item->getId()] = array(array('label' => '<span class="ow_txt_value">' . $commentInfo[$item->getId()] . '</span> ' . OW::getLanguage()->text('links', 'comments'), 'href' => OW::getRouter()->urlForRoute('link', array('id' => $item->getId()))), array('label' => UTIL_DateTime::formatDate($item->getTimestamp()), 'class' => 'ow_ic_date'));
         }
         $this->assign('tb', $tb);
     }
     $this->assign('list', $list);
     $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('links-user', array('user' => BOL_UserService::getInstance()->getUserName($userId))))));
 }
开发者ID:vazahat,项目名称:dudex,代码行数:58,代码来源:user_links_widget.php

示例3: smarty_modifier_more

/**
 * Smarty truncate modifier.
 *
 * @author Sergey Kambalin <greyexpert@gmail.com>
 * @package ow.ow_smarty.plugin
 * @since 1.0
 */
function smarty_modifier_more($string, $length)
{
    $truncated = UTIL_String::truncate($string, $length);
    if (strlen($string) - strlen($truncated) < 50) {
        return $string;
    }
    $uniqId = uniqid("more-");
    $seeMoreEmbed = '<a href="javascript://" class="ow_small" onclick="$(\'#' . $uniqId . '\').attr(\'data-collapsed\', 0);" style="padding-left:4px;">' . OW::getLanguage()->text("base", "comments_see_more_label") . '</a>';
    return '<span class="ow_more_text" data-collapsed="1" id="' . $uniqId . '">' . '<span data-text="full">' . $string . '</span>' . '<span data-text="truncated">' . $truncated . '...' . $seeMoreEmbed . '</span>' . '</span>';
}
开发者ID:hardikamutech,项目名称:loov,代码行数:17,代码来源:modifier.more.php

示例4: onBeforeRender

 public function onBeforeRender()
 {
     parent::onBeforeRender();
     if (!empty($this->oembed['title'])) {
         $this->oembed['title'] = UTIL_String::truncate($this->oembed['title'], 23, '...');
     }
     if (!empty($this->oembed['description'])) {
         $this->oembed['description'] = UTIL_String::truncate($this->oembed['description'], 40, '...');
     }
     $this->assign('message', $this->message);
     $this->assign('data', $this->oembed);
 }
开发者ID:tammyrocks,项目名称:mailbox,代码行数:12,代码来源:oembed_attachment.php

示例5: __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);
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:51,代码来源:blog_widget.php

示例6: question

 public function question($params)
 {
     $questionId = (int) $params['qid'];
     $question = $this->service->findQuestion($questionId);
     if (empty($question)) {
         throw new Redirect404Exception();
     }
     $language = OW::getLanguage();
     OW::getDocument()->setTitle($language->text('equestions', 'question_page_title'));
     OW::getDocument()->setDescription($language->text('equestions', 'question_page_description', array('question' => UTIL_String::truncate(strip_tags($question->text), 200))));
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'equestions', 'main_menu_list');
     $cmp = new EQUESTIONS_CMP_Question($questionId, null, null, array('focusToPost' => isset($_GET['f'])));
     $this->addComponent('question', $cmp);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:14,代码来源:questions.php

示例7: feedOnProjectAdd

 public function feedOnProjectAdd(OW_Event $e)
 {
     $params = $e->getParams();
     if ($params['entityType'] != 'ocsfundraising_project') {
         return;
     }
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $project = $service->getGoalById($params['entityId']);
     if (!$project) {
         return;
     }
     $content = array("format" => "image_content", "vars" => array("image" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image, false) : null, "thumbnail" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image) : null, "title" => UTIL_String::truncate(strip_tags($project['dto']->name), 100, '...'), "description" => UTIL_String::truncate(strip_tags($project['dto']->description), 150, '...'), "url" => array("routeName" => "ocsfundraising.project", "vars" => array('id' => $project['dto']->id)), "iconClass" => "ow_ic_folder"));
     $data = array('time' => (int) $project['dto']->startStamp, 'ownerId' => $project['dto']->ownerId, 'string' => array('key' => 'ocsfundraising+feed_add_project_label'), 'content' => $content, 'view' => array('iconClass' => 'ow_ic_folder'));
     $e->setData($data);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:15,代码来源:event_handler.php

示例8: onBeforeRender

 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $tplList = array();
     foreach ($this->response['feed']['entry'] as $item) {
         $vid = $item['media$group']['yt$videoid']['$t'];
         $uploaded = strtotime($item['media$group']['yt$uploaded']['$t']);
         $duration = $item['media$group']['yt$duration']['seconds'];
         $description = UTIL_String::truncate(strip_tags($item['media$group']['media$description']['$t']), 130, ' ...');
         $title = UTIL_String::truncate(strip_tags($item['media$group']['media$title']['$t']), 65, ' ...');
         $thumb = $item['media$group']['media$thumbnail'][0]['url'];
         $image = $item['media$group']['media$thumbnail'][1]['url'];
         $oembed = array('thumbnail_url' => $image, 'type' => 'video', 'title' => $title, 'description' => $description, 'html' => '<iframe class="attp-yt-iframe" width="300" height="230" src="http://www.youtube.com/embed/' . $vid . '?autoplay=1" frameborder="0" allowfullscreen></iframe>');
         $tplList[] = array('title' => $title, 'description' => $description, 'thumb' => $thumb, 'video' => $vid, 'duration' => round($duration / 60), 'uploaded' => $uploaded, 'date' => UTIL_DateTime::formatDate($uploaded), 'oembed' => json_encode($oembed));
     }
     $this->assign('list', $tplList);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:17,代码来源:youtube_list.php

示例9: findUserVideos

 public function findUserVideos($userId, $start, $offset)
 {
     $clipDao = VIDEO_BOL_ClipDao::getInstance();
     $example = new OW_Example();
     $example->andFieldEqual('status', 'approved');
     $example->andFieldEqual('userId', $userId);
     $example->setOrder('`addDatetime` DESC');
     $example->setLimitClause($start, $offset);
     $list = $clipDao->findListByExample($example);
     $out = array();
     foreach ($list as $video) {
         $id = $video->id;
         $videoThumb = VIDEO_BOL_ClipService::getInstance()->getClipThumbUrl($id);
         $out[$id] = array('id' => $id, 'embed' => $video->code, 'title' => UTIL_String::truncate($video->title, 65, ' ...'), 'description' => UTIL_String::truncate($video->description, 130, ' ...'), 'thumb' => $videoThumb == 'undefined' ? null : $videoThumb, 'date' => UTIL_DateTime::formatDate($video->addDatetime), 'permalink' => OW::getRouter()->urlForRoute('view_clip', array('id' => $id)));
         $out[$id]['oembed'] = json_encode(array('type' => 'video', 'thumbnail_url' => $out[$id]['thumb'], 'html' => $out[$id]['embed'], 'title' => $out[$id]['title'], 'description' => $out[$id]['description']));
     }
     return $out;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:18,代码来源:video_bridge.php

示例10: onInvite

 public function onInvite(OW_Event $event)
 {
     $params = $event->getParams();
     $eventId = $params['eventId'];
     $eventDto = EVENT_BOL_EventService::getInstance()->findEvent($params['eventId']);
     $eventUrl = OW::getRouter()->urlForRoute('event.view', array('eventId' => $eventDto->id));
     $eventTitle = UTIL_String::truncate($eventDto->title, 100, '...');
     $userId = OW::getUser()->getId();
     $userDto = OW::getUser()->getUserObject();
     $userUrl = BOL_UserService::getInstance()->getUserUrlForUsername($userDto->username);
     $userDisplayName = BOL_UserService::getInstance()->getDisplayName($userId);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
     $avatar = $avatars[$userId];
     $users = array($userId);
     $stringAssigns = array('event' => '<a href="' . $eventUrl . '">' . $eventTitle . '</a>');
     $stringAssigns['user1'] = '<a href="' . $userUrl . '">' . $userDisplayName . '</a>';
     $contentImage = null;
     if (!empty($eventDto->image)) {
         $eventSrc = EVENT_BOL_EventService::getInstance()->generateImageUrl($eventDto->image, true);
         $contentImage = array('src' => $eventSrc, 'url' => $eventUrl, 'title' => $eventTitle);
     }
     //$userCount = count($data['users']);
     //        $userIds = array();
     //        for ( $i = 0; $i < $userCount; $i++ )
     //        {
     //            $user = $data['users'][$i];
     //            $stringAssigns['user' . ($i+1)] = '<a href="' . $user['url'] . '">' . $user['name'] . '</a>';
     //
     //            if ( $i >= 2 )
     //            {
     //                $userIds[] = $user['userId'];
     //            }
     //        }
     //$stringAssigns['otherUsers'] = '<a href="javascript://" onclick="OW.showUsers(' . json_encode($users) . ');">' .
     //OW::getLanguage()->text('event', 'invitation_join_string_other_users', array( 'count' => count($users) )) . '</a>';
     // $languageKey = $userCount > 2 ? 'invitation_join_string_many' : 'invitation_join_string_' . $userCount;
     $languageKey = 'invitation_join_string_' . 1;
     $invitationEvent = new OW_Event('invitations.add', array('pluginKey' => 'event', 'entityType' => self::INVITATION_JOIN, 'entityId' => $eventDto->id, 'userId' => $params['userId'], 'time' => time(), 'action' => 'event-invitation'), array('string' => array('key' => 'event+' . $languageKey, 'vars' => $stringAssigns), 'users' => $users, 'avatar' => $avatar, 'contentImage' => $contentImage));
     OW::getEventManager()->trigger($invitationEvent);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:40,代码来源:invitation_handler.php

示例11: onBeforeQuestionAdd

 public function onBeforeQuestionAdd(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if (empty($params['settings']['context']['type']) || $params['settings']['context']['type'] != 'groups') {
         return;
     }
     if (!$this->isActive()) {
         return;
     }
     $context = $params['settings']['context'];
     $service = GROUPS_BOL_Service::getInstance();
     $groupId = (int) $context['id'];
     $group = $service->findGroupById($groupId);
     $url = $service->getGroupUrl($group);
     $title = UTIL_String::truncate(strip_tags($group->title), 100, '...');
     $context['label'] = $title;
     $context['url'] = $url;
     $data['settings']['context'] = $context;
     $data['privacy'] = 'groups';
     $event->setData($data);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:22,代码来源:groups_bridge.php

示例12: processDataInterface

 private function processDataInterface($item)
 {
     $data = $item['data'];
     foreach (array('string', 'conten') as $langProperty) {
         if (!empty($data[$langProperty]) && is_array($data[$langProperty])) {
             $key = explode('+', $data[$langProperty]['key']);
             $vars = empty($data[$langProperty]['vars']) ? array() : $data[$langProperty]['vars'];
             $data[$langProperty] = OW::getLanguage()->text($key[0], $key[1], $vars);
         }
     }
     if (!empty($data['contentImage'])) {
         $data['contentImage'] = is_string($data['contentImage']) ? array('src' => $data['contentImage']) : $data['contentImage'];
     } else {
         $data['contentImage'] = null;
     }
     $data['content'] = empty($data['content']) ? '' : UTIL_String::truncate($data['content'], 140, '...');
     $data['string'] = empty($data['string']) ? '' : $data['string'];
     $data['avatar'] = empty($data['avatar']) ? null : $data['avatar'];
     $data['contentImage'] = empty($data['contentImage']) ? array() : $data['contentImage'];
     $data['toolbar'] = empty($data['toolbar']) ? array() : $data['toolbar'];
     $data['url'] = empty($data['url']) ? null : $data['url'];
     $data['time'] = $item['time'];
     return $data;
 }
开发者ID:tammyrocks,项目名称:notifications,代码行数:24,代码来源:notification.php

示例13: onInvite

 public function onInvite(OW_Event $event)
 {
     $params = $event->getParams();
     $eventDto = EVENTX_BOL_EventService::getInstance()->findEvent($params['eventId']);
     $eventUrl = OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $eventDto->id));
     $eventTitle = UTIL_String::truncate($eventDto->title, 100, '...');
     $userId = OW::getUser()->getId();
     $userDto = OW::getUser()->getUserObject();
     $userUrl = BOL_UserService::getInstance()->getUserUrlForUsername($userDto->username);
     $userDisplayName = BOL_UserService::getInstance()->getDisplayName($userId);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
     $avatar = $avatars[$userId];
     $users = array($userId);
     $stringAssigns = array('event' => '<a href="' . $eventUrl . '">' . $eventTitle . '</a>');
     $stringAssigns['user1'] = '<a href="' . $userUrl . '">' . $userDisplayName . '</a>';
     $contentImage = null;
     if (!empty($eventDto->image)) {
         $eventSrc = EVENTX_BOL_EventService::getInstance()->generateImageUrl($eventDto->image, true);
         $contentImage = array('src' => $eventSrc, 'url' => $eventUrl, 'title' => $eventTitle);
     }
     $languageKey = 'invitation_join_string_' . 1;
     $invitationEvent = new OW_Event('invitations.add', array('pluginKey' => 'eventx', 'entityType' => self::INVITATION_JOIN, 'entityId' => $eventDto->id, 'userId' => $params['userId'], 'time' => time(), 'action' => 'event-invitation'), array('string' => array('key' => 'eventx+' . $languageKey, 'vars' => $stringAssigns), 'users' => $users, 'avatar' => $avatar, 'contentImage' => $contentImage));
     OW::getEventManager()->trigger($invitationEvent);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:24,代码来源:invitation_handler.php

示例14: onUpdateBlogPost

 public function onUpdateBlogPost(OW_Event $e)
 {
     $params = $e->getParams();
     $data = $e->getData();
     if ($params['entityType'] != 'blog-post') {
         return;
     }
     $post = $this->service->findById($params['entityId']);
     $content = nl2br(UTIL_String::truncate(strip_tags($post->post), 150, '...'));
     $title = UTIL_String::truncate(strip_tags($post->title), 100, '...');
     $data = array('time' => (int) $post->timestamp, 'ownerId' => $post->authorId, 'content' => array('format' => 'content', 'vars' => array('title' => $title, 'description' => $content, 'url' => array("routeName" => 'post', "vars" => array('id' => $post->id)), 'iconClass' => 'ow_ic_blog')), 'view' => array('iconClass' => 'ow_ic_write'), 'actionDto' => $data['actionDto']);
     $e->setData($data);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:13,代码来源:event_handler.php

示例15: onFeedItemRenderContext

 public function onFeedItemRenderContext(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     $groupActions = array('groups-status');
     if (in_array($params['action']['entityType'], $groupActions) && $params['feedType'] == 'groups') {
         $data['context'] = null;
     }
     if ($params['action']['entityType'] == 'forum-topic' && isset($data['contextFeedType']) && $data['contextFeedType'] == 'groups' && $data['contextFeedType'] != $params['feedType']) {
         $service = GROUPS_BOL_Service::getInstance();
         $group = $service->findGroupById($data['contextFeedId']);
         $url = $service->getGroupUrl($group);
         $title = UTIL_String::truncate(strip_tags($group->title), 100, '...');
         $data['context'] = array('label' => $title, 'url' => $url);
     }
     $event->setData($data);
 }
开发者ID:tammyrocks,项目名称:groups,代码行数:17,代码来源:event_handler.php


注:本文中的UTIL_String::truncate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。