Added feature #5466: Page selector for the list module
authorFrancois Suter <francois.suter@typo3.org>
Fri, 6 Mar 2009 18:46:47 +0000 (18:46 +0000)
committerFrancois Suter <francois.suter@typo3.org>
Fri, 6 Mar 2009 18:46:47 +0000 (18:46 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5132 709f56b5-9817-0410-a4d7-c38de5d9e867

22 files changed:
ChangeLog
typo3/class.db_list_extra.inc
typo3/gfx/control_first.gif [new file with mode: 0644]
typo3/gfx/control_first_disabled.gif [new file with mode: 0644]
typo3/gfx/control_last.gif [new file with mode: 0644]
typo3/gfx/control_last_disabled.gif [new file with mode: 0644]
typo3/gfx/control_next.gif [new file with mode: 0644]
typo3/gfx/control_next_disabled.gif [new file with mode: 0644]
typo3/gfx/control_previous.gif [new file with mode: 0644]
typo3/gfx/control_previous_disabled.gif [new file with mode: 0644]
typo3/stylesheet.css
typo3/sysext/lang/locallang_common.xml
typo3/sysext/lang/locallang_mod_web_list.xml
typo3/sysext/t3skin/icons/gfx/control_first.gif [new file with mode: 0644]
typo3/sysext/t3skin/icons/gfx/control_first_disabled.gif [new file with mode: 0644]
typo3/sysext/t3skin/icons/gfx/control_last.gif [new file with mode: 0644]
typo3/sysext/t3skin/icons/gfx/control_last_disabled.gif [new file with mode: 0644]
typo3/sysext/t3skin/icons/gfx/control_next.gif [new file with mode: 0644]
typo3/sysext/t3skin/icons/gfx/control_next_disabled.gif [new file with mode: 0644]
typo3/sysext/t3skin/icons/gfx/control_previous.gif [new file with mode: 0644]
typo3/sysext/t3skin/icons/gfx/control_previous_disabled.gif [new file with mode: 0644]
typo3/sysext/t3skin/stylesheets/typo3-db-list-php.css

index 05adb8a..f735be5 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-06  Francois Suter  <francois@typo3.org>
+
+       * Added feature #5466: Page selector for the list module (thanks to Christian Kuhn and Dmitry Pikhno)
+
 2009-03-06  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #10610: htmlArea RTE: Two errors in class.tx_rtehtmlarea_acronym.php (Thanks to Ursula Renziehausen).
index 833642e..31bf19d 100755 (executable)
@@ -520,14 +520,10 @@ class localRecordList extends recordList {
 
                                $iOut = '';
                                $cc = 0;
-                               foreach($accRows as $row)       {
-
-                                               // Forward/Backwards navigation links:
-                                       list($flag,$code) = $this->fwd_rwd_nav($table);
-                                       $iOut.=$code;
 
-                                               // If render item, increment counter and call function
-                                       if ($flag)      {
+                               foreach($accRows as $row)       {
+                                       // Render item row if counter < limit
+                                       if ($cc < $this->iLimit) {
                                                $cc++;
                                                $iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
 
@@ -564,6 +560,12 @@ class localRecordList extends recordList {
                                        $this->eCounter++;
                                }
 
+                               // Record navigation is added to the beginning and end of the table if in single table mode
+                               if ($this->table) {
+                                       $pageNavigation = $this->renderListNavigation();
+                                       $iOut = $pageNavigation . $iOut . $pageNavigation;
+                               }
+
                                        // The header row for the table is now created:
                                $out.=$this->renderListHeader($table,$currentIdList);
                        }
@@ -892,6 +894,138 @@ class localRecordList extends recordList {
                return $this->addelement(1, $icon, $theData, ' class="c-headLine"', '');
        }
 
+       /**
+        * Creates a page browser for tables with many records
+        *
+        * @return      string  Navigation HTML
+        *
+        * @author      Dmitry Pikhno <dpi@goldenplanet.com>
+        * @author      Christian Kuhn <lolli@schwarzbu.ch>
+        */
+       protected function renderListNavigation() {
+               $totalPages = ceil($this->totalItems / $this->iLimit);
+
+               $content = '';
+
+                       // Show page selector if not all records fit into one page
+               if ($totalPages > 1) {
+                       $first = $previous = $next = $last = $reload = '';
+                       $listURL = $this->listURL('', $this->table);
+
+                               // 1 = first page
+                       $currentPage = floor(($this->firstElementNumber + 1) / $this->iLimit) + 1;
+
+                               // Compile first, previous, next, last and refresh buttons
+                       if ($currentPage > 1) {
+                               $labelFirst = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:first');
+
+                               $first = '<a href="' . $listURL . '&pointer=0">
+                                       <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_first.gif')
+                                       . 'alt="' . $labelFirst . '" title="' . $labelFirst . '" />
+                               </a>';
+                       } else {
+                               $first = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_first_disabled.gif') . 'alt="" title="" />';
+                       }
+
+                       if (($currentPage - 1) > 0) {
+                               $labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:previous');
+
+                               $previous = '<a href="' . $listURL . '&pointer=' . (($currentPage - 2) * $this->iLimit) . '">
+                                       <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_previous.gif')
+                                       . 'alt="' . $labelPrevious . '" title="' . $labelPrevious . '" />
+                                       </a>';
+                       } else {
+                               $previous = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_previous_disabled.gif') . 'alt="" title="" />';
+                       }
+
+                       if (($currentPage + 1) <= $totalPages) {
+                               $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
+
+                               $next = '<a href="' . $listURL . '&pointer=' . (($currentPage) * $this->iLimit) . '">
+                                       <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_next.gif')
+                                       . 'alt="' . $labelNext . '" title="' . $labelNext . '" />
+                                       </a>';
+                       } else {
+                               $next = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_next_disabled.gif') . 'alt="" title="" />';
+                       }
+
+                       if ($currentPage != $totalPages) {
+                               $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
+
+                               $last = '<a href="' . $listURL . '&pointer=' . (($totalPages - 1) * $this->iLimit) . '">
+                                       <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_last.gif')
+                                       . 'alt="' . $labelLast . '" title="' . $labelLast . '" />
+                                       </a>';
+                       } else {
+                               $last = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/control_last_disabled.gif') . 'alt="" title="" />';
+                       }
+
+                       $reload = '<a href="#" onclick="document.dblistForm.action=\''
+                               . $listURL . '&pointer=\'+calculatePointer(); document.dblistForm.submit(); return true;">
+                               <img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/refresh_n.gif')
+                               . 'alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:reload')
+                               . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:reload')
+                               . '" /></a>';
+
+                       // Add js to traverse a page select input to a pointer value
+                       $content = '
+<script type="text/JavaScript">
+/*<![CDATA[*/
+
+       function calculatePointer(){
+               page = document.getElementById(\'jumpPage\').value;
+
+               if (page > ' . $totalPages . ') {
+                       page = ' . $totalPages . ';
+               }
+
+               if (page < 1) {
+                       page = 1;
+               }
+
+               pointer = (page - 1) * ' . $this->iLimit . ';
+
+               return pointer;
+       }
+
+/*]]>*/
+</script>
+';
+
+                       $pageNumberInput = '<span>
+                               <input type="text" value="' . $currentPage
+                               . '" size="3" id="jumpPage" name="jumpPage" onkeyup="if (event.keyCode == Event.KEY_RETURN) { document.dblistForm.action=\'' . $listURL . '&pointer=\'+calculatePointer(); document.dblistForm.submit(); } return true;" />
+                               </span>';
+                       $pageIndicator = '<span class="pageIndicator">'
+                               . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages)
+                               . '</span>';
+
+                       if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) {
+                               $lastElementNumber = $this->firstElementNumber + $this->iLimit;
+                       } else {
+                               $lastElementNumber = $this->totalItems;
+                       }
+                       $rangeIndicator = '<span class="pageIndicator">'
+                               . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $this->firstElementNumber + 1, $lastElementNumber)
+                               . '</span>';
+
+                       $content .= '<div id="typo3-dblist-pagination">'
+                               . $first . $previous  
+                               . '<span class="bar">&nbsp;</span>'
+                               . $rangeIndicator . '<span class="bar">&nbsp;</span>'
+                               . $pageIndicator . '<span class="bar">&nbsp;</span>'
+                               . $next . $last . '<span class="bar">&nbsp;</span>'
+                               . $reload
+                               . '</div>';
+               } // end of if pages > 1
+
+               $data = Array();
+               $titleColumn = $this->fieldArray[0];
+               $data[$titleColumn] = $content;
+
+               return ($this->addElement(1, '', $data));
+       }
+
 
 
 
diff --git a/typo3/gfx/control_first.gif b/typo3/gfx/control_first.gif
new file mode 100644 (file)
index 0000000..d04a158
Binary files /dev/null and b/typo3/gfx/control_first.gif differ
diff --git a/typo3/gfx/control_first_disabled.gif b/typo3/gfx/control_first_disabled.gif
new file mode 100644 (file)
index 0000000..59793ca
Binary files /dev/null and b/typo3/gfx/control_first_disabled.gif differ
diff --git a/typo3/gfx/control_last.gif b/typo3/gfx/control_last.gif
new file mode 100644 (file)
index 0000000..498d25b
Binary files /dev/null and b/typo3/gfx/control_last.gif differ
diff --git a/typo3/gfx/control_last_disabled.gif b/typo3/gfx/control_last_disabled.gif
new file mode 100644 (file)
index 0000000..3541cb1
Binary files /dev/null and b/typo3/gfx/control_last_disabled.gif differ
diff --git a/typo3/gfx/control_next.gif b/typo3/gfx/control_next.gif
new file mode 100644 (file)
index 0000000..61920ab
Binary files /dev/null and b/typo3/gfx/control_next.gif differ
diff --git a/typo3/gfx/control_next_disabled.gif b/typo3/gfx/control_next_disabled.gif
new file mode 100644 (file)
index 0000000..01830b6
Binary files /dev/null and b/typo3/gfx/control_next_disabled.gif differ
diff --git a/typo3/gfx/control_previous.gif b/typo3/gfx/control_previous.gif
new file mode 100644 (file)
index 0000000..1570173
Binary files /dev/null and b/typo3/gfx/control_previous.gif differ
diff --git a/typo3/gfx/control_previous_disabled.gif b/typo3/gfx/control_previous_disabled.gif
new file mode 100644 (file)
index 0000000..5700acd
Binary files /dev/null and b/typo3/gfx/control_previous_disabled.gif differ
index 6949f32..a377974 100755 (executable)
@@ -1932,6 +1932,23 @@ div#typo3-listOptions {
        width: 93%;
 }
 
+div#typo3-dblist-pagination {
+       padding: 5px 0;
+       white-space: nowrap;
+}
+div#typo3-dblist-pagination img, div#typo3-dblist-pagination span.pageIndicator {
+       margin-right: 6px;
+}
+div#typo3-dblist-pagination img {
+       vertical-align: bottom;
+       padding-bottom: 2px;
+}
+div#typo3-dblist-pagination span.bar {
+       border-left: 1px solid #5485c3;
+       padding: 0 2px;
+}
+
+
 
 /* - - - - - - - - - - - - - - - - - - - - -
 
index a577cfc..19322c9 100644 (file)
                        <label index="enable">Enable</label>
                        <label index="file">File</label>
                        <label index="files">Files</label>
+                       <label index="first">First</label>
                        <label index="go">Go</label>
                        <label index="goTo">Go to</label>
                        <label index="help">Help</label>
                        <label index="item">Item</label>
                        <label index="items">Items</label>
+                       <label index="last">Last</label>
                        <label index="left">Left</label>
                        <label index="login">Login</label>
                        <label index="logout">Logout</label>
index de56f2f..c23689d 100755 (executable)
@@ -51,6 +51,8 @@
                        <label index="multipleLanguages">All languages</label>
                        <label index="Localize">Localize to:</label>
                        <label index="viewRecords">Viewing records of</label>
+                       <label index="pageIndicator">Page %1$s of %2$d</label>
+                       <label index="rangeIndicator">Records %1$d - %2$d</label>
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file
diff --git a/typo3/sysext/t3skin/icons/gfx/control_first.gif b/typo3/sysext/t3skin/icons/gfx/control_first.gif
new file mode 100644 (file)
index 0000000..d04a158
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_first.gif differ
diff --git a/typo3/sysext/t3skin/icons/gfx/control_first_disabled.gif b/typo3/sysext/t3skin/icons/gfx/control_first_disabled.gif
new file mode 100644 (file)
index 0000000..59793ca
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_first_disabled.gif differ
diff --git a/typo3/sysext/t3skin/icons/gfx/control_last.gif b/typo3/sysext/t3skin/icons/gfx/control_last.gif
new file mode 100644 (file)
index 0000000..498d25b
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_last.gif differ
diff --git a/typo3/sysext/t3skin/icons/gfx/control_last_disabled.gif b/typo3/sysext/t3skin/icons/gfx/control_last_disabled.gif
new file mode 100644 (file)
index 0000000..3541cb1
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_last_disabled.gif differ
diff --git a/typo3/sysext/t3skin/icons/gfx/control_next.gif b/typo3/sysext/t3skin/icons/gfx/control_next.gif
new file mode 100644 (file)
index 0000000..61920ab
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_next.gif differ
diff --git a/typo3/sysext/t3skin/icons/gfx/control_next_disabled.gif b/typo3/sysext/t3skin/icons/gfx/control_next_disabled.gif
new file mode 100644 (file)
index 0000000..01830b6
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_next_disabled.gif differ
diff --git a/typo3/sysext/t3skin/icons/gfx/control_previous.gif b/typo3/sysext/t3skin/icons/gfx/control_previous.gif
new file mode 100644 (file)
index 0000000..1570173
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_previous.gif differ
diff --git a/typo3/sysext/t3skin/icons/gfx/control_previous_disabled.gif b/typo3/sysext/t3skin/icons/gfx/control_previous_disabled.gif
new file mode 100644 (file)
index 0000000..5700acd
Binary files /dev/null and b/typo3/sysext/t3skin/icons/gfx/control_previous_disabled.gif differ
index 16416ac..50c3106 100644 (file)
@@ -78,7 +78,7 @@ tr.lastcol td.col-clipboard {
        border-right: 1px solid #d7d8e2;
        padding-right: 0px;
 }
-tr.fwd_rwd_nav td {
-       padding: 4px 0;
-}
 
+div#typo3-dblist-pagination img {
+       padding-bottom: 1px;
+}