+++ /dev/null
-<?php
-
-function cms_display($basename, &$tem) {
- if(preg_match('/([.]l(ocal)?$)|^192[.]168[.]|^127.0.0.1$|^10[.]/', $_SERVER['HTTP_HOST'])) {
- $GLOBALS['wfpl_main_template']->set('$running_locally');
- }
- $tem->set('$host', this_host());
- $nav_items = db_get_assocs('cms_pages', "coalesce(nullif(nav_title,''), title) as title,filename", 'where navbar!=0 order by navbar');
- if($nav_items) {
- foreach($nav_items as &$item) {
- $item['basename'] = $item['filename']; # for nav-links as images
- if($item['filename'] == $basename) {
- $item['current'] = true;
- }
- if($item['filename'] == 'index') {
- $item['filename'] = './';
- }
- if($item['title'] == '') {
- $item['title'] = '(untitled)';
- }
- }
- $tem->set('$navbar_items', $nav_items);
- }
-
- $cms_page_id = cms_display_content($tem, 'where filename=%"', $basename);
-
- if(logged_in_as_admin()) {
- $admin_links = array();
- if($cms_page_id) {
- $admin_links['id'] = $cms_page_id;
- }
- $tem->set('$admin_links', $admin_links);
- }
-
- if($cms_page_id) {
- return true;
- } else {
- return false;
- }
-}
-
-function cms_display_content(&$tem /*, 'where clause %", %i', string, int */) {
- $args = array_slice(func_get_args(), 1);
- $args = array_merge(array('cms_pages', 'id,title,keywords,description,content'), $args);
- $row = call_user_func_array('db_get_assoc', $args);
- if($row) {
- $tem->set('$cms_title', $row['title']);
- $tem->set('$meta_keywords', $row['keywords']);
- $tem->set('$meta_description', $row['description']);
- $tem->set('$cms_body', $row['content']);
- return $row['id'];
- }
- return false;
-}