Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
0f5e7090
Commit
0f5e7090
authored
9 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
we have working save and revert buttons
parent
6ea007c9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/plugins/styler/action.php
+66
-7
66 additions, 7 deletions
lib/plugins/styler/action.php
lib/plugins/styler/admin.php
+3
-0
3 additions, 0 deletions
lib/plugins/styler/admin.php
with
69 additions
and
7 deletions
lib/plugins/styler/action.php
+
66
−
7
View file @
0f5e7090
...
@@ -19,8 +19,8 @@ class action_plugin_styler extends DokuWiki_Action_Plugin {
...
@@ -19,8 +19,8 @@ class action_plugin_styler extends DokuWiki_Action_Plugin {
*/
*/
public
function
register
(
Doku_Event_Handler
$controller
)
{
public
function
register
(
Doku_Event_Handler
$controller
)
{
$controller
->
register_hook
(
'AJAX_CALL_UNKNOWN'
,
'BEFORE'
,
$this
,
'handle_ajax'
);
$controller
->
register_hook
(
'AJAX_CALL_UNKNOWN'
,
'BEFORE'
,
$this
,
'handle_ajax'
);
$controller
->
register_hook
(
'ACTION_ACT_PREPROCESS'
,
'BEFORE'
,
$this
,
'handle_action'
);
$controller
->
register_hook
(
'ACTION_ACT_PREPROCESS'
,
'BEFORE'
,
$this
,
'handle_action'
);
}
}
...
@@ -35,31 +35,90 @@ class action_plugin_styler extends DokuWiki_Action_Plugin {
...
@@ -35,31 +35,90 @@ class action_plugin_styler extends DokuWiki_Action_Plugin {
public
function
handle_action
(
Doku_Event
&
$event
,
$param
)
{
public
function
handle_action
(
Doku_Event
&
$event
,
$param
)
{
$event
->
data
=
act_clean
(
$event
->
data
);
$event
->
data
=
act_clean
(
$event
->
data
);
if
(
$event
->
data
===
'styler_plugin_preview'
)
{
if
(
$event
->
data
===
'styler_plugin_preview'
)
{
msg
(
'handle'
)
;
$event
->
data
=
'show'
;
$event
->
data
=
'show'
;
$this
->
preview
();
$this
->
preview
();
}
elseif
(
$event
->
data
===
'styler_plugin_
save
'
)
{
}
elseif
(
$event
->
data
===
'styler_plugin_
reset
'
)
{
$event
->
data
=
'show'
;
$event
->
data
=
'show'
;
$this
->
reset
();
}
elseif
(
$event
->
data
===
'styler_plugin_revert'
)
{
$event
->
data
=
'show'
;
$this
->
revert
();
}
elseif
(
$event
->
data
===
'styler_plugin_save'
)
{
$event
->
data
=
'show'
;
$this
->
save
();
}
}
}
}
protected
function
preview
(){
/**
* saves the preview.ini
*/
protected
function
preview
()
{
global
$conf
;
global
$conf
;
$ini
=
$conf
[
'cachedir'
]
.
'/preview.ini'
;
$ini
=
$conf
[
'cachedir'
]
.
'/preview.ini'
;
io_saveFile
(
$ini
,
$this
->
makeini
());
io_saveFile
(
$ini
,
$this
->
makeini
());
}
}
/**
* deletes the preview.ini
*/
protected
function
reset
()
{
global
$conf
;
$ini
=
$conf
[
'cachedir'
]
.
'/preview.ini'
;
io_saveFile
(
$ini
,
''
);
}
/**
* deletes the local style.ini replacements
*/
protected
function
revert
()
{
$this
->
replaceini
(
''
);
$this
->
reset
();
}
/**
* save the local style.ini replacements
*/
protected
function
save
()
{
$this
->
replaceini
(
$this
->
makeini
());
$this
->
reset
();
}
/**
* create the replacement part of a style.ini from submitted data
*
* @return string
*/
protected
function
makeini
()
{
protected
function
makeini
()
{
global
$INPUT
;
global
$INPUT
;
$ini
=
"[replacements]
\n
"
;
$ini
=
"[replacements]
\n
"
;
foreach
(
$INPUT
->
arr
(
'tpl'
)
as
$key
=>
$val
)
{
foreach
(
$INPUT
->
arr
(
'tpl'
)
as
$key
=>
$val
)
{
$ini
.
=
$key
.
' = "'
.
addslashes
(
$val
)
.
'"'
.
"
\n
"
;
$ini
.
=
$key
.
' = "'
.
addslashes
(
$val
)
.
'"'
.
"
\n
"
;
}
}
return
$ini
;
return
$ini
;
}
}
/**
* replaces the replacement parts in the local ini
*
* @param string $new the new ini contents
*/
protected
function
replaceini
(
$new
)
{
global
$conf
;
$ini
=
DOKU_CONF
.
"tpl/"
.
$conf
[
'template'
]
.
"/style.ini"
;
if
(
file_exists
(
$ini
))
{
$old
=
io_readFile
(
$ini
);
$old
=
preg_replace
(
'/\[replacements\]\n.*?(\n\[.*]|$)/s'
,
'\\1'
,
$old
);
$old
=
trim
(
$old
);
}
else
{
$old
=
''
;
}
io_makeFileDir
(
$ini
);
io_saveFile
(
$ini
,
"
$old
\n\n
$new
"
);
}
/**
/**
* [Custom event handler which performs action]
* [Custom event handler which performs action]
*
*
...
...
This diff is collapsed.
Click to expand it.
lib/plugins/styler/admin.php
+
3
−
0
View file @
0f5e7090
...
@@ -61,6 +61,9 @@ class admin_plugin_styler extends DokuWiki_Admin_Plugin {
...
@@ -61,6 +61,9 @@ class admin_plugin_styler extends DokuWiki_Admin_Plugin {
}
}
echo
'</table>'
;
echo
'</table>'
;
echo
'<input type="submit" name="do[styler_plugin_preview]" value="preview">'
;
echo
'<input type="submit" name="do[styler_plugin_preview]" value="preview">'
;
echo
'<input type="submit" name="do[styler_plugin_reset]" value="reset current">'
;
#FIXME only if preview.ini exists
echo
'<input type="submit" name="do[styler_plugin_revert]" value="revert to original">'
;
#FIXME only if local.ini exists
echo
'<input type="submit" name="do[styler_plugin_save]" value="save">'
;
echo
'</form>'
;
echo
'</form>'
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment