Skip to content

Commit

Permalink
[4.0] TinyMCE context menu
Browse files Browse the repository at this point in the history
Tinymce has an option in the plugin called Context Menu but it doesn't do anything as there is no code to do anything.

With this PR you can no disable/enable the ability to right click on an item in the editor and get a contextual menu. When this is disabled you get the context menu from your browser

### Testing
Make sure that you set the option to be enabled/disabled in the correct set. Default for a super user is set 0

### Additional Note
This is also broken in Joomla 3
  • Loading branch information
brianteeman committed Jan 12, 2020
1 parent c104d5e commit 7e187d0
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 26 deletions.
84 changes: 64 additions & 20 deletions administrator/components/com_config/tmpl/component/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,59 +54,103 @@
<?php // End Sidebar ?>

<div class="col-md-9" id="config">
<?php if ($this->fieldsets): ?>

<?php echo HTMLHelper::_('uitab.startTabSet', 'configTabs'); ?>
<?php if ($this->fieldsets): ?>
<?php $opentab = 0; ?>
<!-- <ul class="nav nav-tabs mt-2" id="configTabs"> -->
<?php echo HTMLHelper::_('uitab.startTabSet', 'configTabs'); ?>

<?php foreach ($this->fieldsets as $name => $fieldSet) : ?>

<?php
// Only show first level fieldsets as tabs
if ($xml->xpath('//fieldset/fieldset[@name="' . $name . '"]')) :
continue;
endif;
?>

<?php $dataShowOn = ''; ?>
<?php if (!empty($fieldSet->showon)) : ?>
<?php HTMLHelper::_('script', 'system/showon.min.js', array('version' => 'auto', 'relative' => true)); ?>
<?php $dataShowOn = ' data-showon=\'' . json_encode(FormHelper::parseShowOnConditions($fieldSet->showon, $this->formControl)) . '\''; ?>
<?php endif; ?>

<?php $label = empty($fieldSet->label) ? 'COM_CONFIG_' . $name . '_FIELDSET_LABEL' : $fieldSet->label; ?>
<?php $hasChildren = $xml->xpath('//fieldset[@name="' . $name . '"]/fieldset'); ?>
<li class="nav-item"<?php echo $dataShowOn; ?>><a class="nav-link" data-toggle="tab" href="#<?php echo $name; ?>"><?php echo Text::_($label); ?></a></li>
<?php endforeach; ?>
</ul>

<?php echo HTMLHelper::_('uitab.addTab', 'configTabs', $name, Text::_($label)); ?>
<!-- <div class="tab-content form-no-margin" id="configContent"> -->
<?php echo HTMLHelper::_('uitab.addTab', 'configTabs', $name, Text::_($label)); ?>

<?php foreach ($this->fieldsets as $name => $fieldSet) : ?>
<?php
$hasChildren = $xml->xpath('//fieldset[@name="' . $name . '"]/fieldset');
$hasParent = $xml->xpath('//fieldset/fieldset[@name="' . $name . '"]');
$isGrandchild = $xml->xpath('//fieldset/fieldset/fieldset[@name="' . $name . '"]');
?>

<?php if (!$isGrandchild && $hasParent) : ?>
<fieldset id="fieldset-<?php echo $this->escape($name); ?>" class="options-grid-form options-grid-form-full">
<legend><?php echo Text::_($fieldSet->label); ?></legend>
<div>
<?php elseif (!$hasParent) : ?>
<?php if ($opentab) : ?>

<fieldset id="fieldset-<?php echo $this->escape($name); ?>" class="options-grid-form options-grid-form-full options-menu">
<legend><?php echo Text::_($fieldSet->label); ?></legend>
<div>
<?php if (!empty($fieldSet->description)) : ?>
<div class="tab-description alert alert-info">
<span class="fa fa-info-circle" aria-hidden="true"></span><span class="sr-only"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_($fieldSet->description); ?>
<?php if ($opentab > 1) : ?>
</div>
</fieldset>
<?php endif; ?>

<?php if (!$hasChildren) : ?>
<?php echo $this->form->renderFieldset($name, $name === 'permissions' ? ['hiddenLabel' => true, 'class' => 'revert-controls'] : []); ?>
<?php endif; ?>
</div>

<?php endif; ?>

<div class="tab-pane" id="<?php echo $name; ?>">

<?php $opentab = 1; ?>

<?php if (!$hasChildren) : ?>

<fieldset id="fieldset-<?php echo $this->escape($name); ?>" class="options-grid-form options-grid-form-full">
<legend><?php echo Text::_($fieldSet->label); ?></legend>
<div>
<?php $opentab = 2; ?>
<?php endif; ?>
<?php endif; ?>

<?php if (!empty($fieldSet->description)) : ?>
<div class="tab-description alert alert-info">
<span class="fa fa-info-circle" aria-hidden="true"></span><span class="sr-only"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_($fieldSet->description); ?>
</div>
</fieldset>
<?php endif; ?>

<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php if (!$hasChildren) : ?>
<?php echo $this->form->renderFieldset($name, $name === 'permissions' ? ['hiddenLabel' => true, 'class' => 'revert-controls'] : []); ?>
<?php endif; ?>

<?php if (!$isGrandchild && $hasParent) : ?>
</div>
</fieldset>
<?php endif; ?>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php endforeach; ?>
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>

<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
<?php if ($opentab) : ?>

<?php if ($opentab > 1) : ?>
</div>
</fieldset>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php else: ?>
<div class="alert alert-info">
<span class="fa fa-info-circle" aria-hidden="true"></span><span class="sr-only"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_('COM_CONFIG_COMPONENT_NO_CONFIG_FIELDS_MESSAGE'); ?>
</div>
<?php endif; ?>

</div>

<input type="hidden" name="id" value="<?php echo $this->component->id; ?>">
Expand Down
67 changes: 67 additions & 0 deletions administrator/components/com_fields/Model/GroupsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,73 @@ protected function getStoreId($id = '')
return parent::getStoreId($id);
}

/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 4.0.0
*/
public function getItems()
{
$items = parent::getItems();

if ($items)
{
$this->countItems($items);
}

return $items;
}

/**
* Add the number of fields in each state
*
* @param array $items The field items
*
* @return mixed An array of data items on success, false on failure.
*
* @since 4.0.0
*/
protected function countItems($items)
{
$db = $this->getDbo();

$ids = [0];

foreach ($items as $item)
{
$ids[] = (int) $item->id;
$item->count_published = 0;
$item->count_unpublished = 0;
$item->count_archived = 0;
$item->count_deleted = 0;
}

$query = $db->getQuery(true);

$query ->select('state, count(*) AS count')
->from($db->quoteName('#__fields'))
->group($db->quoteName('state'));
// Filter by context
if ($context = $this->getState('filter.context', 'com_fields'))
{
$query->where($db->quoteName('context') . ' = :context')
->bind(':context', $context);
}

$count = $db->setQuery($query)->loadObjectList('state');
print_r($count);
foreach ($items as $item)
{
if (isset($count[$item->id]))
{
$item->count_states = (int) $count[$item->id]->count;
}
}

}

/**
* Method to get a JDatabaseQuery object for retrieving the data set from a database.
*
Expand Down
9 changes: 9 additions & 0 deletions administrator/components/com_fields/View/Groups/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class HtmlView extends BaseHtmlView
*/
protected $state;

/**
* @var \JObject
*
* @since __DEPLOY_VERSION__
*/

protected $status;

/**
* Execute and display a template script.
*
Expand All @@ -83,6 +91,7 @@ public function display($tpl = null)
$this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->status = $this->get('Status');

// Check for errors.
if (count($errors = $this->get('Errors')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$app = Factory::getApplication();
$user = Factory::getUser();
$userId = $user->get('id');

print_r($this->countItems);
$component = '';
$parts = FieldsHelper::extract($this->state->get('filter.context'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function display($tpl = null)
// Show the message if an update is found.
Factory::getApplication()->enqueueMessage(Text::_('COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATE_NOTICE'), 'warning');
}

print_r($this->ftp);
$this->ftpFieldsDisplay = $this->ftp['enabled'] ? '' : 'style = "display: none"';
$params = ComponentHelper::getParams('com_joomlaupdate');

Expand Down
4 changes: 4 additions & 0 deletions installation/src/View/Remove/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public function display($tpl = null)
$this->phpoptions = $this->get('PhpOptions', 'Checks');
$this->phpsettings = $this->get('PhpSettings', 'Checks');

// $this->items->administrator = $this->model->getInstalledlangsAdministrator();
// $this->items->frontend = $this->model->getInstalledlangsFrontend();
// $this->form = $this->model->getForm();

return parent::display($tpl);
}
}
12 changes: 11 additions & 1 deletion installation/template/js/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@ if (document.getElementById('installLanguagesButton')) {
// Install the extra languages
if (Joomla.install(['languages'], form)) {
document.getElementById('installLanguages').classList.remove('active');
document.getElementById('installFinal').classList.add('active');
document.getElementById('configLanguages').classList.add('active');
document.getElementById('installFinal').classList.add('active');
}
}
})
}

if (document.getElementById('configLanguages')) {
document.getElementById('configLanguages').addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('installFinal').classList.add('active');
document.getElementById('installRecommended').classList.add('active');
document.getElementById('installLanguages').classList.remove('active');
})
}
92 changes: 91 additions & 1 deletion installation/tmpl/remove/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,97 @@ class="btn btn-primary"
</form>
</div>
</fieldset>

<!-- brian start -->
<fieldset id="configLanguages" class="j-install-step">
<legend class="j-install-step-header">
<span class="fa fa-language" aria-hidden="true"></span> <?php echo Text::_('INSTL_DEFAULTLANGUAGE_MULTILANGUAGE_TITLE'); ?>
</legend>
<div class="j-install-step-form">
<form action="index.php" method="post" id="languagesForm" class="form-validate">
<h2><?php echo JText::_('INSTL_DEFAULTLANGUAGE_ADMINISTRATOR'); ?></h2>
<table class="table table-sm">
<thead>
<tr>
<th>
<?php echo JText::_('INSTL_DEFAULTLANGUAGE_COLUMN_HEADER_SELECT'); ?>
</th>
<th>
<?php echo JText::_('INSTL_DEFAULTLANGUAGE_COLUMN_HEADER_LANGUAGE'); ?>
</th>
<th>
<?php echo JText::_('INSTL_DEFAULTLANGUAGE_COLUMN_HEADER_TAG'); ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items->administrator as $i => $lang) : ?>
<tr>
<td>
<input
id="admin-language-cb<?php echo $i; ?>"
type="radio"
name="administratorlang"
value="<?php echo $lang->language; ?>"
<?php if ($lang->published) echo 'checked="checked"'; ?>
/>
</td>
<td>
<label for="admin-language-cb<?php echo $i; ?>">
<?php echo $lang->name; ?>
</label>
</td>
<td>
<?php echo $lang->language; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h2><?php echo JText::_('INSTL_DEFAULTLANGUAGE_FRONTEND'); ?></h2>
<table class="table table-sm">
<thead>
<tr>
<th>
<?php echo JText::_('INSTL_DEFAULTLANGUAGE_COLUMN_HEADER_SELECT'); ?>
</th>
<th>
<?php echo JText::_('INSTL_DEFAULTLANGUAGE_COLUMN_HEADER_LANGUAGE'); ?>
</th>
<th>
<?php echo JText::_('INSTL_DEFAULTLANGUAGE_COLUMN_HEADER_TAG'); ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items->frontend as $i => $lang) : ?>
<tr>
<td>
<input
id="site-language-cb<?php echo $i; ?>"
type="radio"
name="frontendlang"
value="<?php echo $lang->language; ?>"
<?php if ($lang->published) echo 'checked="checked"'; ?>
/>
</td>
<td>
<label for="site-language-cb<?php echo $i; ?>">
<?php echo $lang->name; ?>
</label>
</td>
<td>
<?php echo $lang->language; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h2><?php echo JText::_('INSTL_DEFAULTLANGUAGE_MULTILANGUAGE_TITLE'); ?></h2>
<pre>Load the form here</pre>
</form>
</div>
</fieldset>
<!-- brian end -->
<fieldset id="installFinal" class="j-install-step">
<legend class="j-install-step-header">
<span class="fab fa-joomla" aria-hidden="true"></span> <?php echo Text::_('INSTL_COMPLETE_FINAL'); ?>
Expand Down
5 changes: 5 additions & 0 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ public function onDisplay(
$resizing = 'both';
}


// Check if the context menu should be displayed
$contextmenu = (bool) $levelParams->get('contextmenu', true);

// Set of always available plugins
$plugins = array(
'autolink',
Expand Down Expand Up @@ -596,6 +600,7 @@ public function onDisplay(
'width' => $html_width,
'resize' => $resizing,
'templates' => $templates,
'contextmenu' => $contextmenu,
'image_advtab' => (bool) $levelParams->get('image_advtab', false),
'external_plugins' => empty($externalPlugins) ? null : $externalPlugins,

Expand Down

0 comments on commit 7e187d0

Please sign in to comment.