phpxpress/README.md

123 lines
3.2 KiB
Markdown
Raw Normal View History

2022-02-23 14:55:53 +01:00
# phpxpress
2022-02-26 17:31:18 +01:00
2022-07-30 18:49:31 +02:00
PhpXpress' goal is to create a simple way to programmatically manage Bootstrap elements.
2022-02-26 17:31:18 +01:00
It's similar to Microsoft's WebForms with a great layout by default (like DevExpress).
2022-07-24 22:51:57 +02:00
<noscript><a href="https://liberapay.com/xfarrow/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></noscript>
2022-02-26 17:31:18 +01:00
## Available components
* Table
* Card
2022-03-09 00:36:24 +01:00
* Breadcrumb
2022-03-17 09:34:56 +01:00
* Dropdown
2022-02-26 17:31:18 +01:00
2022-03-07 12:06:34 +01:00
## Examples
2022-02-26 17:31:18 +01:00
### Table
2022-02-23 14:55:53 +01:00
The following code
2022-03-07 12:06:34 +01:00
2022-09-29 10:59:40 +02:00
```php
2022-02-26 17:31:18 +01:00
$employees = array($employee1, $employee2, $employee3);
2022-02-23 14:55:53 +01:00
2022-07-30 18:49:31 +02:00
$table = new PhpXpress\Table;
2022-02-23 18:22:52 +01:00
$table->setDataSource($employees);
2022-09-29 11:00:39 +02:00
$table->setCustomCaptions(array("Name", "Surname", "Date of Birth", "Social Security Number")); //not required. If not specified it'll use objects' property names
2022-03-09 00:36:24 +01:00
$table->addColumn("Extra");
$table->onValueDisplaying("onValueDisplaying");
2022-02-23 18:22:52 +01:00
$table->setStripedRows(true);
$table->setBordered(true);
$table->setHoverAnimation(true);
$table->draw();
2022-03-09 00:36:24 +01:00
function onValueDisplaying($caption, &$value, $row){
if($caption == "ssn"){
2022-09-29 10:59:40 +02:00
if($row["ssn"] == "12345")
2022-05-12 10:22:54 +02:00
{
2022-09-29 10:59:40 +02:00
$value = $row["name"] . " " . $row["surname"] . " agreed to share their ssn (12345)" ;
2022-05-12 10:22:54 +02:00
}
else
{
2022-09-29 10:59:40 +02:00
$value = "SSN not shown for privacy reasons";
2022-05-12 10:22:54 +02:00
}
}
else if($caption == "Extra")
{
2022-03-09 00:36:24 +01:00
$value = "This column did not exist in the datasource";
2022-05-12 10:22:54 +02:00
}
2022-03-09 00:36:24 +01:00
}
2022-02-23 14:55:53 +01:00
```
2022-02-26 17:31:18 +01:00
produces the following output
2022-03-07 12:06:34 +01:00
2022-07-24 11:13:31 +02:00
<img src="/examples/images/demoTable.jpg" alt="Demo">
2022-02-26 17:31:18 +01:00
### Card
The follwing code
2022-03-07 12:06:34 +01:00
2022-09-29 10:59:40 +02:00
```php
2022-02-26 17:31:18 +01:00
Card::beginCardGroupLayout(36);
$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->setFooterText("Image By John");
$card1->addField("Mayor", "Roberto Gualtieri");
$card1->addField("Inhabitants", "2.763.804");
$card1->AddField("Zip", "001XX");
$card1->setButton("More info", "https://en.wikipedia.org/wiki/Rome");
$card1->draw();
class City{
2022-02-28 00:51:10 +01:00
public $Mayor;
2022-02-26 17:31:18 +01:00
public $Inhabitants;
public $Zip;
}
$paris = new City;
$paris->Mayor = "Anne Hidalgo";
$paris->Inhabitants = "2.229.095";
$paris->Zip = "750XX";
$card2 = new Card;
$card2->setImageSource("paris.jpg");
$card2->setTitle("Paris");
$card2->setSubTitle("Capital of France");
$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->draw();
Card::endCardGroupLayout();
```
produces the following output
2022-03-07 12:06:34 +01:00
2022-07-24 11:13:31 +02:00
<img src="/examples/images/card.jpg" alt="Demo">
2022-02-26 17:31:18 +01:00
$card2 receives a DataSource whereas $card1 does not.
2022-03-07 12:06:34 +01:00
### Breadcrumb
The follwing code
2022-09-29 10:59:40 +02:00
```php
2022-03-07 12:06:34 +01:00
$links["Github"] = "https://www.github.com";
$links["xfarrow"] = "https://www.github.com/xfarrow";
$links["PhpXpress"] = "https://www.github.com/xfarrow/phoxpress";
$breadcrumb = new BreadCrumb;
$breadcrumb->setDataSource($links);
$breadcrumb->draw();
```
Produces the following output:
2022-03-09 11:01:24 +01:00
2022-07-24 11:13:31 +02:00
<img src="/examples/images/breadcrumb.jpg" alt="Demo">