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


PHP StringUtil::unifyNewlines方法代码示例

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


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

示例1: __construct

 /**
  * Creates a new MessageAttachmentListEditor object.
  * 
  * @param	array<integer>	$containerIDArray
  * @param	string		$containerType
  * @param	integer		$packageID
  * @param	integer		$maxFileSize
  * @param	string		$allowedExtensions
  * @param	integer		$maxUploads
  * @param	integer		$thumbnailWidth
  * @param	integer		$thumbnailHeight
  * @param	boolean		$addSourceInfo
  * @param	boolean		$useEmbedded
  */
 public function __construct($containerIDArray = array(), $containerType = 'post', $packageID = PACKAGE_ID, $maxFileSize = 2000000, $allowedExtensions = "gif\njpg\njpeg\npng\nbmp\nzip\ntxt", $maxUploads = 5, $thumbnailWidth = ATTACHMENT_THUMBNAIL_WIDTH, $thumbnailHeight = ATTACHMENT_THUMBNAIL_HEIGHT, $addSourceInfo = ATTACHMENT_THUMBNAIL_ADD_SOURCE_INFO, $useEmbedded = ATTACHMENT_THUMBNAIL_USE_EMBEDDED)
 {
     if (!is_array($containerIDArray)) {
         $containerIDArray = array($containerIDArray);
     }
     $this->thumbnailWidth = $thumbnailWidth;
     $this->thumbnailHeight = $thumbnailHeight;
     $this->addSourceInfo = $addSourceInfo;
     $this->useEmbedded = $useEmbedded;
     if (!count($containerIDArray)) {
         $this->getIDHash();
     }
     // call parent constructor
     parent::__construct($containerIDArray, $containerType, $this->idHash, $packageID);
     // read attachments
     $this->readObjects();
     $this->maxFileSize = $maxFileSize;
     $this->maxUploads = $maxUploads;
     $allowedExtensions = StringUtil::unifyNewlines($allowedExtensions);
     $allowedExtensions = implode("\n", array_unique(explode("\n", $allowedExtensions)));
     $this->allowedExtensions = '/^(' . StringUtil::replace("\n", "|", StringUtil::replace('\\*', '.*', preg_quote($allowedExtensions, '/'))) . ')$/i';
     $this->allowedExtensionsDesc = self::formatAllowedExtensions($allowedExtensions);
     $this->getAttachmentHashes();
     $this->assign();
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:39,代码来源:MessageAttachmentListEditor.class.php

示例2: __construct

 /**
  * Creates a new MemcacheAdapter object.
  */
 private function __construct()
 {
     if (!class_exists('Memcache')) {
         throw new SystemException('memcache support is not enabled.');
     }
     // init memcache
     $this->memcache = new Memcache();
     // add servers
     $servers = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHE_HOST));
     foreach ($servers as $server) {
         $server = StringUtil::trim($server);
         if (!empty($server)) {
             $host = $server;
             $port = 11211;
             // default memcache port
             // get port
             if (strpos($host, ':')) {
                 $parsedHost = explode(':', $host);
                 $host = $parsedHost[0];
                 $port = $parsedHost[1];
             }
             $this->memcache->addServer($host, $port, CACHE_SOURCE_MEMCACHE_USE_PCONNECT);
         }
     }
     // test connection
     $this->memcache->get('testing');
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:30,代码来源:MemcacheAdapter.class.php

示例3: __construct

 public function __construct()
 {
     if (MODULE_USER_EMAIL_BLACKLIST && BLOCKED_EMAIL_SUFFIXES != '') {
         $this->enabled = true;
         $blockedEmailSuffixex = explode("\n", preg_quote(StringUtil::unifyNewlines(StringUtil::trim(BLOCKED_EMAIL_SUFFIXES))));
         $blockedEmailSuffixex = array_filter($blockedEmailSuffixex);
         $this->mailSuffixRegex = '!^(.*' . implode('|.*', $blockedEmailSuffixex) . ')$!i';
     }
 }
开发者ID:RouL,项目名称:email_blocklist,代码行数:9,代码来源:EMailBlocklistListener.class.php

示例4: stripCrap

 /**
  * Strips session links, html entities and \r\n from the given text.
  * 
  * @param	string		$text
  * @return	string
  */
 public static function stripCrap($text)
 {
     // strip session links
     $text = preg_replace('/(?<=\\?|&)s=[a-z0-9]{40}/', '', $text);
     // convert html entities (utf-8)
     $text = preg_replace_callback('/&#(3[2-9]|[4-9][0-9]|\\d{3,5});/', array('MessageUtil', 'stripCrapCallback'), $text);
     // remove \r\n
     $text = StringUtil::unifyNewlines($text);
     return $text;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:16,代码来源:MessageUtil.class.php

示例5: onRead

 /**
  * @see	SocketServerClient::onRead()
  */
 public function onRead()
 {
     $string = StringUtil::unifyNewlines($this->readBuffer);
     echo '#~->', strlen($string) > 500 ? substr($string, 0, 500) : $string;
     if (!$this->isValidString($string)) {
         return;
     }
     $lines = ArrayUtil::trim(explode("\n", $string));
     $this->handleRequest($lines);
     $this->read_buffer = '';
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:14,代码来源:WOTAPIServerClient.class.php

示例6: storeQuote

 /**
  * Stores a given quote.
  *
  * @param	integer		$objectID
  * @param	string		$objectType
  * @param	string		$text
  * @param	string		$author
  * @param	string		$url
  * @param	integer		$parentID
  * @param	string		$quoteID
  * @return	string		quote id
  */
 public static function storeQuote($objectID, $objectType, $text, $author = '', $url = '', $parentID = 0, $quoteID = '')
 {
     self::loadStorage();
     if ($quoteID == '') {
         $quoteID = StringUtil::getRandomID();
     }
     self::$quoteStorage[$quoteID] = array('quoteID' => $quoteID, 'objectID' => $objectID, 'objectType' => $objectType, 'author' => $author, 'url' => $url, 'text' => StringUtil::unifyNewlines($text), 'parentID' => $parentID);
     if (!isset(self::$quoteCounts[$objectType . '-' . $objectID])) {
         self::$quoteCounts[$objectType . '-' . $objectID] = 0;
     }
     self::$quoteCounts[$objectType . '-' . $objectID]++;
     return $quoteID;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:25,代码来源:MultiQuoteManager.class.php

示例7: compressCSS

 /**
  * Compresses css code.
  * 
  * @param	string		$string
  * @return	string
  */
 public static function compressCSS($string)
 {
     $string = StringUtil::unifyNewlines($string);
     // remove comments
     $string = preg_replace('!/\\*.*?\\*/\\r?\\n?!s', '', $string);
     // remove tabs
     $string = preg_replace('!\\t+!', '', $string);
     // remove line breaks
     $string = preg_replace('!(?<=\\{|;) *\\n!', '', $string);
     $string = preg_replace('! *\\n(?=})!', '', $string);
     // remove empty lines
     $string = preg_replace('~\\n{2,}~s', "\n", $string);
     return StringUtil::trim($string);
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:20,代码来源:StyleUtil.class.php

示例8: getExcerpt

 /**
  * Returns an excerpt of the message.
  * 
  * @return	string
  */
 public function getExcerpt()
 {
     // pre-format
     $message = StringUtil::trim(StringUtil::unifyNewlines($this->message));
     // find 1st paragraph
     $excerpt = preg_replace('/^(.*?)\\n\\n.*/s', '$1', $message);
     if (StringUtil::length($excerpt) != StringUtil::length($message)) {
         $this->data['hasMoreText'] = 1;
     }
     // format
     require_once WCF_DIR . 'lib/data/message/bbcode/MessageParser.class.php';
     MessageParser::getInstance()->setOutputType('text/html');
     require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php';
     AttachmentBBCode::setMessageID($this->contestID);
     return MessageParser::getInstance()->parse($excerpt, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes);
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:21,代码来源:ViewableContest.class.php

示例9: readParams

 /**
  * Reads the given parameters.
  */
 public function readParams()
 {
     $pollOptionsText = '';
     $this->data['votesNotChangeable'] = $this->data['sortByResult'] = 0;
     if (isset($_POST['pollQuestion'])) {
         $this->data['question'] = StringUtil::trim($_POST['pollQuestion']);
     }
     if (isset($_POST['pollOptions'])) {
         $pollOptionsText = StringUtil::unifyNewlines(StringUtil::trim($_POST['pollOptions']));
     }
     if (isset($_POST['choiceCount'])) {
         $this->data['choiceCount'] = intval($_POST['choiceCount']);
     }
     if (isset($_POST['votesNotChangeable'])) {
         $this->data['votesNotChangeable'] = intval($_POST['votesNotChangeable']);
     }
     if (isset($_POST['sortByResult'])) {
         $this->data['sortByResult'] = intval($_POST['sortByResult']);
     }
     if ($this->canStartPublicPoll) {
         $this->data['isPublic'] = 0;
         if (isset($_POST['isPublic'])) {
             $this->data['isPublic'] = intval($_POST['isPublic']);
         }
     }
     // end time
     if (isset($_POST['endTimeDay'])) {
         $this->endTimeDay = intval($_POST['endTimeDay']);
     }
     if (isset($_POST['endTimeMonth'])) {
         $this->endTimeMonth = intval($_POST['endTimeMonth']);
     }
     if (isset($_POST['endTimeYear'])) {
         $this->endTimeYear = intval($_POST['endTimeYear']);
     }
     if (isset($_POST['endTimeHour'])) {
         $this->endTimeHour = intval($_POST['endTimeHour']);
     }
     if (isset($_POST['endTimeMinutes'])) {
         $this->endTimeMinutes = intval($_POST['endTimeMinutes']);
     }
     $this->pollOptionsArray = array_unique(ArrayUtil::trim(explode("\n", $pollOptionsText)));
     $this->assign();
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:47,代码来源:PollEditor.class.php

示例10: parseMultipleEnableOptions

 /**
  * Returns a list of the enable options.
  * 
  * @param 	string		$enableOptions
  * @return	array
  */
 public static function parseMultipleEnableOptions($enableOptions)
 {
     $result = array();
     if (!empty($enableOptions)) {
         $options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($enableOptions)));
         $key = -1;
         foreach ($options as $option) {
             if (StringUtil::indexOf($option, ':') !== false) {
                 $optionData = explode(':', $option);
                 $key = array_shift($optionData);
                 $value = implode(':', $optionData);
             } else {
                 $key++;
                 $value = $option;
             }
             $result[$key] = $value;
         }
     }
     return $result;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:26,代码来源:OptionUtil.class.php

示例11: __construct

 /**
  * Creates a new PackageUpdateAuthForm object.
  * 
  * @param	PackageUpdateAuthorizationRequiredException	$exception
  */
 public function __construct($exception = null)
 {
     $this->exception = $exception;
     if ($this->exception !== null) {
         $this->packageUpdateServerID = $this->exception->getPackageUpdateServerID();
         $this->url = $this->exception->getURL();
         $this->header = $this->exception->getResponseHeader();
         // get message
         $this->message = $this->exception->getResponseContent();
         // find out response charset
         if (preg_match('/charset=([a-z0-9\\-]+)/i', $this->header, $match)) {
             $charset = strtoupper($match[1]);
             if ($charset != CHARSET) {
                 $this->message = @StringUtil::convertEncoding($charset, CHARSET, $this->message);
             }
         }
         // format message
         $this->message = nl2br(preg_replace("/\n{3,}/", "\n\n", StringUtil::unifyNewlines(StringUtil::trim(strip_tags($this->message)))));
     }
     parent::__construct();
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:26,代码来源:PackageUpdateAuthForm.class.php

示例12: readParameters

 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     // get object id
     if (isset($_REQUEST['objectID'])) {
         $this->objectID = intval($_REQUEST['objectID']);
     }
     // get quote(s)
     if (isset($_REQUEST['text'])) {
         $this->text = $_REQUEST['text'];
     }
     if (is_array($this->text)) {
         $this->text = ArrayUtil::unifyNewlines(ArrayUtil::trim($this->text));
         if (CHARSET != 'UTF-8') {
             $this->text = ArrayUtil::convertEncoding('UTF-8', CHARSET, $this->text);
         }
     } else {
         $this->text = StringUtil::unifyNewlines(StringUtil::trim($this->text));
         if (CHARSET != 'UTF-8') {
             $this->text = StringUtil::convertEncoding('UTF-8', CHARSET, $this->text);
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:26,代码来源:AbstractMessageQuoteAction.class.php

示例13: test

 /**
  * Returns censored words from a text. 
  * 
  * @param	string		$text
  * @return	mixed		$matches / false
  */
 public static function test($text)
 {
     // reset matches
     self::$matches = array();
     // get words which should be censored
     $censoredWords = explode("\n", StringUtil::unifyNewlines(StringUtil::toLowerCase(CENSORED_WORDS)));
     // format censored words
     $censoredWords = ArrayUtil::trim($censoredWords);
     // string to lower case
     $text = StringUtil::toLowerCase($text);
     // ignore bbcode tags
     $text = preg_replace('~\\[/?[a-z]+[^\\]]*\\]~i', '', $text);
     // split the text in single words
     self::$words = preg_split("!" . self::$delimiters . "+!", $text, -1, PREG_SPLIT_NO_EMPTY);
     // check each word if it censored.
     for ($i = 0, $count = count(self::$words); $i < $count; $i++) {
         $word = self::$words[$i];
         foreach ($censoredWords as $censoredWord) {
             // check for direct matches ("badword" == "badword")
             if ($censoredWord == $word) {
                 // store censored word
                 if (isset(self::$matches[$word])) {
                     self::$matches[$word]++;
                 } else {
                     self::$matches[$word] = 1;
                 }
                 continue 2;
             } else {
                 if (StringUtil::indexOf($censoredWord, '*') !== false) {
                     $censoredWord = StringUtil::replace('\\*', '.*', preg_quote($censoredWord));
                     if (preg_match('!^' . $censoredWord . '$!', $word)) {
                         // store censored word
                         if (isset(self::$matches[$word])) {
                             self::$matches[$word]++;
                         } else {
                             self::$matches[$word] = 1;
                         }
                         continue 2;
                     }
                 } else {
                     if (StringUtil::indexOf($censoredWord, '~') !== false) {
                         $censoredWord = StringUtil::replace('~', '', $censoredWord);
                         if (($position = StringUtil::indexOf($censoredWord, $word)) !== false) {
                             if ($position > 0) {
                                 // look behind
                                 if (!self::lookBehind($i - 1, StringUtil::substring($censoredWord, 0, $position))) {
                                     continue;
                                 }
                             }
                             if ($position + StringUtil::length($word) < StringUtil::length($censoredWord)) {
                                 // look ahead
                                 if ($newIndex = self::lookAhead($i + 1, StringUtil::substring($censoredWord, $position + StringUtil::length($word)))) {
                                     $i = $newIndex;
                                 } else {
                                     continue;
                                 }
                             }
                             // store censored word
                             if (isset(self::$matches[$censoredWord])) {
                                 self::$matches[$censoredWord]++;
                             } else {
                                 self::$matches[$censoredWord] = 1;
                             }
                             continue 2;
                         }
                     }
                 }
             }
         }
     }
     // at least one censored word was found
     if (count(self::$matches) > 0) {
         return self::$matches;
     } else {
         return false;
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:83,代码来源:Censorship.class.php

示例14: getPageURLs

 /**
  * Gets the page URLs.
  * 
  * @return	array
  */
 protected static function getPageURLs()
 {
     $urlString = '';
     if (defined('PAGE_URL')) {
         $urlString .= PAGE_URL;
     }
     if (defined('PAGE_URLS')) {
         $urlString .= "\n" . PAGE_URLS;
     }
     $urlString = StringUtil::unifyNewlines($urlString);
     self::$pageURLs = ArrayUtil::trim(explode("\n", $urlString));
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:17,代码来源:SimpleMessageParser.class.php

示例15: unifyNewlines

 /**
  * Converts dos to unix newlines.
  *
  * @param 	array 		$array
  * @return 	array 		$array
  */
 public static function unifyNewlines($array)
 {
     if (!is_array($array)) {
         return StringUtil::unifyNewlines($array);
     } else {
         foreach ($array as $key => $val) {
             $array[$key] = self::unifyNewlines($val);
         }
         return $array;
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:17,代码来源:ArrayUtil.class.php


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