1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Now processing e_tohtml files, old method deprecated. Linkwords updated to use new method. More plugin.xml supporting changes

This commit is contained in:
mcfly
2008-02-01 18:09:02 +00:00
parent 1dd0fbadf8
commit 76c552459a
4 changed files with 90 additions and 42 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
| $Revision: 1.27 $ | $Revision: 1.28 $
| $Date: 2008-01-04 19:54:16 $ | $Date: 2008-02-01 18:09:01 $
| $Author: e107steved $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -657,6 +657,7 @@ class e_parse
//Run any hooked in parsers //Run any hooked in parsers
if (!$opts['no_hook'] && varset($pref['tohtml_hook'])) if (!$opts['no_hook'] && varset($pref['tohtml_hook']))
{ {
//Process the older tohtml_hook pref (depricated)
foreach(explode(",",$pref['tohtml_hook']) as $hook) foreach(explode(",",$pref['tohtml_hook']) as $hook)
{ {
if (!is_object($this->e_hook[$hook])) if (!is_object($this->e_hook[$hook]))
@@ -665,8 +666,24 @@ class e_parse
$hook_class = "e_".$hook; $hook_class = "e_".$hook;
$this->e_hook[$hook] = new $hook_class; $this->e_hook[$hook] = new $hook_class;
} }
$text = $this->e_hook[$hook]->$hook($text,$opts['context']); $text = $this->e_hook[$hook]->$hook($text,$opts['context']);
} }
if(isset($pref['e_tohtml_list']) && is_array($pref['e_tohtml_list']))
{
foreach($pref['e_tohtml_list'] as $hook)
{
if (!is_object($this->e_hook[$hook]))
{
require_once(e_PLUGIN.$hook."/e_tohtml.php");
$hook_class = "e_tohtml_".$hook;
$this->e_hook[$hook] = new $hook_class;
}
$text = $this->e_hook[$hook]->to_html($text, $opts['context']);
}
}
} }

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.23 $ | $Revision: 1.24 $
| $Date: 2008-02-01 14:11:27 $ | $Date: 2008-02-01 18:09:01 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -706,28 +706,7 @@ class e107plugin
{ {
if(isset($plug_vars['mainPrefs']['pref'])) if(isset($plug_vars['mainPrefs']['pref']))
{ {
if(!is_array($plug_vars['mainPrefs']['pref'])) $list = $this->parse_prefs($plug_vars['mainPrefs']['pref']);
{
$pref_list = array($plug_vars['mainPrefs']['pref']);
}
else
{
$pref_list = $plug_vars['mainPrefs']['pref'];
}
$list = array();
foreach($pref_list as $_pref)
{
$attrib = $_pref['@attributes'];
$list['all'][$attrib['name']] = $attrib['value'];
if(!isset($attrib['active']) || $attrib['active'] == 'true')
{
$list['active'][$attrib['name']] = $attrib['value'];
}
if(isset($attrib['active']) && $attrib['active'] == 'false')
{
$list['inactive'][$attrib['name']] = $attrib['value'];
}
}
switch($function) switch($function)
{ {
case 'install': case 'install':
@@ -764,7 +743,7 @@ class e107plugin
{ {
if(isset($plug_vars['userclasses']['userclass'])) if(isset($plug_vars['userclasses']['userclass']))
{ {
if(!is_array($plug_vars['userclasses']['userclass'])) if(!isset($plug_vars['userclasses']['userclass'][0]))
{ {
$uclass_list = array($plug_vars['userclasses']['userclass']); $uclass_list = array($plug_vars['userclasses']['userclass']);
} }
@@ -772,11 +751,8 @@ class e107plugin
{ {
$uclass_list = $plug_vars['userclasses']['userclass']; $uclass_list = $plug_vars['userclasses']['userclass'];
} }
print_a($uclass_list);
foreach($uclass_list as $uclass) foreach($uclass_list as $uclass)
{ {
print_a($uclass);
$attrib = $uclass['@attributes']; $attrib = $uclass['@attributes'];
switch($function) switch($function)
{ {
@@ -809,6 +785,25 @@ class e107plugin
$this -> manage_search($function, $plug_vars['folder']); $this -> manage_search($function, $plug_vars['folder']);
$this -> manage_notify($function, $plug_vars['folder']); $this -> manage_notify($function, $plug_vars['folder']);
// Let's call any custom functions defined in <management> section
if(isset($plug_vars['management'][$function]))
{
$manage = $plug_vars['management'][$function]['@attributes'];
if(is_readable($path.$manage['file']))
{
include($path.$manage['file']);
if($manage['type'] == 'fileFunction')
{
$result = call_user_func($manage['function'], $plug_vars);
}
elseif($manage['type'] == 'classFunction')
{
$_tmp = new $manage['class'];
$result = call_user_func(array($_tmp, $manage['function']), $plug_vars);
}
}
}
if($function == 'install' || $functon = 'upgrade') if($function == 'install' || $functon = 'upgrade')
{ {
@@ -830,6 +825,40 @@ class e107plugin
} }
function parse_prefs($pref_array)
{
$ret = array();
if(!isset($pref_array[0]))
{
$pref_array = array($pref_array);
}
foreach($pref_array as $k => $p)
{
$attrib = $p['@attributes'];
if(isset($attrib['type']) && $attrib['type'] == 'array')
{
$name = $attrib['name'];
$tmp = $this->parse_prefs($pref_array[$k]['key']);
$ret['all'][$name] = $tmp['all'];
$ret['active'][$name] = $tmp['active'];
$ret['inactive'][$name] = $tmp['inactive'];
}
else
{
$ret['all'][$attrib['name']] = $attrib['value'];
if(!isset($attrib['active']) || $attrib['active'] == 'true')
{
$ret['active'][$attrib['name']] = $attrib['value'];
}
else
{
$ret['inactive'][$attrib['name']] = $attrib['value'];
}
}
}
return $ret;
}
function install_plugin_php($id) function install_plugin_php($id)
{ {
global $sql; global $sql;
@@ -998,9 +1027,9 @@ class e107plugin
if ($is_installed) if ($is_installed)
{ {
foreach($this->plugin_addons as $val) foreach($tmp as $val)
{ {
if(in_array($val,$tmp)) if(strpos($val, 'e_') === 0)
{ {
$pref[$val."_list"][$path] = $path; $pref[$val."_list"][$path] = $path;
} }
@@ -1219,6 +1248,7 @@ class e107plugin
require_once(e_HANDLER.'xml_class.php'); require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass; $xml = new xmlClass;
$this->plug_vars = $xml->loadXMLfile($path.'plugin.xml', true, true); $this->plug_vars = $xml->loadXMLfile($path.'plugin.xml', true, true);
// print_a($this->plug_vars);
// $xml->loadXMLfile($path.'plugin.xml', true, true); // $xml->loadXMLfile($path.'plugin.xml', true, true);
// $xml->xmlFileContents = $tp->replaceConstants($xml->xmlFileContents, '', true); // $xml->xmlFileContents = $tp->replaceConstants($xml->xmlFileContents, '', true);
// $this->plug_vars = $xml->parseXml(); // $this->plug_vars = $xml->parseXml();

View File

@@ -29,6 +29,11 @@
<pref name="forum_postspage" value="10" /> <pref name="forum_postspage" value="10" />
<pref name="forum_hilightsticky" value="1" /> <pref name="forum_hilightsticky" value="1" />
<pref name="forum_obsolete_pref" value="1" active="false"/> <pref name="forum_obsolete_pref" value="1" active="false"/>
<pref name="forum_tmp" type="array">
<key name="pref1" value="val1" active="false" />
<key name="pref2" value="val2" />
<key name="pref3" value="val3" />
</pref>
</mainPrefs> </mainPrefs>
<userclasses> <userclasses>
<userclass name="forum_moderator" description="Moderator of all forums" /> <userclass name="forum_moderator" description="Moderator of all forums" />

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/plugin.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/plugin.php,v $
| $Revision: 1.3 $ | $Revision: 1.4 $
| $Date: 2007-07-28 16:47:55 $ | $Date: 2008-02-01 18:09:02 $
| $Author: e107steved $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -24,7 +24,7 @@ if (!defined('e107_INIT')) { exit; }
// Plugin info ------------------------------------------------------------------------------------------------------- // Plugin info -------------------------------------------------------------------------------------------------------
$eplug_name = "LWLANINS_1"; $eplug_name = "LWLANINS_1";
$eplug_version = "1.1"; $eplug_version = "1.2";
$eplug_author = "jalist"; $eplug_author = "jalist";
$eplug_url = "http://e107.org"; $eplug_url = "http://e107.org";
$eplug_email = "jalist@e107.org"; $eplug_email = "jalist@e107.org";
@@ -116,8 +116,4 @@ $upgrade_alter_tables = "";
$eplug_upgrade_done = ""; $eplug_upgrade_done = "";
?> ?>