first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,96 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
/**
* Form Field class for the Joomla Framework.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 2.5
*/
class JFormFieldCaptcha extends JFormField
{
/**
* The field type.
*
* @var string
*/
protected $type = 'Captcha';
/**
* Method to attach a JForm object to the field.
*
* @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 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]".
*
* @return boolean True on success.
*
* @since 2.5
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
$plugin = $this->element['plugin'] ?
(string) $this->element['plugin'] :
JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha'));
if ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null)
{
$this->hidden = true;
}
else
{
// Force field to be required. There's no reason to have a captcha if it is not required.
// Obs: Don't put required="required" in the xml file, you just need to have validate="captcha"
$this->required = true;
$class = $this->element['class'];
if (strpos($class, 'required') === false)
{
$this->element['class'] = $class . ' required';
}
}
return $result;
}
/**
* Method to get the field input.
*
* @return string The field input.
*
* @since 2.5
*/
protected function getInput()
{
$class = $this->element['class'] ? (string) $this->element['class'] : '';
$plugin = $this->element['plugin'] ? (string) $this->element['plugin'] : JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha'));
$namespace = $this->element['namespace'] ? (string) $this->element['namespace'] : $this->form->getName();
// Use 0 for none
if ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null)
{
return '';
}
else
{
if (($captcha = JCaptcha::getInstance($plugin, array('namespace' => $namespace))) == null)
{
return '';
}
}
return $captcha->display($this->name, $this->id, $class);
}
}

View File

@ -0,0 +1,120 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('groupedlist');
/**
* Chrome Styles Form Field class for the Joomla Platform.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 3.0
*/
class JFormFieldChromeStyle extends JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 3.0
*/
public $type = 'ChromeStyle';
/**
* Method to get the list of template chrome style options
* grouped by template.
*
* @return array The field option objects as a nested array in groups.
*
* @since 3.0
*/
protected function getGroups()
{
$groups = array();
// Add Module Style Field
$tmp = '---' . JText::_('JLIB_FORM_VALUE_FROM_TEMPLATE') . '---';
$groups[$tmp][] = JHtml::_('select.option', '0', JText::_('JLIB_FORM_VALUE_INHERITED'));
$templateStyles = $this->getTemplateModuleStyles();
// Create one new option object for each available style, grouped by templates
foreach ($templateStyles as $template => $styles)
{
$template = ucfirst($template);
$groups[$template] = array();
foreach ($styles as $style)
{
$tmp = JHtml::_('select.option', $template . '-' . $style, $style);
$groups[$template][] = $tmp;
}
}
reset($groups);
return $groups;
}
/**
* Method to get the templates module styles.
*
* @return array The array of styles, grouped by templates.
*
* @since 3.0
*/
protected function getTemplateModuleStyles()
{
$moduleStyles = array();
$templates = array($this->getSystemTemplate());
$templates = array_merge($templates, ModulesHelper::getTemplates('site'));
foreach ($templates as $template)
{
$modulesFilePath = JPATH_SITE . '/templates/' . $template->element . '/html/modules.php';
// Is there modules.php for that template?
if (file_exists($modulesFilePath))
{
$modulesFileData = file_get_contents($modulesFilePath);
preg_match_all('/function[\s\t]*modChrome\_([a-z0-9\-\_]*)[\s\t]*\(/i', $modulesFileData, $styles);
if (!array_key_exists($template->element, $moduleStyles))
{
$moduleStyles[$template->element] = array();
}
$moduleStyles[$template->element] = $styles[1];
}
}
return $moduleStyles;
}
/**
* Method to get the system template as an object.
*
* @return array The object of system template.
*
* @since 3.0
*/
protected function getSystemTemplate()
{
$template = new stdClass;
$template->element = 'system';
$template->name = 'system';
$template->enabled = 1;
return $template;
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a list of content languages
*
* @package Joomla.Libraries
* @subpackage Form
* @see JFormFieldLanguage for a select list of application languages.
* @since 1.6
*/
class JFormFieldContentlanguage extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'ContentLanguage';
/**
* Method to get the field options for content languages.
*
* @return array The options the field is going to show.
*
* @since 1.6
*/
protected function getOptions()
{
return array_merge(parent::getOptions(), JHtml::_('contentlanguage.existing'));
}
}

View File

@ -0,0 +1,98 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 3.1
*/
class JFormFieldContenttype extends JFormFieldList
{
/**
* A flexible tag list that respects access controls
*
* @var string
* @since 3.1
*/
public $type = 'Contenttype';
/**
* Method to get the field input for a list of content types.
*
* @return string The field input.
*
* @since 3.1
*/
protected function getInput()
{
if (!is_array($this->value))
{
if (is_object($this->value))
{
$this->value = $this->value->tags;
}
if (is_string($this->value))
{
$this->value = explode(',', $this->value);
}
}
$input = parent::getInput();
return $input;
}
/**
* Method to get a list of content types
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function getOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.type_id AS value, a.type_title AS text')
->from('#__content_types AS a')
->order('a.type_title ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
return false;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
foreach ($options as $option)
{
$option->text = mb_strtoupper(str_replace(' ', '_', $option->text), 'UTF-8');
$option->text = 'COM_TAGS_CONTENT_TYPE_' . $option->text;
$option->text = JText::_($option->text);
}
return $options;
}
}

View File

@ -0,0 +1,156 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* An editarea field for content creation
*
* @package Joomla.Libraries
* @subpackage Form
* @see JEditor
* @since 1.6
*/
class JFormFieldEditor extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'Editor';
/**
* The JEditor object.
*
* @var JEditor
* @since 1.6
*/
protected $editor;
/**
* Method to get the field input markup for the editor area
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$rows = (int) $this->element['rows'];
$cols = (int) $this->element['cols'];
$height = ((string) $this->element['height']) ? (string) $this->element['height'] : '250';
$width = ((string) $this->element['width']) ? (string) $this->element['width'] : '100%';
$assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
$authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by';
$asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id'];
// Build the buttons array.
$buttons = (string) $this->element['buttons'];
if ($buttons == 'true' || $buttons == 'yes' || $buttons == '1')
{
$buttons = true;
}
elseif ($buttons == 'false' || $buttons == 'no' || $buttons == '0')
{
$buttons = false;
}
else
{
$buttons = explode(',', $buttons);
}
$hide = ((string) $this->element['hide']) ? explode(',', (string) $this->element['hide']) : array();
// Get an editor object.
$editor = $this->getEditor();
return $editor
->display(
$this->name, htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), $width, $height, $cols, $rows,
$buttons ? (is_array($buttons) ? array_merge($buttons, $hide) : $hide) : false, $this->id, $asset,
$this->form->getValue($authorField)
);
}
/**
* Method to get a JEditor object based on the form field.
*
* @return JEditor The JEditor object.
*
* @since 1.6
*/
protected function getEditor()
{
// Only create the editor if it is not already created.
if (empty($this->editor))
{
$editor = null;
// Get the editor type attribute. Can be in the form of: editor="desired|alternative".
$type = trim((string) $this->element['editor']);
if ($type)
{
// Get the list of editor types.
$types = explode('|', $type);
// Get the database object.
$db = JFactory::getDbo();
// Iterate over teh types looking for an existing editor.
foreach ($types as $element)
{
// Build the query.
$query = $db->getQuery(true)
->select('element')
->from('#__extensions')
->where('element = ' . $db->quote($element))
->where('folder = ' . $db->quote('editors'))
->where('enabled = 1');
// Check of the editor exists.
$db->setQuery($query, 0, 1);
$editor = $db->loadResult();
// If an editor was found stop looking.
if ($editor)
{
break;
}
}
}
// Create the JEditor instance based on the given editor.
if (is_null($editor))
{
$conf = JFactory::getConfig();
$editor = $conf->get('editor');
}
$this->editor = JEditor::getInstance($editor);
}
return $this->editor;
}
/**
* Method to get the JEditor output for an onSave event.
*
* @return string The JEditor object output.
*
* @since 1.6
*/
public function save()
{
return $this->getEditor()->save($this->id);
}
}

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla! CMS.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 3.0
*/
class JFormFieldHeadertag extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.0
*/
protected $type = 'HeaderTag';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.0
*/
protected function getOptions()
{
$options = array();
$tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p');
// Create one new option object for each tag
foreach ($tags as $tag)
{
$tmp = JHtml::_('select.option', $tag, $tag);
$options[] = $tmp;
}
reset($options);
return $options;
}
}

View File

@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a select list of help sites.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6.0
*/
class JFormFieldHelpsite extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6.0
*/
public $type = 'Helpsite';
/**
* Method to get the help site field options.
*
* @return array The field option objects.
*
* @since 1.6.0
*/
protected function getOptions()
{
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), JHelp::createSiteList(JPATH_ADMINISTRATOR . '/help/helpsites.xml', $this->value));
return $options;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,239 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Provides a modal media selector including upload mechanism
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6
*/
class JFormFieldMedia extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Media';
/**
* The initialised state of the document object.
*
* @var boolean
* @since 1.6
*/
protected static $initialised = false;
/**
* Method to get the field input markup for a media selector.
* Use attributes to identify specific created_by and asset_id fields
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
$authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by';
$asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id'];
if ($asset == '')
{
$asset = JFactory::getApplication()->input->get('option');
}
$link = (string) $this->element['link'];
if (!self::$initialised)
{
// Load the modal behavior script.
JHtml::_('behavior.modal');
// Build the script.
$script = array();
$script[] = ' function jInsertFieldValue(value, id) {';
$script[] = ' var old_value = document.id(id).value;';
$script[] = ' if (old_value != value) {';
$script[] = ' var elem = document.id(id);';
$script[] = ' elem.value = value;';
$script[] = ' elem.fireEvent("change");';
$script[] = ' if (typeof(elem.onchange) === "function") {';
$script[] = ' elem.onchange();';
$script[] = ' }';
$script[] = ' jMediaRefreshPreview(id);';
$script[] = ' }';
$script[] = ' }';
$script[] = ' function jMediaRefreshPreview(id) {';
$script[] = ' var value = document.id(id).value;';
$script[] = ' var img = document.id(id + "_preview");';
$script[] = ' if (img) {';
$script[] = ' if (value) {';
$script[] = ' img.src = "' . JUri::root() . '" + value;';
$script[] = ' document.id(id + "_preview_empty").setStyle("display", "none");';
$script[] = ' document.id(id + "_preview_img").setStyle("display", "");';
$script[] = ' } else { ';
$script[] = ' img.src = ""';
$script[] = ' document.id(id + "_preview_empty").setStyle("display", "");';
$script[] = ' document.id(id + "_preview_img").setStyle("display", "none");';
$script[] = ' } ';
$script[] = ' } ';
$script[] = ' }';
$script[] = ' function jMediaRefreshPreviewTip(tip)';
$script[] = ' {';
$script[] = ' var img = tip.getElement("img.media-preview");';
$script[] = ' tip.getElement("div.tip").setStyle("max-width", "none");';
$script[] = ' var id = img.getProperty("id");';
$script[] = ' id = id.substring(0, id.length - "_preview".length);';
$script[] = ' jMediaRefreshPreview(id);';
$script[] = ' tip.setStyle("display", "block");';
$script[] = ' }';
// Add the script to the document head.
JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
self::$initialised = true;
}
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
// The text field.
$html[] = '<div class="input-prepend input-append">';
// The Preview.
$preview = (string) $this->element['preview'];
$showPreview = true;
$showAsTooltip = false;
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);
break;
}
if ($showPreview)
{
if ($this->value && file_exists(JPATH_ROOT . '/' . $this->value))
{
$src = JUri::root() . $this->value;
}
else
{
$src = '';
}
$width = isset($this->element['preview_width']) ? (int) $this->element['preview_width'] : 300;
$height = isset($this->element['preview_height']) ? (int) $this->element['preview_height'] : 200;
$style = '';
$style .= ($width > 0) ? 'max-width:' . $width . 'px;' : '';
$style .= ($height > 0) ? 'max-height:' . $height . 'px;' : '';
$imgattr = array(
'id' => $this->id . '_preview',
'class' => 'media-preview',
'style' => $style,
);
$img = JHtml::image($src, JText::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgattr);
$previewImg = '<div id="' . $this->id . '_preview_img"' . ($src ? '' : ' style="display:none"') . '>' . $img . '</div>';
$previewImgEmpty = '<div id="' . $this->id . '_preview_empty"' . ($src ? ' style="display:none"' : '') . '>'
. JText::_('JLIB_FORM_MEDIA_PREVIEW_EMPTY') . '</div>';
if ($showAsTooltip)
{
$html[] = '<div class="media-preview add-on">';
$tooltip = $previewImgEmpty . $previewImg;
$options = array(
'title' => JText::_('JLIB_FORM_MEDIA_PREVIEW_SELECTED_IMAGE'),
'text' => '<i class="icon-eye"></i>',
'class' => 'hasTipPreview'
);
$html[] = JHtml::tooltip($tooltip, $options);
$html[] = '</div>';
}
else
{
$html[] = '<div class="media-preview add-on" style="height:auto">';
$html[] = ' ' . $previewImgEmpty;
$html[] = ' ' . $previewImg;
$html[] = '</div>';
}
}
$html[] = ' <input type="text" class="input-small" name="' . $this->name . '" id="' . $this->id . '" value="'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" readonly="readonly"' . $attr . ' />';
$directory = (string) $this->element['directory'];
if ($this->value && file_exists(JPATH_ROOT . '/' . $this->value))
{
$folder = explode('/', $this->value);
$folder = array_diff_assoc($folder, explode('/', JComponentHelper::getParams('com_media')->get('image_path', 'images')));
array_pop($folder);
$folder = implode('/', $folder);
}
elseif (file_exists(JPATH_ROOT . '/' . JComponentHelper::getParams('com_media')->get('image_path', 'images') . '/' . $directory))
{
$folder = $directory;
}
else
{
$folder = '';
}
// The button.
if ($this->element['disabled'] != true)
{
JHtml::_('bootstrap.tooltip');
$html[] = '<a class="modal btn" title="' . JText::_('JLIB_FORM_BUTTON_SELECT') . '" href="'
. ($this->element['readonly'] ? ''
: ($link ? $link
: 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;asset=' . $asset . '&amp;author='
. $this->form->getValue($authorField)) . '&amp;fieldid=' . $this->id . '&amp;folder=' . $folder) . '"'
. ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
$html[] = JText::_('JLIB_FORM_BUTTON_SELECT') . '</a><a class="btn hasTooltip" title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '" href="#" onclick="';
$html[] = 'jInsertFieldValue(\'\', \'' . $this->id . '\');';
$html[] = 'return false;';
$html[] = '">';
$html[] = '<i class="icon-remove"></i></a>';
}
$html[] = '</div>';
return implode("\n", $html);
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
// Import the com_menus helper.
require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
/**
* Supports an HTML select list of menus
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6
*/
class JFormFieldMenu extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'Menu';
/**
* Method to get the list of menus for the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
protected function getOptions()
{
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), JHtml::_('menu.menus'));
return $options;
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('groupedlist');
// Import the com_menus helper.
require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
/**
* Supports an HTML grouped select list of menu item grouped by menu
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6
*/
class JFormFieldMenuitem extends JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'MenuItem';
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
$groups = array();
// Initialize some field attributes.
$menuType = (string) $this->element['menu_type'];
$published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
$disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
$language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array();
// Get the menu items.
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language);
// Build group for a specific menu type.
if ($menuType)
{
// Initialize the group.
$groups[$menuType] = array();
// Build the options array.
foreach ($items as $link)
{
$groups[$menuType][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
// Build groups for all menu types.
else
{
// Build the groups arrays.
foreach ($items as $menu)
{
// Initialize the group.
$groups[$menu->menutype] = array();
// Build the options array.
foreach ($menu->links as $link)
{
$groups[$menu->menutype][] = JHtml::_(
'select.option', $link->value, $link->text, 'value', 'text',
in_array($link->type, $disable)
);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}

View File

@ -0,0 +1,96 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
/**
* Form Field class for the Joomla! CMS.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6
*/
class JFormFieldModuleOrder extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ModuleOrder';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
$html[] = '<script type="text/javascript">';
$ordering = $this->form->getValue('ordering');
$position = $this->form->getValue('position');
$clientId = $this->form->getValue('client_id');
$html[] = 'var originalOrder = "' . $ordering . '";';
$html[] = 'var originalPos = "' . $position . '";';
$html[] = 'var orders = new Array();';
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('position, ordering, title')
->from('#__modules')
->where('client_id = ' . (int) $clientId)
->order('ordering');
$db->setQuery($query);
try
{
$orders = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
$orders2 = array();
for ($i = 0, $n = count($orders); $i < $n; $i++)
{
if (!isset($orders2[$orders[$i]->position]))
{
$orders2[$orders[$i]->position] = 0;
}
$orders2[$orders[$i]->position]++;
$ord = $orders2[$orders[$i]->position];
$title = JText::sprintf('COM_MODULES_OPTION_ORDER_POSITION', $ord, addslashes($orders[$i]->title));
$html[] = 'orders[' . $i . '] = new Array("' . $orders[$i]->position . '","' . $ord . '","' . $title . '");';
}
$html[] = 'writeDynaList(\'name="' . $this->name . '" id="' . $this->id . '"' . $attr . '\', orders, originalPos, originalPos, originalOrder);';
$html[] = '</script>';
return implode("\n", $html);
}
}

View File

@ -0,0 +1,86 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
JFormHelper::loadFieldClass('text');
/**
* Form Field class for the Joomla! CMS.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6
*/
class JFormFieldModulePosition extends JFormFieldText
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ModulePosition';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
// Get the client id.
$clientId = $this->element['client_id'];
if (!isset($clientId))
{
$clientName = $this->element['client'];
if (isset($clientName))
{
$client = JApplicationHelper::getClientInfo($clientName, true);
$clientId = $client->id;
}
}
if (!isset($clientId) && $this->form instanceof JForm)
{
$clientId = $this->form->getValue('client_id');
}
$clientId = (int) $clientId;
// Load the modal behavior script.
JHtml::_('behavior.modal', 'a.modal');
// Build the script.
$script = array();
$script[] = ' function jSelectPosition_' . $this->id . '(name) {';
$script[] = ' document.id("' . $this->id . '").value = name;';
$script[] = ' SqueezeBox.close();';
$script[] = ' }';
// Add the script to the document head.
JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
// Setup variables for display.
$html = array();
$link = 'index.php?option=com_modules&view=positions&layout=modal&tmpl=component&function=jSelectPosition_' . $this->id . '&amp;client_id=' . $clientId;
// The current user display field.
$html[] = '<div class="input-append">';
$html[] = parent::getInput()
. '<a class="btn modal" title="' . JText::_('COM_MODULES_CHANGE_POSITION_TITLE') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'
. '<i class="icon-screenshot"></i> '
. JText::_('COM_MODULES_CHANGE_POSITION_BUTTON') . '</a>';
$html[] = '</div>';
return implode("\n", $html);
}
}

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla! CMS.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 3.0
*/
class JFormFieldModuletag extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.0
*/
protected $type = 'ModuleTag';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.0
*/
protected function getOptions()
{
$options = array();
$tags = array('div', 'section', 'aside', 'nav', 'address', 'article');
// Create one new option object for each tag
foreach ($tags as $tag)
{
$tmp = JHtml::_('select.option', $tag, $tag);
$options[] = $tmp;
}
reset($options);
return $options;
}
}

View File

@ -0,0 +1,241 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 3.1
*/
class JFormFieldTag extends JFormFieldList
{
/**
* A flexible tag list that respects access controls
*
* @var string
* @since 3.1
*/
public $type = 'Tag';
/**
* Flag to work with nested tag field
*
* @var boolean
* @since 3.1
*/
public $isNested = null;
/**
* com_tags parameters
*
* @var JRegistry
* @since 3.1
*/
protected $comParams = null;
/**
* Constructor
*
* @since 3.1
*/
public function __construct()
{
parent::__construct();
// Load com_tags config
$this->comParams = JComponentHelper::getParams('com_tags');
}
/**
* Method to get the field input for a tag field.
*
* @return string The field input.
*
* @since 3.1
*/
protected function getInput()
{
// AJAX mode requires ajax-chosen
if (!$this->isNested())
{
// Get the field id
$id = isset($this->element['id']) ? $this->element['id'] : null;
$cssId = '#' . $this->getId($id, $this->element['name']);
// Load the ajax-chosen customised field
JHtml::_('tag.ajaxfield', $cssId, $this->allowCustom());
}
if (!is_array($this->value) && !empty($this->value))
{
if ($this->value instanceof JHelperTags)
{
if (empty($this->value->tags))
{
$this->value = array();
}
else
{
$this->value = $this->value->tags;
}
}
// String in format 2,5,4
if (is_string($this->value))
{
$this->value = explode(',', $this->value);
}
}
$input = parent::getInput();
return $input;
}
/**
* Method to get a list of tags
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function getOptions()
{
$published = $this->element['published']? $this->element['published'] : array(0,1);
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value, a.path, a.title AS text, a.level, a.published')
->from('#__tags AS a')
->join('LEFT', $db->quoteName('#__tags') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// Ajax tag only loads assigned values
if (!$this->isNested())
{
// Only item assigned values
$values = (array) $this->value;
JArrayHelper::toInteger($values);
$query->where('a.id IN (' . implode(',', $values) . ')');
}
// Filter language
if (!empty($this->element['language']))
{
$query->where('a.language = ' . $db->quote($this->element['language']));
}
$query->where($db->quoteName('a.alias') . ' <> ' . $db->quote('root'));
// Filter on the published state
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif (is_array($published))
{
JArrayHelper::toInteger($published);
$query->where('a.published IN (' . implode(',', $published) . ')');
}
$query->group('a.id, a.title, a.level, a.lft, a.rgt, a.parent_id, a.published, a.path')
->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
return false;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
// Prepare nested data
if ($this->isNested())
{
$this->prepareOptionsNested($options);
}
else
{
$options = JHelperTags::convertPathsToNames($options);
}
return $options;
}
/**
* Add "-" before nested tags, depending on level
*
* @param array &$options Array of tags
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function prepareOptionsNested(&$options)
{
if ($options)
{
foreach ($options as &$option)
{
$repeat = (isset($option->level) && $option->level - 1 >= 0) ? $option->level - 1 : 0;
$option->text = str_repeat('- ', $repeat) . $option->text;
}
}
return $options;
}
/**
* Determine if the field has to be tagnested
*
* @return boolean
*
* @since 3.1
*/
public function isNested()
{
if (is_null($this->isNested))
{
// If mode="nested" || ( mode not set & config = nested )
if ((isset($this->element['mode']) && $this->element['mode'] == 'nested')
|| (!isset($this->element['mode']) && $this->comParams->get('tag_field_ajax_mode', 1) == 0))
{
$this->isNested = true;
}
}
return $this->isNested;
}
/**
* Determines if the field allows or denies custom values
*
* @return boolean
*/
public function allowCustom()
{
if (isset($this->element['custom']) && $this->element['custom'] == 'deny')
{
return false;
}
return true;
}
}

View File

@ -0,0 +1,103 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('groupedlist');
/**
* Form Field class for the Joomla CMS.
* Supports a select grouped list of template styles
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6
*/
class JFormFieldTemplatestyle extends JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'TemplateStyle';
/**
* Method to get the list of template style options
* grouped by template.
* Use the client attribute to specify a specific client.
* Use the template attribute to specify a specific template
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
$groups = array();
$lang = JFactory::getLanguage();
// Get the client and client_id.
$clientName = $this->element['client'] ? (string) $this->element['client'] : 'site';
$client = JApplicationHelper::getClientInfo($clientName, true);
// Get the template.
$template = (string) $this->element['template'];
// Get the database object and a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('s.id, s.title, e.name as name, s.template')
->from('#__template_styles as s')
->where('s.client_id = ' . (int) $client->id)
->order('template')
->order('title');
if ($template)
{
$query->where('s.template = ' . $db->quote($template));
}
$query->join('LEFT', '#__extensions as e on e.element=s.template')
->where('e.enabled=1')
->where($db->quoteName('e.type') . '=' . $db->quote('template'));
// Set the query and load the styles.
$db->setQuery($query);
$styles = $db->loadObjectList();
// Build the grouped list array.
if ($styles)
{
foreach ($styles as $style)
{
$template = $style->template;
$lang->load('tpl_' . $template . '.sys', $client->path, null, false, false)
|| $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, null, false, false)
|| $lang->load('tpl_' . $template . '.sys', $client->path, $lang->getDefault(), false, false)
|| $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, $lang->getDefault(), false, false);
$name = JText::_($style->name);
// Initialize the group if necessary.
if (!isset($groups[$name]))
{
$groups[$name] = array();
}
$groups[$name][] = JHtml::_('select.option', $style->id, $style->title);
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Field to select a user id from a modal list.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6.0
*/
class JFormFieldUser extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6.0
*/
public $type = 'User';
/**
* Method to get the user field input markup.
*
* @return string The field input markup.
*
* @since 1.6.0
*/
protected function getInput()
{
$html = array();
$groups = $this->getGroups();
$excluded = $this->getExcluded();
$link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;field=' . $this->id
. (isset($groups) ? ('&amp;groups=' . base64_encode(json_encode($groups))) : '')
. (isset($excluded) ? ('&amp;excluded=' . base64_encode(json_encode($excluded))) : '');
// Initialize some field attributes.
$attr = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
// Initialize JavaScript field attributes.
$onchange = (string) $this->element['onchange'];
// Load the modal behavior script.
JHtml::_('behavior.modal', 'a.modal_' . $this->id);
// Build the script.
$script = array();
$script[] = ' function jSelectUser_' . $this->id . '(id, title) {';
$script[] = ' var old_id = document.getElementById("' . $this->id . '_id").value;';
$script[] = ' if (old_id != id) {';
$script[] = ' document.getElementById("' . $this->id . '_id").value = id;';
$script[] = ' document.getElementById("' . $this->id . '_name").value = title;';
$script[] = ' ' . $onchange;
$script[] = ' }';
$script[] = ' SqueezeBox.close();';
$script[] = ' }';
// Add the script to the document head.
JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
// Load the current username if available.
$table = JTable::getInstance('user');
if ($this->value)
{
$table->load($this->value);
}
else
{
$table->username = JText::_('JLIB_FORM_SELECT_USER');
}
// Create a dummy text field with the user name.
$html[] = '<div class="input-append">';
$html[] = ' <input class="input-medium" type="text" id="' . $this->id . '_name" value="' . htmlspecialchars($table->name, ENT_COMPAT, 'UTF-8') . '"'
. ' disabled="disabled"' . $attr . ' />';
// Create the user select button.
if ($this->element['readonly'] != 'true')
{
$html[] = ' <a class="btn btn-primary modal_' . $this->id . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '" href="' . $link . '"'
. ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
$html[] = '<i class="icon-user"></i></a>';
}
$html[] = '</div>';
// Create the real field, hidden, that stored the user id.
$html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . (int) $this->value . '" />';
return implode("\n", $html);
}
/**
* Method to get the filtering groups (null means no filtering)
*
* @return mixed array of filtering groups or null.
*
* @since 1.6.0
*/
protected function getGroups()
{
return null;
}
/**
* Method to get the users to exclude from the list of users
*
* @return mixed Array of users to exclude or null to to not exclude them
*
* @since 1.6.0
*/
protected function getExcluded()
{
return null;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,67 @@
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Rule class for the Joomla Framework.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 2.5
*/
class JFormRuleCaptcha extends JFormRule
{
/**
* Method to test if the Captcha is correct.
*
* @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 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 JRegistry $input An optional JRegistry 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 2.5
*/
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
$plugin = $element['plugin'] ?: JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha', 0));
$namespace = $element['namespace'] ?: $form->getName();
// Use 0 for none
if ($plugin === 0 || $plugin === '0')
{
return true;
}
else
{
$captcha = JCaptcha::getInstance($plugin, array('namespace' => (string) $namespace));
}
// Test the value.
if (!$captcha->checkAnswer($value))
{
$error = $captcha->getError();
if ($error instanceof Exception)
{
return $error;
}
else
{
return new JException($error);
}
}
return true;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,68 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Rule class for the Joomla Platform.
*
* @package Joomla.Platform
* @subpackage Form
* @since 11.1
*/
class JFormRuleNotequals extends JFormRule
{
/**
* Method to test if two values are not equal. To use this rule, the form
* XML needs a validate attribute of equals and a field attribute
* that is equal to the field to test against.
*
* @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 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 JRegistry $input An optional JRegistry 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 11.1
* @throws InvalidArgumentException
* @throws UnexpectedValueException
*/
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
$field = (string) $element['field'];
// Check that a validation field is set.
if (!$field)
{
throw new UnexpectedValueException(sprintf('$field empty in %s::test', get_class($this)));
}
if (is_null($form))
{
throw new InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this)));
}
if (is_null($input))
{
throw new InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this)));
}
// Test the two values against each other.
if ($value != $input->get($field))
{
return true;
}
return false;
}
}

View File

@ -0,0 +1,178 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Rule class for the Joomla Platform.
*
* @package Joomla.Libraries
* @subpackage Form
* @since 3.1.2
*/
class JFormRulePassword extends JFormRule
{
/**
* Method to test if two values are not equal. To use this rule, the form
* XML needs a validate attribute of equals and a field attribute
* that is equal to the field to test against.
*
* @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 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 JRegistry $input An optional JRegistry 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.1.2
* @throws InvalidArgumentException
* @throws UnexpectedValueException
*/
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
$field = (string) $element['field'];
$meter = isset($this->element['strengthmeter']) ? ' meter="0"' : '1';
$threshold = isset($this->element['threshold']) ? (int) $this->element['threshold'] : 66;
$minimumLength = isset($this->element['minimum_length']) ? (int) $this->element['minimum_length'] : 4;
$minimumIntegers = isset($this->element['minimum_integers']) ? (int) $this->element['minimum_integers'] : 0;
$minimumSymbols = isset($this->element['minimum_symbols']) ? (int) $this->element['minimum_symbols'] : 0;
$minimumUppercase = isset($this->element['minimum_uppercase']) ? (int) $this->element['minimum_uppercase'] : 0;
// If we have parameters from com_users, use those instead.
// Some of these may be empty for legacy reasons.
$params = JComponentHelper::getParams('com_users');
if (!empty($params))
{
$minimumLengthp = $params->get('minimum_length');
$minimumIntegersp = $params->get('minimum_integers');
$minimumSymbolsp = $params->get('minimum_symbols');
$minimumUppercasep = $params->get('minimum_uppercase');
$meterp = $params->get('meter');
$thresholdp = $params->get('threshold');
empty($minimumLengthp) ? : $minimumLength = (int) $minimumLengthp;
empty($minimumIntegersp) ? : $minimumIntegers = (int) $minimumIntegersp;
empty($minimumSymbolsp) ? : $minimumSymbols = (int) $minimumSymbolsp;
empty($minimumUppercasep) ? : $minimumUppercase = (int) $minimumUppercasep;
empty($meterp) ? : $meter = $meterp;
empty($thresholdp) ? : $threshold = $thresholdp;
}
// If the field is empty and not required, the field is valid.
$required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required');
if (!$required && empty($value))
{
return true;
}
$valueLength = strlen($value);
// We set a maximum length to prevent abuse since it is unfiltered.
if ($valueLength > 99)
{
JFactory::getApplication()->enqueueMessage(
JText::_('COM_USERS_MSG_PASSWORD_TOO_LONG'),
'warning'
);
}
// We don't allow white space inside passwords
$valueTrim = trim($value);
// Set a variable to check if any errors are made in password
$validPassword = true;
if (strlen($valueTrim) != $valueLength)
{
JFactory::getApplication()->enqueueMessage(
JText::_('COM_USERS_MSG_SPACES_IN_PASSWORD'),
'warning'
);
$validPassword = false;
}
// Minimum number of integers required
if (!empty($minimumIntegers))
{
$nInts = preg_match_all('/[0-9]/', $value, $imatch);
if ($nInts < $minimumIntegers)
{
JFactory::getApplication()->enqueueMessage(
JText::plural('COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N', $minimumIntegers),
'warning'
);
$validPassword = false;
}
}
// Minimum number of symbols required
if (!empty($minimumSymbols))
{
$nsymbols = preg_match_all('[\W]', $value, $smatch);
if ($nsymbols < $minimumSymbols)
{
JFactory::getApplication()->enqueueMessage(
JText::plural('COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N', $minimumSymbols),
'warning'
);
$validPassword = false;
}
}
// Minimum number of upper case ASII characters required
if (!empty($minimumUppercase))
{
$nUppercase = preg_match_all("/[A-Z]/", $value, $umatch);
if ($nUppercase < $minimumUppercase)
{
JFactory::getApplication()->enqueueMessage(
JText::plural('COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N', $minimumUppercase),
'warning'
);
$validPassword = false;
}
}
// Minimum length option
if (!empty($minimumLength))
{
if (strlen((string) $value) < $minimumLength)
{
JFactory::getApplication()->enqueueMessage(
JText::plural('COM_USERS_MSG_PASSWORD_TOO_SHORT_N', $minimumLength),
'warning'
);
$validPassword = false;
}
}
// If valid has violated any rules above return false.
if (!$validPassword)
{
return false;
}
return true;
}
}