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);
}
Ejemplo n.º 2
0
function sitewiki_filter_body($body)
{
    $wiki = new Text_Wiki();
    $wiki->setRenderConf('xhtml', 'wikilink', 'view_url', site_prefix() . '/index/sitewiki-app/show.');
    $wiki->setRenderConf('xhtml', 'wikilink', 'new_url', site_prefix() . '/index/sitewiki-app/show.');
    $pages = db_shift_array('select distinct id from sitewiki_page');
    $wiki->setRenderConf('xhtml', 'wikilink', 'pages', $pages);
    return $wiki->transform($body, 'Xhtml');
}
Ejemplo n.º 3
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"));
 }
 /**
  * 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;
 }
Ejemplo n.º 5
0
 function parse($text)
 {
     if (!$this->compatible && false !== ($index = array_search('Compatible', $this->rules))) {
         unset($this->rules[$index]);
     }
     parent::parse($text);
 }
Ejemplo n.º 6
0
 /**
  * Get the Text_Wiki renderer
  *
  * Singleton to get the Text_Wiki instance properly configured for the
  * TIP system. You can specify an array of rules to use in the $rules
  * array, or leave it undefined to use all the available rules.
  *
  * @param  array|null  $rules     The array of rules to enable
  * @param  string|null $toc_title TOC title or null to use a default value
  * @param  string|null $wiki_base Base URI for wiki links
  * @return Text_Wiki              The renderer
  */
 public static function &getWiki($rules = null, $toc_title = null, $wiki_base = '')
 {
     static $renderer = null;
     static $all_rules = array('Prefilter', 'Delimiter', 'Code', 'Function', 'Html', 'Raw', 'Include', 'Embed', 'Anchor', 'Heading', 'Toc', 'Horiz', 'Break', 'Blockquote', 'List', 'Deflist', 'Table', 'Image', 'Phplookup', 'Center', 'Paragraph', 'Url', 'Freelink', 'Interwiki', 'Wikilink', 'Colortext', 'Strong', 'Bold', 'Emphasis', 'Italic', 'Underline', 'Tt', 'Superscript', 'Subscript', 'Revise', 'Tighten');
     static $base_rules = array('Prefilter', 'Break', 'Paragraph', 'Tighten');
     if (is_null($renderer)) {
         require_once 'Text/Wiki.php';
         isset($toc_title) || ($toc_title = TIP::getLocale('index', 'wiki'));
         $renderer =& Text_Wiki::singleton('Default');
         $renderer->disable = array();
         $renderer->setFormatConf('Xhtml', 'charset', 'UTF-8');
         /* According to the following comment:
          * http://php.net/manual/function.htmlentities.php#78509
          * "There's no sane reason to use htmlentities() instead of htmlspecialchars()"
          */
         $renderer->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
         $renderer->setRenderConf('Xhtml', 'url', array('target' => '', 'regexes' => array('|http://picasaweb\\.google\\.com/.*/photo/.*|' => array('TIP_Renderer', 'picasa2PhotoCallback'), '|http://picasaweb\\.google\\.com/.*/albumid/.*|' => array('TIP_Renderer', 'picasa2AlbumCallback'))));
         $renderer->setRenderConf('Xhtml', 'code', array('css' => 'programlisting'));
         $renderer->setRenderConf('Xhtml', 'toc', array('title' => '<p><strong>' . $toc_title . '</strong></p>', 'div_id' => 'idToc', 'use_ul' => true, 'collapse' => false));
         $renderer->setRenderConf('Xhtml', 'freelink', array('pages' => null, 'view_url' => $wiki_base, 'new_text_pos' => null));
     }
     if (is_array($rules)) {
         // Capitalize the $rules values
         $rules = array_map('ucfirst', array_map('strtolower', $rules));
         // Join the forced rules
         $rules = array_merge($rules, $base_rules);
         // Get the real rules to apply
         $rules = array_intersect($all_rules, $rules);
     } else {
         $rules = $base_rules;
     }
     $renderer->rules = $rules;
     return $renderer;
 }
Ejemplo n.º 7
0
 /**
  * Constructor: just adds the path to Creole rules
  *
  * @access public
  * @param array $rules The set of rules to load for this object.
  */
 function Text_Wiki_Creole($rules = null)
 {
     parent::Text_Wiki($rules);
     $this->addPath('parse', $this->fixPath(dirname(__FILE__)) . 'Parse/Creole');
     $this->renderingType = 'char';
     $this->setRenderConf('xhtml', 'center', 'css', 'center');
     $this->setRenderConf('xhtml', 'url', 'target', null);
 }
Ejemplo n.º 8
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.º 9
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.º 10
0
    public function __construct(Sensei_Doc_Toc $toc, array $options = array())
    {
        $defaultOptions = array( 
            'title'    => 'Title',
            'author'   => 'Author',
            'version'  => '',
            'subject'  => 'Subject',
            'keywords' => 'key, word',
            'template' => ''
        );
        
        $this->_options = array_merge($defaultOptions, $this->_options);
            
        $this->setOptions($options);

        $this->_toc = $toc;
        
        $this->_wiki = Text_Wiki::singleton('Doc');
        $this->_wiki->setParseConf('Doclink', 'toc', $this->_toc);
    }
Ejemplo n.º 11
0
function pearwiki_general_parse_data($parser_fmt, &$pParseHash, &$pCommonObject)
{
    global $gBitSystem;
    if (!defined('PAGE_SEP')) {
        define('PAGE_SEP', 'PAGE MARKER HERE*&^%$#^$%*PAGEMARKERHERE');
    }
    $parser = Text_Wiki::singleton($parser_fmt);
    if (PEAR::isError($parser)) {
        $gBitSystem->fatalError("There was an unknown error while constructing the PEAR parser.");
    }
    global $gBitSystem;
    if ($gBitSystem->isPackageActive('wiki')) {
        $parser->setRenderConf('xhtml', 'wikilink', 'exists_callback', array(&$pCommonObject, 'pageExists'));
        $parser->setRenderConf('xhtml', 'wikilink', 'view_url', WIKI_PKG_URL . 'index.php?page=');
        $parser->setRenderConf('xhtml', 'wikilink', 'new_url', WIKI_PKG_URL . 'edit.php?page=');
    }
    $parser->setRenderConf('xhtml', 'table', 'css_table', 'wikitable');
    $xhtml = $parser->transform($pParseHash['data'], 'Xhtml');
    return $xhtml;
}
Ejemplo n.º 12
0
 function beforeCache(&$input)
 {
     global $conf;
     // code highlighting
     require_once 'geshi/geshi.php';
     require_once 'Text/Wiki.php';
     // transform it a little to save it from evil wiki parser ^^
     $input = preg_replace_callback('#<code (\\w+)>(.*?)</code>#Uuism', array($this, 'code_cut_tag'), $input) . ' ';
     // create a Wiki object with the loaded options
     $wiki =& Text_Wiki::singleton('Doku');
     $wiki->setRenderConf('xhtml', 'wikilink', 'new_text', '');
     if (isset($conf['general']['doku_url']) && $conf['general']['doku_url']) {
         $wiki->setRenderConf('xhtml', 'wikilink', 'new_url', $conf['general']['doku_url']);
     }
     $wiki->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
     $wiki->setFormatConf('Xhtml', 'charset', 'utf-8');
     if (@$type == 'Doku') {
         $input = str_replace('\\\\', '', $input);
     }
     $input = @$wiki->transform($input, 'Xhtml');
     // restoring code tags with highlighting
     $input = preg_replace_callback('#:code__(\\d+)_:#Uuism', array($this, 'code_callback'), $input);
 }
Ejemplo n.º 13
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.º 14
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.º 15
0
 function popRenderCallback()
 {
     if (count($this->_renderCallbacks) == 0) {
         return Text_Wiki::error('Render callback popped when no render callbacks in stack');
     } else {
         $callback = array_pop($this->_renderCallbacks);
         $this->_block = call_user_func($callback, $this->_block);
         if (count($this->_blocks)) {
             $parentBlock = array_pop($this->_blocks);
             $this->_block = $parentBlock . $this->_block;
         }
         if (count($this->_renderCallbacks) == 0) {
             $this->output .= $this->_block;
             $this->_block = '';
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Transform text using Wiki library
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function transform($wikitext)
 {
     require_once 'Text/Wiki.php';
     if (!defined('WIKI_PARSER')) {
         define('WIKI_PARSER', 'Default');
     }
     $wiki =& Text_Wiki::factory(WIKI_PARSER);
     if (PEAR::isError($wiki)) {
         return sprintf(dgettext('wiki', 'Error! %s parser not found.'), WIKI_PARSER);
     }
     $wikitext = str_replace("&#39;", "'", $wikitext);
     $db = new PHPWS_DB('wiki_pages');
     $db->addColumn('title');
     $pages = $db->select('col');
     if (PEAR::isError($pages)) {
         PHPWS_Error::log($pages);
         $pages = NULL;
     }
     // Add custom parser rules
     $wiki->addPath('parse', PHPWS_SOURCE_DIR . 'mod/wiki/class/parse/');
     $wiki->insertRule('Template', '');
     $wiki->setRenderConf('xhtml', 'wikilink', 'pages', $pages);
     $wiki->setRenderConf('xhtml', 'wikilink', 'view_url', MOD_REWRITE_ENABLED ? 'wiki/%s' : './index.php?module=wiki&amp;page=%s');
     $wiki->setRenderConf('xhtml', 'wikilink', 'new_url', MOD_REWRITE_ENABLED ? 'wiki/%s' : './index.php?module=wiki&amp;page=%s');
     $wiki->setRenderConf('xhtml', 'toc', 'title', '<strong>' . dgettext('wiki', 'Table of Contents') . '</strong>');
     $wiki->setRenderConf('xhtml', 'image', 'base', 'images/wiki/');
     $wiki->setRenderConf('xhtml', 'url', 'target', PHPWS_Settings::get('wiki', 'ext_page_target'));
     $wiki->setRenderConf('xhtml', 'interwiki', 'target', PHPWS_Settings::get('wiki', 'ext_page_target'));
     $sites = array();
     $db = new PHPWS_DB('wiki_interwiki');
     $result = $db->select();
     foreach ($result as $row) {
         $sites[$row['label']] = $row['url'];
     }
     $wiki->setRenderConf('xhtml', 'interwiki', 'sites', $sites);
     if (PHPWS_Settings::get('wiki', 'ext_chars_support')) {
         $wiki->setParseConf('Wikilink', 'ext_chars', true);
         $wiki->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
     }
     // Setting CSS styles for tags
     $wiki->setRenderConf('xhtml', 'blockquote', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'code', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'code', 'css_code', 'wiki');
     $wiki->setRenderConf('xhtml', 'code', 'css_php', 'wiki');
     $wiki->setRenderConf('xhtml', 'code', 'css_html', 'wiki');
     $wiki->setRenderConf('xhtml', 'deflist', 'css_dl', 'wiki');
     $wiki->setRenderConf('xhtml', 'deflist', 'css_dt', 'wiki');
     $wiki->setRenderConf('xhtml', 'deflist', 'css_dd', 'wiki');
     $wiki->setRenderConf('xhtml', 'emphasis', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'heading', 'css_h1', 'wiki');
     $wiki->setRenderConf('xhtml', 'heading', 'css_h2', 'wiki');
     $wiki->setRenderConf('xhtml', 'heading', 'css_h3', 'wiki');
     $wiki->setRenderConf('xhtml', 'heading', 'css_h4', 'wiki');
     $wiki->setRenderConf('xhtml', 'heading', 'css_h5', 'wiki');
     $wiki->setRenderConf('xhtml', 'heading', 'css_h6', 'wiki');
     $wiki->setRenderConf('xhtml', 'horiz', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'image', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'interwiki', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'list', 'css_ol', 'wiki');
     $wiki->setRenderConf('xhtml', 'list', 'css_ol_li', 'wiki');
     $wiki->setRenderConf('xhtml', 'list', 'css_ul', 'wiki');
     $wiki->setRenderConf('xhtml', 'list', 'css_ul_li', 'wiki');
     $wiki->setRenderConf('xhtml', 'paragraph', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'table', 'css_table', 'wiki');
     $wiki->setRenderConf('xhtml', 'table', 'css_tr', 'wiki');
     $wiki->setRenderConf('xhtml', 'table', 'css_th', 'wiki');
     $wiki->setRenderConf('xhtml', 'table', 'css_td', 'wiki');
     $wiki->setRenderConf('xhtml', 'tt', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'url', 'css_inline', 'wiki');
     $wiki->setRenderConf('xhtml', 'url', 'css_footnote', 'wiki');
     $wiki->setRenderConf('xhtml', 'url', 'css_descr', 'wiki');
     $wiki->setRenderConf('xhtml', 'url', 'css_img', 'wiki');
     $wiki->setRenderConf('xhtml', 'wikilink', 'css', 'wiki');
     $wiki->setRenderConf('xhtml', 'wikilink', 'css_new', 'wiki');
     if (ALLOW_PROFANITY) {
         $wikitext = $wiki->transform($wikitext);
     } else {
         $wikitext = $wiki->transform(PHPWS_Text::profanityFilter($wikitext));
     }
     if (PHPWS_Settings::get('wiki', 'allow_bbcode')) {
         $wikitext = PHPWS_Text::bb2html($wikitext, 'wiki');
     }
     $wikitext = PHPWS_Text::fixAnchors($wikitext);
     $wikitext = str_replace('%23', '#', $wikitext);
     return PHPWS_Text::parseTag($wikitext);
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
0
 /**
  * Return the frozen value of field using the specified Text_Wiki renderer
  * @return string
  * @since  1.0
  * @access public
  */
 function getFrozenHtml()
 {
     if (isset($this->_wiki)) {
         // Use the user provided Text_Wiki instance
         $wiki =& $this->_wiki;
     } else {
         // Use the 'Default' Text_Wiki instance
         require_once 'Text/Wiki.php';
         $wiki =& Text_Wiki::singleton('Default');
     }
     $value = $this->getValue();
     $html = $wiki->transform($value, $this->_renderer);
     return $html . $this->_getPersistantData();
 }
Ejemplo n.º 19
0
 /**
  * Singleton.
  *
  * This avoids instantiating multiple Text_Wiki instances where a number
  * of objects are required in one call, e.g. to save memory in a
  * CMS invironment where several parsers are required in a single page.
  *
  * $single = & singleton();
  *
  * or
  *
  * $single = & singleton('Parser', array('Prefilter', 'Delimiter', 'Code', 'Function',
  *   'Html', 'Raw', 'Include', 'Embed', 'Anchor', 'Heading', 'Toc', 'Horiz',
  *   'Break', 'Blockquote', 'List', 'Deflist', 'Table', 'Image', 'Phplookup',
  *   'Center', 'Newline', 'Paragraph', 'Url', 'Freelink', 'Interwiki', 'Wikilink',
  *   'Colortext', 'Strong', 'Bold', 'Emphasis', 'Italic', 'Underline', 'Tt',
  *   'Superscript', 'Subscript', 'Revise', 'Tighten'));
  *
  * Call using a subset of this list.  The order of passing rulesets in the
  * $rules array is important!
  *
  * After calling this, call $single->setParseConf(), setRenderConf() or setFormatConf()
  * as usual for a constructed object of this class.
  *
  * The internal static array of singleton objects has no index on the parser
  * rules, the only index is on the parser name.  So if you call this multiple
  * times with different rules but the same parser name, you will get the same
  * static parser object each time.
  *
  * @access public
  * @static
  * @since Method available since Release 1.1.0
  * @param string $parser The parser to be used (defaults to 'Default').
  * @param array $rules   The set of rules to instantiate the object. This
  *    will only be used when the first call to singleton is made, if included
  *    in further calls it will be effectively ignored.
  * @return &object a reference to the Text_Wiki unique instantiation.
  */
 function &singleton($parser = 'Default', $rules = null)
 {
     static $only = array();
     if (!isset($only[$parser])) {
         $ret =& Text_Wiki::factory($parser, $rules);
         if (PEAR::isError($ret)) {
             return $ret;
         }
         $only[$parser] =& $ret;
     }
     return $only[$parser];
 }
Ejemplo n.º 20
0
 /**
  * transform the wiki text.
  *
  * @param  string $text
  * @param  array  $rules
  * @return Text_Wiki
  */
 public function execute($text, $rules = null)
 {
     $wiki = new Text_Wiki($rules);
     return $wiki->transform($text);
 }
Ejemplo n.º 21
0
 function Text_Wiki_Tiki($rules = null)
 {
     parent::Text_Wiki($rules);
     $this->addPath('parse', $this->fixPath(dirname(__FILE__)) . 'Parse/Tiki');
     //        $this->addPath('render', $this->fixPath(dirname(__FILE__)).'Render');
 }
        }
        $_REQUEST['translate'] = true;
    }
    foreach (array('parser' => $plist[0], 'render' => $rlist[0], 'exchoice' => $elist ? $elist[0] : '', 'source' => '') as $fld => $def) {
        if (!isset($_REQUEST[$fld])) {
            $_REQUEST[$fld] = $def;
        }
        ${$fld} = $_REQUEST[$fld];
    }
    if (!isset($_REQUEST['translate'])) {
        echo bldHtml('', $plist, $rlist, $elist);
        die;
    }
}
// instantiate a Text_Wiki object from the given class
$wiki =& Text_Wiki::singleton($parser);
// If you want to include rules, use
//$wiki = & Text_Wiki::singleton($parser, $rules);
// If you want to get a new copy of the class use factory
//$wiki =& Text_Wiki::factory($parser);
//print "<pre>\n";
//print_r($wiki);
//print "</pre>\n";
// when rendering XHTML, make sure wiki links point to a
// specific base URL
//$wiki->setRenderConf('xhtml', 'wikilink', 'view_url',
// 'http://example.com/view.php?page=');
// set an array of pages that exist in the wiki
// and tell the XHTML renderer about them
//$pages = array('HomePage', 'AnotherPage', 'SomeOtherPage');
$wiki->setRenderConf('xhtml', 'code', 'css_filename', 'codefilename');
Ejemplo n.º 23
0
 function parse_code($codedpage)
 {
     // Pre-parsing:
     $pageclean = $this->preParsingCleanup($codedpage);
     // Strange bugfix; WIKI databases are URF-8, but apparently the TEXT-WIKI code requires LATIN1 input
     if (IS_ON_KTH_SERVER) {
         $pageclean = mb_convert_encoding($pageclean, "ISO-8859-1");
     }
     // Create wiki object using given parser:
     $parser = "Mediawiki";
     $render = "Xhtml";
     $wiki =& Text_Wiki::singleton($parser);
     $wiki->setRenderConf('xhtml', 'code', 'css_filename', 'codefilename');
     // Transform the wiki text into given rendering
     $decodedpage = $wiki->transform($pageclean, $render);
     $decodedpage = html_entity_decode(html_entity_decode($decodedpage));
     //TODO: bugfix...
     if (!in_array(SUBSITE, array("nordita2011"))) {
         $decodedpage = str_replace("'nordita2011/", "'", $decodedpage);
     }
     // Post-parsing adjustments:
     if (isset($this->wikipage_images)) {
         if (preg_match_all("/src=\"\\/(.*)\"/U", $decodedpage, $ims)) {
             foreach ($ims[1] as $im) {
                 if (isset($this->wikipage_images[$im]["src"])) {
                     // need to match more than just "/".$im (here: also initial quotation mark),
                     // in case a wiki image is displayed more than once:
                     $decodedpage = preg_replace("~([\"'])/" . $im . "~U", "\\1" . $this->wikipage_images[$im]["src"], $decodedpage);
                 }
             }
         }
     }
     $decodedpage = trim($this->postParsingCleanup($decodedpage));
     if (!empty($decodedpage)) {
         $decodedpage .= "\r\n";
     }
     return $decodedpage;
 }
Ejemplo n.º 24
0
 /**
  * Constructor: just adds the path to Mediawiki rules
  *
  * @access public
  * @param array $rules The set of rules to load for this object.
  */
 function Text_Wiki_Mediawiki($rules = null)
 {
     parent::Text_Wiki($rules);
     $this->addPath('parse', $this->fixPath(dirname(__FILE__)) . 'Parse/Mediawiki');
 }
 /**
  * Create a Text_Wiki object to handle the parsing
  * of Mediawiki syntax and define some configuration
  * option
  */
 function configureParser()
 {
     $this->parser = Text_Wiki::factory('Mediawiki');
     // do not replace space by underscore in wikilinks
     $this->parser->setParseConf('Wikilink', 'spaceUnderscore', false);
     // define possible localized namespace for image and files in the wikilink syntax
     $namespaces = $this->dom->getElementsByTagName('namespace');
     $prefix = array('Image', 'image');
     if ($namespaces->length > 0) {
         foreach ($namespaces as $namespace) {
             if ($namespace->getAttribute('key') == '-2' || $namespace->getAttribute('key') == '6') {
                 $prefix[] = $namespace->nodeValue;
             }
         }
     }
     $this->parser->setParseConf('Image', 'prefix', $prefix);
 }
Ejemplo n.º 26
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;
 }
Ejemplo n.º 27
0
 function Text_Wiki_Doku($rules = null)
 {
     parent::Text_Wiki($rules);
     $paths = $this->getPath('parse');
     $this->addPath('parse', str_replace('Default', 'Doku', $paths[0]));
 }
Ejemplo n.º 28
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;
 }
Ejemplo n.º 29
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.º 30
0
<?php

// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');
// load wikitext converter
require_once 'Text/Wiki.php';
// instantiate a Text_Wiki object from the given class
// and set it to use the Mediawiki adapter
$wiki =& Text_Wiki::factory('Mediawiki');
// set some rendering rules
$wiki->setRenderConf('xhtml', 'wikilink', 'view_url', 'http://en.wikipedia.org/wiki/');
$wiki->setRenderConf('xhtml', 'wikilink', 'pages', false);
// define page title
$query = 'The A Team';
try {
    // initialize REST client
    $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');
    // set query parameters
    $wikipedia->action('query');
    $wikipedia->prop('revisions');
    $wikipedia->rvprop('content');
    $wikipedia->format('xml');
    $wikipedia->redirects('1');
    $wikipedia->titles($query);
    // perform request
    // get page content as XML
    $result = $wikipedia->get();
    $content = $result->query->pages->page->revisions->rev;
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());