function ouwiki_display_page_in_index($indexitem, $subwiki, $cm)
{
    if ($startpage = is_null($indexitem->title)) {
        $title = get_string('startpage', 'ouwiki');
        $output = '<div class="ouw_index_startpage">';
    } else {
        $title = $indexitem->title;
        $output = '';
    }
    $output .= '<a class="ouw_title" href="view.php?' . ouwiki_display_wiki_parameters($indexitem->title, $subwiki, $cm) . '">' . htmlspecialchars($title) . '</a>';
    $lastchange = new StdClass();
    $lastchange->userlink = ouwiki_display_user($indexitem, $cm->course);
    $lastchange->date = ouwiki_recent_span($indexitem->timecreated) . ouwiki_nice_date($indexitem->timecreated) . '</span>';
    $output .= '<div class="ouw_indexinfo">';
    $output .= ' <span class="ouw_lastchange">' . get_string('lastchange', 'ouwiki', $lastchange) . '</span>';
    $output .= '</div>';
    if ($startpage) {
        $output .= '</div>';
    }
    return $output;
}
Ejemplo n.º 2
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Import page content from other ouwiki activities into this wiki.
 * @package mod
 * @subpackage ouwiki
 * @copyright 2013 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(__FILE__) . '/../../config.php';
require $CFG->dirroot . '/mod/ouwiki/basicpage.php';
require $CFG->dirroot . '/mod/ouwiki/import_form.php';
$pageparams = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_ARRAY);
/* Define/work out the step of the import process we are on.
 Step 1  - Select wiki (+sub wiki)
Step 2 - Select pages
Step 3 - Confirm
Step 4 - Process import
*/
$curstep = optional_param('step', 1, PARAM_INT);
if (optional_param('cancel', '', PARAM_TEXT) == get_string('cancel')) {
    // Cancelled last step, go back one.
    $curstep -= 2;
}
$pageparams['step'] = $curstep;
$url = new moodle_url('/mod/ouwiki/import.php', array('id' => $id, 'page' => $pagename));
$PAGE->set_url($url);
$PAGE->set_cm($cm);
/**
 * Print the table which list the comments by the user in this subwiki,
 *  with the date of the comment and a link to the page
 *
 * @param unknown_type $subwiki   the subwiki in question
 * @param unknown_type $cm
 * @param unknown_type $userid    the id of the user
 * @param unknown_type $header    the header text for the table
 */
function reportsuser_usercommentstable($subwiki, $cm, $userid, $header, $csv)
{
    // get the user comments info
    $usercomments = ouwiki_get_usercomments($subwiki->id, $userid);
    if (count($usercomments) == 0) {
        return;
    }
    // Print the opening div and table tags as well as the header row
    if (!$csv) {
        print <<<EOF
<div class="ouw_usercommentslist">
 \t<h3>{$header->comments}</h3>
\t<table>
\t\t<tr>
\t\t\t<th class='ouw_leftcol' scope="col">{$header->datetime}</th>
\t\t\t<th class='ouw_rightcol' scope="col">{$header->pagename}</th>\t\t\t
\t\t</tr>\t\t
EOF;
    } else {
        print $csv->line() . $csv->quote($header->comments) . $csv->line() . $csv->quote($header->datetime) . $csv->sep() . $csv->quote($header->pagename) . $csv->line();
    }
    // for each comment in this subwiki by the user
    foreach ($usercomments as $usercomment) {
        // get the date and time of the comment
        $datetime = ouwiki_nice_date($usercomment->timeposted);
        // get the page title of the page with the comment
        $title = $usercomment->title;
        // make it html safe
        $pagetitle = htmlspecialchars($title);
        // create html link to the page
        $pagelink = "<a href='view.php?" . ouwiki_display_wiki_parameters($title, $subwiki, $cm) . "'>{$pagetitle}</a>";
        // if title is blank then must be subwiki start page - create link to there
        if ($title == '') {
            $pagelink = "<a href='view.php?" . ouwiki_display_wiki_parameters(null, $subwiki, $cm) . "'>" . get_string('startpage', 'ouwiki') . "</a>";
        }
        // print the table row for date and time and page link for comments by user
        if (!$csv) {
            print <<<EOF
\t\t<tr>
\t\t\t<td class='ouw_leftcol'>{$datetime}</td>
\t\t\t<td class='ouw_rightcol'>{$pagelink}</td>\t
\t\t</tr>\t\t
EOF;
        } else {
            if ($title == '') {
                $title = get_string('startpage', 'ouwiki');
            }
            print $csv->quote($datetime) . $csv->sep() . $csv->quote($title) . $csv->line();
        }
    }
    // close table and div tags
    if (!$csv) {
        print '
	</table>
</div>';
    }
}
// don't get confused
if ($candelete) {
    $found = false;
    foreach ($comments as $comment) {
        if ($comment->deleted) {
            $found = true;
            break;
        }
    }
    if ($found) {
        print '<p class="ouw_deletedcommentinfo">' . get_string('commentdeletedinfo', 'ouwiki') . '</p>';
    }
}
print '<div class="ouwiki_allcomments">';
// OK, display all comments
print ouwiki_display_comments($comments, $section, $pagename, $subwiki, $cm, true, $candelete);
// And 'add comment' form
if ($canpost) {
    print '<h2>' . get_string('commentpostheader', 'ouwiki') . '</h2>';
    print '<a id="post"></a>';
    print ouwiki_display_comment_form('comments', $section, $section ? $knownsections[$section] : null, $pagename, $subwiki, $cm);
}
print '</div>';
// Link to return to page
global $CFG, $THEME;
print '<div class="ouw_returnlink">' . '<span class="sep">' . $THEME->larrow . '</span> ' . '<a href="view.php?' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm) . '">' . get_string('returntopage', 'ouwiki') . '</a></div>';
// Footer
ouwiki_print_footer($course, $cm, $subwiki, $pagename);
?>

// Check permission
$comment = get_record('ouwiki_comments', 'id', $commentid);
$candelete = has_capability('mod/ouwiki:deletecomments', $context);
global $USER;
$owncomment = $comment->userid == $USER->id;
if (!$owncomment && !$candelete) {
    error('You do not have permission to delete this comment');
}
$confirmed = optional_param('confirm', 0, PARAM_INT);
// Admin users don't have to confirm delete since they can undelete
if ($candelete || $confirmed) {
    // Delete comment
    ouwiki_delete_comment($pageversion->pageid, $commentid, $delete);
    // Redirect
    redirect($url);
} else {
    // Display confirm form
    $nav = get_string('commentdelete', 'ouwiki');
    ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context, array(array('name' => $nav, 'type' => 'ouwiki')), true, true);
    print_box_start();
    print '<p>' . get_string('commentdeleteconfirm', 'ouwiki') . '</p>';
    print '<form action="deletecomment.php" method="post">';
    print ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm, OUWIKI_PARAMS_FORM);
    print '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="comment" value="' . $commentid . '" />' . '<input type="hidden" name="section" value="' . $section . '" />' . '<input type="hidden" name="delete" value="' . $delete . '" />' . '<input type="hidden" name="confirm" value="1" />' . '<input type="submit" name="action" value="' . get_string('commentdelete', 'ouwiki') . '"/> ' . '<input type="submit" name="cancel" value="' . get_string('cancel') . '"/>';
    print '</form>';
    print_box_end();
    ouwiki_print_footer($course, $cm, $subwiki, $pagename);
}
?>

Ejemplo n.º 6
0
    print '</ul>';
}
$missing = ouwiki_get_subwiki_missingpages($subwiki->id);
if (count($missing) > 0) {
    print '<div class="ouw_missingpages"><h2>' . get_string('missingpages', 'ouwiki') . '</h2>';
    print '<p>' . get_string(count($missing) > 1 ? 'advice_missingpages' : 'advice_missingpage', 'ouwiki') . '</p>';
    print '<ul>';
    $first = true;
    foreach ($missing as $title => $from) {
        print '<li>';
        if ($first) {
            $first = false;
        } else {
            print ' &#8226; ';
        }
        print '<a href="view.php?' . ouwiki_display_wiki_parameters($title, $subwiki, $cm) . '">' . htmlspecialchars($title) . '</a> <span class="ouw_missingfrom">(' . get_string(count($from) > 1 ? 'frompages' : 'frompage', 'ouwiki', '<a href="view.php?' . ouwiki_display_wiki_parameters($from[0], $subwiki, $cm) . '">' . ($from[0] ? htmlspecialchars($from[0]) : get_string('startpage', 'ouwiki')) . '</a>)</span>');
        print '</li>';
    }
    print '</ul>';
    print '</div>';
}
$tree = 0;
if (!empty($treemode)) {
    $wikiparams .= '&amp;type=tree';
    $tree = 1;
}
if (count($index) != 0) {
    print '<div class="ouw_entirewiki"><h2>' . get_string('entirewiki', 'ouwiki') . '</h2>';
    print '<p>' . get_string('onepageview', 'ouwiki') . '</p><ul>';
    print '<li id="ouwiki_down_html"><a href="entirewiki.php?' . $wikiparams . '&amp;format=html">' . get_string('format_html', 'ouwiki') . '</a></li>';
    // Are there any files in this wiki?
/**
 * Show the time lines of the edits on each page as a graph
 *
 * @param unknown_type $subwiki the subwiki
 * @param unknown_type $cm
 * @param unknown_type $viewgroupid the user group to view
 */
function ouwiki_showtimelines($subwiki, $cm, $viewgroupid, $header, $csv)
{
    // get the page versions edited in this subwiki by this user group
    $editpagetimes = ouwiki_get_editpagetimes($subwiki->id, $viewgroupid);
    // init arrays and min and max time
    $pagetimeline = array();
    $timeline = array();
    // record last page name
    $pagelast = "-1";
    $mintime = '-1';
    $maxtime = '-1';
    // for each edited page version initialise its array and min/max dates
    foreach ($editpagetimes as $editpagetime) {
        // get the page title
        $page = $editpagetime->pagetitle;
        // get the edit time and make it into a date
        $date = userdate($editpagetime->date, get_string('strftimedate'));
        // if a different page
        if ($page !== $pagelast) {
            // init the timeline info
            $timeline[$page] = array();
            // check for the earliest edit
            $mintime = $mintime == -1 ? $editpagetime->date : min($mintime, $editpagetime->date);
        }
        // check for the latest edit
        $maxtime = $maxtime == -1 ? $editpagetime->date : max($maxtime, $editpagetime->date);
        // save the title of the current page
        $pagelast = $page;
    }
    // number of seconds in a day
    $day = 60 * 60 * 24;
    // round the times to the beginning of the day
    $mintime -= $mintime % $day;
    $maxtime -= $maxtime % $day;
    // count the number of days
    $daycount = ceil(($maxtime - $mintime) / $day);
    // get the page titles
    $pages = array_keys($timeline);
    // for each page initialise every date to 0 edits
    foreach ($pages as $page) {
        // go from first edit date by user group on wiki to last edit date, a day at a time
        for ($time = $mintime; $time <= $maxtime; $time += $day) {
            // get the date
            $date = userdate($time, get_string('strftimedate'));
            // inititilise the data point to 0 edits
            $timeline[$page][$date] = 0;
        }
    }
    // init the maximum edits in a single day for scale
    $maxeditcount = 0;
    // for each edited page version count the number of edits for each page for each day
    foreach ($editpagetimes as $editpagetime) {
        // get the page title
        $page = $editpagetime->pagetitle;
        // get the edit date
        $date = userdate($editpagetime->date, get_string('strftimedate'));
        // increment the number of times the page has been edited on this date
        $timeline[$page][$date]++;
        // check for maximum edits in a single day
        $maxeditcount = max($maxeditcount, $timeline[$page][$date]);
    }
    // get min and max dates for edits by user group in wiki
    $mindate = userdate($mintime, get_string('strftimedate'));
    $maxdate = userdate($maxtime, get_string('strftimedate'));
    // Don't show it if there's nothing in it
    if (count($timeline) == 0) {
        return;
    }
    // print opening div and table tags as well as headers, the first header is the page name and link to the page
    //    and the second contains the first and last date of editing
    if (!$csv) {
        print <<<EOF
    <div class="ouw_timelines_page">
    <h3>{$header->timelinetitle}</h3>
    <table>
    <tr>
    <th scope="col">{$header->timelinepage}<div class='ouw_pagecolumn'></div></th>
    <th class="ouw_firstingroup" scope="col">{$mindate}</th><th class='ouw_rightcol ouw_lastdate' scope="col">{$maxdate}</th>
    \t    </tr>
EOF;
    } else {
        print $csv->line() . $csv->quote($header->timelinetitle) . $csv->line() . $csv->quote($header->timelinepage);
        $data = reset($timeline);
        foreach ($data as $date => $datum) {
            print $csv->sep() . $csv->quote($date);
        }
    }
    // Draw the graphs
    // for each timeline for each page
    $count = count($timeline);
    foreach ($timeline as $pagetitle => $data) {
        // if no title then must be start page of wiki, create link to this
        if ($pagetitle === '') {
            // get the parameters to view the subwiki pages
            $pageparams = ouwiki_display_wiki_parameters(null, $subwiki, $cm);
            // create a link to the page
            $pagelink = "<a href='view.php?" . $pageparams . "'>" . get_string('startpage', 'ouwiki') . "</a>";
        } else {
            // get the page params to link to the page
            $pageparams = ouwiki_display_wiki_parameters($pagetitle, $subwiki, $cm);
            // create a link to the page
            $pagelink = "<a href='view.php?" . $pageparams . "'>" . htmlspecialchars($pagetitle) . "</a>";
        }
        // print the title and link to the page
        $count--;
        if (!$csv) {
            print "\n        \t<tr" . ($count == 0 ? " class='ouw_lastrow'" : "") . ">\n        <td class='ouw_leftcol'>{$pagelink}</td>\n        <td class='ouw_rightcol ouw_firstingroup' colspan='2'>";
            // print the bar chart for the page timeline data, max edit count is for an even scale,
            // the numbers are the size of each graph => width, height
            barchart($data, 800, 20, $maxeditcount);
            // close the tags for the row
            print "\n        \t\t<div class='clearer'></div></td>\n        \t</tr>";
        } else {
            if ($pagetitle === '') {
                $pagetitle = get_string('startpage', 'ouwiki');
            }
            print $csv->line() . $csv->quote(htmlspecialchars($pagetitle));
            foreach ($data as $date => $datum) {
                print $csv->sep() . $csv->quote($datum);
            }
        }
    }
    // close the table and div tags for the timeline data
    if (!$csv) {
        print '
    	</table>
    </div>';
    } else {
        print $csv->line();
    }
}
Ejemplo n.º 8
0
    <link>' . $pagelink . '</link>
    <pubDate>' . date('r', reset($changes)->timecreated) . '</pubDate>';
} else {
    print '
<feed xmlns="http://www.w3.org/2005/Atom">
  <link rel="self" href="' . $feedlink . '"/>
  <link rel="alternate" type="text/html" href="' . $pagelink . '"/>
  <title>' . $feedtitle . '</title>
  <subtitle>' . $feeddescription . '</subtitle>
  <updated>' . date('c', reset($changes)->timecreated) . '</updated>
  <author>
    <name>Wiki system</name>
  </author>
  <id>' . $id . '</id>';
}
$pageparams = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm);
foreach ($changes as $change) {
    $a = new StdClass();
    $a->name = htmlspecialchars(fullname($change));
    if ($change->versionid == $pageversion->versionid) {
        $itemlink = $CFG->wwwroot . '/mod/ouwiki/view.php?' . $pageparams;
    } else {
        $itemlink = $CFG->wwwroot . '/mod/ouwiki/viewold.php?' . $pageparams . '&amp;version=' . $change->versionid;
    }
    $itemtitle = $ouwiki->name . ' - ' . $pagetitle . ' (' . ouwiki_nice_date($change->timecreated) . ')';
    $nextchange = next($changes);
    if ($nextchange) {
        $a->url = $CFG->wwwroot . '/mod/ouwiki/diff.php?' . $pageparams . '&amp;v1=' . $nextchange->versionid . '&amp;v2=' . $change->versionid;
        $a->main = get_string('feedchange', 'ouwiki', $a);
    } else {
        $a->main = get_string('feednewpage', 'ouwiki', $a);
Ejemplo n.º 9
0
 /**
  * Get html for the annotate link.
  *
  * @param string $str
  * @param string $pagename
  * @param object $subwiki
  * @param object $cm
  * @param string $xhtmlid
  * @return string
  */
 public function ouwiki_get_annotate_link($pagename, $subwiki, $cm)
 {
     global $CFG;
     return ' ' . html_writer::tag('a', get_string('annotate', 'ouwiki'), array('href' => $CFG->wwwroot . '/mod/ouwiki/annotate.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL), 'class' => 'ouw_annotate'));
 }
Ejemplo n.º 10
0
require_once dirname(__FILE__) . '/../../config.php';
require_once $CFG->dirroot . '/local/ousearch/searchlib.php';
require $CFG->dirroot . '/mod/ouwiki/basicpage.php';
$querytext = required_param('query', PARAM_RAW);
$url = new moodle_url('/mod/ouwiki/search.php', array('id' => $id, 'user' => $userid, 'query' => $querytext));
$PAGE->set_url($url);
$ouwikioutput = $PAGE->get_renderer('mod_ouwiki');
echo $ouwikioutput->ouwiki_print_start($ouwiki, $cm, $course, $subwiki, get_string('searchresults'), $context, null, null, null, '', '', $querytext);
echo html_writer::start_div();
$query = new local_ousearch_search($querytext);
$query->set_coursemodule($cm);
if ($subwiki->groupid) {
    $query->set_group_id($subwiki->groupid);
}
if ($subwiki->userid) {
    $query->set_user_id($subwiki->userid);
}
$foundsomething = $query->display_results('search.php?' . ouwiki_display_wiki_parameters('', $subwiki, $cm));
echo $foundsomething;
// Add link to search the rest of this website if service available.
if (!empty($CFG->block_resources_search_baseurl)) {
    $params = array('course' => $course->id, 'query' => $querytext);
    $restofwebsiteurl = new moodle_url('/blocks/resources_search/search.php', $params);
    $strrestofwebsite = get_string('restofwebsite', 'local_ousearch');
    $altlink = html_writer::start_tag('div', array('class' => 'advanced-search-link'));
    $altlink .= html_writer::link($restofwebsiteurl, $strrestofwebsite);
    $altlink .= html_writer::end_tag('div');
    print $altlink;
}
// Footer
ouwiki_print_footer($course, $cm, $subwiki, null, 'search.php?query=' . urlencode($querytext), $foundsomething ? null : 'searchfailure', $querytext);
/**
 * This prints a table showing the info about each page including the name of the page with a link to the page;
 *   the number of contributors, edits, comments, intensity; the number of edits and comments by role;
 *   the date of the first and last edits; the number of words and number of links to the page.
 *
 * @param object $subwiki        the subwiki id 
 * @param object $cm			
 * @param int $viewgroupid    the group id
 * @param object $header         the header text object
 * @param unknown_type $pagesinfo      the title, first day of editing, last day and text of each page
 * @param array $rolenames	   the array of role names
 * @param unknown_type $pageeditcount  the array of edit counts for each page
 * @param unknown_type $editsbyroles   the array of edit counts for each role
 * @param unknown_type $pagecontributorcount   the number of contributors on each page
 * @param int $totalusers             the total number of users
 * @param unknown_type $pagecommentcount       the number of comments on each page
 * @param unknown_type $commentsbyroles        the number of comments by each role
 */
function reportssummary_editedpagetable($contexts, $subwiki, $cm, $viewgroupid, $header, $pagesinfo, $rolenames, $pageeditcount, $editsbyroles, $pagecontributorcount, $totalusers, $pagecommentcount, $commentsbyroles, $csv)
{
    // list of edited pages table
    // get the data from the database
    // get the number of pages that link to the each page
    $pagelinks = ouwiki_get_pagelinks($subwiki->id);
    // get the collaboration intensity
    $collabintensity = ouwiki_get_collaborationintensity($contexts, $subwiki->id, $viewgroupid);
    // this function prints out the first two header rows of the table
    reportssummary_editedpagetableheaders($header, $rolenames, $csv);
    // for each page in the subwiki, use the info to display a row of data
    foreach ($pagesinfo as $pageid => $pageinfo) {
        // get the page title
        $title = $pageinfo->title;
        // get total number of edits on page
        $editcount = $pageeditcount[$title];
        // get total number of conrtributors for page
        $contributorcount = $pagecontributorcount[$title];
        // calc percentage of contributers from all users
        $contribpercent = $totalusers != 0 ? round($contributorcount / $totalusers * 100, 1) : 0;
        // get the number of total comments on the page
        $commentcount = $pagecommentcount[$title];
        // calc the number of words in the page text
        $wordcount = str_word_count(strip_tags($pageinfo->text));
        // get the first day of editing on the page
        $startday = userdate($pageinfo->startday, get_string('strftimedate'));
        // get the last day of editing on the page
        $lastday = userdate($pageinfo->lastday, get_string('strftimedate'));
        // get the number of links to the page
        $linkcount = isset($pagelinks[$pageid]) ? $pagelinks[$pageid]->linkcount : 0;
        // get the page params to link to the page
        $pageparams = ouwiki_display_wiki_parameters($title, $subwiki, $cm);
        // create a link to the page
        $pagelink = "<a href='view.php?" . $pageparams . "'>" . htmlspecialchars($title) . "</a>";
        // if no title then must be start page of wiki, create link to this
        if ($title === null) {
            // get the parameters to view the subwiki pages
            $pageparams = ouwiki_display_wiki_parameters(null, $subwiki, $cm);
            $pagelink = "<a href='view.php?" . $pageparams . "'>" . get_string('startpage', 'ouwiki') . "</a>";
        }
        // get the collaboration intensity
        $collaboration = isset($collabintensity[$pageid]) ? $collabintensity[$pageid] : ($editcount ? 0 : '');
        // start the row of data in the table for the current page and print the first four bits of info:
        //    page name and link, contributor count with percentage, edit count and comment count
        if (!$csv) {
            print "\n        <tr>\n        \t<td class='ouw_leftcol'>{$pagelink}</td>\n           \t<td>{$contributorcount} ({$contribpercent}%)</td>           \t\t\t\n           \t<td>{$editcount}</td>\n           \t<td>{$commentcount}</td>           \t\t\t\n           \t<td class='ouw_datecolumn'>{$startday}</td>\n           \t<td class='ouw_datecolumn'>{$lastday}</td>\n           \t<td>{$wordcount}</td>\n           \t<td>{$linkcount}</td>\n           \t<td>{$collaboration}</td>\n           \t";
        } else {
            if ($title === null) {
                $title = get_string('startpage', 'ouwiki');
            }
            print $csv->quote(htmlspecialchars($title)) . $csv->sep() . $csv->quote($contributorcount . ' (' . $contribpercent . '%)') . $csv->sep() . $csv->quote($editcount) . $csv->sep() . $csv->quote($commentcount) . $csv->sep() . $csv->quote($startday) . $csv->sep() . $csv->quote($lastday) . $csv->sep() . $csv->quote($wordcount) . $csv->sep() . $csv->quote($linkcount) . $csv->sep() . $csv->quote($collaboration) . $csv->sep();
        }
        // for each role name, print the info for that role: edits, comments and intensity
        $count = count($rolenames);
        foreach ($rolenames as $roleid => $rolename) {
            $count--;
            $endornot = $count ? '' : ' class="ouw_rightcol"';
            // get the number of edits by current role
            $editsbyrole = $editsbyroles[$roleid];
            $roleeditcount = isset($editsbyrole[$pageid]) ? $editsbyrole[$pageid]->editcount : 0;
            // get the number of comments by role
            $commentsbyrole = $commentsbyroles[$roleid];
            $rolecommentcount = isset($commentsbyrole[$pageid]) ? $commentsbyrole[$pageid]->commentcount : 0;
            // print the 3 data columns for the role name: edits, comments and collaboration
            if (!$csv) {
                print "\n        \t\t<td class='ouw_firstingroup'>{$roleeditcount}</td>\n        \t\t<td{$endornot}>{$rolecommentcount}</td>\n        \t\t";
            } else {
                print $csv->quote($roleeditcount) . $csv->sep() . $csv->quote($rolecommentcount) . $csv->sep();
            }
        }
        // print the data columns for the current page: first day of editing,
        //    last day of editing, word count and number of links
        if (!$csv) {
            print "           \t\t\t\n   \t\t</tr>\n   \t\t";
        } else {
            print $csv->line();
        }
    }
    // close the table and div tags
    $strintensityexplanation = get_string('report_intensityexplanation', 'ouwiki');
    if (!$csv) {
        print "\n\t</table>\n\t<p><small>\n\t  * {$strintensityexplanation}\n\t</small></p>\n</div>\n";
        /* Do not display intensity * or explanation due to html specific characters
            } else {
                print $csv->quote('*' .$strintensityexplanation).$csv->line();
        */
    }
}
/**
 * @param object $subwiki For details of user/group and ID so that
 *   we can make links
 * @param object $cm Course-module object (again for making links)
 * @param object $pageversion Data from page and version tables.
 * @return string HTML content for page
 */
function ouwiki_display_create_page_form($subwiki, $cm, $pageversion)
{
    $result = '';
    $genericformdetails = '<form method="get" action="edit.php">
<div class="ouwiki_addnew_div">
<input type="hidden" name="originalpagename" value="' . $pageversion->title . '" />
' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm, $type = OUWIKI_PARAMS_FORM);
    $result .= '<div id="ouwiki_addnew"><ul>
<li>
' . $genericformdetails . '
' . get_string('addnewsection', 'ouwiki') . '
<input type="text" size="30" name="newsectionname" id="ouw_newsectionname" value="' . get_string('typeinsectionname', 'ouwiki') . '" />
<input type="submit" id="ouw_add" name="ouw_subb" value="' . get_string('add', 'ouwiki') . '" />
</div>
</form>
</li>
<li>
' . $genericformdetails . '
' . get_string('createnewpage', 'ouwiki') . '
<input type="text" name="page" id="ouw_newpagename" size="30" value="' . get_string('typeinpagename', 'ouwiki') . '" />
<input type="submit" id="ouw_create" name="ouw_subb" value="' . get_string('create', 'ouwiki') . '" />
</div>
</form>
</li>
</ul>
</div>';
    return $result;
}
Ejemplo n.º 13
0
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Toggles the controls whether to load HQ videos or SQ videos for this user
 * @package mod_ouwiki
 * @copyright 2012 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require '../../config.php';
require $CFG->dirroot . '/mod/ouwiki/basicpage.php';
require_login();
require_sesskey();
$hide = required_param('hide', PARAM_INT);
if ($hide) {
    set_user_preference(OUWIKI_PREF_HIDEANNOTATIONS, 1);
} else {
    unset_user_preference(OUWIKI_PREF_HIDEANNOTATIONS);
}
// If this is the AJAX version, stop processing now.
if (optional_param('ajax', 0, PARAM_INT)) {
    exit;
}
// Otherwise redirect back.
redirect('view.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL));
if (!preg_match('/^[0-9]+_[0-9]+$/', $section)) {
    $section = null;
}
if ($section) {
    if (!array_key_exists($section, $knownsections)) {
        error("Unknown section {$section}");
    }
    $sectiontitle = $knownsections[$section];
}
// Get other parameters
$fromphp = required_param('fromphp', PARAM_RAW);
$title = stripslashes(required_param('title', PARAM_RAW));
$xhtml = stripslashes(required_param('xhtml', PARAM_CLEAN));
// Work out redirect url
if ($fromphp == 'view') {
    $url = 'view.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL) . '&showcomments' . ($section ? '#ouw_s' . $section : '');
} else {
    $url = 'comments.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL) . ($section ? '&section=' . $section : '');
}
if ('' == preg_replace('/(<.*?>)|(&nbsp;)|\\s/', '', $xhtml)) {
    error(get_string('commentblank', 'ouwiki'), $url);
}
// Check post permission
require_capability('mod/ouwiki:comment', $context);
// Add post
ouwiki_add_comment($pageversion->pageid, $section, $section ? $sectiontitle : null, $title, $xhtml);
// Redirect
redirect($url);
?>

Ejemplo n.º 15
0
    print_error('invalidcoursemodule');
}
$PAGE->set_cm($cm);
// When creating a new page, do some checks
$addpage = false;
if (!is_null($frompage)) {
    $urlparams['frompage'] = $frompage;
    $returnurl = new moodle_url('/mod/ouwiki/view.php', ouwiki_display_wiki_parameters($frompage, $subwiki, $cm, OUWIKI_PARAMS_ARRAY));
    if (trim($pagename) === '') {
        print_error('emptypagetitle', 'ouwiki', $returnurl);
    }
    // Strip whitespace from new page name from form (editor does this for other links).
    $pagename = preg_replace('/\\s+/', ' ', $pagename);
    $addpage = true;
}
$returnurl = new moodle_url('/mod/ouwiki/view.php', ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_ARRAY));
// When creating a section, do checks
$addsection = false;
if (!is_null($newsection)) {
    if (trim($newsection) === '') {
        print_error('emptysectiontitle', 'ouwiki', $returnurl);
    }
    $addsection = true;
}
$context = context_module::instance($cm->id);
$PAGE->set_pagelayout('incourse');
require_course_login($course, true, $cm);
$ouwikioutput = $PAGE->get_renderer('mod_ouwiki');
require_capability('mod/ouwiki:edit', $context);
$url = new moodle_url('/mod/ouwiki/edit.php', $urlparams);
$PAGE->set_url($url);
                print str_repeat($csv->sep(), 8);
            }
        }
    }
    // close the row tag
    if (!$csv) {
        print '
   	</tr>';
    } else {
        print $csv->line();
    }
}
// close table and div tags
if (!$csv) {
    print '
   	</table>
</div>';
} else {
    // That's it for downloading csv file
    exit;
}
// For non-group wiki, also offer non-group view link
if (!$subwiki->groupid) {
    print '<p><a href="reportsgroup.php?' . ouwiki_display_wiki_parameters(null, $subwiki, $cm) . '&amp;viewgroup=0">' . get_string('report_viewallgroups', 'ouwiki') . '</a></p>';
}
// Display csv download links
$wikiparams = ouwiki_display_wiki_parameters(null, $subwiki, $cm);
print '<ul class="csv-links"><li><a href="reportssummary.php?' . $wikiparams . '&amp;format=csv">' . get_string('csvdownload', 'ouwiki') . '</a></li>
    <li><a href="reportssummary.php?' . $wikiparams . '&amp;format=excelcsv">' . get_string('excelcsvdownload', 'ouwiki') . '</a></li></ul>';
// Footer
ouwiki_print_footer($course, $cm, $subwiki);
Ejemplo n.º 17
0
 *
 * @copyright &copy; 2009 The Open University
 * @author b.j.waddington@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ouwiki
 */
require_once dirname(__FILE__) . '/../../config.php';
require $CFG->dirroot . '/mod/ouwiki/basicpage.php';
$id = required_param('id', PARAM_INT);
// Course Module ID that defines wiki
// check we are using the annotation system
$action = required_param('ouw_lock', PARAM_RAW);
$pageid = required_param('ouw_pageid', PARAM_INT);
// Get the current page version, creating page if needed
$pageversion = ouwiki_get_current_page($subwiki, $pagename, OUWIKI_GETPAGE_ACCEPTNOVERSION);
$wikiformfields = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_FORM);
$sectionfields = '';
// get the context and check user has the required capability
require_capability('mod/ouwiki:lock', $context);
$ouwikioutput = $PAGE->get_renderer('mod_ouwiki');
// Get an editing lock
list($lockok, $lock) = ouwiki_obtain_lock($ouwiki, $pageversion->pageid);
// Handle case where page is locked by someone else
if (!$lockok) {
    // Print header etc
    echo $ouwikioutput->ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context);
    $details = new StdClass();
    $lockholder = $DB->get_record('user', array('id' => $lock->userid));
    $details->name = fullname($lockholder);
    $details->lockedat = ouwiki_nice_date($lock->lockedat);
    $details->seenat = ouwiki_nice_date($lock->seenat);
Ejemplo n.º 18
0
    switch ($format) {
        case OUWIKI_FORMAT_TEMPLATE:
            print '<page>';
            if ($pageversion->title !== '') {
                print '<title>' . htmlspecialchars($pageversion->title) . '</title>';
            }
            print '<xhtml>' . htmlspecialchars($pageversion->xhtml) . '</xhtml>';
            print '</page>';
            break;
        case OUWIKI_FORMAT_RTF:
            $html .= '<h1>' . htmlspecialchars($visibletitle) . '</h1>';
            $html .= trim($pageversion->xhtml);
            $html .= '<br /><br /><hr />';
            break;
        case OUWIKI_FORMAT_HTML:
            print '<div class="ouw_entry"><a name="' . $pageversion->pageid . '"></a><h1 class="ouw_entry_heading"><a href="view.php?' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm) . '">' . htmlspecialchars($visibletitle) . '</a></h1>';
            print ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, $index, $pageversion->xhtmlformat);
            print '</div>';
            break;
    }
    if ($first) {
        $first = false;
    }
}
switch ($format) {
    case OUWIKI_FORMAT_TEMPLATE:
        print '</wiki>';
        break;
    case OUWIKI_FORMAT_RTF:
        $html .= '</root>';
        rtf_from_html($filename . '.rtf', $html);
Ejemplo n.º 19
0
 /**
  * Render single user participation record for display
  *
  * @param object $user
  * @param array $changes user participation
  * @param object $cm
  * @param object $course
  * @param object $ouwiki
  * @param object $subwiki
  * @param string $pagename
  * @param int $groupid
  * @param string $download
  * @param bool $canview level of participation user can view
  * @param object $context
  * @param string $fullname
  * @param bool $cangrade permissions to grade user participation
  * @param string $groupname
  */
 public function ouwiki_render_user_participation($user, $changes, $cm, $course, $ouwiki, $subwiki, $pagename, $groupid, $download, $canview, $context, $fullname, $cangrade, $groupname)
 {
     global $DB, $CFG, $OUTPUT;
     require_once $CFG->dirroot . '/mod/ouwiki/participation_table.php';
     $filename = "{$course->shortname}-" . format_string($ouwiki->name, true);
     if (!empty($groupname)) {
         $filename .= '-' . format_string($groupname, true);
     }
     $filename .= '-' . format_string($fullname, true);
     // setup the table
     $table = new ouwiki_user_participation_table($cm, $course, $ouwiki, $pagename, $groupname, $user, $fullname);
     $table->setup($download);
     $table->is_downloading($download, $filename, get_string('participation', 'ouwiki'));
     // participation doesn't need standard ouwiki tabs so we need to
     // add this one div in manually
     if (!$table->is_downloading()) {
         echo html_writer::start_tag('div', array('id' => 'ouwiki_belowtabs'));
     }
     $previouswordcount = false;
     $lastdate = null;
     foreach ($changes as $change) {
         $date = userdate($change->timecreated, get_string('strftimedate'));
         $time = userdate($change->timecreated, get_string('strftimetime'));
         if (!$table->is_downloading()) {
             if ($date == $lastdate) {
                 $date = null;
             } else {
                 $lastdate = $date;
             }
             $now = time();
             $edittime = $time;
             if ($now - $edittime < 5 * 60) {
                 $category = 'ouw_recenter';
             } else {
                 if ($now - $edittime < 4 * 60 * 60) {
                     $category = 'ouw_recent';
                 } else {
                     $category = 'ouw_recentnot';
                 }
             }
             $time = html_writer::start_tag('span', array('class' => $category));
             $time .= $edittime;
             $time .= html_writer::end_tag('span');
         }
         $page = $change->title ? htmlspecialchars($change->title) : get_string('startpage', 'ouwiki');
         $row = array($date, $time, $page);
         // word counts
         if ($ouwiki->enablewordcount) {
             $previouswordcount = false;
             if ($change->previouswordcount) {
                 $words = ouwiki_wordcount_difference($change->wordcount, $change->previouswordcount, true);
             } else {
                 $words = ouwiki_wordcount_difference($change->wordcount, 0, false);
             }
             if (!$table->is_downloading()) {
                 $row[] = $words;
             } else {
                 if ($words <= 0) {
                     $row[] = 0;
                     $row[] = $words;
                 } else {
                     $row[] = $words;
                     $row[] = 0;
                 }
             }
         }
         if (!$table->is_downloading()) {
             $pageparams = ouwiki_display_wiki_parameters($change->title, $subwiki, $cm);
             $pagestr = $page . ' ' . $lastdate . ' ' . $edittime;
             if ($change->id != $change->firstversionid) {
                 $accesshidetext = get_string('viewwikichanges', 'ouwiki', $pagestr);
                 $changeurl = new moodle_url("/mod/ouwiki/diff.php?{$pageparams}" . "&v2={$change->id}&v1={$change->previousversionid}");
                 $changelink = html_writer::start_tag('small');
                 $changelink .= ' (';
                 $changelink .= html_writer::link($changeurl, get_string('changes', 'ouwiki'));
                 $changelink .= ')';
                 $changelink .= html_writer::end_tag('small');
             } else {
                 $accesshidetext = get_string('viewwikistartpage', 'ouwiki', $pagestr);
                 $changelink = html_writer::start_tag('small');
                 $changelink .= ' (' . get_string('newpage', 'ouwiki') . ')';
                 $changelink .= html_writer::end_tag('small');
             }
             $current = '';
             if ($change->id == $change->currentversionid) {
                 $viewurl = new moodle_url("/mod/ouwiki/view.php?{$pageparams}");
             } else {
                 $viewurl = new moodle_url("/mod/ouwiki/viewold.php?" . "{$pageparams}&version={$change->id}");
             }
             $actions = html_writer::tag('span', $accesshidetext, array('class' => 'accesshide'));
             $actions .= html_writer::link($viewurl, get_string('view'));
             $actions .= $changelink;
             $row[] = $actions;
         }
         // add to the table
         $table->add_data($row);
     }
     if (!$table->is_downloading()) {
         $table->print_html();
         /// Print the whole table
         // Grade
         if ($cangrade && $ouwiki->grade != 0) {
             $this->ouwiki_render_user_grade($course, $cm, $ouwiki, $user, $pagename, $groupid);
         }
     }
 }
Ejemplo n.º 20
0
    <pubDate>' . date('r', reset($changes)->timecreated) . '</pubDate>';
} else {
    print '
<feed xmlns="http://www.w3.org/2005/Atom">
  <link rel="self" href="' . $feedlink . '"/>
  <title>' . $feedtitle . '</title>
  <subtitle>' . $feeddescription . '</subtitle>
  <link href="http://example.org/"/>
  <updated>' . date('c', reset($changes)->timecreated) . '</updated>
  <author>
    <name>Wiki system</name>
  </author>
  <id>' . $id . '</id>';
}
foreach ($changes as $change) {
    $pageparams = ouwiki_display_wiki_parameters($change->title, $subwiki, $cm);
    $a = new StdClass();
    $a->name = htmlspecialchars(fullname($change));
    $a->date = ouwiki_nice_date($change->timecreated);
    $itemtitle = $ouwiki->name . ' - ' . ($change->title === '' ? get_string('startpage', 'ouwiki') : htmlspecialchars($change->title));
    $itemlink = $CFG->wwwroot . '/mod/ouwiki/view.php?' . $pageparams;
    if (!empty($change->previousversionid)) {
        $a->url = $CFG->wwwroot . '/mod/ouwiki/diff.php?' . $pageparams . '&amp;v1=' . $change->previousversionid . '&amp;v2=' . $change->versionid;
        $a->main = get_string('feedchange', 'ouwiki', $a);
    } else {
        $a->main = get_string('feednewpage', 'ouwiki', $a);
    }
    $itemdescription = get_string('feeditemdescriptiondate', 'ouwiki', $a);
    if ($rss) {
        // The 'permalink' guid just points to the wiki history page but with a unique-ifying versionid on end
        print '
Ejemplo n.º 21
0
function ouwiki_print_tabs($selected, $pagename, $subwiki, $cm, $context, $pageexists = true, $pagelocked = null)
{
    global $CFG;
    $tabrow = array();
    $params = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm);
    $tabrow[] = new tabobject('view', 'view.php?' . $params, get_string('tab_view', 'ouwiki'));
    if ($subwiki->canedit && !$pagelocked) {
        $tabrow[] = new tabobject('edit', 'edit.php?' . $params, get_string('tab_edit', 'ouwiki'));
    }
    if ($subwiki->annotation) {
        if ($subwiki->canannotate) {
            $tabrow[] = new tabobject('annotate', 'annotate.php?' . $params, get_string('tab_annotate', 'ouwiki'));
        }
    }
    if ($pageexists) {
        $tabrow[] = new tabobject('history', 'history.php?' . $params, get_string('tab_history', 'ouwiki'));
    }
    $tabs = array();
    $tabs[] = $tabrow;
    print_tabs($tabs, $selected, $pageexists ? '' : array('edit', 'annotate'));
    print '<div id="ouwiki_belowtabs">';
}
Ejemplo n.º 22
0
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Handles what happens when a user with appropriate permission attempts to
 * override a wiki page editing lock.
 *
 * @copyright &copy; 2007 The Open University
 * @author s.marshall@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ouwiki
 */
require_once dirname(__FILE__) . '/../../config.php';
require $CFG->dirroot . '/mod/ouwiki/basicpage.php';
if (!data_submitted()) {
    print_error("Only POST requests accepted");
}
if (!has_capability('mod/ouwiki:overridelock', $context)) {
    print_error("You do not have the capability to override editing locks");
}
$pageversion = ouwiki_get_current_page($subwiki, $pagename, OUWIKI_GETPAGE_ACCEPTNOVERSION);
ouwiki_override_lock($pageversion->pageid);
$redirpage = optional_param('redirpage', '', PARAM_ALPHA);
if ($redirpage != '') {
    redirect($redirpage . '.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL), '', 0);
} else {
    redirect('edit.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL), '', 0);
}
Ejemplo n.º 23
0
function get_online_display_content($format, $pageversion, $context, $subwiki, $cm, $index, $fs, &$files)
{
    $markup = '';
    $visibletitle = $pageversion->title === '' ? get_string('startpage', 'ouwiki') : $pageversion->title;
    if ($format != OUWIKI_FORMAT_TEMPLATE) {
        $pageversion->xhtml = file_rewrite_pluginfile_urls($pageversion->xhtml, 'pluginfile.php', $context->id, 'mod_ouwiki', 'content', $pageversion->versionid);
    }
    switch ($format) {
        case OUWIKI_FORMAT_TEMPLATE:
            // Print template wiki page.
            $markup .= '<page>';
            if ($pageversion->title !== '') {
                $markup .= '<title>' . htmlspecialchars($pageversion->title) . '</title>';
            }
            $markup .= '<versionid>' . $pageversion->versionid . '</versionid>';
            // Copy images found in content.
            preg_match_all('#<img.*?src="@@PLUGINFILE@@/(.*?)".*?/>#', $pageversion->xhtml, $matches);
            if (!empty($matches)) {
                // Extract the file names from the matches.
                foreach ($matches[1] as $key => $match) {
                    // Get file name and copy to zip.
                    $match = urldecode($match);
                    // Copy image - on fail swap tag with string.
                    if ($file = $fs->get_file($context->id, 'mod_ouwiki', 'content', $pageversion->versionid, '/', $match)) {
                        $files["/{$pageversion->versionid}/{$match}/"] = $file;
                    } else {
                        $pageversion->xhtml = str_replace($matches[0][$key], $brokenimagestr, $pageversion->xhtml);
                    }
                }
            }
            $markup .= '<xhtml>' . htmlspecialchars($pageversion->xhtml) . '</xhtml>';
            // Add attachments.
            if ($attachments = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $pageversion->versionid, 'itemid', false)) {
                // We have attachements.
                $markup .= '<attachments>';
                $attachmentsarray = array();
                foreach ($attachments as $attachment) {
                    $filename = $attachment->get_filename();
                    array_push($attachmentsarray, $filename);
                    $files["/{$pageversion->versionid}/{$filename}/"] = $attachment;
                }
                $markup .= implode('|', $attachmentsarray);
                $markup .= '</attachments>';
            }
            $markup .= '</page>';
            break;
        case OUWIKI_FORMAT_RTF:
            $markup .= '<h1>' . htmlspecialchars($visibletitle) . '</h1>';
            $markup .= trim($pageversion->xhtml);
            $markup .= '<br /><br /><hr />';
            break;
        case OUWIKI_FORMAT_HTML:
            print '<div class="ouw_entry"><a name="' . $pageversion->pageid . '"></a><h1 class="ouw_entry_heading">' . '<a href="view.php?' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm) . '">' . htmlspecialchars($visibletitle) . '</a></h1>';
            print ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, $index, $pageversion->xhtmlformat);
            print '</div>';
            break;
    }
    return $markup;
}
Ejemplo n.º 24
0
$files1 = ($files1 = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $pageversion1->versionid, "timemodified", false)) ? $files1 : null;
$files2 = ($files2 = $fs->get_area_files($context->id, 'mod_ouwiki', 'attachment', $pageversion2->versionid, "timemodified", false)) ? $files2 : null;
list($attachdiff1, $attachdiff2, $attachnumchanges) = ouwiki_diff_attachments($files1, $files2, $context->id, $pageversion1->versionid, $pageversion2->versionid);
$numchanges = $numchanges + $attachnumchanges;
// if there are no changes then check if there are any annotations in the new version
if ($numchanges == 0) {
    $annotations = ouwiki_get_annotations($pageversion2);
    if (count($annotations) === 0) {
        $advice = get_string('diff_nochanges', 'ouwiki');
    } else {
        $advice = get_string('diff_someannotations', 'ouwiki');
    }
} else {
    $advice = get_string('advice_diff', 'ouwiki');
}
print '<p class="ouw_advice">' . $advice . ' ' . get_string('returntohistory', 'ouwiki', 'history.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm)) . '</p>';
// Obtain pluginfile urls.
$pageversion1->xhtml = file_rewrite_pluginfile_urls($pageversion1->xhtml, 'pluginfile.php', $context->id, 'mod_ouwiki', 'content', $pageversion1->versionid);
$pageversion2->xhtml = file_rewrite_pluginfile_urls($pageversion2->xhtml, 'pluginfile.php', $context->id, 'mod_ouwiki', 'content', $pageversion2->versionid);
// Obtain difference between two versions
list($diff1, $diff2) = ouwiki_diff_html($pageversion1->xhtml, $pageversion2->xhtml);
// To make it look like a user object
$pageversion1->id = $pageversion1->userid;
$v1name = ouwiki_display_user($pageversion1, $course->id);
$pageversion2->id = $pageversion2->userid;
$v2name = ouwiki_display_user($pageversion2, $course->id);
// Disply the two versions
$v1 = new StdClass();
$v1->version = get_string('olderversion', 'ouwiki');
$v1->date = userdate($pageversion1->timecreated);
$v1->savedby = get_string('savedby', 'ouwiki', $v1name);
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package ouwiki
 */
/** */
require 'basicpage.php';
if (class_exists('ouflags')) {
    require_once '../../local/mobile/ou_lib.php';
    global $OUMOBILESUPPORT;
    $OUMOBILESUPPORT = true;
    ou_set_is_mobile(ou_get_is_mobile_from_cookies());
    if (ou_get_is_mobile()) {
        ou_mobile_configure_theme();
    }
}
ouwiki_print_start($ouwiki, $cm, $course, $subwiki, get_string('searchresults'), $context);
require_once '../../blocks/ousearch/searchlib.php';
$querytext = stripslashes(required_param('query', PARAM_RAW));
$query = new ousearch_search($querytext);
$query->set_coursemodule($cm);
if ($subwiki->groupid) {
    $query->set_group_id($subwiki->groupid);
}
if ($subwiki->userid) {
    $query->set_user_id($subwiki->userid);
}
$foundsomething = ousearch_display_results($query, 'search.php?' . ouwiki_display_wiki_parameters(null, $subwiki, $cm));
// Footer
ouwiki_print_footer($course, $cm, $subwiki, null, 'search.php?query=' . urlencode($querytext), $foundsomething ? null : 'searchfailure', $querytext);
?>

// Check permission - Allow anyone with edit capability to revert to a previous version
$canrevert = has_capability('mod/ouwiki:edit', $context);
if (!$canrevert) {
    print_error('reverterrorcapability', 'ouwiki');
}
// Check if reverting to previous version has been confirmed
$confirmed = optional_param('confirm', null, PARAM_RAW);
if ($confirmed) {
    // Lock something - but maybe this should be the current version
    list($lockok, $lock) = ouwiki_obtain_lock($ouwiki, $pageversion->pageid);
    // Revert to previous version
    ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $pagename, $pageversion->xhtml);
    // Unlock whatever we locked
    ouwiki_release_lock($pageversion->pageid);
    // Redirect to view what is now the current version
    redirect('view.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL));
    exit;
} else {
    // Display confirm form
    $nav = get_string('revertversion', 'ouwiki');
    ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context, array(array('name' => $nav, 'type' => 'ouwiki')), true, true);
    print_box_start();
    $a = ouwiki_nice_date($pageversion->timecreated);
    print get_string('revertversionconfirm', 'ouwiki', $a);
    print '<form action="revert.php" method="post">';
    print ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_FORM);
    print '<input type="hidden" name="version" value="' . $versionid . '" />' . '<input type="submit" name="confirm" value="' . get_string('revertversion', 'ouwiki') . '"/> ' . '<input type="submit" name="cancel" value="' . get_string('cancel') . '"/>';
    print '</form>';
    print_box_end();
    ouwiki_print_footer($course, $cm, $subwiki, $pagename);
}
$versionid = required_param('version');
// Get the current page version
$pageversion = ouwiki_get_page_version($subwiki, $pagename, $versionid);
if (!$pageversion) {
    error('Unknown page version');
}
// Check permission - Allow anyone with delete page capability to view a deleted page version
$candelete = has_capability('mod/ouwiki:deletepage', $context);
if (!empty($pageversion->deletedat) && !$candelete) {
    print_error('viewdeletedversionerrorcapability', 'ouwiki');
}
// Get previous and next versions
$prevnext = ouwiki_get_prevnext_version_details($pageversion);
// Get basic wiki parameters
$wikiparams = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm);
ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context, array(array('name' => get_string('tab_history', 'ouwiki'), 'link' => 'history.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm), 'type' => 'ouwiki'), array('name' => get_string('oldversion', 'ouwiki'), 'type' => 'ouwiki')), true, true);
// Information box
if ($prevnext->prev) {
    $date = ouwiki_nice_date($prevnext->prev->timecreated);
    $prev = link_arrow_left(get_string('previousversion', 'ouwiki', $date), "viewold.php?{$wikiparams}&amp;version={$prevnext->prev->versionid}");
} else {
    $prev = '';
}
if ($prevnext->next) {
    if ($prevnext->next->versionid == $pageversion->currentversionid) {
        $date = get_string('currentversion', 'ouwiki');
        $next = link_arrow_right(get_string('nextversion', 'ouwiki', $date), "view.php?{$wikiparams}");
    } else {
        $date = ouwiki_nice_date($prevnext->next->timecreated);
        $next = link_arrow_right(get_string('nextversion', 'ouwiki', $date), "viewold.php?{$wikiparams}&amp;version={$prevnext->next->versionid}");
    }
Ejemplo n.º 28
0
        // Get first undeleted (current) page version (there must be one)
        $pageversions = ouwiki_get_page_history($pageversion->pageid, false, 0, 1);
        $currentpageversion = reset($pageversions);
        if (!$currentpageversion) {
            throw new Exception('Error deleting/undeleting ouwiki page version');
        }
        // Check if version that has been undeleted should be the new current version
        if ($pageversion->currentversionid != $currentpageversion->versionid) {
            // Set new current version id
            $DB->set_field('ouwiki_pages', 'currentversionid', $currentpageversion->versionid, array('id' => $pageversion->pageid));
        }
        // Update completion status for user
        $completion = new completion_info($course);
        if ($completion->is_enabled($cm) && ($ouwiki->completionedits || $ouwiki->completionpages)) {
            $completion->update_state($cm, COMPLETION_COMPLETE, $pageversion->userid);
        }
    }
} catch (Exception $e) {
    // Unlock page
    ouwiki_release_lock($pageversion->pageid);
    ouwiki_dberror('Error deleting/undeleting ouwiki page version ' . $e);
}
// Unlock page
ouwiki_release_lock($pageversion->pageid);
// Log delete or undelete action
$ouwikiparamsurl = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL);
add_to_log($course->id, 'ouwiki', 'version' . $action, 'delete.php?' . $ouwikiparamsurl . '&amp;version=' . $versionid, '', $cm->id);
$redirecturl = new moodle_url('/mod/ouwiki/history.php');
// Redirect to view what is now the current version
redirect($redirecturl . '?' . $ouwikiparamsurl);
exit;
Ejemplo n.º 29
0
function ouwiki_display_entirewiki_page_in_index($pageinfo, $subwiki, $cm, $index, $context)
{
    global $ouwiki;
    // Get page details.
    $pageversion = ouwiki_get_current_page($subwiki, $pageinfo->title);
    // If the page hasn't really been created yet, skip it.
    if (is_null($pageversion->xhtml)) {
        return '';
    }
    $visibletitle = $pageversion->title === '' ? get_string('startpage', 'ouwiki') : $pageversion->title;
    $pageversion->xhtml = file_rewrite_pluginfile_urls($pageversion->xhtml, 'pluginfile.php', $context->id, 'mod_ouwiki', 'content', $pageversion->versionid);
    $pageversion->xhtml = ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, $index, $pageversion->xhtmlformat);
    $output = '<div class="ouw_entry"><a name="' . $pageversion->pageid . '"></a><h1 class="ouw_entry_heading"><a href="view.php?' . ouwiki_display_wiki_parameters($pageversion->title, $subwiki, $cm) . '">' . htmlspecialchars($visibletitle) . '</a></h1>';
    $output .= $pageversion->xhtml;
    $output .= '</div>';
    return $output;
}