Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
- Pages are now stored with an extra metadata field called page_format which is "wikitext" or "xhtml"
- New $flags parameter + RENDER_* constants added that control RenderMan::render() behavior
- Several other changes:
* Added a sprite API for Javascript and made editor use sprites when possible
* Removed a number of config options from the default install schema, replaced with second parameter to getConfig() calls
* MessageBox in editor mostly replaced with miniPrompt
* A few bugfixes related to password changes (registration didn't even work)
* Rewrote the bitfield compression algorithm used to serialize allowed MIME types
* Fixed some typos in language files and strings
* Fixed a Text_Wiki bug in Heading parser
<?php
/*
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
* Version 1.1.6 (Caoineag beta 1)
* output.php - Controls output format, messages of death, that kind of stuff
* Copyright (C) 2006-2008 Dan Fuhry
*
* This program is Free Software; you can redistribute 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 details.
*/
/**
* Abstract class to define how output handlers should act.
* @package Enano
* @subpackage UI
*/
abstract class Output_Base
{
/**
* Page title
* @var string
*/
public $title = 'Untitled';
/**
* To allow scripts to determine whether we are outputting headers or not.
* @var bool
*/
public $naked = false;
/**
* Added content
* @var string
* @var string
* @var string
* @var string
*/
public $before_header = '', $after_header = '', $before_footer = '', $after_footer = '';
/**
* Call this to send content headers (e.g. the first third of the document if HTML) in place of $template->header().
* @access public
*/
abstract public function header();
/**
* Call this to send extra stuff after the content (equivalent of $template->footer()).
* @access public
*/
abstract public function footer();
/**
* Add some code just before the header.
* @access public
*/
public function add_before_header($code)
{
$this->before_header .= $code;
}
/**
* Add some code just after the header.
* @access public
*/
public function add_after_header($code)
{
$this->after_header .= $code;
}
/**
* Add some code just before the footer.
* @access public
*/
public function add_before_footer($code)
{
$this->before_footer .= $code;
}
/**
* Add some code just after the footer.
* @access public
*/
public function add_after_footer($code)
{
$this->after_footer .= $code;
}
/**
* Send any required HTML headers through, e.g. Content-type.
* @access public
*/
public function http_headers()
{
header('Content-type: text/html');
}
/**
* Set the title of the page being output.
* @param string Page name
*/
public function set_title($title)
{
$this->title = $title;
}
/**
* Avoid sending things out of order.
* @var bool
* @var bool
*/
public $headers_sent = false, $footers_sent = false;
}
/**
* HTML outputter.
*/
class Output_HTML extends Output_Base
{
public function header()
{
if ( $this->headers_sent )
return;
$this->headers_sent = true;
ob_start();
}
public function footer()
{
global $template;
if ( !$this->headers_sent )
return;
$this->headers_sent = false;
$content = ob_get_contents();
ob_end_clean();
ob_start();
echo $this->before_header;
echo $template->getHeader();
echo $this->after_header;
echo $content;
echo $this->before_footer;
echo $template->getFooter();
echo $this->after_footer;
}
public function set_title($title)
{
global $template;
$template->assign_vars(array(
'PAGE_NAME' => $title
));
}
}
/**
* Outputter that bypasses $template->header() and $template->footer(), but still shows HTML added via {before,after}_{header,footer}.
*/
class Output_Striptease extends Output_HTML
{
public function header()
{
echo $this->before_header;
echo $this->after_header;
}
public function footer()
{
echo $this->before_footer;
echo $this->after_footer;
}
}
/**
* Outputter that bypasses $template->header() and $template->footer().
*/
class Output_Naked extends Output_HTML
{
public $naked = true;
public function header()
{
}
public function footer()
{
}
}
/**
* Safe template outputter
*/
class Output_Safe
{
protected $template;
protected $headers_sent = false;
public function __construct()
{
$this->template = new template_nodb();
$theme = ( defined('ENANO_CONFIG_FETCHED') ) ? getConfig('theme_default') : 'oxygen';
$style = ( defined('ENANO_CONFIG_FETCHED') ) ? '__foo__' : 'bleu';
$this->template->load_theme($theme, $style);
$this->template->tpl_strings['SITE_NAME'] = getConfig('site_name');
$this->template->tpl_strings['SITE_DESC'] = getConfig('site_desc');
$this->template->tpl_strings['COPYRIGHT'] = getConfig('copyright_notice');
$this->template->tpl_strings['PAGE_NAME'] = 'Untitled';
}
public function header()
{
if ( $this->headers_sent )
return;
$this->headers_sent = true;
$this->template->header();
}
public function footer()
{
global $template;
if ( !$this->headers_sent )
{
$this->template->header();
}
$this->headers_sent = false;
$this->template->footer();
}
public function set_title($title)
{
$this->template->tpl_strings['PAGE_NAME'] = $title;
}
}
?>