Forráskód Böngészése

VIEWTABLE_AJAX: add try catch block

Piotr Labudda 10 éve
szülő
commit
b9a22cd4c3
1 módosított fájl, 40 hozzáadás és 29 törlés
  1. 40 29
      SE/superedit-VIEWTABLE_AJAX.php

+ 40 - 29
SE/superedit-VIEWTABLE_AJAX.php

@@ -33,38 +33,49 @@ function VIEWTABLE_AJAX( $params = array() ) {
 	//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">tblAcl (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($tblAcl);echo'</pre>';
 
 	$forceTblAclInit = ('1' == V::get('_force', '', $_GET));
-	$tblAcl->init($forceTblAclInit);
+	try {
+		$tblAcl->init($forceTblAclInit);
 
-	Lib::loadClass('TableAjax');
+		Lib::loadClass('TableAjax');
 
-	$forceFilterInit = array();
-	$filterInit = new stdClass();
-	$filterInit->currSortCol = 'ID';
-	$filterInit->currSortFlip = 'desc';
-	foreach ($_GET as $k => $v) {
-		if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
-			$filterInit->$k = $v;
-		}
-		else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
-			$filterInit->$k = $v;
-		}
-		else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
-			$fldName = substr($k, 3);
-			$forceFilterInit[$fldName] = $v;
+		$forceFilterInit = array();
+		$filterInit = new stdClass();
+		$filterInit->currSortCol = 'ID';
+		$filterInit->currSortFlip = 'desc';
+		foreach ($_GET as $k => $v) {
+			if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
+				$filterInit->$k = $v;
+			}
+			else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
+				$filterInit->$k = $v;
+			}
+			else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
+				$fldName = substr($k, 3);
+				$forceFilterInit[$fldName] = $v;
+			}
 		}
+
+		$tbl = new TableAjax($tblAcl);
+		$tblLabel = array();
+		if (!empty($zasobObj->DESC_PL)) $tblLabel []= $zasobObj->DESC_PL;
+		if (!empty($zasobObj->OPIS))    $tblLabel []= $zasobObj->OPIS;
+		$tblLabel = implode(" - ", $tblLabel);
+		$tbl->setLabel($tblLabel);
+		$tbl->setFilterInit($filterInit);
+		if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
+		$tbl->addRowFunction('edit');
+		$tbl->addRowFunction('hist');
+		$tbl->addRowFunction('files');
+		$tbl->addRowFunction('cp');
+		echo $tbl->render();
+
+	} catch (Exception $e) {
+		?>
+		<div class="alert alert-error">
+			<strong>Wystąpiły błędy!</strong>
+			<?php echo $e->getMessage(); ?>
+		</div>
+		<?php
 	}
 
-	$tbl = new TableAjax($tblAcl);
-	$tblLabel = array();
-	if (!empty($zasobObj->DESC_PL)) $tblLabel []= $zasobObj->DESC_PL;
-	if (!empty($zasobObj->OPIS))    $tblLabel []= $zasobObj->OPIS;
-	$tblLabel = implode(" - ", $tblLabel);
-	$tbl->setLabel($tblLabel);
-	$tbl->setFilterInit($filterInit);
-	if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
-	$tbl->addRowFunction('edit');
-	$tbl->addRowFunction('hist');
-	$tbl->addRowFunction('files');
-	$tbl->addRowFunction('cp');
-	echo $tbl->render();
 }