3 # This function (which loads the navbar and page content from the database) is
4 # called automatically by wfpl_main()
5 function cms_display($basename, &$tem) {
6 if(preg_match('/([.]l(ocal)?$)|^192[.]168[.]|^127.0.0.1$|^10[.]/', $_SERVER['HTTP_HOST'])) {
7 $GLOBALS['wfpl_main_template']->set('$running_locally');
9 $tem->set('$host', this_host());
10 $nav_items = db_get_assocs('cms_pages', "coalesce(nullif(nav_title,''), title) as title,filename", 'where navbar!=0 order by navbar');
12 foreach($nav_items as &$item) {
13 $item['basename'] = $item['filename']; # for nav-links as images
14 if($item['filename'] == $basename) {
15 $item['current'] = true;
17 if($item['filename'] == 'index') {
18 $item['filename'] = './';
20 if($item['title'] == '') {
21 $item['title'] = '(untitled)';
24 $tem->set('$navbar_items', $nav_items);
27 $cms_page_id = cms_display_content($tem, 'where filename=%"', $basename);
29 if(session_auth_can('admin_links')) {
30 $admin_links = array();
32 $admin_links['$edit_page_id'] = $cms_page_id;
34 $tem->set('$admin_links', $admin_links);
44 function cms_display_content(&$tem /*, 'where clause %", %i', string, int */) {
45 $args = array_slice(func_get_args(), 1);
46 $args = array_merge(array('cms_pages', 'id,title,keywords,description,layout,content,sidebar_content'), $args);
47 $row = call_user_func_array('db_get_assoc', $args);
49 $tem->set('$cms_title', $row['title']);
50 $tem->set('$meta_keywords', $row['keywords']);
51 $tem->set('$meta_description', $row['description']);
52 $tem->set('$cms_body', $row['content']);
53 if ($row['layout'] === '' || $row['layout'] === '0') {
54 $tem->set('$layout_centerer_class', 'full');
56 $tem->set('$layout_centerer_class', 'with_sidebar');
57 if ($row['layout'] === '1') {
58 $tem->set('$layout_sidebar_class', 'plain');
60 $tem->set('$layout_sidebar_class', 'bordered');
62 $tem->set('$cms_sidebar', $row['sidebar_content']);
66 $tem->set('$layout_centerer_class', 'full');