function get_content() { global $CFG, $WS; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); //$this->content->footer = '<br />'.helpbutton ('navigator', get_string('block_navigator', 'wiki'), 'wiki', true, false, '', true).get_string('block_navigator', 'wiki'); // $this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki') . // helpbutton ('navigator', get_string('block_navigator', 'wiki'), 'wiki', true, false, '', true); // dfwiki-block || course-block $dir = ""; if (isset($this->instance->pagetype)) { 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 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; } //starts ead tools $ead = wiki_manager_get_instance(); $text = '<b><span class="nwikiunderline">' . get_string('camefrom', 'wiki') . '</span></b>'; $camefroms = $ead->get_wiki_page_camefrom(addslashes($WS->pagedata->pagename)); $text .= '<table border="0" cellpadding="0" cellspacing="0">'; if ($camefroms == false) { $text .= '<tr><td></td></tr>'; } foreach ($camefroms as $camefrom) { $text .= '<tr><td class="nwikileftnow"><a href="' . $dir . '&page=' . urlencode($camefrom->pagename) . '">' . format_text($this->trim_string($camefrom->pagename, 36), FORMAT_HTML) . '</a></td></tr>'; } $text .= '</table>'; $text .= '<hr /><b><span class="nwikiunderline">' . get_string('goesto', 'wiki') . '</span></b>'; $goestos = $ead->get_wiki_page_goesto($WS->pagedata->pagename); $text .= '<table border="0" cellpadding="0" cellspacing="0">'; if ($goestos == false) { $text .= '<tr><td></td></tr>'; } // rtl / ltr CSS alignment support (nadavkav) if (right_to_left()) { $nwikialignment = 'nwikirightnow'; } else { $nwikialignment = 'nwikileftnow'; } foreach ($goestos as $goesto) { if (wiki_page_exists($WS, $goesto)) { $text .= '<tr><td class="' . $nwikialignment . '"><a href="' . $dir . '&page=' . urlencode($goesto) . '">' . format_text($this->trim_string($goesto, 37), FORMAT_HTML) . '</a></td></tr>'; } else { $text .= '<tr><td class="' . $nwikialignment . '"><span class="nwikiwanted"><a href="' . $dir . '&page=' . urlencode($goesto) . '">' . format_text($this->trim_string($goesto, 37), FORMAT_HTML) . '</a></span></td></tr>'; } } $text .= '</table>'; $this->content->text = $text; return $this->content; }
function wiki_ead_cleanpage() { global $dfwiki_ead_stat; $cleanpage = optional_param('cleanpage', NULL, PARAM_FILE); $dfwiki = wiki_param('dfwiki'); if (wiki_can_change()) { if (wiki_page_exists(false, $cleanpage, false)) { $cleanconfirm = optional_param('dfformcleanconfirm', NULL, PARAM_ALPHA); if (isset($cleanconfirm)) { $cleanvers = optional_param('dfformcleanvers', NULL, PARAM_INT); if (delete_records_select('wiki_pages', 'dfwiki=' . $dfwiki->id . ' and pagename=\'' . addslashes($cleanpage) . '\' and version < ' . $cleanvers)) { $dfwiki_ead_stat = 'cleanok'; } else { $dfwiki_ead_stat = 'cleanerror'; } } else { //show confirm form $dfwiki_ead_stat = 'cleanconfirm'; } } else { //this page can't be eliminated $dfwiki_ead_stat = 'cleanerror'; } } wiki_param('dfcontent', 9); wiki_main_setup(); }
function wiki_discussion_page_exists($deprecated, $name, $syn = true, $wid = false) { return wiki_page_exists(false, 'discussion:' . $name, $syn, $wid); }
function wiki_sintax_create_internal_link(&$linktext) { global $WS, $itinerary, $CFG, $COURSE; $res = ''; //separate type link from link text $parts = explode(":", $linktext); if (count($parts) == 1) { $linktype = 'internal'; $linkname = $parts[0]; } else { $linktype = $parts[0]; $linkname = $parts[1]; } switch ($linktype) { case 'internal': //normal internal links //separate linktext into pagename and text $parts = explode("|", $linkname); if (count($parts) == 1) { $linkpage = trim($parts[0]); $linktext = $parts[0]; } else { $linkpage = trim($parts[0]); $linktext = $parts[1]; } if (isset($itinerary)) { if (!wiki_page_exists($WS, $linkpage)) { $res = '<b><u>' . $linktext . '</u></b><a target="popup" href="' . $CFG->wwwroot . '/mod/wiki/view.php?a=' . $itinerary['dfwiki'] . '&page=' . urlencode($linkpage) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '">?</a>'; } else { $res = '<a href="view.php?id=' . $WS->cm->id . '&page=' . urlencode($linkpage) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '&name=dfwikipage">' . $linkpage . '</a>'; } } else { if (wiki_page_exists($WS, $linkpage)) { //if the page already exists if (isset($WS->dfcourse)) { //course internal link: $res = '<a href="view.php?id=' . $COURSE->id . '&page=' . urlencode($linkpage) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '">' . $linktext . '</a>'; } else { //module internal link: $res = '<a href="view.php?id=' . $WS->cm->id . '&page=' . urlencode($linkpage) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '">' . $linktext . '</a>'; } } else { //to create the page $res = '<b><u>' . $linktext . '</u></b><a href="view.php?id=' . $WS->linkid . '&page=' . urlencode($linkpage) . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '">?</a>'; } } //save link into log if (!isset($WS->parser_logs['internal'])) { $WS->parser_logs['internal'] = array(); } if (!in_array($linkpage, $WS->parser_logs['internal'])) { $WS->parser_logs['internal'][] = $linkpage; } break; case 'user': $res = wiki_get_user_info($linkname, 25); break; case 'attach': $res = '[' . wiki_upload_url($linkname, $WS) . ' ' . $linkname . ']'; break; default: //error } return $res; }
function parse_internal_link($matches) { global $WS, $CFG, $COURSE; // allow spaces before and after the internal link name $matches[1] = trim($matches[1]); $matches[1] = wiki_clean_name($matches[1]); $parts = explode('|', $matches[1]); $target = $parts[0]; $label = $target; if (count($parts) > 1) { $label = $parts[1]; } // internal links to sections $page = $target; $anchor = ''; $anchortype = 0; $pos = strpos($target, '#'); if ($pos > 0) { $page = substr($target, 0, $pos); if (substr($target, $pos + 1, 1) == "#") { // [[page##section]]: partial view of the section $anchortype = 2; $anchor = substr($target, $pos + 2, strlen($target) - $pos); } else { // [[page#section]]: page view plus scroll to section $anchortype = 1; $anchor = substr($target, $pos + 1, strlen($target) - $pos); } } // wikibook $wikibookname = ''; if (count($parts) > 2 && preg_match("/^wikibook:(.*)/", $parts[2], $match)) { $wikibookname = $match[1]; } $wikibookparam = ''; if ($wikibookname) { $wikibookparam = '&wikibook=' . urlencode($wikibookname); } // we can have more than one section with the same name, so we link // to all of them in a list after the link. $res = ''; $urls = wiki_view_page_url($page, $anchor, $anchortype, $wikibookname); $num_urls = count($urls); for ($i = 0; $i < $num_urls; $i++) { if ($i == 0) { // we render the first matched section as a normal link $res = '<a href="' . $urls[$i] . '">' . $label . '</a>'; } elseif ($i == 1) { $res .= ' [<a href="' . $urls[$i] . '">' . ($i + 1) . '</a>'; } else { $res .= ', <a href="' . $urls[$i] . '">' . ($i + 1) . '</a>'; } if ($i == $num_urls - 1 && $i > 0) { $res .= ']'; } } if (!wiki_page_exists($WS, $page, true)) { $res = '<span class="nwikiwanted">' . $res . '</span>'; } else { if ($anchor != '') { if (!wiki_section_exists($page, $anchor)) { $res = '<span class="nwikiwanted">' . $res . '</span>'; } } } return $res; }
function wiki_sintax_create_internal_link_bis(&$linktext) { global $WS, $USER, $itinerary; $WS->member->id = $USER->id; if ($WS->dfwiki->studentmode == '0') { $WS->member->id = '0'; } $res = ''; //separate type link from link text $parts = explode(":", $linktext); if (count($parts) == 1) { $linktype = 'internal'; $linkname = $parts[0]; } else { $linktype = $parts[0]; $linkname = $parts[1]; } switch ($linktype) { case 'internal': //normal internal links //separate linktext into pagename and text $parts = explode("|", $linkname); if (count($parts) == 1) { $linkpage = $parts[0]; $linktext = $parts[0]; } else { $linkpage = $parts[0]; $linktext = $parts[1]; } $cleanpagename = clean_filename($linkpage); if (isset($itinerary)) { if (!wiki_page_exists($WS, $linkpage)) { $res = '<b><u>' . $linktext . '</u></b><a target="popup" href="' . $linkpage . '.html">?</a>'; } else { $res = '<a href="' . $cleanpagename . '.html">' . $linkpage . '</a>'; } } else { if (wiki_page_exists($WS, $linkpage)) { //if the page already exists $res = '<a href="' . $cleanpagename . '.html">' . $linktext . '</a>'; } else { //to create the page $res = '<b><u>' . $linktext . '</u></b><a href="' . $linkpage . '.html">?</a>'; } } //save link into log if (!isset($WS->parser_logs['internal'])) { $WS->parser_logs['internal'] = array(); } if (!in_array($linkpage, $WS->parser_logs['internal'])) { $WS->parser_logs['internal'][] = $linkpage; } break; case 'user': $res = wiki_get_user_info($linkname, 25); break; case 'attach': wiki_upload_config($WS); $res = '[' . wiki_upload_url($linkname, $WS) . ' ' . $linkname . ']'; break; default: //error } return $res; }