Ejemplo n.º 1
0
 public function testLoop()
 {
     $wp_query = $this->getMockBuilder('mock_wp_query')->setMockClassName('WP_Query')->setMethods(array('have_posts', 'the_post'))->getMock();
     $cars = new Cars();
     $loop = $cars->get_loop('test');
     $this->assertTrue(get_class($loop) == 'WP_Query');
 }
Ejemplo n.º 2
0
 public function listmarkiAction()
 {
     $Cars = new Cars();
     $this->Cars = $Cars;
     $this->view->data = $Cars->getMarki();
     $this->view->display('marki');
 }
Ejemplo n.º 3
0
 public function action_index()
 {
     $record = new Cars();
     $record->parent_id = $_POST['parent_id'];
     $record->text = $_POST['text'];
     $record->leaf = $_POST['leaf'];
     $record->save();
     $array = array('success' => 'true', 'msg' => 'Record added successfully');
     $json = json_encode($array);
     return $json;
 }
Ejemplo n.º 4
0
 public function action_index()
 {
     $record = new Cars();
     $record->manufacturer = $_POST['manufacturer'];
     $record->model = $_POST['model'];
     $record->year = $_POST['year'];
     $record->save();
     $array = array('success' => 'true', 'msg' => 'Record added successfully');
     $json = json_encode($array);
     return $json;
 }
 static function display()
 {
     /* The 'parent' keyword references the class that 
     		the current class is extending. It can be used to 
     		call upon a parent class's methods or properties. */
     echo parent::car_detail();
 }
Ejemplo n.º 6
0
 public function editAction()
 {
     $Car = new Cars();
     $this->view->data = $Car->getCategory();
     $new_model = $this->request->getPost('model');
     $new_marka = $this->request->getPost('marka_id');
     $new_opis = $this->request->getPost('opis');
     $id = $this->request->getPost('id');
     $is_photo = $this->request->getFiles('zdjecie');
     if ($new_model == NULL && $new_marka == NULL && $new_opis == NULL && $is_photo == NULL) {
         $this->view->display('edit');
     } else {
         $Car->updateCar($new_model, $new_marka, $new_opis, $is_photo, $id);
         header('location:' . Url::getUrl('car', 'list', array('status' => 6)));
     }
 }
Ejemplo n.º 7
0
 /**
  * @param $cars
  * @depends testArrayApply
  */
 public function testDtoApply($cars)
 {
     $model = Cars::make($cars);
     $this->assertEquals(count($this->data), count($model->toArray()));
     foreach ($this->data as $key => $value) {
         $this->assertEquals($value, $model->toArray()[Str::camel($key)]);
     }
 }
Ejemplo n.º 8
0
 public function __toString()
 {
     $data = parent::__toString();
     $data .= '<li> Batery: ' . $this->getBattery() . "</li>\n";
     $data .= '<li> Max speed: ' . $this->getMaxSpeed() . "</li>\n";
     $data .= '<li> Distance: ' . $this->getDistance() . "</li>\n";
     return $data;
 }
Ejemplo n.º 9
0
 public function put_index()
 {
     $data = file_get_contents('php://input');
     $temp = json_decode($data);
     $new = Cars::find($temp->id);
     $new->text = $temp->text;
     $new->parent_id = $temp->parentId;
     $new->save();
     $array = array('success' => 'true');
     $json = json_encode($array);
     return $json;
 }
Ejemplo n.º 10
0
 public function updateAutoAction()
 {
     $Cars = new Cars();
     $post = $this->request->getPost();
     if (isset($post['nazwaAuta'])) {
         $image = $this->request->getFiles('zdjecie');
         $config = Config::getInstance();
         $config = $config->getConfig();
         $plik = uniqid();
         if ($image['error'] == 0) {
             $e = pathinfo($image['name']);
             $extension = $e['extension'];
             $img = WideImage::load($image['tmp_name']);
             $resized = $img->resize(100, 100);
             $resized->saveToFile($config['IMG_DIR'] . '/small_' . $plik . '.' . $extension);
             move_uploaded_file($image['tmp_name'], $config['IMG_DIR'] . $plik . '.' . $extension);
             $post['zdjecie'] = $plik . '.' . $extension;
         }
         $Cars->editSamochody($post);
     }
     header('Location:' . Url::getUrl('cars', 'list'));
 }
Ejemplo n.º 11
0
 public function put_index()
 {
     $data = file_get_contents('php://input');
     $temp = json_decode($data);
     $new = Cars::find($temp->id);
     $new->id = $temp->id;
     $new->manufacturer = $temp->manufacturer;
     $new->model = $temp->model;
     $new->year = $temp->year;
     $new->save();
     $array = array('success' => 'true');
     $json = json_encode($array);
     return $json;
 }
in a private modifier, allowing you more control over
information.
*/
class Cars
{
    private $door_count = 4;
    function get_values()
    {
        echo $this->door_count;
    }
    function set_values()
    {
        $this->door_count = 10;
    }
}
$bmw = new Cars();
/*
The private property, $door_count, can only be accessed
within the class. Echoing it outside of the class would
not work.

However, by using the get_values()
method (which is located within the class), you can call on
the private property.
*/
$bmw->set_values();
$bmw->get_values();
/* 
If you were to JUST call upon the get_values() method, the
browser would return the value, 4, as it is defined.
Ejemplo n.º 13
0
<?php

class Cars
{
    var $wheel_count = 4;
    var $door_count = 4;
    public function car_Detail()
    {
        return "This car has " . $this->wheel_count . " wheels.";
    }
}
$bmw = new Cars();
$mercedes = new Cars();
echo $bmw->wheel_count . "<br>";
echo $mercedes->wheel_count = 10;
echo $mercedes->car_Detail();
echo $bmw->car_Detail();
Ejemplo n.º 14
0
 /**
  * @param mixed $car
  */
 public function buyCar(Cars $car)
 {
     $price = $car->getPrice();
     if ($this->money >= $price) {
         $this->car = $car;
         $this->money -= $price;
         $car->setOwner($this);
         echo 'You heve a new car', PHP_EOL;
         return true;
     } else {
         echo 'You don\'t have enough money';
         return false;
     }
 }
Ejemplo n.º 15
0
<?php

include_once '../../config/Config.php';
include_once '../../src/Cars.php';
$cars = new Cars(new Config());
$foto = $cars->searchFoto(11);
if (!$foto) {
    ?>
                    
<div>
    <span class="col-xs-12 col-sm-2">
        <img alt="Project Image" src="img/default.png" class="img-responsive">
    </span>
</div>
                
<?php 
} else {
    foreach ($foto as $fotos) {
        $foto_princ = $fotos['local'];
        ?>
                    
<div>
    <span class="col-xs-12 col-sm-2">
        <img alt="Project Image" src="<?php 
        echo $foto_princ;
        ?>
" class="img-responsive">
    </span>
</div>
                
<?php 
Ejemplo n.º 16
0
<?php

class Cars
{
    private $wheels = 4;
    function get_values()
    {
        echo $this->wheels;
    }
    function set_values()
    {
        $this->wheels = 10;
    }
}
$bmw = new Cars();
$bmw->get_values();
Ejemplo n.º 17
0
 public function editAction($id)
 {
     $id = $this->filter->sanitize($id, 'int');
     $car = Cars::findFirst($id);
     $this->view->form = new SellForm($car);
 }
    public $wheel_count = 4;
    static $door_count = 4;
    /*
    Unlike a normal method, using '__construct' will output the
    method automatically WITHOUT requiring you to call upon it,
    so long as an object of that class exists ($bmw in this case).
    */
    function __construct()
    {
        //echo $this->wheel_count;
        echo self::$door_count++;
    }
    /* The '__destruct' method is used a lot less than the 
    construct method. */
    function __destruct()
    {
        echo self::$door_count--;
    }
    function details()
    {
        echo $this->wheel_count;
    }
}
$bmw = new Cars();
$bmw->details();
/*
A regular method requires you to call upon it. A __construct
method only requires an instance of that class to exist ($bmw).
*/
$mercedes = new Cars();
$mercedes_2 = new Cars();
Ejemplo n.º 19
0
<?php

class Cars
{
    public function welcome()
    {
        echo "welcome!";
    }
}
$bmw = new Cars();
$mercedes = new Cars();
$bmw->welcome();
Ejemplo n.º 20
0
 static function display()
 {
     echo parent::car_Detail();
 }
 public function loadCarModel($id)
 {
     $model = Cars::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function saveCar()
 {
     $carId = Input::get('car_id');
     $name = Input::get('name');
     $brand = Input::get('brand');
     $model = Input::get('model');
     $registration = Input::get('registration');
     $policeNumber = Input::get('police_number');
     $uberNumber = Input::get('uber_number');
     try {
         $car = Cars::find($carId);
         $car->name = $name;
         $car->brand = $brand;
         $car->model = $model;
         $car->registration = $registration;
         $car->police_number = $policeNumber;
         $car->uber_number = $uberNumber;
         $car->save();
         $result = array('success' => true);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
         $result = array('success' => false);
     }
     return $result;
 }
Ejemplo n.º 23
0
 public static function getCustomerCar($id)
 {
     return CHtml::textField(Cars::model()->findByPk($id), 'id', 'licenseNumber');
 }
Ejemplo n.º 24
0
    echo ". ";
    $obj1->canFly();
    echo ". Max Passengers: ";
    echo $obj1->maxPassengers();
    echo ".";
    echo "<br>";
    $i = $i + 1;
}
echo "<br><br><br>";
echo "<form action=\"index.php\" method=\"GET\">\n        Choose a vehicle:<br>\n        <input type=\"radio\" name=\"vehicle\" value=\"1\" checked>Plane<br>\n        <input type=\"radio\" name=\"vehicle\" value=\"2\">Car<br>\n        <input type=\"radio\" name=\"vehicle\" value=\"3\">Bike<br>\n        Choose minutes: <br>\n        <input type=\"text\" name=\"hours\" size=\"15\" value=\"1\"><br>\n        <input type=\"submit\" value=\"Calculate Distance\">\n        </form>\n    ";
if (empty($_GET['vehicle'])) {
    $vehicle = "";
} else {
    $vehicle = $_GET['vehicle'];
}
if ($vehicle == "1") {
    $nobj1 = new Planes();
    $maxspeed = $nobj1->speed();
    $resultado = $maxspeed * $nobj1->distance() / 60;
    echo "<div style=\"color:#FF0404; background-color:#EEBE3D; width:250px; border: solid; padding:4px;    \" class=\"alert alert-danger\">\n        You can travel " . $resultado . "Km. in " . $nobj1->distance() . " minutes if you choose a Plane. </div>";
} elseif ($vehicle == "2") {
    $nobj1 = new Cars();
    $maxspeed = $nobj1->speed();
    $resultado = $maxspeed * $nobj1->distance() / 60;
    echo "<div style=\"color:#FF0404; background-color:#EEBE3D; width:250px; border: solid; padding:4px;    \" class=\"alert alert-danger\">\n        You can travel " . $resultado . "Km. in " . $nobj1->distance() . " minutes if you choose a Car. </div>";
} elseif ($vehicle == "3") {
    $nobj1 = new Bikes();
    $maxspeed = $nobj1->speed();
    $resultado = $maxspeed * $nobj1->distance() / 60;
    echo "<div style=\"color:#FF0404; background-color:#EEBE3D; width:250px; border: solid; padding:4px;    \" class=\"alert alert-danger\">\n        You can travel " . $resultado . "Km. in " . $nobj1->distance() . " minutes if you choose a Bike. </div>";
}
Ejemplo n.º 25
0
 public function wyswietlKategorieAction()
 {
     $id = $this->request->getParam('id');
     $Cars = new Cars();
     $this->view->data = $Cars->getKategorieAuta($id);
     $this->view->display('auta');
 }
Ejemplo n.º 26
0
<?php

class Cars
{
    // Properties - Access Control Modifiers
    /* Access modifiers are not used for privacy's sake
    	but instead to achieve better control of variables
    	throughout a document */
    /* public property can be used throughout the whole 
    program */
    public $wheel_count = 4;
    /* private property can be used within the class it's
     defined */
    private $door_count = 4;
    /* protected property is only available inside it's 
    class or subclass (extends '...') */
    protected $seat_count = '2';
    function car_detail()
    {
        echo $this->wheel_count;
        echo $this->door_count;
        echo $this->seat_count;
    }
}
$bmw = new Cars();
$bmw->car_detail();
Ejemplo n.º 27
0
 public function cadastraIMG($nome)
 {
     $cars = new Cars(new Config());
     $carros = $cars->readAllCars();
     if (count($carros) == 0) {
         $id = 1;
         //$cars->cadastrarFoto($nome, $id);
     } else {
         //$cars->cadastrarFoto($nome);
     }
 }
Ejemplo n.º 28
0
 public function indexAction()
 {
     $this->view->cars = Cars::find(array("order" => "ID DESC"));
 }
    // property
    static $wheel_count = 4;
    static $door_count = 4;
    // methods
    static function car_detail()
    {
        /*
        With a static function, you do not use the "$this"
        pseudo-variable because you are not using an
        instance. You format the properties the same way
        you would with a static property.
        */
        echo Cars::$wheel_count;
        echo Cars::$door_count;
    }
}
$bmw = new Cars();
/*
echo $bmw->door_count;
echo $bmw->wheel_count;
*/
// Browser sees these static properties as undefined
// because they're being called with an instance.
echo Cars::$door_count;
/* To call a static property, use the class name
followed by two colons ( : ) and the property name, after
a dollar sign ( $ ). */
Cars::car_detail();
/* To call a static function, use the class name followed
by two colons and the function name WITHOUT a dollar sign.
*/
Ejemplo n.º 30
0
 */
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'orders-form', 'enableAjaxValidation' => false, 'enableClientValidation' => true, 'clientOptions' => array('validateOnSubmit' => true), 'htmlOptions' => array('class' => 'well')));
?>

	<p class="note">
		带<span class="required">*</span>为必填项
	</p>

	<?php 
echo $form->errorSummary($model);
?>
    <!-- when update should use [Yii::app()->user->id]-->
    
    
	<?php 
echo $form->dropDownListRow($model, 'car_id', Cars::getCustomerCars(isset($type) ? Yii::app()->user->id : ''), array('class' => 'span4'));
?>

	<?php 
//echo $form->textField($model,'car_id',array('class' => 'span4'));
?>
	
	<?php 
echo $form->textFieldRow($model, 'date', array('class' => 'span4 datepicker'));
?>
	
	<?php 
echo $form->dropDownListRow($model, 'time', array('AM' => '上午', 'PM' => '下午'), array('class' => 'span4'));
?>
	
	<?php