From b081e262b17e0409d75b608f15192588cd99217c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 19 Nov 2009 14:57:35 +0100 Subject: Dynamically create edit buttons for parts of a page darcs-hash:20091119135735-e4919-3bc4872d1b1f8236571f936406db15bb0018610c.gz --- inc/html.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'inc/html.php') 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 .= '
'; $secedit .= html_btn('secedit',$ID,'', array('do' => 'edit', - 'lines' => "$section", + 'lines' => $section, + 'edittarget' => $edittarget, 'rev' => $INFO['lastmod']), 'post', $name); $secedit .= '
'; @@ -113,11 +117,13 @@ function html_secedit_button($matches){ function html_secedit($text,$show=true){ global $INFO; + $regexp = '##'; + if($INFO['writable'] && $show && !$INFO['rev']){ - $text = preg_replace_callback('##', + $text = preg_replace_callback($regexp, 'html_secedit_button', $text); }else{ - $text = preg_replace('##','',$text); + $text = preg_replace($regexp,'',$text); } return $text; -- cgit v1.2.3 From 7c4635c4cfa34ef378423e198f9e78548cce62f0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 19 Nov 2009 15:05:51 +0100 Subject: Introduce event HTML_EDIT_FORMSELECTION darcs-hash:20091119140551-e4919-7aa50fb6452dc6c402bfcd581f08d21de401999d.gz --- inc/html.php | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 48d4370dc..dda797f9e 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1110,11 +1110,9 @@ function html_updateprofile(){ } /** - * This displays the edit form (lots of logic included) + * Preprocess edit form data * - * @fixme this is a huge lump of code and should be modularized * @triggers HTML_PAGE_FROMTEMPLATE - * @triggers HTML_EDITFORM_INJECTION * @author Andreas Gohr */ function html_edit($text=null,$include='edit'){ //FIXME: include needed? @@ -1128,7 +1126,6 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? global $SUM; global $lang; global $conf; - global $license; //set summary default if(!$SUM){ @@ -1182,20 +1179,44 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? print p_locale_xhtml('read'); } if(!$DATE) $DATE = $INFO['lastmod']; - ?> -
-
-
-
+ $data = compact('wr', 'text', 'mod', 'check'); + trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); +} +/** + * Display the default edit form + * + * Is the default action for HTML_EDIT_FORMSELECTION. + * + * @triggers HTML_EDITFORM_OUTPUT + */ +function html_edit_form($param) { + extract($param); + global $conf; + global $license; + global $lang; + global $REV; + global $DATE; + global $PRE; + global $SUF; + global $INFO; + global $SUM; + global $ID; + ?> +
+ +
+
+
+
'dw__editform')); -- cgit v1.2.3 From 45d0580848a1c48ed59ed416949c0efb4cf790f8 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 26 Nov 2009 13:14:28 +0100 Subject: Add target-specific class to section edit button darcs-hash:20091126121428-e4919-8c21d358a76148a9319bf223d0fa1baba8c92656.gz --- inc/html.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index dda797f9e..7f061ffbd 100644 --- a/inc/html.php +++ b/inc/html.php @@ -104,7 +104,7 @@ function html_secedit_button($matches){ 'lines' => $section, 'edittarget' => $edittarget, 'rev' => $INFO['lastmod']), - 'post', $name); + 'post', $name, 'editbutton_' . $edittarget); $secedit .= '
'; return $secedit; } @@ -149,7 +149,7 @@ function html_topbtn(){ * * @author Andreas Gohr */ -function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ +function html_btn($name,$id,$akey,$params,$method='get',$tooltip='', $class = ''){ global $conf; global $lang; @@ -187,7 +187,9 @@ function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ $tip = htmlspecialchars($label); } - $ret .= ' Date: Mon, 30 Nov 2009 14:10:48 +0100 Subject: Move edit button class to the topmost div darcs-hash:20091130131048-e4919-20c11bb664df45e76a4de30dee53e067dfa9d788.gz --- inc/html.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 7f061ffbd..8a215f440 100644 --- a/inc/html.php +++ b/inc/html.php @@ -98,13 +98,13 @@ function html_secedit_button($matches){ $name = $matches[2]; $secedit = ''; - $secedit .= '
'; + $secedit .= '
'; $secedit .= html_btn('secedit',$ID,'', array('do' => 'edit', 'lines' => $section, 'edittarget' => $edittarget, 'rev' => $INFO['lastmod']), - 'post', $name, 'editbutton_' . $edittarget); + 'post', $name); $secedit .= '
'; return $secedit; } @@ -149,7 +149,7 @@ function html_topbtn(){ * * @author Andreas Gohr */ -function html_btn($name,$id,$akey,$params,$method='get',$tooltip='', $class = ''){ +function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ global $conf; global $lang; @@ -187,9 +187,7 @@ function html_btn($name,$id,$akey,$params,$method='get',$tooltip='', $class = '' $tip = htmlspecialchars($label); } - $class .= ' button'; - - $ret .= ' Date: Sun, 31 Jan 2010 19:02:14 +0100 Subject: first attempt to centralize all include loading Classes are loaded throug PHP5's class autoloader, all other includes are just loaded by default. This skips a lot of require_once calls. Parser and Plugin stuff isn't handled by the class loader yet. --- inc/html.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 8a215f440..5e1d0bab3 100644 --- a/inc/html.php +++ b/inc/html.php @@ -8,8 +8,6 @@ if(!defined('DOKU_INC')) die('meh.'); if(!defined('NL')) define('NL',"\n"); -require_once(DOKU_INC.'inc/parserutils.php'); -require_once(DOKU_INC.'inc/form.php'); /** * Convenience function to quickly build a wikilink -- cgit v1.2.3 From 0af14a6e25ba35e88d96762bc73325838868e3fe Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 1 Feb 2010 15:38:41 +0100 Subject: removed more unneeded require_once() calls --- inc/html.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 5e1d0bab3..2d6c0a093 100644 --- a/inc/html.php +++ b/inc/html.php @@ -296,8 +296,6 @@ function html_hilight_callback($m) { * @author Andreas Gohr */ function html_search(){ - require_once(DOKU_INC.'inc/search.php'); - require_once(DOKU_INC.'inc/fulltext.php'); global $conf; global $QUERY; global $ID; @@ -690,7 +688,6 @@ function html_recent($first=0){ * @author Andreas Gohr */ function html_index($ns){ - require_once(DOKU_INC.'inc/search.php'); global $conf; global $ID; $dir = $conf['datadir']; @@ -828,7 +825,6 @@ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ * @author Michael Klier */ function html_backlinks(){ - require_once(DOKU_INC.'inc/fulltext.php'); global $ID; global $conf; global $lang; @@ -856,7 +852,6 @@ function html_backlinks(){ * @author Andreas Gohr */ function html_diff($text='',$intro=true){ - require_once(DOKU_INC.'inc/DifferenceEngine.php'); global $ID; global $REV; global $lang; -- cgit v1.2.3 From 90df9a4d69a2e467433b419b94fe799d11590539 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 4 Feb 2010 14:50:10 +0100 Subject: Rewrite section edit handling according to #1860 --- inc/html.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 8a215f440..a6ec628cf 100644 --- a/inc/html.php +++ b/inc/html.php @@ -91,22 +91,19 @@ function html_secedit_button($matches){ global $ID; global $INFO; - $edittarget = ($matches[1] === 'SECTION') ? 'plain' : - strtolower($matches[1]); + $nr = $matches[1]; + $target = strtolower($matches[2]); - $section = $matches[3]; - $name = $matches[2]; + $name = $matches[3]; + $section = $matches[4]; - $secedit = ''; - $secedit .= '
'; - $secedit .= html_btn('secedit',$ID,'', + return "
" . + html_btn('secedit',$ID,'', array('do' => 'edit', 'lines' => $section, - 'edittarget' => $edittarget, + 'edittarget' => $target, 'rev' => $INFO['lastmod']), - 'post', $name); - $secedit .= '
'; - return $secedit; + 'post', $name) . '
'; } /** @@ -117,7 +114,7 @@ function html_secedit_button($matches){ function html_secedit($text,$show=true){ global $INFO; - $regexp = '##'; + $regexp = '##'; if($INFO['writable'] && $show && !$INFO['rev']){ $text = preg_replace_callback($regexp, -- cgit v1.2.3 From 40868f2faa85215dfea2fa0c82274a4806d042ab Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 8 Feb 2010 12:50:20 +0100 Subject: Hide secedit buttons without title --- inc/html.php | 65 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 25 deletions(-) (limited to 'inc/html.php') 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 */ -function html_secedit_button($matches){ - global $ID; +function html_secedit($text,$show=true){ global $INFO; - $nr = $matches[1]; - $target = strtolower($matches[2]); + $regexp = '##'; - $name = $matches[3]; - $section = $matches[4]; + if(!$INFO['writable'] || !$show || $INFO['rev']){ + return preg_replace($regexp,'',$text); + } - return "
" . - html_btn('secedit',$ID,'', - array('do' => 'edit', - 'lines' => $section, - 'edittarget' => $target, - 'rev' => $INFO['lastmod']), - 'post', $name) . '
'; + 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 */ -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 + */ +function html_secedit_get_button($data) { + global $ID; global $INFO; - $regexp = '##'; + 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 "
" . + html_btn('secedit', $ID, '', + array_merge(array('do' => 'edit', + 'rev' => $INFO['lastmod']), $data), + 'post', $name) . '
'; } /** -- cgit v1.2.3 From 905fa971d08ada202c78b350303dc6a53c570e01 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 8 Feb 2010 12:58:45 +0100 Subject: Strip (secedit) id from section edit request --- inc/html.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index c2b0db17d..7849cc809 100644 --- a/inc/html.php +++ b/inc/html.php @@ -107,7 +107,7 @@ function html_secedit($text,$show=true){ * @author Andreas Gohr */ function html_secedit_button($matches){ - $data = array('id' => $matches[1], + $data = array('secid' => $matches[1], 'target' => strtolower($matches[2]), 'range' => $matches[count($matches) - 1]); if (count($matches) === 5) { @@ -133,8 +133,11 @@ function html_secedit_get_button($data) { $name = $data['name']; unset($data['name']); + $secid = $data['secid']; + unset($data['secid']); + return "
" . + " editbutton_" . $data['secid'] . "'>" . html_btn('secedit', $ID, '', array_merge(array('do' => 'edit', 'rev' => $INFO['lastmod']), $data), -- cgit v1.2.3 From defa93a1bf01353fdadea22bcc5467baaadca3e0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 8 Feb 2010 13:01:25 +0100 Subject: =?UTF-8?q?I=E2=80=99m=20stupid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 7849cc809..04bb986c5 100644 --- a/inc/html.php +++ b/inc/html.php @@ -137,7 +137,7 @@ function html_secedit_get_button($data) { unset($data['secid']); return "
" . + " editbutton_" . $secid . "'>" . html_btn('secedit', $ID, '', array_merge(array('do' => 'edit', 'rev' => $INFO['lastmod']), $data), -- cgit v1.2.3 From bd0293e7406f93a8897c471193b69413b78b6236 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 28 Feb 2010 12:31:37 +0100 Subject: moved number of search result snippets to a define --- inc/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 04bb986c5..f6f73142c 100644 --- a/inc/html.php +++ b/inc/html.php @@ -373,7 +373,7 @@ function html_search(){ print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex); if($cnt !== 0){ print ': '.$cnt.' '.$lang['hits'].'
'; - if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? + if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only print '
'.ft_snippet($id,$regex).'
'; } $num++; -- cgit v1.2.3 From 8e4da260f71ec0ef3b8559d38fc3f8f22208ec0f Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 4 Mar 2010 11:05:20 +0100 Subject: Output common parts of edit forms before the event --- inc/html.php | 133 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 69 insertions(+), 64 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index f6f73142c..99fa4a9ce 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1195,19 +1195,6 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? } if(!$DATE) $DATE = $INFO['lastmod']; - $data = compact('wr', 'text', 'mod', 'check'); - trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); -} - -/** - * Display the default edit form - * - * Is the default action for HTML_EDIT_FORMSELECTION. - * - * @triggers HTML_EDITFORM_OUTPUT - */ -function html_edit_form($param) { - extract($param); global $conf; global $license; global $lang; @@ -1218,59 +1205,77 @@ function html_edit_form($param) { global $INFO; global $SUM; global $ID; - ?> - - - -
- -
-
-
- -
- 'dw__editform')); - $form->addHidden('id', $ID); - $form->addHidden('rev', $REV); - $form->addHidden('date', $DATE); - $form->addHidden('prefix', $PRE); - $form->addHidden('suffix', $SUF); - $form->addHidden('changecheck', $check); - $attr = array('tabindex'=>'1'); - if (!$wr) $attr['readonly'] = 'readonly'; - $form->addElement(form_makeWikiText($text, $attr)); - $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); - $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); + + $form = new Doku_Form(array('id' => 'dw__editform')); + $form->addHidden('id', $ID); + $form->addHidden('rev', $REV); + $form->addHidden('date', $DATE); + $form->addHidden('prefix', $PRE); + $form->addHidden('suffix', $SUF); + $form->addHidden('changecheck', $check); + + $data = compact('wr', 'text', 'form'); + $data['media_manager'] = true; + trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); + + $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); + $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); + $form->addElement(form_makeCloseTag('div')); + if ($wr) { + $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); + $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); + $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); + $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); $form->addElement(form_makeCloseTag('div')); - if ($wr) { - $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); - $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); - $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); - $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); - $form->addElement(form_makeCloseTag('div')); - $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); - $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); - $elem = html_minoredit(); - if ($elem) $form->addElement($elem); - $form->addElement(form_makeCloseTag('div')); - } + $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); + $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); + $elem = html_minoredit(); + if ($elem) $form->addElement($elem); $form->addElement(form_makeCloseTag('div')); - if($wr && $conf['license']){ - $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); - $out = $lang['licenseok']; - $out .= ''; - $form->addElement($out); - $form->addElement(form_makeCloseTag('div')); - } - html_form('edit', $form); - print '
'.NL; + } + $form->addElement(form_makeCloseTag('div')); + if($wr && $conf['license']){ + $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); + $out = $lang['licenseok']; + $out .= ''; + $form->addElement($out); + $form->addElement(form_makeCloseTag('div')); + } + + if ($wr) { + // sets changed to true when previewed + echo ''; + } ?> +
+ +
+
+
+ +
+ '.NL; +} + +/** + * Display the default edit form + * + * Is the default action for HTML_EDIT_FORMSELECTION. + * + * @triggers HTML_EDITFORM_OUTPUT + */ +function html_edit_form($param) { + extract($param); + $attr = array('tabindex'=>'1'); + if (!$wr) $attr['readonly'] = 'readonly'; + $form->addElement(form_makeWikiText($text, $attr)); } /** -- cgit v1.2.3 From 3f9e3215e07f71f721ddd919b9b06ad5d7cc6742 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 4 Mar 2010 11:01:52 +0100 Subject: Really allow plugins to use section editing --- inc/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 99fa4a9ce..88fa0b4ff 100644 --- a/inc/html.php +++ b/inc/html.php @@ -89,7 +89,7 @@ function html_login(){ function html_secedit($text,$show=true){ global $INFO; - $regexp = '##'; + $regexp = '##'; if(!$INFO['writable'] || !$show || $INFO['rev']){ return preg_replace($regexp,'',$text); -- cgit v1.2.3 From ffde0ac9c67ac7dea5886a325e05300c3a88c163 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 9 Mar 2010 10:37:35 +0100 Subject: Allow plugins to manage edit intro text --- inc/html.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 88fa0b4ff..d9766e543 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1183,28 +1183,18 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? $wr = $INFO['writable'] && !$INFO['locked']; if($wr){ - if ($REV) print p_locale_xhtml('editrev'); - print p_locale_xhtml($include); + if ($REV) $include = 'editrev'; }else{ // check pseudo action 'source' if(!actionOK('source')){ msg('Command disabled: source',-1); return; } - print p_locale_xhtml('read'); + $include = 'read'; } if(!$DATE) $DATE = $INFO['lastmod']; - global $conf; global $license; - global $lang; - global $REV; - global $DATE; - global $PRE; - global $SUF; - global $INFO; - global $SUM; - global $ID; $form = new Doku_Form(array('id' => 'dw__editform')); $form->addHidden('id', $ID); @@ -1216,7 +1206,11 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? $data = compact('wr', 'text', 'form'); $data['media_manager'] = true; + $data['intro_locale'] = $include; trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); + if (isset($data['intro_locale'])) { + echo p_locale_xhtml($data['intro_locale']); + } $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); -- cgit v1.2.3 From 45a9933524f9a31e0a104cccfd082217501017ba Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 9 Mar 2010 11:42:34 +0100 Subject: Move data preprocessing out of html_edit --- inc/html.php | 54 +++++++++++++----------------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index d9766e543..ccab83a24 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1134,54 +1134,26 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? global $ID; global $REV; global $DATE; - global $RANGE; global $PRE; global $SUF; global $INFO; global $SUM; global $lang; global $conf; + global $TEXT; - //set summary default - if(!$SUM){ - if($REV){ - $SUM = $lang['restored']; - }elseif(!$INFO['exists']){ - $SUM = $lang['created']; - } - } - - //no text? Load it! - if(!isset($text)){ - $pr = false; //no preview mode - if($INFO['exists']){ - if($RANGE){ - list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); - }else{ - $text = rawWiki($ID,$REV); - } - $check = md5($text); - $mod = false; - }else{ - //try to load a pagetemplate - $data = array($ID); - $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); - $check = md5(''); - $mod = $text!==''; - } - }else{ - $pr = true; //preview mode - if (isset($_REQUEST['changecheck'])) { - $check = $_REQUEST['changecheck']; - $mod = md5($text)!==$check; - } else { - // Why? Assume default text is unmodified. - $check = md5($text); - $mod = false; - } + if (isset($_REQUEST['changecheck'])) { + $check = $_REQUEST['changecheck']; + } elseif(!$INFO['exists']){ + // $TEXT has been loaded from page template + $check = md5(''); + } else { + $check = md5($TEXT); } + $mod = md5($TEXT) !== $check; $wr = $INFO['writable'] && !$INFO['locked']; + $include = 'edit'; if($wr){ if ($REV) $include = 'editrev'; }else{ @@ -1192,7 +1164,6 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? } $include = 'read'; } - if(!$DATE) $DATE = $INFO['lastmod']; global $license; @@ -1204,7 +1175,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? $form->addHidden('suffix', $SUF); $form->addHidden('changecheck', $check); - $data = compact('wr', 'text', 'form'); + $data = compact('wr', 'form'); $data['media_manager'] = true; $data['intro_locale'] = $include; trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); @@ -1266,10 +1237,11 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? * @triggers HTML_EDITFORM_OUTPUT */ function html_edit_form($param) { + global $TEXT; extract($param); $attr = array('tabindex'=>'1'); if (!$wr) $attr['readonly'] = 'readonly'; - $form->addElement(form_makeWikiText($text, $attr)); + $form->addElement(form_makeWikiText($TEXT, $attr)); } /** -- cgit v1.2.3 From 5a932e77b3c806514203323540cb30e5ab9c28cf Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 9 Mar 2010 11:42:56 +0100 Subject: Remove wordblock action, issue a msg instead --- inc/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index ccab83a24..ae3e56e0a 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1130,7 +1130,7 @@ function html_updateprofile(){ * @triggers HTML_PAGE_FROMTEMPLATE * @author Andreas Gohr */ -function html_edit($text=null,$include='edit'){ //FIXME: include needed? +function html_edit(){ global $ID; global $REV; global $DATE; -- cgit v1.2.3 From fe17917e7668864526ec0f0ae65dd0787831d8a4 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 10 Mar 2010 10:41:32 +0100 Subject: Move & rename HTML_PAGE_FROMTEMPLATE to common.php The new COMMON_PAGE_FROMTEMPLATE is triggered by pageTemplate AFTER the template has been read but before performing the template replacements. --- inc/html.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index ae3e56e0a..cfa4dbe3d 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1127,7 +1127,6 @@ function html_updateprofile(){ /** * Preprocess edit form data * - * @triggers HTML_PAGE_FROMTEMPLATE * @author Andreas Gohr */ function html_edit(){ -- cgit v1.2.3 From 84645d8c01570c5ea4cda556e70beccdec25ee22 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 12 Mar 2010 12:24:04 +0100 Subject: fixed target handling for license link FS#1917 --- inc/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index cfa4dbe3d..3ebba65c8 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1202,7 +1202,7 @@ function html_edit(){ $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); $out = $lang['licenseok']; $out .= ''; $form->addElement($out); $form->addElement(form_makeCloseTag('div')); -- cgit v1.2.3 From 2ffea8f2f2886a64535d5fd81745a8e5944a24c9 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 22 Mar 2010 16:42:58 +0100 Subject: Do not trigger HTML_FORM_SELECTION in some cases When the page is not editable or the section info is out of date, a custom editor should not be used. --- inc/html.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 23eadebc4..86cda46f0 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1121,6 +1121,8 @@ function html_updateprofile(){ * Preprocess edit form data * * @author Andreas Gohr + * + * @triggers HTML_EDITFORM_OUTPUT */ function html_edit(){ global $ID; @@ -1167,10 +1169,16 @@ function html_edit(){ $form->addHidden('suffix', $SUF); $form->addHidden('changecheck', $check); - $data = compact('wr', 'form'); - $data['media_manager'] = true; - $data['intro_locale'] = $include; - trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); + $data = array('form' => $form, + 'wr' => $wr, + 'media_manager' => true, + 'intro_locale' => $include); + if ($wr && $RANGE !== '') { + // Only emit event if page is writable and section edit data is valid. + trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); + } else { + html_edit_form($data); + } if (isset($data['intro_locale'])) { echo p_locale_xhtml($data['intro_locale']); } @@ -1225,8 +1233,6 @@ function html_edit(){ * Display the default edit form * * Is the default action for HTML_EDIT_FORMSELECTION. - * - * @triggers HTML_EDITFORM_OUTPUT */ function html_edit_form($param) { global $TEXT; -- cgit v1.2.3 From d141c8dc0567c892690e1f6ccf66298042034456 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 22 Mar 2010 18:06:17 +0100 Subject: Add missing global declaration --- inc/html.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 86cda46f0..e2128f2bc 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1135,6 +1135,7 @@ function html_edit(){ global $lang; global $conf; global $TEXT; + global $RANGE; if (isset($_REQUEST['changecheck'])) { $check = $_REQUEST['changecheck']; -- cgit v1.2.3 From 12c96ace70f7a177cc40000f905fa3cab633c04a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 23 Mar 2010 12:06:41 +0100 Subject: Send edit target in HTML_EDITFORM_SELECTION --- inc/html.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index e2128f2bc..088f8d3c5 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1173,9 +1173,13 @@ function html_edit(){ $data = array('form' => $form, 'wr' => $wr, 'media_manager' => true, + 'target' => (isset($_REQUEST['target']) && $wr && + $RANGE !== '') ? $_REQUEST['target'] : 'section', 'intro_locale' => $include); - if ($wr && $RANGE !== '') { - // Only emit event if page is writable and section edit data is valid. + + if ($data['target'] !== 'section') { + // Only emit event if page is writable, section edit data is valid and + // edit target is not section. trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); } else { html_edit_form($data); @@ -1237,10 +1241,15 @@ function html_edit(){ */ function html_edit_form($param) { global $TEXT; - extract($param); + + if ($param['target'] !== 'section') { + msg('No editor for edit target ' . $param['target'] . ' found.', -1); + } + $attr = array('tabindex'=>'1'); - if (!$wr) $attr['readonly'] = 'readonly'; - $form->addElement(form_makeWikiText($TEXT, $attr)); + if (!$param['wr']) $attr['readonly'] = 'readonly'; + + $param['form']->addElement(form_makeWikiText($TEXT, $attr)); } /** -- cgit v1.2.3 From b7eccc60d91f1a719b3204da92d4becb2928210e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 24 Mar 2010 11:26:16 +0100 Subject: Keep edit target information for preview --- inc/html.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 088f8d3c5..a8761ad4a 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1188,6 +1188,7 @@ function html_edit(){ echo p_locale_xhtml($data['intro_locale']); } + $form->addHidden('target', $data['target']); $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); $form->addElement(form_makeCloseTag('div')); -- cgit v1.2.3 From 2e61e4df6fa5a971de75b3cefdb0912c9fac7c79 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 25 Mar 2010 11:45:01 +0100 Subject: Fix JavaScript for change detection after preview --- inc/html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index a8761ad4a..4a4cf2739 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1217,9 +1217,9 @@ function html_edit(){ if ($wr) { // sets changed to true when previewed - echo ''; + echo '//-->' . NL; } ?>
-- cgit v1.2.3 From 11c78c94cd43872c1fa380e70027d33226174aba Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 8 May 2010 14:31:57 +0200 Subject: correctly preview no text FS#1945 --- inc/html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 4a4cf2739..c4eb62bc8 100644 --- a/inc/html.php +++ b/inc/html.php @@ -217,7 +217,7 @@ function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ * * @author Andreas Gohr */ -function html_show($txt=''){ +function html_show($txt=null){ global $ID; global $REV; global $HIGH; @@ -229,7 +229,7 @@ function html_show($txt=''){ $secedit = true; } - if ($txt){ + if (!is_null($txt)){ //PreviewHeader echo '
'; echo p_locale_xhtml('preview'); -- cgit v1.2.3 From de4d479af254512700b8aedce9c1a597880322b0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 17 May 2010 11:05:23 +0200 Subject: Let actionOK detect auth backend capabilities --- inc/html.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index c4eb62bc8..01823449e 100644 --- a/inc/html.php +++ b/inc/html.php @@ -45,7 +45,6 @@ function html_login(){ global $lang; global $conf; global $ID; - global $auth; print p_locale_xhtml('login'); print '
'.NL; @@ -61,14 +60,14 @@ function html_login(){ $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); $form->endFieldset(); - if($auth && $auth->canDo('addUser') && actionOK('register')){ + if(actionOK('register')){ $form->addElement('

' . $lang['reghere'] . ': '.$lang['register'].'' . '

'); } - if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { + if (actionOK('resendpwd')) { $form->addElement('

' . $lang['pwdforget'] . ': '.$lang['btn_resendpwd'].'' -- cgit v1.2.3 From 8d22f1e96be5aa2c65ecb6ee934debbfe0f8f4cc Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 26 Jun 2010 13:38:10 +0200 Subject: Changes to the ft_pageLookup and related event FS#1978 This patch changes the ft_pageLookup function to always return the title of pages with the result. This makes it easier to work with the array, as it no longer changes between numeric and key indexes depending on useheading. This also means that action plugins subscribed to SEARCH_QUERY_PAGELOOKUP need to be adjusted. The event contains a new data field called 'has_titles' which plugins can use to check for backwards compatibility. --- inc/html.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 01823449e..7e842e052 100644 --- a/inc/html.php +++ b/inc/html.php @@ -336,18 +336,22 @@ function html_search(){ //do quick pagesearch $data = array(); - if($id) $data = ft_pageLookup($id); + if($id) $data = ft_pageLookup($id,true,useHeading('navigation')); if(count($data)){ print '

'; print '

'.$lang['quickhits'].':

'; print '
    '; - foreach($data as $id){ + foreach($data as $id => $title){ print '
  • '; - $ns = getNS($id); - if($ns){ - $name = shorten(noNS($id), ' ('.$ns.')',30); + if (useHeading('navigation')) { + $name = $title; }else{ - $name = $id; + $ns = getNS($id); + if($ns){ + $name = shorten(noNS($id), ' ('.$ns.')',30); + }else{ + $name = $id; + } } print html_wikilink(':'.$id,$name); print '
  • '; -- cgit v1.2.3 From b150cd2c5cb9ad4413773a774f6eaa17fbd3795e Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sat, 26 Jun 2010 17:50:16 +0200 Subject: FS#1901: prefill section name into summary when editing sections --- inc/html.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 7e842e052..3398e8fb9 100644 --- a/inc/html.php +++ b/inc/html.php @@ -137,7 +137,8 @@ function html_secedit_get_button($data) { " editbutton_" . $secid . "'>" . html_btn('secedit', $ID, '', array_merge(array('do' => 'edit', - 'rev' => $INFO['lastmod']), $data), + 'rev' => $INFO['lastmod'], + 'summary' => '['.$name.'] '), $data), 'post', $name) . '
'; } -- cgit v1.2.3 From 226bf2dc02909d49bb6afbd7b5018572aeba6050 Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sun, 27 Jun 2010 18:18:10 +0200 Subject: FS#1821: Added a permalink to the diff output --- inc/html.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 3398e8fb9..1b9a8d680 100644 --- a/inc/html.php +++ b/inc/html.php @@ -991,6 +991,12 @@ function html_diff($text='',$intro=true){ $tdf = new TableDiffFormatter(); if($intro) print p_locale_xhtml('diff'); + + if (!$text) { + ptln('

'); + ptln(' '.$lang['difflink'].''); + ptln('

'); + } ?> -- cgit v1.2.3 From 8d9e6ae7b19a9971ec0d95cc904de6c07e6647dc Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Fri, 2 Jul 2010 23:56:08 +0100 Subject: improved diff permalink --- inc/html.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 1b9a8d680..b475e2b7a 100644 --- a/inc/html.php +++ b/inc/html.php @@ -993,9 +993,10 @@ function html_diff($text='',$intro=true){ if($intro) print p_locale_xhtml('diff'); if (!$text) { - ptln('

'); - ptln(' '.$lang['difflink'].''); - ptln('

'); + $diffurl = wl($ID, array('do'=>'diff', 'rev2[0]'=>$l_rev, 'rev2[1]'=>$r_rev)); + ptln(''); } ?>
-- cgit v1.2.3