Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…_extension_manager into edit_updatesite
  • Loading branch information
NunoLopesPT committed Jul 25, 2017
2 parents 6169205 + c21ddbf commit 23b566f
Show file tree
Hide file tree
Showing 48 changed files with 374 additions and 341 deletions.
Expand Up @@ -6,28 +6,31 @@
* @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.
*
* @var string
* @since 3.7.0
*/
protected $type = 'ItemLanguage';
protected $type = 'Itemlanguage';

/**
* Method to get the field options.
Expand All @@ -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);

Expand Down Expand Up @@ -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.
Expand Down
Expand Up @@ -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.
Expand All @@ -25,16 +29,16 @@ class JFormFieldItemType extends JFormFieldGroupedList
*
* @since 3.7.0
*/
protected $type = 'ItemType';
protected $type = 'Itemtype';

/**
* Method to get the field input markup.
*
* @return array The field option objects as a nested array in groups.
*
* @since 3.7.0
*
* @throws UnexpectedValueException
* @throws \UnexpectedValueException
*/
protected function getGroups()
{
Expand All @@ -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'));
}
}
}
Expand Down
Expand Up @@ -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.
Expand All @@ -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[] = '<a'
. ' id="select-change"'
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
. ' data-toggle="modal"'
. ' data-select="' . JText::_('COM_ASSOCIATIONS_SELECT_TARGET') . '"'
. ' data-change="' . JText::_('COM_ASSOCIATIONS_CHANGE_TARGET') . '"'
. ' data-select="' . \JText::_('COM_ASSOCIATIONS_SELECT_TARGET') . '"'
. ' data-change="' . \JText::_('COM_ASSOCIATIONS_CHANGE_TARGET') . '"'
. ' role="button"'
. ' href="#associationSelect' . $this->id . 'Modal">'
. '<span class="icon-file" aria-hidden="true"></span> '
Expand All @@ -68,25 +72,25 @@ protected function getInput()
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
. ' onclick="return Joomla.submitbutton(\'undo-association\');"'
. ' id="remove-assoc">'
. '<span class="icon-remove" aria-hidden="true"></span> ' . JText::_('JCLEAR')
. '<span class="icon-remove" aria-hidden="true"></span> ' . \JText::_('JCLEAR')
. '</button>';

$html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $value . '">';

// 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',
'width' => '800px',
'bodyHeight' => 70,
'modalWidth' => 80,
'footer' => '<button type="button" class="btn btn-secondary" data-dismiss="modal" aria-hidden="true">'
. JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>',
. \JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>',
)
);

Expand Down
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<form addfieldprefix="Joomla\Component\Associations\Administrator\Field">
<fieldset>
<field
name="itemlanguage"
Expand All @@ -12,7 +12,7 @@

<field
name="modalassociation"
type="modalassociation"
type="modal_association"
/>
</fieldset>

Expand Down
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<form addfieldprefix="Joomla\Component\Associations\Administrator\Field">
<field
name="itemtype"
type="itemtype"
Expand Down
Expand Up @@ -6,10 +6,13 @@
* @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\Redirect\Administrator\Field;

defined('JPATH_BASE') or die;

JFormHelper::loadFieldClass('list');
use Joomla\CMS\Form\FormHelper;

FormHelper::loadFieldClass('list');

/**
* A dropdown containing all valid HTTP 1.1 response codes.
Expand All @@ -18,7 +21,7 @@
* @subpackage com_redirect
* @since 3.4
*/
class JFormFieldRedirect extends JFormFieldList
class RedirectField extends \JFormFieldList
{
/**
* The form field type.
Expand Down Expand Up @@ -112,7 +115,7 @@ protected function getOptions()

foreach ($this->responseMap as $key => $value)
{
$options[] = JHtml::_('select.option', $key, $value);
$options[] = \JHtml::_('select.option', $key, $value);
}

// Merge any additional options in the XML definition.
Expand Down
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<form addfieldprefix="Joomla\Component\Redirect\Administrator\Field">
<fields name="filter">
<field
name="search"
Expand Down
Expand Up @@ -6,19 +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\Templates\Administrator\Field;

defined('_JEXEC') or die;

JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php');
use Joomla\CMS\Form\FormHelper;
use Joomla\Component\Templates\Administrator\Helper\TemplatesHelper;

JFormHelper::loadFieldClass('list');
FormHelper::loadFieldClass('list');

/**
* Template Location field.
* Template Location field.
*
* @since 3.5
*/
class JFormFieldTemplateLocation extends JFormFieldList
class TemplatelocationField extends \JFormFieldList
{
/**
* The form field type.
Expand Down
Expand Up @@ -6,19 +6,22 @@
* @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\Templates\Administrator\Field;

defined('_JEXEC') or die;

JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php');
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
use Joomla\Component\Templates\Administrator\Helper\TemplatesHelper;

JFormHelper::loadFieldClass('list');
FormHelper::loadFieldClass('list');

/**
* Template Name field.
*
* @since 3.5
*/
class JFormFieldTemplateName extends JFormFieldList
class TemplatenameField extends \JFormFieldList
{
/**
* The form field type.
Expand All @@ -38,7 +41,7 @@ class JFormFieldTemplateName extends JFormFieldList
public function getOptions()
{
// Get the client_id filter from the user state.
$clientId = JFactory::getApplication()->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);
Expand Down
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_templates/models/fields" />
<form addfieldprefix="Joomla\Component\Templates\Administrator\Field">
<field
name="client_id"
type="list"
Expand Down
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_templates/models/fields" />
<field
name="client_id"
type="list"
Expand Down
57 changes: 57 additions & 0 deletions components/com_contact/Rule/ContactEmailMessageRule.php
@@ -0,0 +1,57 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @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\Contact\Site\Rule;

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormRule;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

/**
* FormRule for com_contact to make sure the message body contains no banned word.
*
* @since 1.6
*/
class ContactEmailMessageRule extends FormRule
{
/**
* Method to test a message for banned words
*
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the <field /> 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;
}
}

0 comments on commit 23b566f

Please sign in to comment.