Advertisement
Guest User

Untitled

a guest
Oct 18th, 2014
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. class PHP2CSS {
  4.    
  5.     private static $stylesheet = [];
  6.     private static $setContenttype = false;
  7.    
  8.     public static function contentType($contentType) {
  9.         self::$setContenttype = true;
  10.     }
  11.    
  12.     public static function addStyle($keyname, array $array) {
  13.         self::$stylesheet[] = [
  14.             'name' => $keyname,
  15.             'styles' => $array
  16.         ];
  17.     }
  18.    
  19.     public static function generateStylesheet() {
  20.         if(self::$setContenttype) {
  21.             header('Content-type: '.self::$setContenttype);
  22.         }
  23.         $nStyle = null;
  24.         foreach(self::$stylesheet as $style) {
  25.             $nStyle .= $style['name'].' {'."\n";
  26.                 foreach($style['styles'] as $keyword => $value) {
  27.                     $nStyle .= "\t".$keyword.': '.$value.";\n";
  28.                 }
  29.             $nStyle .= '}'."\n\n";
  30.         }
  31.        
  32.         echo $nStyle;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement