<commit_before><?php
/**
 * @package		HUBzero CMS
 * @author		<NAME> <<EMAIL>>
 * @copyright	Copyright 2005-2009 by Purdue Research Foundation, West Lafayette, IN 47906
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GPLv2
 *
 * Copyright 2005-2009 by Purdue Research Foundation, West Lafayette, IN 47906.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

//-----------

jimport( 'joomla.plugin.plugin' );
JPlugin::loadLanguage( 'plg_mw_questions' );
	
//-----------

class plgMwQuestions extends JPlugin
{
	function plgMwQuestions(&$subject, $config)
	{
		parent::__construct($subject, $config);

		// Load plugin parameters
		$this->_plugin = JPluginHelper::getPlugin( 'mw', 'questions' );
		$this->_params = new JParameter( $this->_plugin->params );
	}
	
	//-----------
	
	function &onMwAreas( $resource ) 
	{
		$areas = array(
			'questions' => JText::_('QUESTIONS')
		);
		return $areas;
	}

	//-----------

	function onMw( $toolname, $option, $authorized, $areas )
	{
		$database =& JFactory::getDBO();

		// Get a needed library
		include_once(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_answers'.DS.'answers.class.php');

		// Get all the questions for this tool
		$a = new mosAnswersQuestion( $database );
		$rows = $a->getQuestionsByTag( 'tool:'.$toolname );

		// Did we get results back?
		if ($rows) {
			ximport('xdocument');
			XDocument::addComponentStylesheet('com_answers');

			// Loop through the results and build the HTML
			$sbjt  = t.t.'<ul class="questions">'.n;
			foreach ($rows as $row) 
			{
				if ($row->anonymous == 0) {
					$xuser =& XUser::getInstance( $row->created_by );
					$name = $xuser->get('name');
				} else {
					$name = JText::_('ANONYMOUS');
				}

				$row->created = $this->mkt($row->created);
				$when = $this->timeAgo($row->created);

				$tags = $this->getTagCloud($row->id);

				$link_on = JRoute::_('index.php?option=com_answers&task=question&id='.$row->id);

				$sbjt .= t.t.t.'<h4><a href="'. $link_on .'">'.$row->subject.'</a></h4>'.n;
				$sbjt .= t.t.t.'<p class="snippet">';
				$sbjt .= $this->shortenText($row->question, 100, 0);
				$sbjt .= '</p>'.n;
				$sbjt .= t.t.t.'<p>'.JText::sprintf('ASKED_BY',$name).' - '.JText::sprintf('TIME_AGO',$when).' - ';
				if ($row->rcount == 1) {
					$sbjt .= JText::sprintf('NUM_RESPONSE',$row->rcount);
				} else {
					$sbjt .= JText::sprintf('NUM_RESPONSES',$row->rcount);
				}
				$sbjt .= '</p>'.n;
				$sbjt .= t.t.t.'<p>Tags:</p> '.$tags.n;
			}
			$sbjt .= t.t.'</ul>'.n;
		} else {
			$sbjt  = t.t.'<p>'.JText::_('NO_QUESTIONS_FOUND').'</p>'.n;
		}<commit_msg>replace xuser reference with xprofile<commit_after><?php
/**
 * @package		HUBzero CMS
 * @author		<NAME> <<EMAIL>>
 * @copyright	Copyright 2005-2009 by Purdue Research Foundation, West Lafayette, IN 47906
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GPLv2
 *
 * Copyright 2005-2009 by Purdue Research Foundation, West Lafayette, IN 47906.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

//-----------

jimport( 'joomla.plugin.plugin' );
JPlugin::loadLanguage( 'plg_mw_questions' );
	
//-----------

class plgMwQuestions extends JPlugin
{
	function plgMwQuestions(&$subject, $config)
	{
		parent::__construct($subject, $config);

		// Load plugin parameters
		$this->_plugin = JPluginHelper::getPlugin( 'mw', 'questions' );
		$this->_params = new JParameter( $this->_plugin->params );
	}
	
	//-----------
	
	function &onMwAreas( $resource ) 
	{
		$areas = array(
			'questions' => JText::_('QUESTIONS')
		);
		return $areas;
	}

	//-----------

	function onMw( $toolname, $option, $authorized, $areas )
	{
		$database =& JFactory::getDBO();

		// Get a needed library
		include_once(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_answers'.DS.'answers.class.php');

		// Get all the questions for this tool
		$a = new mosAnswersQuestion( $database );
		$rows = $a->getQuestionsByTag( 'tool:'.$toolname );

		// Did we get results back?
		if ($rows) {
			ximport('xdocument');
			ximport('xprofile');
			XDocument::addComponentStylesheet('com_answers');

			// Loop through the results and build the HTML
			$sbjt  = t.t.'<ul class="questions">'.n;
			foreach ($rows as $row) 
			{
				if ($row->anonymous == 0) {
					$xprofile =& XProfile::getInstance( $row->created_by );
					$name = $xprofile->get('name');
				} else {
					$name = JText::_('ANONYMOUS');
				}

				$row->created = $this->mkt($row->created);
				$when = $this->timeAgo($row->created);

				$tags = $this->getTagCloud($row->id);

				$link_on = JRoute::_('index.php?option=com_answers&task=question&id='.$row->id);

				$sbjt .= t.t.t.'<h4><a href="'. $link_on .'">'.$row->subject.'</a></h4>'.n;
				$sbjt .= t.t.t.'<p class="snippet">';
				$sbjt .= $this->shortenText($row->question, 100, 0);
				$sbjt .= '</p>'.n;
				$sbjt .= t.t.t.'<p>'.JText::sprintf('ASKED_BY',$name).' - '.JText::sprintf('TIME_AGO',$when).' - ';
				if ($row->rcount == 1) {
					$sbjt .= JText::sprintf('NUM_RESPONSE',$row->rcount);
				} else {
					$sbjt .= JText::sprintf('NUM_RESPONSES',$row->rcount);
				}
				$sbjt .= '</p>'.n;
				$sbjt .= t.t.t.'<p>Tags:</p> '.$tags.n;
			}
			$sbjt .= t.t.'</ul>'.n;
		} else {
			$sbjt  = t.t.'<p>'.JText::_('NO_QUESTIONS_FOUND').'</p>'.n;
		}
{'fraction_non_alphanumeric': 0.18988847583643123, 'fraction_numerical': 0.014572490706319703, 'mean_word_length': 3.3032629558541267, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2939391', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2325, 'n_words': 581}