Minor - format code

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent ffbf8c0af1
commit 2a48183ba8
  1. 36
      main/inc/lib/formvalidator/Element/SelectLanguage.php
  2. 34
      main/inc/lib/formvalidator/Element/SelectTheme.php
  3. 8
      main/inc/lib/formvalidator/Element/Url.php
  4. 5
      main/inc/lib/formvalidator/Element/receivers.php
  5. 18
      main/inc/lib/formvalidator/Rule/Date.php
  6. 29
      main/inc/lib/formvalidator/Rule/FileName.php

@ -7,22 +7,22 @@
*/
class SelectLanguage extends HTML_QuickForm_select
{
/**
* Class constructor
*/
public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
{
parent::__construct($elementName, $elementLabel, $options, $attributes);
// Get all languages
$languages = api_get_languages();
$this->_options = array();
$this->_values = array();
foreach ($languages['name'] as $index => $name) {
if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
$this->addOption($name, $languages['folder'][$index], array('selected'=>'selected'));
} else {
$this->addOption($name, $languages['folder'][$index]);
}
}
}
/**
* Class constructor
*/
public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
{
parent::__construct($elementName, $elementLabel, $options, $attributes);
// Get all languages
$languages = api_get_languages();
$this->_options = array();
$this->_values = array();
foreach ($languages['name'] as $index => $name) {
if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
$this->addOption($name, $languages['folder'][$index], array('selected'=>'selected'));
} else {
$this->addOption($name, $languages['folder'][$index]);
}
}
}
}

@ -6,19 +6,23 @@
*/
class SelectTheme extends HTML_QuickForm_select
{
/**
* Class constructor
*/
public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null)
{
parent::__construct($elementName, $elementLabel, $options, $attributes);
// Get all languages
$themes = api_get_themes();
$this->_options = array();
$this->_values = array();
$this->addOption('--',''); // no theme select
for ($i=0; $i< count($themes[0]); $i++) {
$this->addOption($themes[1][$i],$themes[0][$i]);
}
}
/**
* Class constructor
*/
public function __construct(
$elementName = null,
$elementLabel = null,
$options = null,
$attributes = null
) {
parent::__construct($elementName, $elementLabel, $options, $attributes);
// Get all languages
$themes = api_get_themes();
$this->_options = array();
$this->_values = array();
$this->addOption('--', ''); // no theme select
for ($i = 0; $i < count($themes[0]); $i++) {
$this->addOption($themes[1][$i], $themes[0][$i]);
}
}
}

@ -9,10 +9,10 @@
class Url extends HTML_QuickForm_text
{
/**
* Constructor of Url class
* @param type $elementName
* @param type $elementLabel
* @param type $attributes
* Url constructor.
* @param string $elementName
* @param string $elementLabel
* @param array $attributes
*/
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
{

@ -37,6 +37,7 @@ class HTML_QuickForm_receivers extends HTML_QuickForm_group
$this->_appendName = true;
$this->_type = 'receivers';
}
/**
* Create the form elements to build this element group
*/
@ -48,6 +49,7 @@ class HTML_QuickForm_receivers extends HTML_QuickForm_group
$this->_elements[] = new HTML_QuickForm_advmultiselect('to', '', $this->receivers);
$this->_elements[2]->setSelected($this->receivers_selected);
}
/**
* HTML representation
*/
@ -91,5 +93,4 @@ class HTML_QuickForm_receivers extends HTML_QuickForm_group
{
$renderer->renderElement($this, $required, $error);
}
}
?>
}

@ -7,16 +7,16 @@
*/
class HTML_QuickForm_Rule_Date extends HTML_QuickForm_Rule
{
/**
* Check a date
* @see HTML_QuickForm_Rule
* @param string $date example 2014-04-30
/**
* Check a date
* @see HTML_QuickForm_Rule
* @param string $date example 2014-04-30
* @param array $options
*
* @return boolean True if date is valid
*/
public function validate($date, $options)
{
* @return boolean True if date is valid
*/
public function validate($date, $options)
{
return api_is_valid_date($date, 'Y-m-d');
}
}
}

@ -8,19 +8,18 @@
*/
class HTML_QuickForm_Rule_FileName extends HTML_QuickForm_Rule
{
/**
* @param $value array Uploaded file info (from $_FILES)
* @param null $options
* @return bool
*/
public function validate($value, $options = null)
{
if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
(!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
return is_uploaded_file($elementValue['tmp_name']);
} else {
return false;
}
}
/**
* @param $value array Uploaded file info (from $_FILES)
* @param null $options
* @return bool
*/
public function validate($value, $options = null)
{
if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
(!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
return is_uploaded_file($elementValue['tmp_name']);
} else {
return false;
}
}
}

Loading…
Cancel
Save