CoreFiles by mySites.guru
actionlogsphp55.php68 lines, 1,909 bytes, from Joomla_3.9.2-rc-Release_Candidate-Full_Package.zip
Raw History Compare with 3.9.1-rc
md5
1b9bc4532d3859a7f3481d34b73100f6
sha1
1ef4e22ff97ad658680979bd9b1104007f8c9db7
sha256
c4b37990094459636c239aff84a55ff034f97e2a54ef11848119d261b29a91bd
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_actionlogs
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Date\Date;
use Joomla\CMS\Language\Text;

/**
 * Actionlogs component helper for newer PHP versions.
 *
 * This file should only be included in environments running PHP 5.5 or newer and may potentially cause a parse error on older versions.
 *
 * @since       3.9.0
 * @deprecated  Will be inlined back into ActionlogsHelper when PHP 5.5 or newer is the minimum supported PHP version
 * @internal
 */
class ActionlogsHelperPhp55
{
	/**
	 * Method to convert logs objects array to a Generator for use with a CSV export
	 *
	 * @param   array|Traversable  $data  The logs data objects to be exported
	 *
	 * @return  Generator
	 *
	 * @since   3.9.0
	 * @throws  InvalidArgumentException
	 */
	public static function getCsvAsGenerator($data)
	{
		if (!is_iterable($data))
		{
			throw new InvalidArgumentException(
				sprintf(
					'%s() requires an array or object implementing the Traversable interface, a %s was given.',
					__METHOD__,
					gettype($data) === 'object' ? get_class($data) : gettype($data)
				)
			);
		}

		// Header row
		yield array('Id', 'Message', 'Date', 'Extension', 'User', 'Ip');

		foreach ($data as $log)
		{
			$extension = strtok($log->extension, '.');

			ActionlogsHelper::loadTranslationFiles($extension);

			yield array(
				'id'         => $log->id,
				'message'    => strip_tags(ActionlogsHelper::getHumanReadableLogMessage($log, false)),
				'date'       => (new Date($log->log_date, new DateTimeZone('UTC')))->format('Y-m-d H:i:s T'),
				'extension'  => Text::_($extension),
				'name'       => $log->name,
				'ip_address' => Text::_($log->ip_address),
			);
		}
	}
}

The same content is in 12 releases, Joomla 3.9.2-rc to 3.9.7-rc. See them all, or every version of this file.