Plugin dev Q's: requirements, new hook_event

Creating and modifying plugins.
Post Reply
prim8
Regular
Posts: 20
Joined: Wed Jun 08, 2005 12:48 am
Contact:

Plugin dev Q's: requirements, new hook_event

Post by prim8 » Tue Jun 21, 2005 6:27 pm

Greetings,

I am working on a spellchecker plugin, but need to resolve a couple issues before it will be ready for release.

1. Is there any way to do more advanced PHP requirements. PSPELL is required for the spell checker functions. My only idea at this point is to put a test on the spellcheck configuration screen that will tell you if you don't meet the reqs.

2. I need to add some javascript events to the textareas on the backend_entry screen. Would this be a reasonable way of going about it?

functions_entries.inc.php

Code: Select all

From:
<textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20"><?php echo isset($entry['body']) ? htmlspecialchars($entry['body']) : ''; ?></textarea>

To:
<?php
$textareaBody = '<textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20">'.
    (isset($entry['body']) ? htmlspecialchars($entry['body']) : '').'</textarea>';

serendipity_plugin_api::hook_event('backend_entry_textarea_body', $textareaBody);
echo $textareaBody;
?>


3. Unrelated, but I notice that I have a lot of records in my suppress table that never made it into my referrers table. [edit: Nevermind, I found mention of the way s9y suppresses referrer spam by requiring 2 hits to count.]

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Plugin dev Q's: requirements, new hook_event

Post by garvinhicking » Wed Jun 22, 2005 10:23 am

Hi!

For the first issue, I think checking for requirements in the install() method of a plugin should be quite well. A warning could also be emitted in the description of a plugin, conditional on whether pspell is activated?

2. Can't you use the simple backend_entryform or backend_entry_toolbar_body hook to emit javascript that toggles the textarea and modifies it via DOM functionalities?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

prim8
Regular
Posts: 20
Joined: Wed Jun 08, 2005 12:48 am
Contact:

Re: Plugin dev Q's: requirements, new hook_event

Post by prim8 » Wed Jun 22, 2005 11:01 pm

garvinhicking wrote:2. Can't you use the simple backend_entryform or backend_entry_toolbar_body hook to emit javascript that toggles the textarea and modifies it via DOM functionalities?


Yes, good point. Actually those 2 hooks run too early (before the textareas are loaded into DOM), but backend_display works great. If anyone is interested, here is the code I used:

Code: Select all

case 'backend_display':
                ?>
                            <script lang="javascript">
                                function textBody() {
                                    doSomeJabbascript();                                                             
                                }                               
                                var text = document.getElementById('serendipity[body]');                                                 
                                text.onfocus= textBody;                                                           
                                var text2 = document.getElementById('serendipity[extended]');                     
                                text2.onfocus = textBody;                                                         
                            </script>                                                                             
                <?                                                                                               
                    return true;                                                                                 
                    break; 

Post Reply