[textpattern commit] r2948 - in development: 4.0-plugin-template 4.0/textpattern/include 4.0/textpattern/lib

0 views
Skip to first unread message

codesite...@google.com

unread,
Jul 23, 2008, 2:12:54 PM7/23/08
to txp...@googlegroups.com
Author: ru...@vanmelick.com
Date: Wed Jul 23 11:11:49 2008
New Revision: 2948

Modified:
development/4.0-plugin-template/zem_plugin.php
development/4.0-plugin-template/zem_plugin_example.php
development/4.0/textpattern/include/txp_plugin.php
development/4.0/textpattern/lib/txplib_misc.php

Log:
Add plugin type 3 (admin only) and fix bug which caused library code
plugins to be loaded by on the public side by default.

Currently, these plugin types exist. They define where the plugin code
is loaded:
0 = public : only on the public side of the website (default)
1 = public+admin : on both the public and admin side
2 = library : only when include_plugin() or require_plugin() is called
3 = admin : only on the admin side

Modified: development/4.0-plugin-template/zem_plugin.php
==============================================================================
--- development/4.0-plugin-template/zem_plugin.php (original)
+++ development/4.0-plugin-template/zem_plugin.php Wed Jul 23 11:11:49 2008
@@ -24,10 +24,11 @@
// Orders 6...9 should be considered for plugins which would work
late. This order is user-overrideable.
$plugin['order'] = 5;

-// Plugin types:
-// 0 = regular plugin; loaded on the public web side only
-// 1 = admin plugin; loaded on both the public and admin side
-// 2 = library; loaded only when include_plugin() or require_plugin()
is called
+// Plugin 'type' defines where the plugin is loaded
+// 0 = public : only on the public side of the website (default)
+// 1 = public+admin : on both the public and admin side
+// 2 = library : only when include_plugin() or require_plugin()
is called
+// 3 = admin : only on the admin side
$plugin['type'] = 0;

if (!defined('txpinterface'))

Modified: development/4.0-plugin-template/zem_plugin_example.php
==============================================================================
--- development/4.0-plugin-template/zem_plugin_example.php (original)
+++ development/4.0-plugin-template/zem_plugin_example.php Wed Jul 23
11:11:49 2008
@@ -15,7 +15,12 @@
$plugin['author'] = 'Threshold State';
$plugin['author_uri'] = 'http://thresholdstate.com/';
$plugin['description'] = 'Simple plugin examples';
-$plugin['type'] = 1; // 0 for regular plugin; 1 if it includes
admin-side code
+// Plugin 'type' defines where the plugin is loaded
+// 0 = public : only on the public side of the website (default)
+// 1 = public+admin : on both the public and admin side
+// 2 = library : only when include_plugin() or require_plugin()
is called
+// 3 = admin : only on the admin side
+$plugin['type'] = 1;

if (!defined('txpinterface'))
@include_once('zem_tpl.php');

Modified: development/4.0/textpattern/include/txp_plugin.php
==============================================================================
--- development/4.0/textpattern/include/txp_plugin.php (original)
+++ development/4.0/textpattern/include/txp_plugin.php Wed Jul 23
11:11:49 2008
@@ -295,7 +295,7 @@

extract($plugin);

- $type = empty($type) ? 0 : min(max(intval($type), 0), 2);
+ $type = empty($type) ? 0 : min(max(intval($type), 0), 3);
$order = empty($order) ? 5 : min(max(intval($order), 1), 9);

$exists = fetch('name','txp_plugin','name',$name);

Modified: development/4.0/textpattern/lib/txplib_misc.php
==============================================================================
--- development/4.0/textpattern/lib/txplib_misc.php (original)
+++ development/4.0/textpattern/lib/txplib_misc.php Wed Jul 23 11:11:49 2008
@@ -537,7 +537,7 @@
}

// -------------------------------------------------------------
- function load_plugins($type=NULL)
+ function load_plugins($type=0)
{
global $prefs,$plugins, $plugins_ver;

@@ -557,11 +557,9 @@
}
}

- $where = 'status = 1';
- if ($type !== NULL)
- $where .= (" and type='".doSlash($type)."'");
+ $where = 'status = 1 AND type IN ('.($type ? '1,3' : '0,1').')';

- $rs = safe_rows("name, code, version", "txp_plugin", $where. ' order
by load_order');
+ $rs = safe_rows("name, code, version", "txp_plugin", $where.' order
by load_order');
if ($rs) {
$old_error_handler = set_error_handler("pluginErrorHandler");
foreach($rs as $a) {

Reply all
Reply to author
Forward
0 new messages