add('name', PLUGIN_EXTERNALPHP_TITLE); $propbag->add('description', PLUGIN_EXTERNALPHP_TITLE_BLAHBLAH); $propbag->add('event_hooks', array('entries_header' => true, 'entry_display' => true, 'genpage' => true)); $propbag->add('configuration', array('permalink', 'pagetitle', 'include', 'articleformat')); $propbag->add('author', 'Garvin Hicking'); $propbag->add('version', '1.4.1'); $propbag->add('requirements', array( 'serendipity' => '0.7', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES')); $propbag->add('stackable', true); } function introspect_config_item($name, &$propbag) { global $serendipity; switch($name) { case 'permalink': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EXTERNALPHP_PERMALINK); $propbag->add('description', PLUGIN_EXTERNALPHP_PERMALINK_BLAHBLAH); $propbag->add('default', $serendipity['rewrite'] != 'none' ? $serendipity['serendipityHTTPPath'] . 'pages/phpname.html' : $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/pages/phpname.html'); break; case 'include': // THIS IS AN EVIL EVIL PLUGIN. if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) { return false; } $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EXTERNALPHP_INCLUDE); $propbag->add('description', PLUGIN_EXTERNALPHP_INCLUDE_DESC); $propbag->add('default', $serendipity['serendipityPath'] . 'include/your_php.inc.php'); break; case 'pagetitle': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EXTERNALPHP_PAGETITLE); $propbag->add('description', ''); $propbag->add('default', 'phpname'); break; case 'articleformat': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EXTERNALPHP_ARTICLEFORMAT); $propbag->add('description', PLUGIN_EXTERNALPHP_ARTICLEFORMAT_BLAHBLAH); $propbag->add('default', 'true'); break; default: return false; } return true; } function show() { global $serendipity; if ($this->selected()) { $serendipity['content_message'] = ''; // Reset message for 404 error handling which is now overriden if (!headers_sent()) { header('HTTP/1.0 200'); header('Status: 200 OK'); } if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $_ENV['staticpage_pagetitle'] = preg_replace('@[^a-z0-9]@i', '_',$this->get_config('pagetitle')); $serendipity['smarty']->assign('staticpage_pagetitle', $_ENV['staticpage_pagetitle']); if ($this->get_config('articleformat') == TRUE) { echo '

' . $this->get_config('pagetitle') . '

'; } echo '

' . $this->get_config('headline') . '

'; if ($this->get_config('articleformat') == TRUE) { echo '
'; } $include_file = realpath($this->get_config('include')); ob_start(); include $include_file; $content = ob_get_contents(); ob_end_clean(); if ($this->get_config('markup') == TRUE) { $entry = array('body' => $content); serendipity_plugin_api::hook_event('frontend_display', $entry); echo $entry['body']; } else { echo $content; } if ($this->get_config('articleformat') == TRUE) { echo '
'; } } } function selected() { global $serendipity; if ($serendipity['GET']['subpage'] == $this->get_config('pagetitle') || preg_match('@^' . preg_quote($this->get_config('permalink')) . '@i', $serendipity['GET']['subpage'])) { return true; } return false; } function generate_content(&$title) { $title = PLUGIN_EXTERNALPHP_TITLE.' (' . $this->get_config('pagetitle') . ')'; } function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks = &$bag->get('event_hooks'); if (isset($hooks[$event])) { switch($event) { case 'genpage': $args = implode('/', serendipity_getUriArguments($eventData, true)); if ($serendipity['rewrite'] != 'none') { $nice_url = $serendipity['serendipityHTTPPath'] . $args; } else { $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args; } if (empty($serendipity['GET']['subpage'])) { $serendipity['GET']['subpage'] = $nice_url; } break; case 'entry_display': if ($this->selected()) { if (is_array($eventData)) { $eventData['clean_page'] = true; // This is important to not display an entry list! } else { $eventData = array('clean_page' => true); } } if (version_compare($serendipity['version'], '0.7.1', '<=')) { $this->show(); } return true; break; case 'entries_header': $this->show(); return true; break; default: return false; break; } } else { return false; } } } /* vim: set sts=4 ts=4 expandtab : */