summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Lang <lang@cosmocode.de>2010-02-08 12:50:20 +0100
committerAdrian Lang <lang@cosmocode.de>2010-02-08 12:53:02 +0100
commit40868f2faa85215dfea2fa0c82274a4806d042ab (patch)
tree76bd582d98c89d22818de3622a86c29469036835
parent6c1f778cae7a02dec2e14017e539d541ce6e74fb (diff)
downloadrpg-40868f2faa85215dfea2fa0c82274a4806d042ab.tar.gz
rpg-40868f2faa85215dfea2fa0c82274a4806d042ab.tar.bz2
Hide secedit buttons without title
-rw-r--r--doku.php2
-rw-r--r--inc/html.php65
-rw-r--r--inc/lang/en/lang.php1
-rw-r--r--inc/parser/xhtml.php12
4 files changed, 48 insertions, 32 deletions
diff --git a/doku.php b/doku.php
index 3963a5aa0..5f2d2c582 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 a6ec628cf..c2b0db17d 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 3062d1724..98ded12ca 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 9de712303..3ac8ed35c 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){