diff --git a/boot.php b/boot.php
index ddc2fa381e..6607c737eb 100644
--- a/boot.php
+++ b/boot.php
@@ -28,7 +28,7 @@ class App {
public $argv;
public $argc;
public $module;
-
+ public $pager;
private $scheme;
private $hostname;
private $path;
@@ -38,6 +38,7 @@ class App {
$this->config = array();
$this->page = array();
+ $this->pager= array();
$this->scheme = ((isset($_SERVER['HTTPS'])
&& ($_SERVER['HTTPS'])) ? 'https' : 'http' );
@@ -49,9 +50,9 @@ class App {
if(substr($_SERVER['QUERY_STRING'],0,2) == "q=")
$_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'],2);
-// $this->cmd = trim($_SERVER['QUERY_STRING'],'/');
$this->cmd = trim($_GET['q'],'/');
+
$this->argv = explode('/',$this->cmd);
$this->argc = count($this->argv);
if((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) {
@@ -60,6 +61,10 @@ class App {
else {
$this->module = 'home';
}
+ $this->pager['page'] = ((x($_GET,'page')) ? $_GET['page'] : 1);
+ $this->pager['itemspage'] = 50;
+ $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
+ $this->pager['total'] = 0;
}
function get_baseurl($ssl = false) {
@@ -73,6 +78,15 @@ class App {
$this->path = ltrim(trim($p),'/');
}
+ function set_pager_total($n) {
+ $this->pager['total'] = intval($n);
+ }
+ function set_pager_itemspage($n) {
+ $this->pager['itemspage'] = intval($n);
+ $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
+
+ }
+
function init_pagehead() {
if(file_exists("view/head.tpl"))
$s = file_get_contents("view/head.tpl");
@@ -358,3 +372,54 @@ function hex2bin($s) {
return(pack("H*",$s));
}
+
+function paginate(&$a) {
+ $o = '';
+ $stripped = ereg_replace("(&page=[0-9]*)","",$_SERVER['QUERY_STRING']);
+ $stripped = str_replace('q=','',$stripped);
+ $stripped = trim($stripped,'/');
+ $url = $a->get_baseurl() . '/' . $stripped;
+
+
+ if($a->pager['total'] > $a->pager['itemspage']) {
+ $o .= '
'."\r\n";
+ }
+ return $o;
+}
\ No newline at end of file
diff --git a/mod/directory.php b/mod/directory.php
index aec34f910d..2dd4b15d98 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -1,8 +1,10 @@
set_pager_itemspage(60);
+}
function directory_content(&$a) {
-
+dbg(2);
$search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
$tpl .= file_get_contents('view/directory_header.tpl');
@@ -16,7 +18,17 @@ function directory_content(&$a) {
$search = dbesc($search);
$sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`employer`,`school`) AGAINST ('$search' IN BOOLEAN MODE) " : "");
- $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 $sql_extra ORDER BY `name` ASC");
+
+ $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra ");
+ if(count($r))
+ $a->set_pager_total($r[0]['total']);
+
+
+
+ $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra ORDER BY `name` ASC LIMIT %d , %d ",
+ intval($a->pager['start']),
+ intval($a->pager['itemspage'])
+ );
if(count($r)) {
$tpl = file_get_contents('view/directory_item.tpl');
@@ -62,6 +74,8 @@ function directory_content(&$a) {
}
$o .= "\r\n";
+ $o .= paginate($a);
+
}
else
notice("No entries (some entries may be hidden).");
diff --git a/view/style.css b/view/style.css
index 701a7d0c5f..3105c5f777 100644
--- a/view/style.css
+++ b/view/style.css
@@ -499,4 +499,26 @@ input#dfrn-url {
#directory-search-end {
clear: both;
-}
\ No newline at end of file
+}
+
+.pager {
+ padding: 10px;
+ text-align: center;
+ font-size: 1.0em;
+}
+
+
+.pager_first,
+.pager_last,
+.pager_prev,
+.pager_next,
+.pager_n {
+ border: 1px solid black;
+ background: #EEE;
+ padding: 4px;
+}
+.pager_current {
+ border: 1px solid black;
+ background: #E33;
+ padding: 4px;
+}