Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xml2html-pkp-plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
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
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
FNSO
FAIREST
xml2html-pkp-plugin
Commits
4a0ea8dd
Commit
4a0ea8dd
authored
1 year ago
by
Jerome Chauveau
Browse files
Options
Downloads
Patches
Plain Diff
first elements of settings form
parent
584b9af6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
XML2HTMLPlugin.php
+48
-0
48 additions, 0 deletions
XML2HTMLPlugin.php
XML2HTMLSettingsForm.inc.php
+73
-0
73 additions, 0 deletions
XML2HTMLSettingsForm.inc.php
templates/settingsForm.tpl
+13
-0
13 additions, 0 deletions
templates/settingsForm.tpl
with
134 additions
and
0 deletions
XML2HTMLPlugin.php
+
48
−
0
View file @
4a0ea8dd
...
...
@@ -119,6 +119,54 @@ class XML2HTMLPlugin extends GenericPlugin
return
'This plugin transform XML articles to HTML'
;
}
/**
* @param $request
* @param $verb
* @return mixed
*/
public
function
getActions
(
$request
,
$verb
)
{
$router
=
$request
->
getRouter
();
import
(
'lib.pkp.classes.linkAction.request.AjaxModal'
);
return
array_merge
(
$this
->
getEnabled
()
?
array
(
new
LinkAction
(
'settings'
,
new
AjaxModal
(
$router
->
url
(
$request
,
null
,
null
,
'manage'
,
null
,
array
(
'verb'
=>
'settings'
,
'plugin'
=>
$this
->
getName
(),
'category'
=>
'generic'
)),
$this
->
getDisplayName
()
),
__
(
'manager.plugins.settings'
),
null
),
)
:
array
(),
parent
::
getActions
(
$request
,
$verb
)
);
}
public
function
manage
(
$args
,
$request
)
{
switch
(
$request
->
getUserVar
(
'verb'
))
{
case
'settings'
:
AppLocale
::
requireComponents
(
LOCALE_COMPONENT_APP_COMMON
,
LOCALE_COMPONENT_PKP_MANAGER
);
$this
->
import
(
'XML2HTMLSettingsForm'
);
$form
=
new
XML2HTMLSettingsForm
(
$this
,
$request
->
getContext
()
->
getId
());
if
(
$request
->
getUserVar
(
'save'
))
{
$form
->
readInputData
();
if
(
$form
->
validate
())
{
$form
->
execute
();
$notificationManager
=
new
NotificationManager
();
$notificationManager
->
createTrivialNotification
(
$request
->
getUser
()
->
getId
());
return
new
JSONMessage
(
true
);
}
}
else
{
$form
->
initData
();
}
return
new
JSONMessage
(
true
,
$form
->
fetch
(
$request
));
}
return
parent
::
manage
(
$args
,
$request
);
}
function
getPluginAssetsPath
(
$request
)
{
return
$request
->
getBaseUrl
()
.
'/'
.
$this
->
getPluginPath
()
.
'/resources/'
;
}
...
...
This diff is collapsed.
Click to expand it.
XML2HTMLSettingsForm.inc.php
0 → 100644
+
73
−
0
View file @
4a0ea8dd
<?php
import
(
'lib.pkp.classes.form.Form'
);
class
XML2HTMLSettingsForm
extends
Form
{
private
static
$FORMAT_SETTING
=
"format"
;
private
$_contextId
;
private
$_plugin
;
/**
* Constructor
* @param $plugin xml2html plugin
* @param $contextId int Context ID
*/
function
__construct
(
$plugin
,
$contextId
)
{
$this
->
_contextId
=
$contextId
;
$this
->
_plugin
=
$plugin
;
parent
::
__construct
(
$plugin
->
getTemplateResource
(
'settingsForm.tpl'
));
$this
->
addCheck
(
new
FormValidatorPost
(
$this
));
$this
->
addCheck
(
new
FormValidatorCSRF
(
$this
));
}
/**
* Initialize form data.
*/
function
initData
()
{
$contextId
=
$this
->
_contextId
;
$plugin
=
$this
->
_plugin
;
$this
->
setData
(
'format'
,
$plugin
->
getSetting
(
$contextId
,
XML2HTMLSettingsForm
::
$FORMAT
));
}
/**
* Assign form data to user-submitted data.
*/
function
readInputData
()
{
$this
->
readUserVars
(
array
(
XML2HTMLSettingsForm
::
$FORMAT
));
//
// // if recent items is selected, check that we have a value
// if ($this->getData('displayItems') == 'recent') {
// $this->addCheck(new FormValidator($this, 'recentItems', 'required', 'plugins.generic.webfeed.settings.recentItemsRequired'));
// }
}
/**
* Fetch the form.
* @copydoc Form::fetch()
*/
function
fetch
(
$request
,
$template
=
null
,
$display
=
false
)
{
$templateMgr
=
TemplateManager
::
getManager
(
$request
);
$templateMgr
->
assign
(
'pluginName'
,
$this
->
_plugin
->
getName
());
return
parent
::
fetch
(
$request
);
}
/**
* @copydoc Form::execute()
*/
function
execute
(...
$functionArgs
)
{
$plugin
=
$this
->
_plugin
;
$contextId
=
$this
->
_contextId
;
$plugin
->
updateSetting
(
$contextId
,
XML2HTMLSettingsForm
::
$FORMAT
,
$this
->
getData
(
XML2HTMLSettingsForm
::
$FORMAT
));
parent
::
execute
(
...
$functionArgs
);
}
}
This diff is collapsed.
Click to expand it.
templates/settingsForm.tpl
0 → 100644
+
13
−
0
View file @
4a0ea8dd
<script>
$
(
function
()
{
ldelim
}
// Attach the form handler.
$
(
'
#xml2htmlSettingsForm
'
).
pkpHandler
(
'
$.pkp.controllers.form.AjaxFormHandler
'
);
{
rdelim
}
);
</script>
<form
class=
"pkp_form"
id=
"xml2htmlSettingsForm"
method=
"post"
action=
"
{
url
router
=
$smarty.const.ROUTE_COMPONENT
op
=
"manage"
category
=
"generic"
plugin
=
$pluginName
verb
=
"settings"
save
=
true
}
"
>
<div
id=
"xml2htmlSettings"
>
TEST
</div>
</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