1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

uninstall_options() now included in the _setup.php file. Allowing plugin developers to add their own 'uninstall' options.

This commit is contained in:
CaMer0n
2009-10-30 09:13:37 +00:00
parent 91814acaf7
commit 4e6177f56c
5 changed files with 131 additions and 77 deletions

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_admin/plugin.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
| $Revision: 1.50 $ | $Revision: 1.51 $
| $Date: 2009-10-23 14:16:08 $ | $Date: 2009-10-30 09:13:31 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -211,16 +211,11 @@ class pluginManager{
{ {
$eplug_folder = $plug['plugin_path']; $eplug_folder = $plug['plugin_path'];
$_path = e_PLUGIN.$plug['plugin_path'].'/'; $_path = e_PLUGIN.$plug['plugin_path'].'/';
$eplug_folder = $plug['plugin_path'];
if(file_exists($_path.'plugin.xml')) if(file_exists($_path.'plugin.xml'))
{ {
$options = array( unset($_POST['uninstall_confirm']);
'del_tables' => varset($_POST['delete_tables'],FALSE), $text .= $plugin->install_plugin_xml($this->id, 'uninstall', $_POST); //$_POST must be used.
'del_userclasses' => varset($_POST['delete_userclasses'],FALSE),
'del_extended' => varset($_POST['delete_xfields'],FALSE),
'del_ipool' => varset($_POST['delete_ipool'],FALSE)
);
$text .= $plugin->install_plugin_xml($this->id, 'uninstall', $options);
} }
else else
{ // Deprecated - plugin uses plugin.php { // Deprecated - plugin uses plugin.php
@@ -959,45 +954,87 @@ class pluginManager{
<tr> <tr>
<td>".EPL_ADLAN_55."</td> <td>".EPL_ADLAN_55."</td>
<td>".LAN_YES."</td> <td>".LAN_YES."</td>
</tr>
<tr>
<td>".EPL_ADLAN_57."</td>
<td>".$frm->selectbox('delete_tables','yesno',1)."
<div class='field-help'>".EPL_ADLAN_58."</div>
</td>
</tr>"; </tr>";
$opts = array();
$opts['delete_tables'] = array(
'label' => EPL_ADLAN_57,
'helpText' => EPL_ADLAN_58,
'itemList' => array(1=>LAN_YES,0=>LAN_NO),
'itemDefault' => 1
);
if ($userclasses) if ($userclasses)
{ {
$text .= " <tr> $opts['delete_userclasses'] = array(
<td>".EPL_ADLAN_78."<div class='indent'>".$userclasses."</div></td> 'label' => EPL_ADLAN_78,
<td>".$frm->selectbox('delete_userclasses','yesno',1)." 'preview' => $userclasses,
<div class='field-help'>".EPL_ADLAN_79."</div> 'helpText' => EPL_ADLAN_79,
</td> 'itemList' => array(1=>LAN_YES,0=>LAN_NO),
</tr>"; 'itemDefault' => 1
);
} }
if ($eufields) if ($eufields)
{ {
$text .= " <tr> $opts['delete_xfields'] = array(
<td> 'label' => EPL_ADLAN_80,
".EPL_ADLAN_80."<div class='indent'>".$eufields."</div> 'preview' => $eufields,
</td> 'helpText' => EPL_ADLAN_79,
<td>".$frm->selectbox('delete_xfields','yesno',0)." 'itemList' => array(1=>LAN_YES,0=>LAN_NO),
<div class='field-help'>".EPL_ADLAN_79."</div></td> 'itemDefault' => 0
</tr>"; );
} }
if(e107::getConfig('ipool')->getPref('plugin-'.$plug['plugin_path'])) if(count($icons = e107::getConfig('ipool')->getPref('plugin-'.$plug['plugin_path']))>1)
{ {
$text .= "<tr> foreach($icons as $key=>$val)
<td>Remove icons from icon-pool<div class='indent'>".$eufields."</div> {
</td> $iconText .= "<img src='".$tp->replaceConstants($val)."' alt='' />";
<td>".$frm->selectbox('delete_ipool','yesno',1)."
<div class='field-help'>".EPL_ADLAN_79."</div></td>
</tr>";
} }
$opts['delete_ipool'] = array(
'label' =>'Remove icons from icon-pool',
'preview' => $iconText,
'helpText' => EPL_ADLAN_79,
'itemList' => array(1=>LAN_YES,0=>LAN_NO),
'itemDefault' => 1
);
}
if(is_readable(e_PLUGIN.$plug['plugin_path']."/".$plug['plugin_path']."_setup.php"))
{
include_once(e_PLUGIN.$plug['plugin_path']."/".$plug['plugin_path']."_setup.php");
$mes = e107::getMessage();
$mes->add("Loading ".e_PLUGIN.$plug['plugin_path']."/".$plug['plugin_path']."_setup.php", E_MESSAGE_DEBUG);
$class_name = $plug['plugin_path']."_setup";
if(class_exists($class_name))
{
$obj = new $class_name;
if(method_exists($obj,'uninstall_options'))
{
$arr = call_user_func(array($obj,'uninstall_options'), $this);
foreach($arr as $key=>$val)
{
$newkey = $plug['plugin_path']."_".$key;
$opts[$newkey] = $val;
}
}
}
}
foreach($opts as $key=>$val)
{
$text .= "<tr>\n<td class='top'>".$tp->toHTML($val['label'],FALSE,'TITLE');
$text .= varset($val['preview']) ? "<div class='indent'>".$val['preview']."</div>" : "";
$text .= "</td>\n<td>".$frm->selectbox($key,$val['itemList'],$val['itemDefault']);
$text .= varset($val['helpText']) ? "<div class='field-help'>".$val['helpText']."</div>" : "";
$text .= "</td>\n</tr>\n";
}
$text .="<tr> $text .="<tr>
@@ -1018,7 +1055,7 @@ class pluginManager{
</fieldset> </fieldset>
</form> </form>
"; ";
e107::getRender()->tablerender(EPL_ADLAN_63." ".$tp->toHtml($plug_vars['@attributes']['name'], "", "defs,emotes_off, no_make_clickable"), $text); e107::getRender()->tablerender(EPL_ADLAN_63." ".$tp->toHtml($plug_vars['@attributes']['name'], "", "defs,emotes_off, no_make_clickable"),$mes->render(). $text);
} }

View File

@@ -9,8 +9,8 @@
* Text processing and parsing functions * Text processing and parsing functions
* *
* $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.68 $ * $Revision: 1.69 $
* $Date: 2009-10-26 10:55:39 $ * $Date: 2009-10-30 09:13:31 $
* $Author: e107coders $ * $Author: e107coders $
* *
*/ */
@@ -723,7 +723,15 @@ class e_parse
/**
*
* @param string $text
* @param boolean $parseBB [optional]
* @param string $modifiers [optional] TITLE|SUMMARY|DESCRIPTION|BODY|RAW|LINKTEXT etc.
* @param mixed $postID [optional]
* @param boolean $wrap [optional]
* @return
*/
function toHTML($text, $parseBB = FALSE, $modifiers = "", $postID = "", $wrap=FALSE) function toHTML($text, $parseBB = FALSE, $modifiers = "", $postID = "", $wrap=FALSE)
{ {
if ($text == '') return $text; if ($text == '') return $text;

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/plugin_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.108 $ | $Revision: 1.109 $
| $Date: 2009-10-29 13:55:08 $ | $Date: 2009-10-30 09:13:31 $
| $Author: marj_nl_fr $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -309,7 +309,7 @@ class e107plugin
if($plugin && ($function == 'uninstall') ) if($plugin && ($function == 'uninstall') )
{ {
if(vartrue($this->unInstallOpts['del_ipool'], FALSE)) if(vartrue($this->unInstallOpts['delete_ipool'], FALSE))
{ {
$ipool_entry = 'plugin-'.$plugin; $ipool_entry = 'plugin-'.$plugin;
e107::getConfig('ipool')->remove($ipool_entry); // FIXME - ipool removal issue. e107::getConfig('ipool')->remove($ipool_entry); // FIXME - ipool removal issue.
@@ -872,20 +872,18 @@ class e107plugin
return $txt; return $txt;
} }
/**
//---------------------------------------------------------- * Install routine for XML file
// Install routine for XML file * @param object $id (the number of the plugin in the DB)
//---------------------------------------------------------- * @param object $function install|upgrade|uninstall|refresh (adds things that are missing, but doesn't change any existing settings)
// $id - the number of the plugin in the DB * @param object $options [optional] an array of possible options - ATM used only for uninstall:
// Values for $function: * 'delete_userclasses' - to delete userclasses created
// 'install' * 'delete_tables' - to delete DB tables
// 'upgrade' * 'delete_xfields' - to delete extended fields
// 'uninstall' * 'delete_ipool' - to delete icon pool entry
// 'refresh' - adds things that are missing, but doesn't change any existing settings * + any defined in <pluginname>_setup.php in the uninstall_options() method.
// $options is an array of possible options - ATM used only for uninstall: * @return
// 'del_userclasses' - to delete userclasses created */
// 'del_tables' - to delete DB tables
// 'del_extended' - to delete extended fields
function install_plugin_xml($id, $function='', $options = FALSE) function install_plugin_xml($id, $function='', $options = FALSE)
{ {
global $pref; global $pref;
@@ -998,7 +996,7 @@ class e107plugin
case 'refresh' : // Leave things alone case 'refresh' : // Leave things alone
break; break;
case 'uninstall' : case 'uninstall' :
if (varsettrue($options['del_tables'], FALSE)) if (vartrue($options['delete_tables'], FALSE))
{ {
$txt = "Removing table {$ct[1]} <br />"; $txt = "Removing table {$ct[1]} <br />";
$status = $this->manage_tables('remove', array($ct[1])) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; // Delete the table $status = $this->manage_tables('remove', array($ct[1])) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; // Delete the table
@@ -1348,7 +1346,7 @@ class e107plugin
case 'uninstall': //If uninstalling, remove all userclasses (active or inactive) case 'uninstall': //If uninstalling, remove all userclasses (active or inactive)
if (varsettrue($this->unInstallOpts['del_userclasses'], FALSE)) if (varsettrue($this->unInstallOpts['delete_userclasses'], FALSE))
{ {
$status = $this->manage_userclass('remove', $name, $description) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $status = $this->manage_userclass('remove', $name, $description) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add('Removing Userclass: '.$name, $status); $mes->add('Removing Userclass: '.$name, $status);
@@ -1404,7 +1402,7 @@ class e107plugin
case 'uninstall': //If uninstalling, remove all extended fields (active or inactive) case 'uninstall': //If uninstalling, remove all extended fields (active or inactive)
if (varsettrue($this->unInstallOpts['del_extended'], FALSE)) if (varsettrue($this->unInstallOpts['delete_xfields'], FALSE))
{ {
$status = ($this->manage_extended_field('remove', $name, $source)) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $status = ($this->manage_extended_field('remove', $name, $source)) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add('Removing Extended Field: '.$name.' ... ', $status); $mes->add('Removing Extended Field: '.$name.' ... ', $status);
@@ -1854,7 +1852,7 @@ class e107plugin
echo $plugin_path."/".$addon.".php - ".$passfail."<br />"; echo $plugin_path."/".$addon.".php - ".$passfail."<br />";
} }
$mes = e107::getMessage(); $mes = e107::getMessage();
$mes->add('Detected addon: <b>'.$addon.'</b>', E_MESSAGE_DEBUG); // $mes->add('Detected addon: <b>'.$addon.'</b>', E_MESSAGE_DEBUG);
$p_addons[] = $addon; $p_addons[] = $addon;
} }

View File

@@ -1,5 +1,5 @@
/** /**
* $Id: editor_plugin.js,v 1.1 2009-10-12 06:38:01 e107coders Exp $ * $Id: editor_plugin.js,v 1.2 2009-10-30 09:13:36 e107coders Exp $
* *
* @author Moxiecode * @author Moxiecode
* @copyright Copyright <20> 2004-2008, Moxiecode Systems AB, All rights reserved. * @copyright Copyright <20> 2004-2008, Moxiecode Systems AB, All rights reserved.
@@ -43,6 +43,8 @@
s = s.replace(re, str); s = s.replace(re, str);
}; };
// example: <strong> to [b] // example: <strong> to [b]
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"); rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"); rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
@@ -53,7 +55,10 @@
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"); rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"); rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
rep(/<font>(.*?)<\/font>/gi,"$1"); rep(/<font>(.*?)<\/font>/gi,"$1");
rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"); // rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
// rep(/<img.*?style=\"color: ?(.*?);\".*?>(.*?)\/>/gi,"[img style=$1]$2[/img]");
rep(/<img.*?style=\"?(.*?);\".*? src=\"(.*?)\" alt=\"(.*?)\" .*?width=\"(.*?)\".*? .*?height=\"(.*?)\" .*?\/>/gi,"[img style=$1;width:$4px; height:$5;]$2[/img]");
rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"); rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");
rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"); rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"); rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
@@ -110,13 +115,13 @@
rep(/\[\/u\]/gi,"</u>"); rep(/\[\/u\]/gi,"</u>");
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>"); rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>"); rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />"); rep(/\[img.*?\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>"); rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span>&nbsp;"); rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span>&nbsp;");
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span>&nbsp;"); rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span>&nbsp;");
// e107 FIXME! // e107 FIXME!
// rep("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>');
rep(/\[list\]/gi,"<ul>"); rep(/\[list\]/gi,"<ul>");
rep(/\[\/list\]/gi,"</ul>"); rep(/\[\/list\]/gi,"</ul>");

View File

@@ -9,8 +9,8 @@
* Custom TinyMce install/uninstall/update routines * Custom TinyMce install/uninstall/update routines
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/tinymce_setup.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/tinymce_setup.php,v $
* $Revision: 1.2 $ * $Revision: 1.3 $
* $Date: 2009-10-21 12:53:00 $ * $Date: 2009-10-30 09:13:37 $
* $Author: e107coders $ * $Author: e107coders $
* *
*/ */
@@ -27,7 +27,7 @@ class tinymce_setup
function install_post($var) function install_post($var)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$mes = eMessage::getInstance(); $mes = e107::getMessage();
$query = "INSERT INTO #tinymce ( $query = "INSERT INTO #tinymce (
`tinymce_id`, `tinymce_name`, `tinymce_userclass`, `tinymce_plugins`, `tinymce_buttons1`, `tinymce_buttons2`, `tinymce_buttons3`, `tinymce_buttons4`, `tinymce_custom`, `tinymce_prefs`) VALUES `tinymce_id`, `tinymce_name`, `tinymce_userclass`, `tinymce_plugins`, `tinymce_buttons1`, `tinymce_buttons2`, `tinymce_buttons3`, `tinymce_buttons4`, `tinymce_custom`, `tinymce_prefs`) VALUES
@@ -48,9 +48,15 @@ class tinymce_setup
} }
/* /*
function uninstall_options()
{
}
function uninstall_post($var) function uninstall_post($var)
{ {
// $sql = e107::getDb(); // print_a($var);
} }
function upgrade_post($var) function upgrade_post($var)