本文整理汇总了PHP中CStringHelper::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP CStringHelper::truncate方法的具体用法?PHP CStringHelper::truncate怎么用?PHP CStringHelper::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStringHelper
的用法示例。
在下文中一共展示了CStringHelper::truncate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* The default method that will display the output of this view which is called by
* Joomla
*
* @param string template Template file name
**/
public function display($tpl = null)
{
$document = JFactory::getDocument();
$config =& CFactory::getConfig();
// Get required data's
$events = $this->get('Events');
$categories = $this->get('Categories');
$pagination = $this->get('Pagination');
$mainframe =& JFactory::getApplication();
$filter_order = $mainframe->getUserStateFromRequest("com_community.events.filter_order", 'filter_order', 'a.title', 'cmd');
$filter_order_Dir = $mainframe->getUserStateFromRequest("com_community.events.filter_order_Dir", 'filter_order_Dir', '', 'word');
$search = $mainframe->getUserStateFromRequest("com_community.events.search", 'search', '', 'string');
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
// We need to assign the users object to the groups listing to get the users name.
for ($i = 0; $i < count($events); $i++) {
$row =& $events[$i];
$row->user = JFactory::getUser($row->creator);
// Truncate the description
CFactory::load('helpers', 'string');
$row->description = CStringHelper::truncate($row->description, $config->get('tips_desc_length'));
}
$catHTML = $this->_getCategoriesHTML($categories);
$this->assignRef('events', $events);
$this->assignRef('categories', $catHTML);
$this->assignRef('search', $search);
$this->assignRef('lists', $lists);
$this->assignRef('pagination', $pagination);
parent::display($tpl);
}
示例2: foreach
</div>
<?php
echo $sortings;
if ($videos) {
?>
<?php
foreach ($videos as $video) {
?>
<div class="video-item jomTips tipFullWidth" id="<?php
echo "video-" . $video->getId();
?>
" title="<?php
echo $video->getTitle() . '::' . CStringHelper::truncate($video->getDescription(), VIDEO_TIPS_LENGTH);
?>
">
<div class="video-item">
<div class="video-thumb">
<?php
if ($video->status == 'pending') {
?>
<img src="<?php
echo JURI::root();
?>
/components/com_community/assets/video_thumb.png" width="<?php
echo $videoThumbWidth;
?>
" height="<?php
示例3:
" class="cBoxPad">
<div class="cFeaturedThumb">
<a href="javascript:void(0);" class="cFeaturedAvatar">
<img src="<?php
echo $group->getThumbAvatar();
?>
" alt="<?php
echo $this->escape($group->name);
?>
" />
</a>
</div>
<div class="cFeaturedTitle"><b><?php
echo CStringHelper::truncate(strip_tags($group->name), 25);
?>
</b></div>
<div class="cFeaturedMeta"><?php
echo JText::sprintf(CStringHelper::isPlural($group->membercount) ? 'COM_COMMUNITY_GROUPS_MEMBER_COUNT_MANY' : 'COM_COMMUNITY_GROUPS_MEMBER_COUNT', $group->membercount);
?>
</div>
</div>
</li>
<?php
}
// end foreach
?>
</ul>
</div>
<div class="cSlider-btn cSlider-nav-btn cSlider-nav-prev"><a href="javascript:void(0);" title="<?php
示例4: foreach
?>
<?php
foreach ($albums as $album) {
?>
<option value="<?php
echo $album->id;
?>
" <?php
if ($album->id == $albumId) {
?>
selected="selected"<?php
}
?>
><?php
echo CStringHelper::truncate($this->escape($album->name), 64);
?>
</option>
<?php
}
?>
</select>
<?php
if (!empty($albumId) && $albumId != -1) {
?>
<span><a class="jsIcon1 icon-photos" id="view-albums" href="<?php
echo $viewAlbumLink;
?>
" target="_self"><?php
echo JText::_('COM_COMMUNITY_UPLOAD_VIEW_ALBUM');
示例5: setMetaTags
public function setMetaTags($app, $data)
{
$document = JFactory::getDocument();
$config = CFactory::getConfig();
$description = '';
$groupName = '';
if (isset($data->description)) {
$description = strip_tags($data->description);
}
switch ($app) {
case 'event':
$description = CStringHelper::truncate(CStringHelper::escape($description), $config->getInt('streamcontentlength'));
$document->addHeadLink($data->getThumbAvatar(), 'image_src', 'rel');
break;
case 'video':
$description = CStringHelper::truncate(CStringHelper::escape($description), $config->getInt('streamcontentlength'));
$document->setMetaData('medium', 'video');
$document->addHeadLink($data->getThumbnail(), 'image_src', 'rel');
//cannot exceed 130x110 pixels (facebook)
break;
case 'group':
$groupName = $data->approvals == COMMUNITY_PRIVATE_GROUP ? $data->name . ' (' . JText::_('COM_COMMUNITY_GROUPS_PRIVATE') . ')' : $data->name;
$data->title = $groupName;
$description = JText::sprintf('COM_COMMUNITY_GROUP_META_DESCRIPTION', CStringHelper::escape($data->name), $config->get('sitename'), CStringHelper::escape($description));
$document->addHeadLink($data->getThumbAvatar(), 'image_src', 'rel');
break;
default:
$description = CStringHelper::truncate(CStringHelper::escape($description), $config->getInt('streamcontentlength'));
}
$document->setTitle($data->title);
// JDocument will perform htmlspecialchars escape
$document->setMetaData('title', CStringHelper::escape($data->title));
// hack the above line
$document->setDescription($description);
// Return this object
return $this;
}
示例6: _getGroupsHTML
public function _getGroupsHTML($tmpGroups, $tmpPagination = NULL)
{
$config = CFactory::getConfig();
$tmpl = new CTemplate();
CFactory::load('helpers', 'owner');
CFactory::load('libraries', 'featured');
$featured = new CFeatured(FEATURED_GROUPS);
$featuredList = $featured->getItemIds();
$groups = array();
if ($tmpGroups) {
foreach ($tmpGroups as $row) {
$group =& JTable::getInstance('Group', 'CTable');
$group->bind($row);
$group->updateStats();
//ensure that stats are up-to-date
$group->description = CStringHelper::clean(CStringHelper::truncate($group->description, $config->get('tips_desc_length')));
$groups[] = $group;
}
unset($tmpGroups);
}
$groupsHTML = $tmpl->set('showFeatured', $config->get('show_featured'))->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('groups', $groups)->set('pagination', $tmpPagination)->fetch('groups.list');
unset($tmpl);
return $groupsHTML;
}
示例7: defined
defined('_JEXEC') or die;
?>
<?php
if ($videos) {
?>
<div class="video-items">
<?php
foreach ($videos as $video) {
?>
<div class="video-item jomTips tipFullWidth" id="<?php
echo "video-" . $video->getId();
?>
" title="<?php
echo $this->escape($video->getTitle()) . '::' . $this->escape(CStringHelper::truncate($video->description, VIDEO_TIPS_LENGTH));
?>
">
<div class="video-item">
<!---VIDEO THUMB-->
<div class="video-thumb">
<a class="video-thumb-url" href="<?php
echo $video->getURL();
?>
" style="width: <?php
echo $videoThumbWidth;
?>
px; height:<?php
echo $videoThumbHeight;
?>
px;"><img src="<?php
示例8:
//echo $url;
?>
javascript:joms.walls.showVideoWindow('<?php
echo $video->getId();
?>
')"><img alt="<?php
echo $this->escape($video->getTitle());
?>
" style="width: 112px; height: 84px;" src="<?php
echo $video->getThumbnail();
?>
"/></a>
<span class="video-durationHMS" style="right: 13px; bottom: 5px;"><?php
echo $duration;
?>
</span>
</div>
<strong><a href="javascript:joms.walls.showVideoWindow('<?php
echo $video->getId();
?>
')"><?php
echo $video->getTitle();
?>
</a></strong>
<small>
<?php
echo CStringHelper::truncate($video->getDescription(), $config->getInt('streamcontentlength'));
?>
</small>
<div class="clr"></div>
</div>
示例9: strip_tags
?>
" /></a>
</li>
<li class="detailWrap">
<strong><a href="<?php
echo CUrlHelper::eventLink($event->id);
?>
"><?php
echo strip_tags($event->title);
?>
</a></strong>
<small>
<?php
if (strlen(strip_tags($event->description))) {
echo CStringHelper::truncate(strip_tags($event->description), $config->getInt('streamcontentlength')) . '<br />';
}
?>
<!--
Ross added the startdate, enddate.
Need dev's help to convert it into readable resource.
It supposed to display as shown here:
http://i.firdouss.com/images/screenpkp.png
-->
<?php
echo $event->startdate;
?>
<br />
<?php
echo $event->enddate;
?>
示例10:
<ul class="cDetailList clrfix">
<li class="avatarWrap">
<a href="<?php
echo CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
?>
">
<img class="cAvatar cAvatar-Large" alt="<?php
echo $this->escape($group->name);
?>
" src="<?php
echo $group->getThumbAvatar();
?>
" />
</a>
</li>
<li class="detailWrap">
<strong><a href="<?php
echo CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
?>
"><?php
echo $group->name;
?>
</a></strong>
<small>
<?php
echo CStringHelper::truncate(strip_tags($group->description), $config->getInt('streamcontentlength'));
?>
</small>
</li>
</ul>
<div class="clr"></div>
示例11: defined
defined('_JEXEC') or die;
if (!empty($events)) {
?>
<h3><?php
echo JText::_('CC EVENTS UPCOMING');
?>
</h3>
<ul class="cResetList clrfix">
<?php
foreach ($events as $event) {
?>
<li class="jomTips" title="<?php
echo $this->escape($event->title);
?>
::<?php
echo CStringHelper::truncate($this->escape(strip_tags($event->description)), $config->get('tips_desc_length'));
?>
">
<div class="jsEvDate">
<div class="jsDD"><?php
echo CEventHelper::formatStartDate($event, JText::_('%d'));
?>
</div>
<div class="jsMM"><?php
echo CEventHelper::formatStartDate($event, JText::_('%b'));
?>
</div>
</div>
<div class="jsDetail" style="margin-left:45px">
<div class="small">
<b><a href="<?php
示例12: showLatestGroups
public function showLatestGroups($total = 5)
{
$tmpl = new CTemplate();
$config = CFactory::getConfig();
$showlatestgroups = intval($tmpl->params->get('showlatestgroups'));
$html = '';
$data = array();
if ($showlatestgroups != 0) {
$groupModel = CFactory::getModel('groups');
$tmpGroups = $groupModel->getAllGroups(null, null, null, $total);
$groups = array();
$data = array();
foreach ($tmpGroups as $row) {
$group =& JTable::getInstance('Group', 'CTable');
$group->bind($row);
$group->description = CStringHelper::truncate($group->description, $config->get('tips_desc_length'));
$groups[] = $group;
}
$tmpl = new CTemplate();
$html = $tmpl->setRef('groups', $groups)->fetch('frontpage.latestgroup');
}
$data['HTML'] = $html;
return $data;
}
示例13: trim
/**
* Truncate the given text
* @deprecated Use truncate instead. Trim has different meaning in PHP
* @param string $value
* @param int $length
* @return string
*/
public static function trim($value, $length)
{
return CStringHelper::truncate($value, $length);
}