浏览代码

Add a new text array that is used in the translations.

Mark Crane 10 年之前
父节点
当前提交
7c03b47ce8
共有 1 个文件被更改,包括 55 次插入0 次删除
  1. 55 0
      resources/classes/text.php

+ 55 - 0
resources/classes/text.php

@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * Get the text for the correct translation
+ * 
+ * @method array get
+ */
+class text {
+
+	/**
+	 * Called when the object is created
+	 */
+	public function __construct() {
+		//get the list of languages that are available
+		if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/translate")) {
+			include("app/translate/translate_include.php");
+		}
+	}
+
+	/**
+	 * Called when there are no references to a particular object
+	 * unset the variables used in the class
+	 */
+	public function __destruct() {
+		foreach ($this as $key => $value) {
+			unset($this->$key);
+		}
+	}
+
+	/**
+	 * Get a specific item from the cache
+	 * @var string $path		examples: app/exec or core/domains
+	 */
+	public function get($path) {
+		//get the app_languages.php
+			if (strlen($path) > 0) {
+				require_once glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/".$path."/app_{languages}.php",GLOB_BRACE);
+			}
+			else {
+				require_once getcwd().'/app_languages.php';
+			}
+
+		//add multi-lingual support
+			foreach($text as $key => $value) {
+				$text[$key] = $value[$_SESSION['domain']['language']['code']];
+			}
+
+		//return the array of translations
+			return $text;
+
+	}
+
+}
+
+?>