Location: PHPKode > projects > CsWebmail > cswebmail-3.10/cswebmail-3.10/templates/AddressBookEntry_edit_presentation.php
<?if(VALID_DOCUMENT != 1) die('what?');?>

<tr>
<td>Name</td>
<td><input type="text" name="name" value="<?=htmlspecialchars($this->name)?>" size="50"/></td>
</tr>

<tr>
<td>Nick name</td>
<td><input type="text" name="nick" value="<?=htmlspecialchars($this->nick)?>" size="50"/></td>
</tr>

<tr>
<td>E-mail</td>
<td><input type="text" name="email" value="<?=htmlspecialchars($this->get_email())?>" size="50"/></td>
</tr>

<tr>
<td>Comment</td>
<td><textarea name="comment" class="w100"><?=htmlspecialchars($this->comment)?></textarea></td>
</tr>

<tr>
<td>Addtional Info</td>
<td>
<script type="text/javascript">
var sections_num=0;
function remove_element(id){
  var div = document.getElementById(id);
  div.parentNode.removeChild(div);
}
function add_additional_info_section(name,key_values){
  if(!name)name='';
  var uniq = 'section_'+sections_num;
  var uniq2 = 'section_fields_'+sections_num;
  var e = document.createElement('div');
  e.setAttribute('id',uniq);
  e.style.marginBottom = '1em';
  e.innerHTML =
    '<input type="text" value="'+name+'" name="sections['+sections_num+'][name]" class="bold big"/>'+
    '&nbsp;&nbsp;&nbsp;'+
    '<a onclick="remove_element(\''+uniq+'\');">remove</a>'+
    '<br/>'+
    '<div id="'+uniq2+'"></div>'+
    '<a onclick="add_additional_info_field(\''+sections_num+'\');">add field</a>';
  var div = document.getElementById('additional-info-edit');
  div.appendChild(e);
  if(key_values){
    for(var i=0;i<key_values.length;i+=2){
      add_additional_info_field(sections_num,key_values[i],key_values[i+1]);
    }
  }
  else{
    add_additional_info_field(sections_num,'email');
    add_additional_info_field(sections_num,'phone');
  }
  sections_num++;
}
var fields_num=0;
var fields = <?=js_string($GLOBALS['ADDITIONAL_FIELDS'])?>;
function add_additional_info_field(section_id,name,value){
  if(!name)name='';
  if(!value)value='';
  var options = '';
  for(key in fields){
    options += '<option value="'+key+'"'+(name==key?' selected':'')+'>'+fields[key]+'</option>';
  }
  var uniq = 'section_field'+section_id+'_'+fields_num;
  var e = document.createElement('div');
  e.setAttribute('id',uniq);
  e.style.marginBottom = '3pt';
  e.innerHTML =
    '<select name="sections['+section_id+'][fields]['+fields_num+'][key]">'+
    options+
    '</select> = '+
    '<input type="text" value="'+value+'" name="sections['+section_id+'][fields]['+fields_num+'][value]" size="35"/>'+
    '&nbsp;&nbsp;&nbsp;'+
    '<a onclick="remove_element(\''+uniq+'\');">remove</a>';
  
  var div = document.getElementById('section_fields_'+section_id);
  div.appendChild(e);
  fields_num++;
}
</script>
<?if(array_not_empty($this->info)){?>
<div id="additional-info">
<?foreach($this->info as $section){?>
<b><?=$section['name']?></b>
<div style="margin-left:2em">
  <?foreach($section['fields'] as $f){?>
  <b><?=htmlspecialchars($f['key'])?>:</b> <?=htmlspecialchars($f['value'])?><br/>
  <?}?>
</div>
<?}?>
<a onclick="this.parentNode.style.display='none';document.getElementById('additional-info-edit').style.display='block';">edit info</a>
</div>
    
<?}?>
<div id="additional-info-edit" <?=array_not_empty($this->info)?'style="display:none"':''?>>
<?if(array_not_empty($this->info)){?>
<a onclick="add_additional_info_section('Other');">add section</a>
<?}else{?>
<a onclick="add_additional_info_section('Personal');add_additional_info_section('Work');">add section</a>
<?}?>
</div>
<?if(array_not_empty($this->info)){?>
<script type="text/javascript">
<?foreach($this->info as $section){
  $key_values = array();
  if(array_not_empty($section['fields'])){foreach($section['fields'] as $f){
    $key_values[] = $f['key'];
    $key_values[] = $f['value'];
  }}?>
add_additional_info_section(<?=js_string($section['name'])?>,<?=js_string($key_values)?>);
<?}?>
</script>
<?}?>
</td>
</tr>
Return current item: CsWebmail