소스 검색

added support for tools from active project

Piotr Labudda 8 년 전
부모
커밋
e5982293bf
5개의 변경된 파일38개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 0
      SE/se-lib/Route/Storage/Tools.php
  2. 6 2
      SE/se-lib/RouteBase.php
  3. 11 0
      SE/se-lib/RouteToolBase.php
  4. 12 0
      SE/se-lib/Router.php
  5. 7 0
      SE/se-lib/Schema/SystemFunctionStorageAcl.php

+ 2 - 0
SE/se-lib/Route/Storage/Tools.php

@@ -13,6 +13,8 @@ class Route_Storage_Tools extends RouteBase {
 	public function defaultView() {
 	public function defaultView() {
 		echo $this->getLink();
 		echo $this->getLink();
 		throw new Exception("TODO...");
 		throw new Exception("TODO...");
+		// TODO: @see RouteBase::reinstall()
+		// TODO: SE/projects/{activeProject}/tools/*.php
 	}
 	}
 
 
 }
 }

+ 6 - 2
SE/se-lib/RouteBase.php

@@ -21,10 +21,14 @@ class RouteBase {
 		die("default task not implemented");
 		die("default task not implemented");
 	}
 	}
 
 
-	public function getLink($task = '', $args = null) {
+	public function getUrlRouteName() {
 		$clsName = get_class($this);
 		$clsName = get_class($this);
 		if ('Route_' != substr($clsName, 0, strlen('Route_'))) throw new Exception("Wrong route class name '{$clsName}'");
 		if ('Route_' != substr($clsName, 0, strlen('Route_'))) throw new Exception("Wrong route class name '{$clsName}'");
-		$routeName = substr($clsName, strlen('Route_'));
+		return substr($clsName, strlen('Route_'));
+	}
+
+	public function getLink($task = '', $args = null) {
+		$routeName = $this->getUrlRouteName();
 		if (empty($args)) return Request::getPathUri() . "index.php?_route={$routeName}" . (!empty($task) ? "&_task={$task}" : "");
 		if (empty($args)) return Request::getPathUri() . "index.php?_route={$routeName}" . (!empty($task) ? "&_task={$task}" : "");
 		if (is_string($args)) {
 		if (is_string($args)) {
 			return Request::getPathUri() . "index.php?_route={$routeName}" . (!empty($task) ? "&_task={$task}" : "") . ltrim($args, '&');
 			return Request::getPathUri() . "index.php?_route={$routeName}" . (!empty($task) ? "&_task={$task}" : "") . ltrim($args, '&');

+ 11 - 0
SE/se-lib/RouteToolBase.php

@@ -0,0 +1,11 @@
+<?php
+
+Lib::loadClass('RouteBase');
+
+class RouteToolBase extends RouteBase {
+
+	public function getUrlRouteName() {
+		return "UrlAction_" . get_class($this);
+	}
+
+}

+ 12 - 0
SE/se-lib/Router.php

@@ -40,6 +40,18 @@ class Router {
 		if (array_key_exists($route, $_routeInstances)) return $_routeInstances[$route];
 		if (array_key_exists($route, $_routeInstances)) return $_routeInstances[$route];
 
 
 		$routeClassName = "Route_{$route}";
 		$routeClassName = "Route_{$route}";
+		if ('UrlAction' === substr($route, 0, strlen('UrlAction'))) { // Use project/{$activeProject}/tools/{$routeName}.php
+			$routeClassName = substr($route, strlen('UrlAction') + 1);
+			$activeProjectPath = Config::getProjectPath();
+			$toolPath = "{$activeProjectPath}/tools/{$routeClassName}.php";
+			if (file_exists($toolPath)) {
+				require_once $toolPath;
+				if (!class_exists($routeClassName)) throw new HttpException("Not found class", 404);
+				$_routeInstances[$route] = new $routeClassName();
+				return $_routeInstances[$route];
+			}
+		}
+
 		if (Lib::tryLoadClass($routeClassName)) {
 		if (Lib::tryLoadClass($routeClassName)) {
 			$_routeInstances[$route] = new $routeClassName();
 			$_routeInstances[$route] = new $routeClassName();
 			return $_routeInstances[$route];
 			return $_routeInstances[$route];

+ 7 - 0
SE/se-lib/Schema/SystemFunctionStorageAcl.php

@@ -62,6 +62,13 @@ class Schema_SystemFunctionStorageAcl extends Core_AclSimpleSchemaBase {
 		static $_cacheAllItems = null;
 		static $_cacheAllItems = null;
 		if (null !== $_cacheAllItems) return $_cacheAllItems;
 		if (null !== $_cacheAllItems) return $_cacheAllItems;
 
 
+		// TODO: read from filesystem
+		// TODO: set ON / OFF in companies settings or remote repo for company tools
+		// TODO: install Tool into CRM_LISTA_ZASOBOW - auto
+		// TODO: panel for connect tool with table - Storage_Tools
+		// - TODO: @see RouteBase::reinstall()
+		// - TODO: SE/projects/{activeProject}/tools/*.php
+
 		$_cacheAllItems = [];
 		$_cacheAllItems = [];
 		$_cacheAllItems[] = [ 'name' => "Calendar", 'description' => "Calendar" ];
 		$_cacheAllItems[] = [ 'name' => "Calendar", 'description' => "Calendar" ];
 		$_cacheAllItems[] = [ 'name' => "ProcesEditor", 'description' => "ProcesEditor" ];
 		$_cacheAllItems[] = [ 'name' => "ProcesEditor", 'description' => "ProcesEditor" ];