コード例 #1
0
ファイル: pagelib.php プロジェクト: Burick/moodle
    /**
     * Prints lists of versions which can be deleted
     *
     * @global core_renderer $OUTPUT
     * @global moodle_page $PAGE
     */
    private function print_delete_version() {
        global $OUTPUT, $PAGE;
        $pageid = $this->page->id;

        // versioncount is the latest version
        $versioncount = wiki_count_wiki_page_versions($pageid) - 1;
        $versions = wiki_get_wiki_page_versions($pageid, 0, $versioncount);

        // We don't want version 0 to be displayed
        // version 0 is blank page
        if (end($versions)->version == 0) {
            array_pop($versions);
        }

        $contents = array();
        $version0page = wiki_get_wiki_page_version($this->page->id, 0);
        $creator = wiki_get_user_info($version0page->userid);
        $a = new stdClass();
        $a->date = userdate($this->page->timecreated, get_string('strftimedaydatetime', 'langconfig'));
        $a->username = fullname($creator);
        echo $OUTPUT->heading(get_string('createddate', 'wiki', $a), 4, 'wiki_headingtime');
        if ($versioncount > 0) {
            /// If there is only one version, we don't need radios nor forms
            if (count($versions) == 1) {
                $row = array_shift($versions);
                $username = wiki_get_user_info($row->userid);
                $picture = $OUTPUT->user_picture($username);
                $date = userdate($row->timecreated, get_string('strftimedate', 'langconfig'));
                $time = userdate($row->timecreated, get_string('strftimetime', 'langconfig'));
                $versionid = wiki_get_version($row->id);
                $versionlink = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
                $userlink = new moodle_url('/user/view.php', array('id' => $username->id, 'course' => $PAGE->cm->course));
                $picturelink = $picture . html_writer::link($userlink->out(false), fullname($username));
                $historydate = $OUTPUT->container($date, 'wiki_histdate');
                $contents[] = array('', html_writer::link($versionlink->out(false), $row->version), $picturelink, $time, $historydate);

                //Show current version
                $table = new html_table();
                $table->head = array('', get_string('version'), get_string('user'), get_string('modified'), '');
                $table->data = $contents;
                $table->attributes['class'] = 'mdl-align';

                echo html_writer::table($table);
            } else {
                $lastdate = '';
                $rowclass = array();

                foreach ($versions as $version) {
                    $user = wiki_get_user_info($version->userid);
                    $picture = $OUTPUT->user_picture($user, array('popup' => true));
                    $date = userdate($version->timecreated, get_string('strftimedate'));
                    if ($date == $lastdate) {
                        $date = '';
                        $rowclass[] = '';
                    } else {
                        $lastdate = $date;
                        $rowclass[] = 'wiki_histnewdate';
                    }

                    $time = userdate($version->timecreated, get_string('strftimetime', 'langconfig'));
                    $versionid = wiki_get_version($version->id);
                    if ($versionid) {
                        $url = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
                        $viewlink = html_writer::link($url->out(false), $version->version);
                    } else {
                        $viewlink = $version->version;
                    }

                    $userlink = new moodle_url('/user/view.php', array('id' => $version->userid, 'course' => $PAGE->cm->course));
                    $picturelink = $picture . html_writer::link($userlink->out(false), fullname($user));
                    $historydate = $OUTPUT->container($date, 'wiki_histdate');
                    $radiofromelement = $this->choose_from_radio(array($version->version  => null), 'fromversion', 'M.mod_wiki.deleteversion()', $versioncount, true);
                    $radiotoelement = $this->choose_from_radio(array($version->version  => null), 'toversion', 'M.mod_wiki.deleteversion()', $versioncount, true);
                    $contents[] = array( $radiofromelement . $radiotoelement, $viewlink, $picturelink, $time, $historydate);
                }

                $table = new html_table();
                $table->head = array(get_string('deleteversions', 'wiki'), get_string('version'), get_string('user'), get_string('modified'), '');
                $table->data = $contents;
                $table->attributes['class'] = 'generaltable mdl-align';
                $table->rowclasses = $rowclass;

                ///Print the form
                echo html_writer::start_tag('form', array('action'=>new moodle_url('/mod/wiki/admin.php'), 'method' => 'post'));
                echo html_writer::tag('div', html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'pageid', 'value' => $pageid)));
                echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'option', 'value' => $this->view));
                echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' =>  sesskey()));
                echo html_writer::table($table);
                echo html_writer::start_tag('div', array('class' => 'mdl-align'));
                echo html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'wiki_form-button', 'value' => get_string('deleteversions', 'wiki')));
                echo html_writer::end_tag('div');
                echo html_writer::end_tag('form');
            }
        } else {
            print_string('nohistory', 'wiki');
        }
    }
コード例 #2
0
 /**
  * Prints the history for a given wiki page
  *
  * @global object $CFG
  * @global object $OUTPUT
  * @global object $PAGE
  */
 private function print_history_content()
 {
     global $CFG, $OUTPUT, $PAGE;
     $pageid = $this->page->id;
     $offset = $this->paging * $this->rowsperpage;
     // vcount is the latest version
     $vcount = wiki_count_wiki_page_versions($pageid) - 1;
     if ($this->allversion) {
         $versions = wiki_get_wiki_page_versions($pageid, 0, $vcount);
     } else {
         $versions = wiki_get_wiki_page_versions($pageid, $offset, $this->rowsperpage);
     }
     // We don't want version 0 to be displayed
     // version 0 is blank page
     if (end($versions)->version == 0) {
         array_pop($versions);
     }
     $contents = array();
     $version0page = wiki_get_wiki_page_version($this->page->id, 0);
     $creator = wiki_get_user_info($version0page->userid);
     $a = new StdClass();
     $a->date = userdate($this->page->timecreated, get_string('strftimedaydatetime', 'langconfig'));
     $a->username = $creator->username;
     echo $OUTPUT->heading(get_string('createddate', 'wiki', $a), 4, 'wiki_headingtime');
     if ($vcount > 0) {
         /// If there is only one version, we don't need radios nor forms
         if (count($versions) == 1) {
             $row = array_shift($versions);
             $username = wiki_get_user_info($row->userid);
             $picture = $OUTPUT->user_picture($username);
             $date = userdate($row->timecreated, get_string('strftimedate', 'langconfig'));
             $time = userdate($row->timecreated, get_string('strftimetime', 'langconfig'));
             $versionid = wiki_get_version($row->id);
             $versionlink = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
             $userlink = new moodle_url('/user/view.php', array('id' => $username->id));
             $contents[] = array('', html_writer::link($versionlink->out(false), $row->version), $picture . html_writer::link($userlink->out(false), fullname($username)), $time, $OUTPUT->container($date, 'wiki_histdate'));
             $table = new html_table();
             $table->head = array('', get_string('version'), get_string('user'), get_string('modified'), '');
             $table->data = $contents;
             $table->attributes['class'] = 'mdl-align';
             echo html_writer::table($table);
         } else {
             $checked = $vcount - $offset;
             $lastdate = '';
             $rowclass = array();
             foreach ($versions as $version) {
                 $user = wiki_get_user_info($version->userid);
                 $picture = $OUTPUT->user_picture($user, array('popup' => true));
                 $date = userdate($version->timecreated, get_string('strftimedate'));
                 if ($date == $lastdate) {
                     $date = '';
                     $rowclass[] = '';
                 } else {
                     $lastdate = $date;
                     $rowclass[] = 'wiki_histnewdate';
                 }
                 $time = userdate($version->timecreated, get_string('strftimetime', 'langconfig'));
                 $versionid = wiki_get_version($version->id);
                 if ($versionid) {
                     $url = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
                     $viewlink = html_writer::link($url->out(false), $version->version);
                 } else {
                     $viewlink = $version->version;
                 }
                 $userlink = new moodle_url('/user/view.php', array('id' => $version->userid));
                 $contents[] = array($this->choose_from_radio(array($version->version => null), 'compare', 'M.mod_wiki.history()', $checked - 1, true) . $this->choose_from_radio(array($version->version => null), 'comparewith', 'M.mod_wiki.history()', $checked, true), $viewlink, $picture . html_writer::link($userlink->out(false), fullname($user)), $time, $OUTPUT->container($date, 'wiki_histdate'));
             }
             $table = new html_table();
             $icon = $OUTPUT->help_icon('diff', 'wiki');
             $table->head = array(get_string('diff', 'wiki') . $icon, get_string('version'), get_string('user'), get_string('modified'), '');
             $table->data = $contents;
             $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
             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);
             echo html_writer::start_tag('div', array('class' => 'mdl-align'));
             echo html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'wiki_form-button', 'value' => get_string('comparesel', 'wiki')));
             echo html_writer::end_tag('div');
             echo html_writer::end_tag('form');
         }
     } else {
         print_string('nohistory', 'wiki');
     }
     if (!$this->allversion) {
         //$pagingbar = moodle_paging_bar::make($vcount, $this->paging, $this->rowsperpage, $CFG->wwwroot.'/mod/wiki/history.php?pageid='.$pageid.'&');
         // $pagingbar->pagevar = $pagevar;
         echo $OUTPUT->paging_bar($vcount, $this->paging, $this->rowsperpage, $CFG->wwwroot . '/mod/wiki/history.php?pageid=' . $pageid . '&');
         //print_paging_bar($vcount, $paging, $rowsperpage,$CFG->wwwroot.'/mod/wiki/history.php?pageid='.$pageid.'&','paging');
     } else {
         $link = new moodle_url('/mod/wiki/history.php', array('pageid' => $pageid));
         $OUTPUT->container(html_writer::link($link->out(false), get_string('viewperpage', 'wiki', $this->rowsperpage)), 'mdl-align');
     }
     if ($vcount > $this->rowsperpage && !$this->allversion) {
         $link = new moodle_url('/mod/wiki/history.php', array('pageid' => $pageid, 'allversion' => 1));
         $OUTPUT->container(html_writer::link($link->out(false), get_string('viewallhistory', 'wiki')), 'mdl-align');
     }
 }