/**
  * (non-PHPdoc)
  * @see SpecialEPFormPage::getFormFields()
  * @return array
  */
 protected function getFormFields()
 {
     $fields = parent::getFormFields();
     $fields['name'] = array('type' => 'text', 'label-message' => 'ep-course-edit-name', 'maxlength' => 255, 'required' => true, 'validation-callback' => function ($value, array $alldata = null) {
         return strlen($value) < 5 ? wfMsgExt('ep-course-invalid-name', 'parsemag', 5) : true;
     });
     $orgOptions = EPOrg::getOrgOptions();
     $fields['org_id'] = array('type' => 'select', 'label-message' => 'ep-course-edit-org', 'required' => true, 'options' => $orgOptions, 'validation-callback' => function ($value, array $alldata = null) use($orgOptions) {
         return in_array((int) $value, array_values($orgOptions)) ? true : wfMsg('ep-course-invalid-org');
     });
     $fields['description'] = array('type' => 'textarea', 'label-message' => 'ep-course-edit-description', 'required' => true, 'validation-callback' => function ($value, array $alldata = null) {
         return strlen($value) < 10 ? wfMsgExt('ep-course-invalid-description', 'parsemag', 10) : true;
     }, 'rows' => 10);
     return $this->processFormFields($fields);
 }
Exemplo n.º 2
0
 /**
  * (non-PHPdoc)
  * @see EPEditAction::getFormFields()
  * @return array
  */
 protected function getFormFields()
 {
     $fields = parent::getFormFields();
     $orgOptions = EPOrg::getOrgOptions();
     $fields['name'] = array('type' => 'text', 'label-message' => 'ep-course-edit-name', 'required' => true);
     $mcs = EPCourse::selectFields('mc', array(), array('DISTINCT'));
     if ($this->getRequest()->getCheck('newname')) {
         $newName = $this->getRequest()->getText('newname');
         $mcs = array_merge(array($newName => $newName), $mcs);
     } else {
         $mcs = array_merge(array('' => ''), $mcs);
     }
     $fields['mc'] = array('class' => 'EPHTMLCombobox', 'label-message' => 'ep-course-edit-mc', 'required' => true, 'options' => array_combine($mcs, $mcs));
     $fields['org_id'] = array('type' => 'select', 'label-message' => 'ep-course-edit-org', 'required' => true, 'options' => $orgOptions, 'validation-callback' => function ($value, array $alldata = null) use($orgOptions) {
         return in_array((int) $value, array_values($orgOptions)) ? true : wfMsg('ep-course-invalid-org');
     });
     $fields['token'] = array('type' => 'text', 'label-message' => 'ep-course-edit-token', 'maxlength' => 255, 'size' => 20, 'validation-callback' => function ($value, array $alldata = null) {
         $strLen = strlen($value);
         return $strLen !== 0 && $strLen < 2 ? wfMsgExt('ep-course-invalid-token', 'parsemag', 2) : true;
     });
     $fields['term'] = array('type' => 'text', 'label-message' => 'ep-course-edit-term', 'required' => true);
     $fields['start'] = array('class' => 'EPHTMLDateField', 'label-message' => 'ep-course-edit-start', 'required' => true);
     $fields['end'] = array('class' => 'EPHTMLDateField', 'label-message' => 'ep-course-edit-end', 'required' => true);
     $fieldFields = EPCourse::selectFields('field', array(), array('DISTINCT'));
     $fieldFields = array_merge(array('' => ''), $fieldFields);
     $fields['field'] = array('class' => 'EPHTMLCombobox', 'label-message' => 'ep-course-edit-field', 'required' => true, 'options' => array_combine($fieldFields, $fieldFields));
     $levels = EPCourse::selectFields('level', array(), array('DISTINCT'));
     $levels = array_merge(array('' => ''), $levels);
     $fields['level'] = array('class' => 'EPHTMLCombobox', 'label-message' => 'ep-course-edit-level', 'required' => true, 'options' => array_combine($levels, $levels));
     $langOptions = EPUtils::getLanguageOptions($this->getLanguage()->getCode());
     $fields['lang'] = array('type' => 'select', 'label-message' => 'ep-course-edit-lang', 'maxlength' => 255, 'required' => true, 'options' => $langOptions, 'validation-callback' => function ($value, array $alldata = null) use($langOptions) {
         return in_array($value, $langOptions) ? true : wfMsg('ep-course-invalid-lang');
     });
     $fields['description'] = array('type' => 'textarea', 'label-message' => 'ep-course-edit-description', 'required' => true, 'validation-callback' => function ($value, array $alldata = null) {
         return strlen($value) < 10 ? wfMsgExt('ep-course-invalid-description', 'parsemag', 10) : true;
     }, 'rows' => 10, 'id' => 'wpTextbox1');
     return $this->processFormFields($fields);
 }
Exemplo n.º 3
0
 /**
  * (non-PHPdoc)
  * @see EPPager::getFilterOptions()
  */
 protected function getFilterOptions()
 {
     $options = array();
     $options['org_id'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPOrg::getOrgOptions(EPOrg::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int');
     $terms = EPCourse::selectFields('term', array(), array('DISTINCT'), array(), true);
     natcasesort($terms);
     $terms = array_merge(array(''), $terms);
     $terms = array_combine($terms, $terms);
     $options['term'] = array('type' => 'select', 'options' => $terms, 'value' => '');
     //		$options['lang'] = array(
     //			'type' => 'select',
     //			'options' => EPUtils::getLanguageOptions( $this->getLanguage()->getCode() ),
     //			'value' => '',
     //		);
     $options['status'] = array('type' => 'select', 'options' => array_merge(array('' => ''), EPCourse::getStatuses()), 'value' => 'current');
     return $options;
 }
Exemplo n.º 4
0
 /**
  * Adds a control to add a new course 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 = array())
 {
     if (!$context->getUser()->isAllowed('ep-course')) {
         return false;
     }
     $out = $context->getOutput();
     $out->addHTML(Html::openElement('form', array('method' => 'post', 'action' => SpecialPage::getTitleFor('EditCourse')->getLocalURL())));
     $out->addHTML('<fieldset>');
     $out->addHTML('<legend>' . wfMsgHtml('ep-courses-addnew') . '</legend>');
     $out->addHTML(Html::element('p', array(), wfMsg('ep-courses-namedoc')));
     $out->addHTML(Html::element('label', array('for' => 'neworg'), wfMsg('ep-courses-neworg')));
     $out->addHTML('&#160;');
     $select = new XmlSelect('neworg', 'neworg', array_key_exists('org', $args) ? $args['org'] : false);
     $select->addOptions(EPOrg::getOrgOptions());
     $out->addHTML($select->getHTML());
     $out->addHTML('&#160;');
     $out->addHTML(Xml::inputLabel(wfMsg('ep-courses-newname'), 'newname', 'newname', false, array_key_exists('name', $args) ? $args['name'] : false));
     $out->addHTML('&#160;');
     $out->addHTML(Html::input('addneworg', wfMsg('ep-courses-add'), 'submit'));
     $out->addHTML(Html::hidden('isnew', 1));
     $out->addHTML('</fieldset></form>');
     return true;
 }
 /**
  * (non-PHPdoc)
  * @see EPPager::getFilterOptions()
  */
 protected function getFilterOptions()
 {
     return array('org_id' => array('type' => 'select', 'options' => array_merge(array('' => ''), EPOrg::getOrgOptions(EPOrg::select(array('name', 'id')))), 'value' => '', 'datatype' => 'int'), 'active' => array('type' => 'select', 'options' => array('' => '', wfMsg('epcoursepager-yes') => '1', wfMsg('epcoursepager-no') => '0'), 'value' => ''));
 }
Exemplo n.º 6
0
 /**
  * (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;
 }
Exemplo n.º 7
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-course')) {
         return false;
     }
     $out = $context->getOutput();
     $out->addModules('ep.addcourse');
     $out->addHTML(Html::openElement('form', array('method' => 'post', 'action' => self::getTitleFor('NAME_PLACEHOLDER')->getLocalURL(array('action' => 'edit')))));
     $out->addHTML('<fieldset>');
     $out->addHTML('<legend>' . wfMsgHtml('ep-courses-addnew') . '</legend>');
     $out->addElement('p', array(), wfMsg('ep-courses-namedoc'));
     $out->addElement('label', array('for' => 'neworg'), wfMsg('ep-courses-neworg'));
     $select = new XmlSelect('neworg', 'neworg', array_key_exists('org', $args) ? $args['org'] : false);
     $select->addOptions(EPOrg::getOrgOptions());
     $out->addHTML($select->getHTML());
     $out->addHTML('&#160;' . Xml::inputLabel(wfMsg('ep-courses-newname'), 'newname', 'newname', 20, array_key_exists('name', $args) ? $args['name'] : false));
     $out->addHTML('&#160;' . Xml::inputLabel(wfMsg('ep-courses-newterm'), 'newterm', 'newterm', 10, array_key_exists('term', $args) ? $args['term'] : false));
     $out->addHTML('&#160;' . Html::input('addnewcourse', wfMsg('ep-courses-add'), 'submit', array('disabled' => 'disabled', 'class' => 'ep-course-add')));
     $out->addHTML(Html::hidden('isnew', 1));
     $out->addHTML('</fieldset></form>');
     return true;
 }