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

@ -8,7 +8,14 @@
class ExtraFieldOption extends Model class ExtraFieldOption extends Model
{ {
public $columns = array( 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 * Gets the number of options available for this field
* @param int Field ID * @param int $field_id
* @return int Number of options * @return int Number of options
* @assert ('') === false * @assert ('') === false
* @assert (-1) == 0 * @assert (-1) == 0
@ -98,7 +105,7 @@ class ExtraFieldOption extends Model
/** /**
* Delete all the options of a specific field * Delete all the options of a specific field
* @param int Field ID * @param int $field_id
* @result void * @result void
* @assert (-1) === false * @assert (-1) === false
*/ */
@ -383,7 +390,8 @@ class ExtraFieldOption extends Model
{ {
$field_id = intval($field_id); $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)) { if (!empty($ordered_by)) {
$sql .= " ORDER BY $ordered_by "; $sql .= " ORDER BY $ordered_by ";
@ -511,7 +519,6 @@ class ExtraFieldOption extends Model
{ {
// action links // action links
echo '<div class="actions">'; 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; $field_id = isset($_REQUEST['field_id']) ? intval($_REQUEST['field_id']) : null;
echo '<a href="'.api_get_self( echo '<a href="'.api_get_self(
).'?action=add&type='.$this->type.'&field_id='.$field_id.'">'.Display::return_icon( ).'?action=add&type='.$this->type.'&field_id='.$field_id.'">'.Display::return_icon(

Loading…
Cancel
Save