first Card commit

This commit is contained in:
Alessandro Ferro 2022-02-26 01:34:21 +01:00
parent 4bacdff0de
commit cca8b678d5
6 changed files with 80 additions and 1 deletions

View File

@ -0,0 +1,24 @@
<html>
<head>
<title>Table example</title>
</head>
<body>
<?php
include "../phpxpress/card.php";
$card1 = new Card;
$card1->setImageSource("colosseum.jpg");
$card1->setTitle("Rome");
$card1->setSubTitle("Capital of Italy");
$card1->setInnerText("After the foundation by Romulus according to a legend, Rome was ruled for a period of 244 years by a monarchical system, initially with sovereigns of Latin and Sabine origin, later by Etruscan kings.");
$card1->draw();
$card2 = new Card;
$card2->setImageSource("paris.jpg");
$card2->setTitle("Paris");
$card2->setSubTitle("Capital of France");
$card2->setInnerText("The Parisii, a sub-tribe of the Celtic Senones, inhabited the Paris area from around the middle of the 3rd century BC.");
$card2->draw();
?>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -0,0 +1,49 @@
<?php
include "include.php";
class Card{
private $imageSource;
private $title;
private $subtitle;
private $innerText;
private $width = 18;
function setImageSource($imageSource){
if(!is_string($imageSource))
throw new InvalidArgumentException('Parameter imageSource must be a string.');
$this->imageSource = $imageSource;
}
function setTitle($title){
$this->title = $title;
}
function setSubTitle($subTitle){
$this->subtitle = $subTitle;
}
function setInnerText($innerText){
$this->innerText = $innerText;
}
function setWidth($width){
$this->width = $width;
}
function draw(){
echo '<div class="card" style="width: '.$this->width.'rem;">';
// Image
if(isset($this->imageSource)){
echo '<img class="card-img-top" src="'.$this->imageSource.'" alt="Card image cap">';
}
echo '<div class="card-body">';
echo '<h5 class="card-title">'. $this->title .'</h5>'; // title
echo '<h6 class="card-subtitle mb-2 text-muted">'. $this->subtitle .'</h6>'; // subtitle
echo '<p class="card-text">'. $this->innerText . '</p>';
echo '</div></div>';
}
}
?>

View File

@ -0,0 +1,6 @@
<?php
include "include.php";
class Carousel{
}
?>

View File

@ -1,5 +1,5 @@
<style> <style>
<?php <?php
include '../bootstrap-5.1.3-dist/css/bootstrap.min.css'; include_once '../bootstrap-5.1.3-dist/css/bootstrap.min.css';
?> ?>
</style> </style>