diff --git a/phpxpress/examples/card.php b/phpxpress/examples/card.php index 5fad89f..2d435ab 100644 --- a/phpxpress/examples/card.php +++ b/phpxpress/examples/card.php @@ -1,6 +1,6 @@ - Table example + Card example setImageSource("colosseum.jpg"); $card1->setTitle("Rome"); @@ -18,8 +20,13 @@ $card1->addField("Inhabitants", "2.763.804"); $card1->AddField("Zip", "001XX"); $card1->setButton("More info", "https://en.wikipedia.org/wiki/Rome"); + $card1->addLink("Town", "https://www.comune.roma.it/web/it/welcome.page"); + $card1->addLink("ATAC", "https://www.atac.roma.it/"); $card1->draw(); + + // Paris + class City{ public $Mayor; public $Inhabitants; @@ -38,6 +45,10 @@ $card2->setInnerText("The following fields' name & data will be acquired by the datasource."); $card2->setDataSource($paris); $card2->setButton("More info", "https://en.wikipedia.org/wiki/Paris"); + $card2->addArrayList(array("this is", "just a list")); + $card2->addElementList("of various sentences"); + $card2->addLink("Link1", "#"); + $card2->addLink("Link2", "#"); $card2->draw(); Card::endCardGroupLayout(); diff --git a/phpxpress/phpxpress/card.php b/phpxpress/phpxpress/card.php index e4ab908..32761d0 100644 --- a/phpxpress/phpxpress/card.php +++ b/phpxpress/phpxpress/card.php @@ -9,7 +9,24 @@ private $width = 18; private $footerText; private $fieldsArray; + private $list; + private $linksArray; private $button; + private $borderColor; + private $cardColor; + private $textColor; + + function setBorderColor($color){ + $this->borderColor = Code::bootstrapColors($color); + } + + function setCardColor($color){ + $this->cardColor = Code::bootstrapColors($color); + } + + function setTextColor($color){ + $this->textColor = $color; + } function setImageSource($imageSource){ if(!is_string($imageSource)) @@ -56,8 +73,41 @@ } } + function addLink($caption, $link){ + $this->linksArray[$caption] = $link; + } + + function addArrayList(Array $list){ + if(isset($this->list)){ + $this->list = array_merge($this->list, $list); + }else{ + $this->list = $list; + } + } + + function addElementList($element){ + if(isset($this->list)){ + array_push($this->list, $element); + }else{ + $list = array($element); + } + } + function draw(){ - echo '
'; + + $class = "card"; + + if(isset($this->borderColor)){ + $class.= ' border-' . $this->borderColor; + } + if(isset($this->cardColor)){ + $class.= ' bg-' . $this->cardColor; + } + if(isset($this->textColor)){ + $class.= ' text-' . $this->borderColor; + } + + echo '
'; // Image if(isset($this->imageSource)){ @@ -75,6 +125,23 @@ } } + if(isset($this->list)){ + echo '
'; // close card-body div + echo ''; + echo '
'; + } + + if(isset($this->linksArray)){ // links + foreach($this->linksArray as $caption => $link){ + echo ''. $caption .''; + } + echo '

'; + } + if(isset($this->button)) echo '' . $this->button["text"] . ''; diff --git a/phpxpress/phpxpress/code.php b/phpxpress/phpxpress/code.php new file mode 100644 index 0000000..fdd5f69 --- /dev/null +++ b/phpxpress/phpxpress/code.php @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/phpxpress/phpxpress/include.php b/phpxpress/phpxpress/include.php index 46a837e..fda2f47 100644 --- a/phpxpress/phpxpress/include.php +++ b/phpxpress/phpxpress/include.php @@ -1,5 +1,8 @@ + \ No newline at end of file