From b72788d9ce8a2eb05572ce923aebd3027cb87bb6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 18 Apr 2011 09:47:08 -0400 Subject: [PATCH] pass args from Docfile to renderer --- lib/docfile.php | 8 ++++++-- lib/util.php | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/docfile.php b/lib/docfile.php index feba930b43..982177315a 100644 --- a/lib/docfile.php +++ b/lib/docfile.php @@ -90,13 +90,17 @@ class DocFile } } - function toHTML() + function toHTML($args=null) { + if (is_null($args)) { + $args = array(); + } + if (empty($this->contents)) { $this->contents = file_get_contents($this->filename); } - return common_markup_to_html($this->contents); + return common_markup_to_html($this->contents, $args); } static function defaultPaths() diff --git a/lib/util.php b/lib/util.php index 05c5407cdb..be954feb49 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1933,6 +1933,10 @@ function common_confirmation_code($bits) function common_markup_to_html($c, $args=null) { + if (is_null($args)) { + $args = array(); + } + $c = preg_replace('/%%arg.(\w+)%%/', "{$args['\\1']}", $c); $c = preg_replace('/%%user.(\w+)%%/e', "common_user_property('\\1')", $c); $c = preg_replace('/%%action.(\w+)%%/e', "common_local_url('\\1')", $c);