Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question... PHP functions that'll work? - Solved
#1
Lightbulb 
Okay, to combat the numerous relative link issues and at the same time allow immense customization, I put my CSS in php files and included them in my template... but this increases (obviously) the loading time per pay by 140KBs (size of both CSS files collectively).
So.. what would be the best way to have my plugin instead output CSS files from these php files on command? This way styles are used as they are supposed to (in external files that apply to every page) but the customization from the admin cp is possible as well as fixing any relative link issue with the use of
PHP Code:
<?php get_theme_url(); ?>
to make absolute urls.
.... re-reading that... it sounds confusing... what I'm trying to say is I want to built static CSS files from PHP data after variables are set via my plugin options... whats the best way to do this?



And question 2....
I'm trying to figure out how to allow a user to paste their social site links in a text box and parse each line and validate the url. Then parse each line (I'll add html to give it an image whos filename matches the domain) in my template header....
Make sense? This way the user can just paste away and go instead of tediously trying to find the each field which matches their social site (and theme options would get really messy with 100s of fields).


So... any ideas?
Help is much appreciated!
This is all towards working on a major update to my FoundationNation theme for GetSimple.




Edit:
Doing things this way hasn't worked yet:
Code:
<link rel='stylesheet' type='text/css' href='css/style.php' />
And I don't want to change .htaccess to use css files as php.
I just want the php page to output the css file when accessed.
trying some function ideas out to see if I can make this method to work:
http://aquagraphite.com/2011/11/dynamica...using-php/
I was thinking something like this:
PHP Code:
/* This generates our PHP powered CSS files on demand */
function generate_styles_css() {
    global 
$SITEURL;
    global 
$TEMPLATE;
    
$themeurl trim($SITEURL "theme/" $TEMPLATE);
    
$stylefile_style $themeurl '/style.php';
    
$stylefile_app $themeurl '/appstyle.php';
    if(
file_exists($stylefile_style && $stylefile_app)){
        
ob_start(); // Capture all output
        
require($stylefile_style); // Generate CSS for style.php
        
require($stylefile_app); // Generate CSS for appstyle.php
        
$stylescss ob_get_clean(); // Get generated CSS (output buffering)
        
file_put_contents($themeurl 'style.css'$stylescssLOCK_EX); // Save it
    
}

is there a better way?
Reply
#2
Just return the proper headers for css, and of course use a cache file.
Or do you just want to output a css file once, when settings are modified.

What relative path issues are you having? I do not understand what problem you are having.
Just use relative to root then.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
Couple things I'm trying to do with the static CSS file (from PHP output).
One is have it rendered out when a user makes changes in the plugin settings such as background colors, images, widths, etc. And also have complete html paths in the static CSS instead of relative. This will allow the CSS to work no matter what directory it's called from (various reasons I like this idea).
So with this is mind the static CSS only needs to be rendered out when A) changes are made to the CSS php files via plugin settings or B) whenever save changes is clicked in plugin settings.

I also want the output optimally minimized with 0 errors or comments but still append a header comment for required credits, seems CSS comments don't play nice in PHP variables... the mulitline /* */ has an been an issue last night. So I thought maybe I'd make a separate header credits file and pull that in and then somehow only minifiy the php CSS files. But maybe I'm over complicating things.

Question 2 I haven't even touched yet... still working on getting question one working nicely. I'll be working on this more tonight and probably Monday.

Edit:
I just want to say thank you, thank you both shawn_a and influxweb for participating in this thread. Bouncing ideas around helps tremendously, so thank you. Smile
Reply
#4
Just make it relative to site root.
/pathtofolder
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
yea but I don't want to use relative at all... :/

here.. this might paint a clearer picture.. here's my current plugin php file:
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/
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';

# 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
);

# include HTMLawed
define("FOUND_PATH"dirname(__FILE__));
include (
FOUND_PATH "/FoundationPlugin/htmLawed.php");

# 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'=>//remove the bad tags
);
$lawedspec ''//allow elements override. see documentation

# hooks
add_action('theme-sidebar','createSideMenu',array($thisfile_foundi18n_r($thisfile_found.'/FOUNDATION_TITLE')));

# 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 '';
}


function 
foundation_show() {
    global 
$foundation_file$webfont$rgbvalue1$rgbvalue2$rgbvalue3$shortsitename$slogan$aboutpage$blogpage$facebook$googleplus$twitter$linkedin$tumblr$instagram$youtube$vimeo$github$thisfile_found;
    
$success=null;$error=null;
    
$poweredcss 0//initiate PHP Powered CSS check variable
    
    # 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")) ) {
    } else {
    
$error .= i18n_r($thisfile_found.'/THEMEPLUGIN_ERROR').' ';
    };
    
    
# Check if FoundationNation dir and files exists
    
if ( (is_dir(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")) && (file_exists(GSROOTPATH "/theme/FoundationNation/style.php")) && (file_exists(GSROOTPATH "/theme/FoundationNation/appstyle.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;
        
    
# This generates our PHP powered CSS files on demand
    
function generate_styles_css() {
        
$themeurl GSROOTPATH "theme/FoundationNation";
        
$stylefile_style $themeurl '/style.php';
        
$stylefile_app $themeurl '/appstyle.php';
        if(
file_exists($stylefile_style && $stylefile_app)){
            
ob_start(); // Capture all output
            
require($stylefile_style); // Generate CSS for style.php
            
require($stylefile_app); // Generate CSS for appstyle.php
            
$stylescss ob_get_clean(); // Get generated CSS (output buffering)
            
file_put_contents($themeurl 'style.css'$stylescssLOCK_EX); // Save it. LOCK_EX flag prevents anyone else from writing to the file at the same time
        
} else {
        
$error .= i18n_r($thisfile_found.'/STYLES_ERROR').' ';    
        }
    };

        
# 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']))), 011);
            if ((
$_POST['rgbvalue1']) == $checkrgbvalue1 or $fixedrgbvalue1 ) {
                
$rgbvalue1 $fixedrgbvalue1//we want only numbers and commas within a total limit of 11 characters
                
$poweredcss 1//turn PHP Powered CSS check variable flag on, because a change has been made
            
} 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']))), 011);
            if ((
$_POST['rgbvalue2']) == $checkrgbvalue2 or $fixedrgbvalue2 ) {
                
$rgbvalue2 $fixedrgbvalue2//we want only numbers and commas within a total limit of 11 characters
                
$poweredcss 1//turn PHP Powered CSS check variable flag on, because a change has been made
            
} 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']))), 011);
            if ((
$_POST['rgbvalue3']) == $checkrgbvalue3 or $fixedrgbvalue3 ) {
                
$rgbvalue3 $fixedrgbvalue3//we want only numbers and commas within a total limit of 11 characters
                
$poweredcss 1//turn PHP Powered CSS check variable flag on, because a change has been made
            
} 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);
            
            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');
            }
        }
        
        
# check if PHP powered CSS variables where changed, if so generate CSS
        
if($poweredcss 1) {
        
generate_styles_css(); //generate our new CSS file
        
$poweredcss 0//reset check variable
        
}
    }
    
    
?>
    <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/>';
    }
    
?>
    <div style="width: 100%;">
    <div id="mycolorpicker" class="cp-default"></div>
    <ul id="color-values">
            <li><label>RGB:</label><span id="rgb">rgb(255,0,0)</span></li>
            <li><label>HSV:</label><span id="hsv">hsv(0.2,1,1)</span></li>
            <li><label>HEX:</label><span id="hex">#FF0000</span></li>
    </ul>
    </div>
    <br clear="all"/>
    <form method="post" action="<?php    echo $_SERVER ['REQUEST_URI']?>">
        <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>
        <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('mycolorpicker'), function(hex, hsv, rgb, mouseSlide, mousePicker) {
    document.getElementById('rgb').style.backgroundColor = rgb;
    document.getElementById('hex').innerHTML = hex;
    document.getElementById('rgb').innerHTML = 'rgb(' + rgb.r.toFixed() + ',' + rgb.g.toFixed() + ',' + rgb.b.toFixed() + ')';
    document.getElementById('hsv').innerHTML = 'hsv(' + hsv.h.toFixed() + ',' + hsv.s.toFixed(2) + ',' + hsv.v.toFixed(2) + ')';
    });
    </script>    
    <?php


Now the structure or placement and use of this function:
PHP Code:
# This generates our PHP powered CSS files on demand
    
function generate_styles_css() {
        
$themeurl GSROOTPATH "theme/FoundationNation";
        
$stylefile_style $themeurl '/style.php';
        
$stylefile_app $themeurl '/appstyle.php';
        if(
file_exists($stylefile_style && $stylefile_app)){
            
ob_start(); // Capture all output
            
require($stylefile_style); // Generate CSS for style.php
            
require($stylefile_app); // Generate CSS for appstyle.php
            
$stylescss ob_get_clean(); // Get generated CSS (output buffering)
            
file_put_contents($themeurl 'style.css'$stylescssLOCK_EX); // Save it. LOCK_EX flag prevents anyone else from writing to the file at the same time
        
} else {
        
$error .= i18n_r($thisfile_found.'/STYLES_ERROR').' ';    
        }
    }; 
Is just not working.... lol... so question 1 is asking how I could get that function to work....... ?

I get a variable undefined error on line 136 which is:
PHP Code:
$error .= i18n_r($thisfile_found.'/STYLES_ERROR').' '
and the CSS file isn't being rendered yet.
Reply
#6
Thats a lot of globals, why not just pass the xml object around globally.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#7
You are calling file_exists() on not a file.
Turn php erroring on am pretty sure php should be throwing errors about your code.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
AH ha! thanks!
PHP Code:
# This generates our PHP powered CSS files on demand
function generate_styles_css() {
    
$stylefile_style GSROOTPATH "theme/FoundationNation/style.php";
    
$stylefile_app GSROOTPATH "theme/FoundationNation/appstyle.php";
    if(
file_exists($stylefile_style) && file_exists($stylefile_app)){
           
ob_start();
        require(
$stylefile_style) &&
        require(
$stylefile_app);
        
$stylescss ob_get_clean();
        
file_put_contents(GSROOTPATH "theme/FoundationNation/style.css"$stylescssLOCK_EX);
    } else {
        
$error .= i18n_r($thisfile_found.'/STYLES_ERROR').' ';
    }
}; 
but I'm still doing something wrong...
now the buffer gets thrown to the browser instead of the file.. not to mention to buffer is wrong... it's not including the data I want.

Yea.. I need to do something about the globals....


Edit:
Here I'd like to show you where it's at now:
Click for fullsize:
[Image: hG8WTNtl.png]
Reply
#9
Check it again your arg is a Boolean not a string
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#10
this is well beyond anything I've tried before (I'm new to webdesign btw, I'm a photographer/student)... even when reducing it to a string, it still doesn't output to the file but pushes the buffer to the browser as raw data... it's really ugly.. lol. I've no idea what the issue is.. I'm using XAMP 1.8.1 on windows 7x64 for development..
one person claimed it worked while others aren't sure:
http://stackoverflow.com/questions/15080...e-with-php
Reply
#11
Your probably using the wrong ob function.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#12
You are using && wrong in the requires.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#13
I found a way around the issue! 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&amp;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'=>//remove the bad tags
);
$lawedspec ''//allow elements override. see documentation

# hooks
add_action('theme-sidebar','createSideMenu',array($thisfile_foundi18n_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']))), 011);
            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']))), 011);
            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']))), 011);
            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);
            }
}; 
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 Big Grin

Edit:
btw I got rid of all those globals like you suggested lol
Reply
#14
or just use {less}
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#15
yea, I agree, SASS or LESS is exactly the way to go but I don't want to take on learning yet another language right now. This way will work for now.. without the extra extensions needed to make SASS work. For LESS I know there's this PHP compiler: http://leafo.net/lessphp/ and I think there's a PHP port for SASS too... but this str_replace way is the path of least resistance for me atm.
Reply
#16
I still don't understand just use a php file with variables instead of all those replacements.
Reply
#17
I just want the CSS rendered out when the plugin settings are changed for it. I've tried tons of different ideas and methods with GetSimple to get this to happen with the CSS in an additional PHP file and I just couldn't get the data in the other PHP file to both execute properly and output properly to the CSS file. There was always something wrong... So that's why I went this way. far as I know it's safe too and not to mention it achieves the desired result. Big Grin
Reply
#18
That's how we do it just look at style.php
Reply




Users browsing this thread: 1 Guest(s)