Improved parent folder selector, use SELECT with all folders list instead of radio buttons
This commit is contained in:
parent
e814ae20bb
commit
8416794d45
2 changed files with 50 additions and 8 deletions
|
@ -163,17 +163,11 @@ class kolab_addressbook_ui
|
|||
$hidden_fields[] = array('name' => '_parent', 'value' => $path_imap);
|
||||
}
|
||||
else {
|
||||
$radio1 = new html_radiobutton(array('name' => '_parent', 'value' => ''));
|
||||
$radio2 = new html_radiobutton(array('name' => '_parent', 'value' => $path_imap));
|
||||
|
||||
$html_path = str_replace($delim, ' » ', $path);
|
||||
|
||||
$folderpath = $radio1->show($path_imap) . Q(rcube_label('none')) . ' '
|
||||
.$radio2->show($path_imap) . Q($html_path);
|
||||
$select = rcube_kolab::folder_selector('contact', array('name' => '_parent'));
|
||||
|
||||
$form['props']['fieldsets']['location']['content']['path'] = array(
|
||||
'label' => $this->plugin->gettext('parentbook'),
|
||||
'value' => $folderpath,
|
||||
'value' => $select->show($path_imap),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -377,4 +377,52 @@ class rcube_kolab
|
|||
return 'personal';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SELECT field with folders list
|
||||
*
|
||||
* @param string $type Folder type
|
||||
* @param array $attrs SELECT field attributes (e.g. name)
|
||||
*
|
||||
* @return html_select SELECT object
|
||||
*/
|
||||
public static function folder_selector($type, $attrs)
|
||||
{
|
||||
// get all folders of specified type
|
||||
$folders = self::get_folders($type);
|
||||
|
||||
$names = array();
|
||||
foreach ($folders as $c_folder)
|
||||
$names[$c_folder->name] = rcube_charset_convert($c_folder->name, 'UTF7-IMAP');
|
||||
asort($names, SORT_LOCALE_STRING);
|
||||
|
||||
$folders = array_keys($names);
|
||||
$names = array();
|
||||
|
||||
// Build SELECT field of parent folder
|
||||
$select = new html_select($attrs);
|
||||
$select->add('---', '');
|
||||
|
||||
foreach ($folders as $name) {
|
||||
$imap_name = $name;
|
||||
$name = $origname = self::object_name($name);
|
||||
|
||||
// find folder prefix to truncate
|
||||
for ($i = count($names)-1; $i >= 0; $i--) {
|
||||
if (strpos($name, $names[$i].' » ') === 0) {
|
||||
$length = strlen($names[$i].' » ');
|
||||
$prefix = substr($name, 0, $length);
|
||||
$count = count(explode(' » ', $prefix));
|
||||
$name = str_repeat(' ', $count-1) . '» ' . substr($name, $length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$names[] = $origname;
|
||||
|
||||
$select->add($name, $imap_name);
|
||||
}
|
||||
|
||||
return $select;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue