Hacks: Acronym - new XoopsCode

Posted by: ZirafkaOn 2010/6/24 12:00:00 6239 reads
Do you want to have new XoopsCode? My Little hack add new XoopsCode like HTML < acronym > tag. Add new functionality is easy

First we need to create a directory in CLASS/TEXTSANITIZER new folder and call it "acr". In it are two files:

The first is "index.html" which serves as a basic protection against such intrusions. You can find it in virtually all other directories and it is sufficient merely to copy the new directory.

The second is called "acr.php" and have this content:

<?php
/*
 You may not change or alter any portion of this comment or credits
 of supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit authors.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
 * TextSanitizer extension
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         class
 * @subpackage      textsanitizer
 * @since           2.3.0
 * @author          Wishcraft <simon@xoops.org>
 * @version         $Id: li.php 3575 2009-09-05 19:35:11Z trabis $
 */
defined('XOOPS_ROOT_PATH') or die('Restricted access');

class 
MytsAcr extends MyTextSanitizerExtension
{
    function 
load(&$ts)
    {

        
$ts->patterns[] = "/[acr](.*)[/acr]/sU";
        
$ts->replacements[] = '<acronym title="Unknown acronym">\1</acronym>';
    
        
$ts->patterns[] = "/[acr=(.*)](.*)[/acr]/sU";
        
$ts->replacements[] = '<acronym title="\1">\2</acronym>';
        return 
true;
    }
}

?>


In it, he set his own recognition of the new Xoopscode and its treatment, or switch to HTML tags. You may notice that contains two options:

[acr]Xoops[/acr]


This code creates the text, which completes the acronym, but is not assigned any meaning, because it also writes the label.

[acr=eXtensible Object Oriented Portal System]Xoops[/acr]


This code creates a shortcut again in the sense of HTML, but given the importance of this symbol and therefore it forward.

Everything worked so well, you need to edit another file, and that is the file "config.php" which is located in the directory CLASS/TEXTSANITIZER.

You need to find this part:

return $config = array(
    
"extensions" => array(
        
"iframe" => 0,
        
"image" => 1,
        
"flash" => 1,
        
"youtube" => 1,
        
"mp3" => 0,
        
"wmp" => 0,
        
// If other module is used, please modify the following detection and 'link' in /wiki/config.php
        
"wiki" => is_dir(XOOPS_ROOT_PATH '/modules/mediawiki/'),
        
"mms" => 0,
        
"rtsp" => 0,
        
"ul" => 1,
        
"li" => 1),


and add only one line:

return $config = array(
    
"extensions" => array(
        
"iframe" => 0,
        
"image" => 1,
        
"flash" => 1,
        
"youtube" => 1,
        
"mp3" => 0,
        
"wmp" => 0,
        
// If other module is used, please modify the following detection and 'link' in /wiki/config.php
        
"wiki" => is_dir(XOOPS_ROOT_PATH '/modules/mediawiki/'),
        
"mms" => 0,
        
"rtsp" => 0,
        
"ul" => 1,
        
"li" => 1,
        
"acr" => 1),


That´s all, happy Xoopsing

Demo: see my web page: www.zirafoviny.cz