Explorar el Código

added Schema Table Factory

Piotr Labudda hace 10 años
padre
commit
bcd6e788be

+ 27 - 0
SE/schema/gui/Schema_TableBase.php

@@ -0,0 +1,27 @@
+<?php
+
+// @docs in Schema_TableFactory
+class Schema_TableBase {
+
+	public function __construct() {
+		$this->_types = array();
+		$this->initTypes();
+	}
+
+	public function initTypes() {// TODO: override
+		// parent::initTypes();// always call parent method
+		// example: $this->_types['WWW'] = 'p5:www_link';
+		// TODO: $this->_types['WWW'] = new Type_Link($params = array('maxLength' => 255, ...));
+	}
+
+	public function fixTypes($types) {
+		if (!is_array($this->_types)) return;
+		foreach ($types as $fldName => $type) {
+			if (array_key_exists($fldName, $this->_types)) {
+				$types[$fldName]['simpleType'] = $this->_types[$fldName];
+			}
+		}
+		return $types;
+	}
+
+}

+ 47 - 0
SE/schema/gui/Schema_TableFactory.php

@@ -0,0 +1,47 @@
+<?php
+
+require_once APP_PATH_SCHEMA . '/gui/Schema_TableBase.php';
+
+/**
+ * Base class for all tables - Schema_TableBase
+ *   CoreTableClass extends from Schema_TableBase
+ *     CompanyTableClass extend from CoreTableClass
+ *
+ * WARNING: to add CompanyTableClass, add CoreTableClass first
+ */
+class Schema_TableFactory {
+
+	public static function build($tableName, $idSource = null, $hostName = '') {
+		//_schemaClass
+		$cleanHostName = str_replace(array(".", "-"), '_', $hostName);
+		$cleanTableName = strtolower($tableName);
+		$cleanSourceName = ($idSource == DB::getPDO()->getZasobId())? 'default_db' : "p5_{$idSource}";
+
+		DBG::_('DBG_SCH', '>2', "cleanHostName", $cleanHostName, __CLASS__, __FUNCTION__, __LINE__);
+		DBG::_('DBG_SCH', '>2', "cleanTableName", $cleanTableName, __CLASS__, __FUNCTION__, __LINE__);
+		DBG::_('DBG_SCH', '>2', "cleanSourceName", $cleanSourceName, __CLASS__, __FUNCTION__, __LINE__);
+		// TODO: fetch form widgets from file config
+		//       "schema/gui/core/{$cleanSourceName}.{$cleanTableName}.php";
+		//       class Schema_Core_{$cleanSourceName}_{$cleanTableName};
+		//   TODO: override by company file config
+		//         "schema/gui/{$cleanHostName}/{$cleanSourceName}.{$cleanTableName}.php";
+		//         class Schema_{$cleanHostName}_{$cleanSourceName}_{$cleanTableName};
+		$pathCoreClass = APP_PATH_SCHEMA . "/gui/core/{$cleanSourceName}.{$cleanTableName}.php";
+		if (!file_exists($pathCoreClass)) throw new Exception("Core Class file not found '{$cleanSourceName}.{$cleanTableName}'");
+		require_once $pathCoreClass;
+		$coreClassName = "Schema__Core__{$cleanSourceName}__{$cleanTableName}";
+		if (!class_exists($coreClassName)) throw new Exception("Config error for schema core class {$cleanSourceName}:{$cleanTableName}");
+
+		if ($cleanHostName) {
+			$pathCompanyClass = APP_PATH_SCHEMA . "/gui/company/{$cleanHostName}/{$cleanSourceName}.{$cleanTableName}.php";
+			$companyClassName = "Schema__{$cleanHostName}__{$cleanSourceName}__{$cleanTableName}";
+			if (!file_exists($pathCompanyClass)) throw new Exception("Host Class file not found '{$cleanHostName}/{$cleanSourceName}.{$cleanTableName}'");
+			require_once $pathCompanyClass;
+			if (!class_exists($companyClassName)) throw new Exception("Config error for schema company class {$cleanSourceName}:{$cleanTableName}");
+			return new $companyClassName();
+		} else {
+			return new $coreClassName();
+		}
+	}
+
+}

+ 5 - 13
SE/schema/gui/company/biuro_biall_net_pl/default_db.test_perms.php

@@ -1,19 +1,11 @@
 <?php
 
-class Schema_biuro_biall_net_pl_default_db_test_perms {
+class Schema__biuro_biall_net_pl__default_db__test_perms extends Schema__Core__default_db__test_perms {
 
-	public function fixTypes($types) {
-		foreach ($types as $fldName => $type) {
-			switch ($fldName) {
-				case 'WWW': {
-					$types[$fldName]['simpleType'] = 'p5:www_link';
-				} break;
-				case 'KATALOG_LINK': {
-					$types[$fldName]['simpleType'] = 'p5:www_link';
-				} break;
-			}
-		}
-		return $types;
+	public function initTypes() {
+		parent::initTypes();
+		//$this->_types['WWW'] = 'p5:www_link';
+		$this->_types['KATALOG_LINK'] = 'p5:www_link';
 	}
 
 }

+ 6 - 14
SE/schema/gui/company/biuro_pro_netmedia_pl/default_db.companies.php

@@ -1,19 +1,11 @@
 <?php
 
-class Schema_biuro_pro_netmedia_pl_default_db_companies {
+class Schema__biuro_pro_netmedia_pl__default_db__companies extends Schema__Core__default_db__companies {
 
-	public function fixTypes($types) {
-		foreach ($types as $fldName => $type) {
-			switch ($fldName) {
-				case 'WWW': {
-					$types[$fldName]['simpleType'] = 'p5:www_link';
-				} break;
-				case 'KATALOG_LINK': {
-					$types[$fldName]['simpleType'] = 'p5:www_link';
-				} break;
-			}
-		}
-		return $types;
+	public function initTypes() {
+		parent::initTypes();
+		$this->_types['WWW'] = 'p5:www_link';
+		$this->_types['KATALOG_LINK'] = 'p5:www_link';
 	}
 
-}
+}

+ 18 - 0
SE/schema/gui/company/biuro_pro_netmedia_pl/default_db.raporty.php

@@ -0,0 +1,18 @@
+<?php
+
+class Schema__biuro_pro_netmedia_pl__default_db__raporty extends Schema_TableBase {
+
+}
+
+/*
+CREATE TRIGGER `_RAPORTY__BEFORE__INSERT` BEFORE INSERT ON `raporty`
+ FOR EACH ROW BEGIN
+	SET NEW.SUMA_H = NEW.1_PN + NEW.2_WT + NEW.3_SR + NEW.4_CZ + NEW.5_PT;
+END
+*/
+/*
+CREATE TRIGGER `_RAPORTY__BEFORE__UPDATE` BEFORE UPDATE ON `raporty`
+ FOR EACH ROW BEGIN
+	SET NEW.SUMA_H = NEW.1_PN + NEW.2_WT + NEW.3_SR + NEW.4_CZ + NEW.5_PT;
+END
+*/

+ 5 - 0
SE/schema/gui/core/default_db.companies.php

@@ -0,0 +1,5 @@
+<?php
+
+class Schema__Core__default_db__companies extends Schema_TableBase {
+
+}

+ 5 - 0
SE/schema/gui/core/default_db.raporty.php

@@ -0,0 +1,5 @@
+<?php
+
+class Schema__Core__default_db__raporty extends Schema_TableBase {
+
+}

+ 10 - 0
SE/schema/gui/core/default_db.test_perms.php

@@ -0,0 +1,10 @@
+<?php
+
+class Schema__Core__default_db__test_perms extends Schema_TableBase {
+
+	public function initTypes() {
+		parent::initTypes();
+		$this->_types['WWW'] = 'p5:www_link';
+	}
+
+}

+ 1 - 1
SE/se-lib/Lib.php

@@ -1,6 +1,6 @@
 <?php
 
-if (!defined('APP_PATH_LIB')) define('APP_PATH_LIB', dirname( __FILE__ ));
+if (!defined('APP_PATH_LIB')) define('APP_PATH_LIB', dirname(__FILE__));
 
 class Lib {
 

+ 250 - 33
SE/se-lib/TableAcl.php

@@ -31,7 +31,7 @@ class TableAcl {
 	private $_fields = array();
 	private $_types = array();
 	private $_virtualFieldsIdList = array();
-	private $_sourceLoaded = false;
+	private $_schemaLoaded = false;
 
 	public function __construct($zasobID) {
 		$this->_zasobID = $zasobID;
@@ -350,6 +350,244 @@ class TableAcl {
 		return true;
 	}
 
+	/**
+	 * @param $taskPerm - 'C', 'W'
+	 */
+	public function getFormItem($taskPerm, $fieldID, $fName, $fValue, $params = array(), $record = null) {
+		$out = '';
+		if (!$this->isAllowed($fieldID, $taskPerm, $record)) {
+			if ($taskPerm == 'R') throw new Exception("Brak uprawnień do odczytu");
+			else if ($taskPerm == 'W') throw new Exception("Brak uprawnień do zapisu");
+			else throw new Exception("Brak uprawnień do tego pola ({$taskPerm})");
+		}
+
+		$colName = $this->_fields[$fieldID]['name'];
+		if ($colName == 'ID') return;
+
+		$colType = $this->getFieldTypeById($fieldID);
+		if (!$colType) throw new Exception("Error - unknown type");
+
+		$item = array();
+		$item['htmlType'] = '';
+		$item['rawColType'] = $colType;
+		return $item;
+
+		$html = new stdClass();
+		$html->_params = array();
+		$html->tag = 'input';
+		$html->cnt = '';
+		$html->attrs = array();
+		$html->attrs['id'] = $fName;
+		$html->attrs['name'] = $fName;
+		$html->attrs['type'] = 'text';
+		$html->attrs['value'] = htmlspecialchars($fValue);
+		if (isset($params['tabindex'])) {
+			$html->attrs['tabindex'] = $params['tabindex'];
+		}
+		if (!$this->hasFieldPerm($fieldID, $taskPerm)) {
+			$html->attrs['disabled'] = 'disabled';
+		}
+		$maxGrid = V::get('maxGrid', 10, $params);
+
+		if (substr($colType['type'], 0, 3) == 'int' 
+				|| substr($colType['type'], 0, 7) == 'tinyint'
+				|| substr($colType['type'], 0, 8) == 'smallint'
+				|| substr($colType['type'], 0, 6) == 'bigint'
+		) {
+			//$h->Type_value = (int)str_replace(array(' ','(',')'), '', substr($h->Type, 4));
+			$html->attrs['type'] = 'number';
+			$html->attrs['class'][] = 'input-small';
+		}
+		else if (substr($colType['type'], 0, 6) == 'double') {
+			$html->attrs['type'] = 'text';
+			$html->attrs['class'][] = 'input-small';
+		}
+		else if (substr($colType['type'], 0, 7) == 'decimal') {
+			$html->attrs['type'] = 'text';
+			$html->attrs['class'][] = 'input-small';
+		}
+		else if (substr($colType['type'], 0, 7) == 'varchar'
+				|| substr($colType['type'], 0, 4) == 'char'
+			) {
+			//$h->Type_value = (int)str_replace(array(' ','(',')'), '', substr($h->Type, 8));
+			$html->attrs['type'] = 'text';
+			$maxLength = (int)str_replace(array(' ','(',')'), '', substr($colType['type'], strpos($colType['type'], '(') + 1, -1));
+			if ($maxLength > 0) {
+				$html->attrs['maxlength'] = $maxLength;
+			}
+			$valLength = strlen($fValue);
+			if (isset($params['widthClass'])) {
+				if ($params['widthClass'] == 'inside-modal') {
+					$html->attrs['style'] = 'width:98%;';
+				} else {
+					$html->attrs['style'] = 'width:98%;';
+				}
+			} else {
+				/*
+				if ($maxLength < 11) {
+					$html->attrs['class'][] = 'span2';
+				} else if ($maxLength < 31) {
+					$html->attrs['class'][] = 'span5';
+				} else if ($maxLength < 51) {
+					$html->attrs['class'][] = (8 <= $maxGrid)? 'span8' : "span{$maxGrid}";
+				} else if ($maxLength < 101) {
+					$html->attrs['class'][] = (10 <= $maxGrid)? 'span10' : "span{$maxGrid}";
+				} else {
+					$html->attrs['class'][] = (12 <= $maxGrid)? 'span12' : "span{$maxGrid}";
+				}
+				*/
+			}
+
+			if ($maxLength > 255) {// Fix for long varchar - use textarea
+				$html->tag = 'textarea';
+				$html->cnt = htmlspecialchars($fValue);
+				$html->attrs['rows'] = '3';
+				unset($html->attrs['type']);
+				unset($html->attrs['value']);
+			}
+		}
+		else if (substr($colType['type'], 0, 4) == 'date') {
+			$testDatePicker = true;
+			if ($testDatePicker) {
+				$html->attrs['type'] = 'text';
+				$html->_params[] = 'date';
+				if (substr($colType['type'], 0, 8) == 'datetime') {
+					$html->attrs['class'][] = 'se_type-datetime';// datetimepicker';
+					$html->attrs['data-format'] = 'yyyy-MM-dd hh:mm';
+					$html->attrs['maxlength'] = 19;
+				} else {
+					$html->attrs['class'][] = 'se_type-date';// datetimepicker';
+					$html->attrs['maxlength'] = 10;
+				}
+				if (substr($html->attrs['value'], 0, 10) == '0000-00-00') {
+					$html->attrs['value'] = '';
+				}
+			} else {
+				$html->attrs['type'] = 'date';
+			}
+		}
+		else if ($colType['type'] == 'time') {
+			$testDatePicker = true;
+			if ($testDatePicker) {
+				$html->attrs['type'] = 'text';
+				$html->_params[] = 'time';
+				$html->attrs['class'][] = 'se_type-time';// datetimepicker';
+				$html->attrs['data-format'] = 'hh:mm:ss';
+				$html->attrs['maxlength'] = 8;
+				if (substr($html->attrs['value'], 0, 8) == '00:00:00') {
+					$html->attrs['value'] = '';
+				}
+			} else {
+				$html->attrs['type'] = 'time';
+			}
+		}
+		else if (substr($colType['type'], 0, 4) == 'enum') {
+			unset($html->attrs['type']);
+			unset($html->attrs['value']);
+			$html->tag = 'select';
+
+			$values = explode(',', str_replace(array('(',')',"'",'"'), '', substr($colType['type'], 5)));
+			$selValue = $fValue;
+			if (empty($selValue) && $selValue !== '0' && !empty($colType['default'])) {
+				if ($taskPerm == 'C') {
+					$selValue = $colType['default'];
+				} else if ($taskPerm == 'W' && $this->isAllowed($fieldID, 'R', $record)) {
+					$selValue = $colType['default'];
+				}
+			}
+
+			$html->cnt .= '<option value="">' . "" . '</option>';
+			if (!empty($selValue) && !in_array($selValue, $values)) {
+				$html->cnt .= '<option value="' . $selValue . '" selected="selected">' . $selValue . '</option>';
+			}
+			foreach ($values as $val) {
+				$sel = ($selValue == $val)? ' selected="selected"' : '';
+				$html->cnt .= '<option value="' . $val . '"' . $sel . '>' . $val . '</option>';
+			}
+		}
+		else if (substr($colType['type'], 0, 4) == 'text'
+			|| substr($colType['type'], 0, 8) == 'tinytext'
+			|| substr($colType['type'], 0, 10) == 'mediumtext'
+			|| substr($colType['type'], 0, 8) == 'longtext'
+		) {
+			$html->tag = 'textarea';
+			$html->cnt = htmlspecialchars($fValue);
+			if (isset($params['widthClass'])) {
+				if ($params['widthClass'] == 'inside-modal') {
+					$html->attrs['style'] = 'width:98%;';
+				} else {
+					$html->attrs['style'] = 'width:98%;';
+				}
+			} else {
+				//$html->attrs['class'][] = (8 <= $maxGrid)? 'span8' : "span{$maxGrid}";
+			}
+			$html->attrs['rows'] = '3';
+			unset($html->attrs['type']);
+			unset($html->attrs['value']);
+		}
+		else if ('polygon' == $colType['type']) { return '...'; }// Wielokąt
+		else if ('multipolygon' == $colType['type']) { return '...'; }// Zbiór wielokątów
+		else if ('linestring' == $colType['type']) { return '...'; }// Krzywa z interpolacji liniowej pomiędzy punktami
+		else if ('point' == $colType['type']) { return '...'; }// Punkt w przestrzeni 2-wymiarowej
+		else if ('geometry' == $colType['type']) { return '...'; }// Typy, które mogą przechowywać geometrię dowolnego typu
+		else if ('multipoint' == $colType['type']) { return '...'; }// Zbiór punktów
+		else if ('multilinestring' == $colType['type']) { return '...'; }// Zbiór krzywych z interpolacji liniowej pomiędzy punktami
+		else if ('geometrycollection' == $colType['type']) { return '...'; }// Zbiór obiektów geometrycznych dowolnego typu
+		else throw new Exception("unknown Type '{$colType['type']}'");
+
+		$html->attrs['class'][] = 'form-control';
+
+		$attrsOut = array();
+		foreach ($html->attrs as $k => $v) {
+			if (is_array($v)) $v = implode(' ', $v);
+			$attrsOut[] = "{$k}=\"{$v}\"";
+		}
+
+		if (in_array($html->tag, array('select', 'textarea'))) {
+			$out .= '<' . $html->tag . '' . (($attrsOut)? ' ' . implode(' ', $attrsOut) : '') . '>';
+			$out .= $html->cnt;
+			$out .= '</' . $html->tag . '>';
+		} else {
+			$out .= '<' . $html->tag . '' . (($attrsOut)? ' ' . implode(' ', $attrsOut) : '') . ' />';
+		}
+
+		if (in_array('date', $html->_params)) {
+			$out = '<div class="input-group">' . $out . '<span class="input-group-addon">
+					<span class="glyphicon glyphicon-calendar"></span>
+				</span>
+			</div>';
+		}
+		else if (in_array('time', $html->_params)) {
+			$out = '<div class="input-group">' . $out . '<span class="input-group-addon">
+					<span class="glyphicon glyphicon-time"></span>
+				</span>
+			</div>';
+		}
+
+		if (true == V::get('appendBack', '', $params)
+				&& !in_array('date', $html->_params)
+				&& !in_array('time', $html->_params)
+			 ) {
+			if ($html->tag == 'input' && $taskPerm == 'W') {
+				$out = '<div class="input-group show-last-value">' . $out . '<span class="input-group-addon button-appendBack" title="' . htmlspecialchars($fValue) . '"><span class="glyphicon glyphicon-arrow-left"></span></span></div>';
+			}
+		}
+
+		Lib::loadClass('Typespecial');
+		$typeSpecial = Typespecial::getInstance($fieldID, $colName);
+		if ($typeSpecial) {
+			throw new Exception("TODO: TypeSpecial");
+			$tsParams = array();
+			$tsValue = V::get('typespecialValue', '', $params);
+			if (!empty($tsValue)) {
+				$tsParams['typespecialValue'] = $tsValue;
+			}
+			$out .= ' ' . $typeSpecial->showFormItem($this->_zasobID, $fName, $fValue, $tsParams, $record);
+		}
+
+		return $out;
+	}
+
 	/**
 	 * @param $taskPerm - 'C', 'W'
 	 */
@@ -685,40 +923,20 @@ class TableAcl {
 		return $_cache[$idTable];
 	}
 
-	public function loadSources() {
-		if ($this->_sourceLoaded) return;
+	public function loadSchema() {
+		if ($this->_schemaLoaded) return;
 		$srvName = $_SERVER['SERVER_NAME'];
-		$srvCleanName = str_replace(array(".", "-"), '_', $srvName);
-		$tblLowerName = strtolower($this->_name);
-		$sourceName = ($this->_db == DB::getPDO()->getZasobId())? 'default_db' : "p5_{$this->_db}";
-		DBG::_('DBG_SCH', '>1', "srvCleanName", $srvCleanName, __CLASS__, __FUNCTION__, __LINE__);
-		DBG::_('DBG_SCH', '>1', "tblLowerName", $tblLowerName, __CLASS__, __FUNCTION__, __LINE__);
-		DBG::_('DBG_SCH', '>1', "sourceName", $sourceName, __CLASS__, __FUNCTION__, __LINE__);
-		// TODO: fetch form widgets from file config
-		//       "schema/gui/core/{$sourceName}.{$tblLowerName}.php";
-		//       class Schema_Core_{$sourceName}_{$tblLowerName};
-		//   TODO: override by company file config
-		//         "schema/gui/{$srvCleanName}/{$sourceName}.{$tblLowerName}.php";
-		//         class Schema_{$srvCleanName}_{$sourceName}_{$tblLowerName};
-		$pathCoreClass = APP_PATH_SCHEMA . "/gui/core/{$sourceName}.{$tblLowerName}.php";
-		$coreClassName = "Schema_Core_{$sourceName}_{$tblLowerName}";
-		if (file_exists($pathCoreClass)) {
-			require_once $pathCoreClass;
-			if (!class_exists($coreClassName)) throw new Exception("Config error for schema core class {$sourceName}:{$tblLowerName}");
-			$this->_coreSource = new $coreClassName();
-		}
-		$pathCompanyClass = APP_PATH_SCHEMA . "/gui/company/{$srvCleanName}/{$sourceName}.{$tblLowerName}.php";
-		$companyClassName = "Schema_{$srvCleanName}_{$sourceName}_{$tblLowerName}";
-		if (file_exists($pathCompanyClass)) {
-			require_once $pathCompanyClass;
-			if (!class_exists($companyClassName)) throw new Exception("Config error for schema company class {$sourceName}:{$tblLowerName}");
-			$this->_companySource = new $companyClassName();
-		}
-		$this->_sourceLoaded = true;
+		try {
+			$this->_schemaClass = Schema_TableFactory::build($this->_name, $this->_db, $srvName);
+		} catch (Exception $e) {
+			DBG::_('DBG_SCH', '>1', "Exception in Schema_TableFactory::build", $e->getMessage(), __CLASS__, __FUNCTION__, __LINE__);
+			// TODO: hide only not found, else re-throw
+		}
+		$this->_schemaLoaded = true;
 	}
 
 	public function init($force = false) {
-		$this->loadSources();
+		$this->loadSchema();
 		if (empty($this->_fields)) {
 			$this->_types = array();// clear _types @see $this->isInitialized
 			$userAcl = User::getAcl();
@@ -747,8 +965,7 @@ class TableAcl {
 		$this->_sortEnumFields();
 		$this->_fixProjectType();
 
-		if ($this->_coreSource) $this->_types = $this->_coreSource->fixTypes($this->_types);
-		if ($this->_companySource) $this->_types = $this->_companySource->fixTypes($this->_types);
+		if ($this->_schemaClass) $this->_types = $this->_schemaClass->fixTypes($this->_types);
 		//DBG::_(true, true, "this->_types", $this->_types, __CLASS__, __FUNCTION__, __LINE__);
 
 		$fieldIds = array_keys($this->_fields);

+ 55 - 18
SE/se-lib/TableAjax.php

@@ -84,7 +84,7 @@ class TableAjax extends ViewAjax {
 						$this->_rowFunctions = $v;
 						break;
 					default:
-						
+
 				}
 			}
 		}
@@ -2863,11 +2863,27 @@ class TableAjax extends ViewAjax {
 				$.ajax({
 					url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=EDIT_INLINE&ID=' + e.data.id + '&col=' + e.data.col,
 					type: 'GET',
-					dataType: 'text',
-					data: '',
-					async: true,
+					dataType: 'json',
 					success: function(data) {
-						inlineEditBox$Node.find('.inlineEditBox-cnt').html(data);
+						var content = '';
+						if (data && data.simpleType && 'p5:www_link' == data.simpleType) {
+							inlineEditBox$Node.find('.inlineEditBox-cnt').empty();
+							var label = jQuery('<label>');// for="' + data.htmlFieldName + '">');// "<label for="f22579" class="AjaxTableEdit-label"> ... </label>
+							label.attr('for', data.htmlFieldName);
+							label.attr('class', 'AjaxTableEdit-label');
+							inlineEditBox$Node.find('.inlineEditBox-cnt').append(label);
+							var inLabel = jQuery('<strong title="[' + data.idZasob + '] ' + data.fieldLabel + '">' + data.fieldLabel + '</strong>');
+							label.append(inLabel);
+							var frmItem = jQuery('<input id="' + data.htmlFieldName + '" name="' + data.htmlFieldName + '" type="text" value="biall.com.pl" maxlength="255" style="width:98%;" class="form-control" />');
+							frmItem.insertAfter(label);
+						} else {
+							if (data && data.legacy_html) {
+								content = data.legacy_html;
+							} else {
+								content = 'Nieznany błąd';
+							}
+							inlineEditBox$Node.find('.inlineEditBox-cnt').html(content);
+						}
 						inlineEditBox$Node.find('.btn-save').show();
 
 						initDateTimePicker(inlineEditBox$Node);
@@ -3803,13 +3819,17 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 	 */
 	private function sendAjaxEditInline($rowID, $fieldName, $args) {
 		$DBG = ('1' == V::get('DBG', '', $_REQUEST));
-		header("Content-type: text/plain");
+		$response = array();
+		header("Content-type: application/json");
 
+		ob_start();
 		$fieldID = $this->_acl->getFieldIdByName($fieldName);
 		if (!$fieldID) {
 			echo "404: No field by name ({$fieldName})";
 			exit;
 		}
+		$response['idZasob'] = $fieldID;
+		$response['htmlFieldName'] = "f{$fieldID}";
 
 		if ($DBG) echo "fieldID: {$fieldID}\n";
 
@@ -3842,6 +3862,7 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 
 		$vCol = $this->_acl->getField($fieldID);
 		$vCol['label'] = (!empty($vCol['label']))? $vCol['label'] : $vCol['name'];
+		$response['fieldLabel'] = $vCol['label'];
 
 		$tsValues = array();
 		$typeSpecial = Typespecial::getInstance($fieldID, $vCol['name']);
@@ -3854,6 +3875,26 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 			}
 		}
 
+		$fieldParams = array('widthClass'=>'inside-modal', 'maxGrid'=>6);
+		if (!empty($tsValues[$row->ID])) $fieldParams['typespecialValue'] = $tsValues[$row->ID];
+		if (!empty($tsValues[$row->ID])) $response['typespecialValue'] = $tsValues[$row->ID];
+		$vDefault = $this->_acl->getColDefault($fieldName);
+		if (!empty($vDefault)) $fieldParams['default'] = $vDefault;
+		if (!empty($vDefault)) $response['defaultValue'] = $vDefault;
+		{
+			try {
+				$item = $this->_acl->getFormItem('W', $fieldID, "f{$fieldID}", $fieldVal, $fieldParams, $row);
+				$response['formItem'] = $item;
+				if (!empty($item['rawColType']['simpleType'])) $response['simpleType'] = $item['rawColType']['simpleType'];
+				echo '<div style="display:none">';
+				DBG::_(true, true, "item", $item, __CLASS__, __FUNCTION__, __LINE__);
+				echo '</div>';
+			} catch (Exception $e) {
+				echo '<div style="display:none">';
+				SE_Layout::alert('warning', "Error #" . $e->getCode() .  "|" . $e->getLine() .  ": " . $e->getMessage());
+			}
+		}
+
 		?>
 		<label for="<?php echo "f{$fieldID}"; ?>" class="AjaxTableEdit-label">
 			<strong title="<?php echo "[{$fieldID}] {$fieldName}"; ?>"><?php echo "{$vCol['label']}"; ?></strong>
@@ -3863,14 +3904,6 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 			<?php endif; ?>
 		</label>
 		<?php
-			$fieldParams = array('widthClass'=>'inside-modal', 'maxGrid'=>6);
-			if (!empty($tsValues[$row->ID])) {
-				$fieldParams['typespecialValue'] = $tsValues[$row->ID];
-			}
-			$vDefault = $this->_acl->getColDefault($fieldName);
-			if (!empty($vDefault)) {
-				$fieldParams['default'] = $vDefault;
-			}
 			echo $this->_acl->showFormItem('W', $fieldID, "f{$fieldID}", $fieldVal, $fieldParams, $row);
 			if ($typeSpecial
 					|| $this->_acl->isDateField($fieldName)
@@ -3878,6 +3911,10 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 				 ) {
 				echo '<p style="padding:120px 0;"></p>';
 			}
+
+		$response['legacy_html'] = ob_get_clean();
+		//$response['legacy_html'] = utf8_encode($response['legacy_html']);// pl chars bug
+		echo json_encode($response);
 		exit;
 	}
 
@@ -4352,7 +4389,7 @@ jQuery(document).ready(function(){
 			taskCnt.removeClass('AjaxTable-loading');
 			taskCnt.empty();
 			if (data.type == 'error' || data.type == 'warning') {
-				var out = '<div class="container">' + 
+				var out = '<div class="container">' +
 						'<div class="alert alert-danger">' +
 							'<h4>Wystąpiły błędy!</h4>' + data.msg +
 							(('errors' in data)? '<p>' + data.errors + '</p>' : '') +
@@ -4521,7 +4558,7 @@ jQuery(document).ready(function(){
 					<?php foreach ($visibleColsWithIds as $fldId => $colName) : ?>
 						<?php if (in_array($colName, array('ID', 'A_RECORD_UPDATE_DATE', 'A_RECORD_UPDATE_AUTHOR', 'A_RECORD_CREATE_DATE', 'A_RECORD_CREATE_AUTHOR'))) continue; ?>
 						<?php if ($row->$colName == 'N/S;') continue; ?>
-						<p><em><?php echo $visibleColsLabels[$fldId]; ?></em>: 
+						<p><em><?php echo $visibleColsLabels[$fldId]; ?></em>:
 							<?php if ($this->_acl->isAllowed($fldId, 'R', $record)) : ?>
 								<?php echo $row->$colName; ?>
 							<?php else : ?>
@@ -4980,7 +5017,7 @@ jQuery(document).ready(function(){
 		<script src="stuff/jquery.form.js"></script>
 		<div class="container">
 
-		<h4 style="margin:20px 0 3px 0;">Pliki w katalogu 
+		<h4 style="margin:20px 0 3px 0;">Pliki w katalogu
 			<?php if ($sharePoint) : ?>
 				<a href="<?php echo $sharePoint; ?>"><span class="glyphicon glyphicon-folder-open"></span><code><?php echo $mainFolder; ?></code></a>
 			<?php else : ?>
@@ -5557,7 +5594,7 @@ jQuery(document).ready(function(){
 			$page -= 1;
 		}
 		else {
-			
+
 		}
 
 		$params = array();

+ 2 - 0
SE/se-lib/bootstrap.php

@@ -22,3 +22,5 @@ Lib::loadClass('HttpException');
 Lib::loadClass('StorageException');
 Lib::loadClass('Router');
 Lib::loadClass('Request');
+
+require_once APP_PATH_SCHEMA . '/gui/Schema_TableFactory.php';