本文整理汇总了PHP中JHtmlString类的典型用法代码示例。如果您正苦于以下问题:PHP JHtmlString类的具体用法?PHP JHtmlString怎么用?PHP JHtmlString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JHtmlString类的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: testTruncateComplex
/**
* Tests the JHtmlString::truncateComplex method.
*
* @param string $html The text to truncate.
* @param integer $maxLength The maximum length of the text.
* @param boolean $noSplit Don't split a word if that is where the cutoff occurs (default: true)
* @param string $expected The expected result.
*
* @return void
*
* @dataProvider getTestTruncateComplexData
* @since 12.2
*/
public function testTruncateComplex($html, $maxLength, $noSplit, $expected)
{
$this->assertThat(JHtmlString::truncateComplex($html, $maxLength, $noSplit), $this->equalTo($expected));
}
示例8:
<?php
echo $this->escape($item->title);
?>
</a>
<?php
if ($this->displayProjectsNumber) {
$number = !array_key_exists($item->id, $this->projectsNumber) ? 0 : $this->projectsNumber[$item->id]['number'];
echo '( ' . $number . ' )';
}
?>
</h3>
<?php
if ((bool) $this->params->get('categories_display_description', true)) {
?>
<p><?php
echo JHtmlString::truncate($item->description, $this->descriptionLength, true, false);
?>
</p>
<?php
}
?>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php
}
示例9:
}
}
?>
(<?php
echo StreamMessage::formatBytes($row->filesize);
?>
)
</span>
<div class="file-list-meta-content">
<div class="file-list-meta-inner">
<span>Attached in:</span>
<a href="<?php
echo $streamObj->getUri();
?>
"><?php
echo StreamTemplate::escape(JHtmlString::truncate($streamObj->message, 200));
?>
</a>
</div>
<span class="uploader"><a href="<?php
echo $user->getURL();
?>
" class="actor-link"><?php
echo $this->escape($user->name);
?>
</a></span>
</div>
</div>
<?php
/*
示例10:
<!-- 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');
?>
示例11: array
echo $newprod;
?>
">
<span class="hover"></span>
<?php
$image = !empty($product->images[0]) ? $product->images[0]->displayMediaThumb('class="featuredProductImage" border="0"', FALSE) : '';
echo '<div class="image">' . JHTML::_('link', $link . $itemid, $image, array('title' => $product->product_name)) . '</div>';
?>
<div class="prod-details fixclear">
<h3><?php
echo JHtml::link($link . $itemid, $product->product_name);
?>
</h3>
<p class="desc"><?php
echo JHtmlString::truncate($product->product_desc, 80, true, false);
?>
</p>
<?php
echo shopFunctionsF::renderVmSubLayout('kl_prices_basic', array('product' => $product, 'currency' => $currency));
?>
<div class="kl-extra-info">
<?php
echo shopFunctionsF::renderVmSubLayout('kl_rating', array('showRating' => $showRating, 'product' => $product));
?>
</div>
</div><!-- /.prod-details -->
<div class="prod-actions">
<?php
// More info button
示例12:
?>
</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
示例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($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');
}
示例14:
<tbody>
<?php
for ($i = 0, $max = count($this->mostFunded); $i < $max; $i++) {
?>
<tr>
<td><?php
echo $i + 1;
?>
</td>
<td>
<a href="<?php
echo JRoute::_('index.php?option=com_crowdfunding&view=projects&filter_search=id:' . (int) $this->mostFunded[$i]['id']);
?>
">
<?php
echo JHtmlString::truncate(strip_tags($this->mostFunded[$i]['title']), 53);
?>
</a>
</td>
<td>
<?php
echo $this->amount->setValue($this->mostFunded[$i]['funded'])->formatCurrency();
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
示例15: All
<h3>Files</h3>
<a href="<?php
echo JRoute::_('index.php?option=com_stream&view=files&user_id=' . $this->user->id);
?>
">Show All (<?php
echo $this->fileCount;
?>
)</a>
</div>
<ol class="content-list">
<?php
foreach ($this->files as $file) {
$dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id);
echo '<li class="message-content-file">';
echo '<a title="Click to download" href="' . $dlLink . '">' . StreamTemplate::escape(JHtmlString::truncate($file->filename, 24)) . '</a>';
echo ' <span class="small hint">(' . StreamMessage::formatBytes($file->filesize, 1) . ')</span>';
echo '</li>';
}
?>
</ol>
</div>
<div class="data-grid">
<div class="content-title">
<h3>Links</h3>
<a href="<?php
echo JRoute::_('index.php?option=com_stream&view=links&user_id=' . $this->user->id);
?>