本文整理汇总了PHP中StringUtil::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::truncate方法的具体用法?PHP StringUtil::truncate怎么用?PHP StringUtil::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::truncate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAnyError
public function onAnyError($aOptions, $bNeverPrint = false, $bNeverNotifyDeveloper = false)
{
if ($bNeverNotifyDeveloper) {
return;
}
$aProwlConfig = Settings::getSetting('prowl', 'users', array());
$aKeys = array();
foreach ($aProwlConfig as $aConfig) {
if (in_array(ErrorHandler::getEnvironment(), $aConfig['environments'])) {
$aKeys[] = $aConfig['key'];
}
}
if (count($aKeys) == 0) {
return;
}
$aError =& $aOptions[0];
$aProwlParams = array();
$aProwlParams['apikey'] = implode(',', $aKeys);
$aProwlParams['application'] = "Rapila on " . $aError['host'];
$aProwlParams['event'] = "Error on in " . $aError['path'];
$aProwlParams['url'] = 'http://' . $aError['host'] . $aError['path'];
$aProwlParams['description'] = StringUtil::truncate($aError['message'], 800);
$sParams = http_build_query($aProwlParams);
$rCurl = curl_init('https://api.prowlapp.com/publicapi/add');
curl_setopt($rCurl, CURLOPT_POSTFIELDS, $sParams);
curl_setopt($rCurl, CURLOPT_POST, 1);
curl_exec($rCurl);
}
示例2: getBodyTruncated
public function getBodyTruncated($iLength = 70)
{
$sText = '';
if (is_resource($this->getBody())) {
$sText = RichtextUtil::parseStorageForBackendOutput(stream_get_contents($this->getBody()))->render();
$sText = strip_tags($sText);
}
if ($iLength) {
return StringUtil::truncate($sText, $iLength);
}
return $sText;
}
示例3: renderRecentJournalEntryTeaser
private function renderRecentJournalEntryTeaser($mJournalId)
{
$oJournalEntry = FrontendJournalEntryQuery::create()->filterByJournalId($mJournalId)->mostRecentFirst()->findOne();
if ($oJournalEntry === null) {
return null;
}
$oTemplate = $this->constructTemplate('journal_entry_teaser');
$sHref = LinkUtil::link($oJournalEntry->getLink($this->oJournalPage));
$oTemplate->replaceIdentifier('title', TagWriter::quickTag('a', array('href' => $sHref), $oJournalEntry->getTitle()));
$oTemplate->replaceIdentifier('link_to_detail', $sHref);
$oTemplate->replaceIdentifier('publish_at', $oJournalEntry->getPublishAt('U'));
$oTemplate->replaceIdentifier('user_name', $oJournalEntry->getUserRelatedByCreatedBy()->getFullName());
$sTextShort = RichtextUtil::parseStorageForFrontendOutput($oJournalEntry->getTextShort());
$oTemplate->replaceIdentifier('text_short', $sTextShort);
$oTemplate->replaceIdentifier('text_short_truncated', StringUtil::truncate(strip_tags($sTextShort), 300));
return $oTemplate;
}
示例4: truncate
public function truncate($oTemplateIdentifier, &$iFlags)
{
$iFlags |= Template::NO_HTML_ESCAPE;
$iLength = 20;
if ($oTemplateIdentifier->hasParameter('length')) {
$iLength = $oTemplateIdentifier->getParameter('length');
}
$sPostfix = "…";
if ($oTemplateIdentifier->hasParameter('postfix')) {
$sPostfix = $oTemplateIdentifier->getParameter('postfix');
}
$iTolerance = 3;
if ($oTemplateIdentifier->hasParameter('tolerance')) {
$iTolerance = $oTemplateIdentifier->getParameter('tolerance');
}
return StringUtil::truncate($oTemplateIdentifier->getValue(), $iLength, $sPostfix, $iTolerance);
}
示例5: getName
public function getName($iLength = 20)
{
$sNewsletterName = $this->getNewsletter() ? $this->getNewsletter()->getSubject() : 'oNewsletter missing!';
return $this->getDateSentFormatted() . StringUtil::truncate($sNewsletterName, $iLength);
}
示例6: getName
public function getName($iLength = 35)
{
return StringUtil::truncate($this->getSubject(), $iLength);
}
示例7: getNameTruncated
public function getNameTruncated()
{
return StringUtil::truncate($this->getName(), 50);
}
示例8: getDescriptionTruncated
public function getDescriptionTruncated($iLength = 40)
{
return StringUtil::truncate($this->getDescription(), $iLength);
}
示例9: renderRecentCommentsWidget
/**
* renderRecentCommentsWidget()
*
* description: renders a comments teaser list
* change limit count by overwriting the config param "recent_comments_limit" in your site/config/config.yml
* @return Template object
*/
private function renderRecentCommentsWidget()
{
$oTemplate = $this->constructTemplate('widget_recent_comments');
$oItemPrototype = $this->constructTemplate('widget_recent_comment_item');
$iLimit = Settings::getSetting('journal', 'recent_comments_limit', 3);
$oQuery = JournalCommentQuery::create()->excludeUnverified()->mostRecentFirst()->limit($iLimit)->useJournalEntryQuery()->filterByJournalId($this->aJournalIds)->endUse()->groupByJournalEntryId();
foreach ($oQuery->find() as $oComment) {
$oCommentTemplate = clone $oItemPrototype;
if ($oEntry = $oComment->getJournalEntry()) {
$oCommentTemplate->replaceIdentifier('title', $oEntry->getTitle());
$oDetailLink = TagWriter::quickTag('a', array('rel' => 'internal', 'class' => 'read_more', 'href' => LinkUtil::link($oEntry->getLink($this->oPage)) . '#comments'), TranslationPeer::getString('journal_entry_teaser.read_more'));
$oCommentTemplate->replaceIdentifier('link_to_detail', $oDetailLink);
}
$oCommentTemplate->replaceIdentifier('name', $oComment->getUsername());
$oCommentTemplate->replaceIdentifier('date', $oComment->getCreatedAtLocalized());
$oCommentTemplate->replaceIdentifier('text_stripped', StringUtil::truncate(strip_tags($oComment->getText()), 45));
$oCommentTemplate->replaceIdentifier('text', $oComment->getText());
$oTemplate->replaceIdentifierMultiple('comments', $oCommentTemplate);
}
return $oTemplate;
}
示例10: setTitle
public function setTitle($sTitle)
{
if ($this->isNew() || $this->getSlug() == null) {
$this->setSlug(StringUtil::truncate(StringUtil::normalizePath($sTitle), 50, '', 0));
}
return parent::setTitle($sTitle);
}