diff options
author | Adrian Lang <lang@cosmocode.de> | 2009-11-19 14:57:35 +0100 |
---|---|---|
committer | Adrian Lang <lang@cosmocode.de> | 2010-01-19 16:40:50 +0100 |
commit | b081e262b17e0409d75b608f15192588cd99217c (patch) | |
tree | 0678753abdbf0bff2fe0351d7edf60e8664e8b84 | |
parent | b5ee21aa65a2f380e3b99ff5ea6ced48c1cb720e (diff) | |
download | rpg-b081e262b17e0409d75b608f15192588cd99217c.tar.gz rpg-b081e262b17e0409d75b608f15192588cd99217c.tar.bz2 |
Dynamically create edit buttons for parts of a page
darcs-hash:20091119135735-e4919-3bc4872d1b1f8236571f936406db15bb0018610c.gz
-rw-r--r-- | inc/html.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/inc/html.php b/inc/html.php index 29dddbe74..48d4370dc 100644 --- a/inc/html.php +++ b/inc/html.php @@ -91,14 +91,18 @@ function html_secedit_button($matches){ global $ID; global $INFO; - $section = $matches[2]; - $name = $matches[1]; + $edittarget = ($matches[1] === 'SECTION') ? 'plain' : + strtolower($matches[1]); + + $section = $matches[3]; + $name = $matches[2]; $secedit = ''; $secedit .= '<div class="secedit">'; $secedit .= html_btn('secedit',$ID,'', array('do' => 'edit', - 'lines' => "$section", + 'lines' => $section, + 'edittarget' => $edittarget, 'rev' => $INFO['lastmod']), 'post', $name); $secedit .= '</div>'; @@ -113,11 +117,13 @@ function html_secedit_button($matches){ function html_secedit($text,$show=true){ global $INFO; + $regexp = '#<!-- ([A-Z]+) (?:"(.*)" )?\[(\d+-\d*)\] -->#'; + if($INFO['writable'] && $show && !$INFO['rev']){ - $text = preg_replace_callback('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#', + $text = preg_replace_callback($regexp, 'html_secedit_button', $text); }else{ - $text = preg_replace('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#','',$text); + $text = preg_replace($regexp,'',$text); } return $text; |