Пример #1
0
 public static function parseBBCode($text)
 {
     $config = Komento::getConfig();
     $nofollow = $config->get('links_nofollow') ? ' rel="nofollow"' : '';
     $maxdimension = '';
     if ($config->get('max_image_width') || $config->get('max_image_height')) {
         $maxdimension = ' style="';
         if ($config->get('max_image_width')) {
             $maxdimension .= 'max-width:' . $config->get('max_image_width') . 'px;';
         }
         if ($config->get('max_image_height')) {
             $maxdimension .= 'max-height:' . $config->get('max_image_width') . 'px;';
         }
         $maxdimension .= '"';
     }
     // Converts all html entities properly
     $text = htmlspecialchars($text, ENT_NOQUOTES);
     $text = trim($text);
     $text = preg_replace_callback('/\\[code( type="(.*?)")?\\](.*?)\\[\\/code\\]/ms', array('KomentoCommentHelper', 'escape'), $text);
     // avoid smileys in pre tag gets replaced
     $text = KomentoCommentHelper::encodePre($text);
     // change new line to br (without affecting pre)
     $text = nl2br($text);
     // BBCode to find...
     $in = array('/\\[b\\](.*?)\\[\\/b\\]/ms', '/\\[i\\](.*?)\\[\\/i\\]/ms', '/\\[u\\](.*?)\\[\\/u\\]/ms', '/\\[img\\](.*?)\\[\\/img\\]/ms', '/\\[email\\](.*?)\\[\\/email\\]/ms', '/\\[size\\="?(.*?)"?\\](.*?)\\[\\/size\\]/ms', '/\\[color\\="?(.*?)"?\\](.*?)\\[\\/color\\]/ms', '/\\[quote\\](.*?)\\[\\/quote\\]/ms');
     // And replace them by...
     $out = array('<strong>\\1</strong>', '<em>\\1</em>', '<u>\\1</u>', '<img src="\\1" alt="\\1"' . $maxdimension . ' />', '<a target="_blank" href="mailto:\\1"' . $nofollow . '>\\1</a>', '<span style="font-size:\\1%">\\2</span>', '<span style="color:\\1">\\2</span>', '<blockquote>\\1</blockquote>');
     // strip out bbcode data first
     $tmp = preg_replace($in, '', $text);
     // strip out bbcode url data
     $urlin = '/\\[url\\="?(.*?)"?\\](.*?)\\[\\/url\\]/ms';
     $tmp = preg_replace($urlin, '', $tmp);
     // strip out video links too
     $tmp = Komento::getHelper('videos')->strip($tmp);
     // replace url
     if ($config->get('auto_hyperlink')) {
         $text = self::replaceURL($tmp, $text);
     }
     // replace video links
     if ($config->get('allow_video')) {
         $text = Komento::getHelper('Videos')->replace($text);
     } else {
         $text = Komento::getHelper('Videos')->strip($text);
     }
     // replace bbcode with html
     $text = preg_replace($in, $out, $text);
     // Replace url bbcode with html
     $text = self::replaceBBUrl($text);
     // manual fix for unwrapped li issue
     $text = self::replaceBBList($text);
     $smileyin = array();
     $smileyout = array();
     if ($config->get('bbcode_smile')) {
         $smileyin[] = ':)';
         $smileyout[] = '<img alt=":)" style="width:16px; height:16px;" class="kmt-emoticon" src="' . KOMENTO_EMOTICONS_DIR . 'emoticon-smile.png" />';
     }
     if ($config->get('bbcode_happy')) {
         $smileyin[] = ':D';
         $smileyout[] = '<img alt=":D" style="width:16px; height:16px;" class="kmt-emoticon" src="' . KOMENTO_EMOTICONS_DIR . 'emoticon-happy.png" />';
     }
     if ($config->get('bbcode_surprised')) {
         $smileyin[] = ':o';
         $smileyout[] = '<img alt=":o" style="width:16px; height:16px;" class="kmt-emoticon" src="' . KOMENTO_EMOTICONS_DIR . 'emoticon-surprised.png" />';
     }
     if ($config->get('bbcode_tongue')) {
         $smileyin[] = ':p';
         $smileyout[] = '<img alt=":p" style="width:16px; height:16px;" class="kmt-emoticon" src="' . KOMENTO_EMOTICONS_DIR . 'emoticon-tongue.png" />';
     }
     if ($config->get('bbcode_unhappy')) {
         $smileyin[] = ':(';
         $smileyout[] = '<img alt=":(" style="width:16px; height:16px;" class="kmt-emoticon" src="' . KOMENTO_EMOTICONS_DIR . 'emoticon-unhappy.png" />';
     }
     if ($config->get('bbcode_wink')) {
         $smileyin[] = ';)';
         $smileyout[] = '<img alt=";)" style="width:16px; height:16px;" class="kmt-emoticon" src="' . KOMENTO_EMOTICONS_DIR . 'emoticon-wink.png" />';
     }
     // add in custom smileys
     $smileycode = $config->get('smileycode');
     $smileypath = $config->get('smileypath');
     if (is_array($smileycode) && is_array($smileypath)) {
         foreach ($smileycode as $index => $code) {
             if (!empty($code) && !empty($smileypath[$index])) {
                 $smileyin[] = $code;
                 $smileyout[] = '<img alt="' . $code . '" class="kmt-emoticon" src="' . $smileypath[$index] . '" />';
             }
         }
     }
     $text = str_replace($smileyin, $smileyout, $text);
     // done parsing emoticons and bbcode, decode pre text back
     $text = KomentoCommentHelper::decodePre($text);
     // paragraphs
     $text = str_replace("\r", "", $text);
     $text = "<p>" . preg_replace("/(\n){2,}/", "</p><p>", $text) . "</p>";
     // $text = preg_replace_callback('/<pre>(.*?)<\/pre>/ms', "removeBr", $text);
     // $text = preg_replace('/<p><pre(.*)>(.*?)<\/pre><\/p>/ms', "<pre\\1>\\2</pre>", $text);
     $text = preg_replace_callback('/<ul>(.*?)<\\/ul>/ms', array('KomentoCommentHelper', 'removeBr'), $text);
     // fix [list] within [*] causing dom errors
     $text = preg_replace('/<li>(.*?)<ul>(.*?)<\\/ul>(.*?)<\\/li>/ms', "\\1<ul>\\2</ul>\\3", $text);
     $text = preg_replace('/<p><ul>(.*?)<\\/ul><\\/p>/ms', "<ul>\\1</ul>", $text);
     return $text;
 }
Пример #2
0
 public static function getComment($id = 0, $process = 0, $admin = 0)
 {
     static $commentsObj = array();
     if (empty($commentsObj[$id])) {
         $comment = new KomentoComment($id);
         if ($comment->getError()) {
             return false;
         }
         $commentsObj[$id] = $comment;
     }
     if ($process) {
         self::import('helper', 'comment');
         $commentsObj[$id] = KomentoCommentHelper::process($commentsObj[$id], $admin);
     }
     return $commentsObj[$id];
 }
Пример #3
0
			} else {
				echo $row->created;
			} ?>
		</li>

		<!-- Permalink -->
		<li class="kmt-permalink"><a href="<?php echo Komento::loadApplication( $row->component )->load( $row->cid )->getContentPermalink() . '#kmt-' . $row->id; ?>"><?php echo JText::_( 'COM_KOMENTO_COMMENT_PERMALINK' ) ; ?></a></li>

		<!-- Status -->
		<li class="kmt-status"><?php echo $row->published ? JText::_( 'COM_KOMENTO_PUBLISHED' ) : JText::_( 'COM_KOMENTO_UNPUBLISHED' );?></li>
	</ul>

	<div class="kmt-body">

		<?php // parseBBcode to HTML
			$row->comment = KomentoCommentHelper::parseBBCode($row->comment);
			$row->comment = nl2br($row->comment);
		?>
		<span class="kmt-text"><?php echo $row->comment; ?></span>

	</div>
</td>

<!-- Action -->
<td>
	<ul class="kmt-action">
		<?php if( $system->my->allow( 'publish_all_comment', $row->component ) || ( $row->created_by == $system->my->id && $system->my->allow( 'publish_own_comment', $row->component ) ) ) { ?>
		<li><a href="javascript:void(0);" class="kmt-publish"><?php echo JText::_( 'COM_KOMENTO_PUBLISH' ); ?></a></li>
		<?php } ?>

		<?php if( $system->my->allow( 'delete_all_comment', $row->component ) || ( $row->created_by == $system->my->id && $system->my->allow( 'delete_own_comment', $row->component ) ) ) { ?>
Пример #4
0
 * Komento is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

defined( '_JEXEC' ) or die( 'Restricted access' ); ?>

<?php // KURO THEME

Komento::trigger( 'onBeforeProcessComment', array( 'component' => $row->component, 'cid' => $row->cid, 'comment' => &$row ) );

// Process data
Komento::import( 'helper', 'comment' );
$row = KomentoCommentHelper::process( $row );

Komento::trigger( 'onAfterProcessComment', array( 'component' => $row->component, 'cid' => $row->cid, 'comment' => &$row ) );

// Construct classes for this row
$classes = array();

$classes[] = 'kmt-item';

// Usergroup CSS classes
if( $row->author->guest )
{
	$classes[] = $system->config->get( 'layout_css_public' );
}
else
{
Пример #5
0
	function editComment()
	{
		$now		= Komento::getDate()->toMySQL();
		$profile	= Komento::getProfile();
		$config		= Komento::getConfig();

		$id = JRequest::getVar( 'id' );
		$edittedComment = JRequest::getVar( 'edittedComment', '', 'post', '', JREQUEST_ALLOWRAW );

		// use table instead of commentclass to avoid sending mail
		$commentObj = Komento::getTable( 'comments' );
		$commentObj->load( $id );

		$ajax = Komento::getAjax();
		$acl = Komento::getHelper( 'Acl' );

		if( $acl->allow( 'edit', $commentObj ) )
		{
			// Length check
			if( trim( $edittedComment ) == '' )
			{
				$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_REQUIRED' ) );
				$ajax->send();
			}
			if( $config->get( 'antispam_min_length_enable' ) && JString::strlen( $edittedComment ) < $config->get( 'antispam_min_length' ) )
			{
				$ajax->fail( '<p>' . JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_SHORT' ) . '. ' . JText::sprintf( 'COM_KOMENTO_FORM_CHARACTER_MIN', $config->get( 'antispam_min_length' ) ) . '.</p>' );
				$ajax->send();
			}
			if( $config->get( 'antispam_max_length_enable' ) && JString::strlen( $edittedComment ) > $config->get( 'antispam_max_length' ) )
			{
				$ajax->fail( '<p>' . JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_LONG' ) . '. ' . JText::sprintf( 'COM_KOMENTO_FORM_CHARACTER_MAX', $config->get( 'antispam_max_length' ) ) . '.</p>' );
				$ajax->send();
			}

			$commentObj->comment = $edittedComment;
			$commentObj->modified_by = $profile->id;
			$commentObj->modified = $now;

			$result = 1;
			if( !$commentObj->store() )
			{
				$result = 0;
			}

			$comment = KomentoCommentHelper::parseComment( $commentObj->comment );

			if( $result )
			{
				// success(parsed comment, modified date/time, by )
				$ajax->success( $comment, $commentObj->modified, $profile->name );
			}
			else
			{
				$errors = JText::_( 'COM_KOMENTO_ERROR' );

				if( $commentObj->getErrors() )
				{
					$errors = implode( '\n', $commentObj->getErrors() );
				}

				$ajax->fail( $errors );
			}
		}
		else
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ACL_NO_PERMISSION' ) );
		}

		$ajax->send();
	}