diff --git a/main/inc/lib/extra_field.lib.php b/main/inc/lib/extra_field.lib.php
index b788ea65b4..2e95ba8511 100755
--- a/main/inc/lib/extra_field.lib.php
+++ b/main/inc/lib/extra_field.lib.php
@@ -20,9 +20,8 @@ class ExtraField extends Model
'changeable',
'filter',
'extra_field_type',
- /* Enable this when field_loggeable is introduced as a table field (2.0)
- 'field_loggeable',
- */
+ //Enable this when field_loggeable is introduced as a table field (2.0)
+ //'field_loggeable',
'created_at'
);
@@ -137,7 +136,7 @@ class ExtraField extends Model
break;
}
- $this->pageUrl = 'extra_fields.php?type='.$this->type;
+ $this->pageUrl = 'extra_fields.php?type='.$this->type;
// Example QuestionFields
$this->pageName = get_lang(ucwords($this->type).'Fields');
}
@@ -228,13 +227,14 @@ class ExtraField extends Model
->orderBy($sidx, $sord)
->setFirstResult($start)
->setMaxResults($limit);
+
//echo $query->getQuery()->getSQL();
return $query->getQuery()->getArrayResult();
}
/**
* @param array $conditions
- * @param null $order_field_options_by
+ * @param null $order_field_options_by
*
* @return array
*/
@@ -759,7 +759,7 @@ class ExtraField extends Model
/**
* @param array $params
- * @param bool $show_query
+ * @param bool $show_query
*
* @return bool
*/
@@ -1029,7 +1029,8 @@ class ExtraField extends Model
if ($optionsExists) {
if (isset($userInfo['status']) && !empty($userInfo['status'])) {
- $fieldWorkFlow = $app['orm.em']->getRepository('ChamiloLMS\Entity\ExtraFieldOptionRelFieldOption')
+ $fieldWorkFlow = $app['orm.em']
+ ->getRepository('ChamiloLMS\Entity\ExtraFieldOptionRelFieldOption')
->findBy(
array(
'fieldId' => $field_details['id'],
@@ -1075,8 +1076,8 @@ class ExtraField extends Model
}
if (isset($optionList[$defaultValueId])) {
- if (isset($optionList[$defaultValueId]['option_value']) &&
- $optionList[$defaultValueId]['option_value'] == 'aprobada'
+ if (isset($optionList[$defaultValueId]['option_value'])
+ && $optionList[$defaultValueId]['option_value'] == 'aprobada'
) {
// @todo function don't exists api_is_question_manager
/*if (api_is_question_manager() == false) {
@@ -1086,8 +1087,8 @@ class ExtraField extends Model
}
// Setting priority message
- if (isset($optionList[$defaultValueId]) &&
- isset($optionList[$defaultValueId]['priority'])
+ if (isset($optionList[$defaultValueId])
+ && isset($optionList[$defaultValueId]['priority'])
) {
if (!empty($optionList[$defaultValueId]['priority'])) {
$priorityId = $optionList[$defaultValueId]['priority'];
@@ -1289,7 +1290,9 @@ class ExtraField extends Model
@@ -1423,19 +1426,23 @@ class ExtraField extends Model
break;
case self::FIELD_TYPE_SOCIAL_PROFILE:
// get the social network's favicon
- $extra_data_variable = isset($extraData['extra_'.$field_details['variable']]) ? $extraData['extra_'.$field_details['variable']] : null;
- $field_default_value = isset($field_details['field_default_value']) ? $field_details['field_default_value'] : null;
+ $extra_data_variable = isset($extraData['extra_'.$field_details['variable']])
+ ? $extraData['extra_'.$field_details['variable']]
+ : null;
+ $field_default_value = isset($field_details['field_default_value'])
+ ? $field_details['field_default_value']
+ : null;
$icon_path = UserManager::get_favicon_from_url(
$extra_data_variable,
$field_default_value
);
// special hack for hi5
$leftpad = '1.7';
- $top = '0.4';
- $domain = parse_url($icon_path, PHP_URL_HOST);
+ $top = '0.4';
+ $domain = parse_url($icon_path, PHP_URL_HOST);
if ($domain == 'www.hi5.com' or $domain == 'hi5.com') {
$leftpad = '3';
- $top = '0';
+ $top = '0';
}
// print the input field
$form->addElement(
@@ -1443,8 +1450,16 @@ class ExtraField extends Model
'extra_'.$field_details['variable'],
$field_details['display_text'],
array(
- 'size' => 60,
- 'style' => 'background-image: url(\''.$icon_path.'\'); background-repeat: no-repeat; background-position: 0.4em '.$top.'em; padding-left: '.$leftpad.'em; '
+ 'size' => 60,
+ 'size' => implode(
+ '; ',
+ [
+ "background-image: url('$icon_path')",
+ 'background-repeat: no-repeat',
+ "background-position: 0.4em {$top}em",
+ "padding-left: {$leftpad}em"
+ ]
+ )
)
);
$form->applyFilter('extra_'.$field_details['variable'], 'stripslashes');
@@ -1551,8 +1566,8 @@ class ExtraField extends Model
$field_details['display_text']
);
- if (is_array($extraData) &&
- array_key_exists($fieldVariable, $extraData)
+ if (is_array($extraData)
+ && array_key_exists($fieldVariable, $extraData)
) {
if (file_exists(api_get_path(SYS_UPLOAD_PATH).$extraData[$fieldVariable])) {
$fieldTexts[] = Display::url(
@@ -1655,47 +1670,52 @@ class ExtraField extends Model
$form->freeze('extra_'.$field_details['variable']);
}
- $form->addHtml(
- '
- ');
+ ");
$form->addHtml('
');
@@ -1773,7 +1806,8 @@ class ExtraField extends Model
'.$field_details['display_text'].' - '.get_lang('Map').'
-
@@ -1805,53 +1839,57 @@ class ExtraField extends Model
$lng = $latLag[1];
}
- $form->addHtml(
- '
- ');
+ ");
$form->addHtml('
');
@@ -1929,7 +1981,9 @@ class ExtraField extends Model
'.$field_details['display_text'].' - '.get_lang('Map').'
-
@@ -2043,7 +2097,7 @@ class ExtraField extends Model
'align' => 'left',
'sortable' => 'true',
),
- array(
+ array(
'name' => 'visible_to_others',
'index' => 'visible_to_others',
'width' => '35',
@@ -2089,7 +2143,7 @@ class ExtraField extends Model
$form->addElement('hidden', 'id', $id);
// Setting the form elements
- $header = get_lang('Add');
+ $header = get_lang('Add');
$defaults = array();
if ($action == 'edit') {
@@ -2101,9 +2155,8 @@ class ExtraField extends Model
$form->addElement('header', $header);
if ($action == 'edit') {
- $translateUrl = api_get_path(WEB_CODE_PATH).'extrafield/translate.php?'.http_build_query([
- 'extra_field' => $id
- ]);
+ $translateUrl = api_get_path(WEB_CODE_PATH).'extrafield/translate.php?'
+ .http_build_query(['extra_field' => $id]);
$translateButton = Display::toolbarButton(get_lang('TranslateThisTerm'), $translateUrl, 'language', 'link');
$form->addText(
@@ -2177,12 +2230,12 @@ class ExtraField extends Model
$group[] = $form->createElement('radio', 'visible_to_others', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('VisibleToOthers'), null, false);
- $group = array();
+ $group = array();
$group[] = $form->createElement('radio', 'changeable', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'changeable', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('FieldChangeability'), null, false);
- $group = array();
+ $group = array();
$group[] = $form->createElement('radio', 'filter', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'filter', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('FieldFilter'), null, false);
@@ -2260,8 +2313,8 @@ JAVASCRIPT;
/**
* @param array $columns
- * @param array $column_model
- * @param array $extraFields
+ * @param array $column_model
+ * @param array $extraFields
* @return array
*/
public function getRules(&$columns, &$column_model, $extraFields = array(), $checkExtraFieldExistence = false)
@@ -2277,18 +2330,19 @@ JAVASCRIPT;
$rules = array();
if (!empty($fields)) {
foreach ($fields as $field) {
-
$search_options = array();
- $type = 'text';
+ $type = 'text';
if (in_array($field['field_type'], array(self::FIELD_TYPE_SELECT, self::FIELD_TYPE_DOUBLE_SELECT))) {
- $type = 'select';
+ $type = 'select';
$search_options['sopt'] = array('eq', 'ne'); //equal not equal
} else {
$search_options['sopt'] = array('cn', 'nc'); //contains not contains
}
$search_options['searchhidden'] = 'true';
- $search_options['defaultValue'] = isset($search_options['field_default_value']) ? $search_options['field_default_value'] : null;
+ $search_options['defaultValue'] = isset($search_options['field_default_value'])
+ ? $search_options['field_default_value']
+ : null;
if ($field['field_type'] == self::FIELD_TYPE_DOUBLE_SELECT) {
//Add 2 selects
@@ -2300,7 +2354,8 @@ JAVASCRIPT;
foreach ($options as $option) {
foreach ($option as $sub_option) {
if ($sub_option['option_value'] == 0) {
- $first_options[] = $sub_option['field_id'].'#'.$sub_option['id'].':'.$sub_option['display_text'];
+ $first_options[] = $sub_option['field_id'].'#'.$sub_option['id'].':'
+ .$sub_option['display_text'];
}
}
}
@@ -2387,7 +2442,8 @@ JAVASCRIPT;
$extra_field_info = $extra_field_obj->get($extra['id']);
$extra['extra_field_info'] = $extra_field_info;
- if (isset($extra_field_info['field_type']) && in_array(
+ if (isset($extra_field_info['field_type'])
+ && in_array(
$extra_field_info['field_type'],
array(
self::FIELD_TYPE_SELECT,
@@ -2442,7 +2498,8 @@ JAVASCRIPT;
$inject_joins .= " INNER JOIN $this->table_field_values fv$counter
ON (s.".$this->primaryKey." = fv$counter.".$this->handler_id.") ";
// Add options
- if (isset($extra_field_info['field_type']) && in_array(
+ if (isset($extra_field_info['field_type'])
+ && in_array(
$extra_field_info['field_type'],
array(
self::FIELD_TYPE_SELECT,
@@ -2463,28 +2520,31 @@ JAVASCRIPT;
fv$counter.value = fvo$counter.option_value
)
";
- } else if (isset($extra_field_info['field_type']) &&
- $extra_field_info['field_type'] == self::FIELD_TYPE_TAG
- ) {
- $options['where'] = str_replace(
- $extra_info['field'],
- 'tag'.$counter.'.tag ',
- $options['where']
- );
-
- $inject_joins .= "
- INNER JOIN $this->table_field_rel_tag tag_rel$counter
- ON (tag_rel$counter.field_id = ".$extra_info['id']." AND tag_rel$counter.item_id = s.".$this->primaryKey.")
- INNER JOIN $this->table_field_tag tag$counter
- ON (tag$counter.id = tag_rel$counter.tag_id)
- ";
} else {
- //text, textarea, etc
- $options['where'] = str_replace(
- $extra_info['field'],
- 'fv'.$counter.'.field_id = '.$extra_info['id'].' AND fv'.$counter.'.value',
- $options['where']
- );
+ if (isset($extra_field_info['field_type'])
+ && $extra_field_info['field_type'] == self::FIELD_TYPE_TAG
+ ) {
+ $options['where'] = str_replace(
+ $extra_info['field'],
+ 'tag'.$counter.'.tag ',
+ $options['where']
+ );
+
+ $inject_joins .= "
+ INNER JOIN $this->table_field_rel_tag tag_rel$counter
+ ON (tag_rel$counter.field_id = ".$extra_info['id']." AND tag_rel$counter.item_id = s."
+ .$this->primaryKey.")
+ INNER JOIN $this->table_field_tag tag$counter
+ ON (tag$counter.id = tag_rel$counter.tag_id)
+ ";
+ } else {
+ //text, textarea, etc
+ $options['where'] = str_replace(
+ $extra_info['field'],
+ 'fv'.$counter.'.field_id = '.$extra_info['id'].' AND fv'.$counter.'.value',
+ $options['where']
+ );
+ }
}
$field_value_to_join[] = " fv$counter.$this->handler_id ";
@@ -2603,7 +2663,9 @@ JAVASCRIPT;
}
if (!isset($rule->data)) {
- $condition_array[] = ' ('.$this->get_where_clause($rule->field, $rule->op, $rule->data).') ';
+ $condition_array[] = ' ('
+ .$this->get_where_clause($rule->field, $rule->op, $rule->data)
+ .') ';
$extra_fields[] = array('field' => $rule->field, 'id' => $field_option['id']);
}
} else {
@@ -2611,7 +2673,9 @@ JAVASCRIPT;
if ($rule->data == -1) {
continue;
}
- $condition_array[] = ' ('.$this->get_where_clause($rule->field, $rule->op, $rule->data).') ';
+ $condition_array[] = ' ('
+ .$this->get_where_clause($rule->field, $rule->op, $rule->data)
+ .') ';
$extra_fields[] = array(
'field' => $rule->field,
'id' => $field_option['id'],