}
}
$this->pageTitle = $this->_getPageTitle($this->_catid);
+ $this->_getBackgroundStyle();
$bodyFactory = new Toolkit_Template_Page_BodyFactory(
$this->_breadCrumbs,
$this->hasHeadlines = !empty($this->headlines);
}
+ private function _getBackgroundStyle()
+ {
+ $cache = new Cache_Lite($GLOBALS['cacheOptions']);
+ if ($bgVersion = $cache->get('bgVersion')) {
+ } else {
+ $dbh = Toolkit_Database::getInstance();
+ $sql = "SELECT version FROM background.image";
+ $bgVersion = $dbh->query($sql)->fetchColumn();
+ $cache->save($bgVersion, 'bgVersion');
+ }
+ $this->bgVersion = $bgVersion;
+ }
+
/**
* Check if this page has photo gallery in it
*
--- /dev/null
+<?php
+
+/**
+ * Smarty.php
+ *
+ * PHP version 5.3
+ *
+ * @category Toolkit
+ * @package Package
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license Gaslight Media
+ * @version SVN: (0.1)
+ * @link <>
+ */
+if (!defined('SMARTY_DIR')) {
+ define('SMARTY_DIR', '/var/www/server/CommonApps/Smarty/3.1/');
+}
+require_once SMARTY_DIR . 'Smarty.class.php';
+/**
+ * Toolkit_HeaderImages_Smarty
+ *
+ * Smarty Class Extension
+ *
+ * @category Toolkit
+ * @package Package
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license Gaslight Media
+ * @release Release: (0.1)
+ * @link <>
+ */
+class Toolkit_Smarty
+ extends Smarty
+{
+
+ function __construct(
+ $templateDir,
+ $compileDir,
+ $configDir,
+ $cacheDir
+ ) {
+ parent::__construct();
+
+ $this->setTemplateDir($templateDir);
+ $this->setCompileDir($compileDir);
+ $this->setConfigDir($configDir);
+ $this->setCacheDir($cacheDir);
+ }
+
+}
--- /dev/null
+--
+-- setup schema
+--
+
+CREATE SCHEMA background;
+GRANT ALL ON SCHEMA background TO nobody;
+
+--
+-- Tables
+--
+
+\i ./tables/background.sql
--- /dev/null
+--
+-- Background image database
+--
+DROP TABLE IF EXISTS background.image;
+CREATE TABLE background.image (
+ image TEXT,
+ updated DATE,
+ version INTEGER
+);
+
+INSERT INTO background.image (image, updated, version) values ('', current_date, 1);
+GRANT ALL ON background.image TO nobody;
--- /dev/null
+<?php
+/**
+ * File: backfroundImage.php
+ *
+ * PHP script to change the background image for the website.
+ */
+require '../../setup.phtml';
+$debug = false;
+
+$smarty = new Toolkit_Smarty(
+ BASE_PATH . 'admin/backgroundImage/smarty_tmp/',
+ BASE_PATH . 'admin/backgroundImage/smarty_comp/',
+ BASE_PATH . 'admin/backgroundImage/smarty_conf/',
+ BASE_PATH . 'admin/backgroundImage/smarty_cache/'
+);
+$dbh = Toolkit_Database::getInstance();
+if ($_FILES) {
+ $data = '<pre>' . print_r($_FILES, true) . '</pre>';
+ if ($_FILES['new_image']['size'] > 0 && !$_FILES['new_image']['error']) {
+ $mimeTypes = array(
+ 'image/jpeg',
+ 'image/jpg',
+ 'image/gif',
+ 'image/png',
+ );
+ if (in_array($_FILES['new_image']['type'], $mimeTypes)) {
+ try {
+ $dbh = Toolkit_Database::getInstance();
+ $ia = new Toolkit_FileServer_ImageAdapter();
+ $upload = $ia->upload('new_image');
+ $sql = "
+ UPDATE background.image
+ SET image = :image,
+ updated = current_date,
+ version = version + 1";
+ $stmt = $dbh->prepare($sql);
+ $stmt->bindParam(':image', $upload['name']);
+ $stmt->execute();
+ $message = '<p>Image upload Successful!</p>';
+ } catch(FileServerException $e) {
+ echo '<pre>$e: ' . print_r($e, true) . '</pre>';
+ }
+ // write the style sheet file out to disk
+ $styleSheetContent = '
+body {
+ background-image: url("' . FILE_SERVER_URL . IS_OWNER_ID . '/backgroundImage/' . $upload['name'] . '");
+}
+';
+ file_put_contents(BASE . 'css/background.css', $styleSheetContent);
+ // clean the cache file for the version
+ } else {
+ $message = '<p>Image uploaded is not jpeg, png, or gif. Please upload only these types</p>';
+ }
+ } else if ($_FILES['new_image']['error']) {
+ $message = '<p>There was an ERROR uploading your file!</p>';
+ }
+}
+
+$sql = "
+SELECT *
+ FROM background.image";
+$image_data = $dbh->query($sql)->fetch(PDO::FETCH_ASSOC);
+$bg_image = $image_data['image'];
+$bg_version = $image_data['version'];
+$bg_updated = $image_data['updated'];
+
+$smarty->assign('message', $message);
+$smarty->assign('image_path', FILE_SERVER_URL . IS_OWNER_ID . '/original/');
+$smarty->assign('bg_image', $bg_image);
+$smarty->assign('bg_version', $bg_version);
+$smarty->assign('bg_updated', $bg_updated);
+if ($debug) {
+ $smarty->assign('debug', '<pre>' . print_r($_FILES, true) . '</pre>');
+}
+
+$smarty->display('index.tpl');
--- /dev/null
+<?php /* Smarty version Smarty-3.1.14, created on 2016-05-06 12:03:49
+ compiled from "/var/www/server/www.cityofmi.org/admin/backgroundImage/smarty_tmp/index.tpl" */ ?>
+<?php /*%%SmartyHeaderCode:1074262171572b6b836dead9-11134679%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
+$_valid = $_smarty_tpl->decodeProperties(array (
+ 'file_dependency' =>
+ array (
+ '74702a15f989dbc8f6253a674d3d01ba61a34cd6' =>
+ array (
+ 0 => '/var/www/server/www.cityofmi.org/admin/backgroundImage/smarty_tmp/index.tpl',
+ 1 => 1462550627,
+ 2 => 'file',
+ ),
+ ),
+ 'nocache_hash' => '1074262171572b6b836dead9-11134679',
+ 'function' =>
+ array (
+ ),
+ 'version' => 'Smarty-3.1.14',
+ 'unifunc' => 'content_572b6b8370cdf3_84747520',
+ 'variables' =>
+ array (
+ 'message' => 0,
+ 'image_path' => 0,
+ 'bg_image' => 0,
+ 'bg_updated' => 0,
+ 'bg_version' => 0,
+ 'debug' => 0,
+ ),
+ 'has_nocache_code' => false,
+),false); /*/%%SmartyHeaderCode%%*/?>
+<?php if ($_valid && !is_callable('content_572b6b8370cdf3_84747520')) {function content_572b6b8370cdf3_84747520($_smarty_tpl) {?><html>
+<head>
+ <title>Background Image</title>
+</head>
+<body>
+<h1>Background Image</h1>
+<?php if ($_smarty_tpl->tpl_vars['message']->value){?>
+ <?php echo $_smarty_tpl->tpl_vars['message']->value;?>
+
+<?php }?>
+<form action="index.php" method="post" enctype="multipart/form-data">
+<p>This image needs to be 1900 x 1400 (height x width)</p>
+<span>Only upload images of type jpg png or gif)</span>
+<input type="file" name="new_image" />
+<input type="submit" value="Upload New Image" />
+</form>
+<div><img src="<?php echo $_smarty_tpl->tpl_vars['image_path']->value;?>
+<?php echo $_smarty_tpl->tpl_vars['bg_image']->value;?>
+"></div>
+<div><strong>Last Update</strong> <?php echo $_smarty_tpl->tpl_vars['bg_updated']->value;?>
+</div>
+<div><strong>Version</strong> <?php echo $_smarty_tpl->tpl_vars['bg_version']->value;?>
+</div>
+<?php if ($_smarty_tpl->tpl_vars['debug']->value){?>
+ <?php echo $_smarty_tpl->tpl_vars['debug']->value;?>
+
+<?php }?>
+</body>
+</html>
+<?php }} ?>
\ No newline at end of file
--- /dev/null
+<html>
+<head>
+ <title>Background Image</title>
+</head>
+<body>
+<h1>Background Image</h1>
+{if $message}
+ {$message}
+{/if}
+<form action="index.php" method="post" enctype="multipart/form-data">
+<p>This image needs to be 1900 x 1400 (height x width)</p>
+<span>Only upload images of type jpg png or gif)</span>
+<input type="file" name="new_image" />
+<input type="submit" value="Upload New Image" />
+</form>
+<div><img src="{$image_path}{$bg_image}"></div>
+<div><strong>Last Update</strong> {$bg_updated}</div>
+<div><strong>Version</strong> {$bg_version}</div>
+{if $debug}
+ {$debug}
+{/if}
+</body>
+</html>
$conf = new Config;
$nav['Home'] = MEDIA_BASE_URL.'admin/splash.phtml';
+$nav['Background Image'] = MEDIA_BASE_URL.'admin/backgroundImage/index.php';
$nav['Toolbox'] = MEDIA_BASE_URL.'admin/toolbox.php';
if (defined('GLM_BLOCKS') && GLM_BLOCKS) {
$blocksConfig = new Zend_Config_Ini(
--- /dev/null
+
+body {
+ background-image: url("http://is0.gaslightmedia.com/cityofmi/backgroundImage/is13-1462823942-73195.jpeg");
+}
}
body {
background-color: #e8e5db;
- background-image: url(assets/Spring_2016.jpeg);
+ /*background-image: url(assets/Spring_2016.jpeg);*/
background-size: cover;
background-attachment: fixed;
font-size: 1.3rem;
<link rel="stylesheet" href="{mediaBaseURL:h}css/superfish.css" media="screen">
<script src="{mediaBaseURL:h}js/hoverIntent.js"></script>
<script src="{mediaBaseURL:h}js/superfish.js"></script>
+ <link rel="stylesheet" href="{mediaBaseURL:h}css/background.css?v={bgVersion}">
<!-- initialise Superfish -->
<script>
jQuery(document).ready(function(){