diff --git a/administrator/components/com_associations/models/fields/itemlanguage.php b/administrator/components/com_associations/Field/ItemlanguageField.php similarity index 90% rename from administrator/components/com_associations/models/fields/itemlanguage.php rename to administrator/components/com_associations/Field/ItemlanguageField.php index 15e4631f270b6..1065f292e0128 100644 --- a/administrator/components/com_associations/models/fields/itemlanguage.php +++ b/administrator/components/com_associations/Field/ItemlanguageField.php @@ -6,20 +6,23 @@ * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Associations\Administrator\Field; defined('JPATH_BASE') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\FormHelper; use Joomla\Utilities\ArrayHelper; - use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper; -JFormHelper::loadFieldClass('list'); + +FormHelper::loadFieldClass('list'); /** * Field listing item languages * * @since 3.7.0 */ -class JFormFieldItemLanguage extends JFormFieldList +class ItemlanguageField extends \JFormFieldList { /** * The form field type. @@ -27,7 +30,7 @@ class JFormFieldItemLanguage extends JFormFieldList * @var string * @since 3.7.0 */ - protected $type = 'ItemLanguage'; + protected $type = 'Itemlanguage'; /** * Method to get the field options. @@ -38,7 +41,7 @@ class JFormFieldItemLanguage extends JFormFieldList */ protected function getOptions() { - $input = JFactory::getApplication()->input; + $input = Factory::getApplication()->input; list($extensionName, $typeName) = explode('.', $input->get('itemtype', '', 'string'), 2); @@ -70,7 +73,7 @@ protected function getOptions() continue; } - $options[$langCode] = new stdClass; + $options[$langCode] = new \stdClass; $options[$langCode]->text = $language->title; // If association exists in this language. diff --git a/administrator/components/com_associations/models/fields/itemtype.php b/administrator/components/com_associations/Field/ItemtypeField.php similarity index 77% rename from administrator/components/com_associations/models/fields/itemtype.php rename to administrator/components/com_associations/Field/ItemtypeField.php index 1be5318ec277c..76e7ef8e9fb23 100644 --- a/administrator/components/com_associations/models/fields/itemtype.php +++ b/administrator/components/com_associations/Field/ItemtypeField.php @@ -6,17 +6,21 @@ * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Associations\Administrator\Field; + defined('JPATH_BASE') or die; +use Joomla\CMS\Form\FormHelper; use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper; -JFormHelper::loadFieldClass('groupedlist'); + +FormHelper::loadFieldClass('groupedlist'); /** * A drop down containing all component item types that implement associations. * * @since 3.7.0 */ -class JFormFieldItemType extends JFormFieldGroupedList +class ItemtypeField extends \JFormFieldGroupedList { /** * The form field type. @@ -25,8 +29,8 @@ class JFormFieldItemType extends JFormFieldGroupedList * * @since 3.7.0 */ - protected $type = 'ItemType'; - + protected $type = 'Itemtype'; + /** * Method to get the field input markup. * @@ -34,7 +38,7 @@ class JFormFieldItemType extends JFormFieldGroupedList * * @since 3.7.0 * - * @throws UnexpectedValueException + * @throws \UnexpectedValueException */ protected function getGroups() { @@ -48,7 +52,7 @@ protected function getGroups() foreach ($extension->get('types') as $type) { $context = $extension->get('component') . '.' . $type->get('name'); - $options[$extension->get('title')][] = JHtml::_('select.option', $context, $type->get('title')); + $options[$extension->get('title')][] = \JHtml::_('select.option', $context, $type->get('title')); } } } diff --git a/administrator/components/com_associations/models/fields/modalassociation.php b/administrator/components/com_associations/Field/Modal/AssociationField.php similarity index 72% rename from administrator/components/com_associations/models/fields/modalassociation.php rename to administrator/components/com_associations/Field/Modal/AssociationField.php index cf230ef6b19df..02de1179ad6f6 100644 --- a/administrator/components/com_associations/models/fields/modalassociation.php +++ b/administrator/components/com_associations/Field/Modal/AssociationField.php @@ -6,15 +6,19 @@ * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Associations\Administrator\Field\Modal; defined('JPATH_BASE') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Form\FormField; + /** * Supports a modal item picker. * * @since 3.7.0 */ -class JFormFieldModalAssociation extends JFormField +class AssociationField extends FormField { /** * The form field type. @@ -37,26 +41,26 @@ protected function getInput() // The active item id field. $value = (int) $this->value > 0 ? (int) $this->value : ''; - JFactory::getDocument()->addScriptOptions('modal-associations', ['itemId' => $value]); - JHtml::_('script', 'com_associations/modal-associations.min.js', false, true); + Factory::getDocument()->addScriptOptions('modal-associations', ['itemId' => $value]); + \JHtml::_('script', 'com_associations/modal-associations.min.js', false, true); // Setup variables for display. $html = array(); $linkAssociations = 'index.php?option=com_associations&view=associations&layout=modal&tmpl=component' - . '&forcedItemType=' . JFactory::getApplication()->input->get('itemtype', '', 'string') . '&function=jSelectAssociation_' . $this->id; + . '&forcedItemType=' . Factory::getApplication()->input->get('itemtype', '', 'string') . '&function=jSelectAssociation_' . $this->id; $linkAssociations .= "&forcedLanguage=' + document.getElementById('target-association').getAttribute('data-language') + '"; - $urlSelect = $linkAssociations . '&' . JSession::getFormToken() . '=1'; + $urlSelect = $linkAssociations . '&' . \JSession::getFormToken() . '=1'; // Select custom association button $html[] = '' . ' ' @@ -68,17 +72,17 @@ protected function getInput() . ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"' . ' onclick="return Joomla.submitbutton(\'undo-association\');"' . ' id="remove-assoc">' - . ' ' . JText::_('JCLEAR') + . ' ' . \JText::_('JCLEAR') . ''; $html[] = ''; // Select custom association modal - $html[] = JHtml::_( + $html[] = \JHtml::_( 'bootstrap.renderModal', 'associationSelect' . $this->id . 'Modal', array( - 'title' => JText::_('COM_ASSOCIATIONS_SELECT_TARGET'), + 'title' => \JText::_('COM_ASSOCIATIONS_SELECT_TARGET'), 'backdrop' => 'static', 'url' => $urlSelect, 'height' => '400px', @@ -86,7 +90,7 @@ protected function getInput() 'bodyHeight' => 70, 'modalWidth' => 80, 'footer' => '', + . \JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '', ) ); diff --git a/administrator/components/com_associations/forms/association.xml b/administrator/components/com_associations/forms/association.xml index 9e8d880e22984..c1df8fdacd8d6 100644 --- a/administrator/components/com_associations/forms/association.xml +++ b/administrator/components/com_associations/forms/association.xml @@ -1,5 +1,5 @@ -
+
diff --git a/administrator/components/com_associations/forms/filter_associations.xml b/administrator/components/com_associations/forms/filter_associations.xml index 9563de4489650..80e1a066f2ae8 100644 --- a/administrator/components/com_associations/forms/filter_associations.xml +++ b/administrator/components/com_associations/forms/filter_associations.xml @@ -1,5 +1,5 @@ - + responseMap as $key => $value) { - $options[] = JHtml::_('select.option', $key, $value); + $options[] = \JHtml::_('select.option', $key, $value); } // Merge any additional options in the XML definition. diff --git a/administrator/components/com_redirect/forms/filter_links.xml b/administrator/components/com_redirect/forms/filter_links.xml index 680cd41de0cf5..b5d989cedd0bc 100644 --- a/administrator/components/com_redirect/forms/filter_links.xml +++ b/administrator/components/com_redirect/forms/filter_links.xml @@ -1,5 +1,5 @@ - + getUserStateFromRequest('com_templates.styles.client_id', 'client_id', '0', 'string'); + $clientId = Factory::getApplication()->getUserStateFromRequest('com_templates.styles.client_id', 'client_id', '0', 'string'); // Get the templates for the selected client_id. $options = TemplatesHelper::getTemplateOptions($clientId); diff --git a/administrator/components/com_templates/forms/filter_styles.xml b/administrator/components/com_templates/forms/filter_styles.xml index 8f824fcbc5510..ae96ad2d191f7 100644 --- a/administrator/components/com_templates/forms/filter_styles.xml +++ b/administrator/components/com_templates/forms/filter_styles.xml @@ -1,6 +1,5 @@ - -
+ -
tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + $params = ComponentHelper::getParams('com_contact'); + $banned = $params->get('banned_text'); + + if ($banned) + { + foreach (explode(';', $banned) as $item) + { + if ($item != '' && StringHelper::stristr($value, $item) !== false) + { + return false; + } + } + } + + return true; + } +} diff --git a/components/com_contact/Rule/ContactEmailRule.php b/components/com_contact/Rule/ContactEmailRule.php new file mode 100644 index 0000000000000..1361099f25e05 --- /dev/null +++ b/components/com_contact/Rule/ContactEmailRule.php @@ -0,0 +1,62 @@ + tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + if (!parent::test($element, $value, $group, $input, $form)) + { + return false; + } + + $params = ComponentHelper::getParams('com_contact'); + $banned = $params->get('banned_email'); + + if ($banned) + { + foreach (explode(';', $banned) as $item) + { + if ($item != '' && StringHelper::stristr($value, $item) !== false) + { + return false; + } + } + } + + return true; + } +} diff --git a/components/com_contact/Rule/ContactEmailSubjectRule.php b/components/com_contact/Rule/ContactEmailSubjectRule.php new file mode 100644 index 0000000000000..1d6d4ae7dd142 --- /dev/null +++ b/components/com_contact/Rule/ContactEmailSubjectRule.php @@ -0,0 +1,57 @@ + tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + $params = ComponentHelper::getParams('com_contact'); + $banned = $params->get('banned_subject'); + + if ($banned) + { + foreach (explode(';', $banned) as $item) + { + if ($item != '' && StringHelper::stristr($value, $item) !== false) + { + return false; + } + } + } + + return true; + } +} diff --git a/components/com_contact/forms/contact.xml b/components/com_contact/forms/contact.xml index 8e641c2b9d06c..64cb5c0b51596 100644 --- a/components/com_contact/forms/contact.xml +++ b/components/com_contact/forms/contact.xml @@ -1,6 +1,6 @@ -
+
@@ -40,7 +40,7 @@ id="contact-emailmsg" size="60" filter="string" - validate="contactemailsubject" + validate="ContactEmailSubject" required="true" /> @@ -53,7 +53,7 @@ rows="10" id="contact-message" filter="safehtml" - validate="contactemailmessage" + validate="ContactEmailMessage" required="true" /> diff --git a/components/com_contact/models/rules/contactemail.php b/components/com_contact/models/rules/contactemail.php deleted file mode 100644 index d9657ff595b82..0000000000000 --- a/components/com_contact/models/rules/contactemail.php +++ /dev/null @@ -1,60 +0,0 @@ - tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as an array container for the field. - * For example if the field has name="foo" and the group value is set to "bar" then the - * full field name would end up being "bar[foo]". - * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. - * - * @return boolean True if the value is valid, false otherwise. - */ - public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) - { - if (!parent::test($element, $value, $group, $input, $form)) - { - return false; - } - - $params = JComponentHelper::getParams('com_contact'); - $banned = $params->get('banned_email'); - - if ($banned) - { - foreach (explode(';', $banned) as $item) - { - if ($item != '' && StringHelper::stristr($value, $item) !== false) - { - return false; - } - } - } - - return true; - } -} diff --git a/components/com_contact/models/rules/contactemailmessage.php b/components/com_contact/models/rules/contactemailmessage.php deleted file mode 100644 index 43ba1e1c30d1d..0000000000000 --- a/components/com_contact/models/rules/contactemailmessage.php +++ /dev/null @@ -1,53 +0,0 @@ - tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as an array container for the field. - * For example if the field has name="foo" and the group value is set to "bar" then the - * full field name would end up being "bar[foo]". - * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. - * - * @return boolean True if the value is valid, false otherwise. - */ - public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) - { - $params = JComponentHelper::getParams('com_contact'); - $banned = $params->get('banned_text'); - - if ($banned) - { - foreach (explode(';', $banned) as $item) - { - if ($item != '' && StringHelper::stristr($value, $item) !== false) - { - return false; - } - } - } - - return true; - } -} diff --git a/components/com_contact/models/rules/contactemailsubject.php b/components/com_contact/models/rules/contactemailsubject.php deleted file mode 100644 index c34314aa5eedd..0000000000000 --- a/components/com_contact/models/rules/contactemailsubject.php +++ /dev/null @@ -1,53 +0,0 @@ - tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as an array container for the field. - * For example if the field has name="foo" and the group value is set to "bar" then the - * full field name would end up being "bar[foo]". - * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. - * - * @return boolean True if the value is valid, false otherwise - */ - public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) - { - $params = JComponentHelper::getParams('com_contact'); - $banned = $params->get('banned_subject'); - - if ($banned) - { - foreach (explode(';', $banned) as $item) - { - if ($item != '' && StringHelper::stristr($value, $item) !== false) - { - return false; - } - } - } - - return true; - } -} diff --git a/components/com_users/Rule/LoginUniqueFieldRule.php b/components/com_users/Rule/LoginUniqueFieldRule.php new file mode 100644 index 0000000000000..1a44ead454b38 --- /dev/null +++ b/components/com_users/Rule/LoginUniqueFieldRule.php @@ -0,0 +1,65 @@ +` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + * + * @since 3.6 + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + $loginRedirectUrl = $input['params']->login_redirect_url; + $loginRedirectMenuitem = $input['params']->login_redirect_menuitem; + + if ($form === null) + { + throw new \InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this))); + } + + if ($input === null) + { + throw new \InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this))); + } + + // Test the input values for login. + if ($loginRedirectUrl != '' && $loginRedirectMenuitem != '') + { + return false; + } + + return true; + } +} diff --git a/components/com_users/Rule/LogoutUniqueFieldRule.php b/components/com_users/Rule/LogoutUniqueFieldRule.php new file mode 100644 index 0000000000000..e7e6bd90b7168 --- /dev/null +++ b/components/com_users/Rule/LogoutUniqueFieldRule.php @@ -0,0 +1,65 @@ +` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + * + * @since 3.6 + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + $logoutRedirectUrl = $input['params']->logout_redirect_url; + $logoutRedirectMenuitem = $input['params']->logout_redirect_menuitem; + + if ($form === null) + { + throw new \InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this))); + } + + if ($input === null) + { + throw new \InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this))); + } + + // Test the input values for logout. + if ($logoutRedirectUrl != '' && $logoutRedirectMenuitem != '') + { + return false; + } + + return true; + } +} diff --git a/components/com_users/models/rules/loginuniquefield.php b/components/com_users/models/rules/loginuniquefield.php deleted file mode 100644 index 396b588a2ab31..0000000000000 --- a/components/com_users/models/rules/loginuniquefield.php +++ /dev/null @@ -1,62 +0,0 @@ -` tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as an array container for the field. - * For example if the field has name="foo" and the group value is set to "bar" then the - * full field name would end up being "bar[foo]". - * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. - * - * @return boolean True if the value is valid, false otherwise. - * - * @since 3.6 - */ - public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) - { - $loginRedirectUrl = $input['params']->login_redirect_url; - $loginRedirectMenuitem = $input['params']->login_redirect_menuitem; - - if ($form === null) - { - throw new InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this))); - } - - if ($input === null) - { - throw new InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this))); - } - - // Test the input values for login. - if ($loginRedirectUrl != '' && $loginRedirectMenuitem != '') - { - return false; - } - - return true; - } -} diff --git a/components/com_users/models/rules/logoutuniquefield.php b/components/com_users/models/rules/logoutuniquefield.php deleted file mode 100644 index 3e24711bde544..0000000000000 --- a/components/com_users/models/rules/logoutuniquefield.php +++ /dev/null @@ -1,62 +0,0 @@ -` tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as an array container for the field. - * For example if the field has name="foo" and the group value is set to "bar" then the - * full field name would end up being "bar[foo]". - * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. - * @param JForm $form The form object for which the field is being tested. - * - * @return boolean True if the value is valid, false otherwise. - * - * @since 3.6 - */ - public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null) - { - $logoutRedirectUrl = $input['params']->logout_redirect_url; - $logoutRedirectMenuitem = $input['params']->logout_redirect_menuitem; - - if ($form === null) - { - throw new InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this))); - } - - if ($input === null) - { - throw new InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this))); - } - - // Test the input values for logout. - if ($logoutRedirectUrl != '' && $logoutRedirectMenuitem != '') - { - return false; - } - - return true; - } -} diff --git a/components/com_users/tmpl/login/default.xml b/components/com_users/tmpl/login/default.xml index 7ded7a56936df..24cc0c37f7f36 100644 --- a/components/com_users/tmpl/login/default.xml +++ b/components/com_users/tmpl/login/default.xml @@ -13,7 +13,7 @@ -
+
- @@ -109,12 +109,12 @@ description="JFIELD_LOGOUT_REDIRECT_URL_DESC" class="inputbox" field="logout_redirect_menuitem" - validate="logoutuniquefield" + validate="LogoutUniqueField" hint="COM_USERS_FIELD_LOGIN_REDIRECT_PLACEHOLDER" message="COM_USERS_FIELD_LOGOUT_REDIRECT_ERROR" showon="logoutredirectchoice:0" /> - +