|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00004 // // 00005 // This file is part of Moodle - http://moodle.org/ // 00006 // Moodle - Modular Object-Oriented Dynamic Learning Environment // 00007 // // 00008 // Moodle is free software: you can redistribute it and/or modify // 00009 // it under the terms of the GNU General Public License as published by // 00010 // the Free Software Foundation, either version 3 of the License, or // 00011 // (at your option) any later version. // 00012 // // 00013 // Moodle is distributed in the hope that it will be useful, // 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00016 // GNU General Public License for more details. // 00017 // // 00018 // You should have received a copy of the GNU General Public License // 00019 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. // 00020 // // 00022 00031 class core_publish_renderer extends plugin_renderer_base { 00032 00036 public function publicationselector($courseid) { 00037 $text = ''; 00038 00039 $advertiseurl = new moodle_url("/course/publish/hubselector.php", 00040 array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true)); 00041 $advertisebutton = new single_button($advertiseurl, get_string('advertise', 'hub')); 00042 $text .= $this->output->render($advertisebutton); 00043 $text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'), 00044 array('class' => 'publishhelp')); 00045 00046 $text .= html_writer::empty_tag('br'); 00047 00048 $uploadurl = new moodle_url("/course/publish/hubselector.php", 00049 array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true)); 00050 $uploadbutton = new single_button($uploadurl, get_string('share', 'hub')); 00051 $text .= $this->output->render($uploadbutton); 00052 $text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'), 00053 array('class' => 'publishhelp')); 00054 00055 return $text; 00056 } 00057 00061 public function registeredonhublisting($courseid, $publications) { 00062 global $CFG; 00063 $table = new html_table(); 00064 $table->head = array(get_string('type', 'hub'), get_string('hub', 'hub'), 00065 get_string('date'), get_string('status', 'hub'), get_string('operation', 'hub')); 00066 $table->size = array('10%', '40%', '20%', '%10', '%15'); 00067 00068 $brtag = html_writer::empty_tag('br'); 00069 00070 foreach ($publications as $publication) { 00071 00072 $updatebuttonhtml = ''; 00073 00074 $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 00075 'hubcourseid' => $publication->hubcourseid, 00076 'huburl' => $publication->huburl, 'hubname' => $publication->hubname, 00077 'cancel' => true, 'publicationid' => $publication->id, 00078 'timepublished' => $publication->timepublished); 00079 $cancelurl = new moodle_url("/course/publish/index.php", $params); 00080 $cancelbutton = new single_button($cancelurl, get_string('removefromhub', 'hub')); 00081 $cancelbutton->class = 'centeredbutton'; 00082 $cancelbuttonhtml = $this->output->render($cancelbutton); 00083 00084 if ($publication->enrollable) { 00085 $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 00086 'huburl' => $publication->huburl, 'hubname' => $publication->hubname, 00087 'share' => !$publication->enrollable, 'advertise' => $publication->enrollable); 00088 $updateurl = new moodle_url("/course/publish/metadata.php", $params); 00089 $updatebutton = new single_button($updateurl, get_string('update', 'hub')); 00090 $updatebutton->class = 'centeredbutton'; 00091 $updatebuttonhtml = $this->output->render($updatebutton); 00092 00093 $operations = $updatebuttonhtml . $brtag . $cancelbuttonhtml; 00094 } else { 00095 $operations = $cancelbuttonhtml; 00096 } 00097 00098 $hubname = html_writer::tag('a', 00099 $publication->hubname ? $publication->hubname : $publication->huburl, 00100 array('href' => $publication->huburl)); 00101 //if the publication check time if bigger than May 2010, it has been checked 00102 if ($publication->timechecked > 1273127954) { 00103 if ($publication->status == 0) { 00104 $status = get_string('statusunpublished', 'hub'); 00105 } else { 00106 $status = get_string('statuspublished', 'hub'); 00107 } 00108 00109 $status .= $brtag . html_writer::tag('a', get_string('updatestatus', 'hub'), 00110 array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' 00111 . $courseid . "&updatestatusid=" . $publication->id 00112 . "&sesskey=" . sesskey())) . 00113 $brtag . get_string('lasttimechecked', 'hub') . ": " 00114 . format_time(time() - $publication->timechecked); 00115 } else { 00116 $status = get_string('neverchecked', 'hub') . $brtag 00117 . html_writer::tag('a', get_string('updatestatus', 'hub'), 00118 array('href' => $CFG->wwwroot . '/course/publish/index.php?id=' 00119 . $courseid . "&updatestatusid=" . $publication->id 00120 . "&sesskey=" . sesskey())); 00121 } 00122 //add button cells 00123 $cells = array($publication->enrollable ? 00124 get_string('advertised', 'hub') : get_string('shared', 'hub'), 00125 $hubname, userdate($publication->timepublished, 00126 get_string('strftimedatetimeshort')), $status, $operations); 00127 $row = new html_table_row($cells); 00128 $table->data[] = $row; 00129 } 00130 00131 $contenthtml = html_writer::table($table); 00132 00133 return $contenthtml; 00134 } 00135 00145 public function confirmunpublishing($publication) { 00146 $optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid, 00147 'hubcourseid' => $publication->hubcourseid, 00148 'huburl' => $publication->huburl, 'hubname' => $publication->hubname, 00149 'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true); 00150 $optionsno = array('sesskey' => sesskey(), 'id' => $publication->courseid); 00151 $publication->hubname = html_writer::tag('a', $publication->hubname, 00152 array('href' => $publication->huburl)); 00153 $formcontinue = new single_button(new moodle_url("/course/publish/index.php", 00154 $optionsyes), get_string('unpublish', 'hub'), 'post'); 00155 $formcancel = new single_button(new moodle_url("/course/publish/index.php", 00156 $optionsno), get_string('cancel'), 'get'); 00157 return $this->output->confirm(get_string('unpublishconfirmation', 'hub', $publication), 00158 $formcontinue, $formcancel); 00159 } 00160 00166 public function sendingbackupinfo($backupfile) { 00167 $sizeinfo = new stdClass(); 00168 $sizeinfo->total = number_format($backupfile->get_filesize() / 1000000, 2); 00169 $html = html_writer::tag('div', get_string('sendingsize', 'hub', $sizeinfo), 00170 array('class' => 'courseuploadtextinfo')); 00171 return $html; 00172 } 00173 00181 public function sentbackupinfo($id, $huburl, $hubname) { 00182 $html = html_writer::tag('div', get_string('sent', 'hub'), 00183 array('class' => 'courseuploadtextinfo')); 00184 $publishindexurl = new moodle_url('/course/publish/index.php', 00185 array('sesskey' => sesskey(), 'id' => $id, 00186 'published' => true, 'huburl' => $huburl, 'hubname' => $hubname)); 00187 $continue = $this->output->render( 00188 new single_button($publishindexurl, get_string('continue', 'hub'))); 00189 $html .= html_writer::tag('div', $continue, array('class' => 'sharecoursecontinue')); 00190 return $html; 00191 } 00192 00198 public function hubinfo($hubinfo) { 00199 $params = array('filetype' => HUB_HUBSCREENSHOT_FILE_TYPE); 00200 $imgurl = new moodle_url($hubinfo['url'] . 00201 "/local/hub/webservice/download.php", $params); 00202 $screenshothtml = html_writer::empty_tag('img', 00203 array('src' => $imgurl, 'alt' => $hubinfo['name'])); 00204 $hubdescription = html_writer::tag('div', $screenshothtml, 00205 array('class' => 'hubscreenshot')); 00206 00207 $hubdescription .= html_writer::tag('a', $hubinfo['name'], 00208 array('class' => 'hublink', 'href' => $hubinfo['url'], 00209 'onclick' => 'this.target="_blank"')); 00210 00211 $hubdescription .= html_writer::tag('div', format_text($hubinfo['description'], FORMAT_PLAIN), 00212 array('class' => 'hubdescription')); 00213 $hubdescription = html_writer::tag('div', $hubdescription, array('class' => 'hubinfo')); 00214 00215 return $hubdescription; 00216 } 00217 00218 }