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


PHP x2base::convertLineBreaks方法代码示例

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


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

示例1: convertUrls

	public static function convertUrls($text, $convertLineBreaks = true) {
		$text = preg_replace(
			array(
				'/(?(?=<a[^>]*>.+<\/a>)(?:<a[^>]*>.+<\/a>)|([^="\']?)((?:https?|ftp|bf2|):\/\/[^<> \n\r]+))/iex',
				'/<a([^>]*)target="?[^"\']+"?/i',
				'/<a([^>]+)>/i',
				'/(^|\s|>)(www.[^<> \n\r]+)/iex',
				'/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/iex'
			),
			array(
				"stripslashes((strlen('\\2')>0?'\\1<a href=\"\\2\">\\2</a>\\3':'\\0'))",
				'<a\\1',
				'<a\\1 target="_blank">',
				"stripslashes((strlen('\\2')>0?'\\1<a href=\"http://\\2\">\\2</a>\\3':'\\0'))",
				"stripslashes((strlen('\\2')>0?'<a href=\"mailto:\\0\">\\0</a>':'\\0'))"
			),
			$text
		);
		// $urlRegex = '/(https?|ftp)://[^\s/$.?#].[^\s]*/iSu';
		// $matches = array();
		// preg_match_all($urlRegex, $text, $matches);
		// $usedPatterns = array();
		// foreach($matches as $pattern) {
			// if(!array_key_exists($pattern, $usedPatterns)) {
				// $usedPatterns[$pattern]=true;
				// $text = mb_ereg_replace($pattern, '<a href="$1">$1</a>', $text);
			// }
		// }
		$template="<a href=".Yii::app()->getBaseUrl().'/index.php/search/search?term=%23\\2'."> #\\2</a>";
		$text = mb_ereg_replace('(^|\s)#(\w\w+)',$template,$text);
                $text = mb_ereg_replace('(>)#(\w\w+)',">".$template,$text);
		if($convertLineBreaks)
			return x2base::convertLineBreaks($text,true,false);
		else
			return $text;
	}
开发者ID:ruchida,项目名称:X2Engine,代码行数:36,代码来源:x2base.php

示例2: array

			echo CHtml::link('[x]',array('deletePost','id'=>$data->id,'redirect'=>Yii::app()->controller->action->id)); //,array('class'=>'x2-button') ?>
	</div>
	<?php echo CHtml::link(Yii::t('profile','Reply'),'#',array('onclick'=>"$('#addReply-".$data->id."').toggle();",'class'=>'x2-button float')); ?>

	<?php
	if($authorRecord->id != $data->associationId && $data->associationId != 0) {
		$temp=Profile::model()->findByPk($data->associationId);
		$recipient=$temp->fullName;
		$modifier=' &raquo; ';
	} else {
		$recipient='';
		$modifier='';
	}
	?>
	<?php echo CHtml::link($author,array('profile/view','id'=>$authorRecord->id)).$modifier.CHtml::link($recipient,$data->associationId); ?> <span class="comment-age"><?php echo x2base::timestampAge(date("Y-m-d H:i:s",$data->timestamp)); ?></span><br />
	<?php echo x2base::convertLineBreaks($this->convertUrls($data->data)); ?><br />
	<?php 
	if(count($commentDataProvider->getData())>0){
		$this->widget('zii.widgets.CListView', array(
		'dataProvider'=>$commentDataProvider,
		'itemView'=>'../social/_view',
		'template'=>'{items}'
	));
	}
	
	echo CHtml::beginForm(
		'addComment',
		'get',
		array(
			'style'=>'display:none;',
			'id'=>'addReply-'.$data->id,
开发者ID:ruchida,项目名称:X2Engine,代码行数:31,代码来源:_viewFull.php

示例3: getSignature

 public function getSignature($html = false)
 {
     $adminRule = Yii::app()->params->admin->emailUseSignature;
     $userRule = $this->emailUseSignature;
     $userModel = CActiveRecord::model('User')->findByPk($this->id);
     $signature = '';
     switch ($adminRule) {
         case 'admin':
             $signature = Yii::app()->params->admin->emailSignature;
             break;
         case 'user':
             switch ($userRule) {
                 case 'user':
                     $signature = $signature = $this->emailSignature;
                     break;
                 case 'admin':
                     Yii::app()->params->admin->emailSignature;
                     break;
                 case 'group':
                     $signature == '';
                     break;
                 default:
                     $signature == '';
             }
             break;
         case 'group':
             $signature == '';
             break;
         default:
             $signature == '';
     }
     $signature = preg_replace(array('/\\{first\\}/', '/\\{last\\}/', '/\\{phone\\}/', '/\\{group\\}/', '/\\{email\\}/'), array($userModel->firstName, $userModel->lastName, $this->officePhone, '', $html ? CHtml::mailto($this->emailAddress) : $this->emailAddress), $signature);
     if ($html) {
         $signature = x2base::convertLineBreaks($signature);
     }
     // $signature = '<span style="color:grey;">' . x2base::convertLineBreaks($signature) . '</span>';
     return $signature;
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:38,代码来源:ProfileChild.php

示例4: convertUrls

 public static function convertUrls($text, $convertLineBreaks = true)
 {
     /*$text = preg_replace(
     			array(
     				'/(?(?=<a[^>]*>.+<\/a>)(?:<a[^>]*>.+<\/a>)|([^="\']?)((?:https?|ftp|bf2|):\/\/[^<> \n\r]+))/iex',
     				'/<a([^>]*)target="?[^"\']+"?/i',
     				'/<a([^>]+)>/i',
     				'/(^|\s|>)(www.[^<> \n\r]+)/iex',
     				'/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/iex'
     			),
     			array(
     				"stripslashes((strlen('\\2')>0?'\\1<a href=\"\\2\">\\2</a>\\3':'\\0'))",
     				'<a\\1',
     				'<a\\1 target="_blank">',
     				"stripslashes((strlen('\\2')>0?'\\1<a href=\"http://\\2\">\\2</a>\\3':'\\0'))",
     				"stripslashes((strlen('\\2')>0?'<a href=\"mailto:\\0\">\\0</a>':'\\0'))"
     			),
     			$text
     		);*/
     /* URL matching regex from the interwebs:
      * http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/
      */
     $url_pattern = '/\\b(?:(?:https?|ftp|file):\\/\\/|www\\.|ftp\\.)(?:\\([-A-Z0-9+&@#\\/%=~_|$?!:,.]*\\)|[-A-Z0-9+&@#\\/%=~_|$?!:,.])*(?:\\([-A-Z0-9+&@#\\/%=~_|$?!:,.]*\\)|[A-Z0-9+&@#\\/%=~_|$])/i';
     $email_pattern = '/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/i';
     /* First break the text into two arrays, one containing <a> tags and the like
      * which should not have any replacements, and another with all the text that
      * should have URLs activated.  Each piece of each array has its offset from 
      * original string so we can piece it back together later
      */
     //add any additional tags to be passed over here
     $tags_with_urls = "/(<a[^>]*>.*<\\/a>)|(<img[^>]*>)/i";
     $text_to_add_links = preg_split($tags_with_urls, $text, NULL, PREG_SPLIT_OFFSET_CAPTURE);
     $matches = array();
     preg_match_all($tags_with_urls, $text, $matches, PREG_OFFSET_CAPTURE);
     $text_to_leave = $matches[0];
     // Convert all URLs into html links
     foreach ($text_to_add_links as $i => $value) {
         $text_to_add_links[$i][0] = preg_replace(array($url_pattern, $email_pattern), array("<a href=\"\\0\">\\0</a>", "<a href=\"mailto:\\0\">\\0</a>"), $text_to_add_links[$i][0]);
     }
     // Merge the arrays and sort to be in the original order
     $all_text_chunks = array_merge($text_to_add_links, $text_to_leave);
     usort($all_text_chunks, 'x2base::compareChunks');
     $new_text = "";
     foreach ($all_text_chunks as $chunk) {
         $new_text = $new_text . $chunk[0];
     }
     $text = $new_text;
     // Make sure all links open in new window, and have http:// if missing
     $text = preg_replace(array('/<a([^>]+)target=("[^"]+"|\'[^\']\'|[^\\s]+)([^>]+)/i', '/<a([^>]+)>/i', '/<a([^>]+href="?\'?)(www\\.|ftp\\.)/i'), array('<a\\1\\3', '<a\\1 target="_blank">', '<a\\1http://\\2'), $text);
     //convert any tags into links
     $template = "\\1<a href=" . Yii::app()->getBaseUrl() . '/index.php/search/search?term=%23\\2' . ">#\\2</a>";
     //$text = preg_replace('/(^|[>\s\.])#(\w\w+)($|[<\s\.])/u',$template,$text);
     $text = preg_replace('/(^|[>\\s\\.])#(\\w\\w+)/u', $template, $text);
     if ($convertLineBreaks) {
         return x2base::convertLineBreaks($text, true, false);
     } else {
         return $text;
     }
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:59,代码来源:x2base.php

示例5:

 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 ********************************************************************************/

$authorRecord = Users::model()->findByAttributes(array('username'=>$data->user));
$author = $authorRecord->firstName.' '.$authorRecord->lastName;
?>
<div class="view">
	<div class="deleteButton">
		<?php 
		$parent=Social::model()->findByPk($data->associationId);
		if($data->user==Yii::app()->user->getName() || $parent->associationId==Yii::app()->user->getId())
			echo CHtml::link('[x]',array('deletePost','id'=>$data->id,'redirect'=>Yii::app()->controller->action->id)); //,array('class'=>'x2-button') ?>
	</div>
	<?php echo CHtml::link($author,array('profile/view','id'=>$authorRecord->id)); ?> <span class="comment-age"><?php echo x2base::timestampAge(date("Y-m-d H:i:s",$data->timestamp)); ?></span><br />
	<?php echo x2base::convertLineBreaks($this->convertUrls(CHtml::encode($data->data))); ?>
</div>


<?php /*
<div class="view">
	<div class="deleteButton">
		<?php echo CHtml::link('[x]',array('deleteNote','id'=>$data->id)); //,array('class'=>'x2-button') ?>
		<?php //echo CHtml::link("<img src='".Yii::app()->request->baseUrl."/images/deleteButton.png' />",array("deleteNote","id"=>$data->id)); ?>
	</div>

	<b><?php echo CHtml::encode($data->getAttributeLabel('createdBy')); ?>:</b>
	<?php echo CHtml::encode($data->createdBy); ?>
	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('createDate')); ?>:</b>
开发者ID:ruchida,项目名称:X2Engine,代码行数:31,代码来源:_view.php


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