コード例 #1
0
ファイル: WikiDiff.php プロジェクト: Jopperi/wiki
 /**
  * Diff
  *
  * Main function: Calls the diff and render, then outputs to layout
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function diff($oVer, $nVer)
 {
     PHPWS_Core::initModClass('wiki', 'OldWikiPage.php');
     $olderpage = new OldWikiPage();
     $newerpage = new OldWikiPage();
     $db = new PHPWS_DB('wiki_pages_version');
     $db->addWhere('title', $_REQUEST['page']);
     $db->addWhere('vr_number', $oVer);
     $db->loadObject($olderpage);
     $db->reset();
     $db->addWhere('title', $_REQUEST['page']);
     $db->addWhere('vr_number', $nVer);
     $db->loadObject($newerpage);
     // Need to parse the text, but we can't call parseOutput or this module's
     // transform function.  They both do too much parsing and can't be used
     // for a diff.  So, we call what is needed directly:
     $oPagetext = htmlspecialchars(str_replace("&#39;", "'", $olderpage->getPagetext(FALSE)));
     $nPagetext = htmlspecialchars(str_replace("&#39;", "'", $newerpage->getPagetext(FALSE)));
     if (!ALLOW_PROFANITY) {
         $oPagetext = PHPWS_Text::profanityFilter($oPagetext);
         $nPagetext = PHPWS_Text::profanityFilter($nPagetext);
     }
     // End diff text parsing
     $oPagetext = explode("\n", $oPagetext);
     $nPageText = explode("\n", $nPagetext);
     $diff = new Text_Diff($oPagetext, $nPageText);
     $this->render($diff);
     $tags = array();
     $tags['TITLE'] = dgettext('wiki', 'Difference between revisions');
     $tags['BACK_PAGE'] = PHPWS_Text::moduleLink(dgettext('wiki', 'Back to Page'), 'wiki', array('page' => $_REQUEST['page']));
     $tags['BACK_HISTORY'] = PHPWS_Text::moduleLink(dgettext('wiki', 'Back to History'), 'wiki', array('page_op' => 'history', 'page_id' => $newerpage->getSourceId()));
     $tags['DIFF'] = $this->_output;
     $tags['OLDER_VERSION'] = $olderpage->getVrNumber();
     $tags['NEWER_VERSION'] = $newerpage->getVrNumber();
     $tags['OLDER_UPDATED'] = $olderpage->getUpdated();
     $tags['NEWER_UPDATED'] = $newerpage->getUpdated();
     $tags['VERSION_LABEL'] = dgettext('wiki', 'Version');
     return PHPWS_Template::process($tags, 'wiki', 'diff/' . $this->_format . '/diff.tpl');
 }
コード例 #2
0
ファイル: WikiManager.php プロジェクト: Jopperi/wiki
 /**
  * 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);
 }
コード例 #3
0
ファイル: PHPWS_Text.php プロジェクト: HaldunA/phpwebsite
 public function getPrint()
 {
     if (empty($this->text)) {
         return null;
     }
     $text = $this->text;
     if (!$this->use_profanity) {
         $text = PHPWS_Text::profanityFilter($text);
     }
     if ($this->use_strip_tags) {
         $text = strip_tags($text, $this->allowed_tags);
     }
     if ($this->use_breaker) {
         $text = PHPWS_Text::breaker($text);
     }
     if ($this->fix_anchors) {
         $text = PHPWS_Text::fixAnchors($text);
     }
     if ($this->collapse_urls) {
         $text = PHPWS_Text::collapseUrls($text);
     }
     return $text;
 }