The Horde_Form:: package provides form rendering, validation, and
other functionality for the Horde Application Framework.
Copyright 2001-2007 Robert E. Coyle
Copyright 2001-2016 Horde LLC (http://www.horde.org/)
See the enclosed file COPYING for license information (LGPL). If you
did not receive this file, see http://www.horde.org/licenses/lgpl21.
function prepareImportForm($p_variables, &$p_statement_file_variable) { $v_form = new Horde_Form($p_variables, 'Import Statement', 'import_statement'); $p_statement_file_variable = $v_form->addVariable('Statement File (CSV)', 'statement_file', 'file', TRUE); $v_file_description = '<p>The file must conform to the CSV standard and contain only ' . 'printable, UTF-8 characters.</p>' . '<p>Fields are:</p>' . '<ul><li>Item ID (unique)</li><li>Account Name</li>' . '<li>Item Type (O: opening balance, E: event, C: closing balance)</li>' . '<li>Description</li><li>Amount</li></ul>'; $v_file_description_variable = $v_form->addVariable('', 'description', 'html', FALSE, TRUE); $v_file_description_variable->setDefault($v_file_description); $v_form->setButtons('import'); return $v_form; }
public function __construct(&$vars) { parent::__construct($vars, _("Add Form Reply")); $this->addHidden('', 'type', 'int', true, true); $this->addVariable(_("Form Reply Name"), 'reply_name', 'text', true); $this->addVariable(_("Form Reply Text"), 'reply_text', 'longtext', true); }
public function __construct($vars, $title) { parent::__construct($vars, $title); $this->setButtons(_("Save"), true); try { $sam_driver = $GLOBALS['injector']->getInstance('Sam_Driver'); } catch (Sam_Exception $e) { return; } foreach ($this->_attributes as $key => $attribute) { if (!$sam_driver->hasCapability($key)) { continue; } $var = $this->addVariable($attribute, $key, 'longtext', false, false, null, array('5', '40')); $var->setHelp($key); if (!$vars->exists($key)) { $vars->set($key, $sam_driver->getListOption($key)); } } if ($sam_driver->hasCapability('global_defaults') && $GLOBALS['registry']->isAdmin()) { $this->addVariable('', '', 'spacer', false); $var = $this->addVariable(_("Make Settings Global"), 'global_defaults', 'boolean', false); $var->setHelp('global_defaults'); } }
/** * Renders the form for editing. * * @param Horde_Form_Renderer $renderer A renderer instance, optional * since Horde 3.2. * @param Variables $vars A Variables instance, optional * since Horde 3.2. * @param string $action The form action (url). * @param string $method The form method, usually either * 'get' or 'post'. * @param string $enctype The form encoding type. Determined * automatically if null. * @param boolean $focus Focus the first form field? */ public function renderActive($renderer, $vars, $action, $method = 'get', $enctype = null, $focus = true) { if ($vars->get('old_datatype') === null) { $this->_addParameters($vars); } parent::renderActive($renderer, $vars, $action, $method, $enctype, $focus); }
public function __construct(&$vars) { parent::__construct($vars, 'editjobtypestep2form'); $jobtype = $vars->get('jobtype'); try { $info = $GLOBALS['injector']->getInstance('Hermes_Driver')->getJobTypeByID($jobtype); } catch (Exception $e) { } if (!$info) { $stype = 'invalid'; $type_params = array(_("This is not a valid job type.")); } else { $stype = 'text'; $type_params = array(); } $this->addHidden('', 'jobtype', 'int', true, true); $sname =& $this->addVariable(_("Job Type"), 'name', $stype, true, false, null, $type_params); if (!empty($info['name'])) { $sname->setDefault($info['name']); } $enab =& $this->addVariable(_("Enabled?"), 'enabled', 'boolean', false); $enab->setDefault($info['enabled']); $enab =& $this->addVariable(_("Billable?"), 'billable', 'boolean', false); $enab->setDefault($info['billable']); $enab =& $this->addVariable(_("Hourly Rate"), 'rate', 'number', false); $enab->setDefault($info['rate']); }
public function __construct(&$vars) { parent::__construct($vars, _("Add Type")); $this->appendButtons(_("Add Type")); $this->addVariable(_("Type Name"), 'name', 'text', true); $this->addVariable(_("Type Description"), 'description', 'text', true); }
public function __construct(&$vars) { parent::__construct($vars, _("Add Priority")); $this->addHidden('', 'type', 'int', true, true); $this->addVariable(_("Priority Name"), 'name', 'text', true); $this->addVariable(_("Priority Description"), 'description', 'text', true); }
/** * Return the metadata for the table. * * @return array An array of the table metadata. * @throws Hermes_Exception */ public function getMetaData() { if (is_null($this->_metaData)) { list($app, $name) = explode('/', $this->_config['name']); $args = array($name, $this->_config['params']); $this->_metaData = $GLOBALS['registry']->callByPackage($app, 'getTableMetaData', $args); // We need to make vars for the columns. foreach ($this->_metaData['sections'] as $secname => $section) { foreach ($section['columns'] as $col) { $title = isset($col['title']) ? $col['title'] : ''; $typename = isset($col['type']) ? $col['type'] : 'text'; $params = isset($col['params']) ? $col['params'] : array(); // Column types which begin with % are pseudo-types handled // directly. if (substr($typename, 0, 1) != '%') { // This type needs to be assigned by reference! $type =& Horde_Form::getType($typename, $params); $var = new Horde_Form_Variable($title, $col['name'], $type, false, true, ''); $this->_formVars[$secname][$col['name']] = $var; } } } } return $this->_metaData; }
public function __construct($vars) { parent::__construct($vars, _("Create Address Book")); $this->addVariable(_("Name"), 'name', 'text', true); $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); $this->setButtons(array(_("Create"))); }
public function __construct(&$vars) { parent::__construct($vars, _("Edit Attribute")); $attribute = $vars->get('attribute'); $info = $GLOBALS['whups_driver']->getAttributeDesc($attribute); $this->addHidden('', 'type', 'int', true, true); $this->addHidden('', 'attribute', 'int', true, true); $pname =& $this->addVariable(_("Attribute Name"), 'attribute_name', 'text', true); $pname->setDefault($info['name']); $pdesc =& $this->addVariable(_("Attribute Description"), 'attribute_description', 'text', true); $pdesc->setDefault($info['description']); $preq =& $this->addVariable(_("Required Attribute?"), 'attribute_required', 'boolean', false); $preq->setDefault($info['required']); $ptype =& $this->addVariable(_("Attribute Type"), 'attribute_type', 'enum', true, false, null, array(Whups::fieldTypeNames())); $ptype->setAction(Horde_Form_Action::factory(array('whups', 'whups_reload'), array('formname' => 'whups_form_admin_editattributesteptwo_reload'))); $ptype->setDefault($info['type']); $type = $vars->get('attribute_type'); if (empty($type)) { $type = $info['type']; } foreach (Whups::fieldTypeParams($type) as $param => $param_info) { $pparam =& $this->addVariable($param_info['label'], 'attribute_params[' . $param . ']', $param_info['type'], false); if (isset($info['params'][$param])) { $pparam->setDefault($info['params'][$param]); } } }
public function __construct(&$vars) { parent::__construct($vars, 'editclientstep2form'); $client = $vars->get('client'); try { $info = $GLOBALS['injector']->getInstance('Hermes_Driver')->getClientSettings($client); } catch (Hermes_Exception $e) { } if (!$info) { $stype = 'invalid'; $type_params = array(_("This is not a valid client.")); } else { $stype = 'text'; $type_params = array(); } $this->addHidden('', 'client', 'text', true, true); $name =& $this->addVariable(_("Client"), 'name', $stype, false, true, null, $type_params); $name->setDefault($info['name']); $enterdescription =& $this->addVariable(sprintf(_("Should users enter descriptions of their timeslices for this client? If not, the description will automatically be \"%s\"."), _("See Attached Timesheet")), 'enterdescription', 'boolean', true); if (!empty($info['enterdescription'])) { $enterdescription->setDefault($info['enterdescription']); } $exportid =& $this->addVariable(_("ID for this client when exporting data, if different from the name displayed above."), 'exportid', 'text', false); if (!empty($info['exportid'])) { $exportid->setDefault($info['exportid']); } }
public function __construct(&$vars) { global $whups_driver, $conf; parent::__construct($vars, _("Create Ticket - Step 4")); /* Preserve previously uploaded attachments. */ $this->addHidden('', 'deferred_attachment', 'text', false); /* Groups. */ $mygroups = $GLOBALS['injector']->getInstance('Horde_Group')->listAll($conf['prefs']['assign_all_groups'] ? null : $GLOBALS['registry']->getAuth()); asort($mygroups); $users = $whups_driver->getQueueUsers($vars->get('queue')); $f_users = array(); foreach ($users as $user) { $f_users['user:'******'group:' . $id] = $group; } } if (count($f_users)) { asort($f_users); $owners = $this->addVariable(_("Owners"), 'owners', 'multienum', false, false, null, array($f_users)); } if (count($f_groups)) { asort($f_groups); $group_owners = $this->addVariable(_("Group Owners"), 'group_owners', 'multienum', false, false, null, array($f_groups)); } if (!count($f_users) && !count($f_groups)) { $owner_params = array(_("There are no users to which this ticket can be assigned.")); $this->addVariable(_("Owners"), 'owners', 'invalid', false, false, null, $owner_params); } }
public function __construct($vars, $calendar) { parent::__construct($vars, sprintf(_("Unsubscribe from %s"), $calendar['name'])); $this->addHidden('', 'url', 'text', true); $this->addVariable(sprintf(_("Really unsubscribe from the calendar \"%s\" (%s)?"), htmlspecialchars($calendar['name']), htmlspecialchars($calendar['url'])), 'desc', 'description', false); $this->setButtons(array(array('class' => 'horde-delete', 'value' => _("Unsubscribe")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
public function validate(&$vars) { if (!Whups::hasPermission($this->_queue, 'queue', Horde_Perms::DELETE)) { $this->setError('yesno', _("Permission Denied.")); } return parent::validate($vars); }
public function __construct(&$vars, $title = '') { global $whups_driver; parent::__construct($vars, $title); $this->addHidden('', 'id', 'int', true, true); $this->addHidden('', 'group', 'int', false, true); $this->addHidden('', 'queue', 'int', true, true); $this->addHidden('', 'newcomment', 'longtext', false, true); /* Give the user an opportunity to check that type, version, * etc. are still valid. */ $queue = $vars->get('queue'); $info = $whups_driver->getQueue($queue); if (!empty($info['versioned'])) { $versions = $whups_driver->getVersions($vars->get('queue')); if (count($versions) == 0) { $vtype = 'invalid'; $v_params = array(_("This queue requires that you specify a version, but there are no versions associated with it. Until versions are created for this queue, you will not be able to create tickets.")); } else { $vtype = 'enum'; $v_params = array($versions); } $this->addVariable(_("Queue Version"), 'version', $vtype, true, false, null, $v_params); } $this->addVariable(_("Type"), 'type', 'enum', true, false, null, array($whups_driver->getTypes($queue))); }
public function __construct(&$vars) { parent::__construct($vars, _("Insert Branch")); $branchtypes = array(Whups_Query::TYPE_AND => _("And"), Whups_Query::TYPE_OR => _("Or"), Whups_Query::TYPE_NOT => _("Not")); $this->addHidden(null, 'path', 'text', false, true); $this->addVariable(_("Branch Type"), 'type', 'enum', true, false, null, array($branchtypes)); }
public function __construct($query, $vars) { parent::__construct($vars, _("Query Parameters"), 'Whups_Form_Query_Parameter'); foreach ($query->parameters as $name) { $this->addVariable($name, $name, 'text', true); } }
public function __construct(&$vars) { global $whups_driver; parent::__construct($vars, _("Create Ticket - Step 2")); $types = $whups_driver->getTypes($vars->get('queue')); $info = $whups_driver->getQueue($vars->get('queue')); $type = $whups_driver->getDefaultType($vars->get('queue')); if (count($types) == 0) { $typetype = 'invalid'; $type_params = array(_("There are no ticket types associated with this queue; until there are, you cannot create any tickets in this queue.")); } else { $typetype = 'enum'; $type_params = array($types); if (empty($type) || !isset($types[$type])) { $type_params[] = _("Choose:"); } } $types =& $this->addVariable(_("Ticket Type"), 'type', $typetype, true, false, null, $type_params); $types->setDefault($type); if (!empty($info['versioned'])) { $versions = $whups_driver->getVersions($vars->get('queue')); if (count($versions) == 0) { $vtype = 'invalid'; $v_params = array(_("This queue requires that you specify a version, but there are no versions associated with it. Until versions are created for this queue, you will not be able to create tickets.")); } else { $vtype = 'enum'; $v_params = array($versions); } $this->addVariable(_("Queue Version"), 'version', $vtype, true, false, null, $v_params); } else { $types->setAction(Horde_Form_Action::factory('submit')); } }
public function validate(&$vars) { if (Whups::hasPermission($this->_queue, 'queue', Horde_Perms::DELETE)) { $this->_warn->setDefault('<span class="horde-form-error">' . _("Permission Denied.") . '</span>'); } return parent::validate($vars); }
function ServerSettings(&$vars) { parent::Horde_Form($vars); $this->addHidden('', 'actionId', 'text', true); $vars->set('actionId', 'serversettings'); $this->addVariable(_("Server Name"), 'servername', 'text', true); $this->addVariable(_("Server Port"), 'port', 'int', false); $this->addVariable(_("Player Password"), 'playerpass', 'text', false); $this->addVariable(_("DM Password"), 'dmpass', 'text', false); $this->addVariable(_("Maximum Clients"), 'maxclients', 'int', true); $this->addVariable(_("Minimum Player Level"), 'minlevel', 'int', true); $this->addVariable(_("Maximum Player Level"), 'maxlevel', 'int', true); $this->addVariable(_("Pause And Play"), 'pauseandplay', 'enum', true, false, null, array(array('0' => 'DM Only', '1' => 'DM and Players'))); $this->addVariable(_("Player Vs Player"), 'pvp', 'enum', true, false, null, array(array('0' => 'None', '1' => 'Party Only', '2' => 'Free For All'))); $this->addVariable(_("Server Vault"), 'servervault', 'enum', true, false, null, array(array('0' => 'Local Characters Only', '1' => 'Server Characters Only'))); $this->addVariable(_("Enforce Legal Characters"), 'elc', 'enum', true, false, null, array(array('1' => 'Enforce Legal Characters', '0' => 'Any Characters'))); $this->addVariable(_("Item Level Restrictions"), 'ilr', 'enum', true, false, null, array(array('1' => 'Enforce Item Restrictions', '0' => 'Any Items'))); $this->addVariable(_("Game Type"), 'gametype', 'enum', true, false, null, array(array('0' => 'Action', '1' => 'Story', '2' => 'Story Lite', '3' => 'Role Play', '4' => 'Team', '5' => 'Melee', '6' => 'Arena', '7' => 'Aocial', '8' => 'Alternative', '9' => 'PW Action', '10' => 'PW Story', '11' => 'Solo', '12' => 'Tech Support'))); $this->addVariable(_("Parties"), 'oneparty', 'enum', true, false, null, array(array('0' => 'One Party', '1' => 'Multiple Parties'))); $this->addVariable(_("Difficulty"), 'difficulty', 'enum', true, false, null, array(array('1' => 'Easy', '2' => 'Normal', '3' => 'D&D Hardcore', '4' => 'Insane'))); $this->addVariable(_("Auto Save Interval"), 'autosaveinterval', 'int', true, false, _("In minutes, use 0 to disable")); $this->addVariable(_("Persistence"), 'reloadwhenempty', 'enum', true, false, null, array(array('0' => 'Persistent Module', '1' => 'Reload When Empty'))); $this->addVariable(_("Server Visibility"), 'publicserver', 'enum', true, false, null, array(array('0' => 'Private', '1' => 'Public'))); $this->setTitle(_("Configure Server Settings")); $this->setButtons(_("Update Config")); }
public function __construct($vars) { parent::__construct($vars, _("Add Users")); $this->addHidden('', 'queue', 'int', true, true); global $conf, $whups_driver; $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create(); if ($auth->hasCapability('list')) { $queue = $vars->get('queue'); $current = $whups_driver->getQueueUsers($queue); try { $list = $auth->listUsers(); sort($list); $users = array(); foreach ($list as $user) { if (!in_array($user, $current)) { $users[$user] = $GLOBALS['registry']->convertUsername($user, false); } } $this->addVariable(_("User"), 'user', 'multienum', true, false, null, array($users)); } catch (Horde_Auth_Exception $e) { $this->addVariable(_("User"), 'user', 'invalid', true, false, null, array(sprintf(_("There was an error listing users: %s"), $e->getMessage()))); } } else { $this->addVariable(_("User"), 'user', 'text', true); } }
public function __construct($vars) { parent::__construct($vars, _("Delete Query?"), 'Whups_Form_Query_Delete'); $yesno = array(array(0 => _("No"), 1 => _("Yes"))); $this->addVariable(_("Really delete this query? This operation is not undoable."), 'yesno', 'enum', true, false, null, $yesno); $this->setButtons(array(array('class' => 'horde-delete', 'value' => _("Delete Query")))); }
public function __construct(&$vars) { parent::__construct($vars, _("Add State")); $this->addHidden('', 'type', 'int', true, true); $this->addVariable(_("State Name"), 'name', 'text', true); $this->addVariable(_("State Description"), 'description', 'text', true); $this->addVariable(_("State Category"), 'category', 'enum', false, false, null, array($GLOBALS['whups_driver']->getCategories())); }
public function __construct($vars, $calendar) { $this->_calendar = $calendar; parent::__construct($vars, sprintf(_("Delete %s"), $calendar->get('name'))); $this->addHidden('', 'c', 'text', true); $this->addVariable(sprintf(_("Really delete the calendar \"%s\"? This cannot be undone and all data on this calendar will be permanently removed."), htmlspecialchars($this->_calendar->get('name'))), 'desc', 'description', false); $this->setButtons(array(array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
function NewNWNModule(&$vars) { parent::Horde_Form($vars); $this->addVariable(_("New Module"), 'module', 'file', true); $this->setTitle(_("Upload New Module")); $this->setButtons(_("Upload")); $this->useToken(true); }
public function __construct(&$vars) { parent::__construct($vars, _("Add Queue")); $this->appendButtons(_("Add Queue")); $this->addVariable(_("Queue Name"), 'name', 'text', true); $this->addVariable(_("Queue Description"), 'description', 'text', true); $this->addVariable(_("Queue Slug"), 'slug', 'text', false, false, sprintf(_("Slugs allows direct access to this queue's open tickets by visiting: %s. <br /> Slug names may contain only letters, numbers or the _ (underscore) character."), Horde::url('queue/slugname', true)), array('/^[a-zA-Z1-9_]*$/')); $this->addVariable(_("Queue Email"), 'email', 'email', false, false, _("This email address will be used when sending notifications for any queue tickets.")); }
public function __construct($vars) { parent::__construct($vars, $vars->get('edit') ? _("Edit Text Criterion") : _("Add Text Criterion"), 'Whups_Form_Query_TextCriterion'); $this->addHidden('', 'edit', 'boolean', false); $this->addVariable(_("Text"), 'text', 'text', true); $this->addVariable(_("Match Operator"), 'operator', 'enum', true, false, null, array(Whups_Query::textOperators())); $this->addVariable(_("Search Summary"), 'summary', 'boolean', false); $this->addVariable(_("Search Comments"), 'comments', 'boolean', false); }
/** * Basic constructor for the SearchForm. * * @param Horde_Variables $vars The default variables to use. */ public function __construct($vars) { parent::__construct($vars, _("Search The Inventory")); $this->appendButtons(_("Search")); $this->addHidden('', 'actionId', 'text', true); $this->addVariable(_("Search these properties"), 'location', 'multienum', true, false, null, array(array(Sesha::SEARCH_ID => _("Stock ID"), Sesha::SEARCH_NAME => _("Item Name"), Sesha::SEARCH_NOTE => _("Item Note"), Sesha::SEARCH_PROPERTY => _("Property Value")))); $this->addVariable(_("For this value"), 'criteria', 'text', true); $this->addVariable(_("Only exact matches"), 'exact', 'boolean', true, false); }
public function __construct(&$vars) { parent::__construct($vars, _("Save Query"), 'Whups_Form_Query_ChooseNameForSave'); $this->setButtons(_("Save")); $v = $this->addVariable(_("Query Name"), 'name', 'text', true); $v->setDefault($GLOBALS['whups_query']->name); $v = $this->addVariable(_("Query Slug"), 'slug', 'text', false); $v->setDefault($GLOBALS['whups_query']->slug); }
public function __construct(&$vars) { parent::__construct($vars, _("Select Client")); $action =& Horde_Form_Action::factory('submit'); list($clienttype, $clientparams) = $this->getClientType(); $cli =& $this->addVariable(_("Client"), 'client_id', $clienttype, true, false, null, $clientparams); $cli->setAction($action); $this->setButtons(_("Edit Deliverables")); }