Recent Topics

1 Nov 28, 2006 14:53    

Hello,
i'm very new in b2e, and i already develop 2 plugins for myself for the public part... one is for show google map, one is for import rss (using marpierss plus a plugin for show the results in a post).

now i'm trying to expand the backoffice... i want to add a couple of fields when an editor/admin/whoever can write or edit a post.. basically, clickin on Write, or Edit a post, should show the common things as by default, plus 2 new fields, these fields MUST be completed if a specific blog is selected.

Now, i probably know how to add a "toolbar" in the editor (copied from googlespell plugin), but how do i do the save part? i must save the 2 values in the DB, linked (by ID) with the post..

thank you,

Alex

2 Nov 28, 2006 15:04

Hi,

If you take a look in inc/misc/_plugins.class.php you can find a list of all of the hooks available to plugins. These are the ones available in 1.8.5

	/**
	 * Get the list of supported/available events/hooks.
	 *
	 * Additional to the returned event methods (which can be disabled), there are internal
	 * ones which just get called on the plugin (and get not remembered in T_pluginevents), e.g.:
	 *  - AfterInstall
	 *  - AppendPluginRegister
	 *  - BeforeEnable
	 *  - BeforeDisable
	 *  - BeforeInstall
	 *  - BeforeUninstall
	 *  - BeforeUninstallPayload
	 *  - GetDefaultSettings
	 *  - GetDefaultUserSettings
	 *  - GetHtsrvMethods
	 *  - PluginSettingsUpdateAction (Called as action before updating the plugin's settings)
	 *  - PluginSettingsEditAction (Called as action before editing the plugin's settings)
	 *  - PluginSettingsEditDisplayAfter (Called after standard plugin settings are displayed for editing)
	 *  - PluginSettingsValidateSet (Called before setting a plugin's setting in the backoffice)
	 *  - PluginUserSettingsUpdateAction (Called as action before updating the plugin's user settings)
	 *  - PluginUserSettingsEditAction (Called as action before editing the plugin's settings)
	 *  - PluginUserSettingsEditDisplayAfter (Called after displaying normal user settings)
	 *  - PluginUserSettingsValidateSet (Called before setting a plugin's user setting in the backoffice)
	 *  - PluginVersionChanged (Called when we detect a version change)
	 *
	 *  The max length of event names is 40 chars (T_pluginevents.pevt_event).
	 *
	 * @todo Finish/Complete descriptions
	 *
	 * @return array Name of event (key) => description (value)
	 */
	function get_supported_events()
	{
		if( empty( $this->_supported_events ) )
		{
			$this->_supported_events = array(
				'AdminAfterPageFooter' => '',
				'AdminDisplayEditorButton' => '',
				'AdminDisplayToolbar' => '',
				'AdminDisplayItemFormFieldset' => '',
				'AdminEndHtmlHead' => '',
				'AdminAfterMenuInit' => '',
				'AdminTabAction' => '',
				'AdminTabPayload' => '',
				'AdminToolAction' => '',
				'AdminToolPayload' => '',

				'AdminBeforeItemEditCreate' => 'This gets called before a new item gets created.',
				'AdminBeforeItemEditUpdate' => 'This gets called before an existing item gets updated.',

				'AdminBeginPayload' => '',

				'CacheObjects' => 'Cache data objects.',
				'CachePageContent' => 'Cache page content.',
				'CacheIsCollectingContent' => 'Gets asked for if we are generating cached content.',

				'AfterCommentDelete' => 'Gets called after a comment has been deleted from the database.',
				'AfterCommentInsert' => 'Gets called after a comment has been inserted into the database.',
				'AfterCommentUpdate' => 'Gets called after a comment has been updated in the database.',

				'AfterItemDelete' => '',
				'PrependItemInsertTransact' => '',
				'AfterItemInsert' => '',
				'PrependItemUpdateTransact' => '',
				'AfterItemUpdate' => '',
				'AppendItemPreviewTransact' => '',

				'RenderItemAsHtml' => 'Renders content when generated as HTML.',
				'RenderItemAsXml' => 'Renders content when generated as XML.',
				'RenderItem' => 'Renders content when not generated as HTML or XML.',

				'FilterCommentAuthor' => 'Filters the comment author.',
				'FilterCommentAuthorUrl' => 'Filters the URL of the comment author.',
				'FilterCommentContent' => 'Filters the content of a comment.',

				'AfterUserDelete' => '',
				'AfterUserInsert' => '',
				'AfterUserUpdate' => '',

				/*
				not used yet..
				'DisplayItemAsHtml' => 'Called on an item when it gets displayed as HTML.',
				'DisplayItemAsXml' => 'Called on an item when it gets displayed as XML.',
				'DisplayItem' => 'Called on an item when it gets not displayed as HTML or XML.',
				*/
				'DisplayItemAllFormats' => 'Called on an item when it gets displayed.',

				'FilterIpAddress' => 'Called when displaying an IP address.',

				'ItemViewsIncreased' => 'Called when the view counter of an item got increased.',
				'ItemCanComment' => 'Asks the plugin if an item can receive comments/feedback.',

				'SkinTag' => '',

				'AppendHitLog' => 'Called when a hit gets logged, but before it gets recorded.',

				'DisplayCommentFormButton' => '',
				'DisplayCommentFormFieldset' => '',
				'DisplayMessageFormButton' => '',
				'DisplayMessageFormFieldset' => '',
				'DisplayLoginFormFieldset' => 'Called when displaying the "Login" form.',
				'DisplayRegisterFormFieldset' => 'Called when displaying the "Register" form.',
				'DisplayValidateAccountFormFieldset' => 'Called when displaying the "Validate account" form.',

				'BeforeCommentFormInsert' => 'Called before a comment gets recorded through the public comment form.',
				'AfterCommentFormInsert' => 'Called after a comment has been added through public form.',

				'BeforeTrackbackInsert' => 'Gets called before a trackback gets recorded.',
				'AfterTrackbackInsert' => 'Gets called after a trackback has been recorded.',

				'LoginAttempt' => 'Called when a user tries to login.',
				'AlternateAuthentication' => '',
				'MessageFormSent' => 'Called when the "Message to user" form has been submitted.',
				'MessageFormSentCleanup' => 'Called after a email message has been sent through public form.',
				'Logout' => 'Called when a user logs out.',

				'GetSpamKarmaForComment' => 'Asks plugin for the spam karma of a comment/trackback.',

				// Other Plugins can use this:
				'CaptchaValidated' => 'Validate the test from CaptchaPayload to detect humans.',
				'CaptchaValidatedCleanup' => 'Cleanup data used for CaptchaValidated.',
				'CaptchaPayload' => 'Provide a turing test to detect humans.',

				'RegisterFormSent' => 'Called when the "Register" form has been submitted.',
				'ValidateAccountFormSent' => 'Called when the "Validate account" form has been submitted.',
				'AppendUserRegistrTransact' => 'Gets appended to the transaction that creates a new user on registration.',
				'AfterUserRegistration' => 'Gets called after a new user has registered.',

				'SessionLoaded' => '', // gets called after $Session is initialized, quite early.

				'AfterLoginAnonymousUser' => 'Gets called at the end of the login procedure for anonymous visitors.',
				'AfterLoginRegisteredUser' => 'Gets called at the end of the login procedure for registered users.',

				'BeforeBlogDisplay' => 'Gets called before a (part of the blog) gets displayed.',
				'SkinBeginHtmlHead' => 'Gets called at the top of the HTML HEAD section in a skin.',
				'DisplayTrackbackAddr' => '',
			);
		}

		return $this->_supported_events;
	}

The one's you'll "probably" want to look into are these two :-

                'AdminBeforeItemEditCreate' => 'This gets called before a new item gets created.',
                'AdminBeforeItemEditUpdate' => 'This gets called before an existing item gets updated.',

¥

3 Nov 28, 2006 15:09

AlexMagik wrote:

Hello,
i'm very new in b2e, and i already develop 2 plugins for myself for the public part...

Are you planning on sharing these plugins with everyone else?

4 Nov 28, 2006 15:21

EdB wrote:

Are you planning on sharing these plugins with everyone else?

Do you want an rss plugin? I'm sure I've got a mostly finished one lying around somewhere?

¥

6 Nov 29, 2006 11:23

Thanks guys, this eve i am going to try to see if works :)
For the request to public my plugins... well, i need to clean them up first, if you look at them now, they work, but they are so ugly and messy :) when i done with this new plugin, i will clean the others up and then i may release them (if the customer who is paying me for make them will agree) :)

7 Nov 29, 2006 16:31

i've a problem...
the 2 functions are called BEFORE the update/insert...
and it's fine for the update, but for the insert, my plugin is supposed to insert in another table some extra data, but in this case i can't because after i will not be able to know how to connect the 2 records...

for example, i do the insert of a new post, but how will i be able to know the post_id in the BEFORE function for insert my data in the secondary "extention" table?

8 Nov 29, 2006 16:59

Try :-

                'AfterItemInsert' => '',
                'AfterItemUpdate' => '', 

¥

9 Nov 29, 2006 17:45

this is weird :)
i create the toolbar (and i can see it in the write/edit).
the issue seems that the functions "AfterItemUpdate"/"AdminBeforeItemEditUpdate" and the create ones as well, are never called... :(

should i set some special configuration in the plugin for run these? in the plugin properties the functions are enabled to be run, the render is "never".

EDIT: fixed... seems to be a problem with some other functions :) tooked away the AdminEndHtmlHead, and now it start working :)

10 Nov 29, 2006 18:22

AlexMagik, if you've added the methods into your plugin, you have to reload the plugins (see the link below the list of installed plugins), so that b2evo knows that the plugin hooks the new events.
As an alternative (or in case of releasing a plugin with added hooks), bump the version of the plugin - this will also reload the events.

11 Nov 30, 2006 01:27

thank you guys,
the plugin is working using the AfterItemUpdate/AfterItemCreate/AfterItemDelete

a bit of tuning on my code and will be done :)

Thank you very much :)


Form is loading...