
Untitled
By: a guest on
Jul 13th, 2012 | syntax:
PHP | size: 1.09 KB | hits: 24 | expires: Never
$page_count = intval($_REQUEST['pages']);
$item_count = intval($_REQUEST['chips']);
$chip = array (
'type' => 'header',
'model' => array (
'text' => '',
'font_size' => 10,
'position' => array (0, 0)
)
);
$w = 1004;
$h = 704;
$pages = array();
for ($i = 0; $i < $page_count; $i++) {
$page = array();
$html = "";//"<div class=\"page\">";
for ($j = 0; $j < $item_count; $j++) {
$item = $chip;
$item['model']['text'] = 'ELEMENT '.$i.'.'.$j;
$item['model']['position'] = array(mt_rand(5, $w - 200), mt_rand(5, $h - 50));
$item['model']['font_size'] = intval($j / $item_count * 70) + 10;
$page['chips'][] = $item;
$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>";
}
//$html .= "</div>";
$page['html'] = $html;
$pages[] = $page;
}
$out = json_encode(array('pages' => $pages ));
header("Content-Type: application/json");
echo $out;