data-store.php

Basic data store utility -- unfinished
git clone git://git.finwo.net/lib/data-store.php
Log | Files | Refs

grid.css.php (1442B)


      1 <?php header('Content-Type: text/css'); ?>
      2 [class^=col-] { float:left;width:99.9% }
      3 @media all and (min-width: 720px) {
      4 <?php
      5     function string_format( $template, $data, $prefix = "" ) {
      6         foreach ($data as $key => $value) {
      7             $compositeKey = $prefix . $key;
      8             switch(gettype($value)) {
      9                 case 'string':
     10                 case 'double':
     11                 case 'float':
     12                 case 'integer':
     13                     $template = str_replace( '{'.$compositeKey.'}', $value, $template);
     14                     break;
     15                 case 'boolean':
     16                     $template = str_replace( '{'.$compositeKey.'}', $value ? 'true' : 'false', $template);
     17                     break;
     18                 case 'object':
     19                     $value = (array) $value;
     20                 case 'array':
     21                     $template = string_format( $template, $value, $compositeKey . '.');
     22                     break;
     23             }
     24         }
     25         return $template;
     26     }
     27     function print_grid( $columns, $current = 1 ) {
     28       if ( $current > $columns ) {return;}
     29       print(string_format("  .col-{current}-{columns} {width:{width}%}\n",array(
     30           'columns'=>$columns,
     31           'current'=>$current,
     32           'width'=>$current/$columns*99.9
     33       )));
     34       print_grid($columns,$current+1);
     35     }
     36     $grid = array( 3, 5, 9, 12 );
     37     foreach ($grid as $columns) {
     38         print_grid($columns);
     39     }
     40 ?>
     41 }