CauseFX преди 4 години
родител
ревизия
670925f089
променени са 1 файла, в които са добавени 25 реда и са изтрити 0 реда
  1. 25 0
      api/functions/organizr-functions.php

+ 25 - 0
api/functions/organizr-functions.php

@@ -7,6 +7,31 @@ trait OrganizrFunctions
 		return 'https://organizr.gitbook.io/organizr/' . $path;
 	}
 	
+	public function loadResources($files = [], $rootPath = '')
+	{
+		$scripts = '';
+		if (count($files) > 0) {
+			foreach ($files as $file) {
+				if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'js') {
+					$scripts .= $this->loadJavaResource($file, $rootPath);
+				} elseif (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'css') {
+					$scripts .= $this->loadStyleResource($file, $rootPath);
+				}
+			}
+		}
+		return $scripts;
+	}
+	
+	public function loadJavaResource($file = '', $rootPath = '')
+	{
+		return ($file !== '') ? '<script src="' . $rootPath . $file . '?v=' . trim($this->fileHash) . '"></script>' . "\n" : '';
+	}
+	
+	public function loadStyleResource($file = '', $rootPath = '')
+	{
+		return ($file !== '') ? '<link href="' . $rootPath . $file . '?v=' . trim($this->fileHash) . '" rel="stylesheet">' . "\n" : '';
+	}
+	
 	public function loadDefaultJavascriptFiles()
 	{
 		$javaFiles = [