From 40ca30d8f2fc6f2e3beb9df93c8eb0d4ce21962e Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Thu, 22 Oct 2009 04:14:45 +0000 Subject: [PATCH] more plugin_class work. xml spec now supports sitelink urls outside of the plugin folder (like in 0.7). Also some minor path fixes. --- e107_admin/admin.php | 14 ++- e107_handlers/comment_class.php | 15 ++- e107_handlers/db_debug_class.php | 12 +- e107_handlers/plugin_class.php | 152 +++++++++++++++++--------- e107_handlers/xml_class.php | 6 +- e107_plugins/calendar_menu/plugin.xml | 4 +- e107_plugins/download/plugin.xml | 4 +- e107_plugins/forum/forum_setup.php | 22 ++-- e107_plugins/forum/plugin.xml | 4 +- e107_plugins/gsitemap/plugin.xml | 4 +- e107_plugins/links_page/plugin.xml | 4 +- e107_plugins/list_new/plugin.xml | 4 +- e107_plugins/log/plugin.xml | 4 +- e107_plugins/newsfeed/plugin.xml | 4 +- e107_plugins/tagwords/plugin.xml | 4 +- 15 files changed, 162 insertions(+), 95 deletions(-) diff --git a/e107_admin/admin.php b/e107_admin/admin.php index b1fcbc6e7..c0f5268de 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/admin.php,v $ -| $Revision: 1.18 $ -| $Date: 2009-09-24 02:33:43 $ +| $Revision: 1.19 $ +| $Date: 2009-10-22 04:14:34 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -321,6 +321,7 @@ function log_request() // - common to the various admin layouts. function getPluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb') { + global $sql, $tp; $pref = e107::getConfig('core')->getPref(); @@ -328,13 +329,17 @@ function getPluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb') $text = render_links(e_ADMIN."plugin.php", ADLAN_98, ADLAN_99, "Z", $iconSize, $linkStyle); $plugs = e107::getObject('e107plugin'); - + foreach($pref['plug_installed'] as $plug=>$vers) { - $plugs->parse_plugin_xml($plug); + $plugs->parse_plugin($plug); + $plugin_path = $plug; $name = $plugs->plug_vars['@attributes']['name']; +/* echo "

".$name." ($plug)

"; + print_a($plugs->plug_vars);*/ + foreach($plugs->plug_vars['adminLinks']['link'] as $tag) { if(varset($tag['@attributes']['primary']) !='true') @@ -344,6 +349,7 @@ function getPluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb') loadLanFiles($plugin_path, 'admin'); $att = $tag['@attributes']; + $eplug_name = $tp->toHTML($name,FALSE,"defs, emotes_off"); $eplug_conffile = $att['url']; diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 84b2558a7..5b72f7502 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/comment_class.php,v $ - | $Revision: 1.28 $ - | $Date: 2009-10-09 15:05:12 $ - | $Author: secretr $ + | $Revision: 1.29 $ + | $Date: 2009-10-22 04:14:35 $ + | $Author: e107coders $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) @@ -338,7 +338,14 @@ class comment function enter_comment($author_name, $comment, $table, $id, $pid, $subject, $rateindex = FALSE) { //rateindex : the posted value from the rateselect box (without the urljump) (see function rateselect()) - global $sql,$sql2,$tp,$e107cache,$e_event,$e107,$pref,$rater; + global $e_event,$e107,$pref,$rater; + + $sql = e107::getDb(); + $sql2 = e107::getDb('sql2'); + $tp = e107::getParser(); + $e107cache = e107::getCache(); + + if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) { return; diff --git a/e107_handlers/db_debug_class.php b/e107_handlers/db_debug_class.php index 1397f5822..e56d55c30 100644 --- a/e107_handlers/db_debug_class.php +++ b/e107_handlers/db_debug_class.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/db_debug_class.php,v $ -| $Revision: 1.14 $ -| $Date: 2009-09-13 10:29:56 $ -| $Author: secretr $ +| $Revision: 1.15 $ +| $Date: 2009-10-22 04:14:35 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -598,7 +598,7 @@ class e107_db_debug { // function e107_debug_shutdown() { -global $error_handler,$e107_Clean_Exit,$In_e107_Footer,$ADMIN_DIRECTORY; +global $error_handler,$e107_Clean_Exit,$In_e107_Footer,$ADMIN_DIRECTORY,$THEME_DIRECTORY; if (isset($e107_Clean_Exit)) return; if (!isset($In_e107_Footer)) @@ -609,7 +609,9 @@ global $error_handler,$e107_Clean_Exit,$In_e107_Footer,$ADMIN_DIRECTORY; require_once($filewanted); } else if (defset('USER_AREA')) { - $filewanted=realpath(dirname(__FILE__)).'/../'.FOOTERF; + $filewanted=realpath(dirname(__FILE__)."/../".$THEME_DIRECTORY.'templates/')."/footer_default.php"; // FOOTERF; + // Works better than FOOTERF for e107_files/e_jslib.php. + require_once($filewanted); } } diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 1e3e0d8b0..7496debd9 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $ -| $Revision: 1.103 $ -| $Date: 2009-10-21 12:52:53 $ +| $Revision: 1.104 $ +| $Date: 2009-10-22 04:14:35 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -945,13 +945,6 @@ class e107plugin $this->XmlLanguageFiles($function,$plug_vars['languageFiles'],'pre'); // First of all, see if there's a language file specific to install } - /* // DEPRECATED - if (isset($plug_vars['installLanguageFile']) && isset($plug_vars['installLanguageFile']['@attributes']['filename'])) - { - include_lan($path.str_replace('--LAN--',e_LANGUAGE, $plug_vars['installLanguageFile']['@attributes']['filename'])); - } - */ - // Next most important, if installing or upgrading, check that any dependencies are met if ($canContinue && ($function != 'uninstall') && isset($plug_vars['dependencies'])) { @@ -1268,7 +1261,7 @@ class e107plugin $attrib = $link['@attributes']; $linkName = (defset($link['@value'])) ? constant($link['@value']) : $link['@value']; $remove = (varset($attrib['deprecate']) == 'true') ? TRUE : FALSE; - $url = e_PLUGIN.$attrib['url']; //TODO should also handle links to the root directory. (eg. /news.php) + $url = $attrib['url']; $perm = (isset($attrib['perm']) ? $attrib['perm'] : 0); switch($function) @@ -1609,15 +1602,18 @@ class e107plugin function install_plugin_php($id) { - + $function = 'install'; $sql = e107::getDb(); - + $mes = e107::getMessage(); + $plug = $this->getinfo($id); $_path = e_PLUGIN.$plug['plugin_path'].'/'; $plug['plug_action'] = 'install'; - // $plug_vars = $this->parse_plugin_php($plug['plugin_path']); + $this->parse_plugin_php($plug['plugin_path']); + $plug_vars = $this->plug_vars; + include($_path.'plugin.php'); $func = $eplug_folder.'_install'; @@ -1632,21 +1628,29 @@ class e107plugin if ($result === TRUE) { $text .= EPL_ADLAN_19.'
'; + + $mes->add(EPL_ADLAN_19, E_MESSAGE_SUCCESS); //success } else { - $text .= EPL_ADLAN_18.'
'; + $mes->add(EPL_ADLAN_18, E_MESSAGE_ERROR); //fail } } - - if (is_array($eplug_prefs)) +/* if (is_array($eplug_prefs)) { $this->manage_prefs('add', $eplug_prefs); $text .= EPL_ADLAN_8.'
'; - } + }*/ + + if(varset($plug_vars['mainPrefs'])) //Core pref items + { + $this->XmlPrefs('core',$function,$plug_vars['mainPrefs']); + $text .= EPL_ADLAN_8.'
'; + } + if (is_array($eplug_array_pref)) { @@ -1655,27 +1659,17 @@ class e107plugin $this->manage_plugin_prefs('add', $key, $eplug_folder, $val); } } -/* - if (is_array($eplug_sc)) - { - $this->manage_plugin_prefs('add', 'plug_sc', $eplug_folder, $eplug_sc); - } - if (is_array($eplug_bb)) - { - $this->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb); - } -*/ - if ($eplug_link === TRUE && $eplug_link_url != '' && $eplug_link_name != '') - { - $linkperm = (isset($eplug_link_perms) ? $eplug_link_perms : e_UC_PUBLIC); - $this->manage_link('add', $eplug_link_url, $eplug_link_name, $linkperm); - } - if ($eplug_userclass) + if(varset($plug_vars['siteLinks'])) { - $this->manage_userclass('add', $eplug_userclass, $eplug_userclass_description); + $this->XmlSiteLinks($function,$plug_vars['siteLinks']); } + + if(varset($plug_vars['userClasses'])) + { + $this->XmlUserClasses($function,$plug_vars['userClasses']); + } $this -> manage_search('add', $eplug_folder); @@ -1953,34 +1947,80 @@ class e107plugin // Called to parse the (deprecated) plugin.php file function parse_plugin_php($plugName) { - include(e_PLUGIN.$plugName.'/plugin.php'); + + $mes = e107::getMessage(); + $tp = e107::getParser(); + + if(include(e_PLUGIN.$plugName.'/plugin.php')) + { + //$mes->add("Loading ".e_PLUGIN.$plugName.'/plugin.php', E_MESSAGE_DEBUG); + } + + $ret = array(); // $ret['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || is_array($eplug_sc) || is_array($eplug_bb) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest); - $ret['@attributes']['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest); - - $ret['@attributes']['version'] = varset($eplug_version); + $ret['@attributes']['name'] = varset($eplug_name); + $ret['@attributes']['version'] = varset($eplug_version); $ret['@attributes']['compatibility'] = varset($eplug_compatible); + $ret['@attributes']['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest) ? 'true' : ''; + $ret['@attributes']['xhtmlcompliant'] = vartrue($eplug_compliant) ? 'true' : ''; $ret['folder'] = (varset($eplug_folder)) ? $eplug_folder : $plugName; - $ret['category'] = varset($eplug_category) ? $this->manage_category($eplug_category) : "misc"; - $ret['description'] = varset($eplug_description); + $ret['author']['@attributes']['name'] = varset($eplug_author); $ret['author']['@attributes']['url'] = varset($eplug_url); $ret['author']['@attributes']['email'] = varset($eplug_email); + $ret['description'] = varset($eplug_description); + + $ret['category'] = varset($eplug_category) ? $this->manage_category($eplug_category) : "misc"; $ret['readme'] = varset($eplug_readme); - $ret['compliant'] = varset($eplug_compliant); + $ret['menuName'] = varset($eplug_menu_name); + + if(varset($eplug_prefs)) + { + $c = 0; + foreach($eplug_prefs as $name=>$value) + { + $ret['mainPrefs']['pref'][$c]['@attributes']['name'] = $name; + $ret['mainPrefs']['pref'][$c]['@value'] = $value; + $c++; + } + } - + // For BC. $ret['administration']['icon'] = varset($eplug_icon); $ret['administration']['caption'] = varset($eplug_caption); $ret['administration']['iconSmall'] = varset($eplug_icon_small); $ret['administration']['configFile'] = varset($eplug_conffile); + if(varset($eplug_conffile)) + { + $ret['adminLinks']['link'][0]['@attributes']['url'] = varset($eplug_conffile); + $ret['adminLinks']['link'][0]['@attributes']['description'] = LAN_CONFIGURE; + $ret['adminLinks']['link'][0]['@attributes']['icon'] = varset($eplug_icon); + $ret['adminLinks']['link'][0]['@attributes']['iconSmall'] = varset($eplug_icon_small); + $ret['adminLinks']['link'][0]['@attributes']['primary'] = 'true'; + } + if(vartrue($eplug_link) && varset($eplug_link_name) && varset($eplug_link_url)) + { + $ret['siteLinks']['link'][0]['@attributes']['url'] = $tp->createConstants($eplug_link_url,1); + $ret['siteLinks']['link'][0]['@attributes']['perm'] = $eplug_link_perms; + $ret['siteLinks']['link'][0]['@value'] = $eplug_link_name; + } + + if(vartrue($eplug_userclass) && vartrue($eplug_userclass_description)) + { + $ret['userClasses']['class'][0]['@attributes']['name'] = $eplug_userclass; + $ret['userClasses']['class'][0]['@attributes']['description'] = $eplug_userclass_description; + } + + // Set this key so we know the vars came from a plugin.php file $ret['plugin_php'] = true; $this->plug_vars = $ret; + return true; } @@ -1997,7 +2037,7 @@ class e107plugin // $xml->setOptArrayTags('extendedField,userclass,menuLink,commentID'); // always arrays for these tags. // $xml->setOptStringTags('install,uninstall,upgrade'); - // $plug_vars2 = $xml->loadXMLfile(e_PLUGIN.$plugName.'/plugin2.xml', 'advanced'); + $this->plug_vars = $xml->loadXMLfile(e_PLUGIN.$plugName.'/plugin.xml', 'advanced'); if ($this->plug_vars === FALSE) { @@ -2009,22 +2049,34 @@ class e107plugin $this->plug_vars['category'] = (isset($this->plug_vars['category'])) ? $this->manage_category($this->plug_vars['category']) : "misc"; $this->plug_vars['folder'] = $plugName; // remove the need for tag in plugin.xml. - -/* if($plugName == "forum") + + /* + // Very useful debug code.to compare plugin.php vs plugin.xml + $testplug = 'forum'; + if($plugName == $testplug) { - echo "
"; - //print_a($plug_vars2); + $plug_vars1 = $this->plug_vars; + $this->parse_plugin_php($testplug); + $plug_vars2 = $this->plug_vars; + ksort($plug_vars2); + ksort($plug_vars1); + echo " + +

PHP

XML

"; + print_a($plug_vars2); echo ""; - print_a($this->plug_vars); + print_a($plug_vars1); echo "
"; - }*/ + } + + */ // TODO search for $this->plug_vars['adminLinks']['link'][0]['@attributes']['primary']==true. $this->plug_vars['administration']['icon'] = varset($this->plug_vars['adminLinks']['link'][0]['@attributes']['icon']); $this->plug_vars['administration']['caption'] = varset($this->plug_vars['adminLinks']['link'][0]['@attributes']['description']); $this->plug_vars['administration']['iconSmall'] = varset($this->plug_vars['adminLinks']['link'][0]['@attributes']['iconSmall']); $this->plug_vars['administration']['configFile'] = varset($this->plug_vars['adminLinks']['link'][0]['@attributes']['url']); - + return TRUE; } diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index c550735f8..9dd2ebc12 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -9,8 +9,8 @@ * Simple XML Parser * * $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $ - * $Revision: 1.31 $ - * $Date: 2009-10-21 12:28:17 $ + * $Revision: 1.32 $ + * $Date: 2009-10-22 04:14:35 $ * $Author: e107coders $ */ @@ -817,7 +817,7 @@ class xmlClass $value = (substr($val['@value'],0,7) == "array (") ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value']; $pref[$name] = $value; - $mes->add("Setting up ".$prefType." Pref [".$name."] => ".$value, E_MESSAGE_DEBUG); + // $mes->add("Setting up ".$prefType." Pref [".$name."] => ".$value, E_MESSAGE_DEBUG); } diff --git a/e107_plugins/calendar_menu/plugin.xml b/e107_plugins/calendar_menu/plugin.xml index 9fa95ba5f..c04669eae 100644 --- a/e107_plugins/calendar_menu/plugin.xml +++ b/e107_plugins/calendar_menu/plugin.xml @@ -1,6 +1,6 @@ - + @@ -19,7 +19,7 @@ EC_ADLAN_A173 - Calendar + Calendar 254 diff --git a/e107_plugins/download/plugin.xml b/e107_plugins/download/plugin.xml index 5d2044c55..245d4a9cd 100755 --- a/e107_plugins/download/plugin.xml +++ b/e107_plugins/download/plugin.xml @@ -1,5 +1,5 @@ - + DOWLAN_DESCRIPTION @@ -17,7 +17,7 @@ DOWLAN_128 - DOWLAN_29 + DOWLAN_29 diff --git a/e107_plugins/forum/forum_setup.php b/e107_plugins/forum/forum_setup.php index fb7a0e3ce..3a0d6ff77 100644 --- a/e107_plugins/forum/forum_setup.php +++ b/e107_plugins/forum/forum_setup.php @@ -9,8 +9,8 @@ * Custom forum install/uninstall/update routines * * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_setup.php,v $ -* $Revision: 1.2 $ -* $Date: 2009-10-21 12:53:00 $ +* $Revision: 1.3 $ +* $Date: 2009-10-22 04:14:45 $ * $Author: e107coders $ * */ @@ -19,36 +19,36 @@ class forum_setup { function install_pre($var) { - print_a($var); - echo "custom install 'pre' function

"; + // print_a($var); + // echo "custom install 'pre' function

"; } function install_post($var) { $sql = e107::getDb(); - $mes = eMessage::getInstance(); + $mes = e107::getMessage(); - if($sql -> db_Update("user", "user_forums='0'")) + /*if($sql -> db_Update("user", "user_forums='0'")) // deprecated in 0.8 { $mes->add("Setting all user_forums to 0.", E_MESSAGE_SUCCESS); - } + }*/ } function uninstall_post($var) { $sql = e107::getDb(); - $mes = eMessage::getInstance(); + $mes = e107::getMessage(); - if($sql -> db_Update("user", "user_forums='0'")) +/* if($sql -> db_Update("user", "user_forums='0'")) // deprecated in 0.8 { $mes->add("Setting all user_forums to 0.", E_MESSAGE_SUCCESS); - } + }*/ } function upgrade_post($var) { $sql = e107::getDb(); - $mes = eMessage::getInstance(); + $mes = e107::getMessage(); if(version_compare($var['current_plug']['plugin_version'], "1.2", "<")) { diff --git a/e107_plugins/forum/plugin.xml b/e107_plugins/forum/plugin.xml index 334127bdb..314f82bb2 100755 --- a/e107_plugins/forum/plugin.xml +++ b/e107_plugins/forum/plugin.xml @@ -1,5 +1,5 @@ - + This plugin is a fully featured Forum system @@ -12,7 +12,7 @@ Preferences - Forum + Forum 1 diff --git a/e107_plugins/gsitemap/plugin.xml b/e107_plugins/gsitemap/plugin.xml index 3f205a11d..27110591a 100644 --- a/e107_plugins/gsitemap/plugin.xml +++ b/e107_plugins/gsitemap/plugin.xml @@ -1,5 +1,5 @@ - + GSLAN_41 @@ -11,7 +11,7 @@ Configure Sitemap - Sitemap + Sitemap diff --git a/e107_plugins/links_page/plugin.xml b/e107_plugins/links_page/plugin.xml index 2e71cab22..406f3f329 100644 --- a/e107_plugins/links_page/plugin.xml +++ b/e107_plugins/links_page/plugin.xml @@ -1,6 +1,6 @@ - + @@ -14,7 +14,7 @@ Configure Links Page - Links + Links diff --git a/e107_plugins/list_new/plugin.xml b/e107_plugins/list_new/plugin.xml index d0b3ce69e..92615c945 100644 --- a/e107_plugins/list_new/plugin.xml +++ b/e107_plugins/list_new/plugin.xml @@ -1,6 +1,6 @@ - + @@ -13,7 +13,7 @@ LIST_PLUGIN_3 - LIST_PLUGIN_5 + LIST_PLUGIN_5 diff --git a/e107_plugins/log/plugin.xml b/e107_plugins/log/plugin.xml index 5372ff077..a68ffd136 100644 --- a/e107_plugins/log/plugin.xml +++ b/e107_plugins/log/plugin.xml @@ -1,5 +1,5 @@ - + ADSTAT_L1 @@ -10,7 +10,7 @@ ADSTAT_L33 - ADSTAT_L34 + ADSTAT_L34 0 diff --git a/e107_plugins/newsfeed/plugin.xml b/e107_plugins/newsfeed/plugin.xml index 635b9ce91..3bb823d7d 100644 --- a/e107_plugins/newsfeed/plugin.xml +++ b/e107_plugins/newsfeed/plugin.xml @@ -1,7 +1,7 @@ - + @@ -15,7 +15,7 @@ Configure Newsfeeds - Newsfeeds + Newsfeeds diff --git a/e107_plugins/tagwords/plugin.xml b/e107_plugins/tagwords/plugin.xml index 5fa1f6566..3b8b7682d 100644 --- a/e107_plugins/tagwords/plugin.xml +++ b/e107_plugins/tagwords/plugin.xml @@ -1,5 +1,5 @@ - + A fully featured Tagword system @@ -8,6 +8,6 @@ Configure Tagwords - Tagwords + Tagwords \ No newline at end of file