function get_content() { global $CFG, $WS; if ($this->content !== NULL) { return $this->content; } //If we are out of a dfwiki activity or in a different //dfwiki format course and we want to create a block: if (empty($WS->dfwiki)) { $this->content->text = get_string('block_warning', 'wiki'); return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); //$this->content->footer = '<br />'.helpbutton ('updated', get_string('block_updated', 'wiki'), 'wiki', true, false, '', true).get_string('block_updated', 'wiki'); $ead = wiki_manager_get_instance(); $pages = $ead->get_wiki_most_uptodate_pages(10); // dfwiki-block || course-block $dir = ""; if ($this->instance->pagetype == "mod-wiki-view") { $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id; } else { $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course; } // rtl / ltr CSS alignment support (nadavkav) if (right_to_left()) { $nwikialignment = 'nwikirightnow'; } else { $nwikialignment = 'nwikileftnow'; } if (count($pages) != 0) { $text = '<table border="0" cellpadding="0" cellspacing="0">'; $i = 1; foreach ($pages as $page) { $pageinfo = wiki_page_last_version($page); $brs = strlen($page) > 12 ? '<br /> ' : ''; $text .= '<tr> <td class="' . $nwikialignment . '"> ' . $i . '- <a href="' . $dir . '&page=' . urlencode($page) . '" title="' . $page . '">' . $this->trim_string($page, 40) . '</a>' . $brs . ' - <small>(' . strftime('%d %b %y', $pageinfo->lastmodified) . ')</small> ' . wiki_get_user_info($pageinfo->author, 40, false) . ' </td> </tr>'; $i++; } $text .= '</table>'; } else { $text = get_string('nopages', 'wiki'); } $this->content->text = $text; return $this->content; }
function get_content() { global $CFG, $WS, $USER; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); //$this->content->footer = '<br />'.helpbutton ('contributions', get_string('block_contributions', 'wiki'), 'wiki', true, false, '', true).get_string('block_contributions', 'wiki'); //$this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki').helpbutton ('contributions', get_string('block_contributions', 'wiki'), 'wiki', true, false, '', true); //If we are out of a dfwiki activity or in a different //dfwiki format course and we want to create a block: if (empty($WS->dfwiki)) { $this->content->text = get_string('block_warning', 'wiki'); return $this->content; } $ead = wiki_manager_get_instance(); $pages = $ead->user_activity($USER->username); $dir = ""; if ($this->instance->pagetype == "mod-wiki-view") { $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id; } else { $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course; } if (count($pages) != 0) { $text = '<table border="0" cellpadding="0" cellspacing="0">'; foreach ($pages as $page) { $pageinfo = wiki_page_last_version($page); $modif = $pageinfo->author == $USER->username ? '' : ' ' . wiki_get_user_info($pageinfo->author, 20, false); $text .= '<tr> <td class="nwikileftnow"> <a href="' . $dir . '&page=' . urlencode($page) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '" title="' . urlencode($page) . '">' . format_text($this->trim_string($page, 30), FORMAT_PLAIN) . '</a>' . $modif . ' </td> </tr>'; } $text .= '</table>'; } else { $text = get_string('nopages', 'wiki'); } $this->content->text = $text; return $this->content; }
/** * Returns an array with the URLs of a page (plus optinal section if it's a * a partial editing) to view. * @param String $pagename * @param String $anchor Section name * @param String $anchortype (0, 1, 2)<br> * 0: no anchor<br> * 1: [[page#section]]<br> * 2: [[page##section]] * @return Array URLs Contains a list (if there are more than one section * with the same name in the same page) of URLs that * match the page and section */ function wiki_view_page_url($pagename, $anchor = '', $anchortype = 0, $wikibook = '') { global $CFG, $COURSE, $WS; if ($wikibook) { $wikibook = '&wikibook=' . urlencode($wikibook); } // support page synonyms $pagename = wiki_get_real_pagename($pagename); $urls = array(); $page = wiki_page_last_version($pagename); if ($page) { $sectionnums = wiki_get_section_positions($page->content, $anchor); } if ($page && $anchortype > 0 && count($sectionnums) > 0) { if ($anchortype == 1) { // [[page#section]] foreach ($sectionnums as $sectionnum) { $newurl = 'view.php?id=$COURSE->id&page=view/' . urlencode($pagename) . '&gid=$gid&uid=$uid' . $wikibook . '#' . $sectionnum; $newurl = wiki_format_url($newurl); $urls[] = $newurl; } } else { if ($anchortype == 2) { // [[page##section]] foreach ($sectionnums as $sectionnum) { $newurl = 'view.php?id=$COURSE->id&page=view/' . urlencode($pagename) . '&gid=$gid&uid=$uid' . $wikibook . '&section=' . urlencode($anchor) . '&sectionnum=' . $sectionnum; $newurl = wiki_format_url($newurl); $urls[] = $newurl; } } } } else { // no anchor $newurl = 'view.php?id=' . $COURSE->id . '&page=' . urlencode($pagename) . '&gid=$gid&uid=$uid' . $wikibook; $newurl = wiki_format_url($newurl); $urls[] = $newurl; } return $urls; }
function wiki_ead_print_cleanpage() { global $WS, $dfwiki_ead_stat; echo '<h1>' . get_string('cleanpage', 'wiki') . '</h1>'; echo '<div class="box generalbox generalboxcontent boxaligncenter">'; switch ($dfwiki_ead_stat) { case 'cleanok': echo '<h2>' . get_string('cleanok', 'wiki') . ' ' . stripslashes(optional_param('cleanpage', NULL, PARAM_FILE)) . '</h2><br />'; echo '<form method="post" action="view.php?id=' . $WS->cm->id . '"> <div class="textcenter"><input type="submit" value="' . get_string('continue') . '" /></div> </form>'; break; case 'cleanconfirm': echo '<h2>' . get_string('cleanconfirm', 'wiki') . ' ' . stripslashes(optional_param('cleanpage', NULL, PARAM_FILE)) . '?</h2>'; echo '<p>' . get_string('cleanmessage', 'wiki') . '</p>'; echo '<form method="post" action="view.php?id=' . $WS->cm->id . '&cleanpage=' . optional_param('cleanpage', NULL, PARAM_FILE) . '"> <table border="0" class="boxaligncenter"> <tr> <td> ' . get_string('howmanyversions', 'wiki') . ' </td> <td> <input type="hidden" name="dfsetup" value="2" /> <select name="dfformcleanvers">'; //get the versions count $pageinfo = wiki_page_last_version(optional_param('cleanpage', NULL, PARAM_FILE)); $ead = wiki_manager_get_instance(); $versions = $ead->versions(optional_param('cleanpage', NULL, PARAM_FILE)); $ops = array(5, 10, 20, 50, 100, 150, 200, 300, 500, 1000); echo '<option value="' . $pageinfo->version . '" selected="selected">' . get_string('none') . '</option>'; foreach ($ops as $op) { if ($op < $versions) { echo '<option value="' . ($pageinfo->version - $op) . '">' . $op . '</option>'; } } echo ' </select> </td></tr> </table> <p class="textcenter"> <input type="submit" name="dfformcleanconfirm" value=" ' . get_string('yes') . ' " /> </p> </form> <form method="post" action="view.php?id=' . $WS->cm->id . '"> <p class="textcenter"> <input type="submit" value=" ' . get_string('no') . ' " /> </p> </form>'; break; case 'cleanerror': echo '<h2>' . get_string('cleanerror', 'wiki') . ' ' . stripslashes(optional_param('cleanpage', NULL, PARAM_FILE)) . '</h2><br />'; echo '<form method="post" action="view.php?id=' . $WS->cm->id . '"> <div class="textcenter"><input type="submit" value="' . get_string('continue') . '" /></div> </form>'; break; } echo '</div>'; }
function built_index($page, $level) { global $CFG, $WS; //printed links array $printed_links = array(); // dfwiki-block || course-block $dir = ""; if ($this->instance->pagetype == "mod-wiki-view") { $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id; } else { $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course; } //search in vector if (!in_array($page, $this->pagesel)) { //put in vector $this->pagesel[] = $page; //get last version if (!($pageinfo = wiki_page_last_version($page))) { //empty page //put in result return '<li class="wiki_listme">' . $this->images['square'] . format_text($this->trim_string($page, 20), FORMAT_PLAIN) . '<a href="' . $dir . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=' . urlencode($page) . '">?</a></li>'; } else { //get links $links = wiki_internal_link_to_array($pageinfo->refs); $links = wiki_filter_section_links($links); //put in result if (count($links) == 0) { $res = '<li class="wiki_listme">' . $this->images['square'] . '<a href="' . $dir . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=' . urlencode($page) . '">' . format_text($this->trim_string($page, 20), FORMAT_PLAIN) . '</a>' . '</li>'; } else { //determine if this level is opened or close if ($level <= $this->levelsel) { $display = ''; $image_ico = $this->images['minus']; } else { $display = 'display:none'; $image_ico = $this->images['plus']; } $res = '<li class="wiki_listme">' . $image_ico . '<a href="' . $dir . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=' . urlencode($page) . '">' . format_text($this->trim_string($page, 20), FORMAT_PLAIN) . '</a> <ul class="wiki_listme" style="margin:auto auto auto 15px;' . $display . '">'; //foreach link do recursive foreach ($links as $link) { //get real page name $link = wiki_get_real_pagename($link); //search in printed_links if (!in_array($link, $printed_links)) { //put in printed links $printed_links[] = $link; //mount $res .= $this->built_index($link, $level + 1); } } $res .= '</ul></li>'; } //return result return $res; } } else { //page is already printed return '<li class="wiki_listme">' . $this->images['square'] . '<a href="' . $dir . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&page=' . urlencode($page) . '"><i>' . format_text($this->trim_string($page, 20), FORMAT_PLAIN) . '</i></a></li>'; } }
/** * Locks a page or section if it has not any lock restrictions. * If it has any restrictions, prints them. * * @param Object $WS WikiStorage * @return Boolean */ function wiki_set_lock($WS) { $preview = optional_param('dfformpreview', '', PARAM_TEXT); // don't lock in preview mode if ($preview != '') { return true; } $page = wiki_page_last_version($WS->page, $WS); if (!$page) { // when creating a new wiki or a new page of a wiki $content_text = ''; } else { $content_text = $page->content; } $sectionhash = optional_param('sectionhash', '', PARAM_TEXT); if ($sectionhash != '') { $lock_msg = wiki_is_section_locked($WS, $WS->dfwiki->id, $WS->page, $sectionhash, $content_text); if ($lock_msg == '') { return wiki_lock_message($WS, $sectionhash); } else { print $lock_msg; } } else { $lock_msg = wiki_is_page_locked($WS, $WS->dfwiki->id, $WS->page, $content_text); if ($lock_msg == '') { return wiki_lock_message($WS); } else { print $lock_msg; } } return false; }
function wiki_grade_append_to_discussion($WS, $pagename, $grade, $comment) { global $USER, $CFG, $COURSE; $context = get_context_instance(CONTEXT_MODULE, $WS->cm->id); $wikimanager = wiki_manager_get_instance(); $title = get_string('eval_discuss_title', 'wiki'); switch ($WS->dfform['editor']) { case 'ewiki': $append = chr(13) . chr(10) . '!!! ' . $title . ' ' . chr(13) . chr(10); break; case 'htmleditor': $append = chr(13) . chr(10) . '<h1> ' . $title . ' </h1>' . chr(13) . chr(10); break; default: $append = chr(13) . chr(10) . '= ' . $title . ' =' . chr(13) . chr(10); break; } $anonymous = optional_param('grade_anonymous', '', PARAM_TEXT); if ($anonymous == 'on') { $a->user = get_string('eval_anonymous_user', 'wiki'); } else { $info = $wikimanager->get_user_info_by_id($USER->id); $userprofile = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $USER->id . '&course=' . $COURSE->id . '">' . $info->firstname . ' ' . $info->lastname . '</a>'; $a->user = get_string('user') . ' ' . $userprofile; } $a->grade = wiki_grade_get_wikigrade($WS, $grade); $append .= get_string('eval_discuss_body_1', 'wiki', $a); $append .= "\n {$comment}\n"; unset($a); $a->quality = wiki_grade_get_quality($pagename, $WS->dfwiki->id, $WS->member->id, $WS->groupmember->groupid, 0); $append .= get_string('eval_discuss_body_2', 'wiki', $a); $pagename = 'discussion:' . $pagename; $data->pagename = $pagename; $page = wiki_page_last_version($pagename, $WS); if ($page) { $txt = $page->content . $append; $data->version = $page->version + 1; $data->created = $page->created; //get internal links of the page $links_refs = wiki_sintax_find_internal_links($txt); $links_clean = wiki_clean_internal_links($links_refs); $txt = wiki_set_clean_internal_links($txt, $links_refs, $links_clean); $data->refs = wiki_internal_link_to_string($links_refs); $data->editor = $page->editor; $data->editable = $page->editable; $data->hits = $page->hits; } else { $txt = $append; $data->version = 1; $data->created = time(); $data->refs = ''; //$data->editor = $WS->dfform['editor']; $data->editor = 'nwiki'; $data->editable = 1; $data->hits = 0; } $data->author = $USER->username; $data->userid = $USER->id; $data->ownerid = $WS->member->id; $data->lastmodified = time(); $data->content = addslashes($txt); $data->dfwiki = $WS->dfwiki->id; $data->groupid = $WS->groupmember->groupid; //$WS->groupmember->groupid = isset($WS->gid) ? $WS->gid : $WS->groupmember->groupid; //Check if the version passed is the last one or another one. if (($max = wiki_page_current_version_number($data, $WS)) >= $data->version) { notify("WARNING: some discussion version may be overwrited.", 'notifyproblem', $align = 'center'); $data->version = $max + 1; } ///Add some slashes before inserting the record $data->pagename = addslashes($data->pagename); $newpage = new wiki_page(PAGERECORD, $data); if (!($pageid = $wikimanager->save_wiki_page($newpage))) { error(get_string('noinsert', 'wiki')); } add_to_log($COURSE->id, 'wiki', 'save page', addslashes("view.php?id={$WS->cm->id}&page={$pagename}"), $pageid, $WS->cm->id); }
function wiki_hist_content(&$WS) { global $CFG; $compare_from = optional_param('diff', 0, PARAM_INT); if ($compare_from != 0) { $compare_to = optional_param('oldid', 0, PARAM_INT); if ($compare_from == 1) { $WS->ver = $compare_from . '/' . $compare_from; } elseif ($compare_to == 0) { $WS->ver = $compare_from . '/' . ($compare_from - 1); } else { $WS->ver = $compare_to . '/' . $compare_from; } } ///////////////// WIKI EVALUATION EDITION wiki_grade_set_edition_grade($WS); $tabrows = array(); $rows = array(); //mount tabs $tabs = array('diff', 'newdiff', 'oldversion'); //Converts reserved chars for html to prevent chars misreading $pagetemp = stripslashes_safe($WS->page); // discussions if (substr($WS->page, 0, strlen('discussion:')) != 'discussion:') { $eventview = 'view'; $eventinfo = 'info'; } else { $eventview = 'discussion'; $eventinfo = 'infodiscussion'; } //info $rows[] = new tabobject('return', 'view.php?id=' . $WS->linkid . '&page=' . $eventview . '/' . urlencode($pagetemp) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id, get_string('return', 'wiki')); //view old version foreach ($tabs as $tab) { $rows[] = new tabobject($tab, 'view.php?id=' . $WS->linkid . '&page=' . urlencode($tab . '/' . $pagetemp) . '&dfcontent=11&ver=' . $WS->ver . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id, get_string($tab, 'wiki')); } //info with discussions $rows[] = new tabobject('info', 'view.php?id=' . $WS->linkid . '&page=' . $eventinfo . '/' . urlencode($pagetemp) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id, get_string($eventinfo, 'wiki')); $tabrows[] = $rows; ////interface print_tabs($tabrows, $WS->pageaction); //load pageolddata and pageverdata if (isset($WS->ver)) { //separe old version from compare version $parts = explode('/', $WS->ver); if (count($parts) == 1) { $WS->pageolddata = get_record_sql('SELECT * FROM ' . $CFG->prefix . 'wiki_pages WHERE pagename=\'' . addslashes($WS->page) . '\' AND dfwiki=' . $WS->dfwiki->id . ' AND groupid=' . $WS->groupmember->groupid . ' AND version=' . $WS->ver . ' AND ownerid=' . $WS->member->id); $WS->pageverdata = wiki_page_last_version($WS->page); } else { $WS->pageolddata = get_record_sql('SELECT * FROM ' . $CFG->prefix . 'wiki_pages WHERE pagename=\'' . addslashes($WS->page) . '\' AND dfwiki=' . $WS->dfwiki->id . ' AND groupid=' . $WS->groupmember->groupid . ' AND version=' . $parts[0] . ' AND ownerid=' . $WS->member->id); $WS->pageverdata = get_record_sql('SELECT * FROM ' . $CFG->prefix . 'wiki_pages WHERE pagename=\'' . addslashes($WS->page) . '\' AND dfwiki=' . $WS->dfwiki->id . ' AND groupid=' . $WS->groupmember->groupid . ' AND version=' . $parts[1] . ' AND ownerid=' . $WS->member->id); } wiki_hist_actions($WS); } else { print_string('nocontent', 'wiki'); } }
function parse_header($matches) { global $tocheaders, $hindex; global $WS; $parsed_header = ""; // the first header will be preceeded by the TOC if (!$tocheaders) { $parsed_header .= "NWikiTableOfContents\n"; } $parsed_header .= "</p>"; // $matches[0] contains the full expresion // $matches[1] contains the expresion without the tags $cat = (strlen($matches[0]) - strlen($matches[1])) / 2; //the header includes an anchor, to come from the TOC $headername = trim($matches[1]); // add the header to the TOC $page = wiki_page_last_version($WS->page); $headernum = sizeof($tocheaders) + 1; $tocheaders[] = array($cat, $headername, $headernum); $elem = $cat <= 6 ? "h{$cat}" : "h6"; //$parsed_header .= "<$elem class=\"nwiki\" id=\"$headerid\">"; // add an edit link in the section header $parsed_header .= "<{$elem} class=\"nwiki\" id=\"{$headernum}\">"; $preview = optional_param('dfformpreview', '', PARAM_TEXT); $action = optional_param('dfformaction', '', PARAM_TEXT); $hash = wiki_get_section_hash($WS->pagedata->content, $headernum); // if we are in discussion pages don't add the edit link if (substr($WS->page, 0, strlen('discussion:')) == 'discussion:') { $parsed_header .= $headername . "</{$elem}>" . '<p>'; return $parsed_header; } // if we don't have permissions to edit (different group / student page) // forbid editing too if (!$WS->dfperms['edit']) { $parsed_header .= $headername . "</{$elem}>" . '<p>'; return $parsed_header; } // create the header edit links $section = optional_param('section', '', PARAM_TEXT); $sectionnum = optional_param('sectionnum', 0, PARAM_INTEGER); if ($section == '' && $sectionnum == 0 && $preview == '') { // main page $parsed_header .= '<span class="nwikieditsection">[<a href="view.php?id=' . $WS->linkid . '&uid=' . $WS->member->id . '&gid=' . $WS->groupmember->groupid . '&page=edit/' . urlencode($WS->page) . '&editor=' . $WS->pagedata->editor . '&section=' . urlencode($headername) . '&sectionnum=' . $headernum . '&sectionhash=' . $hash . '">edit</a>]</span>'; } else { if ($action == 'edit' && $preview == '') { $parsed_header .= '<span class="nwikieditsection">[<a href="view.php?id=' . $WS->linkid . '&uid=' . $WS->member->id . '&gid=' . $WS->groupmember->groupid . '&page=edit/' . urlencode($WS->page) . '&editor=' . $WS->pagedata->editor . '&section=' . urlencode($headername) . '&sectionnum=' . $headernum . '&sectionhash=' . $hash . '">edit</a>]</span>'; } } $parsed_header .= $headername . "</{$elem}>" . '<p>'; return $parsed_header; }
/** * This function loads the data of the wiki, depending on the wiki mode. * It considers the wikis with gropus and without them. * * Usually it will be used like this: * $WS->load_page_data(); * */ function load_page_data() { global $USER, $CFG, $WS; //print_object($WS); /* if (($this->dfwiki->studentmode == '0') && ($this->dfwiki->groupmode != '0')){ //only by groups: if (!$max = wiki_get_maximum_value_one($this->page, $this->dfwiki->id,$this->groupmember->groupid)){ error ('Theres\'s an error in page location'); } } else{ //by students and their groups: $max = wiki_get_maximum_value_two($this->page,$this->dfwiki->id,$this->groupmember->groupid,$this->member->id); if ($max === false){ error ('Theres\'s an error in page location'); } } //load page's data if ($max){ if(($this->dfwiki->studentmode == '0') && ($this->dfwiki->groupmode != '0')){ //only by groups $this->pagedata = wiki_get_latest_page_version_one($this->page,$this->dfwiki->id,$max,$this->groupmember->groupid); } else{ //by students and their groups $this->pagedata = wiki_get_latest_page_version_two($this->page,$this->dfwiki->id,$max,$this->groupmember->groupid, $this->member->id); if (isset($this->pagedata->pageaction)){ print $this->pagedata->pageaction; } } }else{ $this->pagedata->pagename = $this->page; $this->pagedata->version = 0; $this->pagedata->created = time(); $this->pagedata->editable = $this->dfwiki->editable; $this->pagedata->editor = isset($this->dfform['editor'])?$this->dfform['editor']:''; $this->pagedata->groupid = $this->groupmember->groupid; $this->pagedata->author = $USER->username; $this->pagedata->userid = $USER->id; $this->pagedata->ownerid = $this->member->id; } */ $pageinfo = wiki_page_last_version($this->page); //print_object(false); //echo "\n"; if ($pageinfo) { $this->pagedata = $pageinfo; } else { $this->pagedata->pagename = $this->page; $this->pagedata->version = 0; $this->pagedata->created = time(); $this->pagedata->editable = $this->dfwiki->editable; $this->pagedata->editor = isset($this->dfform['editor']) ? $this->dfform['editor'] : ''; $this->pagedata->groupid = $this->groupmember->groupid; $this->pagedata->author = $USER->username; $this->pagedata->userid = $USER->id; $this->pagedata->ownerid = $this->member->id; } $this->wikibookinfo = wikibook_info($this->page, $this->wikibook); }
function built_level($tofind, $page, $level) { global $WS, $CFG; //printed links array $printed_links = array(); //search in vector if (!in_array($page, $this->pagesel)) { //put in vector $this->pagesel[] = $page; if ($tofind == $page) { if ($this->pagelev > $level) { $this->pagelev = $level; } } else { //get last version if ($pageinfo = wiki_page_last_version($page)) { //get links $links = wiki_internal_link_to_array($pageinfo->refs); //foreach link do recursive foreach ($links as $link) { //get real page name $link = wiki_get_real_pagename($link); //search in printed_links if (!in_array($link, $printed_links)) { //put in printed links $printed_links[] = $link; //mount $this->built_level($tofind, $link, $level + 1); } } } } } }
/** * this function return an array with the pagenames of search results */ function wiki_part_search_result($text) { global $CFG, $WS; $res = array('pagename' => array(), 'content' => array()); // mount search string $field = '%'; $fields = explode(' ', $text); foreach ($fields as $f) { $field .= $f . '%'; } $ead = wiki_manager_get_instance(); $wiki = wiki_param('dfwiki'); $groupmember = wiki_param('groupmember'); $pages = $ead->get_wiki_page_names_of_wiki($wiki, $groupmember->groupid); foreach ($pages as $page) { $pageinfo = wiki_page_last_version($page); $contentfound = count($fields) != 0; $namefound = count($fields) != 0; foreach ($fields as $f) { $f = stripslashes_safe($f); $namefound = $namefound && stripos($pageinfo->pagename, $f) !== false; $contentfound = $contentfound && strpos($pageinfo->content, $f) !== false; } if ($contentfound) { $res['content'][] = $pageinfo->pagename; } if ($namefound) { $res['pagename'][] = $pageinfo->pagename; } } // search in synonyms $wikimanager = wiki_manager_get_instance(); $synonyms = $wikimanager->get_synonyms_by_wikiid($WS->dfwiki->id); foreach ($synonyms as $synonym) { $found = count($fields) != 0; foreach ($fields as $f) { $f = stripslashes_safe($f); $found = $found && stripos($synonym->name, $f) !== false; } if ($found && !in_array($synonym->pageid->name, $res['pagename'])) { $res['pagename'][] = $synonym->pageid->name; } } return $res; }
/** * return an array of all visibles pages from a pagename * @param String $page: startingpagename * @return array of Strings */ function get_visible_pages_from_page($page) { global $WS, $CFG; //printed links array $printed_links = array(); //search in vector if (!in_array($page, $this->pagesel)) { //put in vector $this->pagesel[] = $page; //get last version if ($pageinfo = wiki_page_last_version($page)) { //get links $links = wiki_internal_link_to_array($pageinfo->refs); //foreach link do recursive foreach ($links as $link) { //get real page name $link = wiki_get_real_pagename($link); //search in printed_links if (!in_array($link, $printed_links)) { //put in printed links $printed_links[] = $link; //mount $this->get_visible_pages_from_page($link); } } } } }
/** * Returns a XHTML string with comma-separated wikitags links * * @param Object $WS WikiStorage */ function wiki_tags_get_tag_links($WS) { global $CFG, $COURSE; $page = wiki_page_last_version($WS->page, $WS); if (!$page) { return null; } $tags = tag_get_tags('wiki', $page->created); if (!empty($tags)) { $tags = array_values($tags); $links = ''; $size = count($tags); for ($i = 0; $i < $size; $i++) { $tag = $tags[$i]; $links .= '<a href="' . $CFG->wwwroot . '/mod/wiki/tags/view.php?cid=' . $COURSE->id . '&cmid=' . $WS->cm->id . '&tagid=' . $tag->id . '">' . tag_display_name($tag) . '</a>'; /* * // when moodle-core (2.0?) allow to add custom items to * // taglist page we can enable this. *$links .= '<a href="'.$CFG->wwwroot.'/tag/index.php?'. * '&id='.$tag->id.'">'.$tag->name.'</a>'; */ if ($i != $size - 1) { $links .= ', '; } } return $links; } return ''; }