$html .= "</ul></div>";
return $html;
}
+ function jerr($str, $errors=array()) // standard error reporting..
+ {
+ require_once 'Services/JSON.php';
+ $json = new Services_JSON();
+
+ // log all errors!!!
+ //$this->addEvent("ERROR", false, $str);
+ /*
+ if (!empty($_REQUEST['returnHTML']) ||
+ (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
+ ) {
+ header('Content-type: text/html');
+ echo "<HTML><HEAD></HEAD><BODY>";
+ echo $json->encodeUnsafe(array(
+ 'success'=> false,
+ 'errorMsg' => $str,
+ 'message' => $str, // compate with exeption / loadexception.
+
+ 'errors' => $errors ? $errors : true, // used by forms to flag errors.
+ 'authFailure' => !empty($errors['authFailure']),
+ ));
+ echo "</BODY></HTML>";
+ exit;
+ }
+ */
+ echo $json->encode(array(
+ 'success'=> false,
+ 'data'=> array(),
+ 'errorMsg' => $str,
+ 'message' => $str, // compate with exeption / loadexception.
+ 'errors' => $errors ? $errors : true, // used by forms to flag errors.
+ 'authFailure' => !empty($errors['authFailure']),
+ ));
+ exit;
+
+ }
+ function jok($str)
+ {
+
+ require_once 'Services/JSON.php';
+ $json = new Services_JSON();
+
+ if (!empty($_REQUEST['returnHTML']) ||
+ (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
+
+ ) {
+ header('Content-type: text/html');
+ echo "<HTML><HEAD></HEAD><BODY>";
+ echo $json->encodeUnsafe(array('success'=> true, 'data' => $str));
+ echo "</BODY></HTML>";
+ exit;
+ }
+
+
+ echo $json->encode(array('success'=> true, 'data' => $str));
+ exit;
+
+ }
+ /**
+ * output data for grids or tree
+ * @ar {Array} ar Array of data
+ * @total {Number|false} total number of records (or false to return count(ar)
+ * @extra {Array} extra key value list of data to pass as extra data.
+ *
+ */
+ function jdata($ar,$total=false, $extra=array())
+ {
+ // should do mobile checking???
+ if ($total == false) {
+ $total = count($ar);
+ }
+ $extra= $extra ? $extra : array();
+ require_once 'Services/JSON.php';
+ $json = new Services_JSON();
+ echo $json->encode(array('success' => true, 'total'=> $total, 'data' => $ar) + $extra);
+ exit;
+
+
+ }