Extension talk:ProtectText

Fixes
It is probably waste of computing power to use memc as it is only called during editing, and then the cache will always be rebuilt. Jeblad 18:10, 28 May 2008 (UTC)

Problem
After "installing" this I can't access my wiki at all. Just get a blank page, html source code shows nothing. On version 1.13.3. I also have PHPBB/Users_Integration. / Erik 03:19, 21 December 2008 (UTC)

Extension Status?
This extension is listed as being in "Beta" version but there's no discussion in the past 8 years. Any reason not to change status to unsupported?

Updated version
HY I checked and modified the old not working version so i could use it with MediaWiki 1.25.5

The below is file inside ... extensions/ProtectABC/ProtectABC.php  * * This program is not free software therefore you can-not redistribute * it and/or modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * Please consult and/or request the administrator of QBox4u * to use the information and samples * To copy the data an written autorisation of the developer as stated in  *  the $wgExtensionCredits is required * *  You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * http://www.gnu.org/copyleft/gpl.html * * To activate this extension, add the following into your LocalSettings.php file: * require_once( "$IP/extensions/ProtectABCText/ProtectABCText.php"); * * @ingroup Extensions * @author Jan boer  * @version 1.0 * @link http://QBox4u.com * */ /****************** * Include all the required library's  * This line must be present before any global variable is referenced. */

if( !defined( 'MEDIAWIKI' ) ) { echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die( 1 ); }

$wgExtensionCredits['other'][] = array(   'path'           	=> __FILE__,	'name'				=> 'Protect ABC Text',	'version'			=> '1.0.1',	'author' 			=>  array( 'https://www.linkedin.com/in/jan-boer-a24640113','qbox4u@gmail.com', 'note:modified from the first base source of ThomasV and John Erling Blad'),	'description' 		=> 'Allow authorised users to protect parts of a Page text by the tag  ',	'license-name' 		=> 'Licence',	'url' 				=> 'http://www.mediawiki.org/wiki/Extension:ProtectText' );

// Keep i18n globals so mergeMessageFileList.php doesn't break $wgMessagesDirs['ProtectABC'] 	= __DIR__. '/i18n';

//$wgMessagesDirs['ProtectABC'] 	= __DIR__. '/i18n';

$wgmodifyProtect 				= false;

// One new permission $wgGroupPermissions['*']['protectABC']        		= false; $wgGroupPermissions['sysop']['protectABC']        	= true; $wgGroupPermissions['bureaucrat']['protectABC']   	= true; $wgAvailableRights[] 								= 'protectABC';

// Register hooks $wgHooks['ParserBeforeStrip'][] 				= 'wfStripProtectTags' ; $wgHooks['EditFilter'][] 						= 'wfCheckProtectText' ; $wgHooks['EditPage::showEditForm:initial'][] 	= 'wfCheckEditPreview' ;

/** * @param &$parser The parser object * @param &$text The text being parsed * @param &$x Something not used */ function wfStripProtectTags ( &$parser, &$text, &$x ) { $text = preg_replace(			array('/(.*?)<\/protectABC>/si', '/(\n;?:*;?)§(.*?)\n/si', '/(\n;?:*;?)§(.*?)$/si', '/\{§(.*?)§\}/si'),			array("$1", "$1$2\n", "$1$2", "$1"),			$text); return true; }

/** * @param $editPage * @param $output */ function wfCheckEditPreview( $editPage, $output ) { global $wgmodifyProtect; if ($wgmodifyProtect){ $errtext = ' '.wfMessage( 'protecttext_rejected' )->parse.' '; $editPage->editFormPageTop .= $errtext; }	return false; }

/** * @param $editor * @param $text * @param $section * @param &$error * @param $summary */

function wfCheckProtectText ( $editor, $text, $section, &$error, $summary ) {

global $wgUser, $wgTitle, $wgOut, $wgVersion, $wgmodifyProtect;

$wgmodifyProtect = false; # check if the user has no access rights if ( !$wgUser->isAllowed( 'protectABC' ) ) { # indeed, we will protect the text $wgmodifyProtect = true; $text1 = $editor->mArticle->getContent(true); $text2 = $text ; preg_match_all( "/ (.*?)<\/protect>|\n;?:*;?§(.*?)\n|\{§(.*?)§\}/si", $text1, $list1, PREG_SET_ORDER ); preg_match_all( "/ (.*?)<\/protect>|\n;?:*;?§(.*?)\n|\{§(.*?)§\}/si", $text2, $list2, PREG_SET_ORDER ); if( count($list1) < count($list2)) { $error = ' '.wfMessage( 'protecttext_add' )->parse.' '; } if( count($list1) > count($list2)) { $error = ' '.wfMessage( 'protecttext_remove' )->parse.' ';	} if( count($list1) == count($list2)) { $error = ' '.wfMessage( 'protecttext_modify' )->parse.' '; }

}		else { $wgmodifyProtect = false; $error = '';} return true;

}

?>

The below is file inside ... extensions/ProtectABC/i18n/en.json

{	"@metadata": { "authors": [ "Jan Boer", "QBox4u" ]	},	"protecttext_add": 			"You are not granted to add protection to a text fragment, or protect an existing text fragment", "protecttext_modify": 		"You are not granted to modify the ABC text enclosed by the tag:  ABC text  or try to remove the tags", "protecttext_remove": 		"You are not granted to remove the protection from a text fragment, or remove a protected text fragment", "protecttext_rejected": 	"All modifications will be therefore rejected. Please press cancel !!!!!!" }