From: <var...@us...> - 2009-01-21 15:35:27
|
Revision: 6428 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6428&view=rev Author: vargenau Date: 2009-01-21 15:35:18 +0000 (Wed, 21 Jan 2009) Log Message: ----------- Reverting to 6424 Modified Paths: -------------- trunk/lib/BlockParser.php trunk/lib/CachedMarkup.php trunk/lib/InlineParser.php Modified: trunk/lib/BlockParser.php =================================================================== --- trunk/lib/BlockParser.php 2009-01-21 13:26:11 UTC (rev 6427) +++ trunk/lib/BlockParser.php 2009-01-21 15:35:18 UTC (rev 6428) @@ -1,7 +1,6 @@ <?php rcs_id('$Id$'); /* Copyright (C) 2002 Geoffrey T. Dairiki <da...@da...> * Copyright (C) 2004,2005 Reini Urban - * Copyright (C) 2008 Marc-Etienne Vargenau, Alcatel-Lucent * * This file is part of PhpWiki. * @@ -23,6 +22,10 @@ require_once('lib/CachedMarkup.php'); require_once('lib/InlineParser.php'); +//////////////////////////////////////////////////////////////// +// +// + /** * Deal with paragraphs and proper, recursive block indents * for the new style markup (version 2) @@ -262,6 +265,7 @@ function skipSpace () { // In contrast to the case for top-level blocks, // for sub-blocks, there never appears to be any trailing space. + // (The last block in the sub-block should always be of class tight-bottom.) while ($this->_line === '') $this->advance(); @@ -328,6 +332,9 @@ function Block_HtmlElement($tag /*, ... */) { $this->_init(func_get_args()); } + + function setTightness($top, $bottom) { + } } class ParsedBlock extends Block_HtmlElement { @@ -395,6 +402,7 @@ if ($line === false or $line === '') { // allow $line === '0' return false; } + $tight_top = !$this->_atSpace; $re_set = &$this->_regexpset; //FIXME: php5 fails to advance here! for ($m = $re_set->match($line); $m; $m = $re_set->nextMatch($line, $m)) { @@ -406,7 +414,8 @@ //$block->_text = $line; if (DEBUG & _DEBUG_PARSER) $input->_debug('<', get_class($block)); - $input->skipSpace(); + $tight_bottom = ! $input->skipSpace(); + $block->_setTightness($tight_top, $tight_bottom); return $block; } if (DEBUG & _DEBUG_PARSER) @@ -467,6 +476,10 @@ trigger_error('pure virtual', E_USER_ERROR); } + function _setTightness ($top, $bot) { + $this->_element->setTightness($top, $bot); + } + function merge ($followingBlock) { return false; } @@ -493,6 +506,8 @@ if (get_class($nextBlock) == get_class($this)) { assert ($nextBlock->_depth < $this->_depth); $nextBlock->_element->unshiftContent($this->_element); + if (!empty($this->_tight_top)) + $nextBlock->_tight_top = $this->_tight_top; return $nextBlock; } return false; @@ -531,6 +546,11 @@ return true; } + function _setTightness($top, $bot) { + $li = &$this->_content[0]; + $li->setTightness($top, $bot); + } + function merge ($nextBlock) { if (isa($nextBlock, 'Block_list') and $this->_tag == $nextBlock->_tag) { if ($nextBlock->_content === $this->_content) { @@ -568,6 +588,14 @@ return true; } + function _setTightness($top, $bot) { + $dt = &$this->_content[0]; + $dd = &$this->_content[1]; + + $dt->setTightness($top, $this->_tight_defn); + $dd->setTightness($this->_tight_defn, $bot); + } + function _do_match (&$input, $m) { $pos = $input->getPos(); @@ -590,6 +618,8 @@ } } + + class Block_table_dl_defn extends XmlContent { var $nrows; @@ -600,6 +630,7 @@ if (!is_array($defn)) $defn = $defn->getContent(); + $this->_next_tight_top = false; // value irrelevant - gets fixed later $this->_ncols = $this->_ComputeNcols($defn); $this->_nrows = 0; @@ -617,6 +648,19 @@ $this->_setTerm($th); } + function setTightness($tight_top, $tight_bot) { + $this->_tight_top = $tight_top; + $this->_tight_bot = $tight_bot; + $first = &$this->firstTR(); + $last = &$this->lastTR(); + $first->setInClass('top', $tight_top); + if (!empty($last)) { + $last->setInClass('bottom', $tight_bot); + } else { + trigger_error(sprintf("no lastTR: %s",AsXML($this->_content[0])), E_USER_WARNING); + } + } + function _addToRow ($item) { if (empty($this->_accum)) { $this->_accum = HTML::td(); @@ -626,10 +670,13 @@ $this->_accum->pushContent($item); } - function _flushRow () { + function _flushRow ($tight_bottom=false) { if (!empty($this->_accum)) { $row = new Block_HtmlElement('tr', false, $this->_accum); + $row->setTightness($this->_next_tight_top, $tight_bottom); + $this->_next_tight_top = $tight_bottom; + $this->pushContent($row); $this->_accum = false; $this->_nrows++; @@ -640,11 +687,12 @@ if (!($table_rows = $table->getContent())) return; - $this->_flushRow(); - + $this->_flushRow($table_rows[0]->_tight_top); + foreach ($table_rows as $subdef) { $this->pushContent($subdef); $this->_nrows += $subdef->nrows(); + $this->_next_tight_top = $subdef->_tight_bot; } } @@ -736,6 +784,10 @@ return true; } + function _setTightness($top, $bot) { + $this->_content[0]->setTightness($top, $bot); + } + function finish () { $defs = &$this->_content; @@ -797,6 +849,68 @@ $this->_content[] = new TightSubBlock($input, $indent, $m->match, $itemtag); return true; } + + function _setTightness($top, $bot) { + if (count($this->_content) == 1) { + $li = &$this->_content[0]; + $li->setTightness($top, $bot); + } + else { + // This is where php5 usually brakes. + // wrong duplicated <li> contents + if (DEBUG and DEBUG & _DEBUG_PARSER and check_php_version(5)) { + if (count($this->_content) != 2) { + echo "<pre>"; + /* + $class = new Reflection_Class('XmlElement'); + // Print out basic information + printf( + "===> The %s%s%s %s '%s' [extends %s]\n". + " declared in %s\n". + " lines %d to %d\n". + " having the modifiers %d [%s]\n", + $class->isInternal() ? 'internal' : 'user-defined', + $class->isAbstract() ? ' abstract' : '', + $class->isFinal() ? ' final' : '', + $class->isInterface() ? 'interface' : 'class', + $class->getName(), + var_export($class->getParentClass(), 1), + $class->getFileName(), + $class->getStartLine(), + $class->getEndline(), + $class->getModifiers(), + implode(' ', Reflection::getModifierNames($class->getModifiers())) + ); + // Print class properties + printf("---> Properties: %s\n", var_export($class->getProperties(), 1)); + */ + echo 'count($this->_content): ', count($this->_content),"\n"; + echo "\$this->_content[0]: "; var_dump ($this->_content[0]); + + for ($i=1; $i < min(5, count($this->_content)); $i++) { + $c =& $this->_content[$i]; + echo '$this->_content[',$i,"]: \n"; + echo "_tag: "; var_dump ($c->_tag); + echo "_content: "; var_dump ($c->_content); + echo "_properties: "; var_dump ($c->_properties); + } + debug_print_backtrace(); + if (DEBUG & _DEBUG_APD) { + if (function_exists("xdebug_get_function_stack")) { + var_dump (xdebug_get_function_stack()); + } + } + echo "</pre>"; + } + } + if (!check_php_version(5)) + assert(count($this->_content) == 2); + $dt = &$this->_content[0]; + $dd = &$this->_content[1]; + $dt->setTightness($top, false); + $dd->setTightness(false, $bot); + } + } } class Block_pre extends BlockMarkup @@ -917,6 +1031,10 @@ $this->_element = new Block_HtmlElement('hr'); return true; } + + function _setTightness($top, $bot) { + // Don't tighten <hr/>s + } } class Block_heading extends BlockMarkup @@ -932,6 +1050,10 @@ return true; } + + function _setTightness($top, $bot) { + // Don't tighten headers. + } } class Block_heading_wikicreole extends BlockMarkup @@ -951,6 +1073,10 @@ return true; } + + function _setTightness($top, $bot) { + // Don't tighten headers. + } } class Block_p extends BlockMarkup @@ -965,10 +1091,16 @@ return true; } + function _setTightness ($top, $bot) { + $this->_tight_top = $top; + $this->_tight_bot = $bot; + } + function merge ($nextBlock) { $class = get_class($nextBlock); - if (strtolower($class) == 'block_p') { + if (strtolower($class) == 'block_p' and $this->_tight_bot) { $this->_text .= "\n" . $nextBlock->_text; + $this->_tight_bot = $nextBlock->_tight_bot; return $this; } return false; @@ -977,6 +1109,7 @@ function finish () { $content = TransformInline(trim($this->_text)); $p = new Block_HtmlElement('p', false, $content); + $p->setTightness($this->_tight_top, $this->_tight_bot); return $p; } } @@ -1030,10 +1163,15 @@ } } $this->_element = new Block_HtmlElement($tag, $args, $content); + //$this->_element->setTightness($tag == 'span', $tag == 'span'); return true; } + function _setTightness($top, $bot) { + // Don't tighten user <div|span> + } } + //////////////////////////////////////////////////////////////// // Modified: trunk/lib/CachedMarkup.php =================================================================== --- trunk/lib/CachedMarkup.php 2009-01-21 13:26:11 UTC (rev 6427) +++ trunk/lib/CachedMarkup.php 2009-01-21 15:35:18 UTC (rev 6428) @@ -2,7 +2,6 @@ rcs_id('$Id$'); /* Copyright (C) 2002 Geoffrey T. Dairiki <da...@da...> * Copyright (C) 2004-2008 $ThePhpWikiProgrammingTeam - * Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent * * This file is part of PhpWiki. * @@ -36,12 +35,8 @@ } function pack() { - // This causes a strange bug when a comment containing - // a single quote is entered in the Summary box: - // - the history is wrong (user and comment missing) - // - the table of contents plugin no longer works - // if (function_exists('gzcompress')) - // return gzcompress(serialize($this), 9); + if (function_exists('gzcompress')) + return gzcompress(serialize($this), 9); return serialize($this); // FIXME: probably should implement some sort of "compression" @@ -760,6 +755,9 @@ } } + function setTightness($top, $bottom) { + } + function isInlineElement() { return false; } @@ -791,6 +789,69 @@ } } +// $Log: not supported by cvs2svn $ +// Revision 1.64 2008/03/21 20:35:52 rurban +// Improve upon embedded ImgObject, such as [ *.mp3 ], objects. +// Object tags now render as label correctly and param tags are also added. +// +// Revision 1.63 2008/03/17 19:03:08 rurban +// protect $WikiTheme->VALID_LINKS +// +// Revision 1.62 2008/02/14 18:40:32 rurban +// fix DUMP_MODE with LINKS +// +// Revision 1.61 2008/01/30 19:08:59 vargenau +// Valid HTML code: we need a div, it might contain a table +// +// Revision 1.60 2007/09/15 12:28:46 rurban +// Improve multi-page format handling: abstract _DumpHtmlToDir. get rid of non-external pdf, non-global VALID_LINKS +// +// Revision 1.59 2007/09/12 19:32:29 rurban +// link only VALID_LINKS with pagelist HTML_DUMP +// +// Revision 1.58 2007/07/14 12:30:53 rurban +// include => require +// +// Revision 1.57 2007/05/28 20:13:46 rurban +// Overwrite all attributes at once at page->save to delete dangling meta +// +// Revision 1.56 2007/04/08 16:39:40 rurban +// fix when DISABLE_UNITS = true (thanks to Walter Rafelsberger) +// simplify title calculation +// +// Revision 1.55 2007/03/18 17:35:14 rurban +// Fix :DontStoreLink +// +// Revision 1.54 2007/01/25 07:41:41 rurban +// Print attribute in title. Use CSS formatting for ::= +// +// Revision 1.53 2007/01/21 23:26:52 rurban +// Translate Found by +// +// Revision 1.52 2007/01/20 15:53:51 rurban +// Rewrite of SearchHighlight: through ActionPage and InlineParser +// +// Revision 1.51 2007/01/20 11:24:53 rurban +// add SpellCheck support +// +// Revision 1.50 2007/01/07 18:41:51 rurban +// Fix fallback ZipReader syntax error. Use label=false. Add parsed plugin names to the stored tree. +// +// Revision 1.49 2007/01/04 16:40:35 rurban +// Remove units object from CachedMarkup links, Store parsed linkinfo only: basevalue, baseunit. +// +// Revision 1.48 2007/01/03 21:22:08 rurban +// Use Units for attributes. Store the unified base value as Cached_SemanticLink->_attribute_base in the wikimarkup and display it as title. +// +// Revision 1.47 2007/01/02 13:17:57 rurban +// fix semantic page links and attributes, esp. attributes. they get stored as link to empty page also. tighten semantic url expander regex, omit want_content if not necessary +// +// Revision 1.46 2006/12/22 00:11:38 rurban +// add seperate expandurl method, to simplify pagename parsing +// +// Revision 1.45 2006/10/12 06:33:50 rurban +// decide later with which class to render this link (fixes interwiki link layout) + // (c-file-style: "gnu") // Local Variables: // mode: php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2009-01-21 13:26:11 UTC (rev 6427) +++ trunk/lib/InlineParser.php 2009-01-21 15:35:18 UTC (rev 6428) @@ -27,6 +27,8 @@ * @package Markup * @author Geoffrey T. Dairiki, Reini Urban */ +/** + */ /** * This is the character used in wiki markup to escape characters with @@ -1136,6 +1138,7 @@ and isa($markup,'Markup_plugin')) { $current =& $output->_content[count($output->_content)-1]; + $current->setTightness(true,true); } $output->pushContent($match->prematch); $text = $match->postmatch; @@ -1159,6 +1162,11 @@ else $current = $markup->markup($match->match, $body); $input = $match->postmatch; + if (isset($markup) and is_object($markup) + and isa($markup,'Markup_plugin')) + { + $current->setTightness(true,true); + } $output->pushContent($match->prematch, $current); $match = $regexps->match($input); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |