本文整理汇总了PHP中JHtmlString::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP JHtmlString::truncate方法的具体用法?PHP JHtmlString::truncate怎么用?PHP JHtmlString::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JHtmlString
的用法示例。
在下文中一共展示了JHtmlString::truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Adds the OpenGraph information on the page
*
* @param array $data - the array containing the open graph data
*
* @return void
*/
public static function add($data)
{
$document = JFactory::getDocument();
$document->addCustomTag('<meta property="og:url" content="' . JURI::current() . '" />');
if (isset($data['type'])) {
if ($data['type'] == 'place') {
if (isset($data['lat']) && isset($data['lng'])) {
$document->addCustomTag('<meta property="og:type" content="' . $data['type'] . '" />');
$document->addCustomTag('<meta property="place:location:latitude" content="' . $data['lat'] . '" />');
$document->addCustomTag('<meta property="place:location:longitude" content="' . $data['lng'] . '" />');
}
} else {
$document->addCustomTag('<meta property="og:type" content="' . $data['type'] . '" />');
}
}
if (isset($data['title'])) {
$document->addCustomTag('<meta property="og:title" content="' . self::escape(JHtmlString::truncate(strip_tags($data['title']), 150)) . '" />');
}
if (isset($data['description'])) {
$document->addCustomTag('<meta property="og:description" content="' . self::escape(JHtmlString::truncate(strip_tags($data['description'], 200))) . '" />');
}
if (isset($data['image']) && strlen($data['image'])) {
$document->addCustomTag('<meta property="og:image" content="' . $data['image'] . '" />');
}
}
示例2: updateFile
public function updateFile()
{
$my = JXFactory::getUser();
$file_id = JRequest::getInt('file_id');
$file_name = JRequest::getVar('new_name', '');
$result = new stdClass();
$result->result = false;
if (intval($file_id) > 0 && preg_match("/^[^\\/?*:;{}\\\\]+\$/", $file_name)) {
$file = JTable::getInstance('File', 'StreamTable');
if ($file->load($file_id)) {
if ($my->authorise('stream.file.edit', $file)) {
$originalName = explode('.', $file->filename);
$extension = array_pop($originalName);
$file->filename = $file_name . '.' . $extension;
$file->store();
$result->result = true;
$result->fileid = $file_id;
$result->filename = StreamTemplate::escape(JHtmlString::truncate($file->filename, 32));
$result->full_filename = StreamTemplate::escape(preg_replace('/\\.[a-z]+$/i', '', $file->filename));
} else {
$result->error = JText::_('Not authorized to edit file!');
}
} else {
$result->error = $file->getError();
}
} else {
$result->error = JText::_('Invalid filename!');
}
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
exit;
}
示例3: getText
/**
* Get text from string with or without stripped html tags
* Strips out Joomla plugin tags
* Joomla 3.1+ only
*
*/
static function getText($text, $type = 'html', $max_letter_count = 0, $strip_tags = true, $tags_to_keep = '')
{
$temp = '';
if ($max_letter_count == 0) {
return $temp;
}
if ($max_letter_count > 0) {
if ($type == 'html') {
$temp = self::stripPluginTags($text);
if ($strip_tags) {
if ($tags_to_keep == '') {
$temp = strip_tags($temp);
return JHtmlString::truncate($temp, $max_letter_count, false, false);
// splits words and no html allowed
} else {
$temp = strip_tags($temp, $tags_to_keep);
if (method_exists('JHtmlString', 'truncateComplex')) {
return JHtmlString::truncateComplex($temp, $max_letter_count, true);
// since Joomla v3.1
} else {
//JFactory::getApplication()->enqueueMessage(JText::_('LIB_SYW_WARNING_CANNOTUSETRUNCATE'), 'warning'); // requires Joomla 3.1 minimum
return JHtmlString::truncate($temp, $max_letter_count, false, false);
}
}
} else {
if (method_exists('JHtmlString', 'truncateComplex')) {
return JHtmlString::truncateComplex($temp, $max_letter_count, true);
// since Joomla v3.1
} else {
//JFactory::getApplication()->enqueueMessage(JText::_('LIB_SYW_WARNING_CANNOTUSETRUNCATE'), 'warning'); // requires Joomla 3.1 minimum
JHtmlString::truncate($temp, $max_letter_count, false, false);
}
}
} else {
// 'txt'
return JHtmlString::truncate($text, $max_letter_count, false, false);
// splits words and no html allowed
}
} else {
// take everything
if ($type == 'html') {
$temp = self::stripPluginTags($text);
if ($strip_tags) {
if ($tags_to_keep == '') {
return strip_tags($temp);
} else {
return strip_tags($temp, $tags_to_keep);
}
} else {
return $temp;
}
} else {
// 'txt'
return $text;
}
}
return $temp;
}
示例4: truncateHighLight
public static function truncateHighLight($text, $limit)
{
preg_match('/' . preg_quote(ElasticSearchConfig::getHighLigthPre()) . '/', $text, $matches, PREG_OFFSET_CAPTURE);
if ($matches) {
$posPreTag = $matches[0][1];
//If pos if at the beginning it is not necessary to truncate the left part
if ($posPreTag > $limit * 0.75) {
$pos = strpos($text, " ", $posPreTag - $limit * 0.3);
$text = substr($text, $pos);
$text = '... ' . $text;
}
return JHtmlString::truncate($text, $limit + 4, true, true);
}
return $text;
}
示例5: storePost
/**
* This method store a post by user.
*/
public function storePost()
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
$content = $this->input->getString('content');
$user = JFactory::getUser();
$userId = $user->get('id');
$content = JString::trim(strip_tags($content));
$content = JHtmlString::truncate($content, 140);
if (!$userId) {
$app->close();
}
$userTimeZone = !$user->getParam('timezone') ? null : $user->getParam('timezone');
try {
$date = new JDate('now', $userTimeZone);
$entity = new Socialcommunity\Wall\User\Post(JFactory::getDbo());
$entity->setUserId($userId);
$entity->setContent($content);
$entity->setCreated($date->toSql(true));
$entity->store();
} catch (Exception $e) {
JLog::add($e->getMessage());
throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
}
$params = JComponentHelper::getParams('com_socialcommunity');
$filesystemHelper = new Prism\Filesystem\Helper($params);
$mediaFolder = $filesystemHelper->getMediaFolderUri($userId);
$profile = new Socialcommunity\Profile\Profile(JFactory::getDbo());
$profile->load(['user_id' => $userId]);
$displayData = new stdClass();
$displayData->id = $entity->getId();
$displayData->profileLink = JRoute::_(SocialCommunityHelperRoute::getProfileRoute($profile->getSlug()), false);
$displayData->name = htmlentities($profile->getName(), ENT_QUOTES, 'utf-8');
$displayData->alias = htmlentities($profile->getAlias(), ENT_QUOTES, 'utf-8');
$displayData->imageSquare = $mediaFolder . '/' . $profile->getImageSquare();
$displayData->imageAlt = $displayData->name;
$displayData->content = $entity->getContent();
$displayData->created = JHtml::_('socialcommunity.created', $entity->getCreated(), $userTimeZone);
$layout = new JLayoutFile('wall_post');
echo $layout->render($displayData);
$app->close();
}
示例6: prepareDocument
/**
* Prepare the document
*/
protected function prepareDocument()
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
// Prepare page heading
$this->preparePageHeading();
// Prepare page heading
$this->preparePageTitle();
if ($this->params->get('menu-meta_description')) {
$this->document->setDescription($this->params->get('menu-meta_description'));
} else {
if (!$this->item) {
$metaDescription = JText::_('COM_CROWDFUNDING_REPORT_CAMPAIGN');
} else {
$metaDescription = JText::sprintf('COM_CROWDFUNDING_REPORT_S', $this->item->title);
}
$this->document->setDescription($metaDescription);
}
if ($this->params->get('menu-meta_keywords')) {
$this->document->setMetaData('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots')) {
$this->document->setMetaData('robots', $this->params->get('robots'));
}
// Breadcrumb
$pathway = $app->getPathway();
$currentBreadcrumb = !$this->item ? JText::_('COM_CROWDFUNDING_REPORT_CAMPAIGN') : JHtmlString::truncate($this->item->title, 16);
$pathway->addItem($currentBreadcrumb, '');
// Add scripts
JHtml::_('jquery.framework');
JHtml::_('prism.ui.bootstrapMaxlength');
JHtml::_('prism.ui.bootstrap3Typeahead');
$this->document->addScript('media/' . $this->option . '/js/site/report.js');
}
示例7: strcmp
<div class="media-body">
<h4 class="media-heading">
<a href="<?php
echo JRoute::_(UserIdeasHelperRoute::getDetailsRoute($item->slug, $item->catid));
?>
" >
<?php
echo $this->escape($item->title);
?>
</a>
</h4>
<?php
if ($this->params->get("items_display_description", 1)) {
?>
<?php
echo JHtmlString::truncate($item->description, $this->params->get("items_description_length", 255), true, $this->params->get("items_description_html", 0));
?>
<?php
}
?>
</div>
<div class="clearfix"></div>
<div class="well well-small">
<div class="pull-left">
<?php
$name = strcmp("name", $this->params->get("name_type")) == 0 ? $item->name : $item->username;
$profile = JHtml::_("userideas.profile", $this->socialProfiles, $item->user_id);
// Prepare item owner avatar.
$profileAvatar = null;
if ($this->params->get("integration_display_owner_avatar", 0)) {
$profileAvatar = JHtml::_("userideas.avatar", $this->socialProfiles, $item->user_id, $this->integrationOptions);
示例8: isset
echo $subject->order_number;
?>
</a> <br />
<label class="label"> <?php
if (isset($orderComplex->hotel)) {
?>
<a
href="<?php
echo JRoute::_('index.php?option=com_bookpro&view=hotel&id=' . $orderComplex->hotel->id);
?>
"
title="<?php
echo $orderComplex->hotel->title;
?>
"><?php
echo JHtmlString::truncate($orderComplex->hotel->title, 20, true);
?>
</a> <?php
}
?>
</label>
</td>
<td><?php
echo isset($orderComplex->orderinfos[0]) ? JFactory::getDate($orderComplex->orderinfos[0]->start)->format(DateHelper::getConvertDateFormat('P')) : '';
?>
</td>
<td><?php
echo isset($orderComplex->orderinfos[0]) ? HotelHelper::checkOutDate($orderComplex->orderinfos[0]->end) : '';
?>
</td>
示例9:
<!-- Cell -->
<?php
if ($item->published != '1') {
?>
<div class="system-unpublished">
<?php
}
?>
<?php
if ($this->params->get('global_list_meta_title') != 'hide') {
?>
<h3> <a href="<?php
echo JRoute::_(hwdMediaShareHelperRoute::getMediaItemRoute($item->slug));
?>
"> <?php
echo $this->escape(JHtmlString::truncate($item->title, $this->params->get('global_list_title_truncate')));
?>
</a> </h3>
<?php
}
?>
<!-- Thumbnail Image -->
<div class="media-item thumbnail">
<?php
if ($canEdit || $canDelete) {
?>
<!-- Actions -->
<ul class="media-nav">
<li><a href="#" class="pagenav-manage"><?php
echo JText::_('COM_HWDMS_MANAGE');
?>
示例10: prepareDocument
/**
* Prepare the document
*/
protected function prepareDocument()
{
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
// Prepare page heading
$this->preparePageHeading();
// Prepare page heading
$this->preparePageTitle();
if ($this->params->get('menu-meta_description')) {
$this->document->setDescription($this->params->get('menu-meta_description'));
} else {
$this->document->setDescription($this->item->short_desc);
}
if ($this->params->get('menu-meta_keywords')) {
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots')) {
$this->document->setMetadata('robots', $this->params->get('robots'));
}
// Breadcrumb
$pathway = $this->app->getPathWay();
$currentBreadcrumb = JHtmlString::truncate($this->item->title, 16);
$pathway->addItem($currentBreadcrumb, '');
// Scripts
JHtml::_('bootstrap.framework');
$this->document->addScript('media/' . $this->option . '/js/site/backing.js');
}
示例11:
?>
</a>
<div class="caption">
<h3>
<a href="<?php
echo JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
?>
">
<?php
echo JHtmlString::truncate($this->item->title, $this->titleLength, true, false);
?>
</a>
</h3>
<p><?php
echo JHtmlString::truncate($this->item->short_desc, $this->descriptionLength, true, false);
?>
</p>
</div>
<div class="cf-caption-info absolute-bottom">
<?php
echo JHtml::_("crowdfunding.progressbar", $fundedPercents, $this->item->days_left, $this->item->funding_type);
?>
<div class="row-fluid">
<div class="col-md-4">
<div class="bolder"><?php
echo $this->item->funded_percents;
?>
%</div>
<div class="text-uppercase"><?php
示例12:
if ($socialProfiles !== null) {
?>
<div class="font-xxsmall">
<?php
echo JText::sprintf('COM_CROWDFUNDING_BY_S', $profileName);
?>
</div>
<?php
}
?>
<?php
if ((bool) $params->get('discover_display_description', Prism\Constants::DISPLAY)) {
?>
<p><?php
echo JHtmlString::truncate($item->short_desc, $displayData['descriptionLength'], true, false);
?>
</p>
<?php
}
?>
</div>
<div class="cf-caption-info absolute-bottom">
<div class="row">
<div class="col-md-8">
<span class="text-uppercase"><span class="fa fa-university"></span> <?php
echo JText::_('COM_CROWDFUNDING_RAISED');
?>
</span>
</div>
<div class="col-md-4 text-right">
示例13: prepareDocument
/**
* Prepare the document
*/
protected function prepareDocument()
{
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
// Prepare page heading
$this->preparePageHeading();
// Prepare page heading
$this->preparePageTitle();
if ($this->params->get('menu-meta_description')) {
$this->document->setDescription($this->params->get('menu-meta_description'));
} else {
$this->document->setDescription(JText::sprintf('COM_CROWDFUNDING_MAIL_TO_FRIEND_META_DESC_S', $this->item->title));
}
if ($this->params->get('menu-meta_keywords')) {
$this->document->setMetaData('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots')) {
$this->document->setMetaData('robots', $this->params->get('robots'));
}
// Breadcrumb
$pathway = $this->app->getPathway();
$currentBreadcrumb = JHtmlString::truncate($this->item->title, 16);
$pathway->addItem($currentBreadcrumb, '');
// Add scripts
JHtml::_('jquery.framework');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
}
示例14:
<?php
}
?>
<td>
<a href="<?php
echo $orderlink;
?>
" target="_blank">
<?php
echo $item->order_number;
?>
<span class="icon-print"></span>
</a>
<br/>
<label class="label"> <?php
echo JHtmlString::truncate($tour->title, 20, true);
?>
</label>
</td>
<td class="center hidden-phone">
<?php
echo $this->escape($item->id);
?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
示例15: htmlspecialchars
echo htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8');
?>
</a>
<?php
} else {
?>
<?php
echo htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8');
?>
<?php
}
?>
</span>
<p><?php
echo htmlspecialchars(JHtmlString::truncate($project->getShortDesc(), $params->get('description_length', 255), true, false), ENT_QUOTES, 'UTF-8');
?>
</p>
</div>
<div class="cf-caption-info absolute-bottom">
<?php
echo JHtml::_('crowdfunding.progressbar', $fundedPercents, $project->getDaysLeft(), $project->getFundingType());
?>
<div class="row">
<div class="col-md-4">
<div class="bolder"><?php
echo $project->getFundedPercent();
?>
%</div>
<div class="text-uppercase"><?php