Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-01-12 00:51:57

tmacwrig
Archived Plugin Author
Registered: 2004-03-06
Posts: 204
Website

Simple Plugin Export

Okay, I just put this all together and it works perfectly for me.

The usual no-guarantees kinda thing here, but I can guarantee it wouln’t hurt your db and the changes are undoable.

If you don’t have any current changes to your txp_plugin.php file and you don’t want to go through modifying it, you can just use mine

<pre>

1: Open include/txp_plugin.php

After the line

case “delete”: plugin_delete();break;

ADD

case “export”: export_plugin();break;

After the plugin_form() function, ADD

// ——————————————————————————————- function export_link($name,$linktext) { $out = ‘<a href=“index.php?’; $out .= ‘event=plugin&#38;step=export&#38;’. ‘name=’.urlencode($name).’”’; $out .= ‘>’.$linktext.’</a>’; return $out; }

// ——————————————————————————————- function export_plugin() { $name = gps(‘name’); //translate pagetop(“export plugin”); echo plugin_export_form($name); }

// ——————————————————————————————- function plugin_export_form($name=’‘) { $sub = fInput(‘submit’,’‘,gTxt(‘save’),‘publish’); $plugin[“name”] = $name; $plugin[“author”] = ($name) ? fetch(‘author’,‘txp_plugin’,‘name’,$name) : ‘’; $plugin[“author_uri”] = ($name) ? fetch(‘author_uri’,‘txp_plugin’,‘name’,$name) : ‘’; $plugin[“version”] = ($name) ? fetch(‘version’,‘txp_plugin’,‘name’,$name) : ‘’; $plugin[“description”] = ($name) ? fetch(‘description’,‘txp_plugin’,‘name’,$name) : ‘’; $plugin[“help”] = ($name) ? fetch(‘help’,‘txp_plugin’,‘name’,$name) : ‘’; $plugin[“code”] = ($name) ? fetch(‘code’,‘txp_plugin’,‘name’,$name) : ‘’; $plugin[‘md5’] = md5($plugin[‘code’]); $eplugin = base64_encode(serialize($plugin)); $textarea = ‘<textarea name=“code” rows=“3” cols=“90”>’.$eplugin.’</textarea>’;

return $textarea; }

</pre>

and that’s all.

Notes

  • The export page needs to be translatable
  • It uses too many DB calls – not a big thing, but refinable.

Enjoy, I’m open to suggestions, although tonight, I’ll be flooded with college essays.

Offline

Board footer

Powered by FluxBB