public function addForm(PHPWS_Form &$form) { $form->addText('piwik_url', $this->getPiwikUrl()); $form->setLabel('piwik_url', dgettext('analytics', 'Base URL of Piwik (DO NOT specify protocol (http:// or https://), as this is autodetected by the script)')); $form->setRequired('piwik_url'); $form->addText('piwik_id', $this->getPiwikId()); $form->setLabel('piwik_id', dgettext('analytics', 'Piwik Site ID')); $form->setRequired('piwik_id'); }
public function checkinForm() { $form = new PHPWS_Form('checkin'); $form->turnOffAutoComplete(); $form->setProtected(false); $form->addHidden('module', 'checkin'); $form->addHidden('uop', 'post_checkin'); $form->addText('first_name', isset($_POST['first_name']) ? trim($_POST['first_name']) : null); $form->setLabel('first_name', dgettext('checkin', 'First name')); $form->setRequired('first_name'); $form->addText('last_name', isset($_POST['last_name']) ? trim($_POST['last_name']) : null); $form->setLabel('last_name', dgettext('checkin', 'Last name')); $form->setRequired('last_name'); if (PHPWS_Settings::get('checkin', 'email')) { $form->addText('email', isset($_POST['email']) ? trim($_POST['email']) : null); $form->setLabel('email', dgettext('checkin', 'Email address')); $form->setRequired('email'); } // If gender is requested if (PHPWS_Settings::get('checkin', 'gender')) { $sex = array('male' => 'Male', 'female' => 'Female'); $form->addRadioAssoc('gender', $sex); $form->addTplTag('GENDER_LABEL', dgettext('checkin', 'Gender')); } // If birthdate is requested if (PHPWS_Settings::get('checkin', 'birthdate')) { /* * Minimum representable date is 12-13-1901, and instead of doing * lots of math to ensure that all selected dates in 1901 are after * 12-13-1901, just make the minimum year always be 1902 */ $yearsPrior = date('Y', time()) - 1902; // current year - minimum full year (1902) $form->dateSelect('birthdate', 0, '%B', $yearsPrior, 0); $form->addTplTag('BIRTHDATE_LABEL', dgettext('checkin', 'Date of birth')); } $reasons = $this->getReasons(); if (!empty($reasons)) { $reasons = array_reverse($reasons, true); $reasons[0] = dgettext('checkin', '-- Please choose a reason from the list below --'); $reasons = array_reverse($reasons, true); $form->addSelect('reason_id', $reasons); $form->setLabel('reason_id', dgettext('checkin', 'Reason for visit')); } $form->addSubmit(dgettext('checkin', 'Check in')); $tpl = $form->getTemplate(); $this->title = dgettext('checkin', 'Please check in using the form below'); $this->content = PHPWS_Template::process($tpl, 'checkin', 'signin.tpl'); if (!Current_User::isLogged() && PHPWS_Settings::get('checkin', 'collapse_signin')) { Layout::collapse(); } }
public function addForm(PHPWS_Form &$form) { $form->addText('owa_url', $this->getOwaUrl()); $form->setLabel('owa_url', dgettext('analytics', 'Base URL of Open Web Analytics (DO specify protocol (http:// or https://)')); $form->setRequired('owa_url'); $form->addText('owa_site_id', $this->getOwaSiteId()); $form->setLabel('owa_site_id', dgettext('analytics', 'Open Web Analytics Site ID')); $form->setRequired('owa_site_id'); $form->addCheck('owa_track_page_view', 1); $form->setMatch('owa_track_page_view', $this->getTrackPageView()); $form->setLabel('owa_track_page_view', dgettext('analytics', 'Track Page Views (see OWA documentation)')); $form->addCheck('owa_track_clicks', 1); $form->setMatch('owa_track_clicks', $this->getTrackClicks()); $form->setLabel('owa_track_clicks', dgettext('analytics', 'Track Clicks (see OWA documentation)')); $form->addCheck('owa_track_domstream', 1); $form->setMatch('owa_track_domstream', $this->getTrackDomStream()); $form->setLabel('owa_track_domstream', dgettext('analytics', 'Track DOM Stream (see OWA documentation)')); }
/** * @param boolean limited If true, use anonymous submission form */ public static function edit(Blog $blog, $version_id = NULL, $limited = false) { javascriptMod('blog', 'image_url'); if ($limited) { throw new \Exception(''); } $form = new PHPWS_Form('edit-blog'); $form->addHidden('module', 'blog'); $form->addHidden('action', 'admin'); $form->addHidden('command', 'post_entry'); if ($blog->id) { $form->addHidden('blog_id', $blog->id); $form->addSubmit('submit', dgettext('blog', 'Update entry')); } else { $form->addSubmit('submit', dgettext('blog', 'Add entry')); } $link_choices['none'] = dgettext('blog', 'No link and ignore image link setting'); $link_choices['default'] = dgettext('blog', 'No link but allow image link setting'); $link_choices['readmore'] = dgettext('blog', 'Link to read more'); $link_choices['parent'] = dgettext('blog', 'Link resized image to parent'); $link_choices['url'] = dgettext('blog', 'Link the url below'); $form->addText('title', $blog->title); $form->setSize('title', 40); $form->setLabel('title', dgettext('blog', 'Title')); $form->setRequired('title'); $form->addTextArea('summary', $blog->getSummaryAndEntry(false)); if (!$limited) { $form->useEditor('summary'); } $form->setRows('summary', '10'); $form->setCols('summary', '60'); $form->setLabel('summary', dgettext('blog', 'Content')); javascript('datetimepicker', null, false, true, true); $form->addText('publish_date', $blog->getPublishDate('%Y/%m/%d %H:%M')); $form->setLabel('publish_date', dgettext('blog', 'Publish date/time')); $form->setSize('publish_date', 20); $form->setClass('publish_date', 'datetimepicker'); $form->addText('expire_date', $blog->getExpireDate()); $form->setLabel('expire_date', dgettext('blog', 'Expire date/time')); $form->setSize('expire_date', 20); $form->setClass('expire_date', 'datetimepicker'); $template = $form->getTemplate(); $jscal['date_name'] = 'expire_date'; $template['EXAMPLE'] = 'YYYY/MM/DD HH:MM'; if ($blog->_error) { $template['MESSAGE'] = implode('<br />', $blog->_error); } $template['REMINDER'] = dgettext('blog', 'Add a horizontal rule to separate content into summary and body'); return PHPWS_Template::process($template, 'blog', 'edit.tpl'); }
public function form() { javascript('jquery'); javascriptMod('properties', 'generate'); \Layout::addStyle('properties', 'forms.css'); $form = new \PHPWS_Form('contact'); $form->addHidden('module', 'properties'); if (!empty($this->id)) { $form->addHidden('cid', $this->id); $form->addSubmit('Update contact'); } else { $form->addSubmit('Add contact'); } if (isset($_SESSION['Contact_User']) && !\Current_User::allow('properties')) { $form->addHidden('cop', 'save_contact'); $form->addHidden('k', $_SESSION['Contact_User']->getKey()); } else { $form->addHidden('aop', 'save_contact'); $form->addText('username', $this->username); $form->setClass('username', 'form-control'); $form->setLabel('username', 'User name'); $form->setSize('username', '20', '20'); $form->setRequired('username'); $form->addButton('make_password', 'Create'); $form->setId('make_password', 'make-password'); $form->setClass('make_password', 'btn btn-default'); $form->addCheck('contact_contact', 1); $form->setLabel('contact_contact', 'Send contact email'); if (!$this->id) { $form->setMatch('contact_contact', 1); } } $form->addPassword('password'); $form->setLabel('password', 'Password'); $form->setClass('password', 'form-control'); $form->addPassword('pw_check'); $form->setLabel('pw_check', 'Retype password below'); $form->setClass('pw_check', 'form-control'); $form->addText('first_name', $this->first_name); $form->setLabel('first_name', 'Contact first name'); $form->setRequired('first_name'); $form->setClass('first_name', 'form-control'); $form->addText('last_name', $this->last_name); $form->setLabel('last_name', 'Contact last name'); $form->setRequired('last_name'); $form->setClass('last_name', 'form-control'); $form->addText('phone', $this->getPhone()); $form->setLabel('phone', 'Phone number'); $form->setRequired('phone'); $form->setClass('phone', 'form-control'); $form->addText('email_address', $this->email_address); $form->setLabel('email_address', 'Email address'); $form->setRequired('email_address'); $form->setSize('email_address', 40); $form->setClass('email_address', 'form-control'); $form->addText('company_name', $this->company_name); $form->setLabel('company_name', 'Company name'); $form->setRequired('company_name'); $form->setSize('company_name', 40); $form->setClass('company_name', 'form-control'); $form->addText('company_url', $this->company_url); $form->setLabel('company_url', 'Company url'); $form->setSize('company_url', 40); $form->setClass('company_url', 'form-control'); $form->addText('company_address', $this->company_address); $form->setLabel('company_address', 'Company (or renter) address'); $form->setClass('company_address', 'form-control'); $form->addTextArea('times_available', $this->times_available); $form->setLabel('times_available', 'Days and hours available for contact'); $form->setRows('times_available', 4); $form->setCols('times_available', 20); $form->setClass('times_available', 'form-control'); $tpl = $form->getTemplate(); if (!empty($this->errors)) { foreach ($this->errors as $key => $message) { $new_key = strtoupper($key) . '_ERROR'; $tpl[$new_key] = $message; } } return \PHPWS_Template::process($tpl, 'properties', 'edit_contact.tpl'); }
public static function showEditForm(Tracker $tracker) { $tpl = array(); $tpl['TRACKER_TYPE'] = $tracker->trackerType(); $form = new PHPWS_Form('tracker'); $form->addHidden('module', 'analytics'); $form->addHidden('command', 'save_tracker'); $form->addSubmit('submit', dgettext('analytics', 'Save Tracker')); if (isset($_REQUEST['tracker'])) { $form->addHidden('tracker', $_REQUEST['tracker']); } if ($tracker->getId() > 0) { $form->addHidden('tracker_id', $tracker->getId()); } $form->addText('name', $tracker->getName()); $form->setLabel('name', dgettext('analytics', 'Friendly Name')); $form->setRequired('name'); $form->addCheck('active', 1); $form->setMatch('active', $tracker->isActive()); $form->setLabel('active', dgettext('analytics', 'Currently Active')); $form->addCheck('disable_if_logged', 1); $form->setMatch('disable_if_logged', $tracker->getDisableIfLogged()); $form->setLabel('disable_if_logged', dgettext('analytics', 'Disable Analytics if a user is logged in')); $tracker->addForm($form); $tpl = array_merge($tpl, $form->getTemplate()); $tpl['TRACKER_FORM'] = PHPWS_Template::process($tpl, 'analytics', $tracker->getFormTemplate()); return PHPWS_Template::process($tpl, 'analytics', 'edit.tpl'); }
public static function userForm(PHPWS_User $user, $message = NULL) { javascript('jquery'); javascriptMod('users', 'generate'); $form = new PHPWS_Form('edit-user'); if ($user->getId() > 0) { $form->addHidden('user_id', $user->getId()); $form->addSubmit('go', dgettext('users', 'Update User')); } else { $form->addSubmit('go', dgettext('users', 'Add User')); } $form->addHidden('action', 'admin'); $form->addHidden('command', 'postUser'); $form->addHidden('module', 'users'); $form->addCheckbox('notify_user', 1); $form->setLabel('notify_user', dgettext('user', 'Notify user of account creation')); if (Current_User::allow('users', 'settings')) { $db = new PHPWS_DB('users_auth_scripts'); $db->setIndexBy('id'); $db->addColumn('id'); $db->addColumn('display_name'); $result = $db->select('col'); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); } else { if (!isset($result[$user->authorize])) { $message['AUTHORIZE'] = dgettext('users', 'Warning: this user\'s authorization script is broken. Choose another and update.'); } $form->addSelect('authorize', $result); $form->setMatch('authorize', $user->authorize); $form->setLabel('authorize', dgettext('users', 'Authorization')); } } if (!$user->id || $user->canChangePassword()) { $form->addText('username', $user->getUsername()); $form->setRequired('username'); $form->setLabel('username', dgettext('users', 'Username')); $form->addPassword('password1'); $form->addPassword('password2'); $form->setLabel('password1', dgettext('users', 'Password')); $form->addButton('create_pw', dgettext('users', 'Generate password')); } else { $form->addTplTag('USERNAME', $user->getUsername()); $form->addTplTag('USERNAME_LABEL', '<strong>' . dgettext('users', 'Username') . '</strong>'); } $form->addText('display_name', $user->display_name); $form->addText('email', $user->getEmail()); $form->setSize('email', 30); $form->setRequired('email'); $form->setLabel('email', dgettext('users', 'Email Address')); $form->setLabel('display_name', dgettext('users', 'Display name')); if (isset($tpl)) { $form->mergeTemplate($tpl); } $template = $form->getTemplate(); $vars['action'] = 'admin'; $vars['user_id'] = $user->id; if ($user->id) { $vars['command'] = 'setUserPermissions'; $links[] = PHPWS_Text::secureLink(\Icon::show('permission') . ' ' . dgettext('users', 'Permissions'), 'users', $vars, null, dgettext('users', 'Permissions'), 'btn btn-default'); } if (isset($links)) { $template['LINKS'] = implode(' | ', $links); } if (isset($message)) { foreach ($message as $tag => $error) { $template[strtoupper($tag) . '_ERROR'] = $error; } } if (!$user->id) { $template['JOIN_GROUPS'] = self::getJoinGroups(); } else { $group_ids = $user->getGroups(); if ($group_ids) { $db = Database::newDB(); $t1 = $db->addTable('users_groups'); $f1 = $t1->addField('name'); $c1 = $t1->getFieldConditional('id', $group_ids, 'in'); $c2 = $t1->getFieldConditional('user_id', 0); $db->stackConditionals($c1, $c2); while ($group = $db->selectColumn()) { $template['members'][] = array('NAME' => $group); } } if (!isset($template['members'])) { $template['EMPTY_GROUP'] = dgettext('user', 'User not a member of any group'); } } return PHPWS_Template::process($template, 'users', 'forms/userForm.tpl'); }
public function getForm($name = null) { javascript('datepicker'); \Layout::addStyle('properties', 'forms.css'); $form = new \PHPWS_Form($name); $form->addHidden('module', 'properties'); $form->addCheck('appalcart', 1); $form->setLabel('appalcart', 'On Appalcart route'); $form->setMatch('appalcart', $this->appalcart); $form->addSelect('campus_distance', array(0 => '0 to 5', 5 => '5 to 10', 10 => '10 to 25', 25 => 'More than 25')); $form->setLabel('campus_distance', 'Miles from campus'); $form->setMatch('campus_distance', $this->campus_distance); $form->addCheck('clubhouse', 1); $form->setLabel('clubhouse', 'Clubhouse'); $form->setMatch('clubhouse', $this->clubhouse); \PHPWS_Core::initModClass('properties', 'User.php'); $contracts = User::getContracts(); $form->addSelect('contract_length', $contracts); $form->setLabel('contract_length', 'Contract length'); $form->setMatch('contract_length', $this->contract_length); $form->addTextarea('description', $this->description); $form->setLabel('description', 'Other property information'); $form->addCheck('airconditioning', 1); $form->setLabel('airconditioning', 'Air Conditioning'); $form->setMatch('airconditioning', $this->airconditioning); $form->addCheck('dishwasher', 1); $form->setLabel('dishwasher', 'Dishwasher'); $form->setMatch('dishwasher', $this->dishwasher); $itypes[NET_DIALUP] = 'Dial Up'; $itypes[NET_CABLE] = 'Cable'; $itypes[NET_DSL] = 'DSL'; $itypes[NET_WIRELESS] = 'Wireless'; $itypes[NET_SATELLITE] = 'Satellite'; $itypes[NET_FIBER] = 'Fiber'; $itypes[NET_BOTH] = 'DSL/Cable'; $form->addSelect('internet_type', $itypes); $form->setLabel('internet_type', 'Internet'); $form->setMatch('internet_type', $this->internet_type); $form->addSelect('laundry_type', array(LAUNDRY_NONE => 'No laundry', LAUNDRY_ON_PREMISES => 'Laundry room on premises', LAUNDRY_HOOKUP => 'Washer/Dryer hook ups in unit', LAUNDRY_IN_UNIT => 'Washer/Dryer in unit')); $form->setLabel('laundry_type', 'Laundry'); $form->setMatch('laundry_type', $this->laundry_type); $form->addText('monthly_rent', $this->getMonthlyRent()); $form->setLabel('monthly_rent', 'Monthly rent'); $form->setSize('monthly_rent', 8, 8); $form->setRequired('monthly_rent'); $form->addText('move_in_date', $this->getMoveInDate()); $form->setLabel('move_in_date', 'Move-in date'); $form->setExtra('move_in_date', 'class="datepicker"'); $form->addText('name', $this->name); $form->setLabel('name', 'Name of property'); $form->setRequired('name'); $form->setSize('name', 50); $form->addCheck('pets_allowed', 1); $form->setLabel('pets_allowed', 'Pets allowed'); $form->setMatch('pets_allowed', $this->pets_allowed); $form->addCheck('sublease', 1); $form->setMatch('sublease', $this->sublease); $form->setLabel('sublease', 'Sublease'); $toptions[TV_NONE] = 'Antenna'; $toptions[TV_CABLE] = 'Cable'; $toptions[TV_SATELLITE] = 'Satellite'; $toptions[TV_FIBER] = 'Fiber'; $form->addSelect('tv_type', $toptions); $form->setLabel('tv_type', 'Television'); $form->setMatch('tv_type', $this->tv_type); $form->addSelect('trash_type', array(TRASH_ON_YOUR_OWN => 'Trash and recycling receptacles not provided', TRASH_ON_PREMISES_NO_RECYCLE => 'Trash receptacles on site. Recycling not provided', TRASH_ON_PREMISES_WITH_RECYCLE => 'Trash and recycling receptacles provided on site', TRASH_PICKUP => 'Curbside pickup for trash and recycling')); $form->setMatch('trash_type', $this->trash_type); $form->setLabel('trash_type', 'Trash removal'); $form->addCheck('workout_room', 1); $form->setMatch('workout_room', $this->workout_room); $form->setLabel('workout_room', 'Workout room'); return $form; }
public function editReason() { $reason =& $this->reason; $form = new PHPWS_Form('edit-reason'); $form->addHidden('module', 'checkin'); $form->addHidden('aop', 'post_reason'); $form->addHidden('reason_id', $reason->id); $form->addText('summary', $reason->summary); $form->setSize('summary', 40); $form->setLabel('summary', dgettext('checkin', 'Summary')); $form->setRequired('summary'); $form->addTextArea('message', $reason->message); $form->setRequired('message'); $form->setLabel('message', dgettext('checkin', 'Completion message')); if ($reason->id) { $this->title = dgettext('checkin', 'Update reason'); $form->addSubmit('go', dgettext('checkin', 'Update')); } else { $this->title = dgettext('checkin', 'Add new reason'); $form->addSubmit('go', dgettext('checkin', 'Add')); } $template = $form->getTemplate(); $this->content = PHPWS_Template::process($template, 'checkin', 'edit_reason.tpl'); }
public function addForm(PHPWS_Form &$form) { $form->addText('account', $this->getAccount()); $form->setLabel('account', dgettext('analytics', 'Account Identifier (ie, UA-XXXXXXXX-X)')); $form->setRequired('account'); }