Minor - format code.

1.9.x
Julio Montoya 10 years ago
parent 367621620a
commit f6432eed0c
  1. 80
      main/inc/lib/extra_field.lib.php
  2. 17
      main/inc/lib/extra_field_option.lib.php

@ -121,6 +121,9 @@ class ExtraField extends Model
$this->pageName = get_lang(ucwords($this->type).'Fields');
}
/**
* @return array
*/
static function getValidExtraFieldTypes()
{
return array(
@ -132,6 +135,9 @@ class ExtraField extends Model
);
}
/**
* @return int
*/
public function get_count()
{
$row = Database::select('count(*) as count', $this->table, array(), 'first');
@ -139,6 +145,12 @@ class ExtraField extends Model
return $row['count'];
}
/**
* @param array $where_conditions
* @param null $order_field_options_by
*
* @return array
*/
public function get_all($where_conditions = array(), $order_field_options_by = null)
{
$options = Database::select(
@ -161,7 +173,10 @@ class ExtraField extends Model
return $options;
}
/**
* @param $field_variable
* @return array|bool
*/
public function get_handler_field_info_by_field_variable($field_variable)
{
$field_variable = Database::escape_string($field_variable);
@ -176,6 +191,9 @@ class ExtraField extends Model
}
}
/**
* @return int
*/
public function get_max_field_order()
{
$sql = "SELECT MAX(field_order) FROM {$this->table}";
@ -190,6 +208,10 @@ class ExtraField extends Model
return $order;
}
/**
* @param $handler
* @return array
*/
public static function get_extra_fields_by_handler($handler)
{
$types = array();
@ -222,6 +244,7 @@ class ExtraField extends Model
*
* @param FormValidator $form
* @param int $item_id
*
* @return array|bool
*/
public function addElements($form, $item_id = null)
@ -253,8 +276,8 @@ class ExtraField extends Model
}
/**
*
* @param int $item_id (session_id, question_id, course id)
*
* @return array
*/
public function get_handler_extra_data($item_id)
@ -303,10 +326,16 @@ class ExtraField extends Model
return $extra_data;
}
/**
* @param string $field_type
*
* @return array
*/
public function get_all_extra_field_by_type($field_type)
{
// all the information of the field
$sql = "SELECT * FROM {$this->table} WHERE field_type='".Database::escape_string($field_type)."'";
$sql = "SELECT * FROM {$this->table}
WHERE field_type = '".Database::escape_string($field_type)."'";
$result = Database::query($sql);
$return = array();
while ($row = Database::fetch_array($result)) {
@ -316,12 +345,19 @@ class ExtraField extends Model
return $return;
}
/**
* @return array
*/
public function get_field_types()
{
return self::get_extra_fields_by_handler($this->type);
}
/**
* @param int $id
*
* @return null
*/
public function get_field_type_by_id($id)
{
$types = self::get_field_types();
@ -338,6 +374,7 @@ class ExtraField extends Model
* into
* array('France' => array('Paris', 'Bregtane', 'Marseilles'), 'Belgique' => array('Namur', 'Liège', etc
* @param string $string
*
* @return array
*/
static function extra_field_double_select_convert_string_to_array($string)
@ -357,6 +394,10 @@ class ExtraField extends Model
return $options_parsed;
}
/**
* @param array $options
* @return array
*/
static function extra_field_double_select_convert_array_to_ordered_array($options)
{
$options_parsed = array();
@ -374,7 +415,9 @@ class ExtraField extends Model
}
/**
* @param array options the result of the get_field_options_by_field() array
* @param array $options the result of the get_field_options_by_field() array
*
* @return string
*/
static function extra_field_double_select_convert_array_to_string($options)
{
@ -406,6 +449,7 @@ class ExtraField extends Model
/**
* @param array $params
*
* @return array
*/
public function clean_parameters($params)
@ -425,6 +469,7 @@ class ExtraField extends Model
/**
* @param array $params
* @param bool $show_query
*
* @return bool
*/
public function save($params, $show_query = false)
@ -448,7 +493,10 @@ class ExtraField extends Model
}
}
/**
* @param $params
* @return bool|void
*/
public function update($params)
{
$params = self::clean_parameters($params);
@ -460,6 +508,10 @@ class ExtraField extends Model
parent::update($params);
}
/**
* @param $id
* @return bool|void
*/
public function delete($id)
{
parent::delete($id);
@ -1103,6 +1155,9 @@ EOF;
echo Display::grid_html($this->type.'_fields');
}
/**
* @return array
*/
public function getJqgridColumnNames()
{
return array(
@ -1117,6 +1172,9 @@ EOF;
);
}
/**
* @return array
*/
public function getJqgridColumnModel()
{
return array(
@ -1305,6 +1363,10 @@ EOF;
return $form;
}
/**
* @param $token
* @return string
*/
public function getJqgridActionLinks($token)
{
//With this function we can add actions to the jgrid (edit, delete, etc)
@ -1559,7 +1621,6 @@ EOF;
);
}
//@todo move this in the display_class or somewhere else
/**
* @param $col
@ -1587,6 +1648,11 @@ EOF;
return " $col {$this->ops[$oper]} '$val' ";
}
/**
* @param $filters
* @param string $stringToSearch
* @return array
*/
public function getExtraFieldRules($filters, $stringToSearch = 'extra_')
{
$extra_fields = array();

@ -8,7 +8,14 @@
class ExtraFieldOption extends Model
{
public $columns = array(
'id', 'field_id', 'option_value', 'option_display_text', 'option_order', 'priority', 'priority_message', 'tms'
'id',
'field_id',
'option_value',
'option_display_text',
'option_order',
'priority',
'priority_message',
'tms'
);
/**
@ -51,7 +58,7 @@ class ExtraFieldOption extends Model
/**
* Gets the number of options available for this field
* @param int Field ID
* @param int $field_id
* @return int Number of options
* @assert ('') === false
* @assert (-1) == 0
@ -98,7 +105,7 @@ class ExtraFieldOption extends Model
/**
* Delete all the options of a specific field
* @param int Field ID
* @param int $field_id
* @result void
* @assert (-1) === false
*/
@ -383,7 +390,8 @@ class ExtraFieldOption extends Model
{
$field_id = intval($field_id);
$sql = "SELECT * FROM {$this->table} WHERE field_id = $field_id ";
$sql = "SELECT * FROM {$this->table}
WHERE field_id = $field_id ";
if (!empty($ordered_by)) {
$sql .= " ORDER BY $ordered_by ";
@ -511,7 +519,6 @@ class ExtraFieldOption extends Model
{
// action links
echo '<div class="actions">';
//echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'', ICON_SIZE_MEDIUM).'</a>';
$field_id = isset($_REQUEST['field_id']) ? intval($_REQUEST['field_id']) : null;
echo '<a href="'.api_get_self(
).'?action=add&type='.$this->type.'&field_id='.$field_id.'">'.Display::return_icon(

Loading…
Cancel
Save