3 function cms_display($basename, &$tem) {
4 if(preg_match('/([.]l(ocal)?$)|^[0-9.]*$/', $_SERVER['HTTP_HOST'])) {
5 $GLOBALS['wfpl_main_template']->set('$running_locally');
7 $tem->set('$host', this_host());
8 $nav_items = db_get_assocs('cms_pages', "coalesce(nullif(nav_title,''), title) as title,filename", 'where navbar!=0 order by navbar');
10 foreach($nav_items as &$item) {
11 $item['basename'] = $item['filename']; # for nav-links as images
12 if($item['filename'] == $basename) {
13 $item['current'] = true;
15 if($item['filename'] == 'index') {
16 $item['filename'] = './';
18 if($item['title'] == '') {
19 $item['title'] = '(untitled)';
22 $tem->set('$navbar_items', $nav_items);
25 $cms_page_id = cms_display_content($tem, 'where filename=%"', $basename);
27 if(logged_in_as_admin()) {
28 $admin_links = array();
30 $admin_links['id'] = $cms_page_id;
32 $tem->set('$admin_links', $admin_links);
42 function cms_display_content(&$tem /*, 'where clause %", %i', string, int */) {
43 $args = array_slice(func_get_args(), 1);
44 $args = array_merge(array('cms_pages', 'id,title,keywords,description,content'), $args);
45 $row = call_user_func_array('db_get_assoc', $args);
47 $tem->set('$cms_title', $row['title']);
48 $tem->set('$meta_keywords', $row['keywords']);
49 $tem->set('$meta_description', $row['description']);
50 $tem->set('$cms_body', $row['content']);