承接 adods/page-marker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adods/page-marker

Composer 安装命令:

composer require adods/page-marker

包简介

Library for saving CRUD list filter in request query

README 文档

README

A Simple Library for remembering/recording URL Query String used for filtering list

Installation

Via Composer:

composer require adods/page-marker

or just download the file manually and put in your lib directory

Requirement

PHP >= 7.0 and PHP Session enabled

Simple Usage

Include the library to your file, create instance, init() and remember(). Use forget() to reset.

require "path/to/lib/src/PageMarker.php";
// or if you're using composer
require "path/to/vendor/autoload.php";

use Adods\PageMarker\PagerMarker;

// Make sure there's no output before doing this
$pm = new PageMarker;

// Setup default setting and redirect when condition are met
$pm->init();

// Start recording
$pm->remember();

init()

By default, init() will generate default name from current URL Path, lowercased, then replace slashes '/', dots '.', stripes '-', and spaces ' ' to underscore _. Set default url to current url without it's query string. And use the content of $_GET Super Global variable as base data. But, it can be changed.

After default properties are set, then it will check if redirect to the last state is met or just go on with the process.

The conditions are:

  • If the base data contain a reset key element, then the remembered session will be erased and will be redirected to the base URL.
  • If the base data is not empty, then process will continue normally
  • Then it will check the session for existing data.
  • If session data is empty, then process will continue normally
  • Lastly, it will redirect to the base URL with the data from session as Query String parameters

Main Settings/Setup

Settings below should be set BEFORE init().

Session Name:

Name is used as part of the session key.

$pm->setName('new_name');

Name should be easy to read and descriptive about the list and also array key friendly. And any characters mentioned above will be replaced with underscore '_'

Change base URL:

$om->setUrl('http://newurl.test/path')

Any query string will be omitted.

Change base data source

$pm->setBase($somearray);

More Function

Add/Change data

$pm->add('newkey', 'newvalue');
// or
$pm->add([
    'key1' => 'val1',
    'key2' => 'val2',
    'key3' => 'val3'
]);

Using array as parameter will merge the array with current data

Excluding data

$pm->except('nothisone');
// or
$pm->except(['notme', 'alsonotme']);

Remember Options

Data can also overrided from remember() method.

$pm->remember([
    'shouldbeme' => 'yes'
]);

By default, the given parameter will REPLACE the current base data. To add them, you can use PageMarker::OVERRIDE_APPEND constant as second parameter.

$pm->remember([
    'letmejoin' => 'yes'
], PageMarker::OVERRIDE_APPEND);

Manually Forget/Reset

$pm->forget();

Get Forget/Reset URL

$pm->getResetUrl();

Full Example

require_once './vendor/autoload.php';

use Adods\PageMarker\PageMarker;

$pm = new PageMarker;

$pm->init();

$pm->remember();

var_dump($pm->getBase());
?>
<div>
    Base URL: <?php echo $pm->getUrl(); ?>
</div>
<a href="<?php echo $pm->getResetUrl(); ?>">Reset</a>

Try to add parameters to the URL. Everytime the base URL accessed it will automatically redirect with last state URL with Query String Parameters. Click on Reset link to clear all the saved data.

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固