]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
allow user properties in documentation files
authorEvan Prodromou <evan@status.net>
Mon, 18 Apr 2011 10:17:28 +0000 (06:17 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 18 Apr 2011 10:17:28 +0000 (06:17 -0400)
lib/util.php

index 13966b2dd6533cd05440aa452cc80155684a866c..086372a7801f3d4f629feb31c2abf3e718328982 100644 (file)
@@ -1933,12 +1933,40 @@ function common_confirmation_code($bits)
 
 function common_markup_to_html($c)
 {
+    $c = preg_replace('/%%user.(\w+)%%/e', "common_user_property('\\1')", $c);
     $c = preg_replace('/%%action.(\w+)%%/e', "common_local_url('\\1')", $c);
     $c = preg_replace('/%%doc.(\w+)%%/e', "common_local_url('doc', array('title'=>'\\1'))", $c);
     $c = preg_replace('/%%(\w+).(\w+)%%/e', 'common_config(\'\\1\', \'\\2\')', $c);
     return Markdown($c);
 }
 
+function common_user_property($property)
+{
+    $profile = Profile::current();
+
+    if (empty($profile)) {
+        return null;
+    }
+
+    switch ($property) {
+    case 'profileurl':
+    case 'nickname':
+    case 'fullname':
+    case 'location':
+    case 'bio':
+        return $profile->$property;
+        break;
+    case 'avatar':
+        return $profile->getAvatar(AVATAR_STREAM_SIZE);
+        break;
+    case 'bestname':
+        return $profile->getBestName();
+        break;
+    default:
+        return null;
+    }
+}
+
 function common_profile_uri($profile)
 {
     if (!$profile) {