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


PHP StringUtil::substring方法代码示例

本文整理汇总了PHP中StringUtil::substring方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::substring方法的具体用法?PHP StringUtil::substring怎么用?PHP StringUtil::substring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringUtil的用法示例。


在下文中一共展示了StringUtil::substring方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($data, $boxname = "")
 {
     $this->TopData['templatename'] = "topthanksgivinguser";
     $this->getBoxStatus($data);
     $this->TopData['boxID'] = $data['boxID'];
     if (!defined('TOPTHANKSGIVINGUSER_COUNT_ACP')) {
         define('TOPTHANKSGIVINGUSER_COUNT_ACP', 10);
     }
     if (!defined('TOPTHANKSGIVINGUSER_TITLELENGTH_ACP')) {
         define('TOPTHANKSGIVINGUSER_TITLELENGTH_ACP', 28);
     }
     if (!defined('TOPTHANKSGIVINGUSER_SBCOLOR_ACP')) {
         define('TOPTHANKSGIVINGUSER_SBCOLOR_ACP', 2);
     }
     if (!defined('TOPTHANKSGIVINGUSER_HITS_ACP')) {
         define('TOPTHANKSGIVINGUSER_HITS_ACP', true);
     }
     $sql = "SELECT wcf.userID, wcf.username, wbb.thanks_got" . "\n  FROM wcf" . WCF_N . "_user wcf" . "\n  LEFT JOIN wbb" . WBB_N . "_user wbb ON (wbb.userid = wcf.userid)" . "\n WHERE wbb.thanks_got > 0" . "\n ORDER BY wbb.thanks_got DESC, wcf.username" . "\n LIMIT 0, " . TOPTHANKSGIVINGUSER_COUNT_ACP;
     $result = WBBCore::getDB()->sendQuery($sql);
     while ($row = WBBCore::getDB()->fetchArray($result)) {
         $plainUser = $row['username'];
         $row['thanks_got'] = StringUtil::formatInteger($row['thanks_got']);
         if (TOPTHANKSGIVINGUSER_TITLELENGTH_ACP != 0 && strlen($plainUser) > TOPTHANKSGIVINGUSER_TITLELENGTH_ACP) {
             $row['username'] = StringUtil::substring($plainUser, 0, TOPTHANKSGIVINGUSER_TITLELENGTH_ACP - 3) . '...';
         }
         $row['username'] = StringUtil::encodeHTML($row['username']);
         $this->TopData['thanksgivinguser'][] = $row;
     }
     WCF::getTPL()->assign('TOPTHANKSGIVINGUSER_SBCOLOR_ACP', intval(TOPTHANKSGIVINGUSER_SBCOLOR_ACP));
     WCF::getTPL()->assign('TOPTHANKSGIVINGUSER_HITS_ACP', TOPTHANKSGIVINGUSER_HITS_ACP);
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:31,代码来源:TopThanksgivingUser.class.php

示例2: checkCondition

 /**
  * Checks the condition.
  *
  * @param	PMRuleCondition		$condition
  * @param	string			$string
  * @return	boolean
  */
 protected function checkCondition(PMRuleCondition $condition, $string)
 {
     $value = StringUtil::toLowerCase($condition->ruleConditionValue);
     $string = StringUtil::toLowerCase($string);
     switch ($condition->ruleCondition) {
         case 'contains':
             if (StringUtil::indexOf($string, $value) !== false) {
                 return true;
             }
             break;
         case 'dontContains':
             if (StringUtil::indexOf($string, $value) === false) {
                 return true;
             }
             break;
         case 'beginsWith':
             if (StringUtil::indexOf($string, $value) === 0) {
                 return true;
             }
             break;
         case 'endsWith':
             if (StringUtil::substring($string, -1 * StringUtil::length($value)) == $value) {
                 return true;
             }
             break;
         case 'isEqualTo':
             if ($value == $string) {
                 return true;
             }
             break;
     }
     return false;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:40,代码来源:SenderPMRuleConditionType.class.php

示例3: parseKeywords

 /**
  * Parses search keywords.
  * 
  * @param	string		$keywordString
  */
 protected static function parseKeywords($keywordString)
 {
     // convert encoding if necessary
     if (CHARSET == 'UTF-8' && !StringUtil::isASCII($keywordString) && !StringUtil::isUTF8($keywordString)) {
         $keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
     }
     // remove bad wildcards
     $keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString);
     // remove search operators
     $keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString);
     if (StringUtil::substring($keywordString, 0, 1) == '"' && StringUtil::substring($keywordString, -1) == '"') {
         // phrases search
         $keywordString = StringUtil::trim(StringUtil::substring($keywordString, 1, -1));
         if (!empty($keywordString)) {
             self::$keywords = array_merge(self::$keywords, array(StringUtil::encodeHTML($keywordString)));
         }
     } else {
         // replace word delimiters by space
         $keywordString = preg_replace('/[.,]/', ' ', $keywordString);
         $keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
         if (count($keywords) > 0) {
             self::$keywords = array_merge(self::$keywords, $keywords);
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:30,代码来源:KeywordHighlighter.class.php

示例4: __construct

 public function __construct($data, $boxname = "")
 {
     $this->TopData['templatename'] = "topthreads";
     $this->getBoxStatus($data);
     $this->TopData['boxID'] = $data['boxID'];
     if (!defined('TOPTHREADS_COUNT')) {
         define('TOPTHREADS_COUNT', 10);
     }
     if (!defined('TOPTHREADS_TITLELENGTH')) {
         define('TOPTHREADS_TITLELENGTH', 25);
     }
     if (!defined('TOPTHREADS_SBCOLOR_ACP')) {
         define('TOPTHREADS_SBCOLOR_ACP', 2);
     }
     require_once WBB_DIR . 'lib/data/board/Board.class.php';
     $boardIDs = Board::getAccessibleBoards();
     if (!empty($boardIDs)) {
         $sql = "SELECT thread.*" . "\n  FROM wbb" . WBB_N . "_thread thread" . "\n WHERE thread.boardID IN (0" . $boardIDs . ")" . "\n ORDER BY thread.replies DESC" . "\n LIMIT 0, " . TOPTHREADS_COUNT;
         $result = WBBCore::getDB()->sendQuery($sql);
         while ($row = WBBCore::getDB()->fetchArray($result)) {
             $row['replies'] = StringUtil::formatInteger($row['replies']);
             $row['title'] = StringUtil::encodeHTML($row['topic']) . ' - ' . $row['replies'];
             if (TOPTHREADS_TITLELENGTH != 0 && strlen($row['topic']) > TOPTHREADS_TITLELENGTH) {
                 $row['topic'] = StringUtil::substring($row['topic'], 0, TOPTHREADS_TITLELENGTH - 3) . '...';
             }
             $row['topic'] = StringUtil::encodeHTML($row['topic']);
             $this->TopData['threads'][] = $row;
         }
     }
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:30,代码来源:TopThreads.class.php

示例5: execute

 /**
  * @see TemplatePluginModifier::execute()
  */
 public function execute($tagArgs, Template $tplObj)
 {
     // default values
     $length = 80;
     $etc = '...';
     $breakWords = false;
     // get values
     $string = $tagArgs[0];
     if (isset($tagArgs[1])) {
         $length = intval($tagArgs[1]);
     }
     if (isset($tagArgs[2])) {
         $etc = $tagArgs[2];
     }
     if (isset($tagArgs[3])) {
         $breakWords = $tagArgs[3];
     }
     // execute plugin
     if ($length == 0) {
         return '';
     }
     if (StringUtil::length($string) > $length) {
         $length -= StringUtil::length($etc);
         if (!$breakWords) {
             $string = preg_replace('/\\s+?(\\S+)?$/', '', StringUtil::substring($string, 0, $length + 1));
         }
         return StringUtil::substring($string, 0, $length) . $etc;
     } else {
         return $string;
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:34,代码来源:TemplatePluginModifierTruncate.class.php

示例6: insertPageNumber

 /**
  * Inserts the page number into the link.
  * 
  * @param 	string		$link
  * @param 	integer		$pageNo
  * @return	string		final link
  */
 protected static function insertPageNumber($link, $pageNo)
 {
     $startPos = StringUtil::indexOf($link, '%d');
     if ($startPos !== null) {
         $link = StringUtil::substring($link, 0, $startPos) . $pageNo . StringUtil::substring($link, $startPos + 2);
     }
     return $link;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:15,代码来源:TemplatePluginFunctionSmallpages.class.php

示例7: getMessagePreview

 /**
  * Returns an excerpt of this private message.
  * 
  * @return	string
  */
 public function getMessagePreview()
 {
     AttachmentBBCode::setMessageID($this->pmID);
     $parser = MessageParser::getInstance();
     $parser->setOutputType('text/plain');
     $message = $parser->parse($this->message, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, false);
     if (StringUtil::length($message) > 500) {
         $message = StringUtil::substring($message, 0, 497) . '...';
     }
     return $message;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:16,代码来源:ViewablePM.class.php

示例8: handleData

 /**
  * @see DatabaseObject::handleData()
  */
 protected function handleData($data)
 {
     parent::handleData($data);
     // calculate page logo path
     if (!empty($this->data['variables']['page.logo.image']) && !FileUtil::isURL($this->data['variables']['page.logo.image']) && StringUtil::substring($this->data['variables']['page.logo.image'], 0, 1) !== '/') {
         $this->data['variables']['page.logo.image'] = RELATIVE_WCF_DIR . $this->data['variables']['page.logo.image'];
     }
     // load icon cache
     WCF::getCache()->addResource('icon-' . PACKAGE_ID . '-' . $this->styleID, WCF_DIR . 'cache/cache.icon-' . PACKAGE_ID . '-' . $this->styleID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderIcon.class.php');
     $this->iconCache = WCF::getCache()->get('icon-' . PACKAGE_ID . '-' . $this->styleID);
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:14,代码来源:ActiveStyle.class.php

示例9: getExcerpt

 /**
  * Returns an excerpt of the message.
  * 
  * @return	string
  */
 public function getExcerpt()
 {
     $enableSmilies = 1;
     $enableHtml = 0;
     $enableBBCodes = 1;
     MessageParser::getInstance()->setOutputType('text/plain');
     $message = MessageParser::getInstance()->parse($this->comment, $enableSmilies, $enableHtml, $enableBBCodes);
     // get abstract
     if (StringUtil::length($message) > 50) {
         $message = StringUtil::substring($message, 0, 47) . '...';
     }
     return $message;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:18,代码来源:ViewableContestComment.class.php

示例10: getTitle

 /**
  * @see NotificationObject::getTitle()
  */
 public function getTitle()
 {
     $message = $this->getFormattedMessage('text/plain');
     $message = StringUtil::stripHTML($message);
     $message = StringUtil::trim($message);
     if (StringUtil::length($message) > 100) {
         $message = StringUtil::substring($message, 0, 97) . '...';
     }
     if (empty($message)) {
         $message = '#' . $this->entryID;
     }
     return $message;
 }
开发者ID:0xLeon,项目名称:com.leon.wbb.notification.post.delete,代码行数:16,代码来源:PostDeleteNotificationObject.class.php

示例11: getTitle

 public static function getTitle($name, $html = false)
 {
     $item = 'wcf.sketchbook.sketchTitles.' . self::nameToLangVar($name);
     $value = WCF::getLanguage()->getDynamicVariable($item);
     $new = false;
     if ($value == $title) {
         $value = StringUtil::substring($title, StringUtil::lastIndexOf($title, '.'));
         $new = true;
     }
     if ($html) {
         return '<span class="sketch' . ($new ? ' sketchNew' : '') . '">' . StringUtil::encodeHTML($title) . '</span>';
     }
     return $title;
 }
开发者ID:nachteule,项目名称:nachteule.wcf.sketchbook,代码行数:14,代码来源:SketchbookUtil.class.php

示例12: getExcerpt

 /**
  * Returns an excerpt of the help item.
  * 
  * @return	string
  */
 public function getExcerpt()
 {
     // get text
     $description = WCF::getLanguage()->getDynamicVariable('wcf.help.item.' . $this->helpItem . '.description');
     // remove headlines
     $description = preg_replace('~<h4>.*?</h4>~', '', $description);
     // remove help images
     $description = preg_replace('~<p class="helpImage.*?</p>~s', '', $description);
     // strip html tags
     $description = strip_tags($description);
     // truncate text
     if (StringUtil::length($description) > 250) {
         $description = preg_replace('/\\s+?(\\S+)?$/', '', StringUtil::substring($description, 0, 251));
         $description = StringUtil::substring($description, 0, 250) . '...';
     }
     return $description;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:22,代码来源:HelpItem.class.php

示例13: executeStart

 /**
  * @see TemplatePluginCompiler::executeStart()
  */
 public function executeStart($tagArgs, TemplateScriptingCompiler $compiler)
 {
     $compiler->pushTag('implode');
     if (!isset($tagArgs['from'])) {
         throw new SystemException($compiler->formatSyntaxError("missing 'from' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()), 12001);
     }
     if (!isset($tagArgs['item'])) {
         throw new SystemException($compiler->formatSyntaxError("missing 'item' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()), 12001);
     }
     $hash = StringUtil::getRandomID();
     $glue = isset($tagArgs['glue']) ? $tagArgs['glue'] : "', '";
     $this->tagStack[] = array('hash' => $hash, 'glue' => $glue);
     $phpCode = "<?php\n";
     $phpCode .= "\$_length" . $hash . " = count(" . $tagArgs['from'] . ");\n";
     $phpCode .= "\$_i" . $hash . " = 0;\n";
     $phpCode .= "foreach (" . $tagArgs['from'] . " as " . (isset($tagArgs['key']) ? (StringUtil::substring($tagArgs['key'], 0, 1) != '$' ? "\$this->v[" . $tagArgs['key'] . "]" : $tagArgs['key']) . " => " : '') . (StringUtil::substring($tagArgs['item'], 0, 1) != '$' ? "\$this->v[" . $tagArgs['item'] . "]" : $tagArgs['item']) . ") { ?>";
     return $phpCode;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:21,代码来源:TemplatePluginCompilerImplode.class.php

示例14: autoload

 /**
  * autoload method for classname
  *
  * @param 	string		$className
  */
 public function autoload($className)
 {
     if (!isset($className)) {
         throw new SystemException('missing className');
     }
     $className = StringUtil::getClassName($className);
     $dir = StringUtil::toLowercase(StringUtil::substring($className, StringUtil::length('ViewableContest')));
     if (empty($dir)) {
         throw new SystemException('wrong dir: ' . $dir);
     }
     $file = WCF_DIR . 'lib/data/contest/' . $dir . '/' . $className . '.class.php';
     if (!is_file($file)) {
         throw new SystemException('wrong file: ' . $file);
     }
     require_once $file;
     if (!class_exists($className)) {
         throw new SystemException('class does not exist: ' . $className);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:24,代码来源:ContestEventMix.class.php

示例15: __construct

 public function __construct($data, $boxname = "")
 {
     $this->threadLastPostsBoxData['templatename'] = "threadlastpostsbox";
     $this->getBoxStatus($data);
     $this->threadLastPostsBoxData['boxID'] = $data['boxID'];
     $cntPosts = 0;
     if (!defined('THREADLASTPOSTSBOX_THREADID')) {
         define('THREADLASTPOSTSBOX_THREADID', 0);
     }
     if (!defined('THREADLASTPOSTSBOX_LIMIT')) {
         define('THREADLASTPOSTSBOX_LIMIT', 10);
     }
     if (!defined('THREADLASTPOSTSBOX_TITLELENGTH')) {
         define('THREADLASTPOSTSBOX_TITLELENGTH', 28);
     }
     if (!defined('THREADLASTPOSTSBOX_SBCOLOR')) {
         define('THREADLASTPOSTSBOX_SBCOLOR', 2);
     }
     require_once WBB_DIR . 'lib/data/board/Board.class.php';
     $boardIDs = Board::getAccessibleBoards();
     if (!empty($boardIDs) && THREADLASTPOSTSBOX_THREADID) {
         $sql = "SELECT wp.postID, wp.threadID, wp.userID, wp.subject, wp.message, wp.time" . "\n  FROM wbb1_1_post wp" . "\n  JOIN wbb1_1_thread wt ON (wt.threadID = wp.threadID)" . "\n WHERE wp.threadID = " . THREADLASTPOSTSBOX_THREADID . "\n   AND wp.isDeleted = 0" . "\n   AND wp.isDisabled = 0" . "\n   AND wt.isDeleted = 0" . "\n   AND wt.isDisabled = 0" . "\n   AND wt.boardID IN (" . $boardIDs . ")" . "\n ORDER BY wp.postID DESC" . "\n  LIMIT 0, " . THREADLASTPOSTSBOX_LIMIT;
         $result = WBBCore::getDB()->sendQuery($sql);
         while ($row = WBBCore::getDB()->fetchArray($result)) {
             if (!empty($row['subject'])) {
                 $title = $row['subject'];
             } else {
                 $title = preg_replace('/\\[/', '<', $row['message']);
                 $title = preg_replace('/\\]/', '>', $title);
                 $title = strip_tags($title);
                 //StringUtil::stripHTML($title);
             }
             if (THREADLASTPOSTSBOX_TITLELENGTH != 0 && StringUtil::length($title) > THREADLASTPOSTSBOX_TITLELENGTH) {
                 $title = StringUtil::substring($title, 0, THREADLASTPOSTSBOX_TITLELENGTH - 3) . '...';
             }
             $row['title'] = StringUtil::encodeHTML($title);
             $this->threadLastPostsBoxData['box'][] = $row;
             $cntPosts++;
         }
     }
     WCF::getTPL()->assign(array('THREADLASTPOSTSBOX_SBCOLOR' => intval(THREADLASTPOSTSBOX_SBCOLOR), 'threadLastPostBoxCnt' => $cntPosts));
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:42,代码来源:ThreadLastPostsBox.class.php


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