18 define (
"IL_WIKI_MODE_REPLACE",
"replace");
19 define (
"IL_WIKI_MODE_COLLECT",
"collect");
20 define (
"IL_WIKI_MODE_EXT_COLLECT",
"ext_collect");
73 $wgLegalTitleChars =
" %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
76 include_once(
"./Modules/Wiki/classes/class.ilMediaWikiAdapter.php");
78 $GLOBALS[
"wgInterWikiCache"] =
false;
80 # the % is needed to support urlencoded titles as well 82 $tc = $wgLegalTitleChars.
'#%';
86 #split the entire text string on occurences of [[ 87 $a = explode(
'[[',
' ' . $s );
88 #get the first element (all text up to first [[), and remove the space we added 89 $s = array_shift( $a );
92 # Match a link having the form [[namespace:link|alternate]]trail 93 $e1 =
"/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
95 # Match cases where there is no "]]", which might still be images 99 # Match the end of a line for a word that's not followed by whitespace, 100 # e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched 129 $useSubpages =
false;
132 for ($k = 0; isset( $a[$k] ); $k++)
152 $might_be_img =
false;
155 if ( preg_match( $e1, $line, $m ) ) { # page with normal text
or alt
157 # If we get a ] at the beginning of $m[3] that means we have a link that's something like: 158 # [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up, 159 # the real problem is with the $e1 regex 162 # Still some problems for cases where the ] is meant to be outside punctuation, 163 # and no image is in sight. See bug 2095. 166 substr( $m[3], 0, 1 ) ===
']' &&
167 strpos($text,
'[') !== false
170 $text .=
']'; # so
that replaceExternalLinks($text) works later
171 $m[3] = substr( $m[3], 1 );
173 # fix up urlencoded title texts 174 if( strpos( $m[1],
'%' ) !==
false ) {
175 # Should anchors '#' also be rejected? 176 $m[1] = str_replace(
array(
'<',
'>'),
array(
'<',
'>'), urldecode($m[1]) );
186 }
else { # Invalid form; output directly
187 $s .= $prefix .
'[[' . $line ;
194 # Don't allow internal links to pages containing 195 # PROTO: where PROTO is a valid URL protocol; these 196 # should be external links. 198 $s .= $prefix .
'[[' . $line ;
202 # Make subpage if necessary 209 $noforce = (substr($m[1], 0, 1) !=
':');
211 # Strip off leading ':' 212 $link = substr($link, 1);
219 include_once(
"./Modules/Wiki/mediawiki/Title.php");
220 include_once(
"./Services/Utilities/classes/Sanitizer.php");
228 $s .= $prefix .
'[[' . $line;
280 $wasblank = (
'' ==
$text );
281 if( $wasblank )
$text = $link;
283 # Link not escaped by : , create the various objects 352 # Special and Media are pseudo-namespaces; no pages actually exist in them 388 $collect[] =
array(
"nt" => $nt,
"text" =>
$text,
389 "trail" => $trail,
"db_title" => $db_title,
390 "url_title" => $url_title);
399 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
403 !in_array($db_title, $collect))
405 $collect[] = $db_title;
428 return str_replace(
array(
"\x00",
"\n",
"\r",
"\\",
"'",
'"',
"\x1a"),
"", $a_str);
446 if ( ! is_object($nt) ) {
448 $retVal =
"<!-- ERROR -->{$prefix}{$text}{$trail}";
456 if ($nt->mFragment !=
"")
458 if (substr(
$text, strlen(
$text) - strlen(
"#".$nt->mFragment))
459 ==
"#".$nt->mFragment)
462 $anc =
"#".$nt->mFragment;
466 $anc =
"#".$nt->mFragment;
470 # Separate the link trail from the rest of the link 474 $retVal =
'***'.$text.
"***".$trail;
490 $wiki_link_class = (!$pg_exists)
491 ?
' class="ilc_link_IntLink ilWikiPageMissing" ' 492 :
' class="ilc_link_IntLink" ';
496 if ($url_title !=
"")
498 $ilCtrl->setParameterByClass(
"ilobjwikigui",
"page", $url_title);
499 $retVal =
'<a '.$wiki_link_class.
' href="'.
500 $ilCtrl->getLinkTargetByClass(
"ilobjwikigui",
"gotoPage").$anc.
501 '">'.$text.
'</a>'.$trail;
502 $ilCtrl->setParameterByClass(
"ilobjwikigui",
"page",
$_GET[
"page"]);
506 $retVal =
'<a '.$wiki_link_class.
' href="'.
508 '">'.$text.
'</a>'.$trail;
518 $retVal =
'<a '.$wiki_link_class.
' href="'.
519 "wpg_".$pg_id.
".html".$anc.
520 '">'.$text.
'</a>'.$trail;
524 $retVal =
'<a '.$wiki_link_class.
' href="'.
526 '">'.$text.
'</a>'.$trail;
531 $retVal =
$text.$trail;
561 $wgUrlProtocols =
array(
576 if ( is_array( $wgUrlProtocols ) ) {
577 $protocols =
array();
578 foreach ($wgUrlProtocols as $protocol)
579 $protocols[] = preg_quote( $protocol,
'/' );
581 return implode(
'|', $protocols );
583 return $wgUrlProtocols;
592 $s = urlencode( $s );
606 return str_replace(
"_",
" ", $a_par);
615 $a_par = str_replace(
" ",
"_", $a_par);
627 $regex =
'/^([a-z]+)(.*)$/sD';
630 if (
'' != $trail ) {
633 if ( preg_match( $regex, $trail, $m ) ) {
639 return array( $inside, $trail );
644 global
$ilUser, $ilObjDataCache, $ilAccess;
646 include_once
"./Services/Notification/classes/class.ilNotification.php";
647 include_once
"./Modules/Wiki/classes/class.ilObjWiki.php";
648 include_once
"./Modules/Wiki/classes/class.ilWikiPage.php";
650 $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
651 $wiki =
new ilObjWiki($a_wiki_ref_id,
true);
655 $ignore_threshold = ($a_action ==
"comment");
658 if($a_action ==
"new")
667 $users = array_merge($users, $wiki_users);
687 include_once
"./Services/Link/classes/class.ilLink.php";
691 $link =
ilLink::_getLink(
"",
"wiki", null,
"wpage_".$a_page_id.
"_".$a_wiki_ref_id);
699 include_once
"./Services/Mail/classes/class.ilMail.php";
700 include_once
"./Services/User/classes/class.ilObjUser.php";
701 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
702 include_once(
"./Services/User/classes/class.ilUserUtil.php");
708 include_once
"Modules/Wiki/classes/class.ilWikiPageGUI.php";
711 $pgui->setAbstractOnly(
true);
712 $pgui->setFileDownloadLink(
".");
713 $pgui->setFullscreenLink(
".");
714 $pgui->setSourcecodeDownloadScript(
".");
715 $snippet = $pgui->showPage();
719 $snippet = str_replace(
'<br/>',
"\n", $snippet);
720 $snippet = str_replace(
'<br />',
"\n", $snippet);
721 $snippet = str_replace(
'</p>',
"\n", $snippet);
722 $snippet = str_replace(
'</div>',
"\n", $snippet);
724 $snippet = trim(strip_tags($snippet));
727 $current_version = array_shift($page->getHistoryEntries());
728 $current_version = $current_version[
"nr"];
729 if(!$current_version)
736 foreach(array_unique($users) as $idx => $user_id)
738 if($user_id != $ilUser->getId() &&
739 $ilAccess->checkAccessOfUser($user_id,
'read',
'', $a_wiki_ref_id))
743 $ulng->loadLanguageModule(
'wiki');
745 $subject = sprintf($ulng->txt(
'wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
751 $message .= $ulng->txt(
'wiki_change_notification_page_body_'.$a_action).
":\n\n";
752 $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
753 $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n";
758 $message .=
"\n".$ulng->txt(
'content').
"\n".
759 "----------------------------------------\n".
761 "----------------------------------------\n";
767 $message .=
"\n".$ulng->txt(
'comment').
":\n\"".trim($a_comment).
"\"\n";
770 $message .=
"\n".$ulng->txt(
'wiki_change_notification_page_link').
": ".$link;
775 $message .= $ulng->txt(
'wiki_change_notification_body_'.$a_action).
":\n\n";
776 $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
777 $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n";
782 $message .= $ulng->txt(
'content').
"\n".
783 "----------------------------------------\n".
785 "----------------------------------------\n\n";
788 $message .= $ulng->txt(
'wiki_change_notification_link').
": ".$link;
791 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
792 $mail_obj->appendInstallationSignature(
true);
794 "",
"", $subject, $message,
array(),
array(
"system"));
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 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.
const IL_WIKI_MODE_COLLECT
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)
Default behaviour is:
static sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment=null)
static wfUrlencode( $s)
From GlobalFunctions.php.
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 processInternalLinks($s, $a_wiki_id, $a_mode=IL_WIKI_MODE_REPLACE, $a_collect_non_ex=false, $a_offline=false)
Process internal links.
static makeDbTitle($a_par)
Handle page GET parameter.
Create styles array
The data for the language used.
static splitTrail( $trail)
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 replaceInternalLinks($s, $a_wiki_id, $a_offline=false)
This one is based on Mediawiki Parser->replaceInternalLinks since we display images in another way...
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="")
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.