file: NP_AdminPreview.php
<?php class NP_AdminPreview extends NucleusPlugin { function getName() { return 'AdminPreview'; } function getAuthor() { return 'Kai Greve'; } function getURL() { return 'http://kgblog.de/'; } function getVersion() { return '0.2'; } function getDescription() { return 'Shows a preview of an item in a popup window'; } function install() { } function getEventList() { return array('AddItemFormExtras', 'EditItemFormExtras'); } function unInstall() { } function buttonCode($_data) { global $CONF; return "<input type=\"button\" value=\"Preview\" onclick=\"javascript: p=window.open ('".$CONF['PluginURL']."adminpreview/preview.php', 'preview', 'width=500,height=400, scrollbars=yes'); p.focus(); return false;\"> Don't forget to save!"; } function event_AddItemFormExtras($_data) { echo $this->buttonCode($_data); } function event_EditItemFormExtras($_data) { echo $this->buttonCode($_data); } function supportsFeature ($what) { switch ($what) { case 'SqlTablePrefix': return 1; default: return 0; } } } ?>
file: adminpreview/preview.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Preview</title> <meta http-equiv="content-type" content="text/xml; charset=ISO-8859-1" /> <meta http-equiv='Pragma' content='no-cache' /> <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' /> <meta http-equiv='Expires' content='-1' /> <link rel="stylesheet" type="text/css" href="preview.css" /> <script type="text/javascript" src="../../javascript/edit.js"></script> </head> <body> <div id="wrapper_outer"> <div id="wrapper_inner"> <h1 id="previewtitle"></h1> <div id="previewbody"></div> <div><br /></div> <div id="previewmore"></div> <script type="text/javascript"> window.document.getElementById('previewtitle').innerHTML=window.opener.document.getElementById('inputtitle').value; setConvertBreaks(window.opener.nucleusConvertBreaks); setMediaUrl(window.opener.nucleusMediaURL); setAuthorId(window.opener.nucleusAuthorId); preview ('previewbody', window.opener.document.getElementById('inputbody').value); preview ('previewmore', window.opener.document.getElementById('inputmore').value); </script> </div> </div> <div id="close"> <a href="javascript:window.close();">Close Window</a> </div> </body> </html>
file: adminpreview/preview.css
/* preview.css for NP_AdminPreview */ body { margin: 0; padding: 0; } body, td, th, li, ul { font-family: "Trebuchet MS", "Bitstream Vera Sans", verdana, lucida, arial, helvetica, sans-serif; font-size: small; color: #000; background-color: #fff; } #wrapper_outer { margin: 10px 10px 0 10px; padding: 0 10px 10px 10px; border: solid 1px #c0c0c0; } #wrapper_inner { width: 100%; } h1 { width: 100%; font-size: 100%; border-bottom: solid 1px #c0c0c0; } #close { clear: both; text-align: center; font-family: sans-serif; font-size: 90%; font-weight: bold; margin: 0 20px 10px 0; }