Ejemplo n.º 1
0
 static function render_page($str)
 {
     if ($str == "") {
         return "";
     }
     if (!class_exists("Text_Wiki", false)) {
         require "lib/wiki/Wiki.php";
     }
     $wiki = new Text_Wiki();
     $wiki->disableRule("Interwiki");
     $wiki->disableRule("Image");
     return str_replace("<p>", "<p style='padding-bottom:16px;'>", $wiki->transform($str, "Xhtml"));
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 function getParsedDescription()
 {
     if (empty($this->pkg_description)) {
         return '';
     }
     // Switching markup types
     switch ($this->markup) {
         case 'wiki':
             include_once 'Text/Wiki.php';
             $wiki = new Text_Wiki();
             $wiki->disableRule('wikilink');
             $description = $wiki->transform($this->pkg_description);
             break;
         case 'bbcode':
         default:
             include_once 'HTML/BBCodeParser.php';
             $bbparser = new HTML_BBCodeParser(array('filters' => 'Basic,Images,Links,Lists,Extended'));
             $description = $bbparser->qparse(nl2br(htmlentities($this->pkg_description)));
             break;
     }
     return $description;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 /**
  * 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');
 }
Ejemplo n.º 7
0
 public function resetWiki()
 {
     // initialize wiki engine with default values
     $wiki = new Text_Wiki();
     $viewUrl = "/%s";
     $wiki->setRenderConf($this->transformationFormat, 'freelink', 'view_url', $viewUrl);
     $wiki->setRenderConf($this->transformationFormat, 'freelink', 'new_url', $viewUrl);
     $wiki->setRenderConf($this->transformationFormat, 'url', 'images', false);
     $wiki->setRenderConf($this->transformationFormat, 'freelink', 'new_text', '');
     $wiki->setRenderConf($this->transformationFormat, 'freelink', 'css_new', 'newpage');
     $wiki->setRenderConf($this->transformationFormat, 'table', 'css_table', 'wiki-content-table');
     $wiki->setRenderConf($this->transformationFormat, 'freelink', 'exists_callback', 'wikiPageExists');
     $interWikis = array('wikipedia' => 'http://en.wikipedia.org/wiki/%s', 'wikipedia.pl' => 'http://pl.wikipedia.org/wiki/%s', 'pl.wikipedia' => 'http://pl.wikipedia.org/wiki/%s', 'google' => 'http://www.google.com/search?q=%s', 'dictionary' => 'http://dictionary.reference.com/browse/%s');
     // configure the interwiki rule
     $wiki->setRenderConf($this->transformationFormat, 'interwiki', 'sites', $interWikis);
     $wiki->setParseConf('interwiki', 'sites', $interWikis);
     $wiki->disableRule('wikilink');
     $this->wiki = $wiki;
 }