« Plugin Manager Support Forum | Main | Reasons for Plugin Manager Plugin Configuration »

January 12, 2004

RFC: Plugin Manager Plugin Configuration

To all the plugin developers out there, I would like to get some feedback on what I am currently planning on implementing for the Plugin Manager with regards to plugin configuration options.

So, to start with, here is some sample code that might appear in remote post:

my $blog_id = 1;
my $author_id = 1;

eval "use MT::Plugins::Config;";
if (!defined $@) {
    require MT::Blog;
    require MT::Author;
    MT::Plugins::Config->add_variable ( Blog_ID => {
        plugin          => 'remote post',
        var             => \$blog_id,
        desc            => "Destination blog for all remote post pings",
        allowed_values  => { map { $_->name => $_->id } MT::Blog->load },
        use_hash_values => 1,
    });
    MT::Plugins::Config->add_variable ( Author_ID => {
        plugin          => 'remote post',
        var             => \$author_id,
        desc            => 'Author as whom to post remote post pings',
        allowed_values  => { map { $_->name => $_->id } MT::Author->load },
        use_hash_values => 1,
    });
}

Basically, the idea is that this plugin can operate with or without the Plugin Manager installed. If it is not, the user just changes the values in the initial declaration. Otherwise, the Plugin Manager can handle the validation and storing of the values.

So, let me go into a little more detail about all the hash keys I plan to include:

  • plugin: Plugin name
  • var: Reference to the variable that should hold the configured value (if you don't understand exactly what a Perl reference is, think of it like a pointer).
  • desc: Description of the variable
  • allowed_values: Hash containing possible values for the variable
  • use_hash_values: If set to a true value (i.e. 1), the Plugin Manager will display the hash keys to the user for choosing, but will store/assign the hash value of that key. Otherwise, it will only use the hash keys.
  • regexp: While allowed_values explicitly sets the possible values, regexp gives you a little more flexibility. Just set it to a regular expression that the value of the variable must match (e.g. '\d{1,3}' for a 1-3 digit number).

In the future, I would like to expand this to include dynamic lists of values. To use remote post as an example, I would use it to define a list of remote post id's that a site administrator could use to designate different author-blog-category combinations.

Any thoughts? Concerns?

Posted by rayners at January 12, 2004 09:31 PM

Trackback Pings

TrackBack URL for this entry:
http://mt.rayners.org/mt-tb.cgi/265

Comments

You might consider adding something that explains a bit more why this is of value to Plugin developers. How this fits into the Plugin manager as a whole and why a developer would want to add this extra code to their plugin.

Posted by: Adam Kalsey at January 13, 2004 10:15 PM

Seems complicated. Maybe we could just do something like defining specific variables?

$VERSION = "0.10; $AUTHOR = "Brandon";

Would that work?

Posted by: Brandon Fuller at January 20, 2004 11:34 PM

Seems complicated. Maybe we could just do something like defining specific variables?

$VERSION = "0.10; $AUTHOR = "Brandon";

Would that work?

Posted by: Brandon Fuller at January 20, 2004 11:35 PM

Would this also let me develop and work on a plugin that is not in the plugin database yet?

And actually, more to the point, has this at all been added? I would love to be able to move data away from the config file (which if not configured right, could easily be accessable to the world, so its a bit of a security risk) and this would be an awsome method (with fallback to the file if nothing else works.)

My only issue is here its very limited as to the kind of data that would work. I'd want to be able to have some way of selecting a blog id, and associating data with that. But still with the ability to have multiple blogs setup with thier own set of information (does that actually make any sense?)

Posted by: Gavin at February 4, 2004 07:50 PM

Hello.i'am from china!can i make friends with you?

Posted by: qqba at March 19, 2004 11:24 AM

i'am from china!can i make friends with you?

Posted by: 21fz at April 28, 2004 04:31 AM

Post a comment




Remember Me?

(you may use HTML tags for style)