[xoops-cvslog 6195] CVS update: xoops2jp/html/core

Back to archive index

Minahito minah****@users*****
2007年 2月 26日 (月) 13:01:46 JST


Index: xoops2jp/html/core/XCube_Utils.class.php
diff -u xoops2jp/html/core/XCube_Utils.class.php:1.1.2.5 xoops2jp/html/core/XCube_Utils.class.php:1.1.2.5.2.1
--- xoops2jp/html/core/XCube_Utils.class.php:1.1.2.5	Tue Dec 26 23:30:54 2006
+++ xoops2jp/html/core/XCube_Utils.class.php	Mon Feb 26 13:01:46 2007
@@ -2,7 +2,7 @@
 /**
  *
  * @package XCube
- * @version $Id: XCube_Utils.class.php,v 1.1.2.5 2006/12/26 14:30:54 nobunobu Exp $
+ * @version $Id: XCube_Utils.class.php,v 1.1.2.5.2.1 2007/02/26 04:01:46 minahito Exp $
  * @copyright Copyright 2005, 2006 XOOPS Cube Project <http://xoopscube.org/>
  * @license http://xoopscube.sourceforge.net/bsd_licenses.txt Modified BSD license
  *
@@ -29,8 +29,14 @@
 		$root =& XCube_Root::getSingleton();
 		$root->mController->executeRedirect($url, $time, $messages);
 	}
-	
-	function formatMessage()
+
+	/**
+	 * @static
+	 * @brief Formats string with special care for international.
+	 * @remark This method doesn't implement the provider which knows how to
+	 *         format for each locales. So, this method is interim implement.
+	 */
+	function formatString()
 	{
 		$arr = func_get_args();
 		
@@ -38,12 +44,48 @@
 			return null;
 		
 		$message = $arr[0];
-		for($i = 1; $i < count($arr); $i++) {
-			$message = str_replace("{" . ($i-1) . "}", $arr[$i], $message);
+		
+		$variables = array();
+		if (is_array($arr[1])) {
+			$variables = $arr[1];
+		}
+		else {
+			$variables = $arr;
+			array_pop($variables);
+		}
+		
+		for ($i = 0; $i < count($variables); $i++) {
+			$message = str_replace("{" . ($i) . "}", $variables[$i], $message);
+			
+			// Temporary....
+			$message = str_replace("{" . ($i) . ":ucfirst}", ucfirst($variables[$i]), $message);
+			$message = str_replace("{" . ($i) . ":strtolower}", strtolower($variables[$i]), $message);
+			$message = str_replace("{" . ($i) . ":strtoupper}", strtoupper($variables[$i]), $message);
 		}
 		
 		return $message;
 	}
+
+	/**
+	 * @deprecated
+	 * @see XCube_Utils::formatString()
+	 */	
+	function formatMessage()
+	{
+		$arr = func_get_args();
+		
+		if (count($arr) == 0) {
+			return null;
+		}
+		else if (count($arr) == 1) {
+			return XCube_Utils::formatString($arr[0]);
+		}
+		else if (count($arr) > 1) {
+			$vals = $arr;
+			array_pop($vals);
+			return XCube_Utils::formatString($arr[0], $vals);
+		}
+	}
 	
 	/**
 	 * @deprecated


xoops-cvslog メーリングリストの案内
Back to archive index