TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Script Giveaway (http://www.talkphp.com/script-giveaway/)
-   -   Css Php (http://www.talkphp.com/script-giveaway/5428-css-php.html)

Monferno 05-26-2010 09:11 PM

Css Php
 
THis PHP script allows you to style your web pages using PHP.

PHP Code:

class CPHP {
        var 
$style;
        
        function 
CPHP() {
            
$this->style = array();
        }
        
        public function 
addSelector($name$attr) {
            
$this->style[] = "$name/@/$attr";
        }
        
        public function 
output() {
            print 
"<pre>";
            
print_r($this->style);
            print 
"</pre><style type='text/css'>";
            foreach (
$this->style as $s) {
                
$style explode('/@/'$s);
                
                print 
$style[0] . '{' $style[1] . '}';
            }
            print 
"</style>";
        }
    }
    
    
$cphp = new CPHP;
    
$cphp ->addSelector('h1''color: red; font-family: Sans-Serif;');
    
$cphp ->addSelector('h2''color: orange');
    
$cphp ->addSelector('h3''color: blue');
    
$cphp ->addSelector('p''color: green');
    
$cphp ->addSelector('p''background-color: red');
    
$cphp ->addSelector('h1''background-color: orange');
    
$cphp ->addSelector('h2''background-color: blue');
    
$cphp ->addSelector('h3''background-color: green');
    
    
$cphp ->output(); 


delayedinsanity 05-26-2010 10:24 PM

I could see that being useful if implemented in a framework - I'd like to see it perform some simple optimizations that most people don't like to do themselves (for some reason) such as looking for rules like border-radius and automatically generating -moz, -khtml and -webkit versions. Shortening color values from #ffffff to #fff or #cc0000 to #c00 would be cool, same with box model settings, margin: 15px 10px 10px 10px to margin: 15px 10px 10px and so on and so forth.


All times are GMT. The time now is 04:14 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0