MDL-38166 mod_data Add option to open url in a new window

This commit is contained in:
Andrew Robert Nicols
2013-03-12 11:29:17 +00:00
parent 8673a98d1d
commit 6f07bf766b
3 changed files with 19 additions and 8 deletions
+10 -4
View File
@@ -109,11 +109,17 @@ class data_field_url extends data_field_base {
}
if ($this->field->param1) {
// param1 defines whether we want to autolink the url.
if (!empty($text)) {
$str = '<a href="'.$url.'">'.$text.'</a>';
} else {
$str = '<a href="'.$url.'">'.$url.'</a>';
$attributes = array();
if ($this->field->param3) {
// param3 defines whether this URL should open in a new window.
$attributes['target'] = '_blank';
}
if (empty($text)) {
$text = $url;
}
$str = html_writer::link($url, $text, $attributes);
} else {
$str = $url;
}
@@ -25,3 +25,4 @@
*/
$string['pluginname'] = 'URL';
$string['openlinkinnewwindow'] = 'Open link in new window';
+8 -4
View File
@@ -7,12 +7,16 @@
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
</tr>
<tr>
<td class="c0"><label for="forcelinkname"><?php echo get_string('forcelinkname', 'data'); ?></label></td>
<td class="c1"><input class="forcelinkname" type="text" name="param2" id="forcelinkname" value="<?php p($this->field->param2);?>" /></td>
</tr>
<tr>
<td class="c0"><label for="param1"><?php echo get_string('autolinkurl', 'data') ?></label></td>
<td class="c1"><input type="checkbox" name="param1" id="param1" <?php if($this->field->param1) {echo 'checked="checked"';} ?> value="1" /></td>
</tr>
<tr>
<td class="c0"><label for="param3"><?php echo get_string('openlinkinnewwindow', 'datafield_url') ?></label></td>
<td class="c1"><input type="checkbox" name="param3" id="param3" <?php if($this->field->param3) {echo 'checked="checked"';} ?> value="1" /></td>
</tr>
<tr>
<td class="c0"><label for="forcelinkname"><?php echo get_string('forcelinkname', 'data'); ?></label></td>
<td class="c1"><input class="forcelinkname" type="text" name="param2" id="forcelinkname" value="<?php p($this->field->param2);?>" /></td>
</tr>
</table>