コード例 #1
0
function pico_textwiki($mydirname, $text, $content4assign)
{
    // add XOOPS_TRUST_PATH/PEAR/ into include_path
    if (!defined('PATH_SEPARATOR')) {
        define('PATH_SEPARATOR', DIRECTORY_SEPARATOR == '/' ? ':' : ';');
    }
    if (!strstr(ini_get('include_path'), XOOPS_TRUST_PATH . '/PEAR')) {
        ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . XOOPS_TRUST_PATH . '/PEAR');
    }
    include_once "Text/Wiki.php";
    // include_once "Text/sunday_Wiki.php";
    if (!class_exists('Text_Wiki')) {
        die('PEAR/Text/Wiki is not installed correctly');
    }
    $wiki = new Text_Wiki();
    // create instance
    // Configuration
    $wiki->deleteRule('Wikilink');
    // remove a rule for auto-linking
    $wiki->setFormatConf('Xhtml', 'translate', false);
    // HTML_ENTITIES -> HTML_SPECIALCHARS -> false
    // $wiki = new sunday_Text_Wiki(); // create instance
    //$text = str_replace ( "\r\n", "\n", $text );
    //$text = str_replace ( "~\n", "[br]", $text );
    //$text = $wiki->transform($text);
    //$content = str_replace ( "[br]", "<br/>", $text );
    // special thx to minahito! you are great!!
    return $wiki->transform($text);
}
コード例 #2
0
ファイル: Text.php プロジェクト: bersace/strass
 function __construct($text = '', $preformated = false)
 {
     parent::__construct();
     $this->text = $text;
     $this->preformated = $preformated;
     if (!self::$const_tw) {
         self::$const_tw = $tw = new Text_Wiki();
         // Désactivation de certaine fonctionnalité peu sécurisé ou utiles dans
         // le cadre d'un wiki uniquement.
         $disable = array('phplookup', 'interwiki', 'wikilink', 'freelink', 'bold', 'italic', 'embed', 'include', 'toc');
         foreach ($disable as $rule) {
             $tw->disableRule($rule);
         }
         $enable = array('code', 'translatehtml');
         foreach ($enable as $rule) {
             $tw->enableRule($rule);
         }
         // Ajouter la gestion des url relative.
         $options = array('/', './', '../', 'http://', 'https://', 'ftp://', 'gopher://', 'news://', 'file://', 'irc://', 'mailto:', 'xmpp:', 'tel:');
         $tw->setParseConf('Url', 'schemes', $options);
         //$tw->setFormatConf('Xhtml', 'charset', 'utf-8');
         $tw->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
         $tw->setRenderConf('Xhtml', 'image', 'base', './');
     }
     $this->tw = clone self::$const_tw;
 }
 /**
  * Executes show action
  *
  * @param sfRequest $request A request object
  */
 public function executeShow($request)
 {
     //$this->form = new CommunityWikiCommentForm();
     $libPath = realpath(dirname(__FILE__) . "/../vendor/Text_Wiki");
     $oldPath = get_include_path();
     set_include_path($oldPath . ":" . $libPath);
     require_once "Text/Wiki.php";
     $wiki = new Text_Wiki();
     $wiki->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
     // bodyの内容をパース後の内容に置換
     $this->communityWiki->body = $wiki->transform($this->communityWiki->getBody());
     return sfView::SUCCESS;
 }
コード例 #4
0
ファイル: ICS.php プロジェクト: bersace/strass
 protected function _preRender($controller)
 {
     $page = Zend_Registry::get('page');
     $controller->view->ics = new ICS($page->metas->get('DC.Title.alternative'));
     $tw = new Text_Wiki();
     // Désactivation de certaine fonctionnalité peu sécurisé ou utiles dans
     // le cadre d'un wiki uniquement.
     $disable = array('phplookup', 'interwiki', 'wikilink', 'freelink', 'bold', 'italic', 'embed', 'include', 'toc');
     foreach ($disable as $rule) {
         $tw->disableRule($rule);
     }
     $enable = array('html', 'code', 'translatehtml');
     foreach ($enable as $rule) {
         $tw->enableRule($rule);
     }
     // Ajouter la gestion des url relative.
     $options = array('http://', 'https://', 'ftp://', 'gopher://', 'news://', 'irc://', 'file://', 'mailto:', 'xmpp:', './', '../');
     $tw->setParseConf('Url', 'schemes', $options);
     $tw->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
     $tw->setRenderConf('Xhtml', 'image', 'base', './');
     $controller->view->tw = $tw;
 }
コード例 #5
0
ファイル: Feed.php プロジェクト: bersace/strass
 function _preRender($controller)
 {
     $view = $controller->view;
     $p = Zend_Registry::get('page');
     $m = $p->metas;
     $view->feed = array('title' => $m->get('DC.Title'), 'link' => $view->url(array('format' => 'html'), false, true), 'charset' => 'UTF-8', 'language' => 'fr', 'entries' => array());
     $tw = new Text_Wiki();
     // Désactivation de certaine fonctionnalité peu sécurisé ou utiles dans
     // le cadre d'un wiki uniquement.
     $disable = array('phplookup', 'interwiki', 'wikilink', 'freelink', 'bold', 'italic', 'embed', 'include', 'toc');
     foreach ($disable as $rule) {
         $tw->disableRule($rule);
     }
     $enable = array('html', 'code', 'translatehtml');
     foreach ($enable as $rule) {
         $tw->enableRule($rule);
     }
     // Ajouter la gestion des url relative.
     $options = array('http://', 'https://', 'ftp://', 'gopher://', 'news://', 'irc://', 'file://', 'mailto:', 'xmpp:', './', '../');
     $tw->setParseConf('Url', 'schemes', $options);
     $tw->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
     $tw->setRenderConf('Xhtml', 'image', 'base', './');
     $view->tw = $tw;
 }
コード例 #6
0
ファイル: gltext.class.php プロジェクト: milk54/geeklog-japan
 /**
  * Convert wiki-formatted text to (X)HTML
  *
  * @param    string  $wikitext   wiki-formatted text
  * @return   string              XHTML formatted text
  *
  */
 public static function renderWikiText($wikitext)
 {
     global $_CONF;
     if (!$_CONF['wikitext_editor']) {
         return $wikitext;
     }
     require_once 'Text/Wiki.php';
     $wiki = new Text_Wiki();
     $wiki->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
     $wiki->setRenderConf('Xhtml', 'charset', COM_getCharset());
     $wiki->disableRule('wikilink');
     $wiki->disableRule('freelink');
     $wiki->disableRule('interwiki');
     return $wiki->transform($wikitext, 'Xhtml');
 }
コード例 #7
0
ファイル: Page.php プロジェクト: raz0rsdge/horde
 public function getProcessor($output_format = 'Xhtml')
 {
     if (isset($this->_proc)) {
         return $this->_proc;
     }
     $view_url = Wicked::url('%s')->setRaw(true)->add('referrer', $this->pageName());
     $view_url = str_replace(urlencode('%s'), '%s', $view_url);
     /* Create format-specific Text_Wiki object */
     $class = 'Text_Wiki_' . $GLOBALS['conf']['wicked']['format'];
     $this->_proc = new $class();
     /* Use a non-printable delimiter character that is still a valid UTF-8
      * character. See http://pear.php.net/bugs/bug.php?id=12490. */
     $this->_proc->delim = chr(1);
     /* Override rules */
     $this->_proc->insertRule('Heading2', 'Heading');
     $this->_proc->deleteRule('Heading');
     $this->_proc->loadParseObj('Paragraph');
     $skip = $this->_proc->parseObj['Paragraph']->getConf('skip');
     $skip[] = 'heading2';
     $this->_proc->setParseConf('Paragraph', 'skip', $skip);
     if ($GLOBALS['conf']['wicked']['format'] == 'Default' || $GLOBALS['conf']['wicked']['format'] == 'Cowiki' || $GLOBALS['conf']['wicked']['format'] == 'Tiki') {
         $this->_proc->insertRule('Toc2', 'Toc');
     }
     $this->_proc->deleteRule('Toc');
     switch ($output_format) {
         case 'Xhtml':
             if ($GLOBALS['conf']['wicked']['format'] != 'Creole') {
                 $this->_proc->insertRule('Code2', 'Code');
             }
             $this->_proc->deleteRule('Code');
             if ($GLOBALS['conf']['wicked']['format'] == 'BBCode') {
                 $this->_proc->insertRule('Wickedblock', 'Code2');
             } else {
                 $this->_proc->insertRule('Wikilink2', 'Wikilink');
                 $this->_proc->setParseConf('Wikilink2', 'utf-8', true);
                 $this->_proc->insertRule('Wickedblock', 'Raw');
             }
             $this->_proc->deleteRule('Wikilink');
             if ($GLOBALS['conf']['wicked']['format'] == 'Default' || $GLOBALS['conf']['wicked']['format'] == 'Cowiki' || $GLOBALS['conf']['wicked']['format'] == 'Tiki') {
                 $this->_proc->insertRule('Freelink2', 'Freelink');
             }
             $this->_proc->deleteRule('Freelink');
             $this->_proc->insertRule('Image2', 'Image');
             $this->_proc->deleteRule('Image');
             $this->_proc->insertRule('RegistryLink', 'Wickedblock');
             $this->_proc->insertRule('Attribute', 'RegistryLink');
             $this->_proc->deleteRule('Include');
             $this->_proc->deleteRule('Embed');
             $this->_proc->setFormatConf('Xhtml', 'charset', 'UTF-8');
             $this->_proc->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
             $create = $this->allows(Wicked::MODE_CREATE) ? 1 : 0;
             $linkConf = array('pages' => $GLOBALS['wicked']->getPages(), 'view_url' => $view_url, 'new_url' => $create ? $view_url : false, 'new_text_pos' => false, 'css_new' => 'newpage', 'ext_chars' => true);
             $this->_proc->setRenderConf('Xhtml', 'Wikilink2', $linkConf);
             $this->_proc->setRenderConf('Xhtml', 'Freelink2', $linkConf);
             $this->_proc->setRenderConf('Xhtml', 'Toc2', array('title' => '<h2>' . _("Table of Contents") . '</h2>'));
             $this->_proc->setRenderConf('Xhtml', 'Table', array('css_table' => 'horde-table'));
             break;
         case 'Rst':
             require_once __DIR__ . '/Text_Wiki/Render/Rst.php';
             break;
     }
     $autoloader = $GLOBALS['injector']->getInstance('Horde_Autoloader');
     $autoloader->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Text_Wiki_Render_' . $output_format . '/', WICKED_BASE . '/lib/Text_Wiki/Render/' . $output_format));
     $autoloader->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Text_Wiki_Parse/', WICKED_BASE . '/lib/Text_Wiki/Parse/' . $GLOBALS['conf']['wicked']['format']));
     return $this->_proc;
 }
コード例 #8
0
 function contentRender($text, $nohtml, $nosmiley, $nobreaks, $nbsp = 0)
 {
     $myts =& TinyDTextSanitizer::getInstance();
     if ($nohtml >= 16) {
         // db content (PEAR wiki)
         if (!defined('PATH_SEPARATOR')) {
             define('PATH_SEPARATOR', DIRECTORY_SEPARATOR == '/' ? ':' : ';');
         }
         ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . XOOPS_ROOT_PATH . '/common/PEAR');
         include_once 'Text/Wiki.php';
         // include_once "Text/sunday_Wiki.php";
         $wiki = new Text_Wiki();
         // create instance
         // Configuration
         $wiki->deleteRule('Wikilink');
         // remove a rule for auto-linking
         $wiki->setFormatConf('Xhtml', 'translate', false);
         // remove HTML_ENTITIES
         // $wiki = new sunday_Text_Wiki(); // create instance
         //$text = str_replace ( "\r\n", "\n", $text );
         //$text = str_replace ( "~\n", "[br]", $text );
         //$text = $wiki->transform($text);
         //$content = str_replace ( "[br]", "<br/>", $text );
         // special thx to minahito! you are great!!
         $content = $wiki->transform($text);
         if ($nohtml & 2) {
             $content = $myts->displayTarea($content, 1, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
         }
     } else {
         if ($nohtml >= 8) {
             // db content (PHP)
             ob_start();
             eval($text);
             $content = ob_get_contents();
             ob_end_clean();
             if ($nohtml & 2) {
                 $content = $myts->displayTarea($content, 1, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
             }
         } else {
             if ($nohtml < 4) {
                 //			echo "go...".$nohtml;
                 switch ($nohtml) {
                     case 0:
                         // HTML with BB
                         $content = $myts->displayTarea($text, 1, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
                         break;
                     case 1:
                         // Text with BB
                         $content = $myts->displayTarea($text, 0, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
                         break;
                     case 2:
                         // HTML without BB
                         //					$content = '<pre>'.$text.'</pre>';
                         $content = $myts->displayTarea($text, 1, !$nosmiley, 0, 1, !$nobreaks, $nbsp);
                         break;
                     case 3:
                         // Text without BB
                         $content = $myts->makeTboxData4Show($text);
                         break;
                 }
             } else {
                 $content = $text;
             }
         }
     }
     //echo "in=".$text;
     //echo "out=".$content;
     return $content;
 }
コード例 #9
0
    $fp = fopen("../language/english/text_wiki_sample.wiki", 'r');
}
$wiki_source = fread($fp, 65536);
fclose($fp);
if (!defined('PATH_SEPARATOR')) {
    define('PATH_SEPARATOR', DIRECTORY_SEPARATOR == '/' ? ':' : ';');
}
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(dirname(dirname(dirname(__FILE__)))) . '/common/PEAR');
include_once "Text/Wiki.php";
// include_once "Text/sunday_Wiki.php";
$wiki = new Text_Wiki();
// create instance
// Configuration
$wiki->deleteRule('Wikilink');
// remove a rule for auto-linking
$wiki->setFormatConf('Xhtml', 'translate', false);
// remove HTML_ENTITIES
// $wiki = new sunday_Text_Wiki(); // create instance
//$text = str_replace ( "\r\n", "\n", $text );
//$text = str_replace ( "~\n", "[br]", $text );
//$text = $wiki->transform($text);
//$content = str_replace ( "[br]", "<br/>", $text );
// special thx to minahito! you are great!!
$wiki_body = $wiki->transform($wiki_source);
echo '
	<html>
	<head>
		<title>PEAR::Text_Wiki Sample</title>
		<style>
		body, p, br, td, th {
			font-family: "Lucida Grande", Verdana, Arial, Geneva;