Ejemplo n.º 1
0
	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;
	}
Ejemplo n.º 2
0
			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,
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 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;
     }
 }
Ejemplo n.º 5
0
 * 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>