[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/plugins/MantisCoreFormatting/ -> MantisCoreFormatting.php (source)

   1  <?php
   2  # MantisBT - A PHP based bugtracking system
   3  # Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
   4  # MantisBT is free software: you can redistribute it and/or modify
   5  # it under the terms of the GNU General Public License as published by
   6  # the Free Software Foundation, either version 2 of the License, or
   7  # (at your option) any later version.
   8  #
   9  # MantisBT is distributed in the hope that it will be useful,
  10  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  # GNU General Public License for more details.
  13  #
  14  # You should have received a copy of the GNU General Public License
  15  # along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  class MantisCoreFormattingPlugin extends MantisFormattingPlugin {
  18  
  19      /**
  20       *  A method that populates the plugin information and minimum requirements.
  21       */
  22  	function register( ) {
  23          $this->name = lang_get( 'plugin_format_title' );
  24          $this->description = lang_get( 'plugin_format_description' );
  25          $this->page = 'config';
  26  
  27          $this->version = '1.0a';
  28          $this->requires = array(
  29              'MantisCore' => '1.2.0',
  30          );
  31  
  32          $this->author = 'MantisBT Team';
  33          $this->contact = 'mantisbt-dev@lists.sourceforge.net';
  34          $this->url = 'http://www.mantisbt.org';
  35      }
  36  
  37      /**
  38       * Default plugin configuration.
  39       */
  40  	function config() {
  41          return array(
  42              'process_text'        => ON,
  43              'process_urls'        => ON,
  44              'process_buglinks'    => ON,
  45          );
  46      }
  47  
  48      /**
  49       * Plain text processing.
  50       * @param string Event name
  51       * @param string Unformatted text
  52       * @param boolean Multiline text
  53       * @return multi Array with formatted text and multiline paramater
  54       */
  55  	function text( $p_event, $p_string, $p_multiline = true ) {
  56          static $s_text;
  57  
  58          $t_string = $p_string;
  59  
  60          if( null === $s_text ) {
  61              $s_text = plugin_config_get( 'process_text' );
  62          }
  63  
  64          if( ON == $s_text ) {
  65              $t_string = string_strip_hrefs( $t_string );
  66              $t_string = string_html_specialchars( $t_string );
  67              $t_string = string_restore_valid_html_tags( $t_string, /* multiline = */ true );
  68  
  69              if( $p_multiline ) {
  70                  $t_string = string_preserve_spaces_at_bol( $t_string );
  71                  $t_string = string_nl2br( $t_string );
  72              }
  73          }
  74  
  75          return $t_string;
  76      }
  77  
  78      /**
  79       * Formatted text processing.
  80       * @param string Event name
  81       * @param string Unformatted text
  82       * @param boolean Multiline text
  83       * @return multi Array with formatted text and multiline paramater
  84       */
  85  	function formatted( $p_event, $p_string, $p_multiline = true ) {
  86          static $s_text, $s_urls, $s_buglinks;
  87  
  88          $t_string = $p_string;
  89  
  90          if( null === $s_text ) {
  91              $s_text = plugin_config_get( 'process_text' );
  92              $s_urls = plugin_config_get( 'process_urls' );
  93              $s_buglinks = plugin_config_get( 'process_buglinks' );
  94          }
  95  
  96          if( ON == $s_text ) {
  97              $t_string = string_strip_hrefs( $t_string );
  98              $t_string = string_html_specialchars( $t_string );
  99              $t_string = string_restore_valid_html_tags( $t_string, /* multiline = */ true );
 100  
 101              if( $p_multiline ) {
 102                  $t_string = string_preserve_spaces_at_bol( $t_string );
 103                  $t_string = string_nl2br( $t_string );
 104              }
 105          }
 106  
 107          if( ON == $s_urls ) {
 108              $t_string = string_insert_hrefs( $t_string );
 109          }
 110  
 111          if( ON == $s_buglinks ) {
 112              $t_string = string_process_bug_link( $t_string );
 113              $t_string = string_process_bugnote_link( $t_string );
 114          }
 115  
 116          return $t_string;
 117      }
 118  
 119      /**
 120       * RSS text processing.
 121       * @param string Event name
 122       * @param string Unformatted text
 123       * @return string Formatted text
 124       */
 125  	function rss( $p_event, $p_string ) {
 126          static $s_text, $s_urls, $s_buglinks;
 127  
 128          $t_string = $p_string;
 129  
 130          if( null === $s_text ) {
 131              $s_text = plugin_config_get( 'process_text' );
 132              $s_urls = plugin_config_get( 'process_urls' );
 133              $s_buglinks = plugin_config_get( 'process_buglinks' );
 134          }
 135  
 136          if( ON == $s_text ) {
 137              $t_string = string_strip_hrefs( $t_string );
 138              $t_string = string_html_specialchars( $t_string );
 139              $t_string = string_restore_valid_html_tags( $t_string );
 140              $t_string = string_nl2br( $t_string );
 141          }
 142  
 143          if( ON == $s_urls ) {
 144              $t_string = string_insert_hrefs( $t_string );
 145          }
 146  
 147          if( ON == $s_buglinks ) {
 148              $t_string = string_process_bug_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
 149              $t_string = string_process_bugnote_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
 150          }
 151  
 152          return $t_string;
 153      }
 154  
 155      /**
 156       * Email text processing.
 157       * @param string Event name
 158       * @param string Unformatted text
 159       * @return string Formatted text
 160       */
 161  	function email( $p_event, $p_string ) {
 162          static $s_text, $s_buglinks;
 163  
 164          $t_string = $p_string;
 165  
 166          if( null === $s_text ) {
 167              $s_text = plugin_config_get( 'process_text' );
 168              $s_buglinks = plugin_config_get( 'process_buglinks' );
 169          }
 170  
 171          if( ON == $s_text ) {
 172              $t_string = string_strip_hrefs( $t_string );
 173          }
 174  
 175          if( ON == $s_buglinks ) {
 176              $t_string = string_process_bug_link( $t_string, false );
 177              $t_string = string_process_bugnote_link( $t_string, false );
 178          }
 179  
 180          return $t_string;
 181      }
 182  }


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7