public function create()
 {
     $obj = new Color($this->db);
     echo json_encode($obj->add($this->f3->get("POST.postdata")));
 }
Esempio n. 2
0
<?php

require_once 'Color.class.php';
//print( Color::doc() );
Color::$verbose = True;
$red = new Color(array('red' => 0xff, 'green' => 0, 'blue' => 0));
$green = new Color(array('rgb' => 255 << 8));
$blue = new Color(array('red' => 0, 'green' => 0, 'blue' => 0xff));
$yellow = $red->add($green);
$cyan = $green->add($blue);
$magenta = $blue->add($red);
$white = $red->add($green)->add($blue);
print $red . PHP_EOL;
print $green . PHP_EOL;
print $blue . PHP_EOL;
print $yellow . PHP_EOL;
print $cyan . PHP_EOL;
print $magenta . PHP_EOL;
print $white . PHP_EOL;
Color::$verbose = False;
$black = $white->sub($red)->sub($green)->sub($blue);
print 'Black: ' . $black . PHP_EOL;
Color::$verbose = True;
$darkgrey = new Color(array('rgb' => (10 << 16) + (10 << 8) + 10));
print 'darkgrey: ' . $darkgrey . PHP_EOL;
$lightgrey = $darkgrey->mult(22.5);
print 'lightgrey: ' . $lightgrey . PHP_EOL;
$random = new Color(array('red' => 12.3, 'green' => 31.2, 'blue' => 23.1));
print 'random: ' . $random . PHP_EOL;
Esempio n. 3
0
<?php

if (Tools::P('saveColor') == 'add') {
    $color = new Color();
    $color->copyFromPost();
    $color->add();
    if (is_array($color->_errors) and count($color->_errors) > 0) {
        $errors = $color->_errors;
    } else {
        $_GET['id'] = $color->id;
        UIAdminAlerts::conf('创建对象成功');
    }
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $obj = new Color($id);
}
if (Tools::P('saveColor') == 'edit') {
    if (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        UIAdminAlerts::conf('更新对象成功');
    }
}
$colors = Color::getEntitys();
if (isset($errors)) {
    UIAdminAlerts::MError($errors);