MDL-22574 removing obsolete choose file elements that can not work any more, developers have to upgrade code
This commit is contained in:
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
global $CFG;
|
||||
require_once "$CFG->libdir/form/group.php";
|
||||
|
||||
/**
|
||||
* Class for an element used to choose a file from the course files folder.
|
||||
*
|
||||
*
|
||||
* @author Jamie Pratt <[email protected]>
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_choosecoursefile extends MoodleQuickForm_group
|
||||
{
|
||||
/**
|
||||
* Options for element :
|
||||
*
|
||||
* $url must be relative to home page eg /mod/survey/stuff.php
|
||||
* courseid => int course id if null then uses $COURSE global
|
||||
* width => int Height to assign to popup window
|
||||
* title => string Text to be displayed as popup page title
|
||||
* options => string List of additional options for popup window
|
||||
*/
|
||||
var $_options = array('courseid'=>null,
|
||||
'height'=>500, 'width'=>750, 'options'=>'none');
|
||||
|
||||
/**
|
||||
* These complement separators, they are appended to the resultant HTML
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
var $_wrap = array('', '');
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string Element's name
|
||||
* @param mixed Label(s) for an element
|
||||
* @param array Options to control the element's display
|
||||
* @param mixed Either a typical HTML attribute string or an associative array
|
||||
*/
|
||||
function MoodleQuickForm_choosecoursefile($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
|
||||
{
|
||||
$this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
|
||||
$this->_appendName = true;
|
||||
$this->_type = 'choosecoursefile';
|
||||
// set the options, do not bother setting bogus ones
|
||||
if (is_array($options)) {
|
||||
foreach ($options as $name => $value) {
|
||||
if (isset($this->_options[$name])) {
|
||||
if (is_array($value) && is_array($this->_options[$name])) {
|
||||
$this->_options[$name] = @array_merge($this->_options[$name], $value);
|
||||
} else {
|
||||
$this->_options[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _createElements()
|
||||
|
||||
function _createElements() {
|
||||
global $COURSE, $OUTPUT;
|
||||
$this->_elements = array();
|
||||
|
||||
if (!is_array($this->getAttributes()) || !array_key_exists('size', $this->getAttributes())) {
|
||||
$this->updateAttributes(array('size' => 48));
|
||||
}
|
||||
|
||||
$this->_elements[0] =& MoodleQuickForm::createElement('text', 'value', '', $this->getAttributes());
|
||||
$this->_elements[1] =& MoodleQuickForm::createElement('button', 'popup', get_string('chooseafile', 'resource') .' ...');
|
||||
|
||||
$button =& $this->_elements[1];
|
||||
|
||||
if ($this->_options['courseid']!==null){
|
||||
$courseid=$this->_options['courseid'];
|
||||
} else {
|
||||
$courseid=$COURSE->id;
|
||||
}
|
||||
// first find out the text field id - this is a bit hacky, is there a better way?
|
||||
$choose = 'id_'.str_replace(array('[', ']'), array('_', ''), $this->getElementName(0));
|
||||
$url="/files/index.php?id=$courseid&choose=".$choose;
|
||||
|
||||
$fullscreen = 0;
|
||||
|
||||
$buttonattributes = array('title'=>get_string("chooseafile", "resource"));
|
||||
|
||||
$button->updateAttributes($buttonattributes);
|
||||
|
||||
//attach the onclick event
|
||||
if ($this->_options['options'] == 'none') {
|
||||
$options = array('height'=>$this->_options['height'],'width'=>$this->_options['width']);
|
||||
}else{
|
||||
$options = $this->_options['options'];
|
||||
}
|
||||
$action = new popup_action('click', $url, $button->getName(), $options);
|
||||
|
||||
$button->updateAttributes(array('id'=>$OUTPUT->add_action_handler($action, $button->getAttribute('id'))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a timestamp. Give it the name of the group.
|
||||
*
|
||||
* @param array $submitValues
|
||||
* @param bool $assoc
|
||||
* @return array
|
||||
*/
|
||||
function exportValue(&$submitValues, $assoc = false)
|
||||
{
|
||||
$value = null;
|
||||
$valuearray = $this->_elements[0]->exportValue($submitValues[$this->getName()], true);
|
||||
$value[$this->getName()]=$valuearray['value'];
|
||||
return $value;
|
||||
}
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* Called by HTML_QuickForm whenever form event is made on this element
|
||||
*
|
||||
* @param string $event Name of event
|
||||
* @param mixed $arg event arguments
|
||||
* @param object $caller calling object
|
||||
* @since 1.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function onQuickFormEvent($event, $arg, &$caller)
|
||||
{
|
||||
switch ($event) {
|
||||
case 'updateValue':
|
||||
// constant values override both default and submitted ones
|
||||
// default values are overriden by submitted
|
||||
$value = $this->_findValue($caller->_constantValues);
|
||||
if (null === $value) {
|
||||
$value = $this->_findValue($caller->_submitValues);
|
||||
if (null === $value) {
|
||||
$value = $this->_findValue($caller->_defaultValues);
|
||||
}
|
||||
}
|
||||
if (!is_array($value)) {
|
||||
$value = array('value' => $value);
|
||||
}
|
||||
if (null !== $value) {
|
||||
$this->setValue($value);
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return parent::onQuickFormEvent($event, $arg, $caller);
|
||||
|
||||
} // end func onQuickFormEvent
|
||||
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
global $CFG;
|
||||
require_once "$CFG->libdir/form/group.php";
|
||||
|
||||
/**
|
||||
* Class for an element used to choose a file from the course files folder or
|
||||
* from the local repository used by the IMS CP resource type.
|
||||
*
|
||||
*/
|
||||
class MoodleQuickForm_choosecoursefileorimsrepo extends MoodleQuickForm_group
|
||||
{
|
||||
/**
|
||||
* Options for element :
|
||||
*
|
||||
* $url must be relative to home page eg /mod/survey/stuff.php
|
||||
* courseid => int course id if null then uses $COURSE global
|
||||
* width => int Height to assign to popup window
|
||||
* title => string Text to be displayed as popup page title
|
||||
* options => string List of additional options for popup window
|
||||
*/
|
||||
var $_options = array('courseid'=>null,
|
||||
'height'=>500, 'width'=>750, 'options'=>'none');
|
||||
|
||||
/**
|
||||
* These complement separators, they are appended to the resultant HTML
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
var $_wrap = array('', '');
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string Element's name
|
||||
* @param mixed Label(s) for an element
|
||||
* @param array Options to control the element's display
|
||||
* @param mixed Either a typical HTML attribute string or an associative array
|
||||
*/
|
||||
function MoodleQuickForm_choosecoursefileorimsrepo($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
|
||||
{
|
||||
$this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
|
||||
$this->_appendName = true;
|
||||
$this->_type = 'choosecoursefileorimsrepo';
|
||||
// set the options, do not bother setting bogus ones
|
||||
if (is_array($options)) {
|
||||
foreach ($options as $name => $value) {
|
||||
if (isset($this->_options[$name])) {
|
||||
if (is_array($value) && is_array($this->_options[$name])) {
|
||||
$this->_options[$name] = @array_merge($this->_options[$name], $value);
|
||||
} else {
|
||||
$this->_options[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _createElements()
|
||||
|
||||
function _createElements() {
|
||||
global $CFG, $COURSE;
|
||||
$this->_elements = array();
|
||||
|
||||
if (!is_array($this->getAttributes()) || !array_key_exists('size', $this->getAttributes())) {
|
||||
$this->updateAttributes(array('size' => 48));
|
||||
}
|
||||
|
||||
$this->_elements[0] =& MoodleQuickForm::createElement('text', 'value', '', $this->getAttributes());
|
||||
$this->_elements[1] =& MoodleQuickForm::createElement('button', 'popup', get_string('chooseafile', 'resource') .' ...');
|
||||
|
||||
$button =& $this->_elements[1];
|
||||
|
||||
if ($this->_options['courseid']!==null){
|
||||
$courseid=$this->_options['courseid'];
|
||||
} else {
|
||||
$courseid=$COURSE->id;
|
||||
}
|
||||
// first find out the text field id - this is a bit hacky, is there a better way?
|
||||
$choose = 'id_'.str_replace(array('[', ']'), array('_', ''), $this->getElementName(0));
|
||||
$url="/files/index.php?id=$courseid&choose=".$choose;
|
||||
|
||||
if ($this->_options['options'] == 'none') {
|
||||
$options = 'menubar=0,location=0,scrollbars,resizable,width='. $this->_options['width'] .',height='. $this->_options['height'];
|
||||
}else{
|
||||
$options = $this->_options['options'];
|
||||
}
|
||||
$fullscreen = 0;
|
||||
|
||||
$buttonattributes = array('title'=>get_string("chooseafile", "resource"));
|
||||
|
||||
$button->updateAttributes($buttonattributes);
|
||||
|
||||
//attach the onclick event
|
||||
$action = new popup_action('click', $url, $button->getName(), $options);
|
||||
$OUTPUT->add_action_handler($action, $button->id);
|
||||
|
||||
/// With repository active, show the button to browse it
|
||||
if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
|
||||
$this->_elements[2] =& MoodleQuickForm::createElement('button', 'imsrepo', get_string('browserepository', 'resource'));
|
||||
$imsbutton =& $this->_elements[2];
|
||||
$url = "/mod/resource/type/ims/finder.php?directory=&choose=".$choose;
|
||||
$buttonattributes = array('title'=>get_string("browserepository", "resource"));
|
||||
$imsbutton->updateAttributes($buttonattributes);
|
||||
|
||||
//attach the onclick event
|
||||
//$action = new popup_action('click', $url, $button->getName(), $options);
|
||||
$OUTPUT->add_action_handler($action, $imsbutton->id);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Output a timestamp. Give it the name of the group.
|
||||
*
|
||||
* @param array $submitValues
|
||||
* @param bool $assoc
|
||||
* @return array
|
||||
*/
|
||||
function exportValue(&$submitValues, $assoc = false)
|
||||
{
|
||||
$value = null;
|
||||
$valuearray = $this->_elements[0]->exportValue($submitValues[$this->getName()], true);
|
||||
$value[$this->getName()]=$valuearray['value'];
|
||||
return $value;
|
||||
}
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* Called by HTML_QuickForm whenever form event is made on this element
|
||||
*
|
||||
* @param string $event Name of event
|
||||
* @param mixed $arg event arguments
|
||||
* @param object $caller calling object
|
||||
* @since 1.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function onQuickFormEvent($event, $arg, &$caller)
|
||||
{
|
||||
switch ($event) {
|
||||
case 'updateValue':
|
||||
// constant values override both default and submitted ones
|
||||
// default values are overriden by submitted
|
||||
$value = $this->_findValue($caller->_constantValues);
|
||||
if (null === $value) {
|
||||
$value = $this->_findValue($caller->_submitValues);
|
||||
if (null === $value) {
|
||||
$value = $this->_findValue($caller->_defaultValues);
|
||||
}
|
||||
}
|
||||
if (!is_array($value)) {
|
||||
$value = array('value' => $value);
|
||||
}
|
||||
if (null !== $value) {
|
||||
$this->setValue($value);
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return parent::onQuickFormEvent($event, $arg, $caller);
|
||||
|
||||
} // end func onQuickFormEvent
|
||||
|
||||
}
|
||||
@@ -2285,8 +2285,6 @@ MoodleQuickForm::registerElementType('button', "$CFG->libdir/form/button.php", '
|
||||
MoodleQuickForm::registerElementType('cancel', "$CFG->libdir/form/cancel.php", 'MoodleQuickForm_cancel');
|
||||
MoodleQuickForm::registerElementType('searchableselector', "$CFG->libdir/form/searchableselector.php", 'MoodleQuickForm_searchableselector');
|
||||
MoodleQuickForm::registerElementType('checkbox', "$CFG->libdir/form/checkbox.php", 'MoodleQuickForm_checkbox');
|
||||
MoodleQuickForm::registerElementType('choosecoursefile', "$CFG->libdir/form/choosecoursefile.php", 'MoodleQuickForm_choosecoursefile');
|
||||
MoodleQuickForm::registerElementType('choosecoursefileorimsrepo', "$CFG->libdir/form/choosecoursefileorimsrepo.php", 'MoodleQuickForm_choosecoursefileorimsrepo');
|
||||
MoodleQuickForm::registerElementType('date_selector', "$CFG->libdir/form/dateselector.php", 'MoodleQuickForm_date_selector');
|
||||
MoodleQuickForm::registerElementType('date_time_selector', "$CFG->libdir/form/datetimeselector.php", 'MoodleQuickForm_date_time_selector');
|
||||
MoodleQuickForm::registerElementType('duration', "$CFG->libdir/form/duration.php", 'MoodleQuickForm_duration');
|
||||
|
||||
@@ -21,9 +21,9 @@ class question_import_form extends moodleform {
|
||||
$i = 0 ;
|
||||
foreach ($fileformatnames as $shortname => $fileformatname) {
|
||||
$currentgrp1 = array();
|
||||
$currentgrp1[] = &$mform->createElement('radio','format','',$fileformatname,$shortname);
|
||||
$currentgrp1[] = &$mform->createElement('radio','format','',$fileformatname,$shortname);
|
||||
$mform->addGroup($currentgrp1,"formathelp[$i]",'',array('<br />'),false);
|
||||
$mform->setHelpButton("formathelp[$i]", array("$shortname",$fileformatname,"qformat_$shortname"));
|
||||
$mform->setHelpButton("formathelp[$i]", array("$shortname",$fileformatname,"qformat_$shortname"));
|
||||
$i++ ;
|
||||
}
|
||||
$mform->addRule("formathelp[0]", null, 'required', null, 'client' );
|
||||
@@ -64,8 +64,8 @@ class question_import_form extends moodleform {
|
||||
//--------------------------------------------------------------------------------
|
||||
if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))){
|
||||
$mform->addElement('header', 'importfilearea', get_string('importfilearea','quiz'));
|
||||
|
||||
$mform->addElement('choosecoursefile', 'choosefile', get_string('choosefile','quiz'));
|
||||
//TODO: MDL-16094
|
||||
//$mform->addElement('choosecoursefile', 'choosefile', get_string('choosefile','quiz'));
|
||||
//--------------------------------------------------------------------------------
|
||||
$mform->addElement('submit', 'submitbutton', get_string('importfromthisfile','quiz'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user