insert('dogs_race', $req->request->all()); return $app->json(one('select * from dogs_race order by id desc limit 1')); }); $app->get('/races/{id}', function (Application $app, Request $req, $id) { return $app->json(one('select * from dogs_race where id =' . q($id))); }); $app->put('/races/{id}', function (Application $app, Request $req, $id) { $json = $req->request->all(); unset($json['id']); update('dogs_race', $id, $json); return $app->json(); }); $app->options('/races/{id}', function (Application $app, Request $req, $id) { return new Response('', 204); }); $app->delete('/races/{id}', function (Application $app, Request $req, $id) { query('delete from dogs_race where id=' . q($id)); return new Response('', 204); }); $app->get('/dogs', function (Application $app, Request $req) { $pp = (int) $req->get('_perPage'); $p = (int) $req->get('_page') - 1; if ($pp == 0) { $pp = 30; } return $app->json(all('select * from dogs_dogs limit ' . $pp . ' offset ' . $p * $pp), 200, ['X-Total-Count' => col('select count(*) from dogs_dogs')]); }); $app->get('/dogs/{id}', function (Application $app, Request $req, $id) { return $app->json(one('select * from dogs_dogs where id = ' . q($id))); }); $app->run();
} echo div(array('class' => 'checkbox')); echo '<label>'; echo form_checkbox(array('name' => 'alterar_imagem', 'value' => '1', 'class' => 'checkbox')); echo ' Alterar a foto.</label>'; echo close_div(3); echo col(4); echo div(array('class' => 'form-group')); echo form_label('Palavras-chave (Separe com vírgula)', 'tags'); echo form_textarea(array('name' => 'tags', 'value' => $row->tags, 'class' => 'form-control', 'rows' => '5')); echo close_div(2); // Opções de status $options = array('0' => 'Rascunho', '1' => 'Publicado'); echo col(3); echo div(array('class' => 'form-group')); echo form_label('Status', 'status'); echo form_dropdown('status', $options, $row->status, null, 'form-control'); echo close_div(3); echo hr(); echo row(); echo col(); echo form_button(array('type' => 'submit', 'name' => 'submit', 'content' => 'Salvar as alterações', 'class' => 'btn btn-primary')); echo nbs(); // echo anchor('admin/pages', 'Cancelar', array('class' => 'btn btn-danger')); echo close_div(3); echo form_close(); ?> </div> </div> </section>
<?php define('INPUT', '.,.,2,.,.,7,4,.,.,.,.,.,4,9,.,.,.,.,9,.,.,3,2,.,.,.,8,4,.,.,7,.,.,6,2,.,.,5,9,.,.,.,3,7,.,.,7,6,.,.,3,.,.,5,8,.,.,.,6,9,.,.,1,.,.,.,.,3,4,.,.,.,.,.,4,2,.,.,9,.,.'); require 'test-fw.php'; ob_start(); require 'solver.php'; $solution = ob_get_contents(); ob_end_clean(); it('solves the puzzle', $solution == '3,8,2,1,5,7,4,9,6,6,1,5,4,9,8,2,3,7,9,4,7,3,2,6,1,5,8,4,3,8,7,1,5,6,2,9,1,5,9,6,8,2,3,7,4,2,7,6,9,4,3,8,1,5,8,2,3,5,6,9,7,4,1,7,9,1,8,3,4,5,6,2,5,6,4,2,7,1,9,8,3' . PHP_EOL); it('receives 81 numbers', COUNT == 81); it('detects 9 as board size', SIZE == 9); it('detects 3 as block size', SQUARE == 3); it('resolves the first row', row(0) == range(0, 8)); it('resolves the last row', row(80) == range(72, 80)); it('resolves the first column', col(0) == range(0, 80, 9)); it('resolves the last column', col(80) == range(8, 80, 9)); done();
<?php echo form_open('admin/categorias/add', array('role' => 'form')); echo div(array('class' => 'form-group')); echo form_label('Título', 'title'); echo form_input(array('name' => 'title', 'value' => set_value('name'), 'class' => 'form-control')); echo form_error('title'); echo div(null, true); echo div(array('class' => 'form-group')); echo form_label('Descrição', 'description'); echo form_textarea(array('name' => 'description', 'class' => 'form-control')); echo div(null, true); echo row(); echo col(6); echo div(array('class' => 'form-group')); echo form_label('Categoria-pai', 'category_id'); echo form_dropdown('category_id', $options, '', null, 'form-control'); echo close_div(2); echo col(6); $options_view = array('Lista' => 'Lista', 'Mosaico' => 'Mosaico'); echo div(array('class' => 'form-group')); echo form_label('Tipo de visualização', 'view'); echo form_dropdown('view', $options_view, '', null, 'form-control'); echo close_div(3); echo form_button(array('type' => 'submit', 'name' => 'submit', 'content' => 'Cadastrar', 'class' => 'btn btn-primary')); echo ' '; echo anchor('admin/categorias', 'Cancelar', array('class' => 'btn btn-danger')); echo form_close(); ?> </div> </div> </section>
function match($pos) { return array_merge(col($pos), row($pos), block($pos)); }