$ss = $s_model->All('ORDER BY ID DESC'); $files = new File($database); $i = 1; $result[0] = array(0 => 0, 1 => "None"); if (!false_or_null($ss)) { foreach ($ss as $s) { $f = $files->Get($s['r_File']); $result[$i++] = array(0 => intval($s['ID']), 1 => $f['Name'], 2 => $f['Name'] . ' #' . $s['ID']); } } echo json_encode($result); exit; } else { if (matches($getpost['R'], 'images')) { $result = array(); $images_model = new FileImage($database); $images = $images_model->All('ORDER BY ID DESC'); $files = new File($database); $i = 0; if (!isset($getpost['N'])) { $result[$i++] = array(0 => 0, 1 => "None", 2 => "i/none64.png", 3 => '<div><span class="enormous">X</span></div>'); } if (!false_or_null($images)) { foreach ($images as $s) { // Return available image file ids $f = $files->Get($s['r_File']); if (!false_or_null($f)) { $tname = $files->ThumbName($f); $result[$i++] = array(0 => intval($s['ID']), 1 => $f['Name'] . ' #' . $f['ID'] . ' ' . $s['Width'] . 'x' . $s['Height'], 2 => $files->ThumbName($f), 3 => $f['ID'], 4 => '<img src="' . $tname . '"><div>' . $f['Name'] . ' (#' . $item['ID'] . ')</div><div class="json-stat-image">' . $stats . '</div>'); } }
function AjaxImageSelector(&$p, $image_name, $table, $table_row_id, $field, $value, $length = 20, $none = TRUE) { global $ajax_image_selector_id; $ajax_image_selector_id++; $a_id = $ajax_image_selector_id; global $database; $fileimage_model = new FileImage($database); $p->HTML('<div class="formemphasis2 wide">'); $p->HTML('<table width="100%"><tr class="no-hover"><td width="300" class="no-hover" id="ajax-image-preview' . $a_id . '">'); $p->HTML('<h3>' . $image_name . '</h3>'); $icon = NULL; if (intval($value) > 0) { $icon = $fileimage_model->GetAll($value); } if (false_or_null($icon)) { $p->HTML('No image.'); } else { $p->HTML('<img src="' . $fileimage_model->ThumbName($icon, 256) . '"><BR>' . $icon['File']['Name']); } $p->HTML('</td><td class="no-hover" width="*">'); AJAXSelector($p, 1, $length, "ajax_image_preview_" . $a_id); $p->HTML('</td></tr></table>'); $p->HTML('</div>'); $p->JS(' function ajax_image_preview_' . $a_id . '( fileimage_id ) { $.ajax({ dataType: "html", url: "ajax.bound", data: {T:"' . $table . '",F:"' . $field . '",V:fileimage_id,I:' . $table_row_id . '}, success: function(d) { } }); $.ajax({ dataType: "html", url: "ajax.html.stat", data: {T:"FileImage",I:fileimage_id,X:256}, success: function(d) { $("#ajax-image-preview' . $a_id . '").html("<h3>' . $image_name . '</h3>"+d); } }); } '); if ($none === TRUE) { $p->HTML('<button id="image-remove-' . $a_id . '" class="buttonlink"><span class="fa fa-sign-out"></span> Remove Image</button>'); $p->JQ(' $("#image-remove-' . $a_id . '").on("click",function(e){ajax_image_preview_' . $a_id . '(0);}); '); } }