Piotr Labudda 4 سال پیش
کامیت
f559319b32
6فایلهای تغییر یافته به همراه148 افزوده شده و 0 حذف شده
  1. 42 0
      auth.php
  2. 10 0
      config-example.php
  3. 0 0
      schema/ant-object/.gitkeep
  4. 39 0
      theme/base.php
  5. 42 0
      tools/ExampleTool.php
  6. 15 0
      tools/ExampleTool.php.example.js

+ 42 - 0
auth.php

@@ -0,0 +1,42 @@
+<?php
+
+// rename file to: `config.php`
+// @used by User class to login
+// - [ ] use to fetch user groups for acl
+
+/**
+ * User object:
+ * - ID // ADM_ID
+ * - ADM_ACCOUNT // AUTHORIZE_USER, ADM_ACCOUNT
+ * - ADM_NAME // ADM_NAME
+ * - ADM_TECH_WORKER // ADM_TECH_WORKER
+ * - ADM_COMPANY // ADM_COMPANY
+ * - ADM_ADMIN_LEVEL // ADM_ADMIN_LEVEL
+ * - ADM_PHONE // ADM_PHONE
+ * - ADM_ADMIN_EXPIRE // ADM_ADMIN_EXPIRE
+ * - ADM_ADMIN_DESC // ADM_ADMIN_DESC
+ * - EMPLOYEE_TYPE // EMPLOYEE_TYPE
+ * - EMAIL_IMAP_IMPORT_HOST // EMAIL_IMAP_IMPORT_HOST
+ * - EMAIL_IMAP_IMPORT_USERNAME // EMAIL_IMAP_IMPORT_USERNAME
+ */
+
+class Theme_Auth_Panel_biall_net { // TODO: implements AuthBaseInterface {
+
+	static function auth($login, $pass) { // @return User object or null
+		return null;
+
+		return (object)[
+			'ID' => "", // ADM_ID
+			'ADM_ACCOUNT' => "", // AUTHORIZE_USER, ADM_ACCOUNT
+			'ADM_NAME' => "", // ADM_NAME
+			'ADM_TECH_WORKER' => "", // ADM_TECH_WORKER
+			'ADM_COMPANY' => "", // ADM_COMPANY
+			'ADM_ADMIN_LEVEL' => "", // ADM_ADMIN_LEVEL
+			'ADM_PHONE' => "", // ADM_PHONE
+			'ADM_ADMIN_EXPIRE' => "", // ADM_ADMIN_EXPIRE
+			'ADM_ADMIN_DESC' => "", // ADM_ADMIN_DESC
+			'EMPLOYEE_TYPE' => "", // EMPLOYEE_TYPE
+		];
+	}
+
+}

+ 10 - 0
config-example.php

@@ -0,0 +1,10 @@
+<?php
+
+// rename file to: `config.php`
+// @use: Config::get('VIEW_TABLE_HIDE_PROCESS_LIST')
+
+return [
+    'VIEW_TABLE_HIDE_PROCESS_LIST' => true,
+    'LEGACY_INIT_FUNCTIONS_OFF' => true,
+    'VIEW_TABLE_HIDE_BASE_ROW_FUNCTIONS' => true,
+];

+ 0 - 0
schema/ant-object/.gitkeep


+ 39 - 0
theme/base.php

@@ -0,0 +1,39 @@
+<?php
+
+// TODO: file and class name must have the same name as project
+
+class Theme_base extends ThemeDefault {
+
+	// function head() { // TODO: echo 'html tag inside <head>'
+	// }
+
+	// function top() { // TODO: first tag after body: top menu or header
+	// 	include dirname(__FILE__) . '/Bocian/top.php';
+	// }
+
+	// function footer() { // TODO: before </body>
+	// 	include dirname(__FILE__) . '/view/footer.php';
+	// }
+
+	// function login($data) { // TODO: login view
+	// 	if (is_array($data) && !empty($data)) {
+	// 		extract($data);
+	// 	}
+	// 	include dirname(__FILE__) . '/view/login.php';
+	// }
+
+	// function logout($data) { // TODO: logout view
+	// 	if (is_array($data) && !empty($data)) {
+	// 		extract($data);
+	// 	}
+	// 	include dirname(__FILE__) . '/view/logout.php';
+	// }
+
+	// function home($data) { // TODO: home page view
+	// 	if (is_array($data) && !empty($data)) {
+	// 		extract($data);
+	// 	}
+	// 	include dirname(__FILE__) . '/view/home.php';
+	// }
+
+}

+ 42 - 0
tools/ExampleTool.php

@@ -0,0 +1,42 @@
+<?php
+
+Lib::loadClass('RouteToolBase');
+Lib::loadClass('UI');
+Lib::loadClass('Response');
+Lib::loadClass('Theme');
+
+// class name must have the same name as file
+// index.php?_route=UrlAction_ExampleTool  - uruchamia defaultAction
+class RouteTool_ExampleTool extends RouteToolBase {
+
+	public function defaultAction() {
+		UI::gora();
+		Theme::top();
+		echo '<h1>Example Tool</h1>';
+		UI::inlineJS(__FILE__ . '.example.js', [
+			'URL_TEST_AJAX_ACTION' => $this->getLink('testAjax'),
+		]);
+		UI::dol();
+	}
+
+	public function testAjaxAction() {
+		Response::sendTryCatchJson(array($this, 'testAjax'), $_REQUEST); // args from request
+		// Response::sendTryCatchJson(array($this, 'testAjax'), $args = 'JSON_FROM_REQUEST_BODY'); // args from json request
+	}
+	public function testAjax($args) { // args given by sendTryCatchJson
+		$items = [
+			[ 'ID' => 1, 'name' => 'x', 'desc' => 'a' ],
+			[ 'ID' => 2, 'name' => 'y', 'desc' => 'b' ],
+			[ 'ID' => 3, 'name' => 'z',  'desc' => 'c' ],
+		];
+
+		return [
+			'type' => 'success',
+			'msg' => 'OK',
+			'body' => [
+				'items' => $items,
+			]
+		];
+	}
+
+}

+ 15 - 0
tools/ExampleTool.php.example.js

@@ -0,0 +1,15 @@
+console.log('URL_TEST_AJAX_ACTION:', URL_TEST_AJAX_ACTION)
+
+if (!URL_TEST_AJAX_ACTION) {
+	throw "Brak zmiennej URL_TEST_AJAX_ACTION"
+}
+
+global.fetch(URL_TEST_AJAX_ACTION, { // @doc https://github.com/github/fetch
+	credentials: 'same-origin', // or 'include' for CORS
+}).then(function (response) {
+	return response.json()
+}).then(function (data) {
+	console.log('data', data)
+}).catch(function (e) {
+	console.warn('Error', e)
+})