X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=admin_pages.php;h=4081f9452eb92a9b552bf23eb1ee209c144af85d;hb=d8a3c68fe7131555725440aabc9f82e53520b5dc;hp=f674b66219108493ed6a87e70f6de984ed1a2689;hpb=be246293072b9e3b10aa10219dbfcb575cc955a8;p=wfpl-cms.git diff --git a/admin_pages.php b/admin_pages.php index f674b66..4081f94 100644 --- a/admin_pages.php +++ b/admin_pages.php @@ -1,13 +1,10 @@ data['$admin_links']['$edit_page_id'] = $id; } function admin_pages_main_delete($id) { @@ -78,9 +81,43 @@ function admin_pages_main_delete($id) { return './admin_pages'; } +# 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; +} + function admin_pages_main_listing() { - $listing_rows = db_get_assocs('cms_pages', 'id,filename,coalesce(nullif(nav_title,\'\'), title) as title', 'order by concat(nav_title,title)'); - tem_set('listings', $listing_rows); + $data = array(); + $desc = ''; + $sort = _REQUEST_cut('sort'); + if ($sort && substr($sort, 0, 1) === '-') { + $sort = substr($sort, 1); + $desc = ' DESC '; + } else { + $data["sorting-by-$sort"] = '-'; + } + $legal_sorts = explode(',', ADMIN_PAGES_DB_FIELDS); + if (!$sort || !in_array($sort, $legal_sorts)) { + $sort = 'filename'; + } + + $data['rows'] = db_get_assocs('cms_pages', 'id,coalesce(nullif(nav_title,\'\'), title) as title,filename', "order by $sort $desc limit 1000"); + tem_set('listing', $data); } function admin_pages_main_form($id = false) { @@ -88,6 +125,13 @@ function admin_pages_main_form($id = false) { tem_set('id', $id); } + tem_set('$basename', 'admin_pages'); + + pulldown('layout', [ + ['0', "Full (no sidebar)"], + ['1', "With Plain Sidebar"], + ['2', "With Bordered Sidebar"] + ]); $navbar_options = array(array('ignored', 'Not at all'), array('0', 'First')); $rows = db_get_rows('cms_pages', 'id,coalesce(nullif(nav_title,\'\'), title) as title,navbar', 'where navbar != 0 order by navbar'); @@ -138,6 +182,16 @@ function admin_pages_main_form($id = false) { $data = array('filename' => format_cms_filename($_REQUEST['new_filename'])); } + if (!isset($data['layout']) || $data['layout'] === '' || $data['layout'] === '0') { + $data['sidebar_editor_display'] = 'none'; + } else { + $data['sidebar_editor_display'] = 'block'; + } + + tem_set('wfpl_images_json', json_encode(admin_pages_get_images())); + tem_set('wfpl_image_width_full', WFPL_IMAGE_WIDTH_FULL); + tem_set('wfpl_image_width_small', WFPL_IMAGE_WIDTH_SMALL); + tem_set('wfpl_image_width_thumb', WFPL_IMAGE_WIDTH_THUMB); tem_set('form', $data); tem_set('$head'); # wysiwyg init goes in }