예제 #1
0
	public function toFormat( $format='%Y-%m-%d %H:%M:%S' )
	{
		if( Komento::joomlaVersion() >= '3.0' )
		{
			if( JString::stristr( $format, '%' ) !== false )
			{
				Komento::import( 'helper', 'date' );
				$format = KomentoDateHelper::strftimeToDate( $format );
			}

			return $this->date->format( $format, true );
		}
		else
		{
			// There is no way to have cross version working, except for detecting % in the format
			if( JString::stristr( $format , '%' ) === false )
			{
				if( Komento::isJoomla15() )
				{
					// forced fallback for Joomla 15 if format doesn't have %
					$format = '%c';
				}
				else
				{
					return $this->date->format( $format , true );
				}

			}

			return $this->date->toFormat( $format, true );
		}
	}
예제 #2
0
 function display($tpl = null)
 {
     //initialise variables
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     $components = array();
     $result = Komento::getHelper('components')->getAvailableComponents();
     if (Komento::joomlaVersion() >= '1.6') {
         if (!$user->authorise('komento.manage.comments', 'com_komento')) {
             $mainframe->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             $mainframe->close();
         }
     }
     //Load pane behavior
     jimport('joomla.html.pane');
     $commentId = JRequest::getVar('commentid', '');
     $comment = Komento::getTable('Comments');
     $comment->load($commentId);
     $this->comment = $comment;
     // Set default values for new entries.
     if (empty($comment->created)) {
         Komento::import('helper', 'date');
         $date = KomentoDateHelper::getDate();
         $now = KomentoDateHelper::toFormat($date);
         $comment->created = $now;
         $comment->published = true;
     }
     // Set all non published comments to unpublished
     if ($comment->published != 1) {
         $comment->published = 0;
     }
     // @task: Translate each component with human readable name.
     foreach ($result as $item) {
         $components[] = JHTML::_('select.option', $item, Komento::loadApplication($item)->getComponentName());
     }
     $this->assignRef('comment', $comment);
     $this->assignRef('components', $components);
     parent::display($tpl);
 }
예제 #3
0
 /**
  * Process comments data
  **/
 public static function process($row, $admin = 0)
 {
     if (isset($row->processed) && $row->processed) {
         return $row;
     }
     Komento::setCurrentComponent($row->component);
     $config = Komento::getConfig();
     $konfig = Komento::getKonfig();
     $user = JFactory::getUser()->id;
     $commentsModel = Komento::getModel('comments');
     Komento::import('helper', 'date');
     // Duplicate created date first before lapsed time messing up the original date
     $row->unformattedDate = $row->created;
     // get number of child for each comment
     $row->childs = $commentsModel->getTotalChilds($row->id);
     // set url to proper url
     if (!empty($row->url)) {
         // Add 'http://' if not present
         $row->url = 0 === strpos($row->url, 'http') ? $row->url : 'http://' . $row->url;
     }
     // 1. Load article and article details
     $application = Komento::loadApplication($row->component)->load($row->cid);
     if ($application === false) {
         $application = Komento::getErrorApplication($row->component, $row->cid);
     }
     // set component title
     $row->componenttitle = $application->getComponentName();
     // set content title
     $row->contenttitle = $application->getContentTitle();
     // get permalink
     $row->pagelink = $application->getContentPermalink();
     $row->permalink = $row->pagelink . '#kmt-' . $row->id;
     // set parentlink
     if ($row->parent_id != 0) {
         $row->parentlink = $row->pagelink . '#kmt-' . $row->parent_id;
     }
     // to be reassign
     $row->shortlink = $row->permalink;
     // set extension object
     // use this to check if application is able to load article details
     // if row->extension is false, means error loading article details
     $row->extension = $application;
     if ($admin == 0) {
         // frontend
         $actionsModel = Komento::getModel('actions');
         $socialHelper = Komento::getHelper('social');
         // parse comments HTML
         $row->comment = self::parseComment($row->comment);
         // author's object
         $row->author = Komento::getProfile($row->created_by);
         // don't convert for guest
         if ($row->created_by != 0 && $row->created_by != $row->author->id) {
             if ($config->get('enable_orphanitem_convert')) {
                 KomentoCommentHelper::convertOrphanitem($row->id);
             }
         }
         if ($row->created_by != 0) {
             switch ($config->get('name_type')) {
                 case 'username':
                     // force username
                     $row->name = $row->author->getUsername();
                     break;
                 case 'name':
                     $row->name = $row->author->getName();
                     break;
                 case 'default':
                 default:
                     // default name to profile if name is null
                     if (empty($row->name)) {
                         $row->name = $row->author->getName();
                     }
                     break;
             }
         } else {
             if (empty($row->name)) {
                 $row->name = JText::_('COM_KOMENTO_GUEST');
             } else {
                 if ($config->get('guest_label')) {
                     $row->name = JText::_('COM_KOMENTO_GUEST') . ' - ' . $row->name;
                 }
             }
         }
         // set datetime
         if ($config->get('enable_lapsed_time')) {
             $row->created = KomentoDateHelper::getLapsedTime($row->unformattedDate);
         } else {
             $dateformat = $config->get('date_format');
             $row->created = KomentoDateHelper::toFormat(KomentoDateHelper::dateWithOffSet($row->created), $dateformat);
             // $row->created = Komento::getDate( $row->created )->toFormat( $dateformat );
         }
         // get actions likes
         $row->likes = $actionsModel->countAction('likes', $row->id);
         // get user liked
         $row->liked = $actionsModel->liked($row->id, $user);
         // get user reported
         $row->reported = $actionsModel->reported($row->id, $user);
     } else {
         // backend
         // format comments
         $row->comment = nl2br(Komento::getHelper('comment')->parseBBCode($row->comment));
         $row->created = KomentoDateHelper::dateWithOffSet($row->created);
     }
     $row->processed = true;
     return $row;
 }
예제 #4
0
 * 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');
?>

<div class="kmt-profile-info">
	<h3 class="kmt-profile-name reset-h"><?php 
echo $profile->getName();
?>
</h3>
	<div class="kmt-profile-account float-wrapper">
		<span><?php 
echo JText::_('COM_KOMENTO_MEMBER_SINCE');
?>
 <?php 
echo KomentoDateHelper::getLapsedTime($profile->registerDate);
?>
</span>
		<span><?php 
echo JText::_('COM_KOMENTO_LAST_LOGIN');
?>
 <?php 
echo KomentoDateHelper::getLapsedTime($profile->lastvisitDate);
?>
</span>
	</div>
</div>
예제 #5
0
	private function prepareData( $type = 'new', $options )
	{
		Komento::import( 'helper', 'date' );

		$data							= array();

		if( $type === 'confirm' )
		{
			$subscribeTable = Komento::getTable( 'subscription' );
			$subscribeTable->load( $options['subscribeId'] );

			$profile = Komento::getProfile( $subscribeTable->userid );
		}
		else
		{
			$profile	= Komento::getProfile( $options['comment']->created_by );

			$data['contentTitle']			= $options['comment']->contenttitle;
			$data['contentPermalink']		= $options['comment']->pagelink;
			$data['commentAuthorName']		= $options['comment']->name;
			$data['commentAuthorAvatar']	= $profile->getAvatar();
		}

		$config 					= Komento::getConfig();

		switch( $type )
		{
			case 'confirm':
				$data['confirmLink']	= rtrim( JURI::root() , '/' ) . '/index.php?option=com_komento&task=confirmSubscription&id=' . $options['subscribeId'];
				break;
			case 'pending':
			case 'moderate':
				$hashkeys = Komento::getTable( 'hashkeys' );
				$hashkeys->uid = $options['comment']->id;
				$hashkeys->type = 'comment';
				$hashkeys->store();
				$key = $hashkeys->key;

				$data['approveLink']	= rtrim( JURI::root() , '/' ) . '/index.php?option=com_komento&task=approveComment&token=' . $key;
				$data['commentContent']	= JFilterOutput::cleanText($options['comment']->comment);
				$date					= KomentoDateHelper::dateWithOffSet( $options['comment']->unformattedDate );
				$date					= KomentoDateHelper::toFormat( $date , $config->get( 'date_format' , '%A, %B %e, %Y' ) );
				$data['commentDate']	= $date;
				break;
			case 'report':
				$action = Komento::getTable( 'actions' );
				$action->load( $options['actionId'] );
				$actionUser = $action->action_by;

				$data['actionUser']			= Komento::getProfile( $actionUser );
				$data['commentPermalink']	= $data['contentPermalink'] . '#kmt-' . $options['comment']->id;
				$data['commentContent']		= JFilterOutput::cleanText($options['comment']->comment);
				$date						= KomentoDateHelper::dateWithOffSet( $options['comment']->unformattedDate );
				$date						= KomentoDateHelper::toFormat( $date , $config->get( 'date_format' , '%A, %B %e, %Y' ) );
				$data['commentDate']		= $date;
				break;
			case 'reply':
			case 'comment':
			case 'new':
			default:
				$data['commentPermalink']	= $data['contentPermalink'] . '#kmt-' . $options['comment']->id;
				$data['commentContent']		= JFilterOutput::cleanText($options['comment']->comment);
				$date						= KomentoDateHelper::dateWithOffSet( $options['comment']->unformattedDate );
				$date						= KomentoDateHelper::toFormat( $date , $config->get( 'date_format' , '%A, %B %e, %Y' ) );
				$data['commentDate']		= $date;
				$data['unsubscribe'] 		= rtrim( JURI::root(), '/' ) . '/index.php?option=com_komento&task=unsubscribe&id=';
				break;
		}

		return $data;
	}
예제 #6
0
		<li class="kmt-author">
			<?php if( !Komento::getProfile( $row->created_by )->guest ) { ?>
				<a href="<?php echo Komento::getProfile( $row->created_by )->getProfileLink(); ?>">
			<?php }

				echo Komento::getProfile( $row->created_by )->getName();

				if( !Komento::getProfile( $row->created_by )->guest) { ?>
				</a>
			<?php } ?>
		</li>

		<!-- Time -->
		<li class="kmt-date">
			<?php if( $system->config->get( 'enable_lapsed_time') ) {
				echo KomentoDateHelper::getLapsedTime( $row->created );
			} 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
예제 #7
0
<?php
/**
 * @package		Komento
 * @copyright	Copyright (C) 2012 Stack Ideas Private Limited. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 *
 * 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');
?>

<div class="kmt-profile-info">
	<h1 class="kmt-profile-name reset-h"><?php echo $profile->getName(); ?></h1>
	<div class="kmt-profile-account float-wrapper">
		<span><?php echo JText::_('COM_KOMENTO_MEMBER_SINCE'); ?> <?php echo KomentoDateHelper::getLapsedTime($profile->registerDate); ?></span>
		<span><?php echo JText::_('COM_KOMENTO_LAST_LOGIN'); ?> <?php echo KomentoDateHelper::getLapsedTime($profile->lastvisitDate); ?></span>
	</div>
</div>
예제 #8
0
	public static function getOffSet( $numberOnly	= false )
	{
		if(Komento::joomlaVersion() >= '1.6')
		{
			//return a timezone object
			return KomentoDateHelper::getOffSet16($numberOnly);
		}

		$mainframe	= JFactory::getApplication();
		$user		= JFactory::getUser();
		$config		= Komento::getConfig();

		$userTZ		= '';
		$dstOffset	= $config->get('main_dstoffset', 0);


		if($user->id != 0)
		{
			$userTZ	= $user->getParam('timezone') + $dstOffset;
		}

		//if user did not set timezone, we use joomla one.
		if(empty($userTZ))
		{
			$userTZ	= $mainframe->getCfg('offset') + $dstOffset;
		}

		return $userTZ;
	}
예제 #9
0
	public function formatDate( $format , $dateString )
	{
		$date	= KomentoDateHelper::dateWithOffSet($dateString);
		return $date->toFormat( $format );
	}