/** * Parent documents (folders) tree list form field (select box). * * @param string $selected selected value * @param string $name field name param * @param string $id field id param * @return string HTML code */ public static function parents($selected, $name = 'joomdoc_parent', $id = 'joomdoc_parent', $realPaths = false) { $parents = JoomDOCFileSystem::getParents(); $tree = array(); // group parents and their children foreach ($parents as $parent) { // this params require JHtml::_('select.genericlist' $parent->name = $parent->title; $parent->parent_id = $parent->parent; // ID and PARENT have to be numeric, cannot use path as array key, use CRC32 to get unique number for each path $parent->id = crc32($parent->path); // add item to parent group $tree[crc32($parent->parent)][] = $parent; } // make tree list $tree = JHtml::_('menu.treerecurse', 0, '', array(), $tree); // empty value $options = array(JHtml::_('select.option', '', JText::_('JOOMDOC_SEARCH_EVERYWHERE'))); foreach ($tree as $list) { $options[] = JHtml::_('select.option', $realPaths && !empty($list->full_alias) ? $list->full_alias : $list->path, $list->treename); } return JHtml::_('select.genericlist', $options, $name, 'autocomplete="off"', 'value', 'text', $selected, $id); }