function levelDropDownControlArray($parent, $depth = 0, $ignore_ids = array(), $full = false)
 {
     $ar = array();
     if ($parent == 0 && $full) {
         $ar[0] = '<Top of Hierarchy>';
     }
     global $db;
     $nodes = $db->selectObjects('section', 'parent=' . $parent);
     if (!defined('SYS_SORTING')) {
         include_once BASE . 'subsystems/sorting.php';
     }
     usort($nodes, 'exponent_sorting_byRankAscending');
     foreach ($nodes as $node) {
         if (($node->public == 1 || exponent_permissions_check('view', exponent_core_makeLocation('NavigationModule', '', $node->id))) && !in_array($node->id, $ignore_ids)) {
             if ($node->active == 1) {
                 $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;
             } else {
                 $text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';
             }
             $ar[$node->id] = $text;
             foreach (NavigationModule::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full) as $id => $text) {
                 $ar[$id] = $text;
             }
         }
     }
     return $ar;
 }
 function _commonForm(&$object)
 {
     $i18n = exponent_lang_loadFile('datatypes/section.php');
     // Create a new blank form.
     $form = new form();
     if (!isset($object->id)) {
         // This is a new section, so we need to set up some defaults.
         $object->name = '';
         $object->active = 1;
         $object->public = 1;
         $object->new_window = 0;
         $object->subtheme = '';
         $object->page_title = SITE_TITLE;
         $object->keywords = SITE_KEYWORDS;
         $object->description = SITE_DESCRIPTION;
         if (!isset($object->parent)) {
             // This is another precaution.  The parent attribute
             // should ALWAYS be set by the caller.
             //FJD - if that's the case, then we should die.
             die(SITE_403_REAL_HTML);
             //$object->parent = 0;
         }
     } else {
         // If we are editing the section, we should store the section's id
         // in a hidden value, so that it comes through when the form is
         // submitted.
         $form->meta('id', $object->id);
     }
     // The name of the section, as it will be linked in the section hierarchy.
     $form->register('name', $i18n['name'], new textcontrol($object->name));
     if (!isset($object->id)) {
         // This is a new section, so we can add the positional dropdown
         // Pull the database object in from the global scope.
         global $db;
         // Retrieve all of the sections that are siblings of the new section
         $sections = $db->selectObjects('section', 'parent=' . $object->parent);
         if (count($sections) && $object->parent >= 0) {
             // Initialize the sorting subsystem so that we can order the sections
             // by rank, ascending, and get the proper ordering.
             if (!defined('SYS_SORTING')) {
                 require_once BASE . 'subsystems/sorting.php';
             }
             usort($sections, 'exponent_sorting_byRankAscending');
             // Generate the Position dropdown array.
             $positions = array($i18n['position_top']);
             foreach ($sections as $section) {
                 $positions[] = sprintf($i18n['position_after'], $section->name);
             }
             $form->register('rank', $i18n['rank'], new dropdowncontrol(count($positions) - 1, $positions));
         } else {
             // If there are no siblings, the new section gets the first
             // slot, with a rank of 0.
             $form->meta('rank', 0);
         }
         // Store the section's parent in a hidden field, so that it comes through
         // when the form is submitted.
         $form->meta('parent', $object->parent);
     } else {
         if ($object->parent >= 0) {
             // Allow them to change parents, but not if the section is outside of the hiearchy (parent > 0)
             $form->register('parent', $i18n['parent'], new dropdowncontrol($object->parent, NavigationModule::levelDropdownControlArray(0, 0, array($object->id), 1)));
         }
     }
     $form->register('new_window', $i18n['new_window'], new checkboxcontrol($object->new_window, true));
     // Return the form to the calling scope, which should always be a
     // member method of this class.
     return $form;
 }