name = plugin_lang_get( 'title' ); $this->description = plugin_lang_get( 'description' ); $this->page = ''; $this->version = '0.1'; $this->requires = array( 'MantisCore' => '2.3.0-dev', ); $this->author = 'Irene Knapp'; $this->contact = 'ireneista@internetsafetylabs.org'; $this->url = 'https://irenes.space'; /* The MantisCoreFormatting plugin already does bug links. We could * reimplement its logic, but it's simpler to just override its * configuration. We set it in memory, not in the database, so that * uninstalling MantisSmalltech will change it back. * * MantisCoreFormatting also has an "issue note" syntax, for links within * a single issue thread. We leave that one at its default. */ config_set_global( 'bug_link_tag', 'b/', true ); } /** * plugin hooks * @return array */ function hooks() { $t_hooks = array( 'EVENT_DISPLAY_BUG_ID' => 'display_bug_id', 'EVENT_DISPLAY_FORMATTED' => 'display_formatted', ); return $t_hooks; } function display_bug_id( $p_event_name, $p_string, $p_number ) { return sprintf( 'b/%u', $p_number ); } function display_formatted( $p_event, $p_string, $p_multiline = true ): string { /* This is better documented in the Gerrit config. If you read that one * first, there's just two things to keep in mind about this one. * * 1. Gerrit applies HTML-escaping to the input prior to letting us see * it, Mantis gives us raw input. * * 2. Gerrit expects HTML output; Mantis expects Markdown. */ $p_string = preg_replace( '/(?<=(?:^|(?<=\\s)))((?:[\\(\\[\\{\'"])*)' . 'cl\\/(\\d+)' . '(?=(?:[\\.,;?!\\)\\]\\}\'"])*(?:$|(?=\\s)))/', '\\1[cl/\\2](https://gerrit.internetsafetylabs.org/c/\\2)', $p_string); return $p_string; } }