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


PHP StringUtil::truncate方法代码示例

本文整理汇总了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);
 }
开发者ID:rapila,项目名称:plugin-prowl_error_handler,代码行数:28,代码来源:ProwlFilterModule.php

示例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;
 }
开发者ID:rapila,项目名称:plugin-documentation,代码行数:12,代码来源:DocumentationPart.php

示例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;
 }
开发者ID:rapila,项目名称:plugin-journal,代码行数:17,代码来源:JournalFrontendModule.php

示例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);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:17,代码来源:SpecialTemplateIdentifierActions.php

示例5: getName

 public function getName($iLength = 20)
 {
     $sNewsletterName = $this->getNewsletter() ? $this->getNewsletter()->getSubject() : 'oNewsletter missing!';
     return $this->getDateSentFormatted() . StringUtil::truncate($sNewsletterName, $iLength);
 }
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:5,代码来源:NewsletterMailing.php

示例6: getName

 public function getName($iLength = 35)
 {
     return StringUtil::truncate($this->getSubject(), $iLength);
 }
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:4,代码来源:Newsletter.php

示例7: getNameTruncated

 public function getNameTruncated()
 {
     return StringUtil::truncate($this->getName(), 50);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:4,代码来源:Document.php

示例8: getDescriptionTruncated

 public function getDescriptionTruncated($iLength = 40)
 {
     return StringUtil::truncate($this->getDescription(), $iLength);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:4,代码来源:Link.php

示例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;
 }
开发者ID:rapila,项目名称:plugin-journal,代码行数:28,代码来源:JournalPageTypeModule.php

示例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);
 }
开发者ID:rapila,项目名称:plugin-journal,代码行数:7,代码来源:JournalEntry.php


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