예제 #1
0
 protected function appendSource($wrapper, $source, $language = 'xml')
 {
     $bitter = new Bitter(false);
     $bitter->loadFormat('symphony');
     $bitter->loadLanguage($language);
     $inner = new XMLElement('div', $bitter->process($source));
     $inner->setAttribute('id', 'source');
     $wrapper->appendChild($inner);
 }
예제 #2
0
function display($file)
{
    global $bitter;
    if (isset($_REQUEST['file']) and $_REQUEST['file'] != $file) {
        return;
    }
    $language = array_pop(explode('.', $file));
    $data = file_get_contents('./examples/files/' . $file);
    if (!$bitter) {
        $bitter = new Bitter();
        $bitter->loadFormat('tabsize-4');
    }
    $bitter->loadLanguage($language);
    echo '<p><a href="?file=', $file, '">', $file, '</a></p>';
    try {
        $source = $bitter->process($data);
        echo '<pre class="language-', $language, '">', $source, '</pre>';
    } catch (Exception $error) {
        $message = $error->getMessage() . "\n\n" . $error->getTraceAsString();
        echo '<pre>', Bitter::encode($message), '</pre>';
    }
}
예제 #3
0
 protected function appendSource(DOMElement $wrapper, $source, $language = 'xml')
 {
     $bitter = new Bitter(true);
     $bitter->loadFormat('symphony');
     $bitter->loadLanguage($language);
     $inner = $this->document->createElement('div');
     $inner->setAttribute('id', 'source');
     $source = $bitter->process($source);
     // Encode special characters:
     // TODO: Find a better way. Not urgent.
     $source = str_replace(array("", "", "", "", ""), '', $source);
     libxml_use_internal_errors(false);
     $fragment = $this->document->createDocumentFragment();
     $fragment->appendXML($source);
     $inner->appendChild($fragment);
     $wrapper->appendChild($inner);
     return $inner;
 }
 protected function appendSource(XMLElement $wrapper, $source, $language = 'xml')
 {
     $bitter = new Bitter();
     $bitter->loadFormat('symphony');
     $bitter->loadLanguage($language);
     $inner = new XMLElement('div', $bitter->process($source));
     $inner->setAttribute('id', 'source');
     $wrapper->appendChild($inner);
     if ($this->_view == 'xml') {
         $viewRaw = Widget::Anchor('', '?debug=raw');
         $viewRaw->setAttribute('id', 'type');
         $viewRaw->appendChild(new XMLElement('span', __('Plain XML')));
         $wrapper->appendChild($viewRaw);
     }
 }
<?php

//------------------------------------------------------------------------------
chdir('../');
require_once './bitter.php';
//------------------------------------------------------------------------------
header('content-type: text/plain; charset=utf8', true, 500);
try {
    $bitter = new Bitter();
    $bitter->loadLanguage($_REQUEST['language']);
    $bitter->loadFormat($_REQUEST['format']);
    $source = $bitter->process(stripslashes($_REQUEST['source']));
    header('content-type: text/plain; charset=utf8', true, 200);
    echo $source;
} catch (Exception $error) {
    if (isset($_REQUEST['debug']) and $_REQUEST['debug'] == 'true') {
        $message = $error->getMessage() . "\n\n" . $error->getTraceAsString();
        echo Bitter::encode($message);
    }
}
//------------------------------------------------------------------------------