Lexer->addSpecialPattern( $this->getConf('actickets.hash').self::PATTERN_FULLTICKET.'|'. $this->getConf('actickets.hash').self::PATTERN_TICKET.'|'. self::PATTERN_PROJECT ,$mode,'plugin_actickets'); } public function handle($match, $state, $pos, &$handler){ $data = array(); if (preg_match('/'.self::PATTERN_PROJECT_GRP.'/', $match, $matches)) { $this->projectId = $matches[1]; } else if (preg_match('/'.$this->getConf('actickets.hash').self::PATTERN_FULLTICKET_GRP.'/', $match, $matches)) { $data['ticketId'] = $matches[1]; $data['projectId'] = $matches[2]; } else if (preg_match('/'.$this->getConf('actickets.hash').self::PATTERN_TICKET_GRP.'/', $match, $matches)) { $data['ticketId'] = $matches[1]; $data['projectId'] = $this->projectId; if (is_null($this->projectId)) { $data['original'] = $match; } } else { throw new Exception("This should not happen, blame the actickets plugin."); } return $data; } public function render($mode, &$renderer, $data) { if($mode != 'xhtml') return false; if (!empty($data)) { if (!is_null($data['projectId'])) { $url = $this->getConf('actickets.url'); if (substr($url, -1) != '/') { $url .= '/'; } $url .= 'public/index.php/projects/'.$data['projectId'].'/tickets/'.$data['ticketId']; $renderer->doc .= ''; $renderer->doc .= $this->getConf('actickets.hash').$data['ticketId']; $renderer->doc .= ''; } else { $renderer->doc .= $data['original']; } } return true; } } // vim:ts=4:sw=4:et: