Skip to content

Commit

Permalink
ajax MDL-22286 removed references to the previous version of the JS f…
Browse files Browse the repository at this point in the history
…unction openpopup()
  • Loading branch information
Andrew Davis committed May 5, 2010
1 parent 8702d4a commit eaed2fd
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 63 deletions.
16 changes: 13 additions & 3 deletions blocks/messages/block_messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ function get_content() {
return $this->content;
}

$this->content->footer = '<a href="'.$CFG->wwwroot.'/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'.get_string('messages', 'message').'</a>...';
$link = '/message/index.php';
$action = new popup_action('click', $link, 'message');
$this->content->footer = $OUTPUT->action_link($link, get_string('messages', 'message'), $action);
//$this->content->footer = '<a href="'.$CFG->wwwroot.'/message/index.php" onclick="this.target=\'message\'; return openpopup_old(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'.get_string('messages', 'message').'</a>...';

$users = $DB->get_records_sql("SELECT m.useridfrom AS id, COUNT(m.useridfrom) AS count,
u.firstname, u.lastname, u.picture, u.imagealt, u.lastaccess
Expand All @@ -47,8 +50,15 @@ function get_content() {
$this->content->text .= '<li class="listentry"><div class="user"><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.SITEID.'" title="'.$timeago.'">';
$this->content->text .= $OUTPUT->user_picture($user, array('courseid'=>SITEID)); //TODO: user might not have capability to view frontpage profile :-(
$this->content->text .= fullname($user).'</a></div>';
$this->content->text .= '<div class="message"><a href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\'; return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="" />&nbsp;'.$user->count.'</a>';
$this->content->text .= '</div></li>';

//<a href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\'; return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="" />&nbsp;'.$user->count.'</a>'
$link = '/message/discussion.php?id='.$user->id;
$anchortagcontents = '<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="" />&nbsp;'.$user->count;

$action = new popup_action('click', $link, 'message_'.$user->id);
$anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);

$this->content->text .= '<div class="message">'.$anchortag.'</div></li>';
}
$this->content->text .= '</ul>';
} else {
Expand Down
10 changes: 8 additions & 2 deletions blocks/online_users/block_online_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@ function get_content() {
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$this->page->course->id.'" title="'.$timeago.'">'.$user->fullname.'</a></div>';
}
if ($canshowicon and ($USER->id != $user->id) and $user->username != 'guest') { // Only when logged in and messaging active etc
$this->content->text .= '<div class="message"><a title="'.get_string('messageselectadd').'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\';return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'
.'<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="'. get_string('messageselectadd') .'" /></a></div>';
//<a title="'.get_string('messageselectadd').'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\';return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">
$link = '/message/discussion.php?id='.$user->id;
$anchortagcontents = '<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="'. get_string('messageselectadd') .'" />';

$action = new popup_action('click', $link, 'message_'.$user->id);
$anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action, array('title'=>get_string('messageselectadd')));

$this->content->text .= '<div class="message">'.$anchortag.'</div>';
}
$this->content->text .= "</li>\n";
}
Expand Down
26 changes: 13 additions & 13 deletions filter/algebra/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ function string_file_picture_algebra($imagefile, $tex= "", $height="", $width=""
}
$style .= '"';
if ($imagefile) {
if (!file_exists("$CFG->dataroot/filter/algebra/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
$output .= "<a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">";
$anchorcontents .= "<img $title alt=\"".s($origtex)."\" src=\"";
if ($CFG->slasharguments) { // Use this method if possible for better caching
$anchorcontents .= "$CFG->wwwroot/filter/algebra/pix.php/$imagefile";
} else {
$output .= "<a target=\"popup\" title=\"TeX\" href=";
$output .= "\"$CFG->wwwroot/filter/algebra/displaytex.php?";
$output .= urlencode($tex) . "\" onclick=\"return openpopup('/filter/algebra/displaytex.php?";
$output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,";
$output .= "resizable,width=300,height=240', 0);\">";
$anchorcontents .= "$CFG->wwwroot/filter/algebra/pix.php?file=$imagefile";
}
$output .= "<img $title alt=\"".s($origtex)."\" src=\"";
if ($CFG->slasharguments) { // Use this method if possible for better caching
$output .= "$CFG->wwwroot/filter/algebra/pix.php/$imagefile";
$anchorcontents .= "\" $style />";

$link = $action = null;
if (!file_exists("$CFG->dataroot/filter/algebra/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
$link = '/filter/algebra/algebradebug.php';
} else {
$output .= "$CFG->wwwroot/filter/algebra/pix.php?file=$imagefile";
$link = '/filter/algebra/displaytex.php?'.urlencode($tex);
$action = new popup_action('click', $link, 'popup', array('height'=>300,'width'=>240));
}
$output .= "\" $style />";
$output .= "</a>";
$output .= $OUTPUT->action_link($link, $anchortagcontents, $action, array('title'=>'TeX'));

} else {
$output .= "Error: must pass URL or course";
}
Expand Down
25 changes: 12 additions & 13 deletions filter/tex/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,22 @@ function string_file_picture_tex($imagefile, $tex= "", $height="", $width="", $a
// Build the output.
$output = "";
if ($imagefile) {
if (!file_exists("$CFG->dataroot/filter/tex/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
$output .= "<a href=\"$CFG->wwwroot/filter/tex/texdebug.php\">";
$anchorcontents = "<img class=\"texrender\" $title alt=\"$alt\" src=\"";
if ($CFG->slasharguments) { // Use this method if possible for better caching
$anchorcontents .= "$CFG->wwwroot/filter/tex/pix.php/$imagefile";
} else {
$output .= "<a target=\"popup\" title=\"TeX\" href=";
$output .= "\"$CFG->wwwroot/filter/tex/displaytex.php?";
$output .= urlencode($tex) . "\" onclick=\"return openpopup('/filter/tex/displaytex.php?";
$output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,";
$output .= "resizable,width=300,height=240', 0);\">";
$anchorcontents .= "$CFG->wwwroot/filter/tex/pix.php?file=$imagefile";
}
$output .= "<img class=\"texrender\" $title alt=\"$alt\" src=\"";
if ($CFG->slasharguments) { // Use this method if possible for better caching
$output .= "$CFG->wwwroot/filter/tex/pix.php/$imagefile";
$anchorcontents .= "\" $style/>";

$link = $action = null;
if (!file_exists("$CFG->dataroot/filter/tex/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
$link = '/filter/tex/texdebug.php';
} else {
$output .= "$CFG->wwwroot/filter/tex/pix.php?file=$imagefile";
$link = '/filter/tex/displaytex.php?'.urlencode($tex);
$action = new popup_action('click', $link, 'popup', array('height'=>300,'width'=>240));
}
$output .= "\" $style/>";
$output .= "</a>";
$output .= $OUTPUT->action_link($link, $anchortagcontents, $action, array('title'=>'TeX'));
} else {
$output .= "Error: must pass URL or course";
}
Expand Down
17 changes: 10 additions & 7 deletions lib/form/choosecoursefile.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,20 @@ function _createElements() {
$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"),
'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', $fullscreen);");
$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);
$OUTPUT->add_action_handler($action, $button->id);
}

/**
Expand Down
14 changes: 10 additions & 4 deletions lib/form/choosecoursefileorimsrepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,25 @@ function _createElements() {
}
$fullscreen = 0;

$buttonattributes = array('title'=>get_string("chooseafile", "resource"),
'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', $fullscreen);");
$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"),
'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', $fullscreen);");
$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);
}
}
/**
Expand Down
1 change: 1 addition & 0 deletions message/refresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
define('MESSAGE_DEFAULT_REFRESH', 5);

require_login();
echo('refresh.php');

if (isguestuser()) {
redirect($CFG->wwwroot);
Expand Down
15 changes: 11 additions & 4 deletions mod/chat/chatd.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,18 @@ function openpopup(url,name,options,fullscreen) {
$userinfo = $this->sets_info[$usersessionid];

$lastping = $timenow - $userinfo['chatuser']->lastmessageping;
$popuppar = '\'/user/view.php?id='.$userinfo['user']->id.'&amp;course='.$userinfo['courseid'].'\',\'user'.$userinfo['chatuser']->id.'\',\'\'';
//$popuppar = '\'/user/view.php?id='.$userinfo['user']->id.'&amp;course='.$userinfo['courseid'].'\',\'user'.$userinfo['chatuser']->id.'\',\'\'';
echo '<tr><td width="35">';
echo '<a target="_new" onclick="return openpopup('.$popuppar.');" href="'.$CFG->wwwroot.'/user/view.php?id='.$userinfo['chatuser']->id.'&amp;course='.$userinfo['courseid'].'">';
echo $OUTPUT->user_picture($userinfo['user'], array('courseid'=>$userinfo['courseid']));
echo "</a></td><td valign=\"center\">";

//echo '<a target="_new" onclick="return openpopup('.$popuppar.');" href="'.$CFG->wwwroot.'/user/view.php?id='.$userinfo['chatuser']->id.'&amp;course='.$userinfo['courseid'].'">';
$link = '/user/view.php?id='.$userinfo['user']->id.'&course='.$userinfo['courseid'];
$anchortagcontents = $OUTPUT->user_picture($userinfo['user'], array('courseid'=>$userinfo['courseid']));

$action = new popup_action('click', $link, 'user'.$userinfo['chatuser']->id);
$anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);

echo $anchortag;
echo "</td><td valign=\"center\">";
echo "<p><font size=\"1\">";
echo fullname($userinfo['user'])."<br />";
echo "<font color=\"#888888\">$str->idle: ".format_time($lastping, $str)."</font> ";
Expand Down
7 changes: 6 additions & 1 deletion mod/data/preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,16 @@
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
echo '<input type="hidden" name="action" value="importzip" />';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input name="file" size="20" value="" id="fromfile" type="text" /><input name="coursefiles" value="'.$strchooseorupload.'" onclick="return openpopup('."'/files/index.php?id={$course->id}&amp;choose=uploadpreset.file', 'coursefiles', 'menubar=0,location=0,scrollbars,resizable,width=750,height=500', 0".');" type="button" />';
echo '<input name="file" size="20" value="" id="fromfile" type="text" /><input name="coursefiles" value="'.$strchooseorupload.'" type="button" />';
echo '<input type="submit" value="'.$strimport.'" />';
echo '</fieldset></form>';
echo '</td></tr>';

//attach the onclick event to fromfile button
$link = '/files/index.php?id={$course->id}&amp;choose=uploadpreset.file';
$action = new popup_action('click', $link, 'coursefiles', array('height'=>750,'width'=>500));
$OUTPUT->add_action_handler($action, 'fromfile');

echo '<tr valign="top"><td><label>'.$strusestandard.'</label>';
echo $OUTPUT->help_icon('usestandard', 'data');
echo '</td><td>';
Expand Down
13 changes: 8 additions & 5 deletions mod/glossary/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,15 @@ function glossary_filter($courseid, $text) {
$encodedconcept = urlencode($concept->concept);
$title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->concept));
}
$href_tag_begin = '<a class="glossary autolink glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
$randid = html_writer::random_id($title);
$href_tag_begin = '<a id="'.$randid.'" class="glossary autolink glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
'href="'.$CFG->wwwroot.'/mod/glossary/showentry.php?courseid='.$courseid.
'&amp;concept='.$encodedconcept.'" '.
'onclick="return openpopup(\'/mod/glossary/showentry.php?courseid='.$courseid.
'\&amp;concept='.$encodedconcept.'\', \'entry\', '.
'\'menubar=0,location=0,scrollbars,resizable,width=600,height=450\', 0);">';
'&amp;concept='.$encodedconcept.'" >';

//attach the onclick event
$link = '/mod/glossary/showentry.php?courseid='.$courseid.'\&amp;concept='.$encodedconcept;
$action = new popup_action('click', $link, 'entry', array('height'=>600,'width'=>450));
$OUTPUT->add_action_handler($action, $randid);
}


Expand Down
14 changes: 10 additions & 4 deletions mod/glossary/formats/entrylist/entrylist_format.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $aliases=true) {
global $USER;
global $USER, $OUTPUT;

$return = false;

Expand All @@ -11,9 +11,15 @@ function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode=''
echo '<td class="entry">';
if ($entry) {
glossary_print_entry_approval($cm, $entry, $mode);
echo "<div class=\"concept\"><a href=\"showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary\" target=\"_blank\" onclick=\"return openpopup('/mod/glossary/showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
glossary_print_entry_concept($entry);
echo '</a></div> ';

//<a href=\"showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary\" target=\"_blank\" onclick=\"return openpopup('/mod/glossary/showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">
$link = "/mod/glossary/showentry.php?courseid={$course->id}&eid={$entry->id}&displayformat=dictionary";
$anchortagcontents = glossary_print_entry_concept($entry);

$action = new popup_action('click', $link, 'entry',array('title'=>'entry','width'=>600,'height'=>450));
$anchor = $OUTPUT->action_link($link, $anchortagcontents, $action);

echo "<div class=\"concept\">$anchor</div> ";
echo '</td><td align="right" class="entrylowersection">';
if ($printicons) {
glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,'print');
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,7 @@ function glossary_print_alphabet_links($cm, $glossary, $mode, $hook, $sortkey, $
* @param string $sortorder
*/
function glossary_print_sorting_links($cm, $mode, $sortkey = '',$sortorder = '') {
global $CFG;
global $CFG, $OUTPUT;

$asc = get_string("ascending","glossary");
$desc = get_string("descending","glossary");
Expand Down
4 changes: 2 additions & 2 deletions mod/glossary/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@

$searchcond = array();
$alcond = array();
$params = array();
//$params = array();
$i = 0;

$concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition',"' '", "COALESCE(al.alial, '')");
$concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition',"' '", "COALESCE(al.alias, '')");

$searchterms = explode(" ",$hook);

Expand Down
8 changes: 5 additions & 3 deletions mod/hotpot/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ function definition() {
if ($choosefile_button) {
$wdir = "'+getDir(this.form.reference.value)+'";
$url="/files/index.php?id=$id&wdir=$wdir&choose=id_reference";
$options = 'menubar=0,location=0,scrollbars,resizable,width=750,height=500';
$attributes = array(
'title'=>get_string('chooseafile', 'resource'),
'onclick'=>"return openpopup('$url', '".$choosefile_button->getName()."', '$options', 0);"
'title'=>get_string('chooseafile', 'resource')
);
$choosefile_button->updateAttributes($attributes);

//attach the onclick event
$action = new popup_action('click', $url, $choosefile_button->getName(), array('title'=>$choosefile_button->getName(),'width'=>750,'height'=>500));
$OUTPUT->add_action_handler($action, $choosefile_button->id);
}
$mform->setType('reference', PARAM_TEXT);

Expand Down
Loading

0 comments on commit eaed2fd

Please sign in to comment.