Skip to content

Commit

Permalink
DescriptionField plugin on GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis POKORSKI committed Dec 15, 2020
0 parents commit 083cf5b
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 0 deletions.
75 changes: 75 additions & 0 deletions DescriptionField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* Created by PhpStorm.
* User: apokorski
* Date: 26/07/2018
* Time: 11:27
*/

class DescriptionFieldPlugin extends MantisPlugin {

function register() {
$this->name = lang_get( 'plugin_description_title' );
$this->description = lang_get( 'plugin_description_description' );
$this->page = 'config';

$this->version = '1.0';
$this->requires = array(
'MantisCore' => '2.0.0',
);

$this->author = 'Alexis POKORSKI';
$this->contact = '';
$this->url = '';
}

function hooks(){
return array(
"EVENT_CORE_HEADERS" => 'csp_headers',
"EVENT_LAYOUT_RESOURCES" => 'ressources',
"EVENT_LAYOUT_PAGE_FOOTER" => 'update_description'
);
}

function ressources(){
if(basename($_SERVER['PHP_SELF']) === 'bug_report_page.php') {
echo '<script type="text/javascript" src="' . plugin_file('UpdateDescriptionTextArea.js') . '" ></script>';
}
}

function update_description(){
if(basename($_SERVER['PHP_SELF']) === 'bug_report_page.php') {
$f_master_bug_id = gpc_get_int( 'm_id', 0 );
if($f_master_bug_id == 0){
$description = json_encode(plugin_config_get('description_text'));
echo '<script type="text/javascript"> setDescription('. $description . '); </script>';
}
}
}

function csp_headers(){
http_csp_add( 'script-src', "'unsafe-inline'" );
}

/**
* Default plugin configuration.
* @return array
*/
function config() {
return array(
'description_text' => '[u]Profil (Navigateur, utilisateur, poste de travail)[/u]:
[u]Description[/u] :
[u]Étapes pour reproduire[/u] :
[u]Résultat attendu[/u] :
'
);
}




}
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
DescriptionField
=============
## Description

Mantis Bug Tracker plugin which add template on description field when you report a ticket.

If you want to guide your users in describing the problems, use this plugin !

## Repository Information

| Branch | Description |
| ------------------------------------------------------------ | ------------------------------------------------------ |
| [master](https://github.com/VirusTwo/DescriptionField) | Support for MantisBT 2.x (current production version). |


## Installation

1. Download the files and place the folder `DescriptionField` in the directory `plugins/` of your Mantis installation.
2. With administrator privileges, go to the page *"Manage"* / *"Manage Plugins"*
3. In the list *"Available Plugins"*, you should see *"DescriptionField"*: click the install link for the plugin.
4. When you have install, you can click on it to configure description template directly in configuration page.

The DescriptionField plugin is now available.

## Change Log

## Screenshots & Gif :

What change DescriptionField plugin ?

![DescriptionFieldConfig](https://github.com/VirusTwo/DescriptionField/blob/master/screenshots/descriptionFieldConfigScreen.PNG)


![DescriptionFieldScreen](https://github.com/VirusTwo/DescriptionField/blob/master/screenshots/descriptionFieldScreen.png)


4 changes: 4 additions & 0 deletions files/UpdateDescriptionTextArea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

function setDescription(description) {
$('textarea[name="description"]').val(description);
};
6 changes: 6 additions & 0 deletions lang/strings_english.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$s_plugin_description_title = 'Template of description field';
$s_plugin_description_description = 'Adds a description template to guide users';
$s_plugin_description_config = 'Config';
$s_plugin_description_template_title = 'Description Template :';

6 changes: 6 additions & 0 deletions lang/strings_french.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$s_plugin_description_title = 'Template de description';
$s_plugin_description_description = 'Ajoute un template de description pour orienter les utilisateurs.';
$s_plugin_description_config = 'Configuration';
$s_plugin_description_template_title = 'Template de description';

53 changes: 53 additions & 0 deletions pages/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
auth_reauthenticate( );
access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );

layout_page_header( lang_get( 'plugin_description_title' ) );

layout_page_begin( 'manage_overview_page.php' );

print_manage_menu( 'manage_plugin_page.php' );

?>

<div class="col-md-12 col-xs-12">
<div class="space-10"></div>
<div class="form-container" >

<form id="formatting-config-form" action="<?php echo plugin_page( 'config_edit' )?>" method="post">
<?php echo form_security_field( 'plugin_format_config_edit' ) ?>

<div class="widget-box widget-color-blue2">
<div class="widget-header widget-header-small">
<h4 class="widget-title lighter">
<i class="ace-icon fa fa-text-width"></i>
<?php echo lang_get( 'plugin_description_title' ) . ': ' . lang_get( 'plugin_description_config' )?>
</h4>
</div>
<div class="widget-body">
<div class="widget-main no-padding">
<div class="table-responsive">
<table class="table table-bordered table-condensed table-striped">
<tr>
<th class="category width-40">
<?php echo lang_get( 'plugin_description_template_title' )?>
</th>
<td class="center" width="20%">
<textarea name="description" cols="80" rows="10"><?php echo plugin_config_get('description_text')?></textarea>
</td>
</tr>

</table>
</div>
</div>
<div class="widget-toolbox padding-8 clearfix">
<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'change_configuration' )?>" />
</div>
</div>
</div>
</form>
</div>
</div>

<?php
layout_page_end();
15 changes: 15 additions & 0 deletions pages/config_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
form_security_validate( 'plugin_format_config_edit' );

auth_reauthenticate( );
access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );

$f_description_text = gpc_get_string( 'description');

if( plugin_config_get( 'description_text' ) != $f_description_text ) {
plugin_config_set( 'description_text', $f_description_text );
}

form_security_purge( 'plugin_format_config_edit' );

print_successful_redirect( plugin_page( 'config', true ) );
Binary file added screenshots/descriptionFieldConfigScreen.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/descriptionFieldScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 083cf5b

Please sign in to comment.