1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +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).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
| $Revision: 1.50 $
| $Date: 2009-10-23 14:16:08 $
| $Revision: 1.51 $
| $Date: 2009-10-30 09:13:31 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -211,16 +211,11 @@ class pluginManager{
{
$eplug_folder = $plug['plugin_path'];
$_path = e_PLUGIN.$plug['plugin_path'].'/';
$eplug_folder = $plug['plugin_path'];
if(file_exists($_path.'plugin.xml'))
{
$options = array(
'del_tables' => varset($_POST['delete_tables'],FALSE),
'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);
{
unset($_POST['uninstall_confirm']);
$text .= $plugin->install_plugin_xml($this->id, 'uninstall', $_POST); //$_POST must be used.
}
else
{ // Deprecated - plugin uses plugin.php
@@ -959,45 +954,87 @@ class pluginManager{
<tr>
<td>".EPL_ADLAN_55."</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>";
$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)
{
$text .= " <tr>
<td>".EPL_ADLAN_78."<div class='indent'>".$userclasses."</div></td>
<td>".$frm->selectbox('delete_userclasses','yesno',1)."
<div class='field-help'>".EPL_ADLAN_79."</div>
</td>
</tr>";
{
$opts['delete_userclasses'] = array(
'label' => EPL_ADLAN_78,
'preview' => $userclasses,
'helpText' => EPL_ADLAN_79,
'itemList' => array(1=>LAN_YES,0=>LAN_NO),
'itemDefault' => 1
);
}
if ($eufields)
{
$text .= " <tr>
<td>
".EPL_ADLAN_80."<div class='indent'>".$eufields."</div>
</td>
<td>".$frm->selectbox('delete_xfields','yesno',0)."
<div class='field-help'>".EPL_ADLAN_79."</div></td>
</tr>";
$opts['delete_xfields'] = array(
'label' => EPL_ADLAN_80,
'preview' => $eufields,
'helpText' => EPL_ADLAN_79,
'itemList' => array(1=>LAN_YES,0=>LAN_NO),
'itemDefault' => 0
);
}
if(e107::getConfig('ipool')->getPref('plugin-'.$plug['plugin_path']))
if(count($icons = e107::getConfig('ipool')->getPref('plugin-'.$plug['plugin_path']))>1)
{
$text .= "<tr>
<td>Remove icons from icon-pool<div class='indent'>".$eufields."</div>
</td>
<td>".$frm->selectbox('delete_ipool','yesno',1)."
<div class='field-help'>".EPL_ADLAN_79."</div></td>
</tr>";
foreach($icons as $key=>$val)
{
$iconText .= "<img src='".$tp->replaceConstants($val)."' alt='' />";
}
$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>
@@ -1018,7 +1055,7 @@ class pluginManager{
</fieldset>
</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
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
* $Revision: 1.68 $
* $Date: 2009-10-26 10:55:39 $
* $Revision: 1.69 $
* $Date: 2009-10-30 09:13:31 $
* $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)
{
if ($text == '') return $text;

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.108 $
| $Date: 2009-10-29 13:55:08 $
| $Author: marj_nl_fr $
| $Revision: 1.109 $
| $Date: 2009-10-30 09:13:31 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -309,7 +309,7 @@ class e107plugin
if($plugin && ($function == 'uninstall') )
{
if(vartrue($this->unInstallOpts['del_ipool'], FALSE))
if(vartrue($this->unInstallOpts['delete_ipool'], FALSE))
{
$ipool_entry = 'plugin-'.$plugin;
e107::getConfig('ipool')->remove($ipool_entry); // FIXME - ipool removal issue.
@@ -871,25 +871,23 @@ class e107plugin
$txt .='<br />';
return $txt;
}
//----------------------------------------------------------
// Install routine for XML file
//----------------------------------------------------------
// $id - the number of the plugin in the DB
// Values for $function:
// 'install'
// 'upgrade'
// 'uninstall'
// 'refresh' - adds things that are missing, but doesn't change any existing settings
// $options is an array of possible options - ATM used only for uninstall:
// 'del_userclasses' - to delete userclasses created
// 'del_tables' - to delete DB tables
// 'del_extended' - to delete extended fields
/**
* 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)
* @param object $options [optional] an array of possible options - ATM used only for uninstall:
* 'delete_userclasses' - to delete userclasses created
* 'delete_tables' - to delete DB tables
* 'delete_xfields' - to delete extended fields
* 'delete_ipool' - to delete icon pool entry
* + any defined in <pluginname>_setup.php in the uninstall_options() method.
* @return
*/
function install_plugin_xml($id, $function='', $options = FALSE)
{
global $pref;
$sql = e107::getDb();
$mes = eMessage::getInstance();
@@ -998,7 +996,7 @@ class e107plugin
case 'refresh' : // Leave things alone
break;
case 'uninstall' :
if (varsettrue($options['del_tables'], FALSE))
if (vartrue($options['delete_tables'], FALSE))
{
$txt = "Removing table {$ct[1]} <br />";
$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)
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;
$mes->add('Removing Userclass: '.$name, $status);
@@ -1404,7 +1402,7 @@ class e107plugin
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;
$mes->add('Removing Extended Field: '.$name.' ... ', $status);
@@ -1514,7 +1512,7 @@ class e107plugin
else
{
$setup_file = e_PLUGIN.$this->plugFolder.'/'.$this->plugFolder.'_setup.php';
}
}
if(is_readable($setup_file))
{
@@ -1854,7 +1852,7 @@ class e107plugin
echo $plugin_path."/".$addon.".php - ".$passfail."<br />";
}
$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;
}

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
* @copyright Copyright <20> 2004-2008, Moxiecode Systems AB, All rights reserved.
@@ -42,6 +42,8 @@
function rep(re, str) {
s = s.replace(re, str);
};
// example: <strong> to [b]
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
@@ -53,7 +55,10 @@
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
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=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
@@ -110,13 +115,13 @@
rep(/\[\/u\]/gi,"</u>");
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</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(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span>&nbsp;");
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span>&nbsp;");
// e107 FIXME!
// rep("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>');
rep(/\[list\]/gi,"<ul>");
rep(/\[\/list\]/gi,"</ul>");

View File

@@ -9,8 +9,8 @@
* Custom TinyMce install/uninstall/update routines
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/tinymce_setup.php,v $
* $Revision: 1.2 $
* $Date: 2009-10-21 12:53:00 $
* $Revision: 1.3 $
* $Date: 2009-10-30 09:13:37 $
* $Author: e107coders $
*
*/
@@ -27,7 +27,7 @@ class tinymce_setup
function install_post($var)
{
$sql = e107::getDb();
$mes = eMessage::getInstance();
$mes = e107::getMessage();
$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
@@ -47,10 +47,16 @@ class tinymce_setup
}
}
/*
/*
function uninstall_options()
{
}
function uninstall_post($var)
{
// $sql = e107::getDb();
// print_a($var);
}
function upgrade_post($var)