Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 13th, 2012  |  syntax: PHP  |  size: 1.09 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $page_count = intval($_REQUEST['pages']);
  2. $item_count = intval($_REQUEST['chips']);
  3.  
  4. $chip = array (
  5.   'type' => 'header',
  6.   'model' => array (
  7.     'text' => '',
  8.     'font_size' => 10,
  9.     'position' => array (0, 0)
  10.   )
  11. );
  12.  
  13. $w = 1004;
  14. $h = 704;
  15.  
  16. $pages = array();
  17. for ($i = 0; $i < $page_count; $i++) {
  18.   $page = array();
  19.   $html = "";//"<div class=\"page\">";
  20.   for ($j = 0; $j < $item_count; $j++) {
  21.     $item = $chip;
  22.     $item['model']['text'] = 'ELEMENT '.$i.'.'.$j;
  23.     $item['model']['position'] = array(mt_rand(5, $w - 200), mt_rand(5, $h - 50));
  24.     $item['model']['font_size'] = intval($j / $item_count * 70) + 10;
  25.     $page['chips'][] = $item;
  26.     $html .= "<div style=\"position:absolute;left:{$item['model']['position'][0]}px;top:{$item['model']['position'][1]}px;\"><h1 style=\"font-size:{$item['model']['font_size']}px;\">{$item['model']['text']}</h1></div>";
  27.   }
  28.   //$html .= "</div>";
  29.   $page['html'] = $html;
  30.   $pages[] = $page;
  31. }
  32.  
  33. $out = json_encode(array('pages' => $pages ));
  34.  
  35. header("Content-Type: application/json");
  36.   echo $out;