JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
db_upgrade rework, admin_header, cleanup
[wfpl-cms.git] / inc / cms.php
index 895c810..06324f0 100644 (file)
@@ -2,6 +2,12 @@
 
 # This function (which loads the navbar and page content from the database) is
 # called automatically by wfpl_main()
+
+function enc_css_str($str) {
+       $str = str_replace("\\", "\\00005c", $str);
+       return str_replace("\"", "\\000022", $str);
+}
+
 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');
@@ -24,8 +30,36 @@ function cms_display($basename, &$tem) {
                $tem->set('$navbar_items', $nav_items);
        }
 
+       $header_image = persistent_get('wfplcms_header_image');
+       if ($header_image) {
+               $hi_css  = "\n<style>\n";
+               if ($header_image['width'] != WFPL_SITE_WIDTH) {
+                       $hi_css .= "#site_header {\n";
+                       $hi_css .=   'width: ' . $header_image['width'] . "px;\n";
+                       $hi_css .= "}\n";
+               }
+               $hi_css .= "#site_header:before {\n";
+               $hi_css .=   "content: \"\";\n";
+               $hi_css .=   'background-image: url(' . $header_image['url'] . ");\n";
+               $hi_css .=   'padding-top: ' . ($header_image['height'] / $header_image['width'] * 100) . "%;\n";
+               $hi_css .= "}\n";
+               if ($header_image['caption']) {
+                       $hi_css .= "#site_header:after {\n";
+                       $hi_css .=   "content: \"" . enc_css_str($header_image['caption']) . "\";\n";
+                       $hi_css .= "}\n";
+               }
+               $hi_css .= "</style>\n";
+
+               $tem->set('$cms_css', $hi_css);
+       }
+
        $cms_page_id = cms_display_content($tem, 'where filename=%"', $basename);
 
+       $footer = db_get_value('cms_pages', 'content', 'where filename="_footer"');
+       if ($footer) {
+               $tem->set('$cms_footer', $footer);
+       }
+
        if(session_auth_can('admin_links')) {
                $admin_links = array();
                if($cms_page_id) {
@@ -62,6 +96,8 @@ function cms_display_content(&$tem /*, 'where clause %", %i', string, int */) {
                        $tem->set('$cms_sidebar', $row['sidebar_content']);
                }
                return $row['id'];
+       } else {
+               $tem->set('$layout_centerer_class', 'full');
        }
        return false;
 }