routeSQL : Actions can be wrote at the start or at the end of line

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1998 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-03-10 14:39:55 +00:00
parent 8773bb9058
commit 1b3e234e22

View File

@@ -17,6 +17,8 @@ class routeSQL
public $displayActions = true; public $displayActions = true;
/** Do a confirmation in javascript before deleting entry */ /** Do a confirmation in javascript before deleting entry */
public $deleteConfirm = true; public $deleteConfirm = true;
/** Push the actions buttons at end of line */
public $actionsAtEnd = false;
/** The model file containing the database description */ /** The model file containing the database description */
private $model_file = ""; private $model_file = "";
/** The model class included in the model file */ /** The model class included in the model file */
@@ -111,10 +113,12 @@ class routeSQL
dgettext("domframework","Add new entry")."</a>\n"; dgettext("domframework","Add new entry")."</a>\n";
$content .= "<table>\n"; $content .= "<table>\n";
$content .= " <thead>\n"; $content .= " <thead>\n";
if ($this->displayActions) if ($this->displayActions && $this->actionsAtEnd === false)
$content .= " <th>".dgettext("domframework","Actions")."</th>\n"; $content .= " <th>".dgettext("domframework","Actions")."</th>\n";
foreach ($titles as $title) foreach ($titles as $title)
$content .= " <th>".htmlentities ($title)."</th>\n"; $content .= " <th>".htmlentities ($title)."</th>\n";
if ($this->displayActions && $this->actionsAtEnd !== false)
$content .= " <th>".dgettext("domframework","Actions")."</th>\n";
$content .= " </thead>\n"; $content .= " </thead>\n";
$content .= " <tbody>\n"; $content .= " <tbody>\n";
if (count ($datas) === 0) if (count ($datas) === 0)
@@ -128,7 +132,7 @@ class routeSQL
foreach ($datas as $line) foreach ($datas as $line)
{ {
$content .= " <tr>"; $content .= " <tr>";
if ($this->displayActions) if ($this->displayActions && $this->actionsAtEnd === false)
{ {
$content .= "<td>"; $content .= "<td>";
$content .= " <a href='".$route->baseURL().$this->url_prefix."/". $content .= " <a href='".$route->baseURL().$this->url_prefix."/".
@@ -146,6 +150,22 @@ class routeSQL
} }
foreach ($line as $col) foreach ($line as $col)
$content .= "<td>".htmlentities ($col)."</td>"; $content .= "<td>".htmlentities ($col)."</td>";
if ($this->displayActions && $this->actionsAtEnd !== false)
{
$content .= "<td>";
$content .= " <a href='".$route->baseURL().$this->url_prefix."/".
$line[$this->objectDB->primary]."'>".
dgettext("domframework","Edit")."</a>";
$content .= " <a href='".$route->baseURL().$this->url_prefix."/".
$line[$this->objectDB->primary]."/delete/$token'";
if ($this->deleteConfirm)
$content .= " onclick=\"return confirm('".
dgettext("domframework",
"Are you sure to delete this entry?")."')\"";
$content .= ">".
dgettext("domframework","Delete")."</a>";
$content .= "</td>";
}
$content .= "</tr>\n"; $content .= "</tr>\n";
} }
} }