File: /home/iestorre/informatica/modules/mod_randomquotes/helper.php
<?php
/**
* @copyright Copyright (C) 2014 OpenSource Technologies Pvt. Ltd. All rights reserved
* * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
class modRandomQuotesHelper
{
public static function renderItem(&$item, &$params)
{
$mainframe = JFactory::getApplication();
$results = $mainframe->triggerEvent('onAfterDisplayTitle', array(&$item, &$params, 1));
//$item->afterDisplayTitle = trim(implode("\n", $results));
$results = $mainframe->triggerEvent('onBeforeDisplayContent', array(&$item, &$params, 1));
//$item->beforeDisplayContent = trim(implode("\n", $results));
require JModuleHelper::getLayoutPath('mod_randomquotes', '_item');
}
public static function getList(&$params, &$access)
{
$randomquotesPath = 'modules/mod_randomquotes/quotes/';
// Name of the randomquotes text file
$randomquotesFile = 'randomquotes.txt';
$GLOBAL['randomquotesPath'] = $randomquotesPath;
$lineSep = "\n";
$quoteFile = fopen(implode('/', array($randomquotesPath, $randomquotesFile)), 'r') or die("Unable to find $randomquotesFile in $randomquotesPath");
while (!feof($quoteFile)) {
$tquote = trim(fgets($quoteFile, 1024));
if (strlen($tquote) > 0) {
$quotes[] = $tquote;
}
}
return $quotes;
}
}