Plugins

A plugin responds to events that occur in the system (all available events are listed below). This means that you can extend the standard funtionality.
A plugin is created in code as a .cs or .vb class. The class file can recide in your project or be referenced as a separate assembly.

 

Example of a plugin class

using Mindroute.Core.Plugins;
using Mindroute.Core.Model;

namespace MyProject.Lemoon.Plugins {
    [Serializable]
    [Description("A test plugin")]
    public class MyPlugin : Plugin {
        public void OnContentInsert(Content inserted) {
            inserted.Title = inserted.Title + " (!)";
        }
    }
}

 

Creating plugins

Start off by creating a new class. Add references to Mindroute.Core.Plugins and Mindroute.Core.Model namespaces. A plugin must be serializable, so make sure you add the attribute [Serializable] to the class. The [Description] attribute is used inside lemoon 4 editorial interface as a descriptional text. The class must inherit from the Plugins class.

The next step is to decide which events you want to implement. The hook enumeration is available in the Mindroute.Core.Plugins namespace. For each hook, the correct signature that should be used is displayed. If you for example would like to do something before a content item is created in lemoon, you should hook on to OnContentInsert. If you would like to do something after a content item is created, you should hook on to OnContentInserted. You will notice that all hooks have signatures for both before and after an event occurs.

When the plugin has been created and you have compiled your project, you must enable it. You enable your plugins in the editorial interface. Log on to the lemoon editorial interface and go to Manage -> Plugins. All available plugins (including those installed with lemoon 4) are displayed in the list. Click on the plugin you would like to enable, check the Enabled box and then save. The plugin is now enabled.

Properties in plugins

Properties are created in code and the only thing you have to think of is to add the [Persisted] attribute to make it available for the plugin. See an example below.

using Mindroute.Core.Plugins;
using Mindroute.Core.Model;

namespace Lemoon.PluginTest {
    [Serializable]
    [Author("Mindroute Software")]
    [Description("My plugin test!")]
    public class MyPlugin : Plugin {

        [Persisted]
        public string Suffix { get; set; }

        public void OnContentInsert(Content inserted) {
            inserted.Title = inserted.Title + Suffix;
        }
    }
}

The properties you create in a plugin are available in the editorial interface for editing.

 

Available events

Event nameDescription and method signature
OnBlobInserted Occurs after after a Mindroute.Core.Model.Documentwas updated with Blob ID and Size.

void OnBlobInserted(Document inserted)
OnCacheCleared Occurs after the cache was cleared.

void OnCacheCleared()
OnCacheRegionCleared Occurs after a cache region was cleared.

void OnCacheCleared(CacheRegion region)
OnContentInsert Occurs before a Mindroute.Core.Model.Content item is inserted.

void OnContentInsert(Content inserted)
OnContentInserted

Occurs after a Mindroute.Core.Model.Content item was inserted.

void OnContentInserted(Content inserted)
OnContentUpdate

Occurs before updating a Mindroute.Core.Model.Content item.

void OnContentUpdate(Content original, Content updated)
OnContentUpdated

Occurs after a Mindroute.Core.Model.Content item was updated.

void OnContentUpdated(Content original, Content updated)
OnContentDelete

Occurs before deleting a Mindroute.Core.Model.Content item.

void OnContentDelete(Content deleted)
OnContentDeleted

Occurs after a Mindroute.Core.Model.Content item was deleted.

void OnContentDeleted(Content deleted)
OnContentRestore

Occurs before restoring a Mindroute.Core.Model.Content item.

void OnContentRestore(Content restored)
OnContentRestored

Occurs after a Mindroute.Core.Model.Content item was restored.

void OnContentRestored(Content restored)
OnContentRemove

Occurs before removing a Mindroute.Core.Model.Content item.

void OnContentRemove(Content removed)
OnContentRemoved

Occurs after a Mindroute.Core.Model.Content item was removed.

void OnContentRemoved(Content removed)
OnContentRevert

Occurs before removing a Mindroute.Core.Model.Content item is reverted to a previous version.

void OnContentRevert(Content current, Content old)
OnContentReverted

Occurs after a Mindroute.Core.Model.Content item was reverted to a previous version.

void OnContentReverted(Content current, Content reverted)
OnContentPublish

Occurs before a draft Mindroute.Core.Model.Content item is published.

void OnContentPublish(Content original, Content draft)
OnContentPublished

Occurs after a draft Mindroute.Core.Model.Content item was published.

void OnContentPublished(Content original, Content published)
OnContentLock

Occurs before a Mindroute.Core.Model.Content item is locked for edit.

void OnContentLock(Content original)
OnContentLocked

Occurs after a Mindroute.Core.Model.Content item was locked for edit.

void OnContentLocked(Content locked)
OnContentUnlock

Occurs before a Mindroute.Core.Model.Content item is unlocked.

void OnContentUnlock(Content locked)
OnContentUnlocked

Occurs after a Mindroute.Core.Model.Content item was unlocked.

void OnContentUnlocked(Content unlocked)
OnContentCopy

Occurs before a Mindroute.Core.Model.Content item is copied.

void OnContentCopy(Content source, Content destination)
OnContentCopied

Occurs after a Mindroute.Core.Model.Content item was copied.

void OnContentCopied(Content source, Content copy)
OnContentMove

Occurs before a Mindroute.Core.Model.Content item is moved.

void OnContentMove(Content source, Content destination)
OnContentMoved

Occurs after a Mindroute.Core.Model.Content item was moved.

 

void OnContentMoved(Content original, Content moved)
OnContentSearch

Occurs before a Mindroute.Core.Services.ContentService.Search search.

void OnContentSearch(ContentQuery query)
OnContentSearched

Occurs after a Mindroute.Core.Services.ContentService.Search search.

void OnContentSearched(ContentQuery query, List<Content> result))
OnCommentInsert

Occurs before a Mindroute.Core.Model.Comment is inserted.

void OnCommentInsert(Comment inserted)
OnCommentInserted

Occurs after a Mindroute.Core.Model.Comment item was inserted.

 

void OnCommentInserted(Comment inserted)
OnCommentUpdate

Occurs before a Mindroute.Core.Model.Comment item is updated.

void OnCommentUpdate(Comment original, Comment updated)
OnCommentUpdated

Occurs after a Mindroute.Core.Model.Comment item was updated.

void OnCommentUpdated(Comment original, Comment updated)
OnCommentRemove

Occurs before a Mindroute.Core.Model.Comment is removed.

void OnCommentRemove(Comment removed)
OnCommentRemoved

Occurs after a Mindroute.Core.Model.Comment was removed.

void OnCommentRemoved(Comment removed)
OnUserAuthenticate

Occurs before a Mindroute.Core.Model.User is authenticated.

void OnUserAuthenticate(string username, string providerName)
OnUserAuthenticated

Occurs after a Mindroute.Core.Model.User was authenticated.

void OnUserAuthenticated(User authenticated)
OnUserDelete

Occurs before deleting a Mindroute.Core.Model.User.

void OnUserDelete(User deleted)
OnUserDeleted

Occurs after deleting a Mindroute.Core.Model.User.

void OnUserDeleted(User deleted)
OnUserInsert

Occurs before a Mindroute.Core.Model.User is inserted.

void OnUserInsert(User inserted)
OnUserInserted

Occurs after a Mindroute.Core.Model.User was inserted.

void OnUserInserted(User inserted)
OnUserUpdate

Occurs before a Mindroute.Core.Model.User is updated.

void OnUserUpdate(User original, User updated)
OnUserUpdated

Occurs after a Mindroute.Core.Model.User was updated.

void OnUserUpdated(User original, User updated)
OnGetTopTags

Occurs when the TagService.GetTopTags method is called.

IList<Tag> OnGetTopTags(IList<Tag> tags)
OnExtractText

Occurs when the FullTextService.AddToIndex(Blob) method is called.

string OnExtractText(Blob blob)