-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix pagination for composer based apps
- Loading branch information
1 parent
6135d46
commit bcba752
Showing
7 changed files
with
213 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Basemkhirat\Elasticsearch; | ||
|
||
use Illuminate\Pagination\LengthAwarePaginator; | ||
|
||
class Pagination extends LengthAwarePaginator | ||
{ | ||
|
||
/** | ||
* Render the paginator using the given view. | ||
* | ||
* @param string $view | ||
* @param array $data | ||
* @return string | ||
*/ | ||
public function links($view = "default", $data = []) | ||
{ | ||
return $this->render($view, $data); | ||
} | ||
|
||
/** | ||
* Render the paginator using the given view. | ||
* | ||
* @param string $view | ||
* @param array $data | ||
* @return string | ||
*/ | ||
public function render($view = "default", $data = []) | ||
{ | ||
|
||
extract($data); | ||
|
||
$paginator = $this; | ||
|
||
$elements = $this->elements(); | ||
|
||
require dirname(__FILE__) . "/pagination/" . $view . ".php"; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Basemkhirat\Elasticsearch; | ||
|
||
/** | ||
* Class Request | ||
* @package Basemkhirat\Elasticsearch | ||
*/ | ||
class Request | ||
{ | ||
|
||
/** | ||
* get the request url | ||
* @return string | ||
*/ | ||
public static function url() | ||
{ | ||
|
||
$server = $_SERVER; | ||
|
||
$ssl = (!empty($server['HTTPS']) && $server['HTTPS'] == 'on'); | ||
|
||
$sp = strtolower($server['SERVER_PROTOCOL']); | ||
|
||
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : ''); | ||
|
||
$port = $server['SERVER_PORT']; | ||
|
||
$port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port; | ||
|
||
$host = isset($host) ? $host : $server['SERVER_NAME'] . $port; | ||
|
||
$host .= preg_replace("/\?.*/", "", $server["REQUEST_URI"]); | ||
|
||
return $protocol . '://' . $host; | ||
} | ||
|
||
/** | ||
* get all query string parameters | ||
* @return mixed | ||
*/ | ||
public static function query() | ||
{ | ||
return $_GET; | ||
} | ||
|
||
/** | ||
* get value of query string parameter | ||
* @param $name | ||
* @param null $value | ||
* @return null | ||
*/ | ||
public static function get($name, $value = NULL) | ||
{ | ||
return isset($_GET[$name]) ? $_GET[$name] : $value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php if ($paginator->hasPages()) { ?> | ||
<ul class="pagination"> | ||
<?php if ($paginator->onFirstPage()) { ?> | ||
<li class="page-item disabled"><span class="page-link">«</span></li> | ||
<?php } else { ?> | ||
<li class="page-item"><a class="page-link" href="<?php echo $paginator->previousPageUrl() ?>" | ||
rel="prev">«</a></li> | ||
<?php } ?> | ||
|
||
<?php foreach ($elements as $element) { ?> | ||
|
||
<?php if (is_string($element)) { ?> | ||
<li class="page-item disabled"><span class="page-link"><?php echo $element ?></span></li> | ||
<?php } ?> | ||
|
||
<?php if (is_array($element)) { ?> | ||
<?php foreach ($element as $page => $url) { ?> | ||
<?php if ($page == $paginator->currentPage()) { ?> | ||
<li class="page-item active"><span class="page-link"><?php echo $page ?></span></li> | ||
<?php } else { ?> | ||
<li class="page-item"><a class="page-link" href="<?php echo $url ?>"><?php echo $page ?></a> | ||
</li> | ||
<?php } ?> | ||
<?php } ?> | ||
<?php } ?> | ||
<?php } ?> | ||
|
||
|
||
<?php if ($paginator->hasMorePages()) { ?> | ||
<li class="page-item"><a class="page-link" href="<?php echo $paginator->nextPageUrl() ?>" | ||
rel="next">»</a></li> | ||
<?php } else { ?> | ||
<li class="page-item disabled"><span class="page-link">»</span></li> | ||
<?php } ?> | ||
</ul> | ||
<?php } ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php if ($paginator->hasPages()) { ?> | ||
<ul class="pagination"> | ||
|
||
<?php if ($paginator->onFirstPage()) { ?> | ||
<li class="disabled"><span>«</span></li> | ||
<?php } else { ?> | ||
<li><a href="<?php echo $paginator->previousPageUrl() ?>" rel="prev">«</a></li> | ||
<?php } ?> | ||
|
||
<?php foreach ($elements as $element) { ?> | ||
|
||
<?php if (is_string($element)) { ?> | ||
<li class="disabled"><span><?php echo $element ?></span></li> | ||
<?php } ?> | ||
|
||
<?php if (is_array($element)) { ?> | ||
<?php foreach ($element as $page => $url) { ?> | ||
<?php if ($page == $paginator->currentPage()) { ?> | ||
<li class="active"><span><?php echo $page ?></span></li> | ||
<?php } else { ?> | ||
<li><a href="<?php echo $url ?>"><?php echo $page ?></a></li> | ||
<?php } ?> | ||
<?php } ?> | ||
<?php } ?> | ||
<?php } ?> | ||
|
||
<?php if ($paginator->hasMorePages()) { ?> | ||
<li><a href="<?php echo $paginator->nextPageUrl() ?>" rel="next">»</a></li> | ||
<?php } else { ?> | ||
<li class="disabled"><span>»</span></li> | ||
<?php } ?> | ||
</ul> | ||
<?php } ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php if ($paginator->hasPages()){ ?> | ||
<ul class="pagination"> | ||
|
||
<?php if ($paginator->onFirstPage()){ ?> | ||
<li class="page-item disabled"><span class="page-link">«</span></li> | ||
<?php }else{ ?> | ||
<li class="page-item"><a class="page-link" href="<?php echo $paginator->previousPageUrl() ?>" rel="prev">«</a></li> | ||
<?php } ?> | ||
|
||
<?php if ($paginator->hasMorePages()){ ?> | ||
<li class="page-item"><a class="page-link" href="<?php echo $paginator->nextPageUrl() ?>" rel="next">»</a></li> | ||
<?php }else{ ?> | ||
<li class="page-item disabled"><span class="page-link">»</span></li> | ||
<?php } ?> | ||
|
||
</ul> | ||
<?php } ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php if ($paginator->hasPages()) { ?> | ||
<ul class="pagination"> | ||
<?php if ($paginator->onFirstPage()) { ?> | ||
<li class="disabled"><span>«</span></li> | ||
<?php } else { ?> | ||
<li><a href="<?php echo $paginator->previousPageUrl() ?>" rel="prev">«</a></li> | ||
<?php } ?> | ||
|
||
<?php if ($paginator->hasMorePages()) { ?> | ||
<li><a href="<?php echo $paginator->nextPageUrl() ?>" rel="next">»</a></li> | ||
<?php } else { ?> | ||
<li class="disabled"><span>»</span></li> | ||
<?php } ?> | ||
</ul> | ||
<?php } ?> |