Beispiel #1
0
    /**
     * helper function for print_delete_content. This will add data to the table.
     *
     * @global object $OUTPUT
     * @param array $pages objects of wiki pages in subwiki
     * @param int $swid id of subwiki
     * @param object $table reference to the table in which data needs to be added
     */
    protected function add_page_delete_options($pages, $swid, &$table) {
        global $OUTPUT;
        foreach ($pages as $page) {
            $link = wiki_parser_link($page->title, array('swid' => $swid));
            $class = ($link['new']) ? 'class="wiki_newentry"' : '';
            $pagelink = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
            $urledit = new moodle_url('/mod/wiki/edit.php', array('pageid' => $page->id, 'sesskey' => sesskey()));
            $urldelete = new moodle_url('/mod/wiki/admin.php', array(
                                                                   'pageid'  => $this->page->id,
                                                                   'delete'  => $page->id,
                                                                   'option'  => $this->view,
                                                                   'listall' => !$this->listorphan?'1': '',
                                                                   'sesskey' => sesskey()));

            $editlinks = $OUTPUT->action_icon($urledit, new pix_icon('t/edit', get_string('edit')));
            $editlinks .= $OUTPUT->action_icon($urldelete, new pix_icon('t/delete', get_string('delete')));
            $table->data[] = array($editlinks, $pagelink);
        }
    }
Beispiel #2
0
/**
 * Generate wiki's page tree
 *
 * @param page_wiki $page. A wiki page object
 * @param navigation_node $node. Starting navigation_node
 * @param array $keys. An array to store keys
 * @return an array with all tree nodes
 */
function wiki_build_tree($page, $node, &$keys)
{
    $content = array();
    static $icon;
    $icon = new pix_icon('f/odt', '');
    $pages = wiki_get_linked_pages($page->id);
    foreach ($pages as $p) {
        $key = $page->id . ':' . $p->id;
        if (in_array($key, $keys)) {
            break;
        }
        array_push($keys, $key);
        $l = wiki_parser_link($p);
        $link = new moodle_url('/mod/wiki/view.php', array('pageid' => $p->id));
        // navigation_node::get_content will format the title for us
        $nodeaux = $node->add($p->title, $link, null, null, null, $icon);
        if ($l['new']) {
            $nodeaux->add_class('wiki_newentry');
        }
        wiki_build_tree($p, $nodeaux, $keys);
    }
    $content[] = $node;
    return $content;
}
 /**
  * Prints the updated tab content
  *
  * @uses $COURSE, $OUTPUT
  *
  */
 private function print_updated_content()
 {
     global $COURSE, $OUTPUT;
     $page = $this->page;
     if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
         $fresh = wiki_refresh_cachedcontent($page);
         $page = $fresh['page'];
     }
     $swid = $this->subwiki->id;
     $table = new html_table();
     $table->head = array(get_string('updatedpages', 'wiki') . $OUTPUT->help_icon('updatedpages', 'wiki'));
     $table->attributes['class'] = 'wiki_editor generalbox';
     $table->data = array();
     $table->rowclasses = array();
     if ($pages = wiki_get_updated_pages_by_subwiki($swid)) {
         $strdataux = '';
         foreach ($pages as $page) {
             $user = wiki_get_user_info($page->userid);
             $strdata = strftime('%d %b %Y', $page->timemodified);
             if ($strdata != $strdataux) {
                 $table->data[] = array($OUTPUT->heading($strdata, 4));
                 $strdataux = $strdata;
             }
             $link = wiki_parser_link($page->title, array('swid' => $swid));
             $class = $link['new'] ? 'class="wiki_newentry"' : '';
             $linkpage = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
             $icon = $OUTPUT->user_picture($user, array($COURSE->id));
             $table->data[] = array("{$icon}&nbsp;{$linkpage}");
         }
     } else {
         $table->data[] = array(get_string('noupdatedpages', 'wiki'));
     }
     echo html_writer::table($table);
 }