bradcathey has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monasterians,

I have a simple content manager that uses the expected Perl/MySQL/HTML::Template in relative harmony. However, rolling my own wysiwyg editor has proven monumental, so I've decided to use WysiwygPro editor.

It's a powerful editor, but requires a php file to fire it up. Not a problem, until it comes to passing the content-to-edit from my Perl/MySQL routines to the .php. Three possibilities come to mind:

1) Learn PHP and handle the MySQL from within the .php, bypassing Perl altogether. Update: drats, security issues trying to avoid hardcoding the DBI log-on info.

2) From within Perl, fetch and print the content to a temporary text file on the server, and then use php within the .php file to retrieve and assign it accordingly. Seems goofy.

3) Print my .php as a heredoc, populating it from within my Perl script. Update: Can't seem to get this to work. Maybe it's not possible to print a .php file to screen.

The 1st and 3rd options seem best, the first being the cleanest, learning enough PHP to do the work, notwithstanding.

Of course, it would be great to have something like PHP::Template (maybe there is something like it), but in the meantime, what's the monastery's take on this? Thanks


—Brad
"Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton

Replies are listed 'Best First'.
Re: Starting a PHP file from Perl
by b10m (Vicar) on Nov 13, 2004 at 21:22 UTC

      Thanks, I'm aware of both, but being on a Mac, I need the editor to run on OS X. Think I'll need to find a way to make the PHP work.


      —Brad
      "Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton
Re: Starting a PHP file from Perl
by TedPride (Priest) on Nov 13, 2004 at 20:04 UTC
    PHP is simple to learn and use, and given that you've chosen a PHP editor, I'd personally go with option 1 here. See the following, with emphasis on Language Reference and mySQL functions:

    http://www.php.net/manual/en/

    (yes, I like Perl, but that doesn't mean I use it 100% of the time)

Re: Starting a PHP file from Perl
by Jaap (Curate) on Nov 14, 2004 at 10:29 UTC
    I'd use option 4:

    4) Find out what the PHP is doing and do it in Perl.

    The bulk of the magic of WysiwygPro editor is client-side DHTML stuff. It only uses some server-side stuff to handle image uploads, the html upload itself and some other stuff.

    Just start out by copy pasting the source of http://www.wysiwygpro.com/demos/demo1.php into a html page and then get it to work step-by-step.

      Great suggestion Jaap, but this is new ground for me. It looks like the initial .php file I'm trying to start up does does a OO call to fire up the editor:

      $editor = new wysiwygPro(); //send parameters $editor->set_code($content); //print it to the browser $editor->print_editor(720, 500);

      The editor class is in another .php file:

      class wysiwygPro { var $classname = "wysiwygPro"; //etc.

      I might be able to successfully call the editor, but I'm unclear how to integrate it with my Perl and the need to ultimately see it in the browser as HTML.

      But it's a path worth pursuing. If I can make it work, I'll do an update. Thanks.


      —Brad
      "Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton