diff --git a/doku.php b/doku.php index 3963a5aa040b33aa5ea7b848c40e155dfc0b5575..5f2d2c582e8b959a72cac7e1f56c5b5a6a55c71b 100644 --- a/doku.php +++ b/doku.php @@ -35,7 +35,7 @@ $NS = getNS($ID); $REV = $_REQUEST['rev']; $IDX = $_REQUEST['idx']; $DATE = $_REQUEST['date']; -$RANGE = $_REQUEST['lines']; +$RANGE = $_REQUEST['range']; $HIGH = $_REQUEST['s']; if(empty($HIGH)) $HIGH = getGoogleQuery(); diff --git a/inc/html.php b/inc/html.php index a6ec628cf0c92b3ca9cd491bc52e2c3b2419b026..c2b0db17d1262a579043a92cbd29de24322f7090 100644 --- a/inc/html.php +++ b/inc/html.php @@ -82,48 +82,63 @@ function html_login(){ } /** - * prints a section editing button - * used as a callback in html_secedit + * inserts section edit buttons if wanted or removes the markers * * @author Andreas Gohr <andi@splitbrain.org> */ -function html_secedit_button($matches){ - global $ID; +function html_secedit($text,$show=true){ global $INFO; - $nr = $matches[1]; - $target = strtolower($matches[2]); + $regexp = '#<!-- EDIT(\d+) ([A-Z]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->#'; - $name = $matches[3]; - $section = $matches[4]; + if(!$INFO['writable'] || !$show || $INFO['rev']){ + return preg_replace($regexp,'',$text); + } - return "<div class='secedit editbutton_$target editbutton_$nr'>" . - html_btn('secedit',$ID,'', - array('do' => 'edit', - 'lines' => $section, - 'edittarget' => $target, - 'rev' => $INFO['lastmod']), - 'post', $name) . '</div>'; + return preg_replace_callback($regexp, + 'html_secedit_button', $text); } /** - * inserts section edit buttons if wanted or removes the markers + * prepares section edit button data for event triggering + * used as a callback in html_secedit * + * @triggers HTML_SECEDIT_BUTTON * @author Andreas Gohr <andi@splitbrain.org> */ -function html_secedit($text,$show=true){ +function html_secedit_button($matches){ + $data = array('id' => $matches[1], + 'target' => strtolower($matches[2]), + 'range' => $matches[count($matches) - 1]); + if (count($matches) === 5) { + $data['name'] = $matches[3]; + } + + return trigger_event('HTML_SECEDIT_BUTTON', $data, + 'html_secedit_get_button'); +} + +/** + * prints a section editing button + * used as default action form HTML_SECEDIT_BUTTON + * + * @author Adrian Lang <lang@cosmocode.de> + */ +function html_secedit_get_button($data) { + global $ID; global $INFO; - $regexp = '#<!-- EDIT(\d+) ([A-Z]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->#'; + if (!isset($data['name']) || $data['name'] === '') return; - if($INFO['writable'] && $show && !$INFO['rev']){ - $text = preg_replace_callback($regexp, - 'html_secedit_button', $text); - }else{ - $text = preg_replace($regexp,'',$text); - } + $name = $data['name']; + unset($data['name']); - return $text; + return "<div class='secedit editbutton_" . $data['target'] . + " editbutton_" . $data['id'] . "'>" . + html_btn('secedit', $ID, '', + array_merge(array('do' => 'edit', + 'rev' => $INFO['lastmod']), $data), + 'post', $name) . '</div>'; } /** diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 3062d1724e121d7c6f366703cba1f089dc786f46..98ded12ca0d6342c27dd122e3503e2c9df7ec25f 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -152,7 +152,6 @@ $lang['external_edit'] = 'external edit'; $lang['summary'] = 'Edit summary'; $lang['noflash'] = 'The <a href="http://www.adobe.com/products/flashplayer/">Adobe Flash Plugin</a> is needed to display this content.'; $lang['download'] = 'Download Snippet'; -$lang['table_edit_title'] = 'Table'; $lang['mail_newpage'] = 'page added:'; $lang['mail_changed'] = 'page changed:'; diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 9de7123038697e0fa1729e5d63d556c1742a96a5..3ac8ed35cfe3ea16002130064cc2ec0b140711d1 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -49,7 +49,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @return string A marker class for the starting HTML element * @author Adrian Lang <lang@cosmocode.de> */ - protected function startSectionEdit($start, $type, $title) { + protected function startSectionEdit($start, $type, $title = null) { static $lastsecid = 0; $this->sectionedits[] = array(++$lastsecid, $start, $type, $title); return 'sectionedit' . $lastsecid; @@ -63,9 +63,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { */ protected function finishSectionEdit($end) { list($id, $start, $type, $title) = array_pop($this->sectionedits); - $this->doc .= "<!-- EDIT$id " . strtoupper($type) . ' "' . - str_replace('"', '', $title) . "\" [$start-" . - ($end === 0 ? '' : $end) . "] -->"; + $this->doc .= "<!-- EDIT$id " . strtoupper($type) . ' '; + if (!is_null($title)) { + $this->doc .= '"' . str_replace('"', '', $title) . '" '; + } + $this->doc .= "[$start-" . ($end === 0 ? '' : $end) . '] -->'; } function getFormat(){ @@ -885,7 +887,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { global $lang; // initialize the row counter used for classes $this->_counter['row_counter'] = 0; - $this->doc .= '<table class="inline ' . $this->startSectionEdit($pos, 'table', $lang['table_edit_title']) . '">'.DOKU_LF; + $this->doc .= '<table class="inline ' . $this->startSectionEdit($pos, 'table') . '">'.DOKU_LF; } function table_close($pos){