hallo
im englisch sprachigem forum ist das auch mal angesprochen worden.
ich bin erst heute wieder drueber gestolpert als nen test von mir "verstaendlicherweise" fehl schlug.
ich quote hier mal einige passagen damit nicht zwischen den foren hin und her gesprungen werden muss.

Zitat von
babba42
Hi,
experimenting with 1.5 nightly build (2007-12-09) and a plugin, I got a similar problem.
In the doc on
http://dev.joomla.org/component/opti...xtensions_fit/
on Remark #3 you could read this:
Code:
$plugin =& JPluginHelper::getPlugin('content', 'mybot');
if (!$plugin->published){
//plugin not published
}else {
//plugin published
}
My problem, even if the plugin is enabled, the above code didn't work. Searched in the code,
I realised that in the class JPluginHelper under libraries/joomla/plugin/helper.php there is no such variable like 'published'.
So I think, the idea was to trigger onPrepareContent whether the plugin is enabled or not.
But something seems to be missing. Maybe someone can help us.
Thanks

Zitat von
rmullinnix
If you check the JPluginHelper code, the only plugins loaded are those that are published. There is a isEnabled function within JPluginHelper, but it calls the getPlugin, which calls _load which only loads published plugins.
To determine if it's not published you would check for an empty return from JPluginHelper::getPlugin(), but at that point you do not know if it is in the database with published = 0 or it does not exist in the database. This is what the isEnabled function checks (empty return from getPlugin).

Zitat von
felfert

Zitat von
swese44
So what was the verdict on this one? Is there really no way to run a markup-removal function if the plugin isn't enabled?
No, there isn't (unless you hack the Joomla Framework itself - which is not a good idea).
What you can do: Since in your plugin you are free to define and use any custom tag, instead of the usual tag
{foo}...
{/foo}, use a tag which isn't visible and compatible to standard html. e.g.
<!-- {foo}...
{/foo} -->. This eliminates the need for removal. It could even be optional. E.g. try matching for a tag in comments first, then fall back to the plain form. This way, the users can decide if they want tags visible or invisible if your plugin is disabled.
Quelle:http://forum.joomla.org/viewtopic.php?f=231&t=242470
das bedeutet in kuerze das es von joomla her keine moeglichkeit gibt ( weil die funktion nicht ausgefuehrt wird ) zu erfragen ob das plugin veroeffentlicht ist oder nicht. im letzten quote ist eine methode beschrieben die ueber kommentare versucht den plugin code im quelltext bzw im content herauszufiltern.
im ersten posting des original threads wurde generell gefragt welche moeglichkeiten es ueberhaupt gibt. eine davon waere den code voellig unangetastet zu lassen um autoren und oder administratoren nen hinweis darauf zu geben das etwas nicht stimmt. der eigentlich zu ersetzende code bleibt im content und kann so als "fehlermeldung" genutzt werden.
die huebschere und eigentlich schmerzfreiere variante finde ich, gibt es im core plugin "loadmodule".
hier wurde ueber die xml einfach ein radio box parameter mit dem namen enabled und den werten 0 und 1 hinzugefuegt.
im plugin wird dann folgendermassen geprueft:
PHP-Code:
// F e t c h P l u g i n I n f o
$plugin =& JPluginHelper::getPlugin( 'content', 'PLUGIN_NAME' );
$pluginParams = new JParameter( $plugin->params );
// E n a b l e d ? !
if ( !$pluginParams->get( 'enabled', 1 ) ) {
$article->text = preg_replace( $regex, 'REPLACEMENT', $article->text );
return true;
}
// ELSE => PROCEED WITH CODE => PLUGIN IS "PUBLISHED"
dies entspricht natuerlich nur einem workarround. wenn das plugin wirklich unpublished ist, verhaelt es sich natuerlich genauso wie vorher auch. der code bleibt im content enthalten. hier ist der zustaendige admin gefragt wobei - ob nun der admin den parameter auf enabled setzt, oder das plugin aktiviert / deaktivert ...
in jedem fall ist es aber so nun moeglich durch "deaktivieren" ( nicht unpublishen ) des plugins den plugin code aus allen content items filtern oder ersetzen zu lassen.
im obigen beispiel waere REPLACEMENT also entweder leer "... " / ' ... ' - oder der code / text einer meldung die anzeigt, dass das plugin gerade nicht aktiv ist.
als anmerkung noch:
wenn ich richtig informiert bin und sich nicht wieder etwas geaendert hat, dann ist folgende methode "veraltet"
PHP-Code:
$mainframe->registerEvent( 'onPrepareContent', 'PLUGIN_NAME' );
eine ausfuehrlichere anleitung mit allem drum und dran findet man hier.
viel erfolg
sven
Lesezeichen