mirror of
https://github.com/e107inc/e107.git
synced 2025-04-22 13:41:52 +02:00
This commit is contained in:
parent
97772a48d9
commit
2bd651c630
@ -388,31 +388,36 @@ e107::js('footer-inline', js());
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Automatically exectured when edit mode is active.
|
||||
*/
|
||||
public function EditObserver()
|
||||
{
|
||||
parent::EditObserver();
|
||||
|
||||
$parms = e107::getDb()->retrieve('user_extended_struct', 'user_extended_struct_parms',"user_extended_struct_id = ".intval($_GET['id']));
|
||||
$tmp = explode('^,^', $parms);
|
||||
|
||||
$this->fields['field_include']['writeParms']['default'] = $tmp[0];
|
||||
$this->fields['field_regex']['writeParms']['default'] = $tmp[1];
|
||||
$this->fields['field_regexfail']['writeParms']['default'] = $tmp[2];
|
||||
$this->fields['field_userhide']['writeParms']['default'] = $tmp[3];
|
||||
$this->fields['field_placeholder']['writeParms']['default'] = $tmp[4];
|
||||
$this->fields['field_helptip']['writeParms']['default'] = $tmp[5];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if($this->getAction() == 'edit' || $this->getAction() == 'create')
|
||||
{
|
||||
$this->fields['user_extended_struct_type']['title'] = LAN_TYPE;
|
||||
}
|
||||
|
||||
if($this->getAction() == 'edit')
|
||||
{
|
||||
$parms = e107::getDb()->retrieve('user_extended_struct', 'user_extended_struct_parms',"user_extended_struct_id = ".intval($_GET['id']));
|
||||
$tmp = explode('^,^', $parms);
|
||||
|
||||
$this->fields['field_include']['writeParms']['default'] = $tmp[0];
|
||||
$this->fields['field_regex']['writeParms']['default'] = $tmp[1];
|
||||
$this->fields['field_regexfail']['writeParms']['default'] = $tmp[2];
|
||||
$this->fields['field_userhide']['writeParms']['default'] = $tmp[3];
|
||||
$this->fields['field_placeholder']['writeParms']['default'] = $tmp[4];
|
||||
$this->fields['field_helptip']['writeParms']['default'] = $tmp[5];
|
||||
}
|
||||
|
||||
$data = e107::getDb()->retrieve("user_extended_struct", "*", "user_extended_struct_type = 0 ORDER BY user_extended_struct_order ASC", true);
|
||||
|
||||
$opts = array();
|
||||
@ -447,7 +452,7 @@ e107::js('footer-inline', js());
|
||||
$new_data['user_extended_struct_parms'] = implode('^,^', $parms);
|
||||
}
|
||||
|
||||
if($new_data['user_extended_struct_values']==EUF_DB_FIELD)
|
||||
if($new_data['user_extended_struct_type'] == EUF_DB_FIELD)
|
||||
{
|
||||
$new_data['user_extended_struct_values'] = array($new_data['table_db'],$new_data['field_id'],$new_data['field_value'],$new_data['field_order']);
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ class e_db_mysql
|
||||
* @param boolean $multi if true, fetch all (multi mode)
|
||||
* @param string $indexField field name to be used for indexing when in multi mode
|
||||
* @param boolean $debug
|
||||
* @return array
|
||||
* @return string|array
|
||||
*/
|
||||
public function retrieve($table, $fields = null, $where=null, $multi = false, $indexField = null, $debug = false)
|
||||
{
|
||||
|
@ -862,106 +862,73 @@ class e107_user_extended
|
||||
|
||||
return $ret;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case EUF_CHECKBOX : //checkboxes
|
||||
case EUF_CHECKBOX : //checkboxes
|
||||
|
||||
// print_a($choices);
|
||||
if(!is_array($curval))
|
||||
{
|
||||
$curval = e107::unserialize($curval);
|
||||
}
|
||||
if(!is_array($curval))
|
||||
{
|
||||
$curval = e107::unserialize($curval);
|
||||
}
|
||||
|
||||
return e107::getForm()->checkboxes($fname.'[]',$choices, $curval, array('useLabelValues'=>1));
|
||||
|
||||
break;
|
||||
|
||||
return e107::getForm()->checkboxes($fname.'[]',$choices, $curval, array('useLabelValues'=>1));
|
||||
/*
|
||||
|
||||
foreach($choices as $choice)
|
||||
{
|
||||
case EUF_DROPDOWN : //dropdown
|
||||
$ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} {$title} >\n";
|
||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||
foreach($choices as $choice)
|
||||
{
|
||||
$choice = trim($choice);
|
||||
|
||||
if(strpos($choice,"|")!==FALSE)
|
||||
$choice = deftrue($choice, $choice);
|
||||
$sel = ($curval == $choice) ? " selected='selected' " : "";
|
||||
$ret .= "<option value='{$choice}' {$sel}>{$choice}</option>\n";
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
return $ret;
|
||||
break;
|
||||
|
||||
case EUF_PREDEFINED : // predefined list, shown in dropdown
|
||||
$listRoot = trim($struct['user_extended_struct_values']); // Base list name
|
||||
$filename = e_CORE.'sql/extended_'.$listRoot.'.php';
|
||||
if (!is_readable($filename)) return 'No file: '.$filename;
|
||||
require_once($filename);
|
||||
$className = 'extended_'.$listRoot;
|
||||
if (!class_exists($className)) return '?????';
|
||||
$temp = new $className();
|
||||
if (!method_exists($className, 'getValue')) return '???-???';
|
||||
$temp->pointerReset();
|
||||
|
||||
$ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} >\n";
|
||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chooses it.
|
||||
while (FALSE !== ($row = $temp->getValue(0, 'next')))
|
||||
{
|
||||
list($val,$label) = explode("|",$choice);
|
||||
$val = key($row);
|
||||
$choice = $temp->getValue($val, 'display');
|
||||
$sel = ($curval == $val) ? " selected='selected' " : '';
|
||||
$ret .= "<option value='{$val}' {$sel}>{$choice}</option>\n";
|
||||
}
|
||||
elseif(strpos($choice," => ")!==FALSE) // new in v2.x
|
||||
$ret .= "</select>\n";
|
||||
return $ret;
|
||||
|
||||
case EUF_DB_FIELD : //db_field
|
||||
|
||||
if(empty($choices))
|
||||
{
|
||||
list($val,$label) = explode(" => ",$choice);
|
||||
e107::getDebug()->log("DB Field Choices is empty");
|
||||
}
|
||||
else
|
||||
{
|
||||
$val = $choice;
|
||||
$label = $choice;
|
||||
}
|
||||
$label = deftrue($label, $label);
|
||||
|
||||
if(deftrue('BOOTSTRAP'))
|
||||
{
|
||||
$ret .= $frm->checkbox($fname.'[]',$val,($curval == $val), array('label'=>$label));
|
||||
}
|
||||
else
|
||||
{
|
||||
$chk = ($curval == $val)? " checked='checked' " : "";
|
||||
$ret .= "<input {$include} type='checkbox' name='{$fname}[]' value='{$val}' {$chk} /> {$label}<br />";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $ret;
|
||||
|
||||
*/
|
||||
|
||||
break;
|
||||
|
||||
case EUF_DROPDOWN : //dropdown
|
||||
$ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} {$title} >\n";
|
||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||
foreach($choices as $choice)
|
||||
{
|
||||
$choice = trim($choice);
|
||||
$choice = deftrue($choice, $choice);
|
||||
$sel = ($curval == $choice) ? " selected='selected' " : "";
|
||||
$ret .= "<option value='{$choice}' {$sel}>{$choice}</option>\n";
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
return $ret;
|
||||
break;
|
||||
|
||||
case EUF_PREDEFINED : // predefined list, shown in dropdown
|
||||
$listRoot = trim($struct['user_extended_struct_values']); // Base list name
|
||||
$filename = e_CORE.'sql/extended_'.$listRoot.'.php';
|
||||
if (!is_readable($filename)) return 'No file: '.$filename;
|
||||
require_once($filename);
|
||||
$className = 'extended_'.$listRoot;
|
||||
if (!class_exists($className)) return '?????';
|
||||
$temp = new $className();
|
||||
if (!method_exists($className, 'getValue')) return '???-???';
|
||||
$temp->pointerReset();
|
||||
|
||||
$ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} >\n";
|
||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chooses it.
|
||||
while (FALSE !== ($row = $temp->getValue(0, 'next')))
|
||||
{
|
||||
$val = key($row);
|
||||
$choice = $temp->getValue($val, 'display');
|
||||
$sel = ($curval == $val) ? " selected='selected' " : '';
|
||||
$ret .= "<option value='{$val}' {$sel}>{$choice}</option>\n";
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
return $ret;
|
||||
|
||||
case EUF_DB_FIELD : //db_field
|
||||
|
||||
|
||||
$sql = e107::getDb('ue');
|
||||
$order = ($choices[3]) ? "ORDER BY ".$tp -> toDB($choices[3], true) : "";
|
||||
|
||||
if($sql->select($tp -> toDB($choices[0], true), $tp -> toDB($choices[1], true).",".$tp -> toDB($choices[2], true), "1 $order")){
|
||||
$choiceList = $sql->db_getList('ALL',FALSE);
|
||||
$ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} >\n";
|
||||
$order = ($choices[3]) ? "ORDER BY " . $tp->toDB($choices[3], true) : "";
|
||||
|
||||
if($sql->select($tp->toDB($choices[0], true), $tp->toDB($choices[1], true) . "," . $tp->toDB($choices[2], true), "1 $order"))
|
||||
{
|
||||
$choiceList = $sql->db_getList('ALL', false);
|
||||
$ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} {$title}>\n";
|
||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||
|
||||
foreach($choiceList as $cArray)
|
||||
{
|
||||
$cID = trim($cArray[$choices[1]]);
|
||||
@ -969,47 +936,52 @@ class e107_user_extended
|
||||
$sel = ($curval == $cID) ? " selected='selected' " : "";
|
||||
$ret .= "<option value='{$cID}' {$sel}>{$cText}</option>\n";
|
||||
}
|
||||
|
||||
$ret .= "</select>\n";
|
||||
|
||||
return $ret;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<span class='label label-danger'>Failed to load</span>";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EUF_TEXTAREA : //textarea
|
||||
return "<textarea id='{$fid}' {$include} name='{$fname}' {$required} {$title}>{$curval}</textarea>";
|
||||
break;
|
||||
return "<textarea id='{$fid}' {$include} name='{$fname}' {$required} {$title}>{$curval}</textarea>";
|
||||
break;
|
||||
|
||||
case EUF_DATE : //date
|
||||
|
||||
if($curval == '0000-00-00') // Quick datepicker fix.
|
||||
{
|
||||
$curval = '';
|
||||
}
|
||||
|
||||
if(THEME_LEGACY === true)
|
||||
{
|
||||
return e107::getForm()->text($fname,$curval,10,array('placeholder'=>'yyyy-mm-dd'));
|
||||
}
|
||||
|
||||
return e107::getForm()->datepicker($fname,$curval,array('format'=>'yyyy-mm-dd','return'=>'string'));
|
||||
break;
|
||||
if($curval == '0000-00-00') // Quick datepicker fix.
|
||||
{
|
||||
$curval = '';
|
||||
}
|
||||
|
||||
if(THEME_LEGACY === true)
|
||||
{
|
||||
return e107::getForm()->text($fname,$curval,10,array('placeholder'=>'yyyy-mm-dd'));
|
||||
}
|
||||
|
||||
return e107::getForm()->datepicker($fname,$curval,array('format'=>'yyyy-mm-dd','return'=>'string'));
|
||||
break;
|
||||
|
||||
case EUF_LANGUAGE : // language
|
||||
$lanlist = e107::getLanguage()->installed();
|
||||
sort($lanlist);
|
||||
|
||||
$ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} >\n";
|
||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||
foreach($lanlist as $choice)
|
||||
{
|
||||
$choice = trim($choice);
|
||||
$sel = ($curval == $choice || (!USER && $choice == e_LANGUAGE))? " selected='selected' " : "";
|
||||
$ret .= "<option value='{$choice}' {$sel}>{$choice}</option>\n";
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
|
||||
break;
|
||||
$lanlist = e107::getLanguage()->installed();
|
||||
sort($lanlist);
|
||||
|
||||
$ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} >\n";
|
||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||
foreach($lanlist as $choice)
|
||||
{
|
||||
$choice = trim($choice);
|
||||
$sel = ($curval == $choice || (!USER && $choice == e_LANGUAGE))? " selected='selected' " : "";
|
||||
$ret .= "<option value='{$choice}' {$sel}>{$choice}</option>\n";
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user