1
Peekay
Blue Move Tip - Search and Replace
  • 2010/8/7 16:48

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


If you are updating an old module, using a multi-pass search and replace editor can speed up code conversion. You can buy some shareware solutions, but the Windows utility wReplace is free!.

http://www.sharktime.com/us_wReplace.html

wReplace only works on one file at a time, but you can create a 'batch' search and replace set and apply it to each file.

For example:

Search For            Replace with:

$HTTP_GET_VARS              $_GET    
$HTTP_POST_VARS              $_POST    
makeTareaData4Preview          previewTarea    
makeTareaData4Show          displayTarea    
makeTboxData4Show          htmlSpecialChars    
makeTboxData4Edit          htmlSpecialChars    
makeTareaData4Edit          htmlSpecialChars    
makeTareaData4InsideQuotes      htmlSpecialChars    
makeTboxData4Save          addSlashes    
makeTareaData4Save          addSlashes


The only problem is you must NOT save a converted PHP file to disc. Instead, copy and paste the converted text into a plain text editor like ConText and then save it.

The reason for this is that wReplace saves files in Unicode format and that seems to mess up PHP badly, even though it looks alright in the application.

Having to cut and paste is a bit of a nuisance, but other than that I found it works really well and certainly saves some time.

A thread is for life. Not just for Christmas.

2
trabis
Re: Blue Move Tip - Search and Replace
  • 2010/8/7 18:30

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You could use
http://www.inforapid.de/html/searchreplace.htm

It is better and also free.

3
Peekay
Re: Blue Move Tip - Search and Replace
  • 2010/8/7 22:07

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Thx Trabis!

If you download this, take a look at the help page about 'batch files' which explains how to achieve multiple string replacements in one go.
A thread is for life. Not just for Christmas.

4
ghia
Re: Blue Move Tip - Search and Replace
  • 2010/8/8 1:36

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


You can search and replace in all files of a directory (and its sub) very easy with OpenSource editor Notepad++.

5
Mamba
Re: Blue Move Tip - Search and Replace
  • 2010/8/8 3:16

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


You could also use a tool that I've written a long time ago for JEDI Project: JVCL-Convert

With it you can:

- define which file extensions you want to target (e.g. only *.php)
- scan directories/subdirectories for files to convert
- you can also drag files for conversion
- you can load/save your conversion strings
- you can also have a "dry-run" to see which files will be affected
- you can create a backup for each file changed
- you can also replace strings in the file names

And it's actually pretty fast

Note: I am not sure how it will work on UTF files, as it was developed for standard Delphi source code files back in 2003, but since all our old modules are non-UTF files, it should be no problem there.



Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

6
Peekay
Re: Blue Move Tip - Search and Replace
  • 2010/9/10 21:22

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


One of the things I do before running a module on a live site is to check that there are no 'http' links buried in the code that the developer may have used in testing but forgot to remove.

InfoRapid is excellent for this, but if you search for 'http://' it will also find the links to xoops.org in the GPL copyright notices.

To exclude this address from the search, you can use the expression:

Search for: http://www.&!xoops.org
In Files: *.*


InfoRapid will even find links hidden in .GIF files, like the one embedded in the animated 'arrow' icon common in many older modules. It's just a backlink to the GIF creator software company, but it is hidden none the less.

If you want to get rid of it you'll need a HEX editor.

HXD seems pretty easy to use. Open the file, select the offending code in the right hand panel, choose 'Edit/Fill Selection' and press 'OK' in the next screen to overwrite the selected text with '00's.

HxD automatically creates a backup of the original file, just in case you mess it up.
A thread is for life. Not just for Christmas.

7
Balzac
Re: Blue Move Tip - Search and Replace
  • 2010/9/13 7:12

  • Balzac

  • Just popping in

  • Posts: 68

  • Since: 2010/1/11


And what about
Quote:
Warning: Class 'XoopsTree' is deprecated, check 'XoopsObjectTree' in tree.php in file /class/xoopstree.php line 49


Old modules use xoopsTree.
Should this be replaced too? If yes, how?

8
trabis
Re: Blue Move Tip - Search and Replace
  • 2010/9/13 13:01

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

Balzac wrote:
And what about
Quote:
Warning: Class 'XoopsTree' is deprecated, check 'XoopsObjectTree' in tree.php in file /class/xoopstree.php line 49


Old modules use xoopsTree.
Should this be replaced too? If yes, how?


XoopsObjectTree requires modules to use XoopsObject and some old modules do not have them.

The easier way is to copy the class into the module folder, rename the class, remove the deprecated message from the class constructor and change module references to use the new class.

The hard and best way is to create object classes for those modules and use XoopsObjectTree.

News module->already has object classes
wf-links, mytube->does not have object classes

9
zyspec
Re: Blue Move Tip - Search and Replace
  • 2010/9/13 13:23

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Yes, It should be replaced. Unfortunately there's not an 'easy' fix or one answer for all situations. The new XoopsObjectTree is dealing with class objects, not an 'array' from the database like XoopsTree did.

The difficulty in replacing XoopsObject with XoopsObjectTree will depend on whether the objects to be used are already in existance (for example the module uses classes/objects) or if they'll need to be created.

The replacement is further complicated by the fact that some of the XoopsTree methods are no longer available in XoopsObjectTree so alternate ways of creating the same result will have to be created.

Login

Who's Online

172 user(s) are online (114 user(s) are browsing Support Forums)


Members: 0


Guests: 172


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits