Merging Vector's navigation_urls and SkinTemplate's content_actions code into content...
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index cf0c4b6..d636b44 100644 (file)
@@ -595,6 +595,26 @@ function wfMessage( $key /*...*/) {
        return new Message( $key, $params );
 }
 
+/**
+ * This function accepts multiple message keys and returns a message instance
+ * for the first message which is non-empty. If all messages are empty then an
+ * instance of the first message key is returned.
+ * Varargs: message keys
+ * @return \type{Message}
+ * @since 1.18
+ */
+function wfMessageFallback( /*...*/ ) {
+       $keys = func_get_args();
+       $first = $keys[0];
+       foreach ( $keys as $key ) {
+               if ( wfEmptyMsg( $key ) ) {
+                       continue;
+               }
+               return wfMessage( $key );
+       }
+       return wfMessage( $first );
+}
+
 /**
  * Get a message from anywhere, for the current user language.
  *