18 define(
"IL_WIKI_MODE_REPLACE",
"replace");
19 define(
"IL_WIKI_MODE_COLLECT",
"collect");
20 define(
"IL_WIKI_MODE_EXT_COLLECT",
"ext_collect");
80 $a_collect_non_ex =
false,
85 $wgLegalTitleChars =
" %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
88 include_once(
"./Modules/Wiki/classes/class.ilMediaWikiAdapter.php");
90 $GLOBALS[
"wgInterWikiCache"] =
false;
92 # the % is needed to support urlencoded titles as well 94 $tc = $wgLegalTitleChars .
'#%';
98 #split the entire text string on occurences of [[ 99 $a = explode(
'[[',
' ' .
$s);
100 #get the first element (all text up to first [[), and remove the space we added 101 $s = array_shift($a);
104 # Match a link having the form [[namespace:link|alternate]]trail 105 $e1 =
"/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
107 # Match cases where there is no "]]", which might still be images 111 # Match the end of a line for a word that's not followed by whitespace, 112 # e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched 133 $useSubpages =
false;
136 for ($k = 0; isset($a[$k]); $k++) {
140 $might_be_img =
false;
143 if (preg_match($e1, $line,
$m)) { # page with normal text or alt
145 # If we get a ] at the beginning of $m[3] that means we have a link that's something like: 146 # [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up, 147 # the real problem is with the $e1 regex 150 # Still some problems for cases where the ] is meant to be outside punctuation, 151 # and no image is in sight. See bug 2095. 154 substr(
$m[3], 0, 1) ===
']' &&
155 strpos($text,
'[') !== false
157 $text .=
']'; # so that replaceExternalLinks($text) works later
158 $m[3] = substr($m[3], 1);
160 # fix up urlencoded title texts 161 if (strpos(
$m[1],
'%') !==
false) {
162 # Should anchors '#' also be rejected? 163 $m[1] = str_replace(
array(
'<',
'>'),
array(
'<',
'>'), urldecode(
$m[1]));
173 }
else { # Invalid form; output directly
174 $s .= $prefix .
'[[' . $line ;
181 # Don't allow internal links to pages containing 182 # PROTO: where PROTO is a valid URL protocol; these 183 # should be external links. 185 $s .= $prefix .
'[[' . $line ;
189 # Make subpage if necessary 196 $noforce = (substr(
$m[1], 0, 1) !=
':');
198 # Strip off leading ':' 199 $link = substr($link, 1);
206 include_once(
"./Modules/Wiki/mediawiki/Title.php");
207 include_once(
"./Services/Utilities/classes/Sanitizer.php");
215 $s .= $prefix .
'[[' . $line;
267 $wasblank = (
'' ==
$text);
272 # Link not escaped by : , create the various objects 341 # Special and Media are pseudo-namespaces; no pages actually exist in them 377 if (is_object($nt)) {
381 $collect[] =
array(
"nt" => $nt,
"text" =>
$text,
382 "trail" => $trail,
"db_title" => $db_title,
383 "url_title" => $url_title);
390 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
394 !in_array($db_title, $collect)) {
395 $collect[] = $db_title;
415 return str_replace(
array(
"\x00",
"\n",
"\r",
"\\",
"'",
'"',
"\x1a"),
"", $a_str);
441 if (!is_object($nt)) {
443 $retVal =
"<!-- ERROR -->{$prefix}{$text}{$trail}";
451 if ($nt->mFragment !=
"") {
452 if (substr(
$text, strlen(
$text) - strlen(
"#" . $nt->mFragment))
453 ==
"#" . $nt->mFragment) {
454 $text = substr(
$text, 0, strlen(
$text) - strlen(
"#" . $nt->mFragment));
455 $anc =
"#" . $nt->mFragment;
457 $anc =
"#" . $nt->mFragment;
461 # Separate the link trail from the rest of the link 465 $retVal =
'***' .
$text .
"***" . $trail;
468 if ($db_title !=
"") {
478 $wiki_link_class = (!$pg_exists)
479 ?
' class="ilc_link_IntLink ilWikiPageMissing" ' 480 :
' class="ilc_link_IntLink" ';
483 if ($url_title !=
"") {
484 $ilCtrl->setParameterByClass(
"ilobjwikigui",
"page", $url_title);
485 $retVal =
'<a ' . $wiki_link_class .
' href="' .
486 $ilCtrl->getLinkTargetByClass(
"ilobjwikigui",
"gotoPage") . $anc .
487 '">' .
$text .
'</a>' . $trail;
488 $ilCtrl->setParameterByClass(
"ilobjwikigui",
"page",
$_GET[
"page"]);
490 $retVal =
'<a ' . $wiki_link_class .
' href="' .
492 '">' .
$text .
'</a>' . $trail;
496 if ($db_title !=
"") {
498 $retVal =
'<a ' . $wiki_link_class .
' href="' .
499 "wpg_" . $pg_id .
".html" . $anc .
500 '">' .
$text .
'</a>' . $trail;
502 $retVal =
'<a ' . $wiki_link_class .
' href="' .
504 '">' .
$text .
'</a>' . $trail;
507 $retVal =
$text . $trail;
537 $wgUrlProtocols =
array(
552 if (is_array($wgUrlProtocols)) {
553 $protocols =
array();
555 $protocols[] = preg_quote($protocol,
'/');
558 return implode(
'|', $protocols);
560 return $wgUrlProtocols;
583 return str_replace(
"_",
" ", $a_par);
592 $a_par = str_replace(
" ",
"_", $a_par);
599 $regex =
'/^([a-z]+)(.*)$/sD';
605 if (preg_match($regex, $trail,
$m)) {
611 return array( $inside, $trail );
619 $ilObjDataCache = $DIC[
"ilObjDataCache"];
620 $ilAccess = $DIC->access();
622 include_once
"./Services/Notification/classes/class.ilNotification.php";
623 include_once
"./Modules/Wiki/classes/class.ilObjWiki.php";
624 include_once
"./Modules/Wiki/classes/class.ilWikiPage.php";
626 $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
627 $wiki =
new ilObjWiki($a_wiki_ref_id,
true);
631 $ignore_threshold = ($a_action ==
"comment");
634 if ($a_action ==
"new") {
657 include_once
"./Services/Link/classes/class.ilLink.php";
660 $link =
ilLink::_getLink(
"",
"wiki", null,
"wpage_" . $a_page_id .
"_" . $a_wiki_ref_id);
665 include_once
"./Services/Mail/classes/class.ilMail.php";
666 include_once
"./Services/User/classes/class.ilObjUser.php";
667 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
668 include_once(
"./Services/User/classes/class.ilUserUtil.php");
674 include_once
"Modules/Wiki/classes/class.ilWikiPageGUI.php";
677 $pgui->setAbstractOnly(
true);
678 $pgui->setFileDownloadLink(
".");
679 $pgui->setFullscreenLink(
".");
680 $pgui->setSourcecodeDownloadScript(
".");
681 $snippet = $pgui->showPage();
685 $snippet = str_replace(
'<br/>',
"\n", $snippet);
686 $snippet = str_replace(
'<br />',
"\n", $snippet);
687 $snippet = str_replace(
'</p>',
"\n", $snippet);
688 $snippet = str_replace(
'</div>',
"\n", $snippet);
690 $snippet = trim(strip_tags($snippet));
693 $current_version = array_shift($page->getHistoryEntries());
694 $current_version = $current_version[
"nr"];
695 if (!$current_version) {
701 foreach (array_unique(
$users) as $idx => $user_id) {
702 if ($user_id !=
$ilUser->getId() &&
703 $ilAccess->checkAccessOfUser($user_id,
'read',
'', $a_wiki_ref_id)) {
706 $ulng->loadLanguageModule(
'wiki');
708 $subject = sprintf($ulng->txt(
'wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
713 $message .= $ulng->txt(
'wiki_change_notification_page_body_' . $a_action) .
":\n\n";
714 $message .= $ulng->txt(
'wiki') .
": " . $wiki->getTitle() .
"\n";
715 $message .= $ulng->txt(
'page') .
": " . $page->getTitle() .
"\n";
719 $message .=
"\n" . $ulng->txt(
'content') .
"\n" .
720 "----------------------------------------\n" .
722 "----------------------------------------\n";
727 $message .=
"\n" . $ulng->txt(
'comment') .
":\n\"" . trim($a_comment) .
"\"\n";
730 $message .=
"\n" . $ulng->txt(
'wiki_change_notification_page_link') .
": " . $link;
733 $message .= $ulng->txt(
'wiki_change_notification_body_' . $a_action) .
":\n\n";
734 $message .= $ulng->txt(
'wiki') .
": " . $wiki->getTitle() .
"\n";
735 $message .= $ulng->txt(
'page') .
": " . $page->getTitle() .
"\n";
739 $message .= $ulng->txt(
'content') .
"\n" .
740 "----------------------------------------\n" .
742 "----------------------------------------\n\n";
745 $message .= $ulng->txt(
'wiki_change_notification_link') .
": " . $link;
748 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
749 $mail_obj->appendInstallationSignature(
true);
static _lookupLogin($a_user_id)
lookup login
static _lookupFullname($a_user_id)
Lookup Full Name.
static makeLink(&$nt, $a_wiki_id, $text='', $query='', $trail='', $prefix='', $a_offline=false)
Make a wiki link, the following formats are supported:
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static updateNotificationTime($type, $id, array $user_ids, $page_id=false)
Update the last mail timestamp for given object and users.
static collectInternalLinks($s, $a_wiki_id, $a_collect_non_ex=false)
Collect internal wiki links of a string.
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
static processInternalLinks( $s, $a_wiki_id, $a_mode=IL_WIKI_MODE_REPLACE, $a_collect_non_ex=false, $a_offline=false)
Process internal links.
const IL_WIKI_MODE_COLLECT
static sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment=null)
catch(Exception $e) $message
static removeUnsafeCharacters($a_str)
See class.ilInitialisation.php.
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
This class handles base functions for mail handling.
const IL_WIKI_MODE_REPLACE
Wiki link / page title handling:
setRawPageContent($a_rawpagecontent)
Set Get raw page content only.
Class ilWikiPage GUI class.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static makeDbTitle($a_par)
Handle page GET parameter.
Create styles array
The data for the language used.
static _getLanguageOfUser($a_usr_id)
Get language object of user.
static truncateHTML($a_text, $a_length=100, $a_ending='...', $a_exact=false, $a_consider_html=true)
Truncate (html) string.
static _wikiPageExists($a_wiki_id, $a_title)
Check whether page exists for wiki or not.
static wfUrlProtocols()
From mediawiki GlobalFunctions.php.
const IL_WIKI_MODE_EXT_COLLECT
static wfUrlencode($s)
From GlobalFunctions.php.
static replaceInternalLinks($s, $a_wiki_id, $a_offline=false)
This one is based on Mediawiki Parser->replaceInternalLinks since we display images in another way...
static splitTrail($trail)
static getIdForPageTitle($a_wiki_id, $a_title)
Checks whether a page with given title exists.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")