2013-02-27, 22:55:27
(This post was last modified: 2013-02-27, 22:56:13 by WebDevandPhoto.)
I found a way around the issue! lol:
Basically this function:
Takes a CSS template file in the plugin's folder which has tags in it, grabs it, replaces the tags and renders out the New CSS file to the template folder!
I think I'm missing something though as if defined() aren't working right... but other than that progress is happening
Edit:
btw I got rid of all those globals like you suggested lol
PHP Code:
<?php
/****************************************************
Plugin Name: FoundationNation Theme Settings
Description: Settings for the default GetSimple Theme: FoundationNation
Version: 1.1
* Theme Credits
* Theme FoundationNation developed by David AE Levy
* Title of Work: FoundationNation Theme for GetSimple MCMS
* Attribute work to name: David AE Levy
* Attribute work to URL: http://www.webdevandphoto.com
* Source work URL: http://www.webdevandphoto.com
* More permissions URL: http://www.levyimage.com
* Format of work: Multiple formats
* Copyright 2013, David AE Levy - http://www.webdevandphoto.com + http://www.levyimage.com
* Released under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/
* According to the license agreement you must keep my attributions intact on this theme and must stay intact both during and after any alterations you make to the theme
* Attribution must be as follows in theme footer: Theme by <a href="http://www.webdevandphoto.com" >WD&P</a>
* This massive comment block should also be left intact and unaltered.
* I ask if you make drastic changes to the theme please append your credits after my footer attribution so people know you edited the theme because I don't want credit for work I didn't do.
* thank you and I hope you enjoy my theme!
This plugin is inspired by the original plugin: Innovation by ccagle8
Original Plugin Author URI: http://chriscagle.me
*****************************************************/
# get correct id for plugin
$thisfile_found=basename(__FILE__, ".php");
$foundation_file=GSDATAOTHERPATH .'FoundationSettings.xml';
# include HTMLawed
define("FOUND_PATH", dirname(__FILE__));
include (FOUND_PATH . "/FoundationPlugin/htmLawed.php");
# add in this plugin's language file
i18n_merge($thisfile_found) || i18n_merge($thisfile_found, 'en_US');
# register plugin
register_plugin(
$thisfile_found, # ID of plugin, should be filename minus php
i18n_r($thisfile_found.'/FOUNDATION_TITLE'), # Title of plugin
'1.1', # Version of plugin
'Levy Image', # Author of plugin
'http://webdevandphoto.com', # Author URL
i18n_r($thisfile_found.'/FOUNDATION_DESC'), # Plugin Description
'theme', # Page type of plugin
'foundation_show' # Function that displays content
);
# Configure HTMLawed
$lawedconfig = array(
'safe'=>1, //auto config maximum safety
'deny_attribute'=>'style, on*', //disable inline styles and on click to prevent click hijacking
'tidy'=>-1, //minify any html data
'elements'=>'* -script', //disable script element
'keep_bad'=>0 //remove the bad tags
);
$lawedspec = ''; //allow elements override. see documentation
# hooks
add_action('theme-sidebar','createSideMenu',array($thisfile_found, i18n_r($thisfile_found.'/FOUNDATION_TITLE')));
#Check variables and write to CSS
function phppowered_css() {
if ((!$cssflag) && (file_exists(FOUND_PATH . "/FoundationPlugin/style.css"))) {
$url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'];
$url .= htmlspecialchars($_SERVER['REQUEST_URI']);
$themeurl = dirname(dirname($url)) . "/theme/FoundationNation/images";
//open file and get data
$data = file_get_contents(FOUND_PATH . "/FoundationPlugin/style.css");
// do tag replacements or whatever you want
if (defined('IMAGECDN')) {
$data = str_replace("<THEMEURL>", $imagecdn, $data);
} else {
$data = str_replace("<THEMEURL>", $themeurl, $data);
}
if (defined('RGBVALUE1')) {
$data = str_replace("<RGBVALUE1>", $rgbvalue1, $data);
} else {
$data = str_replace("<RGBVALUE1>", "40,52,59", $data);
}
if (defined('RGBVALUE2')) {
$data = str_replace("<RGBVALUE2>", $rgbvalue2, $data);
} else {
$data = str_replace("<RGBVALUE2>", "20,30,30", $data);
}
if (defined('RGBVALUE3')) {
$data = str_replace("<RGBVALUE3>", $rgbvalue3, $data);
} else {
$data = str_replace("<RGBVALUE3>", "17,17,17", $data);
}
if (defined('RGBVALUE4')) {
$data = str_replace("<RGBVALUE4>", $rgbvalue4, $data);
} else {
$data = str_replace("<RGBVALUE4>", "", $data);
}
if (defined('RGBVALUE5')) {
$data = str_replace("<RGBVALUE5>", $rgbvalue5, $data);
} else {
$data = str_replace("<RGBVALUE5>", "", $data);
}
//save it back:
file_put_contents(GSROOTPATH . "/theme/FoundationNation/style.css", $data);
}
};
function foundation_show() {
global $foundation_file, $thisfile_found;
$success=null;$error=null;$cssflag="on";
# get XML data
if (file_exists($foundation_file)) {
$x = getXML($foundation_file);
$webfont = $x->webfont;
$rgbvalue1 = $x->rgbvalue1;
$rgbvalue2 = $x->rgbvalue2;
$rgbvalue3 = $x->rgbvalue3;
$shortsitename = $x->shortsitename;
$slogan = $x->slogan;
$aboutpage = $x->aboutpage;
$blogpage = $x->blogpage;
$facebook = $x->facebook;
$googleplus = $x->googleplus;
$twitter = $x->twitter;
$linkedin = $x->linkedin;
$tumblr = $x->tumblr;
$instagram = $x->instagram;
$youtube = $x->youtube;
$vimeo = $x->vimeo;
$github = $x->github;
} else {
$webfont ='';
$rgbvalue1 ='';
$rgbvalue2 ='';
$rgbvalue3 ='';
$shortsitename = '';
$slogan = '';
$aboutpage = '';
$blogpage = '';
$facebook = '';
$googleplus = '';
$twitter = '';
$linkedin = '';
$tumblr = '';
$instagram = '';
$youtube = '';
$vimeo = '';
$github = '';
}
# Check if FoundationNation Plugin files exists
if ( (file_exists(GSROOTPATH . "/plugins/FoundationPlugin/colorpicker.js")) && (file_exists(GSROOTPATH . "/plugins/FoundationPlugin/colorpicker.css")) && (file_exists(GSROOTPATH . "/plugins/FoundationPlugin/htmLawed.php")) && (file_exists(GSROOTPATH . "/plugins/FoundationPlugin/style.css")) ) {
} else {
$error .= i18n_r($thisfile_found.'/THEMEPLUGIN_ERROR').' ';
};
# Check if FoundationNation dir and files exists
if ( (is_dir(trim(GSROOTPATH . "/theme/FoundationNation"))) && (file_exists(GSROOTPATH . "/theme/FoundationNation/functions.php")) && (file_exists(GSROOTPATH . "/theme/FoundationNation/header.php")) && (file_exists(GSROOTPATH . "/theme/FoundationNation/footer.php")) && (file_exists(GSROOTPATH . "/theme/FoundationNation/slider.php")) && (file_exists(GSROOTPATH . "/theme/FoundationNation/social.php")) && (file_exists(GSROOTPATH . "/theme/FoundationNation/template.php")) ) {
} else {
$error .= i18n_r($thisfile_found.'/THEME_ERROR').' ';
};
// submitted form
if (isset($_POST['submit'])) {
$webfont=null; $rgbvalue1=null; $rgbvalue2=null; $rgbvalue3=null; $shortsitename=null; $slogan=null; $aboutpage=null; $blogpage=null; $facebook=null; $googleplus=null; $twitter=null; $linkedin=null; $tumblr=null; $instagram=null; $youtube=null; $vimeo=null; $github=null;
# check to see if the entries provided are valid
if ($_POST['webfont'] != '') {
if (($_POST['webfont']) == (preg_replace("/[^a-zA-Z0-9+|:]+/", "",($_POST['webfont'])))) {
$webfont = $_POST['webfont']; //we want characters +|: allowed so used preg rep
} else {
$error .= i18n_r($thisfile_found.'/WEBFONT_ERROR').' ';
}
}
if ($_POST['rgbvalue1'] != '') {
$checkrgbvalue1 = substr((preg_replace("/[^0-9,rgb()]+/", "",($_POST['rgbvalue1']))),0,16);
$fixedrgbvalue1 = substr((preg_replace("/[^0-9,]+/", "",($_POST['rgbvalue1']))), 0, 11);
if (($_POST['rgbvalue1']) == $checkrgbvalue1 or $fixedrgbvalue1 ) {
$rgbvalue1 = $fixedrgbvalue1; //we want only numbers and commas within a total limit of 11 characters
$cssflag=null;
} else {
$error .= i18n_r($thisfile_found.'/RGBVALUE1_ERROR').' ';
}
}
if ($_POST['rgbvalue2'] != '') {
$checkrgbvalue2 = substr((preg_replace("/[^0-9,rgb()]+/", "",($_POST['rgbvalue2']))),0,16);
$fixedrgbvalue2 = substr((preg_replace("/[^0-9,]+/", "",($_POST['rgbvalue2']))), 0, 11);
if (($_POST['rgbvalue2']) == $checkrgbvalue2 or $fixedrgbvalue2 ) {
$rgbvalue2 = $fixedrgbvalue2; //we want only numbers and commas within a total limit of 11 characters
} else {
$error .= i18n_r($thisfile_found.'/RGBVALUE2_ERROR').' ';
}
}
if ($_POST['rgbvalue3'] != '') {
$checkrgbvalue3 = substr((preg_replace("/[^0-9,rgb()]+/", "",($_POST['rgbvalue3']))),0,16);
$fixedrgbvalue3 = substr((preg_replace("/[^0-9,]+/", "",($_POST['rgbvalue3']))), 0, 11);
if (($_POST['rgbvalue3']) == $checkrgbvalue3 or $fixedrgbvalue3 ) {
$rgbvalue3 = $fixedrgbvalue3; //we want only numbers and commas within a total limit of 11 characters
} else {
$error .= i18n_r($thisfile_found.'/RGBVALUE3_ERROR').' ';
}
}
if ($_POST['shortsitename'] != '') {
if (ctype_alnum($_POST['shortsitename'])) {
$shortsitename = $_POST['shortsitename']; //ctype does the trick since we don't want spaces and only alphanum
} else {
$error .= i18n_r($thisfile_found.'/SHORTSITENAME_ERROR').' ';
}
}
if ($_POST['aboutpage'] != '') {
if (validate_url($_POST['aboutpage'])) {
$aboutpage = $_POST['aboutpage']; //we must validate if real url
} else {
$error .= i18n_r($thisfile_found.'/ABOUTPAGE_ERROR').' ';
}
}
if ($_POST['blogpage'] != '') {
if (validate_url($_POST['blogpage'])) {
$blogpage = $_POST['blogpage'];
} else {
$error .= i18n_r($thisfile_found.'/BLOGPAGE_ERROR').' ';
}
}
if ($_POST['slogan'] != '') {
if (($_POST['slogan']) == (preg_replace("/[^a-zA-Z0-9 ]+/", "",($_POST['slogan'])))) {
$slogan = $_POST['slogan']; //we want spaces allowed so used preg rep
} else {
$error .= i18n_r($thisfile_found.'/SLOGAN_ERROR').' ';
}
}
if ($_POST['facebook'] != '') {
if (validate_url($_POST['facebook'])) {
$facebook = $_POST['facebook'];
} else {
$error .= i18n_r($thisfile_found.'/FACEBOOK_ERROR').' ';
}
}
if ($_POST['googleplus'] != '') {
if (validate_url($_POST['googleplus'])) {
$googleplus = $_POST['googleplus'];
} else {
$error .= i18n_r($thisfile_found.'/GOOGLEPLUS_ERROR').' ';
}
}
if ($_POST['twitter'] != '') {
if (validate_url($_POST['twitter'])) {
$twitter = $_POST['twitter'];
} else {
$error .= i18n_r($thisfile_found.'/TWITTER_ERROR').' ';
}
}
if ($_POST['linkedin'] != '') {
if (validate_url($_POST['linkedin'])) {
$linkedin = $_POST['linkedin'];
} else {
$error .= i18n_r($thisfile_found.'/LINKEDIN_ERROR').' ';
}
}
if ($_POST['tumblr'] != '') {
if (validate_url($_POST['tumblr'])) {
$tumblr = $_POST['tumblr'];
} else {
$error .= i18n_r($thisfile_found.'/TUMBLR_ERROR').' ';
}
}
if ($_POST['instagram'] != '') {
if (validate_url($_POST['instagram'])) {
$instagram = $_POST['instagram'];
} else {
$error .= i18n_r($thisfile_found.'/INSTAGRAM_ERROR').' ';
}
}
if ($_POST['youtube'] != '') {
if (validate_url($_POST['youtube'])) {
$youtube = $_POST['youtube'];
} else {
$error .= i18n_r($thisfile_found.'/YOUTUBE_ERROR').' ';
}
}
if ($_POST['vimeo'] != '') {
if (validate_url($_POST['vimeo'])) {
$vimeo = $_POST['vimeo'];
} else {
$error .= i18n_r($thisfile_found.'/VIMEO_ERROR').' ';
}
}
if ($_POST['github'] != '') {
if (validate_url($_POST['github'])) {
$github = $_POST['github'];
} else {
$error .= i18n_r($thisfile_found.'/GITHUB_ERROR').' ';
}
}
# if there are no errors, save data
if (!$error) {
$xml = @new SimpleXMLElement('<item></item>');
$xml->addChild('webfont', $webfont);
$xml->addChild('rgbvalue1', $rgbvalue1);
$xml->addChild('rgbvalue2', $rgbvalue2);
$xml->addChild('rgbvalue3', $rgbvalue3);
$xml->addChild('shortsitename', $shortsitename);
$xml->addChild('slogan', $slogan);
$xml->addChild('aboutpage', $aboutpage);
$xml->addChild('blogpage', $blogpage);
$xml->addChild('facebook', $facebook);
$xml->addChild('googleplus', $googleplus);
$xml->addChild('twitter', $twitter);
$xml->addChild('linkedin', $linkedin);
$xml->addChild('tumblr', $tumblr);
$xml->addChild('instagram', $instagram);
$xml->addChild('youtube', $youtube);
$xml->addChild('vimeo', $vimeo);
$xml->addChild('github', $github);
phppowered_css();
if (! $xml->asXML($foundation_file)) {
$error = i18n_r('CHMOD_ERROR');
} else {
$x = getXML($foundation_file);
$webfont = $x->webfont;
$rgbvalue1 = $x->rgbvalue1;
$rgbvalue2 = $x->rgbvalue2;
$rgbvalue3 = $x->rgbvalue3;
$shortsitename = $x->shortsitename;
$slogan = $x->slogan;
$aboutpage = $x->aboutpage;
$blogpage = $x->blogpage;
$facebook = $x->facebook;
$googleplus = $x->googleplus;
$twitter = $x->twitter;
$linkedin = $x->linkedin;
$tumblr = $x->tumblr;
$instagram = $x->instagram;
$youtube = $x->youtube;
$vimeo = $x->vimeo;
$github = $x->github;
$success = i18n_r('SETTINGS_UPDATED');
}
}
}
?>
<h3><?php i18n($thisfile_found.'/FOUNDATION_TITLE'); ?></h3>
<noscript>
Please enable JavaScript to properly use this Theme Plugin
</noscript>
<?php
if($success) {
echo '<p style="color:#5da423;"><b>'. $success .'</b></p>';
}
if($error) {
echo '<p style="color:#c60f13;"><b>'. $error .'</b></p>';
}
?>
<?php
if((file_exists(GSROOTPATH . "/plugins/FoundationPlugin/colorpicker.js")) && (file_exists(GSROOTPATH . "/plugins/FoundationPlugin/colorpicker.css")) ) {
echo '<!-- This script will allow color picker to work -->';
$new_elm = ((file_get_contents(GSROOTPATH . "/plugins/FoundationPlugin/colorpicker.css")).(file_get_contents(GSROOTPATH . "/plugins/FoundationPlugin/colorpicker.js")));
echo $new_elm;
}
if(file_exists(GSROOTPATH . "/theme/FoundationNation/images/screenshot.png")) {
$screenshot = "../theme/FoundationNation/images/screenshot.png";
echo '<img style="border:2px solid #333;" src="'. $screenshot .'" alt="Theme Screenshot"><br/><br/>';
}
?>
<form method="post" action="<?php echo $_SERVER ['REQUEST_URI']?>">
<hr />
<strong>Currently Saved Header Bar Gradient:</strong>
<div class="currentheaderbar" style="background: rgb(<?php if (isset($rgbvalue1)) { ?><?php echo $rgbvalue1; ?><?php } else { ?>40,52,59<?php } ?>) !important;background: -moz-linear-gradient(top, rgba(<?php if (isset($rgbvalue1)) { ?><?php echo $rgbvalue1; ?><?php } else { ?>40,52,59<?php } ?>,1) 0%, rgba(<?php if (isset($rgbvalue2)) { ?><?php echo $rgbvalue2; ?><?php } else { ?>20,30,30<?php } ?>,1) 36%, rgba(<?php if (isset($rgbvalue3)) { ?><?php echo $rgbvalue3; ?><?php } else { ?>17,17,17<?php } ?>,1) 100%) !important;background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(<?php if (isset($rgbvalue1)) { ?><?php echo $rgbvalue1; ?><?php } else { ?>40,52,59<?php } ?>,1)), color-stop(36%,rgba(<?php if (isset($rgbvalue2)) { ?><?php echo $rgbvalue2; ?><?php } else { ?>20,30,30<?php } ?>,1)), color-stop(100%,rgba(<?php if (isset($rgbvalue3)) { ?><?php echo $rgbvalue3; ?><?php } else { ?>17,17,17<?php } ?>,1))) !important;background: -webkit-linear-gradient(top, rgba(<?php if (isset($rgbvalue1)) { ?><?php echo $rgbvalue1; ?><?php } else { ?>40,52,59<?php } ?>,1) 0%,rgba(<?php if (isset($rgbvalue2)) { ?><?php echo $rgbvalue2; ?><?php } else { ?>20,30,30<?php } ?>,1) 36%,rgba(<?php if (isset($rgbvalue3)) { ?><?php echo $rgbvalue3; ?><?php } else { ?>17,17,17<?php } ?>,1) 100%) !important;background: -o-linear-gradient(top, rgba(<?php if (isset($rgbvalue1)) { ?><?php echo $rgbvalue1; ?><?php } else { ?>40,52,59<?php } ?>,1) 0%,rgba(<?php if (isset($rgbvalue2)) { ?><?php echo $rgbvalue2; ?><?php } else { ?>20,30,30<?php } ?>,1) 36%,rgba(<?php if (isset($rgbvalue3)) { ?><?php echo $rgbvalue3; ?><?php } else { ?>17,17,17<?php } ?>,1) 100%) !important;background: -ms-linear-gradient(top, rgba(<?php if (isset($rgbvalue1)) { ?><?php echo $rgbvalue1; ?><?php } else { ?>40,52,59<?php } ?>,1) 0%,rgba(<?php if (isset($rgbvalue2)) { ?><?php echo $rgbvalue2; ?><?php } else { ?>20,30,30<?php } ?>,1) 36%,rgba(<?php if (isset($rgbvalue3)) { ?><?php echo $rgbvalue3; ?><?php } else { ?>17,17,17<?php } ?>,1) 100%) !important;background: linear-gradient(to bottom, rgba(<?php if (isset($rgbvalue1)) { ?><?php echo $rgbvalue1; ?><?php } else { ?>40,52,59<?php } ?>,1) 0%,rgba(<?php if (isset($rgbvalue2)) { ?><?php echo $rgbvalue2; ?><?php } else { ?>20,30,30<?php } ?>,1) 36%,rgba(<?php if (isset($rgbvalue3)) { ?><?php echo $rgbvalue3; ?><?php } else { ?>17,17,17<?php } ?>,1) 100%) !important;filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#28343b', endColorstr='#111',GradientType=0 ) !important;-moz-box-shadow: 0px 3px 4px rgba(0, 0, 0, 0.4);-webkit-box-shadow: 0px 3px 4px rgba(0, 0, 0, 0.4);box-shadow: 0px 3px 4px rgba(0, 0, 0, 0.4);"></div><br/>
<div>
<p><strong>Color pickers for the 3 color gradient of the theme header bar!</strong><br/>Color 1 is shared with drop down header, footer, and slider 3 color gradients for color schema cohesion!</p>
<div id="mycolorpicker1" class="cp-default" title="Color 1"></div>
<div id="mycolorpicker2" class="cp-default" title="Color 2"></div>
<div id="mycolorpicker3" class="cp-default" title="Color 3"></div>
<br clear="all"/><br/>
<p><label for="inn_rgbvalue1" ><?php i18n($thisfile_found.'/RGBVALUE1_TEXT'); ?></label><input id="inn_rgbvalue1" name="rgbvalue1" class="text" value="rgb(<?php echo $rgbvalue1; ?>)" type="text" /></p>
<p><label for="inn_rgbvalue2" ><?php i18n($thisfile_found.'/RGBVALUE2_TEXT'); ?></label><input id="inn_rgbvalue2" name="rgbvalue2" class="text" value="rgb(<?php echo $rgbvalue2; ?>)" type="text" /></p>
<p><label for="inn_rgbvalue3" ><?php i18n($thisfile_found.'/RGBVALUE3_TEXT'); ?></label><input id="inn_rgbvalue3" name="rgbvalue3" class="text" value="rgb(<?php echo $rgbvalue3; ?>)" type="text" /></p>
</div><hr /><br/>
<p><label for="inn_webfont" ><?php i18n($thisfile_found.'/WEBFONT_TEXT'); ?></label><input id="inn_webfont" name="webfont" class="text" value="<?php echo $webfont; ?>" type="text" /></p>
<p><label for="inn_shortsitename" ><?php i18n($thisfile_found.'/SHORTSITENAME_TEXT'); ?></label><input id="inn_shortsitename" name="shortsitename" class="text" value="<?php echo $shortsitename; ?>" type="text" /></p>
<p><label for="inn_aboutpage" ><?php i18n($thisfile_found.'/ABOUTPAGE_URL'); ?></label><input id="inn_aboutpage" name="aboutpage" class="text" value="<?php echo $aboutpage; ?>" type="url" /></p>
<p><label for="inn_blogpage" ><?php i18n($thisfile_found.'/BLOGPAGE_URL'); ?></label><input id="inn_blogpage" name="blogpage" class="text" value="<?php echo $blogpage; ?>" type="url" /></p>
<p><label for="inn_slogan" ><?php i18n($thisfile_found.'/SLOGAN_TEXT'); ?></label><input id="inn_slogan" name="slogan" class="text" value="<?php echo $slogan; ?>" type="text" /></p>
<p><label for="inn_facebook" ><?php i18n($thisfile_found.'/FACEBOOK_URL'); ?></label><input id="inn_facebook" name="facebook" class="text" value="<?php echo $facebook; ?>" type="url" /></p>
<p><label for="inn_googleplus" ><?php i18n($thisfile_found.'/GOOGLEPLUS_URL'); ?></label><input id="inn_googleplus" name="googleplus" class="text" value="<?php echo $googleplus; ?>" type="url" /></p>
<p><label for="inn_twitter" ><?php i18n($thisfile_found.'/TWITTER_URL'); ?></label><input id="inn_twitter" name="twitter" class="text" value="<?php echo $twitter; ?>" type="url" /></p>
<p><label for="inn_linkedin" ><?php i18n($thisfile_found.'/LINKEDIN_URL'); ?></label><input id="inn_linkedin" name="linkedin" class="text" value="<?php echo $linkedin; ?>" type="url" /></p>
<p><label for="inn_tumblr" ><?php i18n($thisfile_found.'/TUMBLR_URL'); ?></label><input id="inn_tumblr" name="tumblr" class="text" value="<?php echo $tumblr; ?>" type="url" /></p>
<p><label for="inn_instagram" ><?php i18n($thisfile_found.'/INSTAGRAM_URL'); ?></label><input id="inn_instagram" name="instagram" class="text" value="<?php echo $instagram; ?>" type="url" /></p>
<p><label for="inn_youtube" ><?php i18n($thisfile_found.'/YOUTUBE_URL'); ?></label><input id="inn_youtube" name="youtube" class="text" value="<?php echo $youtube; ?>" type="url" /></p>
<p><label for="inn_vimeo" ><?php i18n($thisfile_found.'/VIMEO_URL'); ?></label><input id="inn_vimeo" name="vimeo" class="text" value="<?php echo $vimeo; ?>" type="url" /></p>
<p><label for="inn_github" ><?php i18n($thisfile_found.'/GITHUB_URL'); ?></label><input id="inn_github" name="github" class="text" value="<?php echo $github; ?>" type="url" /></p>
<p><input type="submit" id="submit" class="submit" value="<?php i18n('BTN_SAVESETTINGS'); ?>" name="submit" /></p>
</form>
<script>
ColorPicker(
document.getElementById('mycolorpicker1'), function(hex, hsv, rgb, mouseSlide, mousePicker) {
document.getElementById('inn_rgbvalue1').value = 'rgb(' + rgb.r.toFixed() + ',' + rgb.g.toFixed() + ',' + rgb.b.toFixed() + ')';
document.getElementById('inn_rgbvalue1').style.backgroundColor = document.getElementById('inn_rgbvalue1').value;
});
ColorPicker(
document.getElementById('mycolorpicker2'), function(hex, hsv, rgb, mouseSlide, mousePicker) {
document.getElementById('inn_rgbvalue2').value = 'rgb(' + rgb.r.toFixed() + ',' + rgb.g.toFixed() + ',' + rgb.b.toFixed() + ')';
document.getElementById('inn_rgbvalue2').style.backgroundColor = document.getElementById('inn_rgbvalue2').value;
});
ColorPicker(
document.getElementById('mycolorpicker3'), function(hex, hsv, rgb, mouseSlide, mousePicker) {
document.getElementById('inn_rgbvalue3').value = 'rgb(' + rgb.r.toFixed() + ',' + rgb.g.toFixed() + ',' + rgb.b.toFixed() + ')';
document.getElementById('inn_rgbvalue3').style.backgroundColor = document.getElementById('inn_rgbvalue3').value;
});
document.getElementById('inn_rgbvalue1').style.backgroundColor = document.getElementById('inn_rgbvalue1').value;
document.getElementById('inn_rgbvalue2').style.backgroundColor = document.getElementById('inn_rgbvalue2').value;
document.getElementById('inn_rgbvalue3').style.backgroundColor = document.getElementById('inn_rgbvalue3').value;
</script>
<?php
}
Basically this function:
PHP Code:
#Check variables and write to CSS
function phppowered_css() {
if ((!$cssflag) && (file_exists(FOUND_PATH . "/FoundationPlugin/style.css"))) {
$url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'];
$url .= htmlspecialchars($_SERVER['REQUEST_URI']);
$themeurl = dirname(dirname($url)) . "/theme/FoundationNation/images";
//open file and get data
$data = file_get_contents(FOUND_PATH . "/FoundationPlugin/style.css");
// do tag replacements or whatever you want
if (defined('IMAGECDN')) {
$data = str_replace("<THEMEURL>", $imagecdn, $data);
} else {
$data = str_replace("<THEMEURL>", $themeurl, $data);
}
if (defined('RGBVALUE1')) {
$data = str_replace("<RGBVALUE1>", $rgbvalue1, $data);
} else {
$data = str_replace("<RGBVALUE1>", "40,52,59", $data);
}
if (defined('RGBVALUE2')) {
$data = str_replace("<RGBVALUE2>", $rgbvalue2, $data);
} else {
$data = str_replace("<RGBVALUE2>", "20,30,30", $data);
}
if (defined('RGBVALUE3')) {
$data = str_replace("<RGBVALUE3>", $rgbvalue3, $data);
} else {
$data = str_replace("<RGBVALUE3>", "17,17,17", $data);
}
if (defined('RGBVALUE4')) {
$data = str_replace("<RGBVALUE4>", $rgbvalue4, $data);
} else {
$data = str_replace("<RGBVALUE4>", "", $data);
}
if (defined('RGBVALUE5')) {
$data = str_replace("<RGBVALUE5>", $rgbvalue5, $data);
} else {
$data = str_replace("<RGBVALUE5>", "", $data);
}
//save it back:
file_put_contents(GSROOTPATH . "/theme/FoundationNation/style.css", $data);
}
};
I think I'm missing something though as if defined() aren't working right... but other than that progress is happening
Edit:
btw I got rid of all those globals like you suggested lol