定制 sjaakp/yii2-dateline 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

sjaakp/yii2-dateline

最新稳定版本:2.0.3

Composer 安装命令:

composer require sjaakp/yii2-dateline

包简介

Widget to handle dates

README 文档

README

Widget for date-related data in Yii 2.0 PHP Framework.

Latest Stable Version Total Downloads License

Dateline widget renders my JavaScript Dateline. The event data for the dateline are provided by a Yii DataProvider (any object implementing yii\data\DataProviderInterface).

A demonstration of Dateline widget is here.

See it in action at Moordatlas.nl (Dutch). At Weltliteratur is a nice example of the underlying JavaScript widget.

Installation

Install Dateline with Composer. Either add the following to the require section of your composer.json file:

"sjaakp/yii2-dateline": "*"

Or run:

composer require sjaakp/yii2-dateline "*"

You can manually install Dateline by downloading the source in ZIP-format.

Using Dateline

Yii2-dateline implements a widget of the class Dateline. It gets its data from an ActiveDataProvider, ArrayDataProvider, or other class derived from BaseDataProvider Using it is not unlike using a GridView. For instance, in the Controller you might have something like:

<?php
// ...
public function actionFoo()	{
	$dataProvider = new ActiveDataProvider([
		'query' => InterestingEvent::find(),
	    'pagination' => false
	]);
	
	return $this->render('foo', [
		'dataProvider' => $dataProvider
	]);
}
// ...
?>

An example of rendering a Dateline in the View is:

use sjaakp\dateline\Dateline;

/* ... */

<?php $dl = Dateline::begin([
    'dataProvider' => $dataProvider,
    'attributes' => [
        'id' => 'id',
        'start' => 'date1',
        'text' => 'name'
    ],
    'options' => [
		/* ... */
    ]
]);

$dl->band([
    'size' => '75%',
    'scale' => Dateline::WEEK,
    'interval'=> 90,
])
  ->band([
    'size' => '25%',
    'layout' => 'overview',
    'scale' => Dateline::YEAR,
    'interval'=> 80
]);

Dateline::end();
?>

options

Dateline has the following options:

  • dataProvider: the DataProvider for Dateline. Must be set.
  • attributes: used to 'translate' the model attributes to Dateline attributes. It is an array with key => value pairs of:
    • {dateline attribute name} => {model attribute name}.
    • {dateline attribute name} => function($model) returning {model attribute value}.
  • options: array of options for the underlying Dateline jQuery widget. More information here.
  • htmlOptions (optional): array of HTML options for the Dateline container. Use this if you want to explicitly set the ID.

Bands

Dateline consists of one or more Bands. They each display the Events in a different time resolution.

A Band is defined by the Dateline method band().

public function band( $options )

options

$options is an array with the following keys:

  • size: the part of Dateline occupied by this band, as a percentage or another CSS3 dimension,
  • layout: the only sensible value is 'overview'; all other values (including none) default to 'normal', which is the layout of the main band
  • scale: the time unit that divides the horizontal scale of the Band. The value should be one of the following unit constants (yes, Dateline has an astonishing range!):
    • Dateline::MILLISECOND
    • Dateline::SECOND
    • Dateline::MINUTE
    • Dateline::HOUR
    • Dateline::DAY
    • Dateline::WEEK
    • Dateline::MONTH
    • Dateline::YEAR
    • Dateline::DECADE
    • Dateline::CENTURY
    • Dateline::MILLENNIUM
  • interval: the width of one division on the horizontal scale in pixels
  • multiple (optional): modifies the horizontal scale division to multiples of the unit

Events

Note that we're not talking about PHP or JavaScript events here!

Dateline displays Events. These are Models or ActiveRecords characterized by a moment in time.

The Dateline::attributes property holds the translation from Model attributes to Dateline attributes.

A few attributes are essential for Dateline. The Dateline names are:

  • start: the point in time where the Event is situated
  • text: the text (or HTML) displayed on the main Dateline

Events come in two types:

Instant Events

These are the basic Events, having just one point in time. Dateline displays them as dot icons. Only the above attributes are required.

Duration Events

These have a certain duration. Dateline displays them as a piece of 'tape'. Apart from the above, also required is:

  • stop: the point in time where, well, the Event ends.

Duration Events also have some optional attributes, making the Event imprecise:

  • post_start: optional. Indicates a degree of uncertainty in start.

  • pre_stop: optional. Indicates a degree of uncertainty in stop.

The imprecise part of a Duration Event is displayed as faded tape.

Optional Event attribute

Dates

Dateline understands a lot of date formats (in the options and in the Event data). Every date can be provided in one of the following formats:

  • a string, recognized by JavaScript Date, that is in RFC2822 or ISO-8601 format; among them MySQL date and datetime fields
  • an integer: Unix time stamp (seconds since the Unix Epoch, 1-1-1970, return value of PHP time())

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固