routeSQL : Allow the user to define which Area is write in each bar (top or bottom) and left or right

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2014 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-03-11 21:41:37 +00:00
parent 3e72a3189c
commit 6938ce0a75

View File

@@ -25,6 +25,18 @@ class routeSQL
public $textEdit = "";
/** enable internal CSS */
public $enableInternalCSS = true;
/** Definition of the position in top bar at left
Allowed : addNew numberEntryByDisplay search informations paginator */
public $topBarLeft = array ("addNew", "numberEntryByDisplay");
/** Definition of the position in top bar at right
Allowed : addNew numberEntryByDisplay search informations paginator */
public $topBarRight = array ("search");
/** Definition of the position in bottom bar at left
Allowed : addNew numberEntryByDisplay search informations paginator */
public $bottomBarLeft = array ("informations");
/** Definition of the position in bottom bar at right
Allowed : addNew numberEntryByDisplay search informations paginator */
public $bottomBarRight = array ("paginator");
/** The cookie path used to determine the old parameters
It is automatically generated with the URL */
public $path = "";
@@ -110,13 +122,13 @@ class routeSQL
$nbentries is the total number of elements
num is the number of elements displayed by page
page is the page to display */
private function paginator ($nbentries, $page, $num, $search)
private function paginatorArea ($nbentries, $page, $num, $search)
{
// The maximum of links available in the paginator
$maxClickPaginator = 10;
$prePage = false;
$postPage = false;
$content = " <div class='paginator'>\n";
$content = " <div class='paginatorArea'>\n";
$displayedNumbers = 0;
for ($i = 1 ; $i < (1+$nbentries/($num)) ; $i++)
{
@@ -157,7 +169,7 @@ class routeSQL
/** Display the actions buttons outside of the table (actually, juste the
'Add new entry' button */
private function externalActions ()
private function addNewArea ($nbentries, $page, $num, $search)
{
$content = "";
if ($this->displayActions)
@@ -172,11 +184,11 @@ class routeSQL
}
/** Display the select list to choose the number of displayed entries */
private function listNumberDisplayedEntries ($num)
private function numberEntryByDisplayArea ($nbentries, $page, $num, $search)
{
$route = new route ();
$content = "";
$content .= " <div class='listNumberDisplayedEntries'>\n";
$content .= " <div class='numberEntryByDisplayArea'>\n";
$content .= " <form method='get' action='".$route->baseURL().
$this->url_prefix."'>\n";
$content .= " <select name='num' onchange='this.form.submit()' >\n";
@@ -196,7 +208,7 @@ class routeSQL
}
/** Display the search area */
public function searchArea ($search)
public function searchArea ($nbentries, $page, $num, $search)
{
$route = new route ();
$content = "";
@@ -284,7 +296,7 @@ class routeSQL
$criteria[] = array ($column, "%$search%", "LIKE");
$datas = $this->objectDB->read ($criteria, null, null, true);
}
$count = count ($datas);
$nbentries = count ($datas);
if ($num > 1000)
$route->redirect ("/".$this->url_prefix.
"?page=$page&num=1000&search=$search", "");
@@ -292,9 +304,9 @@ class routeSQL
$route->redirect ("/".$this->url_prefix.
"?page=1&num=$num&search=$search", "");
// Push on the last page if the values are too high
if ($count > 0 && ($page-1)*$num > $count)
if ($nbentries > 0 && ($page-1)*$num > $nbentries)
{
$maxPage = intval ($count/$num)+1;
$maxPage = intval ($nbentries/$num)+1;
$route->redirect ("/".$this->url_prefix.
"?page=$maxPage&num=$num&search=$search", "");
}
@@ -314,14 +326,14 @@ class routeSQL
$content .= ".routeSQL .bottomBar .bottomleft { display: inline; float:left; }\n";
$content .= ".routeSQL .bottomBar .bottomright { display: inline; float:right; }\n";
$content .= ".routeSQL .actionExtern { border:1px solid #ddd; border-radius:5px; padding:10px; margin:3px; float:left; }\n";
$content .= ".routeSQL .listNumberDisplayedEntries { border:1px solid #ddd; border-radius:5px; padding:10px; margin:3px; float:left; }\n";
$content .= ".routeSQL .numberEntryByDisplayArea { border:1px solid #ddd; border-radius:5px; padding:10px; margin:3px; float:left; }\n";
$content .= ".routeSQL .searchArea { border:1px solid #ddd; border-radius:5px; padding:10px; margin:3px; float:left; }\n";
$content .= ".routeSQL .searchArea form { margin:-1px; }\n";
$content .= ".routeSQL .listNumberDisplayedEntries form { margin:-3px; }\n";
$content .= ".routeSQL .numberEntryByDisplayArea form { margin:-3px; }\n";
$content .= ".routeSQL .informationsArea { border:1px solid #ddd; border-radius:5px; padding:10px; margin:3px; float:left; }\n";
$content .= ".routeSQL .paginator { border:1px solid #ddd; border-radius:5px; padding:10px; margin:3px; float:left; }\n";
$content .= ".routeSQL .paginator a { border:1px solid grey; border-radius:5px; padding:3px; }\n";
$content .= ".routeSQL .paginator .selected { background-color:#04d; color:white;font-weight:bold; }\n";
$content .= ".routeSQL .paginatorArea { border:1px solid #ddd; border-radius:5px; padding:10px; margin:3px; float:left; }\n";
$content .= ".routeSQL .paginatorArea a { border:1px solid grey; border-radius:5px; padding:3px; }\n";
$content .= ".routeSQL .paginatorArea .selected { background-color:#04d; color:white;font-weight:bold; }\n";
$content .= ".routeSQL table { width:100%;overflow:auto; border-collapse:collapse; }\n";
$content .= ".routeSQL table tr { border-top:1px solid #ccc;}\n";
$content .= ".routeSQL table th { border-bottom:3px solid #ccc; border-top:1px solid #fff; padding:9px 5px 9px 1px; }\n";
@@ -337,11 +349,18 @@ class routeSQL
$content .= $this->showflash ();
$content .= " <div class='topBar'>\n";
$content .= " <div class='topleft'>\n";
$content .= $this->externalActions ();
$content .= $this->listNumberDisplayedEntries ($num);
foreach ($this->topBarLeft as $area)
{
$areaName = $area."Area";
$content .= $this->$areaName ($nbentries, $page, $num, $search);
}
$content .= " </div>\n";
$content .= " <div class='topright'>\n";
$content .= $this->searchArea ($search);
foreach ($this->topBarRight as $area)
{
$areaName = $area."Area";
$content .= $this->$areaName ($nbentries, $page, $num, $search);
}
$content .= " </div>\n";
$content .= " </div>\n"; // End of topBar
$content .= " <table>\n";
@@ -356,7 +375,7 @@ class routeSQL
$content .= " </tr>\n";
$content .= " </thead>\n";
$content .= " <tbody>\n";
if ($count === 0)
if ($nbentries === 0)
{
// Add one column more for actions
$countTitles = count($titles);
@@ -413,10 +432,18 @@ class routeSQL
$content .= " </table>\n";
$content .= " <div class='bottomBar'>\n";
$content .= " <div class='bottomleft'>\n";
$content .= $this->informationsArea ($count, $page, $num, $search);
foreach ($this->bottomBarLeft as $area)
{
$areaName = $area."Area";
$content .= $this->$areaName ($nbentries, $page, $num, $search);
}
$content .= " </div>\n";
$content .= " <div class='bottomright'>\n";
$content .= $this->paginator($count, $page, $num, $search);
foreach ($this->bottomBarRight as $area)
{
$areaName = $area."Area";
$content .= $this->$areaName ($nbentries, $page, $num, $search);
}
$content .= " </div>\n";
$content .= " </div>\n"; // End of bottomBar
$content .= "</div>\n";