|
|
@@ -38,6 +38,16 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
'@namespace' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja',
|
|
|
...
|
|
|
]
|
|
|
+
|
|
|
+ 'YT_LINK' => [ '@type' => 'p5:typeSpecialSimpleLink',
|
|
|
+ '@label' => "Youtube link",
|
|
|
+ '@@params' => [// $acl->getXsdFieldParam($col, 'format');
|
|
|
+ 'format' => '<a href="https://www.youtube.com/watch?v={LINK}" target="_blank"></a>',
|
|
|
+ 'aliasMap' => [
|
|
|
+ 'LINK' => 'LINK'
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ],
|
|
|
]
|
|
|
*/
|
|
|
public $_simpleSchema = array();
|
|
|
@@ -68,7 +78,7 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
$this->_sourceNamespace = implode('__x3A__', $this->_sourceNamespace);
|
|
|
}
|
|
|
|
|
|
- if (empty($this->_simpleSchema['root']['@primaryKey'])) $this->_simpleSchema['root']['@primaryKey'] = 'ID';// TODO: throw new Exception("Missing @primaryKey in simpleSchema");
|
|
|
+ if (empty($this->_simpleSchema['root']['@primaryKey'])) $this->_simpleSchema['root']['@primaryKey'] = 'ID';// TODO: throw new Exception("Missing @primaryKey in simpleSchema '{$this->_name}'");
|
|
|
$this->_primaryKey = $this->_simpleSchema['root']['@primaryKey'];// TODO: check if field exists
|
|
|
|
|
|
{// validate and fix _simpleSchema:
|
|
|
@@ -241,12 +251,24 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
public function getTotal($params = array()) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }// TODO: use ParseOgcQuery
|
|
|
public function getItem($primaryKey) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }
|
|
|
public function getItems($params = array()) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }// TODO: use ParseOgcQuery
|
|
|
- public function fetchItemRef(&$items) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }
|
|
|
- public function addItem($itemTodo) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }
|
|
|
+ public function fetchItemRef(&$items) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }// TODO: , $fieldName = ''
|
|
|
+ public function fetchItemFieldRefs($primaryKey, $fieldName) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }
|
|
|
+ public function addItem($itemTodo) { throw new Exception("Unimplemented - TODO: " . get_class($this) . "::" . __FUNCTION__); }
|
|
|
public function updateItem($itemPatch) { throw new Exception("Unimplemented - TODO: F." . __FUNCTION__); }
|
|
|
|
|
|
public function getGeomFieldType($fieldName) { return null; }
|
|
|
public function getPrimaryKeyField() { return $this->_primaryKey; }
|
|
|
+ public function getSqlPrimaryKeyField() {
|
|
|
+ return (!empty($this->_simpleSchema['root'][$this->_primaryKey]['@alias']))
|
|
|
+ ? $this->_simpleSchema['root'][$this->_primaryKey]['@alias']
|
|
|
+ : $this->_primaryKey;
|
|
|
+ }
|
|
|
+ public function getSqlFieldName($fieldName) {
|
|
|
+ if (empty($this->_simpleSchema['root'][$fieldName])) throw new Exception("Missing field in schema '{$fieldName}'");
|
|
|
+ return (!empty($this->_simpleSchema['root'][$fieldName]['@alias']))
|
|
|
+ ? $this->_simpleSchema['root'][$fieldName]['@alias']
|
|
|
+ : $fieldName;
|
|
|
+ }
|
|
|
public function getID() { return 0; }
|
|
|
public function getAttributesFromZasoby() { return array(); }
|
|
|
public function isEnumerationField($fieldName) { return false; }
|
|
|
@@ -265,4 +287,58 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
// return $this->parentAcl->isGeomField($fieldName);
|
|
|
}
|
|
|
|
|
|
+ public function generateSqlSelectFromRootTable($prefix = 't') {
|
|
|
+ $sqlSelect = [];
|
|
|
+ foreach ($this->_simpleSchema['root'] as $key => $field) {
|
|
|
+ if ('@' == substr($key, 0, 1)) continue;// skip attr
|
|
|
+ if (!empty($field['@ref'])) continue;// skip ref
|
|
|
+ if (empty($field['@type'])) continue;// skip wrong simpleType structure - BUG
|
|
|
+ if ('xsd:' != substr($field['@type'], 0, 4)) continue;// skip non xsd types - eg. p5:typeSpecialSimpleLink
|
|
|
+ $sqlField = (!empty($field['@alias'])) ? $field['@alias'] : $key;
|
|
|
+ $sqlSelect[] = "{$prefix}.`{$sqlField}` as `$key`";
|
|
|
+ }
|
|
|
+ return implode("\n, ", $sqlSelect);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getXsdFieldParam($fieldName, $paramKey) {
|
|
|
+ if (empty($this->_simpleSchema['root'][$fieldName])) return null;
|
|
|
+ if (empty($this->_simpleSchema['root'][$fieldName]['@@params'])) return null;
|
|
|
+ if (empty($this->_simpleSchema['root'][$fieldName]['@@params'][$paramKey])) return null;
|
|
|
+ return $this->_simpleSchema['root'][$fieldName]['@@params'][$paramKey];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addP5Types(&$item, $key) {
|
|
|
+ DBG::_('DBG_ACL', '>1', "\$item", $item, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ $sqlSelect = [];
|
|
|
+ foreach ($this->_simpleSchema['root'] as $key => $field) {
|
|
|
+ if ('@' == substr($key, 0, 1)) continue;// skip attr
|
|
|
+ if (empty($field['@type'])) continue;// skip ref
|
|
|
+ if ('p5:' != substr($field['@type'], 0, 3)) continue;// skip non p5 types
|
|
|
+ $fieldName = $key;
|
|
|
+ $item[$fieldName] = '';
|
|
|
+ switch ($field['@type']) {
|
|
|
+ case 'p5:typeSpecialSimpleLink': {
|
|
|
+ // '@@params' => [// $acl->getXsdFieldParam($col, 'format');
|
|
|
+ // 'format' => '<a href="https://www.youtube.com/watch?v={LINK}" target="_blank"></a>',
|
|
|
+ // 'aliasMap' => [
|
|
|
+ // 'LINK' => 'LINK'
|
|
|
+ // ]
|
|
|
+ // ]
|
|
|
+ $link = $this->getXsdFieldParam($fieldName, 'format');
|
|
|
+ // $.each(_fieldProps._tsSimpleLink.aliasMap, function(i, v) {
|
|
|
+ // //console.log('simpleLink aliasMap columnName:', columnName, 'i:', i, 'v:', v, 'props['+v+']', props[v], 'val', val, 'typeof val', typeof val);
|
|
|
+ // if (undefined !== row[v]) {
|
|
|
+ // valLink = valLink.replace(new RegExp('\{' + i + '\}', 'g'), row[v]);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ foreach ($this->getXsdFieldParam($fieldName, 'aliasMap') as $itemFieldName => $alias) {
|
|
|
+ DBG::_('DBG_ACL', '>1', "aliasMap({$itemFieldName} => {$alias})", $item[$itemFieldName], __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ $link = str_replace("{{$alias}}", $item[$itemFieldName], $link);
|
|
|
+ }
|
|
|
+ $item[$fieldName] = $link;
|
|
|
+ } break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|