Exemple #1
0
 public function index()
 {
     // list products and prices
     $cates = make_dict($this->db->get('cate')->result_array());
     $subcates = make_dict($this->db->get('subcate')->result_array());
     $products = $this->db->get('product')->result_array();
     $price = make_dict($this->db->get_where('price', array('agent_level' => $this->user['level']))->result_array(), 'product_id');
     $tree = array();
     foreach ($products as $product) {
         $cate_id = $product['cate'];
         $subcate_id = $product['subcate'];
         if (!isset($tree[$cate_id])) {
             $tree[$cate_id] = $cates[$cate_id];
             $tree[$cate_id]['subcates'] = array();
         }
         if (!isset($tree[$cate_id]['subcates'][$subcate_id])) {
             $tree[$cate_id]['subcates'][$subcate_id] = $subcates[$subcate_id];
             $tree[$cate_id]['subcates'][$subcate_id]['products'] = array();
         }
         $product['stock_price'] = $price[$product['id']]['stock_price'];
         $tree[$cate_id]['subcates'][$subcate_id]['products'][$product['id']] = $product;
     }
     $this->load->vars('tree', $tree);
     $this->load->view('make');
 }
    $fp = fopen($file_name, "wb");
    if (!$fp) {
        echo "cannot open: ", $file_name, "\n";
        exit(1);
    }
    $count = 0;
    fwrite($fp, $header);
    for ($cp = 0; $cp < 0x10000; $cp++) {
        $result = get_decomposition_first($cp, 0);
        if ($result >= 0) {
            if ($is_html) {
                fwrite($fp, sprintf("&#x%x;(U+%04X) ; %s(U+%04X)\n", $cp, $cp, chr($result), $result));
            } else {
                fwrite($fp, pack("vc", $cp, $result));
            }
            $count++;
        }
        if ($count % 100 == 0) {
            echo "\r", sprintf("%04X", $cp);
        }
    }
    fwrite($fp, $footer);
    fclose($fp);
    chmod($file_name, 0644);
    $fp = null;
    echo "\n";
    echo $count, " codepoints are generated into {$file_name}.\n";
}
setup();
make_dict();
// vim:set ts=4 sw=4 fenc=UTF-8 ff=unix ft=php fdm=marker :