Ejemplo n.º 1
0
 public function getAjaxTemplate()
 {
     $files = JRequest::getVar('names', '');
     if (empty($files)) {
         return false;
     }
     // Ensure the integrity of each items submitted to be an array.
     if (!is_array($files)) {
         $files = array($files);
     }
     $result = array();
     foreach ($files as $file) {
         $template = Komento::getTheme();
         $out = $template->fetch($file . '.ejs');
         $obj = new stdClass();
         $obj->name = $file;
         $obj->content = $out;
         $result[] = $obj;
     }
     Komento::getClass('json', 'KomentoJson');
     header('Content-type: text/x-json; UTF-8');
     $json = new KomentoJson();
     echo $json->encode($result);
     exit;
 }
Ejemplo n.º 2
0
	public static function loadForm( $id, $component, $options = array() )
	{
		$theme	= Komento::getTheme();
		$html	= $theme->fetch( 'comment/form.php' );

		echo $html;
	}
Ejemplo n.º 3
0
	function display($tmpl = null)
	{
		$mainframe = JFactory::getApplication();
		$commentsModel = Komento::getModel( 'comments' );

		$cid = JRequest::getVar( 'cid', 'all' );

		$filter['component']	= $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_component', 'filter-component', 'all', 'string' );
		$filter['sort']			= $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_sort', 'filter-sort', 'latest', 'string' );
		$filter['search']		= trim( JString::strtolower( $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_search', 'filter-search', '', 'string' ) ) );

		$options = array(
			'limit'		=> 0,
			'sort'		=> $filter['sort'],
			'search'	=> $filter['search'],
			'published'	=> 2,
			'threaded'	=> 0
		);

		$comments = $commentsModel->getComments( $filter['component'], $cid, $options );
		$pagination = $commentsModel->getPagination();
		$components = $commentsModel->getUniqueComponents();

		$theme = Komento::getTheme();
		$theme->set( 'components', $components );
		$theme->set( 'pagination', $pagination );
		$theme->set( 'comments', $comments );
		$theme->set( 'filter', $filter );

		echo $theme->fetch('dashboard/pending.php');
	}
Ejemplo n.º 4
0
 public function getResource()
 {
     $resources = JRequest::getVar('resource');
     $component = JRequest::getCmd('kmtcomponent');
     Komento::setCurrentComponent($component);
     if (!is_array($resources)) {
         header('Content-type: text/x-json; UTF-8');
         echo '[]';
         exit;
     }
     foreach ($resources as &$resource) {
         $resource = (object) $resource;
         switch ($resource->type) {
             case 'language':
                 $resource->content = JText::_(strtoupper($resource->name));
                 break;
             case 'view':
                 $template = Komento::getTheme();
                 $out = $template->fetch($resource->name . '.ejs');
                 if ($out !== false) {
                     $resource->content = $out;
                 }
                 break;
         }
     }
     Komento::getClass('json', 'KomentoJson');
     header('Content-type: text/x-json; UTF-8');
     $json = new KomentoJson();
     echo $json->encode($resources);
     exit;
 }
Ejemplo n.º 5
0
	public function getHTML()
	{
		$captcha			= Komento::getTable( 'Captcha', 'KomentoTable' );
		$captcha->created	= Komento::getDate()->toMySQL();
		$captcha->store();

		$theme		= Komento::getTheme();
		$theme->set( 'id' , $captcha->id );
		$theme->set( 'url', $this->getCaptchaUrl( $captcha->id ) );
		return $theme->fetch( 'comment/captcha.php' );
	}
Ejemplo n.º 6
0
 public function display($tpl = null)
 {
     $konfig = Komento::getKonfig();
     $id = JRequest::getInt('id', 0);
     // @task: If profiles are disabled, do not show the profile here.
     if (!$konfig->get('profile_enable')) {
         $app = JFactory::getApplication();
         $app->redirect('index.php', JText::_('COM_KOMENTO_PROFILE_SYSTEM_DISABLED'));
         $app->close();
     }
     $profileModel = Komento::getModel('Profile');
     $activityModel = Komento::getModel('Activity');
     $commentsModel = Komento::getModel('Comments');
     $actionsModel = Komento::getModel('Actions');
     $count = new stdClass();
     $user = JFactory::getUser();
     if ($id === 0 && $user->id > 0) {
         $id = $user->id;
     }
     // Block non-exists profile
     if (!$profileModel->exists($id)) {
         echo JText::_('COM_KOMENTO_PROFILE_NOT_FOUND');
         return;
     }
     // TODO: Block custom profile id
     // ..
     $profile = Komento::getProfile($id);
     // $activities		= $activityModel->getUserActivities( $profile->id );
     $count->totalComments = $commentsModel->getTotalComment($profile->id);
     $count->likesReceived = $actionsModel->getLikesReceived($profile->id);
     $count->likesGiven = $actionsModel->getLikesGiven($profile->id);
     // Set Pathway
     // Check if Komento profile menu item exist before setting profile pathway
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $item = $menu->getActive();
     if (empty($item) || $item->query['view'] != 'profile') {
         $this->setPathway(JText::_('COM_KOMENTO_PROFILE'), '');
     }
     $this->setPathway($profile->getName(), '');
     // Set browser title
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_KOMENTO_USER_PROFILE') . ' - ' . $profile->getName());
     // set component to com_komento
     Komento::setCurrentComponent('com_komento');
     $theme = Komento::getTheme();
     $theme->set('profile', $profile);
     $theme->set('count', $count);
     // $theme->set( 'activities', $activities );
     echo $theme->fetch('profile/profile.php');
 }
Ejemplo n.º 7
0
 public function getView($name)
 {
     // Due to compatibility, we had to append komento/ infront of the views, but we do not want this when fetching template
     if (strpos('komento/', $name) >= 0) {
         $name = substr($name, 8);
     }
     $template = Komento::getTheme();
     $out = $template->fetch($name . '.ejs');
     $contents = '';
     if ($out !== false) {
         $contents = $out;
     }
     return $contents;
 }
Ejemplo n.º 8
0
 public function getHTML()
 {
     $template = Komento::getTheme();
     $config = Komento::getConfig();
     $publicKey = $config->get('antispam_recaptcha_public_key');
     $language = $config->get('antispam_recaptcha_lang', 'en');
     $theme = $config->get('antispam_recaptcha_theme', 'clean');
     $server = $config->get('antispam_recaptcha_ssl') ? self::RECAPTCHA_API_SECURE_SERVER : self::RECAPTCHA_API_SERVER;
     $template->set('server', $server);
     $template->set('publicKey', $publicKey);
     $template->set('language', $language);
     $template->set('theme', $theme);
     // Use AJAX method to prevent operation aborted problems with IE
     return $template->fetch('comment/recaptcha.php');
 }
Ejemplo n.º 9
0
	function display($tmpl = null)
	{
		$mainframe = JFactory::getApplication();
		$commentsModel = Komento::getModel( 'comments' );

		$cid = JRequest::getVar( 'cid', 'all' );

		$filter['component']	= $mainframe->getUserStateFromRequest( 'com_komento.reports.filter_component', 'filter-component', 'all', 'string' );
		$filter['sort']			= $mainframe->getUserStateFromRequest( 'com_komento.reports.filter_sort', 'filter-sort', 'latest', 'string' );
		$filter['search']		= trim( JString::strtolower( $mainframe->getUserStateFromRequest( 'com_komento.reports.filter_search', 'filter-search', '', 'string' ) ) );

		$options = array(
			'limit'		=> 0,
			'sort'		=> $filter['sort'],
			'search'	=> $filter['search'],
			'published'	=> 'all',
			'threaded'	=> 0
		);

		$comments		= $commentsModel->getComments( $filter['component'], $cid, $options );
		$pagination 	= $commentsModel->getPagination();
		$result			= $commentsModel->getUniqueComponents();
		$components 	= array();

		// @task: Let's replace it with a proper text.
		foreach( $result as $item )
		{
			$components[ $item ]	= Komento::loadApplication( $item )->getComponentName();
		}

		$theme = Komento::getTheme();
		$theme->set( 'components', $components );
		$theme->set( 'pagination', $pagination );
		$theme->set( 'comments', $comments );
		$theme->set( 'filter', $filter );

		echo $theme->fetch( 'dashboard/flags.php' );
	}
Ejemplo n.º 10
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');
if ($system->config->get('enable_reply_reference') && $row->parent_id != 0) {
    ?>
<span class="inReplyTo kmt-inreplyto">
	<?php 
    if ($system->config->get('enable_threaded')) {
        $name = '';
        $parent = Komento::getComment($row->parent_id, true);
        echo JText::sprintf('COM_KOMENTO_COMMENT_IN_REPLY_TO_NAME', $row->parentlink, $parent->name);
        // echo JText::sprintf( 'COM_KOMENTO_COMMENT_IN_REPLY_TO_NAME', $row->parentlink, $parent->name );
    } else {
        // non threaded no need to show name, because will have parent comment as a popup when hover over comment id
        echo JText::sprintf('COM_KOMENTO_COMMENT_IN_REPLY_TO', $row->parentlink, $row->parent_id);
        // echo JText::sprintf( 'COM_KOMENTO_COMMENT_IN_REPLY_TO', $row->parentlink, $row->parent_id );
    }
    $parent = '';
    if ($system->konfig->get('parent_preload')) {
        $parent = Komento::getComment($row->parent_id);
    }
    $parentTheme = Komento::getTheme(true);
    $parentTheme->set('parent', $parent);
    echo $parentTheme->fetch('comment/item/parent.php');
    ?>
</span>
<?php 
}
Ejemplo n.º 11
0
 /**
  * This is the heart of Komento that does magic
  *
  * @param	$component	string
  * @param	$article	object
  * @param	$options	array
  * @return null
  */
 public static function commentify($component, &$article, $options = array())
 {
     $eventTrigger = null;
     $context = null;
     $params = array();
     $page = 0;
     if (array_key_exists('trigger', $options)) {
         $eventTrigger = $options['trigger'];
     }
     if (array_key_exists('context', $options)) {
         $context = $options['context'];
     }
     if (array_key_exists('params', $options)) {
         $params = $options['params'];
     }
     if (array_key_exists('page', $options)) {
         $page = $options['page'];
     }
     // TODO: Allow string/int: see line 662
     // Sometimes people pass in $article as an array, we convert it to object
     if (is_array($article)) {
         $article = (object) $article;
     }
     // Check if there is a valid component
     if (empty($component)) {
         return false;
     }
     // @task: prepare data and checking on plugin level
     $application = Komento::loadApplication($component);
     // We verify context and trigger first before going into onBeforeLoad because onBeforeLoad already expects the article to be what Komento want to integrate
     // @task: verify if context is correct
     if (!Komento::verifyContext($context, $application->getContext())) {
         return false;
     }
     // @task: verify if event trigger is correct
     if (!Komento::verifyEventTrigger($eventTrigger, $application->getEventTrigger())) {
         return false;
     }
     // @trigger: onBeforeLoad
     // we do this checking before load because in some cases,
     // article is not an object and the article id might be missing.
     if (!$application->onBeforeLoad($eventTrigger, $context, $article, $params, $page, $options)) {
         return false;
     }
     // @task: set the component
     self::setCurrentComponent($component);
     // @task: get all the configuration
     $config = self::getConfig($component);
     $konfig = Komento::getKonfig();
     // @task: check if enabled
     if (!$config->get('enable_komento')) {
         return false;
     }
     // @task: disable Komento in tmpl=component mode such as print mode
     if ($config->get('disable_komento_on_tmpl_component') && JRequest::getString('tmpl', '') === 'component') {
         return false;
     }
     // We accept $article as an int
     // For $article as a string, onBeforeLoad should already prepare the $article object properly
     if (is_string($article) || is_int($article)) {
         $cid = $article;
     } else {
         // @task: set cid based on application mapping keys because some component might have custom keys (not necessarily always $article-id)
         $cid = $article->{$application->_map['id']};
     }
     // Don't proceed if $cid is empty
     if (empty($cid)) {
         return false;
     }
     // @task: process in-content parameters
     self::processParameter($article, $options);
     // terminate if it's disabled
     if ($options['disable']) {
         if (!$application->onParameterDisabled($eventTrigger, $context, $article, $params, $page, $options)) {
             return false;
         }
     }
     // @task: loading article infomation with defined get methods
     if (!$application->load($cid)) {
         return false;
     }
     // If enabled flag exists, bypass category check
     if (array_key_exists('enable', $options) && !$options['enable']) {
         // @task: category access check
         $categories = $config->get('allowed_categories');
         // no categories mode
         switch ($config->get('allowed_categories_mode')) {
             // selected categories
             case 1:
                 if (empty($categories)) {
                     return false;
                 } else {
                     // @task: For some reason $article->catid might not be set. If it it's not set, just return false.
                     $catid = $application->getCategoryId();
                     if (!$catid) {
                         if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) {
                             // raise error
                         }
                         return false;
                     }
                     if (!is_array($categories)) {
                         $categories = explode(',', $categories);
                     }
                     if (!in_array($catid, $categories)) {
                         if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) {
                             // raise error
                         }
                         return false;
                     }
                 }
                 break;
                 // except selected categories
             // except selected categories
             case 2:
                 if (!empty($categories)) {
                     // @task: For some reason $article->catid might not be set. If it it's not set, just return false.
                     $catid = $application->getCategoryId();
                     if (!$catid) {
                         if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) {
                             // raise error
                         }
                         return false;
                     }
                     if (!is_array($categories)) {
                         $categories = explode(',', $categories);
                     }
                     if (in_array($catid, $categories)) {
                         if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) {
                             // raise error
                         }
                         return false;
                     }
                 }
                 break;
                 // no categories
             // no categories
             case 3:
                 return false;
                 break;
                 // all categories
             // all categories
             case 0:
             default:
                 break;
         }
     }
     // @trigger: onAfterLoad
     // Now the article with id has been loaded.
     if (!$application->onAfterLoad($eventTrigger, $context, $article, $params, $page, $options)) {
         return false;
     }
     // @task: send mail on page load
     if ($config->get('notification_sendmailonpageload')) {
         self::getMailQueue()->sendOnPageLoad();
     }
     // @task: clear captcha database
     if ($konfig->get('database_clearcaptchaonpageload')) {
         self::clearCaptcha();
     }
     // @task: load necessary css and javascript files.
     self::getHelper('Document')->loadHeaders();
     /**********************************************/
     // Run Komento!
     $commentsModel = Komento::getModel('comments');
     $comments = '';
     $return = false;
     $commentCount = $commentsModel->getCount($component, $cid);
     // Get total ratings
     $ratings = $commentsModel->getOverallRatings($component, $cid);
     $totalRating = 0;
     $totalRatingCount = 0;
     if ($ratings) {
         $totalRating = $ratings->value;
         $totalRatingCount = $ratings->total;
     }
     if ($application->isListingView()) {
         $html = '';
         if (!array_key_exists('skipBar', $options)) {
             $commentOptions = array();
             $commentOptions['threaded'] = 0;
             $commentOptions['limit'] = $config->get('preview_count', '3');
             $commentOptions['sort'] = $config->get('preview_sort', 'latest');
             $commentOptions['parentid'] = $config->get('preview_parent_only', false) ? 0 : 'all';
             $commentOptions['sticked'] = $config->get('preview_sticked_only', false) ? true : 'all';
             if ($commentOptions['sort'] == 'popular') {
                 $comments = $commentsModel->getPopularComments($component, $cid, $commentOptions);
             } else {
                 $comments = $commentsModel->getComments($component, $cid, $commentOptions);
             }
             $theme = Komento::getTheme();
             $theme->set('commentCount', $commentCount);
             $theme->set('componentHelper', $application);
             $theme->set('component', $component);
             $theme->set('cid', $cid);
             $theme->set('comments', $comments);
             $theme->set('article', $article);
             $html = $theme->fetch('comment/bar.php');
         }
         $return = $application->onExecute($article, $html, 'listing', $options);
     }
     if ($application->isEntryView()) {
         // check for escaped_fragment (google ajax crawler)
         $fragment = JRequest::getVar('_escaped_fragment_', '');
         if ($fragment != '') {
             $tmp = explode('=', $fragment);
             $fragment = array($tmp[0] => $tmp[1]);
             if (isset($fragment['kmt-start'])) {
                 $options['limitstart'] = $fragment['kmt-start'];
             }
         } else {
             // Sort comments oldest first by default.
             if (!isset($options['sort'])) {
                 $options['sort'] = JRequest::getVar('kmt-sort', $config->get('default_sort'));
             }
             if ($config->get('load_previous')) {
                 $options['limitstart'] = $commentCount - $config->get('max_comments_per_page');
                 if ($options['limitstart'] < 0) {
                     $options['limitstart'] = 0;
                 }
             }
         }
         $options['threaded'] = $config->get('enable_threaded');
         $profile = Komento::getProfile();
         $my = JFactory::getUser();
         if (!$profile->allow('read_others_comment')) {
             $options['userid'] = $my->id;
         }
         if ($profile->allow('read_comment')) {
             $comments = $commentsModel->getComments($component, $cid, $options);
         }
         $contentLink = $application->getContentPermalink();
         $theme = Komento::getTheme();
         $theme->set('totalRating', $totalRating);
         $theme->set('totalRatingCount', $totalRatingCount);
         $theme->set('component', $component);
         $theme->set('cid', $cid);
         $theme->set('comments', $comments);
         $theme->set('options', $options);
         $theme->set('componentHelper', $application);
         $theme->set('application', $application);
         $theme->set('commentCount', $commentCount);
         $theme->set('contentLink', $contentLink);
         $html = $theme->fetch('comment/box.php');
         /* [KOMENTO_POWERED_BY_LINK] */
         // free version powered by link append (for reference only)
         // $html	.= '<div style="text-align: center; padding: 20px 0;"><a href="http://stackideas.com">' . JText::_( 'COM_KOMENTO_POWERED_BY_KOMENTO' ) . '</a></div>';
         $return = $application->onExecute($article, $html, 'entry', $options);
         // @task: Append hidden token into the page.
         $return .= '<span id="komento-token" style="display:none;"><input type="hidden" name="' . Komento::_('getToken') . '" value="1" /></span>';
     }
     return $return;
 }
Ejemplo n.º 12
0
	public function getTemplateBuffer( $template, $data, $params = array() )
	{
		$theme	= Komento::getTheme();

		foreach( $data as $key => $val )
		{
			$theme->set( $key , $val );
		}

		$document = JFactory::getDocument();

		$theme->set( 'data', $data );
		$theme->set( 'options', $params );
		$theme->set( 'document', $document );

		$contents	= $theme->fetch( $template );

		return $contents;
	}
Ejemplo n.º 13
0
	public function getResourcesSettings()
	{
		$config 	= Komento::getConfig();

		// Build a deterministic cache
		$settings = array(
							"language"	=> JFactory::getLanguage()->getTag(),
							"template"	=> array(
													"site"   => $config->get( 'layout_theme' )
											),
							"view"		=> array(),
							"modified"	=> filemtime($this->resourceManifestFile)
							);

		// Get manifest
		$manifest = $this->getResourcesManifest();

		if(isset($manifest[0]->view) && $manifest[0]->view)
		{
			foreach ($manifest[0]->view as $view)
			{
				$theme 		= Komento::getTheme();
				$path 		= $theme->resolve( $view . '.ejs' );

				// If the file still does not exist, we'll skip this
				if (!JFile::exists($path))
				{
					continue;
				}

				$settings["view"][] = array(
					"path"     => str_ireplace(JPATH_ROOT, '', $path),
					"modified" => filemtime($path)
				);
			}
		}

		// Build hash
		$settings["id"] = md5(serialize($settings));

		return $settings;
	}
Ejemplo n.º 14
0
	public function getSubscribeContent()
	{
		$component = JRequest::getCmd( 'component' );
		$cid = JRequest::getCmd( 'cid' );

		$user = Komento::getProfile();

		$subscribed = null;

		if( !$user->guest )
		{
			$subscriptionModel = Komento::getModel( 'subscription' );
			$subscribed = $subscriptionModel->checkSubscriptionExist( $component, $cid, $user->id );
		}

		$html = '';

		$theme = Komento::getTheme();
		$theme->set( 'my', $user );
		$theme->set( 'subscribed', $subscribed );

		$html = $theme->fetch( 'dialogs/subscribe.email.php' );

		$ajax = Komento::getAjax();

		$ajax->success( $html );
		$ajax->send();
	}
Ejemplo n.º 15
0
	function getStickedComments()
	{
		$loadMore = JRequest::getInt( 'loadMore', 0 );

		$ajax = Komento::getAjax();
		$model = Komento::getModel( 'comments' );

		$uid = JRequest::getInt( 'uid' );
		$start = JRequest::getInt( 'start', 0 );
		$limit = JRequest::getInt( 'limit', 10 );

		$options = array(
			'limitstart'	=> $start,
			'limit'			=> $limit,
			'userid'		=> $uid,
			'sticked'		=> 1,
			'threaded'		=> 0,
			'sort'			=> 'latest'
			);

		$comments = $model->getComments( 'all', 'all', $options );
		$total = '';

		if( !$loadMore )
		{
			$total = $model->getCount( 'all', 'all', $options );
		}

		$count = count( $comments );

		$theme = Komento::getTheme();
		$theme->set( 'items', $comments );
		$theme->set( 'total', $total );
		$html = '';

		if( $loadMore )
		{
			$html = $theme->fetch( 'profile/sticked/list.php' );
		}
		else
		{
			$html = $theme->fetch( 'profile/sticked.php' );
		}

		$ajax->success( $html, $count, $total);
		$ajax->send();
	}