Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Aiheen aloitti: tL0z - kesäkuu 25, 2007, 07:19:12 AP

Otsikko: Find and replace
Kirjoitti: tL0z - kesäkuu 25, 2007, 07:19:12 AP
Hello,

Can anyone please make a mod which would search for a specific word in all messages and replace it with another one?

It would be very useful when changing usernames (to change the author field in the quote tag) and to replace smiley bbcode.

Thanks
Otsikko: Re: Find and replace
Kirjoitti: tL0z - kesäkuu 27, 2007, 05:57:52 IP
Nobody willing to help me? :(
Otsikko: Re: Find and replace
Kirjoitti: tL0z - kesäkuu 30, 2007, 01:27:27 IP
up!
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 03, 2007, 06:07:42 AP
Up
Otsikko: Re: Find and replace
Kirjoitti: Rudolf - heinäkuu 03, 2007, 01:48:06 IP
I started working on it, should be ready by the weekend.
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 03, 2007, 02:45:13 IP
Thanks man! ;)

By the way, how can I learn how to integrate my code in the SMF system/admin panel?
I would like to be able to write some modifications. :)
Otsikko: Re: Find and replace
Kirjoitti: Rudolf - heinäkuu 03, 2007, 02:58:02 IP
Well, I can show you what I was doing now for this mod:

To add a link in the admin menu open up the Subs.php and search the adminindex() function.
This will add the link below the "Error log" link.
Koodi (Search for) [Valitse]
'view_errors' => '<a href="' . $scripturl . '?action=viewErrorLog;desc">' . $txt['errlog1'] . '</a>',
Koodi (Add after) [Valitse]
'find_replace' => '<a href="' . $scripturl . '?action=findreplace">' . $txt['find_replace'] . '</a>', //- Find & Replace MOD-

Define the action, in index.php:
add int he actions array
'findreplace' => array('FindAndReplace.php', 'Main'), //- Find & Replace MOD-

Write the action: Create a file called FindAndReplace.php in the Source directory and define the Main() function inside

Koodi (Example file) [Valitse]

<?php

if (!defined('SMF'))
die('Hacking attempt...');

function 
Main()
{
//Everything in here is admin ONLY. No exceptions.
isAllowedTo('admin_forum');

$subActions = array(
'all' => array('ViewReplacelist'),
);

// Default to sub action 'index' or 'settings' depending on permissions.
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'all';

$subActions[$_REQUEST['sa']][0]();

}

function 
ViewReplaceList()
{
global $txt$scripturl$db_prefix$context$modSettings$sourcedir;

adminindex('find_replace'); //this will load up the admin menu with the replace link highlighted as active
loadTemplate('FindAndReplace'); //this loads up a template to work with

        /**
        * do stuff here
        */
}

?>



This is the basic idea behind adding an admin area. Look at how the ManageMembers.(template).php, and other Manage... files are written to learn more.
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 03, 2007, 03:12:16 IP
The file you are writing (FindAndReplace.php) will be included by another one which is the main template of the admin panel, right?

For example, the function isAllowedTo is in one of the sources file which is included in the main admin template, am I correct?

How is made the automatic installation? With a xml file?

I will see if I learn the SMF structure when I finish a project I am currently working on.
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 10, 2007, 05:17:18 AP
How is it going? :)
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 22, 2007, 06:00:44 AP
Well, anybody else would like to do this mod? Why is it so difficult to get support here?
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 24, 2007, 08:35:45 AP
up
Otsikko: Re: Find and replace
Kirjoitti: Rudolf - heinäkuu 24, 2007, 08:37:57 AP
Sorry, I had some troubles with my computer last weeks. Yesterday I reinstalled my system and I think I will be able to finish it this week.
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 24, 2007, 08:44:11 AP
Ok, sorry for my lack of patience, but I've been asking for this for a long time. :)
Otsikko: Re: Find and replace
Kirjoitti: Rudolf - heinäkuu 31, 2007, 12:23:02 AP
Finally I made it to an initial release. It is in Beta, which means that you should thread carefully.
If you have the time and means to do some testing it would be awsome.
PLease see the topic [BETA] Find and Replace MOD (http://www.simplemachines.org/community/index.php?topic=185762.msg1182242#msg1182242) and report any issues or feedback in there?

Thanks,
Rudolf
Otsikko: Re: Find and replace
Kirjoitti: tL0z - heinäkuu 31, 2007, 05:12:05 AP
Thanks. I will try to do some tests today, on the forum I have installed on my PC. ;)
Otsikko: Re: Find and replace
Kirjoitti: perro88 - heinäkuu 31, 2007, 05:38:32 AP
nice mod. thanks to you both