<?php /* * NP_Documentation * * Nucleus CMS is shipped with a online documentation. NP_Documentation * embeds the inbuilt documentation into the admin area. * * History: * * v0.01 2007-08-10 Kai Greve (http://kgblog.de): * - initial release * * * Licence: * * This program is free software and open source software; you can redistribute * it and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit * http://www.gnu.org/licenses/gpl.html * */ class NP_Documentation extends NucleusPlugin { function getName() { return 'NP_Documentation'; } function getAuthor() { return 'Kai Greve'; } function getURL() { return 'http://kgblog.de/'; } function getVersion() { return '0.1'; } function getDescription() { return 'NP_Documentation embeds the documentation which is shipped with Nucleus CMS into the admin area. '; } function install() { $this->createOption("quickmenu", "Show in quick menu?", "yesno", "yes"); } function event_QuickMenu(&$data) { global $manager; if ($this->getOption('quickmenu') != 'yes') return; array_push( $data['options'], array( 'title' => 'Documentation', 'url' => $manager->addTicketToUrl($this->getAdminURL()), 'tooltip' => 'Inbuild documentation' ) ); } function getEventList() { return array('QuickMenu', 'AdminPrePageHead'); } function supportsFeature($what) { switch ($what) { case 'SqlTablePrefix': return 1; default: return 0; } } function event_AdminPrePageHead(&$data) { global $CONF; // add styles for the documentation pages only if needed if (strpos (serverVar('REQUEST_URI'), 'documentation')) { // Hint: $data['extrahead'] should be appended not overwritten // use $data['extrahead'].= instead of $data['extrahead'] // otherwise the baseUrl is changed and the Quickmenu doesn't work // add plugins own style for the page navigation $style = $CONF['PluginURL'].'documentation'.'/docplug.css'; $data['extrahead'].='<link rel="stylesheet" title="" type="text/css" href="'.$style.'" />'."\n"; // add the rewritten Nucleus documentation style $style = $CONF['PluginURL'].'documentation'.'/manualcss.php'; $data['extrahead'].='<link rel="stylesheet" title="" type="text/css" href="'.$style.'" />'."\n"; } } function hasAdminArea() { return 1; } } ?>
<?php // if your 'plugin' directory is not in the default location, // edit this variable to point to your site directory // (where config.php is) $strRel = '../../../'; include($strRel . 'config.php'); // check if member is logged in if (!$member->isLoggedIn()) doError('You\'re not logged in.'); // include PLUGINADMIN vlass include($DIR_LIBS . 'PLUGINADMIN.php'); // create the admin area page $oPluginAdmin = new PluginAdmin('Documentation'); $oPluginAdmin->start(); // header echo '<h2>Documentation</h2>'; global $CONF; $self= $CONF['PluginURL'].'documentation/index.php'; // wrapper for navigation buttons $wrapper_start = '<div class="page_button">'; $wrapper_end = '</div>'; // navigation echo '<div class="navline">'; echo '<strong>Documents: </strong>'; echo $wrapper_start.'<a href="'.$self.'?file=index">Index</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=skins">Skins</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=tips">Tips</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=history">History</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=help">Help</a>'.$wrapper_end; echo '</div>'; echo '<div class="navline">'; echo '<strong>Developer Docs: </strong>'; echo $wrapper_start.'<a href="'.$self.'?file=devdocs/index">Index</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=devdocs/custominstall">Custom install</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=devdocs/sqltables">SQL tables</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=devdocs/plugins">Plugins</a>'.$wrapper_end; echo $wrapper_start.'<a href="'.$self.'?file=devdocs/xmlrpc">XML-RPC</a><br />'.$wrapper_end; echo '</div>'; echo '<br />'; // allow only documentation files switch ($_GET['file']) { case 'tips': $filename='tips.html'; break; case 'index': $filename='index.html'; break; case 'history': $filename='history.html'; break; case 'skins': $filename='skins.html'; break; case 'help': $filename='help.html'; break; case 'devdocs/index': $filename='devdocs/index.html'; break; case 'devdocs/custominstall': $filename='devdocs/custominstall.html'; break; case 'devdocs/sqltables': $filename='devdocs/sqltables.html'; break; case 'devdocs/plugins': $filename='devdocs/plugins.html'; break; case 'devdocs/xmlrpc': $filename='devdocs/xmlrpc.html'; break; default: $filename='index.html'; break; } // read the requested file $content = file_get_contents($strRel.'nucleus/documentation/'.$filename); // replace all content outside the body tag and the body tags itself $content = substr_replace($content, '', 0, strpos($content, '<body>')); $content = substr_replace($content, '', strpos($content, '</body>'), -1); // replace one bracket which is left at the end $content = substr($content,0,strlen($content)-1); // reduce the header level $content = str_replace('<h2>', '<h3>', $content); $content = str_replace('</h2>', '</h3>', $content); $content = str_replace('<h1>', '<h2>', $content); $content = str_replace('</h1>', '</h2>', $content); // correct the path to the icon-up.gif $content = str_replace('icon-up.gif', 'documentation/icon-up.gif', $content); // previous correction should also work in the subfolder devdocs $content = str_replace('../documentation/icon-up.gif', 'documentation/icon-up.gif', $content); // correct the path for pictures in the folder pics $content = str_replace('pics/', 'documentation/pics/', $content); // evaluate if we are currently in the subdirectory devdocs if (is_numeric(strpos($_GET['file'], 'devdocs'))) { $prefix='devdocs/'; } else { $prefix=''; } // correct all internal links between the documents $content = preg_replace('/(\<a href\=\")([a-z\/]*)(\.html)(#[a-z-_]*)?(\")/Ui', '\1plugins/documentation/index.php?file='.$prefix.'\2\4\5', $content); // evaluate the path of the own page $self = serverVar('REQUEST_URI'); // correct links $content = preg_replace('/(\<a href\=\")(#[a-z-_]*)(\")/Ui', '\1'.$self.'\2\3', $content); // add own page path to top anchors // (not matched because of the class definition in the links) $content = str_replace('href="#top"', 'href="'.$self.'#top"', $content); // wrap content into a div $content = "\n".'<!-- start --><a name="top"></a><div id="manual" style="border:solid 1px #c0c0c0; padding:10px 6px;">'."\n".$content."\n".'</div><!-- end -->'; // footer for the manual page $original = $CONF['IndexURL'].'nucleus/documentation/'.$filename; $content .= "\n".'<div id="manual_footer"><div id="manual_footer_left"><em> URL of the original document: </em><a href="'.$original.'">'.$filename.'</a></div><div id="manual_footer_right"><a href="'.$self.'#top">Back to top</a></div></div>'; // output content of the manual page echo $content; $oPluginAdmin->end(); ?>
/* CSS for the Nucleus plugin NP_Documentation */ .page_button { display:inline; padding: 2px 4px; margin: 2px; border: solid 1px #c0c0c0; background-color: #f8f8f8; } .navline { padding:4px; margin:4px 0; } #manual_footer { margin:4px 0px; border:solid 1px #c0c0c0; text-align:right; } #manual_footer_left { text-align:left; float:left; } #manual_footer_right { display:inline; margin-right:4px; }
<?php /* Part of NP_Documentation * manualcss.php changes the manual.css to work in the admin area * and add some indivdual styles from the documentation globally */ $strRel = '../../../'; $content = file_get_contents($strRel.'nucleus/documentation/styles/manual.css'); header('Content-type: text/css'); // decrease header levels $content = str_replace('h2', 'h3',$content); $content = str_replace('h1', 'h2',$content); // add id manual to all style definitions $content = preg_replace('/([a-z0-9,:@\. ]*)({)/Ui', '#manual \1\2', $content); $content .="\n\n"; // add extra style for plugin events $content .= <<<EOT /* refence parameters (greenish) */ .ref { background-color: #afa; color: #000; } /* object parameters */ .obj { color: #00f; } .obj:after { content: " (object)"; } /* read-only parameters (non-ref; reddish) */ .ro { background-color: #faa; color: #000; } EOT; // add extra style for the sql tables $content .= <<<EOT /* auto increment table columns*/ .autoinc { } /* primary-keys */ .primary { text-decoration: underline; font-weight: bold; } /* NOT NULL */ .notnull { } /* unique key */ .unique { } /* foreign keys */ .foreign { font-style: italic; } /* auto increment table columns*/ .autoinc { } /* fulltext index */ .fulltext { } /* columns/tables to remove in later versions */ .toremove { color: red; } EOT; // quick and dirty solution to get white borders for tables // that are lost in the previous CSS $content .= <<<EOT /* white borders for the table cells */ #manual table td, th { border:solid 2px white; } EOT; // layout improvements $content .= <<<EOT /* change styles for class heading */ #manual .heading { padding-top:2px; padding-bottom:2px; } #manual .heading i { position: relative; top: 0px; right: 0px; } EOT; echo $content; ?>