Skip to content

Commit

Permalink
Merge branch '2.0.0' into 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamed committed Aug 20, 2021
2 parents 26b1b40 + f0303c7 commit 89e862a
Show file tree
Hide file tree
Showing 16 changed files with 798 additions and 236 deletions.
40 changes: 40 additions & 0 deletions plugins/system/helixultimate/assets/css/frontend-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -602,3 +602,43 @@ body.contentpane.joomla4.layout-modal .js-stools-field-list + .js-stools-field-l
text-indent: 0;
content: '×';
}

/* Media Manager */
.subhead {
position: sticky;
top: 0;
right: 0;
left: 0;
z-index: 1000;
width: auto;
min-height: 43px;
padding: 10px 0;
color: #495057;
background: white;
box-shadow: -3px -2px 22px #ddd;
}

.subhead.noshadow {
box-shadow: none;
}

.subhead .btn {
/* --subhead-btn-accent: #495057; */
padding: 0 1rem;
margin: 5px 0;
font-size: 1rem;
line-height: 2.45rem;
color: #495057;
background: white;
border-color: #adb5bd;
}

.subhead joomla-toolbar-button, .subhead .btn-group {
-webkit-margin-start: 0.75rem;
margin-inline-start: 0.75rem;
}

.subhead joomla-toolbar-button:first-child, .subhead .btn-group:first-child {
-webkit-margin-start: 0;
margin-inline-start: 0;
}
263 changes: 125 additions & 138 deletions plugins/system/helixultimate/html/layouts/form/field/media.php
Original file line number Diff line number Diff line change
@@ -1,85 +1,84 @@
<?php
/**
* @package Joomla.Site
* @package Joomla.Admin
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;
defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\MediaHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;

extract($displayData);

// Load the modal behavior script.
JHtml::_('behavior.modal');

// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'media/mediafield-mootools.min.js', array('version' => 'auto', 'relative' => true, 'framework' => true));

// Tooltip for INPUT showing whole image path
$options = array(
'onShow' => 'jMediaRefreshImgpathTip',
);

JHtml::_('behavior.tooltip', '.hasTipImgpath', $options);

if (!empty($class))
{
$class .= ' form-control hasTipImgpath';
}
else
{
$class = 'form-control hasTipImgpath';
}
/**
* Layout variables
* -----------------
* @var string $asset The asset text
* @var string $authorField The label text
* @var integer $authorId The author id
* @var string $class The class text
* @var boolean $disabled True if field is disabled
* @var string $folder The folder text
* @var string $id The label text
* @var string $link The link text
* @var string $name The name text
* @var string $preview The preview image relative path
* @var integer $previewHeight The image preview height
* @var integer $previewWidth The image preview width
* @var string $onchange The onchange text
* @var boolean $readonly True if field is readonly
* @var integer $size The size text
* @var string $value The value text
* @var string $src The path and filename of the image
* @var array $mediaTypes The supported media types for the Media Manager
* @var array $imagesExt The supported extensions for images
* @var array $audiosExt The supported extensions for audios
* @var array $videosExt The supported extensions for videos
* @var array $documentsExt The supported extensions for documents
* @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*
*/

$attr = '';

$attr .= ' title="' . htmlspecialchars('<span id="TipImgpath"></span>', ENT_COMPAT, 'UTF-8') . '"';

// Initialize some field attributes.
$attr .= !empty($class) ? ' class="input-small field-media-input ' . $class . '"' : ' class="input-small"';
$attr .= !empty($class) ? ' class="form-control field-media-input ' . $class . '"' : ' class="form-control field-media-input"';
$attr .= !empty($size) ? ' size="' . $size . '"' : '';
$attr .= $dataAttribute;

// Initialize JavaScript field attributes.
$attr .= !empty($onchange) ? ' onchange="' . $onchange . '"' : '';

// The text field.
echo '<div class="input-group">';

// The Preview.
$showPreview = true;
$showAsTooltip = false;

switch ($preview)
{
switch ($preview) {
case 'no': // Deprecated parameter value
case 'false':
case 'none':
$showPreview = false;
break;

case 'yes': // Deprecated parameter value
case 'true':
case 'show':
break;
case 'tooltip':
default:
$showAsTooltip = true;
$options = array(
'onShow' => 'jMediaRefreshPreviewTip',
);
JHtml::_('behavior.tooltip', '.hasTipPreview', $options);
$showPreview = true;
break;
}

// Pre fill the contents of the popover
if ($showPreview)
{
if ($value && file_exists(JPATH_ROOT . '/' . $value))
$cleanValue = MediaHelper::getCleanMediaFieldValue($value);

if ($cleanValue && file_exists(JPATH_ROOT . '/' . $cleanValue))
{
$src = Uri::root() . $value;
}
Expand All @@ -100,104 +99,92 @@
'style' => $style,
);

$img = JHtml::_('image', $src, JText::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr);
$previewImg = '<div id="' . $id . '_preview_img"' . ($src ? '' : ' style="display:none"') . '>' . $img . '</div>';
$previewImgEmpty = '<div id="' . $id . '_preview_empty"' . ($src ? ' style="display:none"' : '') . '>'
. JText::_('JLIB_FORM_MEDIA_PREVIEW_EMPTY') . '</div>';
$img = HTMLHelper::_('image', $src, Text::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr);

if ($showAsTooltip)
{
echo '<div class="media-preview input-group-text">';
$tooltip = $previewImgEmpty . $previewImg;
$options = array(
'title' => JText::_('JLIB_FORM_MEDIA_PREVIEW_SELECTED_IMAGE'),
'text' => '<span class="icon-eye" aria-hidden="true"></span>',
'class' => 'input-group-text hasTipPreview'
);

echo JHtml::_('tooltip', $tooltip, $options);
echo '</div>';
}
else
{
echo '<div class="media-preview input-group-text" style="height:auto">';
echo ' ' . $previewImgEmpty;
echo ' ' . $previewImg;
echo '</div>';
}
}
$previewImg = '<div id="' . $id . '_preview_img">' . $img . '</div>';
$previewImgEmpty = '<div id="' . $id . '_preview_empty"' . ($src ? ' class="hidden"' : '') . '>'
. Text::_('JLIB_FORM_MEDIA_PREVIEW_EMPTY') . '</div>';

echo ' <input type="text" name="' . $name . '" id="' . $id . '" value="'
. htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" readonly="readonly"' . $attr . ' data-basepath="'
. Uri::root() . '"/>';
$showPreview = 'static';
}

?>
// The url for the modal
$url = ($readonly ? ''
: ($link ?: 'index.php?option=com_media&view=media&tmpl=component&mediatypes=' . $mediaTypes
. '&asset=' . $asset . '&author=' . $authorId)
. '&fieldid={field-media-id}&path=' . $folder);

// Correctly route the url to ensure it's correctly using sef modes and subfolders
$url = Route::_($url);
$doc = Factory::getDocument();
$wam = $doc->getWebAssetManager();

$wam->useScript('webcomponent.media-select');

Text::script('JFIELD_MEDIA_LAZY_LABEL');
Text::script('JFIELD_MEDIA_ALT_LABEL');
Text::script('JFIELD_MEDIA_ALT_CHECK_LABEL');
Text::script('JFIELD_MEDIA_ALT_CHECK_DESC_LABEL');
Text::script('JFIELD_MEDIA_CLASS_LABEL');
Text::script('JFIELD_MEDIA_FIGURE_CLASS_LABEL');
Text::script('JFIELD_MEDIA_FIGURE_CAPTION_LABEL');
Text::script('JFIELD_MEDIA_LAZY_LABEL');
Text::script('JFIELD_MEDIA_SUMMARY_LABEL');
Text::script('JFIELD_MEDIA_EMBED_CHECK_DESC_LABEL');
Text::script('JFIELD_MEDIA_DOWNLOAD_CHECK_DESC_LABEL');
Text::script('JFIELD_MEDIA_DOWNLOAD_CHECK_LABEL');
Text::script('JFIELD_MEDIA_EMBED_CHECK_LABEL');
Text::script('JFIELD_MEDIA_WIDTH_LABEL');
Text::script('JFIELD_MEDIA_TITLE_LABEL');
Text::script('JFIELD_MEDIA_HEIGHT_LABEL');
Text::script('JFIELD_MEDIA_UNSUPPORTED');
Text::script('JFIELD_MEDIA_DOWNLOAD_FILE');
Text::script('JLIB_APPLICATION_ERROR_SERVER');
Text::script('JLIB_FORM_MEDIA_PREVIEW_EMPTY', true);

$modalHTML = HTMLHelper::_(
'bootstrap.renderModal',
'imageModal_' . $id,
[
'url' => $url,
'title' => Text::_('JLIB_FORM_CHANGE_IMAGE'),
'closeButton' => true,
'height' => '100%',
'width' => '100%',
'modalWidth' => '80',
'bodyHeight' => '60',
'footer' => '<button type="button" class="btn btn-success button-save-selected">' . Text::_('JSELECT') . '</button>'
. '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('JCANCEL') . '</button>',
]
);

<?php
$modalLink = '';
$wam->useStyle('webcomponent.field-media')
->useScript('webcomponent.field-media');

if(!$readonly)
{
if(!$link)
{
$modalLink .= 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;asset=' . $asset . '&amp;author=' . $authorField;
}
else
{
$modalLink .= $link;
}

$modalLink .= '&amp;fieldid=' . $id . '&amp;folder=' . $folder;
}
?>
if (count($doc->getScriptOptions('media-picker')) === 0) {
$doc->addScriptOptions('media-picker', [
'images' => $imagesExt,
'audios' => $audiosExt,
'videos' => $videosExt,
'documents' => $documentsExt,
]);
}

<?php
/**
* Close the modal on selecting image
* and clicking insert button
*/
JFactory::getDocument()->addScriptDeclaration(
"
jQuery(function($) {
window.parent.jModalClose = function(e) {
let bsModal = $('.modal.show');
let mtModal = $('#sbox-window');
let frameContents = $('#sbox-content iframe').contents();
let isMediaModal = frameContents.find('body.com-media.view-images').length > 0;
if (bsModal.length) {
if (isMediaModal) {
if ($('.img-preview.selected').length) {
bsModal.modal('hide');
}
}
} else if (mtModal.length) {
if (isMediaModal) {
let imageListFrame = frameContents.find('iframe').contents().find('body.com-media.view-imagesList');
if (imageListFrame.find('.img-preview.selected').length) {
SqueezeBox.close();
}
}
}
}
});
"
);
?>

<div class="input-group-text">
<a class="modal modal-btn btn btn-primary" title="<?php echo JText::_('JLIB_FORM_BUTTON_SELECT'); ?>" href="<?php echo $modalLink; ?>" rel="{handler: 'iframe', size: {x: 800, y: 500}}">
<?php echo JText::_('JLIB_FORM_BUTTON_SELECT'); ?>
</a>

<a class="btn btn-secondary hasTooltip"
title="<?php echo JText::_('JLIB_FORM_BUTTON_CLEAR'); ?>"
href="#"
onclick="jInsertFieldValue('', '<?php echo $id; ?>'); return false;"
>
<span class="fas fa-times" aria-hidden="true"></span>
</a>
<joomla-field-media class="field-media-wrapper" type="image" <?php // @TODO add this attribute to the field in order to use it for all media types
?> base-path="<?php echo Uri::root(); ?>" root-folder="<?php echo ComponentHelper::getParams('com_media')->get('file_path', 'images'); ?>" url="<?php echo $url; ?>" modal-container=".modal" modal-width="100%" modal-height="400px" input=".field-media-input" button-select=".button-select" button-clear=".button-clear" button-save-selected=".button-save-selected" preview="static" preview-container=".field-media-preview" preview-width="<?php echo $previewWidth; ?>" preview-height="<?php echo $previewHeight; ?>" supported-extensions="<?php echo str_replace('"', '&quot;', json_encode(['images' => $imagesAllowedExt, 'audios' => $audiosAllowedExt, 'videos' => $videosAllowedExt, 'documents' => $documentsAllowedExt])); ?>">
<?php echo $modalHTML; ?>
<?php if ($showPreview) : ?>
<div class="field-media-preview">
<?php echo ' ' . $previewImgEmpty; ?>
<?php echo ' ' . $previewImg; ?>
</div>
<?php endif; ?>
<div class="input-group">
<input type="text" name="<?php echo $name; ?>" id="<?php echo $id; ?>" value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>" readonly="readonly" <?php echo $attr; ?>>
<?php if ($disabled != true) : ?>
<button type="button" class="btn btn-success button-select"><?php echo Text::_('JLIB_FORM_BUTTON_SELECT'); ?></button>
<button type="button" class="btn btn-danger button-clear"><span class="icon-times" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('JLIB_FORM_BUTTON_CLEAR'); ?></span></button>
<?php endif; ?>
</div>
</div>
</joomla-field-media>
Loading

0 comments on commit 89e862a

Please sign in to comment.