public static function renderAllAsSelectControl($unique_id = '', $default_selected_id = 0, $first_item_text = '')
 {
     if (is_object($default_selected_id)) {
         $default_selected = $default_selected_id->metadata_term_set_id;
     }
     if (!$unique_id) {
         $unique_id = 'metadata_term_set_id';
     }
     global $DB;
     $all_mdts = Metadata_Term_Set::getAllFromDb(['flag_delete' => FALSE], $DB);
     usort($all_mdts, 'Metadata_Term_Set::cmp');
     if (!$first_item_text) {
         $first_item_text = util_lang('prompt_select');
     }
     $rendered = '<select name="' . $unique_id . '" id="' . $unique_id . '" class="metadata_term_set_selector">' . "\n";
     $rendered .= '<option value="-1">' . $first_item_text . '</option>' . "\n";
     foreach ($all_mdts as $mdts) {
         $rendered .= $mdts->renderAsOption('', $default_selected_id) . "\n";
     }
     $rendered .= '</select>';
     return $rendered;
 }
    require_once '../app_head.php';
}
# 4. branch behavior based on the action
#      update - update the object with the data coming in, then show the object (w/ 'saved' message)
#      verify/publish - set the appropriate flag (true or false, depending on data coming in), then show the object (w/ 'saved' message)
#      *list* - not a standard action; show a list (tree) of all metadata to which the user has view access
#      view - show the object
#      create/edit - show a form with the object's current values ($action is 'update' on form submit)
#      delete - delete the metadata_structure, then go to list w/ 'deleted' message
if ($action == 'update' || $action == 'verify' || $action == 'publish') {
    echo 'TODO: implement update, verify, and publish actions';
    $action = 'view';
}
if ($action == 'list') {
    echo '<h2>' . util_lang('all_metadata_term_sets', 'properize') . '</h2>' . "\n";
    $all_metadata_term_sets = Metadata_Term_Set::getAllFromDb([], $DB);
    echo '<ul class="all-metadata-term-sets">' . "\n";
    foreach ($all_metadata_term_sets as $a_mdts) {
        if ($USER->canActOnTarget($ACTIONS['view'], $a_mdts)) {
            echo $a_mdts->renderAsListItem();
        }
    }
    echo '</ul>' . "\n";
}
if ($action == 'view') {
    if ($USER->canActOnTarget($ACTIONS['edit'], $mdts)) {
        echo '<div id="actions">' . $mdts->renderAsButtonEdit() . '</div>' . "\n";
    }
    echo $mdts->renderAsView();
} else {
    if ($action == 'edit' || $action == 'create') {