MyBB Community Forums

Full Version: PluginLibrary 13
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
PluginLibrary is not a stand-alone plugin, but rather a library of useful functions that can be used by plugins and plugin developers. For example, it can help you manage settings of your plugin, or apply edits to core files. The list of PluginLibrary's features is expected to grow over time and contributions are welcome.

PluginLibrary is Open Source Software, licensed under the GNU Lesser General Public License, Version 3. This is the same license as MyBB itself uses, so if you can use MyBB, you should also be able to use PluginLibrary.

PluginLibrary is Copyright © 2011 Andreas Klauer ([email protected])

Function overview:
  • settings()
    This function creates a setting group and a list of settings. If the setting group already exists, the settings inside this group will be updated to their new names and descriptions, while keeping their custom values intact. Settings that no longer exist will be removed. Optionally, it also generates a language file for your settings.
  • settings_delete()
    This function deletes one (or more) setting groups and settings.
  • templates()
    Create a template group and list of templates. If the group already exists, the templates will be added/updated/removed depending on whether a template is new/changed/no longer in use. User edited versions of updated templates will show up in MyBB's "Find Updated Templates" feature.
  • templates_delete()
    Deletes one (or more) template groups and their templates.
  • stylesheet()
    This function creates/updates/activates a stylesheet in the MyBB Master Style. It will be inherited by all themes, enabling the user to edit and revert like the official stylesheets.
  • stylesheet_delete()
    Delete one or more stylesheets.
  • stylesheet_deactivate()
    Deactivate one or more stylesheet without losing user edits.
  • cache_read()
    This function reads an on-demand cache and returns its value (if present). Note that on-demand cache is allowed to vanish any time.
  • cache_update()
    This function creates or updates an on-demand cache with contents. Unlike MyBB's built-in $cache, it does not use the database nor does it load the cache automatically. Instead it uses a more specialized cache handler (by default: disk) directly, and you have to load the cache on demand using $PL->cache_read().
  • cache_delete()
    This function safely deletes one (or more) caches.
  • edit_core()
    This function makes, updates, and undoes simple, line based changes to PHP/JS/CSS files. Using search patterns, it locates blocks of one or more lines of code, and inserts new code before or after them, or replaces them.
  • is_member()
    This function checks if a user is member of one or more groups. Useful if your plugin has a setting to include/exclude one or more groups.
  • url_append()
    Append one or more query parameters to an URL that may or may not have an existing ?query. The parameters will be encoded properly.
  • xml_export()
    Export arbitrary data as XML. Useful for plugins where you want to share $some_data with others.
  • xml_import()
    Import previously exported data.

The full developer documentation and a sample plugin is included in the package.

Alternate Download:
Documentation: (also included in the package)
I'm glad you took my suggestion into consideration! Thanks for releasing by the way, I'll give it a try for my next plugin.
Looks useful if I was ever to try my hand at a larger plugin. It seems pretty pointless for small plugins though. Great job as ever!
Small plugins that do nothing but something minor in a single hook won't need it. It's already plenty useful if your plugin has any settings, though. And functionality is expected to grow over time. Depends on my future projects and other people's suggestions.
Well, I'd love it if there was a super easy way to do usergroup permissions. There is a way already, but an easy way would be quite useful really.
Today I learned that I have to enable all warnings in my PHP install. They weren't shown to me and that's why I missed this error until now:

Warning: Call-time pass-by-reference has been deprecated

I'll have to change how edit_core() provides debug info for failed edits, since passing $search as &$search apparently is no longer wanted / allowed by PHP...

Added $debug parameter to edit_core() in PluginLibrary 2.
Can a moderator please stick this? I think it's quite good for the developers to know about this library.
Wow I might get this just for the settings Big Grin, makes it much simpler! Nice!

Maybe a simple function to add a new link to the UserCP / AdminCP navigation bars and add a page for them. (I only ask because it's a b!tch and I can't seem to do it myself >.<)
The next version of PluginLibrary will include a XML Export/Import function that works with arbitrary data of types bool, int, float, string, array. Useful for plugins where you want to share $some_data with others...
cool, it will be great tool
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16