getCode() . "|" . $e->getLine() . ": " . $e->getMessage()); } UI::dol(); } public function coreObjectListAction() { UI::gora(); UI::menu(); Router::getRoute('Storage')->navView(); try { $coreObjlist = OBJ::getCoreObjectList(); $objectList = array(); foreach ($coreObjlist as $objName) { $objItem = array(); $objItem['name'] = $objName; $objItem['struktura'] = UI::h('a', [ 'href' => $this->getLink('coreObjectStruct', [ 'object' => $objName ]) ], "struct"); // $objItem['label'] = "";// TODO: read from json $objectList[] = $objItem; } usort($objectList, function($rowA, $rowB) { $a = $rowA['nazwa']; $b = $rowB['nazwa']; if ($a == $b) return 0; return ($a < $b) ? -1 : 1; }); DBG::table("objectList", $objectList, __CLASS__, __FUNCTION__, __LINE__); } catch (Exception $e) { UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage()); } UI::dol(); } public function checkObjectInstallAjaxAction() { $response = array(); try { $objectName = V::get('object', '', $_REQUEST, 'word'); if (empty($objectName)) throw new Exception("Missing Object name"); $response['object'] = $objectName; $json = OBJ::getCoreObjectFromFile($objectName); OBJ::checkInstall($json); $response['type'] = 'success'; $response['msg'] = "OK - object installed"; } catch (Exception $e) { $response['type'] = 'error'; $response['msg'] = $e->getMessage(); $response['code'] = $e->getCode(); $response['line'] = $e->getLine(); } Response::sendJsonExit($response); } public function coreObjectConnectAction() { UI::gora(); UI::menu(); Router::getRoute('Storage')->navView(); try { $objectName = V::get('object', '', $_REQUEST, 'word'); if (empty($objectName)) throw new Exception("Missing Object name"); $json = OBJ::getCoreObjectFromFile($objectName); $label = OBJ::getLabel($json); $parentList = OBJ::getParentList($json); $linksParentList = array(); foreach ($parentList as $parentName) { $parentLink = UI::h('a', [ 'href' => $this->getLink('coreObjectStruct', [ 'object' => str_replace('/', '-', $parentName) ]) ], $parentName); array_unshift($linksParentList, $parentLink); } $ajaxCheckInstall = Router::getRoute('Storage_TestObj')->getLink('checkObjectInstallAjax', [ 'object' => $objectName ]); $onClick = "return p5UI__ButtonAjax(this, 'p5UIBtnAjax:Storage:checkObjectInstallAjax', { href: '{$ajaxCheckInstall}' })"; $btnCheckInstall = ''; UI::startContainer(); echo UI::h('h1', [], "Obiekt {$label} {$btnCheckInstall}"); if (!empty($parentList)) { echo UI::h('ol', [ 'class' => "breadcrumb" ], array_merge([ '
  • Dziedziczy z:
  • ', ], array_map(function ($parentLink) { return "
  • {$parentLink}
  • "; }, $linksParentList))); //
  • Data
  • // echo '

    ' . implode(", ", $parentList) . '

    '; } $tableOne = array(); $tableOne['caption'] = 'Klasy'; $tableOne['rows'] = array(); $parentList = OBJ::getParentList($json); $tableOne['rows'][] = array('__primary_key' => $objectName, 'name' => $objectName); $linksParentList = array(); foreach ($parentList as $parentName) { // $parentLink = UI::h('a', [ 'href' => $this->getLink('coreObjectStruct', [ 'object' => str_replace('/', '-', $parentName) ]) ], $parentName); // array_unshift($linksParentList, $parentLink); $tableOne['rows'][] = array('__primary_key' => $parentName, 'name' => $parentName); } $tableTwo = array(); $tableTwo['caption'] = 'Rekordy w tabeli głównej'; $mainTable = OBJ::getMainTableName($json); $sqlFields = OBJ::getTableFields($json); $tableTwo['rows'] = $this->getTableRows($mainTable, $sqlFields); foreach ($tableTwo['rows'] as $idx => $row) { // $tableTwo['rows'][] = array('__primary_key' => $objectName, 'name' => $objectName); $tableTwo['rows'][$idx]['__primary_key'] = $row['ID']; } echo '
    '; // TODO: filter connected rows // TODO: filter not connected rows // TODO: action connect rows - args(schema, rows_primary_key_list) // TODO: action un connect rows - args(schema, rows_primary_key_list) $this->showConnectSchemaToTableWidget(compact('tableOne', 'tableTwo')); UI::endContainer(); echo UI::h('script', [], " jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:click', function(e, n, payload) { console.log('event p5UIBtnAjax:Storage:checkObjectInstallAjax:click', n, payload); }); jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', function(e, n, payload) { console.log('event p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', n, payload); if ('success' == payload.type) { // jQuery(n).parents('td').text(payload.body.id); } jQuery.notify(payload.msg, payload.type); }); "); DBG::_(true, true, "json", $json, __CLASS__, __FUNCTION__, __LINE__); } catch (Exception $e) { UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage()); } UI::dol(); } public function coreObjectStructAction() { UI::gora(); UI::menu(); Router::getRoute('Storage')->navView(); try { $objectName = V::get('object', '', $_REQUEST, 'word'); if (empty($objectName)) throw new Exception("Missing Object name"); $json = OBJ::getCoreObjectFromFile($objectName); $label = OBJ::getLabel($json); $parentList = OBJ::getParentList($json); $linksParentList = array(); foreach ($parentList as $parentName) { $parentLink = UI::h('a', [ 'href' => $this->getLink('coreObjectStruct', [ 'object' => str_replace('/', '-', $parentName) ]) ], $parentName); array_unshift($linksParentList, $parentLink); } $ajaxCheckInstall = $this->getLink('checkObjectInstallAjax', [ 'object' => $objectName ]); $onClick = "return p5UI__ButtonAjax(this, 'p5UIBtnAjax:Storage:checkObjectInstallAjax', { href: '{$ajaxCheckInstall}' })"; $btnCheckInstall = ''; UI::startContainer(); UI::tag('h1', [], "Obiekt {$label} {$btnCheckInstall}"); if (!empty($parentList)) { UI::startTag('ol', ['class'=>"breadcrumb"]); UI::tag('li', [], "Dziedziczy z:"); foreach ($linksParentList as $parentLink) { UI::tag('li', [], $parentLink); } // UI::endTag('ol'); // } // TODO: UI::table(['rows'=>array_map()]); $jsonFields = OBJ::getFields($json); UI::table([ 'caption' => "Struktura:", 'rows' => array_map(function ($field, $fieldName) { return [ 'nazwa' => $fieldName, 'typ' => $field['type'], 'label' => $field['label'], 'json' => json_encode($field), ]; }, $jsonFields, array_keys($jsonFields)) ]); echo UI::h('a', [ 'class' => "btn btn-primary", 'href' => $this->getLink('coreObjectConnect', [ 'object' => $objectName ]) ], "Przypisz rekordy do klasy"); $mainTable = OBJ::getMainTableName($json); $sqlFields = OBJ::getTableFields($json); $this->showTableWidget($mainTable, $sqlFields); UI::endContainer(); echo UI::h('script', [], " jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:click', function(e, n, payload) { console.log('event p5UIBtnAjax:Storage:checkObjectInstallAjax:click', n, payload); }); jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', function(e, n, payload) { console.log('event p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', n, payload); if ('success' == payload.type) { // jQuery(n).parents('td').text(payload.body.id); } jQuery.notify(payload.msg, payload.type); }); "); DBG::_(true, true, "json", $json, __CLASS__, __FUNCTION__, __LINE__); } catch (Exception $e) { UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage()); } UI::dol(); } public function coreObjectParseAllAction() { UI::gora(); UI::menu(); Router::getRoute('Storage')->navView(); try { OBJ::parseAll(); } catch (Exception $e) { UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage()); } UI::dol(); } public function showConnectSchemaToTableWidget($params) { if (empty($params['tableOne'])) throw new Exception("Missing tableOne in Connect widget"); if (empty($params['tableTwo'])) throw new Exception("Missing tableTwo in Connect widget"); $tableOne = $params['tableOne']; $tableTwo = $params['tableTwo']; // TODO: add p5BtnAjax to table filters button // TODO: add p5BtnAjax to conn button $jsEventNamespace = 'ConnectTableWidget' . time(); $htmlIdWrap = "{$jsEventNamespace}-wrap"; $stateLogId = "{$jsEventNamespace}-state-log"; $stateSelectedTotalId = "{$jsEventNamespace}-state-selected"; $stateClearSelectedBtnId = "{$jsEventNamespace}-state-clear-selected-btn"; foreach ($tableOne['rows'] as $idx => $r) { $tableOne['rows'][$idx]['@onClick'] = "return p5UI__Clickable(this, '{$jsEventNamespace}:tableOne', { primary_key: '{$r['__primary_key']}' });"; } foreach ($tableTwo['rows'] as $idx => $r) { $tableTwo['rows'][$idx]['@onClick'] = "return p5UI__Clickable(this, '{$jsEventNamespace}:tableTwo', { primary_key: '{$r['__primary_key']}' });"; } $tableOne['hidden_cols'] = $tableTwo['hidden_cols'] = array('__primary_key', '@onClick', '__html_id'); $tableTwo['__html_id'] = "{$jsEventNamespace}-table-two"; ?>
    Zaznaczono 0