public static function autoload($className) { global $debug; $includePath = 'Classes/' . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; if (is_readable(__DIR__ . '/' . $includePath)) { require $includePath; //$debug->add('Included: ' . $includePath); } else { die('Could not include: ' . get_include_path() . $includePath); } } } spl_autoload_register(null, false); spl_autoload_register('AdrlistAutoloader::autoload'); if (empty($debug)) { $debug = new Adrlist_Debug(); } $debug->newFile($fileInfo['fileName']); /* The settings below here generally do not need to be changed. Define HTTPS and redirect to http or https. To force an https connection add define('FORCEHTTPS',true); at the top of the page before including this file. Conversely, add define('FORCEHTTPS',false); to force an http connection. */ if (!defined('FORCEHTTPS')) { define('FORCEHTTPS', false, true); } if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { //Using https:. This does not mean the connection is actually secure, just that the protocol is HTTPS. define('HTTPS', true, true); } else {
public function output($mobileOptimizedId = false) { /* * Output the pagination. * * $mobileOptimizedId string If you want to hide all of the search and limit stuff, make a unique ID for the toggle hide function. * * @return string */ global $debug; $output = ''; $tempDebug = new Adrlist_Debug(); $tempDebug->add('$this->_defaultSearchValue at begining of output: ' . $this->_defaultSearchValue); try { $pageNumbersOutput = ''; if ($this->_itemCount === '' || !is_int($this->_itemCount)) { throw new Adrlist_CustomException('', '_itemCount is not valid: ' . $this->_itemCount . '.'); } elseif ($this->_offset === '' || !is_int($this->_offset)) { throw new Adrlist_CustomException('', '_offset is not valid: ' . $this->_offset . '.'); } elseif ($this->_limit === '' || !is_int($this->_limit)) { throw new Adrlist_CustomException('', '_limit is not valid: ' . $this->_limit . '.'); } elseif ($this->_uniqueId === '') { throw new Adrlist_CustomException('', '_uniqueId is not valid: ' . $this->_uniqueId . '.'); } $tempDebug->add('$this->_itemCount: ' . $this->_itemCount . '<br>$this->_offset: ' . $this->_offset . '<br>$this->_limit: ' . $this->_limit . '<br>$this->_uniqueId: ' . $this->_uniqueId . '<br>$this->_defaultSearchValue: ' . $this->_defaultSearchValue); $tempDebug->add('itemCount: ' . $this->_itemCount); //Build pagination. This is a numerical listing showing a user-selectable number of pages. if ($this->_itemCount > 0) { $totalPages = @ceil($this->_itemCount / $this->_limit); $currentPage = @ceil(($this->_offset + 1) / $this->_limit); $displayPages = empty($this->_displayPages) ? 11 : $this->_displayPages; $splitPoint = floor($displayPages / 2); //A halfway measurement. $preceedingDots = false; $trailingDots = false; //Determine where $currentPage is in relation to $totalPages. if ($totalPages - $currentPage < $splitPoint) { //$currentPage is near end. $tempDebug->add('1'); $endPage = $totalPages; if ($endPage - $displayPages < 1) { $tempDebug->add('1-1'); $startPage = 1; } else { $tempDebug->add('1-2'); $startPage = $endPage - ($displayPages - 1); $preceedingDots = true; } } else { //$currentPage is not near the end. $tempDebug->add('2'); $trailingDots = true; if ($currentPage - $splitPoint > 1) { //It is not near the beginning. $tempDebug->add('2-1'); $startPage = $currentPage - $splitPoint; $preceedingDots = true; $endPage = $currentPage + $splitPoint; if ($startPage + ($displayPages - 1) == $totalPages) { $tempDebug->add('2-1-1'); $trailingDots = false; } } else { $tempDebug->add('2-2'); $startPage = 1; if ($displayPages >= $totalPages) { $tempDebug->add('2-2-1'); $endPage = $totalPages; $trailingDots = false; } else { $tempDebug->add('2-2-2'); $endPage = $displayPages; } } } $tempDebug->add('$totalPages: ' . "{$totalPages}<br>" . '$displayPages: ' . "{$displayPages}<br>" . '$currentPage: ' . "{$currentPage}<br>" . '$splitPoint: ' . "{$splitPoint}<br>" . '$startPage: ' . "{$startPage}<br>" . '$endPage: ' . "{$endPage}"); if (empty($this->_limit)) { $pageNumbersOutput .= '<table class="table"><tr><td style="padding:2px 0px 2px 0px"> </td></tr></table>'; } else { $pageNumbersOutput = ' <div class="pagination"><table class="center"> <tr> '; $pageCount = $startPage; if ($preceedingDots) { $pageNumbersOutput .= '<td><button action="' . $this->_action . '" class="goToPage ui-btn ui-btn-c ui-btn-inline ui-shadow ui-corner-all ui-mini" limit="' . $this->_limit . '" offset="0" uniqueId="' . $this->_uniqueId . '">«</button></td><td class="backgroundWhite textLarge" style="border:none; padding:0px 0px 0px 0px">…</td>'; } while ($displayPages >= 1) { if ($pageCount > $totalPages) { $pageNumbersOutput .= '<td style="padding: 2px 6px"> </td>'; break; } $newOffset = ($pageCount - 1) * $this->_limit; if ($pageCount == $currentPage) { //The current page. $pageNumbersOutput .= ' <td><button action="' . $this->_action . '" class="ui-btn ui-btn-a ui-btn-inline ui-shadow ui-corner-all ui-mini" limit="' . $this->_limit . '" offset="' . $newOffset . '" uniqueId="' . $this->_uniqueId . '">' . $pageCount . '</button</td>'; } else { //Other pages. $pageNumbersOutput .= ' <td> <button action="' . $this->_action . '" class="goToPage ui-btn ui-btn-c ui-btn-inline ui-shadow ui-corner-all ui-mini" limit="' . $this->_limit . '" offset="' . $newOffset . '" uniqueId="' . $this->_uniqueId . '">' . $pageCount . '</button></td>'; } $pageCount++; $displayPages--; } if ($trailingDots) { $newOffset = ($totalPages - 1) * $this->_limit; $pageNumbersOutput .= '<td class="backgroundWhite textLarge" style="border:none; font-size:larger; padding:0px 0px 0px 3px">…</td><td><button action="' . $this->_action . '" class="goToPage ui-btn ui-btn-c ui-btn-inline ui-shadow ui-corner-all ui-mini" limit="' . $this->_limit . '" offset="' . $newOffset . '" uniqueId="' . $this->_uniqueId . '">»</button></td>'; } $pageNumbersOutput .= ' </tr> </table> </div> '; } } $debug->add('$this->_limit when $this->_uniqueId is ' . $this->_uniqueId . ': ' . $this->_limit); $searchOutput = '<div class="pagination textLeft"> <label class="ui-hidden-accessible" for="search' . $this->_uniqueId . '">Search Input:</label> <input class="searchfield" type="search" action="' . $this->_action . '" autocapitalize="off" autocorrect="off" autoreset="true" id="search' . $this->_uniqueId . '" placeholder="' . $this->_defaultSearchValue . '" goswitch="' . $this->_uniqueId . 'Goswitch"' . $this->_additionalSearchParams . ' name="search' . $this->_uniqueId . '"'; // default="' . $this->_defaultSearchValue . '" $searchOutput .= $this->_fromSearch ? ' value="' . $_POST['searchVal'] . '"' : ''; //hide $searchOutput .= '><button action="' . $this->_action . '" class="hide searchButton ui-btn ui-btn-inline ui-btn-cui-shadow ui-corner-all ui-mini" id="' . $this->_uniqueId . 'Goswitch" style="margin:0 .5em"><i class="fa fa-search" ></i>Search</button> </div>'; //<button class="clearSearch ui-btn ui-btn-inline ui-btn-b ui-icon-delete ui-btn-icon-left ui-shadow ui-corner-all ui-mini" default="' . $this->_defaultSearchValue . '" style="margin:0;">Clear</button> $limitOutput = '<div class="desktop pagination textRight" id="' . $mobileOptimizedId . '"> Show <input class="textRight" data-role="none" goswitch="setLimitButton' . $this->_uniqueId . '" offset="0" type="number" style="margin-right:.5em;width:3em;" value="' . $this->_limit . '"><button action="' . $this->_action . '" class="setLimitButton ui-btn ui-btn-inline ui-btn-c ui-shadow ui-corner-all ui-mini" id="setLimitButton' . $this->_uniqueId . '" uniqueId="' . $this->_uniqueId . '">Set</button><button action="' . $this->_action . '" class="limitShowAll ui-btn ui-btn-inline ui-btn-c ui-shadow ui-corner-all ui-mini" uniqueId="' . $this->_uniqueId . '">Show All</button> </div>'; //Build the output. if ($this->_searchOnly) { $output .= $searchOutput; } else { $output .= '<!-- begin pagination --><div class="break textCenter">' . $searchOutput . $pageNumbersOutput . $limitOutput . '</div>'; $output .= $mobileOptimizedId ? '<button class="mobile tablet ui-btn ui-mini ui-icon-carat-r ui-btn-inline ui-corner-all left" toggle="' . $mobileOptimizedId . '">View Options</button>' : ''; $output .= '<!-- end pagination -->'; } } catch (Adrlist_CustomException $e) { } //$debug->add($tempDebug->output()); return $output; }