function _commonForm(&$object) { pathos_lang_loadDictionary('standard', 'core'); pathos_lang_loadDictionary('modules', 'navigationmodule'); // 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. $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', TR_NAVIGATIONMODULE_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, 'pathos_sorting_byRankAscending'); // Generate the Position dropdown array. $positions = array(TR_NAVIGATIONMODULE_ATTOP); foreach ($sections as $section) { $positions[] = sprintf(TR_NAVIGATIONMODULE_POSAFTER, $section->name); } $form->register('rank', TR_NAVIGATIONMODULE_POSITION, 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', TR_NAVIGATIONMODULE_PARENTSECTION, new dropdowncontrol($object->parent, navigationmodule::hierarchyDropdownControlArray(0, array($object->id)))); } } $form->register('new_window', 'Open in 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; }