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


PHP StringUtil::unifyNewlines方法代码示例

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


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

示例1: getAliases

 /**
  * Returns all aliases for this smiley.
  * 
  * @return	array<string>
  */
 public function getAliases()
 {
     if (!$this->aliases) {
         return array();
     }
     return explode("\n", StringUtil::unifyNewlines($this->aliases));
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:12,代码来源:Smiley.class.php

示例2: cleanup

 /**
  * Cleans up newlines and converts input to lower-case.
  * 
  * @param	string		$newValue
  * @return	string
  */
 protected function cleanup($newValue)
 {
     $newValue = StringUtil::unifyNewlines($newValue);
     $newValue = trim($newValue);
     $newValue = preg_replace('~\\n+~', "\n", $newValue);
     $newValue = mb_strtolower($newValue);
     return $newValue;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:14,代码来源:UrlControllerReplacementOptionType.class.php

示例3: __construct

	/**
	 * Creates a new instance of memcached.
	 */
	public function __construct() {
		if (!class_exists('Memcached')) {
			throw new SystemException('memcached support is not enabled.');
		}
		
		// init memcached
		$this->memcached = new \Memcached();
		
		// add servers
		$tmp = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHED_HOST));
		$servers = array();
		$defaultWeight = floor(100 / count($tmp));
		$regex = new Regex('^\[([a-z0-9\:\.]+)\](?::([0-9]{1,5}))?(?::([0-9]{1,3}))?$', Regex::CASE_INSENSITIVE);
		
		foreach ($tmp as $server) {
			$server = StringUtil::trim($server);
			if (!empty($server)) {
				$host = $server;
				$port = 11211; // default memcached port
				$weight = $defaultWeight;
				
				// check for IPv6
				if ($regex->match($host)) {
					$matches = $regex->getMatches();
					$host = $matches[1];
					if (isset($matches[2])) {
						$port = $matches[2];
					}
					if (isset($matches[3])) {
						$weight = $matches[3];
					}
				}
				else {
					// IPv4, try to get port and weight
					if (strpos($host, ':')) {
						$parsedHost = explode(':', $host);
						$host = $parsedHost[0];
						$port = $parsedHost[1];
						
						if (isset($parsedHost[2])) {
							$weight = $parsedHost[2];
						}
					}
				}
				
				$servers[] = array($host, $port, $weight);
			}
		}
		
		$this->memcached->addServers($servers);
		
		// test connection
		$this->memcached->get('testing');
		
		// set variable prefix to prevent collision
		$this->prefix = substr(sha1(WCF_DIR), 0, 8) . '_';
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:60,代码来源:MemcachedCacheSource.class.php

示例4: matches

 /**
  * Checks whether this question matches the given message.
  * 
  * @param string $message
  * @return boolean
  */
 public function matches($message)
 {
     $lines = explode("\n", \wcf\util\StringUtil::unifyNewlines($this->questionMessage));
     foreach ($lines as $line) {
         if (\wcf\system\Regex::compile($line)->match($message)) {
             return true;
         }
     }
     return false;
 }
开发者ID:cfHxqA,项目名称:com.github.cfHxqA.wbb.post.butler,代码行数:16,代码来源:Question.class.php

示例5: 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:0xLeon,项目名称:WCF,代码行数:20,代码来源:StyleUtil.class.php

示例6: init

 /**
  * @see	\wcf\system\SingletonFactory::init()
  */
 protected function init()
 {
     $this->titleRegex = new Regex('[\\x0-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7F]+');
     if (defined('URL_TITLE_COMPONENT_REPLACEMENT') && URL_TITLE_COMPONENT_REPLACEMENT) {
         $replacements = explode("\n", StringUtil::unifyNewlines(StringUtil::trim(URL_TITLE_COMPONENT_REPLACEMENT)));
         foreach ($replacements as $replacement) {
             if (strpos($replacement, '=') === false) {
                 continue;
             }
             $components = explode('=', $replacement);
             $this->titleSearch[] = $components[0];
             $this->titleReplace[] = $components[1];
         }
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:18,代码来源:LinkHandler.class.php

示例7: getOutput

 /**
  * Returns the html for this provider.
  * 
  * @param	string		$url
  * @return	string
  */
 public function getOutput($url)
 {
     $lines = explode("\n", StringUtil::unifyNewlines($this->regex));
     foreach ($lines as $line) {
         $regex = new Regex($line);
         if (!$regex->match($url)) {
             continue;
         }
         $output = $this->html;
         foreach ($regex->getMatches() as $name => $value) {
             $output = str_replace('{$' . $name . '}', $value, $output);
         }
         return $output;
     }
     return '';
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:22,代码来源:BBCodeMediaProvider.class.php

示例8: compare

 /**
  * @see	\wcf\system\option\IOptionType::compare()
  */
 public function compare($value1, $value2)
 {
     $value1 = explode("\n", StringUtil::unifyNewlines($value1));
     $value2 = explode("\n", StringUtil::unifyNewlines($value2));
     // check if value1 contains more elements than value2
     $diff = array_diff($value1, $value2);
     if (!empty($diff)) {
         return 1;
     }
     // check if value1 contains less elements than value2
     $diff = array_diff($value2, $value1);
     if (!empty($diff)) {
         return -1;
     }
     // both lists are equal
     return 0;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:20,代码来源:TextareaOptionType.class.php

示例9: isAnswer

 /**
  * Returns true if the given user input is an answer to this question.
  * 
  * @param	string		$answer
  * @return	boolean
  */
 public function isAnswer($answer)
 {
     $answers = explode("\n", StringUtil::unifyNewlines(WCF::getLanguage()->get($this->answers)));
     foreach ($answers as $__answer) {
         if (mb_substr($__answer, 0, 1) == '~' && mb_substr($__answer, -1, 1) == '~') {
             if (Regex::compile(mb_substr($__answer, 1, mb_strlen($__answer) - 2))->match($answer)) {
                 return true;
             }
             continue;
         } else {
             if ($__answer == $answer) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:23,代码来源:CaptchaQuestion.class.php

示例10: 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, security tokens and access tokens
     $text = Regex::compile('(?<=\\?|&)([st]=[a-f0-9]{40}|at=\\d+-[a-f0-9]{40})')->replace($text, '');
     // convert html entities (utf-8)
     $text = Regex::compile('&#(3[2-9]|[4-9][0-9]|\\d{3,5});')->replace($text, new Callback(function ($matches) {
         return StringUtil::getCharacter(intval($matches[1]));
     }));
     // unify new lines
     $text = StringUtil::unifyNewlines($text);
     // remove 4 byte utf-8 characters as MySQL < 5.5 does not support them
     // see http://stackoverflow.com/a/16902461/782822
     $text = preg_replace('/[\\xF0-\\xF7].../s', '', $text);
     // remove control characters
     $text = preg_replace('~[\\x00-\\x08\\x0B-\\x1F\\x7F]~', '', $text);
     return $text;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:23,代码来源:MessageUtil.class.php

示例11: validate

 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate fields
     if (empty($this->title)) {
         throw new UserInputException('title');
     }
     if (empty($this->regex)) {
         throw new UserInputException('regex');
     }
     if (empty($this->html)) {
         throw new UserInputException('html');
     }
     $lines = explode("\n", StringUtil::unifyNewlines($this->regex));
     foreach ($lines as $line) {
         if (!Regex::compile($line)->isValid()) {
             throw new UserInputException('regex', 'notValid');
         }
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:23,代码来源:BBCodeMediaProviderAddForm.class.php

示例12: init

 /**
  * @see	\wcf\system\SingletonFactory::init()
  */
 protected function init()
 {
     // get words which should be censored
     $censoredWords = explode("\n", StringUtil::unifyNewlines(mb_strtolower(CENSORED_WORDS)));
     // format censored words
     for ($i = 0, $length = count($censoredWords); $i < $length; $i++) {
         $censoredWord = StringUtil::trim($censoredWords[$i]);
         if (empty($censoredWord)) {
             continue;
         }
         $displayedCensoredWord = str_replace(array('~', '*'), '', $censoredWord);
         // check if censored word contains at least one delimiter
         if (preg_match('!' . $this->delimiters . '+!', $displayedCensoredWord)) {
             // remove delimiters
             $censoredWord = preg_replace('!' . $this->delimiters . '!', '', $censoredWord);
             // enforce partial matching
             $censoredWord = '~' . $censoredWord;
         }
         $this->censoredWords[$displayedCensoredWord] = $censoredWord;
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:24,代码来源:Censorship.class.php

示例13: compile

 /**
  * Compiles LESS stylesheets.
  * 
  * @param	\wcf\data\style\Style	$style
  */
 public function compile(Style $style)
 {
     // read stylesheets by dependency order
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("filename REGEXP ?", array('style/([a-zA-Z0-9\\_\\-\\.]+)\\.less'));
     $sql = "SELECT\t\tfilename, application\n\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tpackageID";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $files = array();
     while ($row = $statement->fetchArray()) {
         $files[] = Application::getDirectory($row['application']) . $row['filename'];
     }
     // get style variables
     $variables = $style->getVariables();
     $individualLess = '';
     if (isset($variables['individualLess'])) {
         $individualLess = $variables['individualLess'];
         unset($variables['individualLess']);
     }
     // add style image path
     $imagePath = '../images/';
     if ($style->imagePath) {
         $imagePath = FileUtil::getRelativePath(WCF_DIR . 'style/', WCF_DIR . $style->imagePath);
         $imagePath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator($imagePath));
     }
     $variables['style_image_path'] = "'{$imagePath}'";
     // apply overrides
     if (isset($variables['overrideLess'])) {
         $lines = explode("\n", StringUtil::unifyNewlines($variables['overrideLess']));
         foreach ($lines as $line) {
             if (preg_match('~^@([a-zA-Z]+): ?([@a-zA-Z0-9 ,\\.\\(\\)\\%\\#-]+);$~', $line, $matches)) {
                 $variables[$matches[1]] = $matches[2];
             }
         }
         unset($variables['overrideLess']);
     }
     $this->compileStylesheet(WCF_DIR . 'style/style-' . $style->styleID, $files, $variables, $individualLess, new Callback(function ($content) use($style) {
         return "/* stylesheet for '" . $style->styleName . "', generated on " . gmdate('r') . " -- DO NOT EDIT */\n\n" . $content;
     }));
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:45,代码来源:StyleCompiler.class.php

示例14: import

 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // copy smiley
     $data['smileyPath'] = 'images/smilies/' . basename($additionalData['fileLocation']);
     if (!@copy($additionalData['fileLocation'], WCF_DIR . $data['smileyPath'])) {
         return 0;
     }
     // check smileycode
     if (isset($this->knownCodes[mb_strtolower($data['smileyCode'])])) {
         return $this->knownCodes[mb_strtolower($data['smileyCode'])];
     }
     $data['packageID'] = 1;
     if (!isset($data['aliases'])) {
         $data['aliases'] = '';
     }
     // check aliases
     $aliases = array();
     if (!empty($data['aliases'])) {
         $aliases = explode("\n", StringUtil::unifyNewlines($data['aliases']));
         foreach ($aliases as $key => $alias) {
             if (isset($this->knownCodes[mb_strtolower($alias)])) {
                 unset($aliases[$key]);
             }
         }
         $data['aliases'] = implode("\n", $aliases);
     }
     // get category id
     if (!empty($data['categoryID'])) {
         $data['categoryID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.smiley.category', $data['categoryID']);
     }
     // save smiley
     $smiley = SmileyEditor::create($data);
     // add smileyCode + aliases to knownCodes
     $this->knownCodes[mb_strtolower($data['smileyCode'])] = $smiley->smileyID;
     foreach ($aliases as $alias) {
         $this->knownCodes[mb_strtolower($alias)] = $smiley->smileyID;
     }
     return $smiley->smileyID;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:42,代码来源:SmileyImporter.class.php

示例15: assignVariables

 public function assignVariables()
 {
     parent::assignVariables();
     if (WCF::getSession()->getPermission('user.cms.news.canStartPoll') && MODULE_POLL) {
         PollManager::getInstance()->assignVariables();
     }
     if ($this->imageID && $this->imageID != 0) {
         $this->image = FileCache::getInstance()->getFile($this->imageID);
     }
     WCF::getTPL()->assign(array('categoryList' => $this->categoryList, 'categoryIDs' => $this->categoryIDs, 'imageID' => $this->imageID, 'image' => $this->image, 'teaser' => $this->teaser, 'time' => $this->time, 'action' => $this->action, 'tags' => $this->tags, 'allowedFileExtensions' => explode("\n", StringUtil::unifyNewlines(WCF::getSession()->getPermission('user.cms.news.allowedAttachmentExtensions')))));
 }
开发者ID:jacboy,项目名称:Fireball_News,代码行数:11,代码来源:NewsAddForm.class.php


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