Преглед изворни кода

added try catch to fetch remote p5:alias in TableAjax

Piotr Labudda пре 8 година
родитељ
комит
64f36720c1
1 измењених фајлова са 29 додато и 17 уклоњено
  1. 29 17
      SE/se-lib/TableAjax.php

+ 29 - 17
SE/se-lib/TableAjax.php

@@ -453,14 +453,16 @@ class TableAjax extends ViewAjax {
 					]);
 					]);
 				}
 				}
 				?>
 				?>
-				<?php if ($this->_tbl == 'IN7_MK_BAZA_DYSTRYBUCJI') : ?>
-					<a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?MENU_INIT=TREEJS&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
-				<?php elseif ($this->allowTreeView()) : ?>
-					<a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?MENU_INIT=VIEWTREE_AJAX&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
-				<?php endif; ?>
-				<?php if ($this->_tbl == 'WMS_MAP_GEOREFERENCES') : ?>
-					<a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?_route=GeoreferencesManager"; ?>"><i class="glyphicon glyphicon glyphicon-wrench"></i> Zarządzaj punktami</a>
-				<?php endif; ?>
+				<?php
+				if ($this->_tbl == 'IN7_MK_BAZA_DYSTRYBUCJI') {
+					echo UI::h('a', [ 'class' => "pull-right", 'style' => "padding:0 20px 0 0", 'href' => "index.php?MENU_INIT=TREEJS&ZASOB_ID={$this->_zasobID}" ], "<i class=\"glyphicon glyphicon-eye-open\"></i> Drzewo");
+				} else if ($this->allowTreeView()) {
+					echo UI::h('a', [ 'class' => "pull-right", 'style' => "padding:0 20px 0 0", 'href' => "index.php?MENU_INIT=VIEWTREE_AJAX&ZASOB_ID={$this->_zasobID}" ], "<i class=\"glyphicon glyphicon-eye-open\"></i> Drzewo");
+				}
+				if ($this->_tbl == 'WMS_MAP_GEOREFERENCES') {
+					echo UI::h('a', [ 'class' => "pull-right", 'style' => "padding:0 20px 0 0", 'href' => "index.php?_route=GeoreferencesManager" ], "<i class=\"glyphicon glyphicon glyphicon-wrench\"></i> Zarządzaj punktami");
+				}
+				?>
 			</ul>
 			</ul>
 			<?php
 			<?php
 				if ($this->_backRefFilter) {
 				if ($this->_backRefFilter) {
@@ -478,8 +480,7 @@ class TableAjax extends ViewAjax {
 						]),
 						]),
 					]);
 					]);
 				}
 				}
-			?>
-			<?php
+
 				if ($this->_childRefFilter) {
 				if ($this->_childRefFilter) {
 					echo UI::h('div', [ 'class' => "container" ], [
 					echo UI::h('div', [ 'class' => "container" ], [
 						UI::h('div', [ 'class' => "alert alert-info" ], [
 						UI::h('div', [ 'class' => "alert alert-info" ], [
@@ -495,8 +496,9 @@ class TableAjax extends ViewAjax {
 						]),
 						]),
 					]);
 					]);
 				}
 				}
+
+				echo UI::h('div', [ 'id' => $this->_htmlID ]);
 			?>
 			?>
-			<div id="<?= $this->_htmlID; ?>"></div>
 		</div>
 		</div>
 		<?php
 		<?php
 		UI::inlineJS(__FILE__ . '.generateFunctionNode.js');
 		UI::inlineJS(__FILE__ . '.generateFunctionNode.js');
@@ -5823,11 +5825,16 @@ jQuery(document).ready(function(){
 								$sqlRemoteValueFieldName = V::get('remote_column_value', '', $conf);
 								$sqlRemoteValueFieldName = V::get('remote_column_value', '', $conf);
 								$sqlRemoteKeyName = V::get('remote_join_key', '', $conf);
 								$sqlRemoteKeyName = V::get('remote_join_key', '', $conf);
 								$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
 								$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
-								$aliasValuesRaw = DB::getPDO()->fetchAllByKey("
-									select r.{$sqlRemoteKeyName} as {$sqlLocalKeyName}, r.{$sqlRemoteValueFieldName} as remote_value
-									from {$sqlRemoteTable} r
-									where r.{$sqlRemoteKeyName} in(" . implode(",", $localKeys[$localKeyName]) . ")
-								", $sqlLocalKeyName);
+								try {
+									$aliasValuesRaw = DB::getPDO()->fetchAllByKey("
+										select r.{$sqlRemoteKeyName} as {$sqlLocalKeyName}, r.{$sqlRemoteValueFieldName} as remote_value
+										from {$sqlRemoteTable} r
+										where r.{$sqlRemoteKeyName} in(" . implode(",", $localKeys[$localKeyName]) . ")
+									", $sqlLocalKeyName);
+								} catch (Exception $e) {
+									// TODO: error msg for GUI
+									DBG::log($e);
+								}
 								if(V::get('DBG', '', $_GET)){$jsonData->__DBG__['$aliasValuesRaw'][$fieldName] = $aliasValuesRaw;}
 								if(V::get('DBG', '', $_GET)){$jsonData->__DBG__['$aliasValuesRaw'][$fieldName] = $aliasValuesRaw;}
 							}
 							}
 						}
 						}
@@ -5847,7 +5854,12 @@ jQuery(document).ready(function(){
 						if (!empty($localKeys[$localKeyName])) {
 						if (!empty($localKeys[$localKeyName])) {
 							$sql = str_replace('{sql_in_local_join_key}', implode(",", $localKeys[$localKeyName]), $sqlFormat);
 							$sql = str_replace('{sql_in_local_join_key}', implode(",", $localKeys[$localKeyName]), $sqlFormat);
 							$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
 							$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
-							$aliasValuesRaw = DB::getPDO()->fetchAllByKey($sql, $sqlLocalKeyName);
+							try {
+								$aliasValuesRaw = DB::getPDO()->fetchAllByKey($sql, $sqlLocalKeyName);
+							} catch (Exception $e) {
+								// TODO: error msg for GUI
+								DBG::log($e);
+							}
 						}
 						}
 					}
 					}
 					DBG::log($aliasValuesRaw, 'array', '$aliasValuesRaw');
 					DBG::log($aliasValuesRaw, 'array', '$aliasValuesRaw');