Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2005-03-10 00:13:34

dhscompguy
Xinha Community Member
Registered: 2005-03-10
Posts: 23

How to write a simple plugin?

Let's say I have a database full of articles and I want to be able to do the following within Xinha --

1) run a search on the database
2) select a radio button next to any given result
3) click an "embed" button, which will insert something like EMBED:12 in the document being edited.

Is this a plugin or a popup? What's the difference? Will it be very difficult to implement?

Thanks,
Denny


Learn how to astral project: [url]http://gnosticweb.org[/url]

Offline

#2 2005-03-10 02:15:14

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: How to write a simple plugin?

If you don't know javascript it will be difficult.  A popup is a popup window, a plugin is some javascript code to do something that Xinha doesn't do by default smile

I'd suggest using the XMLHTTPRequest object to do the communication between client and server, and writing a plugin that exposes a panel on the left/right of the editor to form the interface.  See the existing plugins to learn how to do it.


James Sleeman

Offline

#3 2005-03-10 15:55:39

dhscompguy
Xinha Community Member
Registered: 2005-03-10
Posts: 23

Re: How to write a simple plugin?

Thanks, James.

I've been looking through the source of the Linker plugin today.

I have a question --

    if($hash)
    {
      session_start();
      if(!isset($_SESSION[sha1($hash)]))
      {
        ?>
        [ ];
        <?php
        exit;
      }
    }

It looks like you're checking for the session variable here and sending an empty array to javascript if it's not found. However, I can't seem to find where the variable is being set. Would you be so kind as to clue me in?

Thanks,
Denny

Last edited by dhscompguy (2005-03-10 15:57:29)


Learn how to astral project: [url]http://gnosticweb.org[/url]

Offline

#4 2005-03-11 00:36:24

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: How to write a simple plugin?

It's not, not in the plugin anyway.  That's only used if you are going to set the backend config value to include a (base) dir parameter, so that any old joe bloggs can't just call the Linker backend with whatever directory they want.  Example usage...

<?php
  $dir = realpath($_SERVER['BASE_DIR'] . '/some_directory') . '/';
  $_SESSION[sha1('dir=' . $dir)] = TRUE;
?>
<script language="Javascript">
myEditor.config.Linker.backend = _editor_url + 'plugins/Linker/scan.php?dir=<?php echo urlencode($dir) ?>';
</script>

James Sleeman

Offline

Board footer

Powered by FluxBB