Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial stand-alone plugin for markdown, moved all dependencies to the plugin folder. - revert CoreFormatting back to its original state, as well as other, unneeded previous changes - disable all processing in MantisCoreFormatting if enabled - turn MantisCoreFormatting back on if Markdown is uninstalled - hook EVENT_CORE_HEADERS to enable images referenced from the internet
- Loading branch information
Showing
12 changed files
with
195 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
/** | ||
* MantisBT - A PHP based bugtracking system | ||
* | ||
* MantisBT is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MantisBT is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with MantisBT. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net | ||
*/ | ||
|
||
require_api( 'mention_api.php' ); | ||
require_once( 'core/MantisMarkdown.php' ); | ||
|
||
/** | ||
* Mantis Markdown Plugin | ||
*/ | ||
class MantisMarkdownPlugin extends MantisPlugin { | ||
|
||
/** | ||
* Initialized any needed methods, api's, etc... | ||
* | ||
* Make sure to turn Text Processing off, causing markdown to not render properly | ||
* @return void | ||
*/ | ||
function init() { | ||
|
||
if ( ON == config_get( 'plugin_MantisCoreFormatting_process_text' ) ) { | ||
config_set( 'plugin_MantisCoreFormatting_process_text', OFF ); | ||
} | ||
|
||
if ( ON == config_get( 'plugin_MantisCoreFormatting_process_urls' ) ) { | ||
config_set( 'plugin_MantisCoreFormatting_process_urls', OFF ); | ||
} | ||
|
||
if ( ON == config_get( 'plugin_MantisCoreFormatting_process_buglinks' ) ) { | ||
config_set( 'plugin_MantisCoreFormatting_process_buglinks', OFF ); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Make sure to turn Text Processing back on uninstall | ||
* reset it back to MantisCoreFormatting position | ||
*/ | ||
function uninstall() { | ||
config_set( 'plugin_MantisCoreFormatting_process_text', ON ); | ||
config_set( 'plugin_MantisCoreFormatting_process_urls', ON ); | ||
config_set( 'plugin_MantisCoreFormatting_process_buglinks', ON ); | ||
} | ||
|
||
/** | ||
* A method that populates the plugin information and minimum requirements. | ||
* @return void | ||
*/ | ||
function register() { | ||
$this->name = lang_get( 'plugin_markdown_title' ); | ||
$this->description = lang_get( 'plugin_markdown_description' ); | ||
|
||
$this->version = MANTIS_VERSION; | ||
$this->requires = array( | ||
'MantisCore' => '2.0.0', | ||
); | ||
|
||
$this->author = 'MantisBT Team'; | ||
$this->contact = 'mantisbt-dev@lists.sourceforge.net'; | ||
$this->url = 'http://www.mantisbt.org'; | ||
} | ||
|
||
/** | ||
* Event hook declaration. | ||
* @return array | ||
*/ | ||
function hooks() { | ||
return array( | ||
'EVENT_DISPLAY_FORMATTED' => 'markdown', # Formatted String Display | ||
'EVENT_CORE_HEADERS' => 'csp_headers' | ||
); | ||
} | ||
|
||
/** | ||
* Add img-src directives to enable to referenced images from internet. | ||
* @return void | ||
*/ | ||
function csp_headers() { | ||
http_csp_add( 'img-src', "*" ); | ||
} | ||
|
||
/** | ||
* Markdown processing. | ||
* | ||
* Performs markdown and bug links processing | ||
* | ||
* @param string $p_event Event name. | ||
* @param string $p_string Raw text to process. | ||
* @param boolean $p_multiline True for multiline text (default), false for single-line. | ||
* | ||
* @return string The html text | ||
*/ | ||
function markdown( $p_event, $p_string, $p_multiline = true ) { | ||
|
||
$t_string = $p_string; | ||
|
||
# Process bug links | ||
$t_string = string_process_bug_link( $t_string ); | ||
$t_string = string_process_bugnote_link( $t_string ); | ||
|
||
$t_string = mention_format_text( $t_string, true ); | ||
|
||
# Markdown processing | ||
if ( $p_multiline ) { | ||
$t_string = MantisMarkdown::convert_text( $t_string ); | ||
} else { | ||
$t_string = MantisMarkdown::convert_line( $t_string ); | ||
} | ||
|
||
return $t_string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
# MantisBT - A PHP based bugtracking system | ||
|
||
# MantisBT is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MantisBT is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Language File - English (English) | ||
* | ||
* ********************************************************************** | ||
* ** This file is generated from translations stored in translatewiki ** | ||
* ** Information on Copyright/License for translatewiki translations ** | ||
* ** is available at http://translatewiki.net/wiki/Project:About ** | ||
* ********************************************************************** | ||
* ** ** | ||
* ** DO NOT UPDATE MANUALLY ** | ||
* ** ** | ||
* ** To improve a translation please visit http://translatewiki.net ** | ||
* ** Detailed instructions on how to create or update translations at ** | ||
* ** http://www.mantisbt.org/wiki/doku.php/mantisbt:translationshowto ** | ||
* ********************************************************************** | ||
* | ||
* See the qqq 'language' for message documentation incl. usage of parameters | ||
* | ||
* @ingroup Language | ||
* @file | ||
* @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net | ||
* @link http://www.mantisbt.org | ||
* | ||
*/ | ||
|
||
$s_plugin_markdown_title = 'MantisBT Markdown'; | ||
$s_plugin_markdown_description = 'Official Markdown plugin.'; | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters