Ejemplo n.º 1
0
 public function show()
 {
     // Setup form
     $form = new \PHPWS_Form('addthis_settings');
     $form->setMethod('POST');
     // Hidden fields for directing this request after submission
     $form->addHidden('module', 'addthis');
     $form->addHidden('action', 'SaveSettings');
     // List of checkboxes and their labels for settings
     $settingList = array('enabled', 'fb_like_enabled', 'google_plus_enabled', 'share_bar_enabled');
     $settingLabels = array('Enabled', 'Facebook Like Enabled', 'Google+ Enabled', 'Share Bar Enabled');
     // Add checkboxes, set labels
     $form->addCheck('enabled_check', $settingList);
     $form->setLabel('enabled_check', $settingLabels);
     // If a setting is enabled, then check its box
     $toCheck = array();
     foreach ($this->settings->getAll() as $key => $value) {
         if ($value == 1) {
             $toCheck[] = $key;
         }
     }
     // NB: Have to set the checked elements all at once
     $form->setMatch('enabled_check', $toCheck);
     $form->addSubmit('submit', 'Submit');
     $tpl = $form->getTemplate();
     return \PHPWS_Template::process($tpl, 'addthis', 'settings.tpl');
 }
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'LotteryApplication.php');
     $this->setTitle('Special Interest Group');
     javascript('jquery');
     $tpl = array();
     $groups = HMS_Lottery::getSpecialInterestGroupsMap();
     // If a group was selected
     if (!is_null($this->group) && $this->group != 'none') {
         $tpl['GROUP_PAGER'] = LotteryApplication::specialInterestPager($this->group, PHPWS_Settings::get('hms', 'lottery_term'));
         $tpl['GROUP'] = $groups[$this->group];
     }
     // Show the drop down box of groups
     $form = new PHPWS_Form('special_interest');
     $form->setMethod('get');
     $form->addDropBox('group', $groups);
     $form->setClass('group', 'form-control');
     $form->setMatch('group', $this->group);
     $cmd = CommandFactory::getCommand('ShowSpecialInterestGroupApproval');
     $cmd->initForm($form);
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'hms', 'admin/special_interest_approval.tpl');
 }
 public function execute(CommandContext $context)
 {
     $options = array(BANNER_MEAL_LOW => 'Low', BANNER_MEAL_STD => 'Standard', BANNER_MEAL_HIGH => 'High', BANNER_MEAL_SUPER => 'Super', BANNER_MEAL_5WEEK => 'Summer (5 Weeks)', BANNER_MEAL_NONE => 'None');
     $form = new PHPWS_Form('select_meal');
     $form->addSelect('mealplan', $options);
     // If summer term, set default as Summer 5Week
     $term = Term::getSelectedTerm();
     if (strlen($term) >= 2 && (substr($term, -2) == TERM_SUMMER1 || substr($term, -2) == TERM_SUMMER2)) {
         $form->setMatch('mealplan', BANNER_MEAL_5WEEK);
     } else {
         $form->setMatch('mealplan', BANNER_MEAL_STD);
     }
     $form->setClass('mealplan', 'form-control');
     $template = $form->getTemplate();
     echo \PHPWS_Template::process($template, 'hms', 'admin/get_meal_plan_dropbox.tpl');
     exit;
 }
Ejemplo n.º 4
0
 function editSettings()
 {
     $form = new PHPWS_Form('whatsnew_settings');
     $form->addHidden('module', 'whatsnew');
     $form->addHidden('aop', 'post_settings');
     $form->addCheckbox('enable', 1);
     $form->setMatch('enable', PHPWS_Settings::get('whatsnew', 'enable'));
     $form->setLabel('enable', dgettext('whatsnew', 'Enable whatsnew'));
     $form->addCheckbox('homeonly', 1);
     $form->setMatch('homeonly', PHPWS_Settings::get('whatsnew', 'homeonly'));
     $form->setLabel('homeonly', dgettext('whatsnew', 'Show whatsnew sidebox on home page only'));
     $form->addTextField('title', PHPWS_Settings::get('whatsnew', 'title'));
     $form->setLabel('title', dgettext('whatsnew', 'Sidebox title'));
     $form->setSize('title', 30);
     $form->addTextArea('text', PHPWS_Settings::get('whatsnew', 'text'));
     $form->setRows('text', '4');
     $form->setCols('text', '40');
     $form->setLabel('text', dgettext('whatsnew', 'Sidebox text'));
     $form->addTextField('cache_timeout', PHPWS_Settings::get('whatsnew', 'cache_timeout'));
     $form->setLabel('cache_timeout', dgettext('whatsnew', 'Cache duration for whatsnew list (in seconds, 0-7200)'));
     $form->setSize('cache_timeout', 4, 4);
     $form->addTextField('qty_items', PHPWS_Settings::get('whatsnew', 'qty_items'));
     $form->setLabel('qty_items', dgettext('whatsnew', 'Number of recent items to display (0-50)'));
     $form->setSize('qty_items', 4, 4);
     $form->addCheckbox('show_summaries', 1);
     $form->setMatch('show_summaries', PHPWS_Settings::get('whatsnew', 'show_summaries'));
     $form->setLabel('show_summaries', dgettext('whatsnew', 'Show item summaries'));
     $form->addCheckbox('show_dates', 1);
     $form->setMatch('show_dates', PHPWS_Settings::get('whatsnew', 'show_dates'));
     $form->setLabel('show_dates', dgettext('whatsnew', 'Show item update dates'));
     $form->addCheckbox('show_source_modules', 1);
     $form->setMatch('show_source_modules', PHPWS_Settings::get('whatsnew', 'show_source_modules'));
     $form->setLabel('show_source_modules', dgettext('whatsnew', 'Show item source module names'));
     $form->addSubmit('save', dgettext('whatsnew', 'Save settings'));
     $tpl = $form->getTemplate();
     $tpl['SETTINGS_LABEL'] = dgettext('whatsnew', 'General Settings');
     $tpl['FLUSH_LINK'] = PHPWS_Text::secureLink(dgettext('whatsnew', 'Flush cache'), 'whatsnew', array('aop' => 'flush_cache'));
     $tpl['EXCLUDE'] = $this->whatsnew->getKeyMods(unserialize(PHPWS_Settings::get('whatsnew', 'exclude')), 'exclude');
     $tpl['EXCLUDE_LABEL'] = dgettext('whatsnew', 'Select any modules you wish to exclude from your whatsnew box.');
     $this->whatsnew->title = dgettext('whatsnew', 'Settings');
     $this->whatsnew->content = PHPWS_Template::process($tpl, 'whatsnew', 'edit_settings.tpl');
 }
 public function execute(CommandContext $context)
 {
     $options = array(ASSIGN_ADMIN => 'Administrative', ASSIGN_LOTTERY => 'Lottery', ASSIGN_FR => 'Freshmen', ASSIGN_TRANSFER => 'Transfer', ASSIGN_APH => 'APH', ASSIGN_RLC_FRESHMEN => 'RLC Freshmen', ASSIGN_RLC_TRANSFER => 'RLC Transfer', ASSIGN_RLC_CONTINUING => 'RLC Continuing', ASSIGN_HONORS_FRESHMEN => 'Honors Freshmen', ASSIGN_HONORS_CONTINUING => 'Honors Continuing', ASSIGN_LLC_FRESHMEN => 'LLC Freshmen', ASSIGN_LLC_CONTINUING => 'LLC Continuing', ASSIGN_INTL => 'International', ASSIGN_RA => 'RA', ASSIGN_RA_ROOMMATE => 'RA Roommate', ASSIGN_MEDICAL => 'Medical', ASSIGN_SPECIAL => 'Special Needs', ASSIGN_RHA => 'RHA/NRHH', ASSIGN_SCHOLARS => 'Diversity & Plemmons Scholars');
     $form = new PHPWS_Form('select_assignment');
     $form->addSelect('type', $options);
     $form->setMatch('type', ASSIGN_ADMIN);
     $form->setClass('type', 'form-control');
     $template = $form->getTemplate();
     echo \PHPWS_Template::process($template, 'hms', 'admin/assignment_type_dropbox.tpl');
     exit;
 }
Ejemplo n.º 6
0
 public function show()
 {
     // Setup form
     $form = new PHPWS_Form('likebox_settings');
     $form->setMethod('POST');
     // Hidden fields for directing this request after submission
     $form->addHidden('module', 'likebox');
     $form->addHidden('action', 'SaveSettings');
     // Enabled Checkbox
     $form->addCheck('enabled', 'enabled');
     $form->setLabel('enabled', 'Enabled');
     // URL
     $form->addText('fb_url', $this->settings->get('fb_url'));
     $form->setLabel('fb_url', 'Facebook Page URL:');
     // Width
     $form->addText('width', $this->settings->get('width'));
     $form->setLabel('width', 'Width');
     // Height
     $form->addText('height', $this->settings->get('height'));
     $form->setLabel('height', 'Height');
     // Show header bar i.e. "Find us on Facebook"
     $form->addCheck('small_header', 'small_header');
     $form->setLabel('small_header', 'Use Small header');
     // Show border
     $form->addCheck('hide_cover', 'hide_cover');
     $form->setLabel('hide_cover', 'Hide Cover Photo');
     // Show stream
     $form->addCheck('show_posts', 'show_posts');
     $form->setLabel('show_posts', 'Show Page Posts');
     // Show faces
     $form->addCheck('show_faces', 'show_faces');
     $form->setLabel('show_faces', 'Show Friend\'s faces');
     // Submit button
     $form->addSubmit('submit', 'Submit');
     $checkBoxes = array('enabled', 'small_header', 'hide_cover', 'show_posts', 'show_faces');
     foreach ($checkBoxes as $key) {
         $value = $this->settings->get($key);
         if (isset($value) && $value == 1) {
             $form->setMatch($key, $key);
         }
     }
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'likebox', 'settings.tpl');
 }
Ejemplo n.º 7
0
 public static function userForm(PHPWS_User $user, $message = NULL)
 {
     require_once PHPWS_SOURCE_DIR . 'core/class/Time.php';
     javascript('jquery');
     $form = new PHPWS_Form();
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'user');
     $form->addHidden('command', 'my_page');
     $form->addHidden('subcommand', 'postUser');
     if (Current_User::allow('users') || $user->display_name == $user->username) {
         $form->addText('display_name', $user->display_name);
         $form->setClass('display_name', 'form-control');
         $form->setLabel('display_name', dgettext('users', 'Display Name'));
     } else {
         $form->addTplTag('DISPLAY_NAME_LABEL', dgettext('users', 'Display Name'));
         $tpl['DISPLAY_NAME'] = javascript('slider', array('link' => $user->display_name, 'id' => 'name-info', 'message' => dgettext('users', 'Once you change your display name, you may not change it again until reset by the site administrator.')));
     }
     if ($user->canChangePassword()) {
         $form->addPassword('password1');
         $form->setAutoComplete('password1');
         $form->setClass('password1', 'form-control');
         $form->addPassword('password2');
         $form->setAutoComplete('password2');
         $form->setClass('password2', 'form-control');
         $form->setTitle('password2', dgettext('users', 'Password confirm'));
         $form->setLabel('password1', dgettext('users', 'Password'));
     } else {
         $tpl['PASSWORD1_LABEL'] = dgettext('users', 'Password');
         $tpl['PASSWORD1'] = javascript('slider', array('link' => dgettext('users', 'Why can\'t I change my password?'), 'id' => 'pw-info', 'message' => dgettext('users', 'Your account is authorized external to this site. You will need to update it at the source.')));
     }
     $form->addText('email', $user->getEmail());
     $form->setSize('email', 40);
     $form->setLabel('email', dgettext('users', 'Email Address'));
     $form->setClass('email', 'form-control');
     if (isset($tpl)) {
         $form->mergeTemplate($tpl);
     }
     $tz_list = PHPWS_Time::getTZList();
     $timezones['server'] = dgettext('users', '-- Use server\'s time zone --');
     foreach ($tz_list as $tz) {
         if (!empty($tz['codes'])) {
             $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['codes'][0]);
         } elseif (!empty($tz['city'])) {
             $timezones[$tz['id']] = sprintf('%s : %s', $tz['id'], $tz['city'][0]);
         } else {
             $timezones[$tz['id']] = $tz['id'];
         }
     }
     if (isset($_REQUEST['timezone'])) {
         $user_tz = $_REQUEST['timezone'];
     } else {
         $user_tz = PHPWS_Cookie::read('user_tz');
     }
     $form->addSelect('timezone', $timezones);
     $form->setLabel('timezone', dgettext('users', 'Time Zone'));
     $form->setMatch('timezone', $user_tz);
     $form->setClass('timezone', 'form-control');
     if (isset($_REQUEST['dst']) && $_REQUEST['timezone'] != 'server') {
         $dst = $_REQUEST['dst'];
     } else {
         $dst = PHPWS_Cookie::read('user_dst');
     }
     $form->addCheckbox('dst', 1);
     $form->setMatch('dst', $dst);
     $form->setLabel('dst', dgettext('users', 'Use Daylight Savings Time'));
     if (isset($_POST['cp'])) {
         $cp = (int) $_POST['cp'];
     } else {
         $cp = (int) PHPWS_Cookie::read('user_cp');
     }
     if (Current_User::allowRememberMe()) {
         // User must authorize locally
         if ($_SESSION['User']->authorize == 1) {
             $form->addCheckbox('remember_me', 1);
             if (PHPWS_Cookie::read('remember_me')) {
                 $form->setMatch('remember_me', 1);
             }
             $form->setLabel('remember_me', dgettext('users', 'Remember me'));
         }
     }
     $form->addHidden('userId', $user->getId());
     $form->addSubmit('submit', dgettext('users', 'Update my information'));
     $form->setClass('submit', 'btn btn-primary');
     if (!DISABLE_TRANSLATION && !FORCE_DEFAULT_LANGUAGE) {
         $language_file = PHPWS_Core::getConfigFile('users', 'languages.php');
         if ($language_file) {
             include $language_file;
             $form->addSelect('language', $languages);
             $form->setClass('language', 'form-control');
             $form->setLabel('language', dgettext('users', 'Language preference'));
             if (isset($_COOKIE['phpws_default_language'])) {
                 $language = preg_replace('/\\W/', '', $_COOKIE['phpws_default_language']);
                 $form->setMatch('language', $language);
             }
         }
     }
     $template = $form->getTemplate();
     if (isset($message)) {
         foreach ($message as $tag => $error) {
             $template[$tag] = $error;
         }
     }
     $template['ACCT_INFO'] = dgettext('users', 'Account Information');
     $template['LOCAL_INFO'] = dgettext('users', 'Localization');
     $template['PREF'] = dgettext('users', 'Preferences');
     return PHPWS_Template::process($template, 'users', 'my_page/user_setting.tpl');
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
 /**
  * Returns the html for the toolbar
  *
  * This function creates the toolbar which is used in edit mode to do
  * operations on this form (i.e.: Add Element, Settings, Save). It is
  * templated according to the form/toolbar.tpl template.
  *
  * @return string The html needed to display the toolbar
  * @access private
  * @see    view()
  */
 function _toolbar()
 {
     $elementTypes = array('PHAT_Dropbox' => dgettext('phatform', 'Dropbox'), 'PHAT_Textfield' => dgettext('phatform', 'Textfield'), 'PHAT_Textarea' => dgettext('phatform', 'Textarea'), 'PHAT_Multiselect' => dgettext('phatform', 'Multiple Select'), 'PHAT_Radiobutton' => dgettext('phatform', 'Radio Button'), 'PHAT_Checkbox' => dgettext('phatform', 'Checkbox'));
     for ($i = 1; $i <= $this->numPages(); $i++) {
         $pageNumber[$i] = $i;
     }
     $form = new PHPWS_Form();
     $form->addSelect('PHAT_PageNumber', $pageNumber);
     $form->setMatch('PHAT_PageNumber', $this->currentPage());
     $form->setLabel('PHAT_PageNumber', dgettext('phatform', 'Page'));
     $form->addSelect('PHAT_ElementType', $elementTypes);
     $form->addSubmit('PHAT_Go', dgettext('phatform', 'Go!'));
     $form->addSubmit('PHAT_Add', dgettext('phatform', 'Add'));
     $form->addSubmit('PHAT_Settings', dgettext('phatform', 'Form Settings'));
     if ($this->isApproved()) {
         $form->addSubmit('PHAT_Save', dgettext('phatform', 'Save Form'));
     }
     $form->addHidden('module', 'phatform');
     $form->addHidden('PHAT_FORM_OP', 'ToolbarAction');
     $template = $form->getTemplate();
     return PHPWS_Template::process($template, 'phatform', 'form/toolbar.tpl');
 }
Ejemplo n.º 10
0
 public function display()
 {
     // Set up search fields
     $form = new \PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'intern');
     $form->addHidden('action', 'results');
     $form->useRowRepeat();
     // Student name or Banner ID
     $form->addText('name');
     $form->setLabel('name', "Name or Banner ID");
     /***************
      * Course Info *
      ***************/
     $terms = Term::getTermsAssoc();
     $form->addSelect('term_select', $terms);
     $form->setLabel('term_select', 'Term');
     $form->setClass('term_select', 'form-control');
     $subjects = array('-1' => 'Select subject ') + Subject::getSubjects();
     $form->addSelect('course_subj', $subjects);
     $form->setLabel('course_subj', 'Subject');
     $form->setClass('course_subj', 'form-control');
     $form->addText('course_no');
     $form->setLabel('course_no', 'Course Number');
     $form->setSize('course_no', 6);
     $form->setMaxSize('course_no', 4);
     $form->setClass('course_no', 'form-control');
     $form->addText('course_sect');
     $form->setLabel('course_sect', 'Section');
     $form->setSize('course_sect', 6);
     $form->setMaxSize('course_sect', 4);
     $form->setClass('course_sect', 'form-control');
     /****************
      * Faculty Info *
      ****************/
     // Deity can search for any department. Other users are restricted.
     if (\Current_User::isDeity()) {
         $depts = Department::getDepartmentsAssoc();
     } else {
         $depts = Department::getDepartmentsAssocForUsername(\Current_User::getUsername());
     }
     $depts = array('-1' => 'Select Department') + $depts;
     $form->addSelect('dept', $depts);
     $form->setLabel('dept', 'Department');
     //$form->setClass('', 'form-control');
     $form->setClass('dept', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $form->setMatch('dept', $keys[1]);
     }
     // Student level radio button
     javascript('jquery');
     javascriptMod('intern', 'majorSelector', array('form_id' => $form->id));
     // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected)
     $levels = array('-1' => 'Choose student level first');
     $form->addDropBox('student_major', $levels);
     $form->setLabel('student_major', 'Major / Program');
     $form->addCssClass('student_major', 'form-control');
     // Get the majors list
     $majorsList = MajorsProviderFactory::getProvider()->getMajors(Term::timeToTerm(time()));
     // Undergrad major drop down
     $undergradMajors = array('-1' => 'Select Undergraduate Major') + $majorsList->getUndergradMajorsAssoc();
     $form->addSelect('undergrad_major', $undergradMajors);
     $form->setMatch('undergrad_major', '-1');
     $form->setClass('undergrad_major', 'form-control');
     // Graduate major drop down
     $graduateMajors = array('-1' => 'Select Graduate Major') + $majorsList->getGraduateMajorsAssoc();
     $form->addSelect('graduate_major', $graduateMajors);
     $form->setMatch('graduate_major', '-1');
     $form->setClass('graduate_major', 'form-control');
     /*******************
      * Internship Type *
      *******************/
     // Handeled directly in the html template
     /************
      * Location *
      ************/
     // Campus Handeled directly in the html template
     // International vs Domestic - Handeled directly in the html template
     // State search
     /*******************
      * Workflow States *
      *******************/
     $workflowStates = WorkflowStateFactory::getStatesAssoc();
     unset($workflowStates['Intern\\WorkflowState\\CreationState']);
     // Remove this state, since it's not valid (internal only state for initial creation)
     $form->addCheckAssoc('workflow_state', $workflowStates);
     $form->addSubmit('submit', 'Search');
     // Javascript...
     javascriptMod('intern', 'resetSearch');
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'search.tpl');
 }
Ejemplo n.º 11
0
 /**
  * DBPager row method for the floor edit pager.
  *
  * @return Array
  */
 public function get_row_edit()
 {
     javascript('jquery');
     $tpl = array();
     $tpl['ID'] = $this->id;
     $tpl['ROOM_NUMBER'] = PHPWS_Text::secureLink($this->room_number, 'hms', array('action' => 'EditRoomView', 'room' => $this->id));
     if (Current_User::allow('hms', 'room_structure') && $this->get_number_of_assignees() == 0) {
         $deleteRoomCmd = CommandFactory::getCommand('DeleteRoom');
         $deleteRoomCmd->setRoomId($this->id);
         $deleteRoomCmd->setFloorId($this->floor_id);
         $confirm = array();
         $confirm['QUESTION'] = 'Are you sure want to delete room ' . $this->room_number . '?';
         $confirm['ADDRESS'] = $deleteRoomCmd->getURI();
         $confirm['LINK'] = 'Delete';
         $tpl['DELETE'] = Layout::getJavascript('confirm', $confirm);
     }
     $form = new PHPWS_Form($this->id);
     $form->addSelect('gender_type', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, COED => COED_DESC, AUTO => AUTO_DESC));
     $form->setMatch('gender_type', $this->gender_type);
     $form->setExtra('gender_type', 'onChange="submit_form(this, true)"');
     $form->addSelect('default_gender', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, AUTO => AUTO_DESC));
     $form->setMatch('default_gender', $this->default_gender);
     $form->setExtra('default_gender', 'onChange="submit_form(this, true)"');
     $form->addSelect('rlc_reserved', array('-1' => 'Select RLC') + RlcFactory::getRlcList($this->term));
     $form->setMatch('rlc_reserved', $this->getReservedRlcId());
     $form->setExtra('rlc_reserved', 'onChange="submit_form(this, true)"');
     $form->addCheck('offline', 'yes');
     $form->setMatch('offline', $this->offline == 1 ? 'yes' : 0);
     $form->setExtra('offline', 'onChange="submit_form(this, false)"');
     $form->addCheck('reserved', 'yes');
     $form->setMatch('reserved', $this->reserved == 1 ? 'yes' : 0);
     $form->setExtra('reserved', 'onChange="submit_form(this, false)"');
     $form->addCheck('ra', 'yes');
     $form->setMatch('ra', $this->ra == 1 ? 'yes' : 0);
     $form->setExtra('ra', 'onChange="submit_form(this, false)"');
     $form->addCheck('private', 'yes');
     $form->setMatch('private', $this->private == 1 ? 'yes' : 0);
     $form->setExtra('private', 'onChange="submit_form(this, false)"');
     $form->addCheck('overflow', 'yes');
     $form->setMatch('overflow', $this->overflow == 1 ? 'yes' : 0);
     $form->setExtra('overflow', 'onChange="submit_form(this, false)"');
     $form->addCheck('ada', 'yes');
     $form->setMatch('ada', $this->isAda() ? 'yes' : 0);
     $form->setExtra('ada', 'onChange="submit_form(this, false)"');
     $form->addHidden('action', 'UpdateRoomField');
     $form->addHidden('room', $this->id);
     $form->mergeTemplate($tpl);
     //test($form->getTemplate(),1);
     return $form->getTemplate();
 }
Ejemplo n.º 12
0
 public static function addAlternates(PHPWS_Form $form)
 {
     $file = PHPWS_Core::getConfigFile('search', 'alternate.php');
     if ($file) {
         include $file;
         if (!empty($alternate_search_engine) && is_array($alternate_search_engine)) {
             $alternate_sites['local'] = dgettext('search', 'Local');
             foreach ($alternate_search_engine as $title => $altSite) {
                 $alternate_sites[$title] = $altSite['title'];
             }
             $form->addRadio('alternate', array_keys($alternate_sites));
             $form->setLabel('alternate', $alternate_sites);
             $form->setMatch('alternate', 'local');
         }
     }
 }
Ejemplo n.º 13
0
 public function schedulePick()
 {
     $schedules = $this->calendar->getScheduleList('brief');
     if (count($schedules) < 2) {
         return null;
     }
     $form = new PHPWS_Form('schedule_pick');
     $form->setMethod('get');
     $form->addHidden('module', 'calendar');
     $form->addHidden('view', $this->current_view);
     $form->addHidden('date', $this->calendar->current_date);
     $form->addSelect('sch_id', $schedules);
     $form->setMatch('sch_id', $this->calendar->schedule->id);
     $form->addSubmit('go', dgettext('calendar', 'Change schedule'));
     $tpl = $form->getTemplate();
     return $tpl['START_FORM'] . $tpl['SCH_ID'] . $tpl['GO'] . $tpl['END_FORM'];
 }
Ejemplo n.º 14
0
 public function userSignup()
 {
     if (!$this->signup->sheet->id) {
         PHPWS_Core::errorPage('404');
     }
     $sheet = $this->signup->sheet;
     $peep = $this->signup->peep;
     if (Current_User::isLogged() && empty($peep->email)) {
         $peep->email = Current_User::getEmail();
     }
     if ($sheet->end_time < time()) {
         $this->signup->title = dgettext('signup', 'Sorry');
         $this->signup->content = dgettext('signup', 'We are no longer accepting applications.');
         return;
     }
     $slots = $sheet->getAllSlots();
     $slots_filled = $sheet->totalSlotsFilled();
     if (empty($slots)) {
         $this->signup->title = dgettext('signup', 'Sorry');
         $this->signup->content = dgettext('signup', 'There is a problem with this signup sheet. Please check back later.');
         return;
     }
     $this->signup->title =& $sheet->title;
     foreach ($slots as $slot) {
         // if the slots are filled, don't offer it
         if ($slots_filled && isset($slots_filled[$slot->id])) {
             $filled =& $slots_filled[$slot->id];
             if ($filled >= $slot->openings) {
                 continue;
             } else {
                 $openings_left = $slot->openings - $filled;
             }
         } else {
             $openings_left =& $slot->openings;
         }
         $options[$slot->id] = sprintf(dngettext('signup', '%s (%s opening)', '%s (%s openings)', $openings_left), $slot->title, $openings_left);
     }
     if (!isset($options)) {
         $this->signup->content = dgettext('signup', 'Sorry, but all available slots are full. Please check back later for possible cancellations.');
         return;
     } else {
         $form = new PHPWS_Form('slots');
         $form->useFieldset();
         $form->setLegend(dgettext('signup', 'Signup form'));
         $form->addHidden('module', 'signup');
         $form->addHidden('uop', 'slot_signup');
         $form->addHidden('sheet_id', $this->signup->sheet->id);
         $form->addSelect('slot_id', $options);
         $form->setLabel('slot_id', dgettext('signup', 'Available slots'));
         $form->setMatch('slot_id', $peep->slot_id);
         $form->addText('first_name', $peep->first_name);
         $form->setLabel('first_name', dgettext('signup', 'First name'));
         $form->addText('last_name', $peep->last_name);
         $form->setLabel('last_name', dgettext('signup', 'Last name'));
         $form->addText('email', $peep->email);
         $form->setSize('email', 30);
         $form->setLabel('email', dgettext('signup', 'Email address'));
         $form->addText('phone', $peep->getPhone());
         $form->setSize('phone', 15);
         $form->setLabel('phone', dgettext('signup', 'Phone number'));
         if (!empty($this->signup->sheet->extra1)) {
             $form->addText('extra1', $peep->extra1);
             $form->setLabel('extra1', $this->signup->sheet->extra1);
         }
         if (!empty($this->signup->sheet->extra2)) {
             $form->addText('extra2', $peep->extra2);
             $form->setLabel('extra2', $this->signup->sheet->extra2);
         }
         if (!empty($this->signup->sheet->extra3)) {
             $form->addText('extra3', $peep->extra3);
             $form->setLabel('extra3', $this->signup->sheet->extra3);
         }
         $form->addSubmit(dgettext('signup', 'Submit'));
         $tpl = $form->getTemplate();
     }
     $tpl['DESCRIPTION'] = $sheet->getDescription();
     $this->signup->content = PHPWS_Template::process($tpl, 'signup', 'signup_form.tpl');
     $this->signup->sheet->flag();
 }
Ejemplo n.º 15
0
 /**
  * Creates the permission menu template
  */
 public static function permissionMenu(Key $key, $popbox = FALSE)
 {
     $edit_groups = Users_Permission::getRestrictedGroups($key, TRUE);
     if (PHPWS_Error::isError($edit_groups)) {
         PHPWS_Error::log($edit_groups);
         $tpl['MESSAGE'] = $edit_groups->getMessage();
         return $tpl;
     }
     $view_groups = User_Form::_getNonUserGroups();
     $view_matches = $key->getViewGroups();
     $edit_matches = $key->getEditGroups();
     if (!empty($edit_groups)) {
         $edit_select = User_Form::_createMultiple($edit_groups['restricted']['all'], 'edit_groups', $edit_matches);
     } else {
         $edit_select = null;
     }
     if (!empty($view_groups)) {
         $view_select = User_Form::_createMultiple($view_groups, 'view_groups', $view_matches);
     } else {
         $view_select = null;
     }
     $form = new PHPWS_Form('choose_permissions');
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'permission');
     $form->addHidden('key_id', $key->id);
     $form->addRadio('view_permission', array(0, 1, 2));
     $form->setExtra('view_permission', 'onclick="hideSelect(this.value)"');
     $form->setLabel('view_permission', array(dgettext('users', 'All visitors'), dgettext('users', 'Logged visitors'), dgettext('users', 'Specific group(s)')));
     $form->setMatch('view_permission', $key->restricted);
     $form->addSubmit(dgettext('users', 'Save permissions'));
     if ($popbox) {
         $form->addHidden('popbox', 1);
     }
     $tpl = $form->getTemplate();
     $tpl['TITLE'] = dgettext('users', 'Permissions');
     $tpl['EDIT_SELECT_LABEL'] = dgettext('users', 'Edit restrictions');
     $tpl['VIEW_SELECT_LABEL'] = dgettext('users', 'View restrictions');
     if ($edit_select) {
         $tpl['EDIT_SELECT'] = $edit_select;
     } else {
         $tpl['EDIT_SELECT'] = dgettext('users', 'No restricted edit groups found.');
     }
     if ($view_select) {
         $tpl['VIEW_SELECT'] = $view_select;
     } else {
         $tpl['VIEW_SELECT'] = dgettext('users', 'No view groups found.');
     }
     if ($popbox) {
         $tpl['CANCEL'] = sprintf('<input type="button" value="%s" onclick="window.close()" />', dgettext('users', 'Cancel'));
     }
     if (isset($_SESSION['Permission_Message'])) {
         $tpl['MESSAGE'] = $_SESSION['Permission_Message'];
         unset($_SESSION['Permission_Message']);
     }
     return $tpl;
 }
Ejemplo n.º 16
0
 private function settingsForm()
 {
     \Layout::addStyle('properties', 'forms.css');
     $form = new \PHPWS_Form();
     $form->addHidden('module', 'properties');
     $form->addHidden('aop', 'post_settings');
     $form->addText('login_link', \PHPWS_Settings::get('properties', 'login_link'));
     $form->setLabel('login_link', 'Alternate authentication link');
     $form->setSize('login_link', 30);
     $form->addText('email', \PHPWS_Settings::get('properties', 'email'));
     $form->setLabel('email', 'Site email');
     $form->setSize('email', 30);
     $form->addCheck('roommate_only');
     $form->setMatch('roommate_only', \PHPWS_Settings::get('properties', 'roommate_only'));
     $form->setLabel('roommate_only', 'Only use the roommate functionality');
     $form->addSubmit('Save settings');
     $tpl = $form->getTemplate();
     if (!empty($this->errors)) {
         foreach ($this->errors as $key => $message) {
             $new_key = strtoupper($key) . '_ERROR';
             $tpl[$new_key] = $message;
         }
     }
     $this->title = 'Settings';
     $this->content = \PHPWS_Template::process($tpl, 'properties', 'settings.tpl');
 }
Ejemplo n.º 17
0
 /**
  * Edit a new or existing PHAT_Dropbox element
  *
  * The edit function provides the HTML form to edit a new or existing
  * PHAT_Dropbox element.
  * g
  * return string The HTML form to edit a PHAT_Dropbox
  */
 function edit()
 {
     $numOptions = sizeof($this->getOptionText());
     if (!$numOptions || $this->getOptionSet()) {
         $numOptions = '';
     }
     $form = new PHPWS_Form();
     $form->addHidden('module', 'phatform');
     $form->addHidden('PHAT_EL_OP', 'SaveElement');
     if (!$this->getLabel()) {
         $num = $_SESSION['PHAT_FormManager']->form->numElements();
         $this->setLabel('Element' . ($num + 1));
     }
     $form->addTextArea('PHAT_ElementBlurb', $this->getBlurb());
     $form->setRows('PHAT_ElementBlurb', PHAT_DEFAULT_ROWS);
     $form->setCols('PHAT_ElementBlurb', PHAT_DEFAULT_COLS);
     $form->setLabel('PHAT_ElementBlurb', dgettext('phatform', 'Associated Text'));
     $form->addText('PHAT_ElementName', $this->getLabel());
     $form->setSize('PHAT_ElementName', PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
     $form->setLabel('PHAT_ElementName', dgettext('phatform', 'Name'));
     $form->addText('PHAT_ElementNumOptions', $numOptions);
     $form->setSize('PHAT_ElementNumOptions', 5, 3);
     $form->setLabel('PHAT_ElementNumOptions', dgettext('phatform', 'Number of Options'));
     $options = $this->getOptionSets();
     if (is_array($options)) {
         $editTags['OPTION_SET_LABEL'] = dgettext('phatform', 'Predefined Option Set');
         $form->addSelect('PHAT_OptionSet', $options);
         $form->setMatch('PHAT_OptionSet', $this->getOptionSet());
     }
     $form->addCheck('PHAT_ElementRequired', 1);
     $form->setMatch('PHAT_ElementRequired', $this->isRequired());
     $form->setLabel('PHAT_ElementRequired', dgettext('phatform', 'Required'));
     $form->addSubmit('PHAT_ElementBack', dgettext('phatform', 'Back'));
     $form->addSubmit('NEXT_BUTTON', dgettext('phatform', 'Next'));
     $template = $form->getTemplate();
     return PHPWS_Template::processTemplate($template, 'phatform', 'dropbox/edit.tpl');
 }
Ejemplo n.º 18
0
 function getKeyMods($match = null, $select_name = 'exclude', $multiple = true, $count = true)
 {
     PHPWS_Core::initCoreClass('Key.php');
     $db = new PHPWS_DB('phpws_key');
     $db->addOrder('module asc');
     $result = $db->getObjects('Key');
     if ($result) {
         foreach ($result as $item) {
             if ($count) {
                 $db = new PHPWS_DB('phpws_key');
                 $db->addWhere('module', $item->module);
                 $qty = $db->count();
                 if ($qty == 1) {
                     $qty_label = dgettext('whatsnew', 'item');
                 } else {
                     $qty_label = dgettext('whatsnew', 'items');
                 }
                 $items[$item->module] = $item->module . ' (' . $qty . ' ' . $qty_label . ')';
             } else {
                 $items[$item->module] = $item->module;
             }
         }
     }
     if ($items) {
         if ($multiple) {
             $form = new PHPWS_Form();
             $form->addMultiple($select_name, $items);
             if (!empty($match) && is_array($match)) {
                 $form->setMatch($select_name, $match);
             }
             return $form->get($select_name);
         } else {
             $form = new PHPWS_Form();
             $form->addSelect($select_name, $items);
             if (!empty($match) && is_string($match)) {
                 $form->setMatch($select_name, $match);
             }
             return $form->get($select_name);
         }
     } else {
         return dgettext('whatsnew', 'No keyed items.');
     }
 }
Ejemplo n.º 19
0
 /**
  * Form for meta tags. Used for site mata tags and individual key
  * meta tags.
  */
 public static function metaForm($key_id = 0)
 {
     $meta_description = $meta_keywords = $page_title = null;
     $meta_robots = '11';
     if (!$key_id) {
         $vars = $_SESSION['Layout_Settings']->getMetaTags();
     } else {
         $vars = $_SESSION['Layout_Settings']->getPageMetaTags($key_id);
         if (empty($vars)) {
             $vars = $_SESSION['Layout_Settings']->getMetaTags();
             $key = new Key($key_id);
             $vars['page_title'] = $key->title;
         }
     }
     if (is_array($vars)) {
         extract($vars);
     }
     $index = substr($meta_robots, 0, 1);
     $follow = substr($meta_robots, 1, 1);
     $form = new PHPWS_Form('metatags');
     if ($key_id) {
         $form->addHidden('key_id', $key_id);
         $form->addSubmit('reset', dgettext('layout', 'Restore to default'));
     }
     $form->addHidden('module', 'layout');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'postMeta');
     $form->addText('page_title', $page_title);
     $form->setClass('page_title', 'form-control');
     $form->setLabel('page_title', dgettext('layout', 'Site Name'));
     $form->addTextArea('meta_keywords', $meta_keywords);
     $form->setLabel('meta_keywords', dgettext('layout', 'Keywords'));
     $form->setClass('meta_keywords', 'form-control');
     $form->addTextArea('meta_description', $meta_description);
     $form->setLabel('meta_description', dgettext('layout', 'Description'));
     $form->setClass('meta_description', 'form-control');
     $form->addCheckBox('index', 1);
     $form->setMatch('index', $index);
     $form->setLabel('index', dgettext('layout', 'Allow indexing'));
     $form->addCheckBox('follow', 1);
     $form->setMatch('follow', $follow);
     $form->setLabel('follow', dgettext('layout', 'Allow link following'));
     $form->addCheckBox('use_key_summaries', 1);
     $form->setMatch('use_key_summaries', PHPWS_Settings::get('layout', 'use_key_summaries'));
     $form->setLabel('use_key_summaries', dgettext('layout', 'Use Key summaries for meta description'));
     $form->addSubmit('submit', dgettext('layout', 'Update'));
     $template = $form->getTemplate();
     $template['ROBOT_LABEL'] = dgettext('layout', 'Default Robot Settings');
     return PHPWS_Template::process($template, 'layout', 'metatags.tpl');
 }
Ejemplo n.º 20
0
 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');
 }
Ejemplo n.º 21
0
 public static function edit(Block_Item $block, $js = FALSE)
 {
     javascript('jquery');
     javascript('ckeditor');
     $form = new PHPWS_Form('block-form');
     $form->addHidden('module', 'block');
     $form->addCheck('hide_title', 1);
     $form->setMatch('hide_title', $block->hide_title);
     $form->setLabel('hide_title', dgettext('block', 'Hide title'));
     $form->addCheck('hide_narrow', 1);
     $form->setMatch('hide_narrow', $block->hide_narrow);
     $form->setLabel('hide_narrow', dgettext('block', 'Hide when width &lt; 768px'));
     $form->addTextArea('block_content', $block->getContent(false));
     $form->setRows('block_content', '10');
     $form->setWidth('block_content', '80%');
     $form->setLabel('block_content', dgettext('block', 'Entry'));
     if ($js) {
         if (isset($_REQUEST['key_id']) && is_numeric($_REQUEST['key_id'])) {
             $key_id = (int) $_REQUEST['key_id'];
         } else {
             $key_id = 0;
         }
         $form->addHidden('key_id', $key_id);
         $form->addHidden('action', 'postJSBlock');
         $pdb = Database::newDB();
         $pdb->addTable('block_pinned');
         $all_pinned = $pdb->select();
         if (!empty($all_pinned)) {
             $pinned = new \Variable\Arr($all_pinned);
             $pinned->indexByColumn('block_id', true, 'key_id');
             $pinned_keys = $pinned->get();
         } else {
             $pinned_keys = null;
         }
         $db = Database::newDB();
         $blocks = $db->addTable('block');
         $blocks->addField('id');
         $blocks->addOrderBy($blocks->addField('title'));
         $db->loadSelectStatement();
         while ($b = $db->fetch()) {
             /**
              * Checking here to see if this block is already set for the current
              * key OR is this block is set to show everywhere. If either,
              * then don't add to select list.
              */
             if (!empty($pinned_keys)) {
                 if (isset($pinned_keys[$b['id']])) {
                     if (in_array($key_id, $pinned_keys[$b['id']]) || in_array('-1', $pinned_keys[$b['id']])) {
                         continue;
                     }
                 }
             }
             $block_options[$b['id']] = $b['title'];
         }
         if (!empty($block_options)) {
             $form->addSelect('block_list', $block_options);
             $form->addSubmit('pick_block', 'Add this block to the page');
         }
     } else {
         $form->useEditor('block_content');
         $form->addHidden('action', 'postBlock');
         if (empty($block->id)) {
             $form->addSubmit('submit', dgettext('block', 'Save New Block'));
         } else {
             $form->addHidden('block_id', $block->getId());
             $form->addSubmit('submit', dgettext('block', 'Update Current Block'));
         }
     }
     $form->addText('title', $block->getTitle());
     $form->setLabel('title', dgettext('block', 'Title'));
     $form->setSize('title', 50);
     $template = $form->getTemplate();
     if ($js) {
         if (!empty($block_options)) {
             $template['ALTERNATIVE'] = t('or create new block below');
         }
         $content = PHPWS_Template::process($template, 'block', 'js_edit.tpl');
     } else {
         $content = PHPWS_Template::process($template, 'block', 'edit.tpl');
     }
     return $content;
 }
Ejemplo n.º 22
0
 public function show()
 {
     require PHPWS_SOURCE_DIR . 'mod/hms/inc/profile_options.php';
     $majors = hms\MajorFactory::getMajorsList();
     $tpl = array();
     $profile_form = new PHPWS_Form('profile_form');
     $profile_form->useRowRepeat();
     $none_given = '<span style="color:#CCC;">none given</span>';
     /***** Contact Info *****/
     $tpl['TITLE'] = $this->student->getName() . '\'s Profile';
     $tpl['EMAIL_ADDRESS'] = "<a href=\"mailto:{$this->student->getUsername()}@appstate.edu\">{$this->student->getUsername()}@appstate.edu</a>";
     $tpl['ALTERNATE_EMAIL_LABEL'] = 'Alternate email: ';
     $alt_email = $this->profile->get_text('alternate_email');
     if (!empty($alt_email)) {
         $tpl['ALTERNATE_EMAIL'] = "<a href=\"mailto:{$alt_email}\">{$alt_email}</a>";
     } else {
         $tpl['ALTERNATE_EMAIL'] = $none_given;
     }
     $tpl['FB_LINK_LABEL'] = 'Facebook link: ';
     $fb_link = $this->profile->get_text('fb_link');
     if (!empty($fb_link)) {
         $tpl['FB_LINK'] = $fb_link;
     } else {
         $tpl['FB_LINK'] = $none_given;
     }
     $tpl['INSTAGRAM_SN_LABEL'] = 'Instagram username: '******'instagram_sn');
     if (!empty($instagram_sn)) {
         $tpl['INSTAGRAM_SN'] = $instagram_sn;
     } else {
         $tpl['INSTAGRAM_SN'] = $none_given;
     }
     $tpl['TWITTER_SN_LABEL'] = 'Twitter username: '******'twitter_sn');
     if (!empty($twitter_sn)) {
         $tpl['TWITTER_SN'] = $twitter_sn;
     } else {
         $tpl['TWITTER_SN'] = $none_given;
     }
     $tpl['TUMBLR_SN_LABEL'] = 'Tumblr username: '******'tumblr_sn');
     if (!empty($tumblr_sn)) {
         $tpl['TUMBLR_SN'] = $tumblr_sn;
     } else {
         $tpl['TUMBLR_SN'] = $none_given;
     }
     $tpl['KIK_SN_LABEL'] = 'Kik username: '******'kik_sn');
     if (!empty($kik_sn)) {
         $tpl['KIK_SN'] = $kik_sn;
     } else {
         $tpl['KIK_SN'] = $none_given;
     }
     $tpl['ABOUT_ME_LABEL'] = 'Additional information: ';
     $about_me = $this->profile->get_text('about_me');
     if (!empty($about_me)) {
         $tpl['ABOUT_ME'] = $about_me;
     } else {
         $tpl['ABOUT_ME'] = $none_given;
     }
     /***** About Me *****/
     $profile_form->addCheck('hobbies_checkbox', $hobbies);
     $profile_form->setLabel('hobbies_checkbox', $hobbies_labels);
     $profile_form->setDisabled('hobbies_checkbox');
     $tpl['HOBBIES_CHECKBOX_QUESTION'] = 'My Hobbies and Interests: ';
     # set matches on hobby check boxes
     $hobbies_matches = RoommateProfileFactory::get_hobbies_matches($this->profile);
     $profile_form->setMatch('hobbies_checkbox', $hobbies_matches);
     $profile_form->addCheck('music_checkbox', $music);
     $profile_form->setLabel('music_checkbox', $music_labels);
     $profile_form->setDisabled('music_checkbox');
     $tpl['MUSIC_CHECKBOX_QUESTION'] = 'My Music Preferences: ';
     # set matches on music check boxes
     $music_matches = RoommateProfileFactory::get_music_matches($this->profile);
     $profile_form->setMatch('music_checkbox', $music_matches);
     $profile_form->addCheck('language_checkbox', $language);
     $profile_form->setLabel('language_checkbox', $language_labels);
     $profile_form->setDisabled('language_checkbox');
     $tpl['LANGUAGE_CHECKBOX_QUESTION'] = 'Languages I speak: ';
     # set matches on language check boxes
     $language_matches = RoommateProfileFactory::get_language_matches($this->profile);
     $profile_form->setMatch('language_checkbox', $language_matches);
     $tpl['POLITICAL_VIEWS_LABEL'] = 'Political views: ';
     $tpl['POLITICAL_VIEWS'] = $political_views[$this->profile->get_text('political_views')];
     /***** College Life *****/
     $tpl['MAJOR_LABEL'] = 'Intended major: ';
     $tpl['MAJOR'] = $majors[$this->profile->get_text('major')];
     $tpl['EXPERIENCE_LABEL'] = 'I feel the most important part of my college experience is: ';
     $tpl['EXPERIENCE'] = $experiences[$this->profile->get_text('experience')];
     /***** Daily Life *****/
     $tpl['SLEEP_TIME_LABEL'] = 'I generally go to sleep: ';
     $tpl['SLEEP_TIME'] = $sleep_times[$this->profile->get_text('sleep_time')];
     $tpl['WAKEUP_TIME_LABEL'] = 'I generally wake up: ';
     $tpl['WAKEUP_TIME'] = $wakeup_times[$this->profile->get_text('wakeup_time')];
     $tpl['OVERNIGHT_GUESTS_LABEL'] = 'I plan on hosting overnight guests: ';
     $tpl['OVERNIGHT_GUESTS'] = $overnight_guests[$this->profile->get_text('overnight_guests')];
     $tpl['LOUDNESS_LABEL'] = 'In my daily activities: ';
     $tpl['LOUDNESS'] = $loudness[$this->profile->get_text('loudness')];
     $tpl['CLEANLINESS_LABEL'] = 'I would describe myself as: ';
     $tpl['CLEANLINESS'] = $cleanliness[$this->profile->get_text('cleanliness')];
     $tpl['FREE_TIME_LABEL'] = 'If I have free time I would rather: ';
     $tpl['FREE_TIME'] = $free_time[$this->profile->get_text('free_time')];
     $profile_form->addCheck('study_times', $study_times);
     $profile_form->setLabel('study_times', $study_times_labels);
     $profile_form->setDisabled('study_times');
     $tpl['STUDY_TIMES_QUESTION'] = 'I prefer to study: ';
     # set matches on study times check boxes here, set disabled
     $study_matches = RoommateProfileFactory::get_study_matches($this->profile);
     $profile_form->setMatch('study_times', $study_matches);
     $profile_form->mergeTemplate($tpl);
     $tpl = $profile_form->getTemplate();
     Layout::addPageTitle("Roommate Profile");
     return PHPWS_Template::process($tpl, 'hms', 'student/profile_form.tpl');
 }
Ejemplo n.º 23
0
 /**
  * View of files in current folder
  */
 public function folderContentView()
 {
     javascript('jquery');
     PHPWS_Core::initModClass('filecabinet', 'Image.php');
     javascript('confirm');
     // needed for deletion
     Layout::addStyle('filecabinet');
     if (empty($this->current_folder) || empty($this->folder_type)) {
         javascript('alert', array('content' => dgettext('filecabinet', 'Problem with opening browser page. Closing File Manager window.')));
         javascript('close_refresh', array('timeout' => 3, 'refresh' => 0));
         return;
     }
     $tpl = array();
     $this->folderIcons($tpl);
     if (Current_User::allow('filecabinet', 'edit_folders')) {
         $tpl['FOLDER_TITLE'] = $this->current_folder->editLink('title', $this->current_folder->module_created);
     } else {
         $tpl['FOLDER_TITLE'] =& $this->current_folder->title;
     }
     $img_dir = PHPWS_SOURCE_HTTP . 'mod/filecabinet/img/file_manager/';
     $image_string = '<img src="%s" title="%s" alt="%s" />';
     $link_info = $this->linkInfo();
     switch ($this->folder_type) {
         case IMAGE_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize image.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This image is larger than the %s x %s limit. Do you want to resize the image to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             $db = new PHPWS_DB('images');
             $class_name = 'PHPWS_Image';
             $file_type = FC_IMAGE;
             $altvars = $link_info;
             // check
             unset($altvars['mw']);
             unset($altvars['mh']);
             unset($altvars['fr']);
             $img1 = 'folder_random.png';
             $img2 = 'thumbnails.png';
             $img3 = 'lightbox.png';
             $img1_alt = dgettext('filecabinet', 'Random image icon');
             $img2_alt = dgettext('filecabinet', 'Thumbnail icon');
             $img3_alt = dgettext('filecabinet', 'Lightbox icon');
             if (!$this->reserved_folder) {
                 if ($this->current_folder->public_folder) {
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_IMAGE_RANDOM;
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     if (!$this->lock_type || in_array(FC_IMAGE_RANDOM, $this->lock_type)) {
                         $img1_title = dgettext('filecabinet', 'Show a random image from this folder');
                         $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                         $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                         if ($this->file_assoc->file_type == FC_IMAGE_RANDOM && $this->current_folder->id == $this->file_assoc->file_id) {
                             $tpl['ALT_HIGH1'] = ' alt-high';
                         }
                     } else {
                         $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                         $tpl['ALT1'] = $image1;
                         $tpl['ALT_HIGH1'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_FOLDER, $this->lock_type)) {
                         /** start new * */
                         if ($this->file_assoc->file_type == FC_IMAGE_FOLDER) {
                             $tpl['ALT_HIGH2'] = ' alt-high';
                         }
                         $img2_title = dgettext('filecabinet', 'Show block of thumbnails');
                         $image2 = sprintf($image_string, $img_dir . $img2, $img2_title, $img2_alt);
                         $form = new PHPWS_Form('carousel-options');
                         $form->setMethod('get');
                         $altvars['file_type'] = FC_IMAGE_FOLDER;
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8);
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Carousel direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return carousel_pick();">%s</a>', $image2);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT2'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/carousel_pick.tpl');
                     } else {
                         $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                         $tpl['ALT2'] = $image2;
                         $tpl['ALT_HIGH2'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_LIGHTBOX, $this->lock_type)) {
                         /** start VV * */
                         if ($this->file_assoc->file_type == FC_IMAGE_LIGHTBOX) {
                             $tpl['ALT_HIGH3'] = ' alt-high';
                         }
                         $img3_title = dgettext('filecabinet', 'Show lightbox slideshow');
                         $image3 = sprintf($image_string, $img_dir . $img3, $img3_title, $img3_alt);
                         $altvars['file_type'] = FC_IMAGE_LIGHTBOX;
                         $form = new PHPWS_Form('lightbox-options');
                         $form->setMethod('get');
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(3 => 3, 6 => 6, 9 => 9, 12 => 12, 15 => 15, 18 => 18, 21 => 21, 99 => 'unlimited');
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Thumbnail direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return lightbox_pick();">%s</a>', $image3);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT3'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/lightbox_pick.tpl');
                     } else {
                         $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                         $tpl['ALT3'] = $image3;
                         $tpl['ALT_HIGH3'] = ' no-use';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                     $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                     $tpl['ALT2'] = $image2;
                     $tpl['ALT_HIGH2'] = ' no-use';
                     $tpl['ALT3'] = $image3;
                     $tpl['ALT_HIGH3'] = ' no-use';
                 }
             }
             break;
         case DOCUMENT_FOLDER:
             PHPWS_Core::initModClass('filecabinet', 'Document.php');
             $db = new PHPWS_DB('documents');
             $class_name = 'PHPWS_Document';
             $file_type = FC_DOCUMENT;
             $img1 = 'all_files.png';
             $img1_alt = dgettext('filecabinet', 'All files icon');
             if ($this->current_folder->public_folder) {
                 if (!$this->lock_type || in_array(FC_DOCUMENT_FOLDER, $this->lock_type)) {
                     $altvars = $link_info;
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_DOCUMENT_FOLDER;
                     $img1_title = dgettext('filecabinet', 'Show all files in the folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                     $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                     if ($this->file_assoc->file_type == FC_DOCUMENT_FOLDER && $this->current_folder->id == $this->file_assoc->file_id) {
                         $tpl['ALT_HIGH1'] = ' alt-high';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                 }
             } else {
                 $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                 $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                 $tpl['ALT1'] = $image1;
                 $tpl['ALT_HIGH1'] = ' no-use';
             }
             break;
         case MULTIMEDIA_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize media.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This media is larger than the %s x %s limit. Do you want to resize the media to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
             $db = new PHPWS_DB('multimedia');
             $class_name = 'PHPWS_Multimedia';
             $file_type = FC_MEDIA;
             //$tpl['ADD_EMBED'] = $this->current_folder->embedLink(true);
             break;
     }
     $db->addWhere('folder_id', $this->current_folder->id);
     $db->addOrder('title');
     $items = $db->getObjects($class_name);
     if ($items) {
         foreach ($items as $item) {
             $stpl = $item->managerTpl($this);
             $tpl['items'][] = $stpl;
         }
     } else {
         $not_allowed = dgettext('filecabinet', 'No files in folder');
         if (isset($tpl['ALT1'])) {
             $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
             $tpl['ALT1'] = $image1;
             $tpl['ALT_HIGH1'] = ' no-use';
         }
         if (isset($tpl['ALT2'])) {
             $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
             $tpl['ALT2'] = $image2;
             $tpl['ALT_HIGH2'] = ' no-use';
         }
     }
     if (Current_User::allow('filecabinet', 'edit_folders', $this->current_folder->id, 'folder')) {
         if ($this->force_upload_dimensions) {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true, $this->max_width, $this->max_height);
         } else {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true);
         }
     }
     $tpl['CLOSE'] = javascript('close_window');
     return PHPWS_Template::process($tpl, 'filecabinet', 'file_manager/folder_content_view.tpl');
 }
Ejemplo n.º 24
0
 public function fileTypes()
 {
     $known_images = null;
     $known_media = null;
     $known_documents = null;
     include PHPWS_SOURCE_DIR . 'mod/filecabinet/inc/known_types.php';
     $image_types = explode(',', PHPWS_Settings::get('filecabinet', 'image_files'));
     $media_types = explode(',', PHPWS_Settings::get('filecabinet', 'media_files'));
     $doc_types = explode(',', PHPWS_Settings::get('filecabinet', 'document_files'));
     $all_file_types = PHPWS_File::getAllFileTypes();
     $form = new PHPWS_Form('allowed-file-types');
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('aop', 'post_allowed_files');
     $img_checks = $this->sortType($known_images, $all_file_types);
     if (!empty($img_checks)) {
         $form->addCheckAssoc('allowed_images', $img_checks);
         $form->setMatch('allowed_images', $image_types);
     }
     $media_checks = $this->sortType($known_media, $all_file_types);
     if (isset($media_checks)) {
         $form->addCheckAssoc('allowed_media', $media_checks);
         $form->setMatch('allowed_media', $media_types);
     }
     $doc_checks = $this->sortType($known_documents, $all_file_types);
     if (isset($doc_checks)) {
         $form->addCheckAssoc('allowed_documents', $doc_checks);
         $form->setMatch('allowed_documents', $doc_types);
     }
     $form->useRowRepeat();
     $form->addSubmit(dgettext('filecabinet', 'Save allowed files'));
     $tpl = $form->getTemplate();
     $tpl['CHECK_IMAGES'] = javascript('check_all', array('checkbox_name' => 'allowed_images'));
     $tpl['CHECK_MEDIA'] = javascript('check_all', array('checkbox_name' => 'allowed_media'));
     $tpl['CHECK_DOCUMENTS'] = javascript('check_all', array('checkbox_name' => 'allowed_documents'));
     return PHPWS_Template::process($tpl, 'filecabinet', 'Forms/allowed_types.tpl');
 }
Ejemplo n.º 25
0
 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');
 }
Ejemplo n.º 26
0
 public function settings()
 {
     $form = new PHPWS_Form('calendar_settings');
     $form->addHidden('module', 'calendar');
     $form->addHidden('aop', 'post_settings');
     $form->addCheckbox('allow_submissions', 1);
     $form->setMatch('allow_submissions', PHPWS_Settings::get('calendar', 'allow_submissions'));
     $form->setLabel('allow_submissions', dgettext('calendar', 'Allow public event submissions'));
     $form->addCheckbox('mini_event_link', 1);
     $form->setMatch('mini_event_link', PHPWS_Settings::get('calendar', 'mini_event_link'));
     $form->setLabel('mini_event_link', dgettext('calendar', 'Only link days with events in mini calendar'));
     $form->addCheckbox('anon_ical', 1);
     $form->setMatch('anon_ical', PHPWS_Settings::get('calendar', 'anon_ical'));
     $form->setLabel('anon_ical', dgettext('calendar', 'Allow anonymous iCal exports of public schedules'));
     $form->addCheckbox('no_follow', 1);
     $form->setMatch('no_follow', PHPWS_Settings::get('calendar', 'no_follow'));
     $form->setLabel('no_follow', dgettext('calendar', 'No follow directives added to navigation links'));
     $start_days = array(0, 1);
     $start_days_label[0] = strftime('%A', mktime(0, 0, 0, 1, 4, 1970));
     $start_days_label[1] = strftime('%A', mktime(0, 0, 0, 1, 5, 1970));
     $form->addRadio('starting_day', $start_days);
     $form->setLabel('starting_day', $start_days_label);
     $form->setMatch('starting_day', PHPWS_Settings::get('calendar', 'starting_day'));
     $form->addRadio('brief_grid', array(0, 1));
     $form->setMatch('brief_grid', PHPWS_Settings::get('calendar', 'brief_grid'));
     $form->setLabel('brief_grid', array(0 => dgettext('calendar', 'Show event titles'), 1 => dgettext('calendar', 'Show number of events')));
     $form->addCheck('personal_schedules', 1);
     $form->setLabel('personal_schedules', dgettext('calendar', 'Allow personal schedules'));
     $form->setMatch('personal_schedules', PHPWS_Settings::get('calendar', 'personal_schedules'));
     $form->addCheck('cache_month_views', 1);
     $form->setLabel('cache_month_views', dgettext('calendar', 'Cache month views (public only)'));
     $form->setMatch('cache_month_views', PHPWS_Settings::get('calendar', 'cache_month_views'));
     $form->addCheck('mini_grid', 1);
     $form->setLabel('mini_grid', dgettext('calendar', 'Show mini grid'));
     $form->setMatch('mini_grid', PHPWS_Settings::get('calendar', 'mini_grid'));
     $form->addRadio('display_mini', array(0, 1, 2));
     $form->setLabel('display_mini', array(dgettext('calendar', 'Don\'t show'), dgettext('calendar', 'Only on front page'), dgettext('calendar', 'On all pages')));
     $form->setMatch('display_mini', PHPWS_Settings::get('calendar', 'display_mini'));
     $views['grid'] = dgettext('calendar', 'Month grid');
     $views['list'] = dgettext('calendar', 'Month list');
     $views['day'] = dgettext('calendar', 'Day view');
     $views['week'] = dgettext('calendar', 'Week view');
     $form->addSelect('default_view', $views);
     $form->setLabel('default_view', dgettext('calendar', 'Default view'));
     $form->setMatch('default_view', PHPWS_Settings::get('calendar', 'default_view'));
     $form->addSubmit(dgettext('calendar', 'Save settings'));
     $tpl = $form->getTemplate();
     $tpl['BRIEF_GRID_LABEL'] = dgettext('calendar', 'Grid event display');
     $tpl['MINI_CALENDAR'] = dgettext('calendar', 'Display mini calendar');
     $tpl['START_LABEL'] = dgettext('calendar', 'Week start day');
     $this->content = PHPWS_Template::process($tpl, 'calendar', 'admin/settings.tpl');
     $this->title = dgettext('calendar', 'Calendar settings');
 }
Ejemplo n.º 27
0
 public static function settings()
 {
     $form = new PHPWS_Form('rss-settings');
     $form->addHidden('module', 'rss');
     $form->addHidden('command', 'save_settings');
     $files = array(1 => '1', 2 => '2');
     $filenames = array(1 => 'RSS 1.0', 2 => 'RSS 2.0');
     $form->addRadio('rssfeed', $files);
     $form->setLabel('rssfeed', $filenames);
     $form->setMatch('rssfeed', PHPWS_Settings::get('rss', 'rssfeed'));
     $form->addText('editor', PHPWS_Settings::get('rss', 'editor'));
     $form->setLabel('editor', dgettext('rss', 'Managing editor email address'));
     $form->setSize('editor', 30);
     $form->addText('webmaster', PHPWS_Settings::get('rss', 'webmaster'));
     $form->setLabel('webmaster', dgettext('rss', 'Webmaster email address'));
     $form->setSize('webmaster', 30);
     $form->addText('copyright', PHPWS_Settings::get('rss', 'copyright'));
     $form->setLabel('copyright', dgettext('rss', 'Copyright'));
     $form->setSize('copyright', 40);
     $form->addSubmit(dgettext('rss', 'Save settings'));
     $tpl = $form->getTemplate();
     $fc['TITLE'] = dgettext('rss', 'General Settings');
     $fc['CONTENT'] = PHPWS_Template::process($tpl, 'rss', 'settings.tpl');
     return $fc;
 }
Ejemplo n.º 28
0
 /**
  * Form to create or edit a branch
  */
 public function edit_db($force = false)
 {
     $this->title = dgettext('branch', 'Setup branch database');
     $form = new PHPWS_Form('branch-form');
     $form->addHidden('module', 'branch');
     $form->addHidden('command', 'post_db');
     $form->addHidden('force', (int) $force);
     $form->addCheck('createdb', $this->createdb);
     $form->setLabel('createdb', dgettext('branch', 'Create new database'));
     $form->addSelect('dbtype', $this->db_list);
     $form->setMatch('dbtype', $this->dbtype);
     $form->setLabel('dbtype', dgettext('branch', 'Database syntax'));
     $form->addText('dbname', $this->dbname);
     $form->setLabel('dbname', dgettext('branch', 'Database name'));
     $form->addText('dbuser', $this->dbuser);
     $form->setLabel('dbuser', dgettext('branch', 'Permission user'));
     $form->addPassword('dbpass', $this->dbpass);
     $form->allowValue('dbpass');
     $form->setLabel('dbpass', dgettext('branch', 'User password'));
     $form->addText('dbprefix', $this->dbprefix);
     $form->setLabel('dbprefix', dgettext('branch', 'Table prefix'));
     $form->setSize('dbprefix', 5, 5);
     $form->addText('dbhost', $this->dbhost);
     $form->setLabel('dbhost', dgettext('branch', 'Database Host'));
     $form->setSize('dbhost', 40);
     $form->addText('dbport', $this->dbport);
     $form->setLabel('dbport', dgettext('branch', 'Connection Port'));
     $form->addTplTag('DB_LEGEND', dgettext('branch', 'Database information'));
     $form->addSubmit('plug', dgettext('branch', 'Use hub values'));
     $form->addSubmit('submit', dgettext('branch', 'Continue...'));
     $template = $form->getTemplate();
     $this->content = PHPWS_Template::process($template, 'branch', 'edit_db.tpl');
 }
Ejemplo n.º 29
0
 public function databaseConfig()
 {
     $form = new PHPWS_Form();
     $form->addHidden('step', '2');
     $databases = array('mysqli' => 'MySQL', 'pgsql' => 'PostgreSQL');
     $formTpl['DBTYPE_DEF'] = dgettext('core', 'phpWebSite supports MySQL and PostgreSQL. Choose the type your server currently is running.');
     $formTpl['DBUSER_DEF'] = dgettext('core', 'This is the user name that phpWebSite will use to access its database.') . ' <br /><i>' . dgettext('core', 'Note: it is a good idea to give each phpWebSite installation its own user.') . '</i>';
     if (isset($this->messages['dbuser'])) {
         $formTpl['DBUSER_ERR'] = $this->messages['dbuser'];
     }
     $formTpl['DBPASS_DEF'] = dgettext('core', 'Enter the database\'s user password here.');
     if (isset($this->messages['dbpass'])) {
         $formTpl['DBPASS_ERR'] = $this->messages['dbpass'];
     }
     $formTpl['DBPREF_DEF'] = dgettext('core', 'If you are installing phpWebSite in a shared environment, you may assign a prefix to tables.<br />We recommend you run without one.');
     if (isset($this->messages['dbpref'])) {
         $formTpl['DBPREF_ERR'] = $this->messages['dbpref'];
     }
     $formTpl['DBHOST_DEF'] = dgettext('core', 'If your database is on the same server as your phpWebSite installation, leave this as &#x22;localhost&#x22;.') . '<br />' . dgettext('core', 'Otherwise, enter the ip or dns to the database server.');
     $formTpl['DBPORT_DEF'] = dgettext('core', 'If your host specification requires access via a specific port, enter it here.');
     $formTpl['DBNAME_DEF'] = dgettext('core', 'The database\'s name into which you are installing phpWebSite.') . '<br /><i>' . dgettext('core', 'Note: if you have not made this database yet, you should do so before continuing.') . '</i>';
     if (isset($this->messages['dbname'])) {
         $formTpl['DBNAME_ERR'] = $this->messages['dbname'];
     }
     $formTpl['TITLE'] = dgettext('core', 'Database configuration');
     $form->addSelect('dbtype', $databases);
     $form->setMatch('dbtype', $this->getConfigSet('dbtype'));
     $form->setLabel('dbtype', dgettext('core', 'Database Type'));
     $form->addText('dbuser', $this->getConfigSet('dbuser'));
     $form->setSize('dbuser', 20);
     $form->setLabel('dbuser', dgettext('core', 'Database User'));
     $form->addPassword('dbpass', $this->getConfigSet('dbpass'));
     $form->allowValue('dbpass');
     $form->setSize('dbpass', 20);
     $form->setLabel('dbpass', dgettext('core', 'Database Password'));
     $form->addText('dbprefix', $this->getConfigSet('dbprefix'));
     $form->setSize('dbprefix', 5, 5);
     $form->setLabel('dbprefix', dgettext('core', 'Table prefix'));
     $form->addText('dbhost', $this->getConfigSet('dbhost'));
     $form->setSize('dbhost', 20);
     $form->setLabel('dbhost', dgettext('core', 'Host Specification'));
     $form->addText('dbport', $this->getConfigSet('dbport'));
     $form->setSize('dbport', 6);
     $form->setLabel('dbport', dgettext('core', 'Host Specification Port'));
     $form->addText('dbname', $this->getConfigSet('dbname'));
     $form->setSize('dbname', 20);
     $form->setLabel('dbname', dgettext('core', 'Database Name'));
     $form->mergeTemplate($formTpl);
     $form->addSubmit('default_submit', dgettext('core', 'Continue'));
     $this->content = $this->createForm($form, 'databaseConfig.tpl');
     $this->title = dgettext('core', 'Configure phpWebSite');
     $this->display();
 }
Ejemplo n.º 30
0
 public function getPageDrop()
 {
     if (empty($this->total_pages)) {
         $page_list[1] = 1;
     } else {
         for ($i = 1; $i <= $this->total_pages; $i++) {
             $page_list[$i] = $i;
         }
     }
     $form = new PHPWS_Form('page_list');
     $form->setMethod('get');
     $values = $this->getLinkValues();
     $form->addHidden($values);
     $form->addSelect('change_page', $page_list);
     $form->setExtra('change_page', 'onchange="this.form.submit()"');
     $form->setMatch('change_page', $this->current_page);
     if (!function_exists('javascriptEnabled') || !javascriptEnabled()) {
         $form->addSubmit('go', _('Go'));
     }
     $template = $form->getTemplate();
     if (PHPWS_Error::isError($template)) {
         PHPWS_Error::log($template);
         return null;
     }
     return $template['START_FORM'] . $template['CHANGE_PAGE'] . $template['END_FORM'];
 }