From 1a461924336f8ab227c135e13d7661b7a4f1e1df Mon Sep 17 00:00:00 2001
From: Bart Visscher <bartv@thisnet.nl>
Date: Mon, 3 Sep 2012 18:13:45 +0200
Subject: [PATCH] Add args parameter to linkTo(Absolute) function, to append
 the args automaticly

---
 lib/helper.php      | 12 +++++++++---
 lib/public/util.php | 10 ++++++----
 lib/template.php    |  5 +++--
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/lib/helper.php b/lib/helper.php
index 3cf464dfa7..ea43304da5 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -32,11 +32,12 @@ class OC_Helper {
 	 * @brief Creates an url
 	 * @param $app app
 	 * @param $file file
+	 * @param $args array with param=>value, will be appended to the returned url
 	 * @returns the url
 	 *
 	 * Returns a url to the given app and file.
 	 */
-	public static function linkTo( $app, $file ){
+	public static function linkTo( $app, $file, $args = array() ){
 		if( $app != '' ){
 			$app_path = OC_App::getAppPath($app);
 			// Check if the app is in the app folder
@@ -61,6 +62,10 @@ class OC_Helper {
 			}
 		}
 
+		foreach($args as $k => $v) {
+			$urlLinkTo .= '&'.$k.'='.$v;
+		}
+
 		return $urlLinkTo;
 	}
 
@@ -68,12 +73,13 @@ class OC_Helper {
 	 * @brief Creates an absolute url
 	 * @param $app app
 	 * @param $file file
+	 * @param $args array with param=>value, will be appended to the returned url
 	 * @returns the url
 	 *
 	 * Returns a absolute url to the given app and file.
 	 */
-	public static function linkToAbsolute( $app, $file ) {
-		$urlLinkTo = self::linkTo( $app, $file );
+	public static function linkToAbsolute( $app, $file, $args = array() ) {
+		$urlLinkTo = self::linkTo( $app, $file, $args );
 		return self::makeURLAbsolute($urlLinkTo);
 	}
 
diff --git a/lib/public/util.php b/lib/public/util.php
index 6ad578441e..cc05e6d535 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -124,12 +124,13 @@ class Util {
 	 * @brief Creates an absolute url
 	 * @param $app app
 	 * @param $file file
+	 * @param $args array with param=>value, will be appended to the returned url
 	 * @returns the url
 	 *
 	 * Returns a absolute url to the given app and file.
 	 */
-	public static function linkToAbsolute( $app, $file ) {
-		return(\OC_Helper::linkToAbsolute( $app, $file ));
+	public static function linkToAbsolute( $app, $file, $args = array() ) {
+		return(\OC_Helper::linkToAbsolute( $app, $file, $args ));
 	}
 
 
@@ -160,12 +161,13 @@ class Util {
 	* @brief Creates an url
 	* @param $app app
 	* @param $file file
+	* @param $args array with param=>value, will be appended to the returned url
 	* @returns the url
 	*
 	* Returns a url to the given app and file.
 	*/
-	public static function linkTo( $app, $file ){
-		return(\OC_Helper::linkTo( $app, $file ));
+	public static function linkTo( $app, $file, $args = array() ){
+		return(\OC_Helper::linkTo( $app, $file, $args ));
 	}
 
 	/**
diff --git a/lib/template.php b/lib/template.php
index fa8d419261..2359bd50c4 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -25,12 +25,13 @@
  * @brief make OC_Helper::linkTo available as a simple function
  * @param $app app
  * @param $file file
+ * @param $args array with param=>value, will be appended to the returned url
  * @returns link to the file
  *
  * For further information have a look at OC_Helper::linkTo
  */
-function link_to( $app, $file ){
-	return OC_Helper::linkTo( $app, $file );
+function link_to( $app, $file, $args = array() ){
+	return OC_Helper::linkTo( $app, $file, $args );
 }
 
 /**
-- 
GitLab