Skip to content

Commit

Permalink
Merge branch 'MDL-36749-m' of git://github.com/andrewnicols/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Mar 6, 2013
2 parents 6a9235c + a6d81a7 commit ab1e921
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 237 deletions.
105 changes: 3 additions & 102 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1883,33 +1883,9 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
* Print a help button.
*
* @deprecated since Moodle 2.0
*
* @param string $page The keyword that defines a help page
* @param string $title The title of links, rollover tips, alt tags etc
* 'Help with' (or the language equivalent) will be prefixed and '...' will be stripped.
* @param string $module Which module is the page defined in
* @param mixed $image Use a help image for the link? (true/false/"both")
* @param boolean $linktext If true, display the title next to the help icon.
* @param string $text If defined then this text is used in the page, and
* the $page variable is ignored. DEPRECATED!
* @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
* @param string $imagetext The full text for the helpbutton icon. If empty use default help.gif
* @return string|void Depending on value of $return
*/
function helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false, $imagetext='') {
debugging('helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_icon().');

global $OUTPUT;

$output = $OUTPUT->old_help_icon($page, $title, $module, $linktext);

// hide image with CSS if needed

if ($return) {
return $output;
} else {
echo $output;
}
throw new coding_exception('helpbutton() can not be used any more, please see $OUTPUT->help_icon().');
}

/**
Expand Down Expand Up @@ -1962,10 +1938,6 @@ function editorshortcutshelpbutton() {

global $CFG;
//TODO: detect current editor and print correct info
/* $imagetext = '<img src="' . $CFG->httpswwwroot . '/lib/editor/htmlarea/images/kbhelp.gif" alt="'.
get_string('editorshortcutkeys').'" class="iconkbhelp" />';
return helpbutton('editorshortcuts', get_string('editorshortcutkeys'), 'moodle', true, false, '', true, $imagetext);*/
return '';
}

Expand Down Expand Up @@ -2032,23 +2004,9 @@ function print_arrow($direction='up', $strsort=null, $return=false) {
* Also contains an icon by default. Shown to teachers and admin only.
*
* @deprecated since Moodle 2.0
*
* @global object
* @param string $path The page link after doc root and language, no leading slash.
* @param string $text The text to be displayed for the link
* @param string $iconpath The path to the icon to be displayed
* @return string Either the link or an empty string
*/
function doc_link($path='', $text='', $iconpath='ignored') {
global $CFG, $OUTPUT;

debugging('doc_link() has been deprecated. Please change your code to use $OUTPUT->doc_link().');

if (empty($CFG->docroot)) {
return '';
}

return $OUTPUT->doc_link($path, $text);
throw new coding_exception('doc_link() can not be used any more, please see $OUTPUT->doc_link().');
}

/**
Expand Down Expand Up @@ -2347,67 +2305,10 @@ function print_date_selector($day, $month, $year, $currenttime=0, $return=false)
* Implements a complete little form with a dropdown menu.
*
* @deprecated since Moodle 2.0
*
* When JavaScript is on selecting an option from the dropdown automatically
* submits the form (while avoiding the usual acessibility problems with this appoach).
* With JavaScript off, a 'Go' button is printed.
*
* @global object
* @global object
* @param string $baseurl The target URL up to the point of the variable that changes
* @param array $options A list of value-label pairs for the popup list
* @param string $formid id for the control. Must be unique on the page. Used in the HTML.
* @param string $selected The option that is initially selected
* @param string $nothing The label for the "no choice" option
* @param string $help The name of a help page if help is required
* @param string $helptext The name of the label for the help button
* @param boolean $return Indicates whether the function should return the HTML
* as a string or echo it directly to the page being rendered
* @param string $targetwindow The name of the target page to open the linked page in.
* @param string $selectlabel Text to place in a [label] element - preferred for accessibility.
* @param array $optionsextra an array with the same keys as $options. The values are added within the corresponding <option ...> tag.
* @param string $submitvalue Optional label for the 'Go' button. Defaults to get_string('go').
* @param boolean $disabled If true, the menu will be displayed disabled.
* @param boolean $showbutton If true, the button will always be shown even if JavaScript is available
* @return string|void If $return=true returns string, else echo's and returns void
*/
function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false,
$targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false, $showbutton=false) {
global $OUTPUT, $CFG;

debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->single_select() or $OUTPUT->url_select().');

if (empty($options)) {
return '';
}

$urls = array();

foreach ($options as $value=>$label) {
$url = $baseurl.$value;
$url = str_replace($CFG->wwwroot, '', $url);
$url = str_replace('&amp;', '&', $url);
$urls[$url] = $label;
if ($selected == $value) {
$active = $url;
}
}

$nothing = $nothing ? array(''=>$nothing) : null;

$select = new url_select($urls, $active, $nothing, $formid);
$select->disabled = $disabled;

$select->set_label($selectlabel);
$select->set_old_help_icon($help, $helptext);

$output = $OUTPUT->render($select);

if ($return) {
return $output;
} else {
echo $output;
}
throw new coding_exception('popup_form() can not be used any more, please see $OUTPUT->single_select or $OUTPUT->url_select().');
}

/**
Expand Down
64 changes: 4 additions & 60 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,58 +411,6 @@ public function get_url(moodle_page $page, renderer_base $renderer = null) {
}
}

/**
* Data structure representing a help icon.
*
* @copyright 2009 Nicolas Connault, 2010 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
* @package core
* @category output
*/
class old_help_icon implements renderable {

/**
* @var string Lang pack identifier
*/
public $helpidentifier;

/**
* @var string A descriptive text for title tooltip
*/
public $title = null;

/**
* @var string Component name, the same as in get_string()
*/
public $component = 'moodle';

/**
* @var string Extra descriptive text next to the icon
*/
public $linktext = null;

/**
* Constructor: sets up the other components in case they are needed
*
* @param string $helpidentifier The keyword that defines a help page
* @param string $title A descriptive text for accessibility only
* @param string $component
*/
public function __construct($helpidentifier, $title, $component = 'moodle') {
if (empty($title)) {
throw new coding_exception('A help_icon object requires a $text parameter');
}
if (empty($helpidentifier)) {
throw new coding_exception('A help_icon object requires a $helpidentifier parameter');
}

$this->helpidentifier = $helpidentifier;
$this->title = $title;
$this->component = $component;
}
}

/**
* Data structure representing a help icon.
*
Expand Down Expand Up @@ -807,12 +755,10 @@ public function add_action(component_action $action) {
/**
* Adds help icon.
*
* @param string $helppage The keyword that defines a help page
* @param string $title A descriptive text for accessibility only
* @param string $component
* @deprecated since Moodle 2.0
*/
public function set_old_help_icon($helppage, $title, $component = 'moodle') {
$this->helpicon = new old_help_icon($helppage, $title, $component);
throw new coding_exception('set_old_help_icon() can not be used any more, please see set_help_icon().');
}

/**
Expand Down Expand Up @@ -931,12 +877,10 @@ public function __construct(array $urls, $selected = '', $nothing = array('' =>
/**
* Adds help icon.
*
* @param string $helppage The keyword that defines a help page
* @param string $title A descriptive text for accessibility only
* @param string $component
* @deprecated since Moodle 2.0
*/
public function set_old_help_icon($helppage, $title, $component = 'moodle') {
$this->helpicon = new old_help_icon($helppage, $title, $component);
throw new coding_exception('set_old_help_icon() can not be used any more, please see set_help_icon().');
}

/**
Expand Down
63 changes: 1 addition & 62 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,6 @@ protected function render_single_select(single_select $select) {

if ($select->helpicon instanceof help_icon) {
$output .= $this->render($select->helpicon);
} else if ($select->helpicon instanceof old_help_icon) {
$output .= $this->render($select->helpicon);
}
$output .= html_writer::select($select->options, $select->name, $select->selected, $select->nothing, $select->attributes);

Expand Down Expand Up @@ -1609,8 +1607,6 @@ protected function render_url_select(url_select $select) {

if ($select->helpicon instanceof help_icon) {
$output .= $this->render($select->helpicon);
} else if ($select->helpicon instanceof old_help_icon) {
$output .= $this->render($select->helpicon);
}

// For security reasons, the script course/jumpto.php requires URL starting with '/'. To keep
Expand Down Expand Up @@ -1880,66 +1876,9 @@ public function heading_with_help($text, $helpidentifier, $component = 'moodle',
* Returns HTML to display a help icon.
*
* @deprecated since Moodle 2.0
* @param string $helpidentifier The keyword that defines a help page
* @param string $title A descriptive text for accessibility only
* @param string $component component name
* @param string|bool $linktext true means use $title as link text, string means link text value
* @return string HTML fragment
*/
public function old_help_icon($helpidentifier, $title, $component = 'moodle', $linktext = '') {
debugging('The method old_help_icon() is deprecated, please fix the code and use help_icon() method instead', DEBUG_DEVELOPER);
$icon = new old_help_icon($helpidentifier, $title, $component);
if ($linktext === true) {
$icon->linktext = $title;
} else if (!empty($linktext)) {
$icon->linktext = $linktext;
}
return $this->render($icon);
}

/**
* Implementation of user image rendering.
*
* @param old_help_icon $helpicon A help icon instance
* @return string HTML fragment
*/
protected function render_old_help_icon(old_help_icon $helpicon) {
global $CFG;

// first get the help image icon
$src = $this->pix_url('help');

if (empty($helpicon->linktext)) {
$alt = $helpicon->title;
} else {
$alt = get_string('helpwiththis');
}

$attributes = array('src'=>$src, 'alt'=>$alt, 'class'=>'iconhelp');
$output = html_writer::empty_tag('img', $attributes);

// add the link text if given
if (!empty($helpicon->linktext)) {
// the spacing has to be done through CSS
$output .= $helpicon->linktext;
}

// now create the link around it - we need https on loginhttps pages
$url = new moodle_url($CFG->httpswwwroot.'/help.php', array('component' => $helpicon->component, 'identifier' => $helpicon->helpidentifier, 'lang'=>current_language()));

// note: this title is displayed only if JS is disabled, otherwise the link will have the new ajax tooltip
$title = get_string('helpprefix2', '', trim($helpicon->title, ". \t"));

$attributes = array('href'=>$url, 'title'=>$title, 'aria-haspopup' => 'true');
$id = html_writer::random_id('helpicon');
$attributes['id'] = $id;
$output = html_writer::tag('a', $output, $attributes);

$this->page->requires->js_init_call('M.util.help_icon.add', array(array('id'=>$id, 'url'=>$url->out(false))));
$this->page->requires->string_for_js('close', 'form');

// and finally span
return html_writer::tag('span', $output, array('class' => 'helptooltip'));
throw new coding_exception('old_help_icon() can not be used any more, please see help_icon().');
}

/**
Expand Down
12 changes: 1 addition & 11 deletions mod/wiki/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1310,17 +1310,7 @@ private function print_history_content() {
$table->attributes['class'] = 'generaltable mdl-align';
$table->rowclasses = $rowclass;

/*$table = new StdClass();
$table->head = array(helpbutton('diff', 'diff', 'wiki', true, false, '', true, ''),
get_string('version'),
get_string('user'),
get_string('modified'),
'');
$table->data = $contents;
$table->class = 'mdl-align';
$table->rowclass = $rowclass;*/

///Print the form
// Print the form.
echo html_writer::start_tag('form', array('action'=>new moodle_url('/mod/wiki/diff.php'), 'method'=>'get', 'id'=>'diff'));
echo html_writer::tag('div', html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'pageid', 'value'=>$pageid)));
echo html_writer::table($table);
Expand Down
2 changes: 0 additions & 2 deletions theme/mymobile/renderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,6 @@ protected function render_single_select(single_select $select) {

if ($select->helpicon instanceof help_icon) {
$output .= $this->render($select->helpicon);
} else if ($select->helpicon instanceof old_help_icon) {
$output .= $this->render($select->helpicon);
}

$output .= html_writer::select($select->options, $select->name, $select->selected, $select->nothing, $select->attributes);
Expand Down

0 comments on commit ab1e921

Please sign in to comment.