                                                                                                                                                                                
                                                                                                                                                                                
mediajce.xml                                                                                        0000705                 00000003277 15242077761 0007051 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?xml version="1.0" encoding="utf-8" ?>
<extension type="plugin" version="3.8" group="fields" method="upgrade">
	<name>plg_fields_mediajce</name>
	 <version>2.8.3</version>
  	<creationDate>15-01-2020</creationDate>
  	<author>Ryan Demmer</author>
  	<authorEmail>info@joomlacontenteditor.net</authorEmail>
  	<authorUrl>https://www.joomlacontenteditor.net</authorUrl>
  	<copyright>Copyright (C) 2006 - 2020 Ryan Demmer. All rights reserved</copyright>
  	<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
	<description>PLG_FIELDS_MEDIAJCE_XML_DESCRIPTION</description>
	<files folder="plugins/fields/mediajce">
		<filename plugin="mediajce">mediajce.php</filename>
		<folder>params</folder>
		<folder>tmpl</folder>
	</files>
	<languages folder="administrator/language/en-GB">
		<language tag="en-GB">en-GB.plg_fields_mediajce.ini</language>
		<language tag="en-GB">en-GB.plg_fields_mediajce.sys.ini</language>
	</languages>
	<config>
		<fields name="params">
			<fieldset name="basic">
				<field
					name="mediatype"
					type="combo"
					label="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIATYPE_LABEL"
					description="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIATYPE_DESC"
				>
				<option value="images">images</option>
				<option value="files">files</option>
				</field>
				<field
					name="media_class"
					type="text"
					label="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIA_CLASS_LABEL"
					description="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIA_CLASS_DESC"
				/>
				<field
					name="media_description"
					type="text"
					label="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIA_DESCRIPTION_LABEL"
					description="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIA_DESCRIPTION_DESC"
				/>
			</fieldset>
		</fields>
	</config>
</extension>
                                                                                                                                                                                                                                                                                                                                 mediajce.php                                                                                        0000705                 00000001435 15242077761 0007032 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?php
/**
 * @package     JCE.Plugin
 * @subpackage  Fields.Media_Jce
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @copyright   Copyright (C) 2020 Ryan Demmer. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JLoader::import('components.com_fields.libraries.fieldsplugin', JPATH_ADMINISTRATOR);

JForm::addFieldPath(JPATH_PLUGINS . '/system/jce/fields');

/**
 * Fields MediaJce Plugin
 *
 * @since  2.6.27
 */
class PlgFieldsMediaJce extends FieldsPlugin
{
    public function onCustomFieldsPrepareDom($field, DOMElement $parent, JForm $form)
    {
        $fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
        return $fieldNode;
    }
}
                                                                                                                                                                                                                                   tmpl/mediajce.php                                                                                   0000705                 00000003515 15242077761 0010007 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.MediaJce
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @copyright   Copyright (C) 2020 Ryan Demmer. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;

jimport('joomla.filesystem.path');

if ($field->value == '') {
    return;
}

$data = json_decode($field->value);

if (!$data) {
	$data = (object) array('src' => $field->value, 'alt' => '');
}


$class = (string) $fieldParams->get('media_class', '');
$type = (string) $fieldParams->get('mediatype', 'images');
$text = (string) $fieldParams->get('media_description', '');

if ($class) {
    $class = ' class="' . htmlentities($class, ENT_COMPAT, 'UTF-8', true) . '"';
}

if ($text) {
    $text = htmlentities($text, ENT_COMPAT, 'UTF-8', true);
}

$value = (array) $data->src;
$buffer = '';

$element = '<img src="%s"%s alt="%s" />';

if ($type !== "images") {
    $element = '<a href="%s"%s>%s</a>';
} else {
	$text = $data->alt;
}

foreach ($value as $path) {
    if (!$path) {
        continue;
    }

    // remove some common characters
    $path = preg_replace('#[\+\\\?\#%&<>"\'=\[\]\{\},;@\^\(\)£€$]#', '', $path);

    // trim
    $path = trim($path);

    // check for valid path after clean
    if (!$path) {
        continue;
    }

    // clean path
    $path = JPath::clean($path);

    // create full path
    $fullpath = JPATH_SITE . '/' . trim($path, '/');

    // check path is valid
    if (!is_file($fullpath)) {
        continue;
    }

    // set text as basename if not an image
    if (!$text && $type !== "images") {
        $text = basename($path);
    }

    $buffer .= sprintf($element,
        htmlentities($path, ENT_COMPAT, 'UTF-8', true),
        $class,
        $text
    );
}

echo $buffer;
                                                                                                                                                                                   params/mediajce.xml                                                                                 0000705                 00000001430 15242077761 0010321 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="fieldparams">
			<fieldset name="fieldparams">
				<field
					name="mediatype"
					type="combo"
					label="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIATYPE_LABEL"
					description="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIATYPE_DESC"
				>
				<option value="images">images</option>
				<option value="files">files</option>
				</field>
				<field
					name="media_class"
					type="text"
					label="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIA_CLASS_LABEL"
					description="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIA_CLASS_DESC"
				/>
				<field
					name="media_description"
					type="text"
					label="PLG_FIELDS_MEDIAJCE_PARAMS_MEDIA_DESCRIPT<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at 
 postmaster@entreprises-adaptees.fr to inform them of the time this error occurred,
 and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
