Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'item-form', array('category.apply', 'category.save', 'category.save2new', 'category.save2copy'));

$app = JFactory::getApplication();
$input = $app->input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('bootstrap.tooltip');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'application-form', array('config.save.application.apply', 'config.save.application.save'));

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbutton = function(task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'component-form', array('config.save.component.apply', 'config.save.component.save'));

JFactory::getDocument()->addScriptDeclaration(
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'item-form', array('article.apply', 'article.save', 'article.save2new', 'article.save2copy'));

$this->configFieldsets = array('editorConfig');
$this->hiddenFieldsets = array('basic-limited');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
JHtml::_('behavior.tabstate');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'item-form', array('item.apply', 'item.save', 'item.save2new', 'item.save2copy'));

JText::script('ERROR');
JText::script('JGLOBAL_VALIDATION_FORM_FAILED');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.combobox');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'module-form', array('module.apply', 'module.save', 'module.save2new', 'module.save2copy'));

$hasContent = empty($this->item->module) || isset($this->item->xml->customContent);
$hasContentFieldName = "content";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'style-form', array('plugin.apply', 'plugin.save'));

$this->fieldsets = $this->form->getFieldsets('params');

JFactory::getDocument()->addScriptDeclaration("
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.inputlimittest', 'user-form', array('user.apply', 'user.save', 'user.save2new'));

JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ JERROR_NOLOGIN_BLOCKED="Login denied! Your account has either been blocked or yo
JERROR_SENDING_EMAIL="Email could not be sent."
JERROR_SESSION_STARTUP="Error initialising the session."
JERROR_SAVE_FAILED="Could not save data. Error: %s"
JERROR_MAXVARS_REACHED="Your PHP configuration has an input limit of %s variables and your website is close to that limit or has reached that limit and is using approximately <strong>%s</strong>. <strong> <br />This will create issues making changes to your website.</strong> <br />Please contact your hosting provider and ask them to increase the limit of the PHP setting <strong>max_input_vars</strong>."
JERROR_MAXVARS_NOSUBMIT="You cannot submit the form until the limit is changed."

JFIELD_ACCESS_DESC="The access level group that is allowed to view this item."
JFIELD_ACCESS_LABEL="Access"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.inputlimittest', 'item-form', array('category.apply', 'category.save', 'category.save2new', 'category.save2copy'));

JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

JHtml::_('behavior.formvalidator');
JHtml::_('behavior.switcher');
JHtml::_('behavior.inputlimittest', 'application-form', array('config.save.application.apply', 'config.save.application.save'));

// Load submenu template, using element id 'submenu' as needed by behavior.switcher
$this->document->setBuffer($this->loadTemplate('navigation'), 'modules', 'submenu');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

JHtml::_('behavior.formvalidator');
JHtml::_('bootstrap.framework');
JHtml::_('behavior.inputlimittest', 'component-form', array('config.save.component.apply', 'config.save.component.save'));

JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('behavior.inputlimittest', 'item-form', array('article.apply', 'article.save', 'article.save2new', 'article.save2copy'));

// Create shortcut to parameters.
$params = $this->state->get('params');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
JHtml::_('behavior.framework');
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.modal');
JHtml::_('behavior.inputlimittest', 'item-form', array('item.apply', 'item.save', 'item.save2new', 'item.save2copy'));

$assoc = JLanguageAssociations::isEnabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

JHtml::_('behavior.formvalidator');
JHtml::_('behavior.combobox');
JHtml::_('behavior.inputlimittest', 'module-form', array('module.apply', 'module.save', 'module.save2new', 'module.save2copy'));

$hasContent = empty($this->item->module) || $this->item->module == 'custom' || $this->item->module == 'mod_custom';

$script = "Joomla.submitbutton = function(task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');

JHtml::_('behavior.formvalidator');
JHtml::_('behavior.inputlimittest', 'style-form', array('plugin.apply', 'plugin.save'));

JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('behavior.inputlimittest', 'user-form', array('user.apply', 'user.save', 'user.save2new'));

// Get the form fieldsets.
$fieldsets = $this->form->getFieldsets();
Expand Down
66 changes: 66 additions & 0 deletions libraries/cms/html/behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -900,4 +900,70 @@ public static function tabstate()
JHtml::_('script', 'system/tabs-state.js', false, true);
self::$loaded[__METHOD__] = true;
}

/**
* Add script for checks the setting of php max_input_vars and notify user
*
* @param string $formid The id of the form that will be used for test
* @param array $preventTasks Tasks that will be prevented when limit is reached
*
* @return void
*
* @since 3.5
*/
public static function inputLimitTest($formid = 'adminForm', $preventTasks = array())
{
if (isset(self::$loaded[__METHOD__][$formid]))
{
return;
}

// Get the request limit from the PHP configiration
$suhosinPostVars = (int) ini_get('suhosin.post.max_vars');
$suhosinReqVars = (int) ini_get('suhosin.request.max_vars');
$maxinputvars = (int) ini_get('max_input_vars');

if ($suhosinPostVars || $suhosinReqVars)
{
// Take the minimum value but not a zero
$maxinputvars = min(array_filter(array($suhosinPostVars, $suhosinReqVars)));
}
elseif (!$maxinputvars)
{
// Server do not tell us his secrets
return;
}

static::core();
JHtml::_('jquery.framework');
JText::script('JERROR_MAXVARS_REACHED');
JText::script('JERROR_MAXVARS_NOSUBMIT');

JFactory::getDocument()->addScriptDeclaration('
jQuery(window).load(function(){
var form = document.getElementById("' . $formid . '"),
tasks = ' . json_encode($preventTasks) . ', msgs = {},
limit = ' . $maxinputvars . ', msg, type, reached, near;
if (!form) return;
reached = form.length >= limit;
near = form.length/limit > 0.8;
if (!reached && !near) return;
type = reached ? "error" : "warning";
msg = Joomla.JText._("JERROR_MAXVARS_REACHED");
msg = msg.replace("%s", limit).replace("%s", form.length);
msgs[type] = [msg];
Joomla.renderMessages(msgs);
if (reached) {
jQuery(form).on("submit", function(){
if (tasks.indexOf(this.task.value) !== -1) {
Joomla.renderMessages({"error":[msg, Joomla.JText._("JERROR_MAXVARS_NOSUBMIT")]});
return false;
}
});
}
});
');

self::$loaded[__METHOD__][$formid] = true;
}
}