/**
  * (non-PHPdoc)
  * @see SpecialEPFormPage::getFormFields()
  * @return array
  */
 protected function getFormFields()
 {
     $fields = parent::getFormFields();
     $courseOptions = EPCourse::getCourseOptions();
     $fields['course_id'] = array('type' => 'select', 'label-message' => 'ep-term-edit-course', 'required' => true, 'options' => $courseOptions, 'validation-callback' => function ($value, array $alldata = null) use($courseOptions) {
         return in_array((int) $value, array_values($courseOptions)) ? true : wfMsg('ep-term-invalid-course');
     });
     $fields['token'] = array('type' => 'text', 'label-message' => 'ep-term-edit-token', 'maxlength' => 255, 'required' => true, 'size' => 20, 'validation-callback' => function ($value, array $alldata = null) {
         $strLen = strlen($value);
         return $strLen !== 0 && $strLen < 2 ? wfMsgExt('ep-term-invalid-token', 'parsemag', 2) : true;
     });
     $fields['year'] = array('type' => 'int', 'label-message' => 'ep-term-edit-year', 'required' => true, 'min' => 2000, 'max' => 9001, 'size' => 15);
     $fields['start'] = array('class' => 'EPHTMLDateField', 'label-message' => 'ep-term-edit-start', 'required' => true);
     $fields['end'] = array('class' => 'EPHTMLDateField', 'label-message' => 'ep-term-edit-end', 'required' => true);
     $fields['description'] = array('type' => 'textarea', 'label-message' => 'ep-term-edit-description', 'required' => true, 'validation-callback' => function ($value, array $alldata = null) {
         return strlen($value) < 10 ? wfMsgExt('ep-term-invalid-description', 'parsemag', 10) : true;
     }, 'rows' => 10);
     return $this->processFormFields($fields);
 }
Example #2
0
 /**
  * Adds a control to add a term org to the provided context.
  * Additional arguments can be provided to set the default values for the control fields.
  *
  * @since 0.1
  *
  * @param IContextSource $context
  * @param array $args
  *
  * @return boolean
  */
 public static function displayAddNewControl(IContextSource $context, array $args)
 {
     if (!$context->getUser()->isAllowed('ep-term')) {
         return false;
     }
     $out = $context->getOutput();
     $out->addHTML(Html::openElement('form', array('method' => 'post', 'action' => SpecialPage::getTitleFor('EditTerm')->getLocalURL())));
     $out->addHTML('<fieldset>');
     $out->addHTML('<legend>' . wfMsgHtml('ep-terms-addnew') . '</legend>');
     $out->addHTML(Html::element('p', array(), wfMsg('ep-terms-namedoc')));
     $out->addHTML(Html::element('label', array('for' => 'newcourse'), wfMsg('ep-terms-newcourse')));
     $select = new XmlSelect('newcourse', 'newcourse', array_key_exists('course', $args) ? $args['course'] : false);
     $select->addOptions(EPCourse::getCourseOptions());
     $out->addHTML($select->getHTML());
     $out->addHTML('&#160;' . Xml::inputLabel(wfMsg('ep-terms-newyear'), 'newyear', 'newyear', 10));
     $out->addHTML('&#160;' . Html::input('addnewterm', wfMsg('ep-terms-add'), 'submit'));
     $out->addHTML(Html::hidden('isnew', 1));
     $out->addHTML('</fieldset></form>');
     return true;
 }
 /**
  * (non-PHPdoc)
  * @see EPPager::getFilterOptions()
  */
 protected function getFilterOptions()
 {
     $options = array();
     if (!array_key_exists('course_id', $this->conds)) {
         $options['course_id'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPCourse::getCourseOptions(EPCourse::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int');
         $options['org_id'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPOrg::getOrgOptions(EPOrg::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int');
     }
     $years = EPTerm::selectFields('year', array(), array('DISTINCT'), array(), true);
     asort($years, SORT_NUMERIC);
     $years = array_merge(array(''), $years);
     $years = array_combine($years, $years);
     $options['year'] = array('type' => 'select', 'options' => $years, 'value' => '');
     $options['status'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPTerm::getStatuses()), 'value' => 'current');
     return $options;
 }