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
fd51614b
Commit
fd51614b
authored
11 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
enable/disable extensions via AJAX FS#2927
parent
c6d9f1e8
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/extension/action.php
+29
-10
29 additions, 10 deletions
lib/plugins/extension/action.php
lib/plugins/extension/script.js
+46
-4
46 additions, 4 deletions
lib/plugins/extension/script.js
with
75 additions
and
14 deletions
lib/plugins/extension/action.php
+
29
−
10
View file @
fd51614b
...
...
@@ -28,25 +28,23 @@ class action_plugin_extension extends DokuWiki_Action_Plugin {
* @param Doku_Event $event
* @param $param
*/
public
function
info
(
Doku_Event
&
$event
,
$param
){
public
function
info
(
Doku_Event
&
$event
,
$param
)
{
global
$USERINFO
;
global
$INPUT
;
if
(
$event
->
data
!=
'plugin_extension'
)
return
;
$event
->
preventDefault
();
$event
->
stopPropagation
();
if
(
empty
(
$_SERVER
[
'REMOTE_USER'
])
||
!
auth_isadmin
(
$_SERVER
[
'REMOTE_USER'
],
$USERINFO
[
'grps'
])){
if
(
empty
(
$_SERVER
[
'REMOTE_USER'
])
||
!
auth_isadmin
(
$_SERVER
[
'REMOTE_USER'
],
$USERINFO
[
'grps'
]))
{
http_status
(
403
);
echo
'Forbidden'
;
exit
;
}
header
(
'Content-Type: text/html; charset=utf-8'
);
$ext
=
$INPUT
->
str
(
'ext'
);
if
(
!
$ext
)
{
http_status
(
400
);
echo
'no extension given'
;
return
;
}
...
...
@@ -55,11 +53,32 @@ class action_plugin_extension extends DokuWiki_Action_Plugin {
$extension
=
plugin_load
(
'helper'
,
'extension_extension'
);
$extension
->
setExtension
(
$ext
);
/** @var helper_plugin_extension_list $list */
$list
=
plugin_load
(
'helper'
,
'extension_list'
);
echo
$list
->
make_info
(
$extension
);
$act
=
$INPUT
->
str
(
'act'
);
switch
(
$act
)
{
case
'enable'
:
case
'disable'
:
$json
=
new
JSON
();
$extension
->
$act
();
//enables/disables
$reverse
=
(
$act
==
'disable'
)
?
'enable'
:
'disable'
;
$return
=
array
(
'state'
=>
$act
.
'd'
,
// isn't English wonderful? :-)
'reverse'
=>
$reverse
,
'label'
=>
$extension
->
getLang
(
'btn_'
.
$reverse
)
);
header
(
'Content-Type: application/json'
);
echo
$json
->
encode
(
$return
);
break
;
case
'info'
:
default
:
/** @var helper_plugin_extension_list $list */
$list
=
plugin_load
(
'helper'
,
'extension_list'
);
header
(
'Content-Type: text/html; charset=utf-8'
);
echo
$list
->
make_info
(
$extension
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/plugins/extension/script.js
+
46
−
4
View file @
fd51614b
jQuery
(
function
(){
var
$extmgr
=
jQuery
(
'
#extension__manager
'
);
/**
* Confirm uninstalling
*/
jQuery
(
'
#extension__manager
input.uninstall
'
).
click
(
function
(
e
){
$extmgr
.
find
(
'
input.uninstall
'
).
click
(
function
(
e
){
if
(
!
window
.
confirm
(
LANG
.
plugins
.
extension
.
reallydel
)){
e
.
preventDefault
();
return
false
;
...
...
@@ -15,7 +17,7 @@ jQuery(function(){
* very simple lightbox
* @link http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/super-simple-lightbox-with-css-and-jquery/
*/
jQuery
(
'
#extension__manager
a.extension_screenshot
'
).
click
(
function
(
e
)
{
$extmgr
.
find
(
'
a.extension_screenshot
'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
//Get clicked link href
...
...
@@ -41,10 +43,49 @@ jQuery(function(){
return
false
;
});
/**
* Enable/Disable extension via AJAX
*/
$extmgr
.
find
(
'
input.disable, input.enable
'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
var
$btn
=
jQuery
(
this
);
// get current state
var
extension
=
$btn
.
attr
(
'
name
'
).
split
(
'
[
'
)[
2
];
extension
=
extension
.
substr
(
0
,
extension
.
length
-
1
);
var
act
=
(
$btn
.
hasClass
(
'
disable
'
))
?
'
disable
'
:
'
enable
'
;
// disable while we wait
$btn
.
attr
(
'
disabled
'
,
'
disabled
'
);
$btn
.
css
(
'
cursor
'
,
'
wait
'
);
// execute
jQuery
.
get
(
DOKU_BASE
+
'
lib/exe/ajax.php
'
,
{
call
:
'
plugin_extension
'
,
ext
:
extension
,
act
:
act
},
function
(
data
)
{
$btn
.
css
(
'
cursor
'
,
''
)
.
removeAttr
(
'
disabled
'
)
.
removeClass
(
'
disable
'
)
.
removeClass
(
'
enable
'
)
.
val
(
data
.
label
)
.
addClass
(
data
.
reverse
)
.
parents
(
'
li
'
)
.
removeClass
(
'
disabled
'
)
.
removeClass
(
'
enabled
'
)
.
addClass
(
data
.
state
);
}
);
});
/**
* AJAX detail infos
*/
jQuery
(
'
#extension__manager
a.info
'
).
click
(
function
(
e
){
$extmgr
.
find
(
'
a.info
'
).
click
(
function
(
e
){
e
.
preventDefault
();
var
$link
=
jQuery
(
this
);
...
...
@@ -60,7 +101,8 @@ jQuery(function(){
DOKU_BASE
+
'
lib/exe/ajax.php
'
,
{
call
:
'
plugin_extension
'
,
ext
:
$link
.
data
(
'
extid
'
)
ext
:
$link
.
data
(
'
extid
'
),
act
:
'
info
'
},
function
(
data
){
$link
.
parent
().
append
(
data
);
...
...
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