- $delete_id = format_int($_REQUEST['admin_pages_delete_id']);
- unset($_REQUEST['admin_pages_delete_id']);
- if($delete_id) {
- db_delete('cms_pages', 'where id=%i', $delete_id);
- message('Page deleted.');
+# get all images from admin_images (for cms)
+function admin_pages_get_images() {
+ $out = [];
+ $rows = db_get_assocs('cms_images', 'image,name,caption', "order by coalesce(nullif(name, ''), caption), created_at");
+ if ($rows) {
+ $id = -1;
+ foreach($rows as &$row) { $id += 1;
+ $parts = explode(' ', $row['image'] . ' ', 7);
+ $out[] = [
+ 'id' => '' . $id,
+ 'src' => $parts[0],
+ 'aspect' => ''.(round(100000 * ((int)$parts[2]) / ((int)$parts[1]) / 1000)).'%',
+ 'name' => $row['name'],
+ 'caption' => $row['caption']
+ ];
+ } unset($row);
+ }
+ return $out;
+}