diff --git a/main/wiki/index.php b/main/wiki/index.php index bb9cb14539..20937edf28 100644 --- a/main/wiki/index.php +++ b/main/wiki/index.php @@ -285,7 +285,10 @@ echo '
  • '; //menu delete all wiki -echo '
  • '; +if(api_is_allowed_to_edit() || api_is_platform_admin()) +{ + echo '
  • '; +} //menu more echo '
  • '; @@ -326,7 +329,10 @@ else echo '
  • '.$LinksPages.'
  • '; //menu delete wikipage -echo '
  • '.get_lang('Delete').'
  • '; +if(api_is_allowed_to_edit() || api_is_platform_admin()) +{ + echo '
  • '.get_lang('Delete').'
  • '; +} echo ''; /* @@ -1414,8 +1420,8 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference if($_POST['HistoryDifferences2']) { - $lines1 = array(stripslashes($version_old['content'])); //it may not be necessary stripslashes. TODO - $lines2 = array(stripslashes($version_new['content'])); //it may not be necessary stripslashes. TODO + $lines1 = array(strip_tags($version_old['content'])); //without <> tags + $lines2 = array(strip_tags($version_new['content'])); //without <> tags $diff = &new Text_Diff($lines1, $lines2); @@ -1988,8 +1994,8 @@ author Juan Carlos Raña Trabado **/ function detect_external_link($input) { - $exlink=''.get_lang('ShowPage').''; + $visibility_page= ''.get_lang('HidePageExtra').''.get_lang('Show').''; } } else { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $visibility_page= ''.get_lang('ShowPageExtra').''.get_lang('HidePage').''; + $visibility_page= ''.get_lang('ShowPageExtra').''.get_lang('Hide').''; } } @@ -2528,7 +2534,7 @@ function display_wiki_entry() if (wiki_exist($title)) { - echo $icon_assignment.'   '.stripslashes($title).'
    '.$protect_addnewpage.'
    '.'   '.$protect_page.''.'   '.$visibility_page.''.'   '.$notify_page.''.'   '.get_lang('Progress').': '.stripslashes($row['progress']).'%   '.get_lang('Rating').': '.stripslashes($row['score']); + echo $icon_assignment.'   '.stripslashes($title).'
    '.$protect_addnewpage.'
    '.'   '.$protect_page.''.'   '.$visibility_page.''.'   '.$notify_page.''.'   '.get_lang('Progress').': '.stripslashes($row['progress']).'%   '.get_lang('Rating').': '.stripslashes($row['score']).'   '.get_lang('Words').': '.word_count($content); } else { @@ -2594,6 +2600,43 @@ if ($_POST['export2DOC']) export2doc($titleDOC,$contentDOC,$groupIdDOC); } +/** +* This function counted the words in a document. Thanks Adeel Khan +*/ + +function word_count($document) { + + $search = array( + '@]*?>.*?@si', + '@]*?>.*?@siU', + '@@' + ); + + $document = preg_replace($search, '', $document); + + # strip all html tags + $wc = strip_tags($document); + + # remove 'words' that don't consist of alphanumerical characters or punctuation + $pattern = "#[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-|:|\&|@)]+#"; + $wc = trim(preg_replace($pattern, " ", $wc)); + + # remove one-letter 'words' that consist only of punctuation + $wc = trim(preg_replace("#\s*[(\'|\"|\.|\!|\?|;|,|\\|\/|\-|:|\&|@)]\s*#", " ", $wc)); + + # remove superfluous whitespace + $wc = preg_replace("/\s\s+/", " ", $wc); + + # split string into an array of words + $wc = explode(" ", $wc); + + # remove empty elements + $wc = array_filter($wc); + + # return the number of words + return count($wc); + +} /** * This function checks if wiki title exist