Repository: 2amigos/yii2-date-picker-widget
Branch: master
Commit: 48e73f154f8e
Files: 35
Total size: 43.8 KB
Directory structure:
gitextract_2641p111/
├── .gitattributes
├── .gitignore
├── .scrutinizer.yml
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── composer.json
├── phpunit.xml.dist
├── src/
│ ├── DatePicker.php
│ ├── DatePickerAsset.php
│ ├── DatePickerLanguageAsset.php
│ ├── DatePickerTrait.php
│ ├── DateRangePicker.php
│ ├── DateRangePickerAsset.php
│ └── assets/
│ └── css/
│ └── bootstrap-daterangepicker.css
└── tests/
└── functional/
├── AssetManager.php
├── DatePickerAssetTest.php
├── DatePickerLanguageAssetTest.php
├── DatePickerTest.php
├── DateRangePickerAssetTest.php
├── DateRangePickerTest.php
├── TestCase.php
├── assets/
│ └── .gitignore
├── bootstrap.php
├── models/
│ └── Post.php
├── overrides/
│ ├── TestDatePicker.php
│ ├── TestDatePickerLanguageAsset.php
│ ├── TestDateRangePicker.php
│ └── TestDateRangePickerAsset.php
└── views/
├── datepicker-widget.php
├── daterangepicker-widget.php
└── layouts/
├── main.php
└── rawlayout.php
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/tests export-ignore
/composer.lock export-ignore
================================================
FILE: .gitignore
================================================
build
#composer.lock
docs
vendor
# cache directories
Thumbs.db
*.DS_Store
*.empty
#phpstorm project files
.idea
#netbeans project files
nbproject
#eclipse, zend studio, aptana or other eclipse like project files
.buildpath
.project
.settings
# mac deployment helpers
switch
index
================================================
FILE: .scrutinizer.yml
================================================
filter:
excluded_paths: [tests/*]
checks:
php:
code_rating: true
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
tools:
external_code_coverage:
timeout: 600
runs: 3
php_analyzer: true
php_code_coverage: false
php_code_sniffer:
config:
standard: PSR2
filter:
paths: ['src']
php_loc:
enabled: true
excluded_dirs: [vendor, tests]
php_cpd:
enabled: true
excluded_dirs: [vendor, tests]
================================================
FILE: .travis.yml
================================================
language: php
php:
- 5.5
- 5.6
install:
- composer self-update
- composer global require "fxp/composer-asset-plugin:^1.2.0"
- composer install
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev
script:
- phpunit --coverage-text --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
================================================
FILE: CHANGELOG.md
================================================
# Changelog
## 1.0.5 - 2015-04-02
## Changed
- Added CHANGELOG.md file
## Fixed
- Fixed asset registration bug when using form
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
Contributions are **welcome** and will be fully **credited**.
We accept contributions via Pull Requests on [Github](https://github.com/2amigos/yii2-datepicker-widget).
## Pull Requests
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
- **Create feature branches** - Don't ask us to pull from your master branch.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
## Running Tests
``` bash
$ phpunit
```
**Happy coding**!
================================================
FILE: LICENSE.md
================================================
# The BSD License (BSD)
Copyright (c) 2013-2015, 2amigOS! Consulting Group LLC.
> Redistribution and use in source and binary forms, with or without modification,
> are permitted provided that the following conditions are met:
>
> Redistributions of source code must retain the above copyright notice, this
> list of conditions and the following disclaimer.
>
> Redistributions in binary form must reproduce the above copyright notice, this
> list of conditions and the following disclaimer in the documentation and/or
> other materials provided with the distribution.
>
> Neither the name of 2amigOS! Consulting Group, LLC. nor the names of its
> contributors may be used to endorse or promote products derived from
> this software without specific prior written permission.
>
>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
>ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
>WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
>ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
>(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
>LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
>ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
>(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
>SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================
FILE: README.md
================================================
Bootstrap DatePicker Widget for Yii2
====================================
[](https://github.com/2amigos/yii2-date-picker-widget/tags)
[](LICENSE.md)
[](https://travis-ci.org/2amigos/yii2-date-picker-widget)
[](https://scrutinizer-ci.com/g/2amigos/yii2-date-picker-widget/code-structure)
[](https://scrutinizer-ci.com/g/2amigos/yii2-date-picker-widget)
[](https://packagist.org/packages/2amigos/yii2-date-picker-widget)
Renders a [Bootstrap DatePicker plugin](http://bootstrapformhelpers.com/datepicker/).
Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```bash
$ composer require 2amigos/yii2-date-picker-widget:~1.0
```
or add
```json
"2amigos/yii2-date-picker-widget" : "~1.0"
```
to the require section of your application's `composer.json` file.
Usage
-----
The widget comes in two flavors:
- DatePicker
- DateRangePicker
**DatePicker**
This widget renders a Bootstrap DatePicker input control. Best suitable for model with date string attribute.
***Example of use with a form***
There are two ways of using it, with an `ActiveForm` instance or as a widget setting up its `model` and `attribute`.
```php
<?php
use dosamigos\datepicker\DatePicker;
// as a widget
?>
<?= DatePicker::widget([
'model' => $model,
'attribute' => 'date',
'template' => '{addon}{input}',
'clientOptions' => [
'autoclose' => true,
'format' => 'dd-M-yyyy'
]
]);?>
<?php
// with an ActiveForm instance
?>
<?= $form->field($model, 'date')->widget(
DatePicker::className(), [
// inline too, not bad
'inline' => true,
// modify template for custom rendering
'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>',
'clientOptions' => [
'autoclose' => true,
'format' => 'dd-M-yyyy'
]
]);?>
```
***Example of use without a model***
```php
<?php
use dosamigos\datepicker\DatePicker;
?>
<?= DatePicker::widget([
'name' => 'Test',
'value' => '02-16-2012',
'template' => '{addon}{input}',
'clientOptions' => [
'autoclose' => true,
'format' => 'dd-M-yyyy'
]
]);?>
```
**DateRangePicker**
This widget renders a Bootstrap DateRangePicker Input control.
***Example of use with a form***
The following example works with a model that has two attributes named `date_from` and `date_to`.
```php
<?php
use dosamigos\datepicker\DateRangePicker;
?>
<?= $form->field($tour, 'date_from')->widget(DateRangePicker::className(), [
'attributeTo' => 'date_to',
'form' => $form, // best for correct client validation
'language' => 'es',
'size' => 'lg',
'clientOptions' => [
'autoclose' => true,
'format' => 'dd-M-yyyy'
]
]);?>
```
***Example of use without a model***
```php
<?php
use dosamigos\datepicker\DateRangePicker;
?>
<?= DateRangePicker::widget([
'name' => 'date_from',
'value' => '02-16-2012',
'nameTo' => 'name_to',
'valueTo' => '02-20-2012'
]);?>
```
Testing
-------
To test the extension, is better to clone this repository on your computer. After, go to the extensions folder and do
the following (assuming you have `composer` installed on your computer):
```bash
$ composer install --no-interaction --prefer-source --dev
```
Once all required libraries are installed then do:
```bash
$ vendor/bin/phpunit
```
I would recommend to have `phpunit` globally installed together with `xdebug` so you can have code coverage analysis too.
Further Information
-------------------
Please, check the [Bootstrap DatePicker site](http://bootstrap-datepicker.readthedocs.io/en/latest/) documentation for further information about its configuration options.
Contributing
------------
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
Credits
-------
- [Antonio Ramirez](https://github.com/tonydspaniard)
- [All Contributors](../../contributors)
License
-------
The BSD License (BSD). Please see [License File](LICENSE.md) for more information.
> [](http://www.2amigos.us)
<i>Web development has never been so fun!</i>
[www.2amigos.us](http://www.2amigos.us)
================================================
FILE: composer.json
================================================
{
"name": "2amigos/yii2-date-picker-widget",
"description": "Bootstrap DatePicker widget for Yii2.",
"type": "yii2-extension",
"keywords": [
"2amigos",
"yii",
"yii2",
"yii 2",
"extension",
"widget",
"datepicker"
],
"homepage": "http://yiiwheels.com/extension/bootstrap-datepicker",
"license": "BSD-3-Clause",
"authors": [
{
"name": "2amigOS! Consulting Group",
"email": "hola@2amigos.us",
"homepage": "http://2amigos.us",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/2amigos/yii2-date-picker-widget/issues",
"source": "https://github.com/2amigos/yii2-date-picker-widget"
},
"require": {
"yiisoft/yii2": ">=2.0.9",
"yiisoft/yii2-bootstrap": "*",
"bower-asset/bootstrap-datepicker": "1.7.0"
},
"require-dev": {
"phpunit/phpunit": "4.*"
},
"autoload": {
"psr-4": {
"dosamigos\\datepicker\\": "src"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"asset-installer-paths": {
"bower-asset-library": "vendor/bower"
}
}
}
================================================
FILE: phpunit.xml.dist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/functional/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Yii2 DatePicker Test Suite">
<directory>./tests/functional</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
================================================
FILE: src/DatePicker.php
================================================
<?php
/**
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\datepicker;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
/**
* DatePicker renders a DatePicker input.
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\datepicker
*/
class DatePicker extends InputWidget
{
use DatePickerTrait;
/**
* @var string the addon markup if you wish to display the input as a component. If you don't wish to render as a
* component then set it to null or false.
*/
public $addon = '<i class="glyphicon glyphicon-calendar"></i>';
/**
* @var string the template to render the input.
*/
public $template = '{input}{addon}';
/**
* @var bool whether to render the input as an inline calendar
*/
public $inline = false;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->inline) {
$this->options['readonly'] = 'readonly';
Html::addCssClass($this->options, 'text-center');
}
if ($this->size) {
Html::addCssClass($this->options, 'input-' . $this->size);
Html::addCssClass($this->containerOptions, 'input-group-' . $this->size);
}
Html::addCssClass($this->options, 'form-control');
Html::addCssClass($this->containerOptions, 'input-group date');
}
/**
* @inheritdoc
*/
public function run()
{
$input = $this->hasModel()
? Html::activeTextInput($this->model, $this->attribute, $this->options)
: Html::textInput($this->name, $this->value, $this->options);
if ($this->inline) {
$input .= '<div></div>';
}
if ($this->addon && !$this->inline) {
$addon = Html::tag('span', $this->addon, ['class' => 'input-group-addon']);
$input = strtr($this->template, ['{input}' => $input, '{addon}' => $addon]);
$input = Html::tag('div', $input, $this->containerOptions);
}
if ($this->inline) {
$input = strtr($this->template, ['{input}' => $input, '{addon}' => '']);
}
echo $input;
$this->registerClientScript();
}
/**
* Registers required script for the plugin to work as DatePicker
*/
public function registerClientScript()
{
$js = [];
$view = $this->getView();
// @codeCoverageIgnoreStart
if ($this->language !== null && $this->language !== 'en') {
$this->clientOptions['language'] = $this->language;
DatePickerLanguageAsset::register($view)->js[] = 'bootstrap-datepicker.' . $this->language . '.min.js';
} else {
DatePickerAsset::register($view);
}
// @codeCoverageIgnoreEnd
$id = $this->options['id'];
$selector = ";jQuery('#$id')";
if ($this->addon || $this->inline) {
$selector .= ".parent()";
}
$options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : '';
if ($this->inline) {
$this->clientEvents['changeDate'] = "function (e){ jQuery('#$id').val(e.format());}";
}
$js[] = "$selector.datepicker($options);";
if (!empty($this->clientEvents)) {
foreach ($this->clientEvents as $event => $handler) {
$js[] = "$selector.on('$event', $handler);";
}
}
$view->registerJs(implode("\n", $js));
}
}
================================================
FILE: src/DatePickerAsset.php
================================================
<?php
/**
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\datepicker;
use yii\web\AssetBundle;
/**
* DatePickerAsset
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\datepicker
*/
class DatePickerAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap-datepicker/dist';
public $css = [
'css/bootstrap-datepicker3.css',
];
public $js = [
'js/bootstrap-datepicker.js'
];
public $depends = [
'yii\bootstrap\BootstrapPluginAsset'
];
}
================================================
FILE: src/DatePickerLanguageAsset.php
================================================
<?php
/**
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\datepicker;
use yii\web\AssetBundle;
/**
* DatePickerLanguageAsset
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\datepicker
*/
class DatePickerLanguageAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap-datepicker/dist/locales';
public $depends = [
'dosamigos\datepicker\DateRangePickerAsset'
];
}
================================================
FILE: src/DatePickerTrait.php
================================================
<?php
/**
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\datepicker;
/**
* DatePickerTrait holds common attributes
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\datepicker
*/
trait DatePickerTrait
{
/**
* @var string the language to use
*/
public $language;
/**
* @var array the options for the Bootstrap DatePicker plugin.
* Please refer to the Bootstrap DatePicker plugin Web page for possible options.
* @see http://bootstrap-datepicker.readthedocs.org/en/release/options.html
*/
public $clientOptions = [];
/**
* @var array the event handlers for the underlying Bootstrap DatePicker plugin.
* Please refer to the [DatePicker](http://bootstrap-datepicker.readthedocs.org/en/release/events.html) plugin
* Web page for possible events.
*/
public $clientEvents = [];
/**
* @var string the size of the input ('lg', 'md', 'sm', 'xs')
*/
public $size;
/**
* @var array HTML attributes to render on the container
*/
public $containerOptions = [];
}
================================================
FILE: src/DateRangePicker.php
================================================
<?php
/**
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\datepicker;
use yii\base\InvalidConfigException;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\InputWidget;
/**
* DateRangePicker renders a DatePicker range input.
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\datepicker
*/
class DateRangePicker extends InputWidget
{
use DatePickerTrait;
/**
* @var string the attribute name for date range (to Date)
*/
public $attributeTo;
/**
* @var string the name for date range (to Date)
*/
public $nameTo;
/**
* @var string the value for date range (to Date value)
*/
public $valueTo;
/**
* @var array HTML attributes for the date to input
*/
public $optionsTo;
/**
* @var string the label to. Defaults to 'to'.
*/
public $labelTo = 'to';
/**
* @var \yii\widgets\ActiveForm useful for client validation of attributeTo
*/
public $form;
/**
* @var string the template to render. Used internally.
*/
protected $_template = '{inputFrom}<span class="input-group-addon">{labelTo}</span>{inputTo}';
/**
* @inheritdoc
* @throws \yii\base\InvalidConfigException
*/
public function init()
{
parent::init();
if ((!$this->hasModel() && $this->nameTo === null) || ($this->hasModel() && $this->attributeTo === null)) {
// @codeCoverageIgnoreStart
throw new InvalidConfigException("Either 'nameTo', or 'model' and 'attributeTo' properties must be specified.");
// @codeCoverageIgnoreEnd
}
if ($this->size) {
Html::addCssClass($this->options, 'input-' . $this->size);
Html::addCssClass($this->optionsTo, 'input-' . $this->size);
Html::addCssClass($this->containerOptions, 'input-group-' . $this->size);
}
Html::addCssClass($this->containerOptions, 'input-group input-daterange');
Html::addCssClass($this->options, 'form-control');
Html::addCssClass($this->optionsTo, 'form-control');
}
/**
* @inheritdoc
*/
public function run()
{
if ($this->form) {
Html::addCssClass($this->options, 'datepicker-from');
Html::addCssClass($this->optionsTo, 'datepicker-to');
$inputFrom = $this->form->field(
$this->model,
$this->attribute,
[
'template' => '{input}{error}',
'options' => ['class' => 'input-group datepicker-range'],
]
)->textInput($this->options);
$inputTo = $this->form->field(
$this->model,
$this->attributeTo,
[
'template' => '{input}{error}',
'options' => ['class' => 'input-group datepicker-range'],
]
)->textInput($this->optionsTo);
} else {
$inputFrom = $this->hasModel()
? Html::activeTextInput($this->model, $this->attribute, $this->options)
: Html::textInput($this->name, $this->value, $this->options);
$inputTo = $this->hasModel()
? Html::activeTextInput($this->model, $this->attributeTo, $this->optionsTo)
: Html::textInput($this->nameTo, $this->valueTo, $this->optionsTo);
}
echo Html::tag(
'div',
strtr(
$this->_template,
['{inputFrom}' => $inputFrom, '{labelTo}' => $this->labelTo, '{inputTo}' => $inputTo]
), $this->containerOptions);
$this->registerClientScript();
}
/**
* Registers required script for the plugin to work as DateRangePicker
*/
public function registerClientScript()
{
$js = [];
$view = $this->getView();
// @codeCoverageIgnoreStart
if($this->language !== null) {
$this->clientOptions['language'] = $this->language;
DatePickerLanguageAsset::register($view)->js[] = 'bootstrap-datepicker.' . $this->language . '.min.js';
} else {
DateRangePickerAsset::register($view);
}
// @codeCoverageIgnoreEnd
$id = $this->options['id'];
$selector = ";jQuery('#$id').parent()";
if($this->form && $this->hasModel()) {
// @codeCoverageIgnoreStart
$selector .= '.parent()';
$class = "field-" . Html::getInputId($this->model, $this->attribute);
$js[] = "$selector.closest('.$class').removeClass('$class');";
// @codeCoverageIgnoreEnd
}
$options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : '';
$js[] = "$selector.datepicker($options);";
// @codeCoverageIgnoreStart
if (!empty($this->clientEvents)) {
foreach ($this->clientEvents as $event => $handler) {
$js[] = "$selector.on('$event', $handler);";
}
}
// @codeCoverageIgnoreEnd
$view->registerJs(implode("\n", $js));
}
}
================================================
FILE: src/DateRangePickerAsset.php
================================================
<?php
/**
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\datepicker;
use yii\web\AssetBundle;
/**
* DateRangePickerAsset
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\datepicker
*/
class DateRangePickerAsset extends AssetBundle
{
public $sourcePath = '@vendor/2amigos/yii2-date-picker-widget/src/assets';
public $css = [
'css/bootstrap-daterangepicker.css'
];
public $depends = [
'dosamigos\datepicker\DatePickerAsset'
];
}
================================================
FILE: src/assets/css/bootstrap-daterangepicker.css
================================================
/*!
* Custom styling. Removing padding when using DateRangePicker.
*/
.datepicker {
z-index: 1151 !important;
}
.datepicker-range {
padding: 0 !important;
border: 0 !important;
text-align: left !important;
}
.datepicker-from {
border-radius: 4px !important;
border-top-right-radius: 0 !important;
border-bottom-right-radius: 0 !important;
text-align: left !important;
}
.datepicker-to {
border-radius: 4px !important;
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
text-align: left !important;
}
div.datepicker-range {
width: 100%;
}
================================================
FILE: tests/functional/AssetManager.php
================================================
<?php
/**
* @link https://github.com/2amigos/yii2-date-picker-widget
* @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC
* @license http://opensource.org/licenses/BSD-3-Clause
*/
namespace tests;
/**
* AssetManager
*/
class AssetManager extends \yii\web\AssetManager
{
private $_hashes = [];
private $_counter = 0;
/**
* @inheritdoc
*/
public function hash($path) {
if (!isset($this->_hashes[$path])) {
$this->_hashes[$path] = $this->_counter++;
}
return $this->_hashes[$path];
}
}
================================================
FILE: tests/functional/DatePickerAssetTest.php
================================================
<?php
namespace tests;
use dosamigos\datepicker\DatePickerAsset;
use yii\web\AssetBundle;
class DatePickerAssetTest extends TestCase
{
public function testRegister()
{
$view = $this->getView();
$this->assertEmpty($view->assetBundles);
DatePickerAsset::register($view);
$this->assertEquals(4, count($view->assetBundles));
$this->assertArrayHasKey('yii\\web\\JqueryAsset', $view->assetBundles);
$this->assertTrue($view->assetBundles['dosamigos\\datepicker\\DatePickerAsset'] instanceof AssetBundle);
$content = $view->render('//layouts/rawlayout.php');
$this->assertContains('jquery.js', $content);
$this->assertContains('bootstrap.js', $content);
$this->assertContains('bootstrap-datepicker.js', $content);
$this->assertContains('bootstrap-datepicker3.css', $content);
}
}
================================================
FILE: tests/functional/DatePickerLanguageAssetTest.php
================================================
<?php
namespace tests;
use tests\overrides\TestDatePickerLanguageAsset;
use yii\web\AssetBundle;
class DatePickerLanguageAssetTest extends TestCase
{
public function testRegister()
{
$view = $this->getView();
$this->assertEmpty($view->assetBundles);
TestDatePickerLanguageAsset::register($view)->js[] = 'bootstrap-datepicker.es.min.js';
$this->assertEquals(6, count($view->assetBundles));
$this->assertTrue($view->assetBundles['tests\overrides\TestDatePickerLanguageAsset'] instanceof AssetBundle);
$content = $view->render('//layouts/rawlayout.php');
$this->assertContains('jquery.js', $content);
$this->assertContains('bootstrap-datepicker.es.min.js', $content);
}
}
================================================
FILE: tests/functional/DatePickerTest.php
================================================
<?php
namespace tests;
use dosamigos\datepicker\DatePicker;
use tests\models\Post;
use tests\overrides\TestDatePicker;
use yii\web\JsExpression;
use yii\web\View;
use Yii;
class DatePickerTest extends TestCase
{
public function testRenderWithModel()
{
$model = new Post();
$model->create_time = 1425807308;
$out = DatePicker::widget([
'model' => $model,
'attribute' => 'create_time'
]);
$expected = '<div class="input-group date"><input type="text" id="post-create_time" class="form-control" name="Post[create_time]" value="1425807308"><span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>';
$this->assertEqualsWithoutLE($expected, $out);
}
public function testRenderWithNameAndValue()
{
$out = DatePicker::widget([
'id' => 'test',
'name' => 'test-editor-name',
'value' => '02-16-2012'
]);
$expected = '<div class="input-group date"><input type="text" id="test" class="form-control" name="test-editor-name" value="02-16-2012"><span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>';
$this->assertEqualsWithoutLE($expected, $out);
}
public function testRenderInline()
{
$out = DatePicker::widget([
'id' => 'test',
'name' => 'test-editor-name',
'value' => 'test-editor-value',
'inline' => true
]);
$expected = '<input type="text" id="test" class="text-center form-control" name="test-editor-name" value="test-editor-value" readonly="readonly"><div></div>';
$this->assertEqualsWithoutLE($expected, $out);
}
public function testRenderWithSize()
{
$out = DatePicker::widget([
'id' => 'test',
'name' => 'test-editor-name',
'value' => 'test-editor-value',
'size' => 'lg'
]);
$expected = '<div class="input-group-lg input-group date"><input type="text" id="test" class="input-lg form-control" name="test-editor-name" value="test-editor-value"><span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>';
$this->assertEqualsWithoutLE($expected, $out);
}
public function testDatePickerRegisterPluginScriptMethod()
{
$class = new \ReflectionClass('tests\\overrides\\TestDatePicker');
$method = $class->getMethod('registerClientScript');
$method->setAccessible(true);
$model = new Post();
$model->create_time = 1425807308;
$widget = TestDatePicker::begin(
[
'model' => $model,
'attribute' => 'create_time',
'language' => 'es',
'clientEvents' => [
'changeDate' => new JsExpression('function(ev){console.log(ev);}')
]
]
);
$class->getProperty('language')->setValue($widget, 'es');
$view = $this->getView();
$widget->setView($view);
$method->invoke($widget);
$test = <<<JS
;jQuery('#post-create_time').parent().datepicker({"language":"es"});
;jQuery('#post-create_time').parent().on('changeDate', function(ev){console.log(ev);});
JS;
$this->assertEquals($test, $view->js[View::POS_READY]['test-datepicker-js']);
}
public function testWidget()
{
$model = new Post();
$view = Yii::$app->getView();
$content = $view->render('//datepicker-widget', ['model' => $model]);
$actual = $view->render('//layouts/main', ['content' => $content]);
$expected = file_get_contents(__DIR__ . '/data/test-datepicker-widget.bin');
$this->assertEquals($expected, $actual);
}
}
================================================
FILE: tests/functional/DateRangePickerAssetTest.php
================================================
<?php
namespace tests;
use tests\overrides\TestDateRangePickerAsset;
use yii\web\AssetBundle;
class DateRangePickerAssetTest extends TestCase
{
public function testRegister()
{
$view = $this->getView();
$this->assertEmpty($view->assetBundles);
TestDateRangePickerAsset::register($view);
$this->assertEquals(5, count($view->assetBundles));
$this->assertArrayHasKey('yii\\web\\JqueryAsset', $view->assetBundles);
$this->assertTrue($view->assetBundles['tests\\overrides\\TestDateRangePickerAsset'] instanceof AssetBundle);
$content = $view->render('//layouts/rawlayout.php');
$this->assertContains('jquery.js', $content);
$this->assertContains('bootstrap.js', $content);
$this->assertContains('bootstrap-daterangepicker.css', $content);
}
}
================================================
FILE: tests/functional/DateRangePickerTest.php
================================================
<?php
namespace tests;
use Yii;
use dosamigos\datepicker\DateRangePicker;
use tests\models\Post;
use tests\overrides\TestDateRangePicker;
use yii\bootstrap\ActiveForm;
use yii\web\JsExpression;
use yii\web\View;
class DateRangePickerTest extends TestCase
{
public function testRenderWithModel()
{
$model = new Post();
$out = TestDateRangePicker::widget([
'form' => new ActiveForm(),
'model' => $model,
'attribute' => 'date_from',
'attributeTo' => 'date_to'
]);
$expected = '<div class="input-group input-daterange"><div class="input-group datepicker-range field-post-date_from">
<input type="text" id="post-date_from" class="form-control datepicker-from" name="Post[date_from]"><p class="help-block help-block-error"></p>
</div><span class="input-group-addon">to</span><div class="input-group datepicker-range field-post-date_to">
<input type="text" id="post-date_to" class="form-control datepicker-to" name="Post[date_to]"><p class="help-block help-block-error"></p>
</div></div>';
$this->assertEqualsWithoutLE($expected, $out);
}
public function testRenderWithNameAndValue()
{
$out = TestDateRangePicker::widget([
'name' => 'name_from',
'value' => '02-16-2015',
'nameTo' => 'name_to',
'valueTo' => '02-18-2015'
]);
$expected = '<div class="input-group input-daterange"><input type="text" id="w1" class="form-control" name="name_from" value="02-16-2015"><span class="input-group-addon">to</span><input type="text" class="form-control" name="name_to" value="02-18-2015"></div>';
$this->assertEqualsWithoutLE($expected, $out);
}
public function testRenderWithSize()
{
$out = TestDateRangePicker::widget([
'name' => 'name_from',
'value' => '02-16-2015',
'nameTo' => 'name_to',
'valueTo' => '02-18-2015',
'size' => 'lg'
]);
$expected = '<div class="input-group-lg input-group input-daterange"><input type="text" id="w2" class="input-lg form-control" name="name_from" value="02-16-2015"><span class="input-group-addon">to</span><input type="text" class="input-lg form-control" name="name_to" value="02-18-2015"></div>';
$this->assertEqualsWithoutLE($expected, $out);
}
public function testWrongConfig() {
$this->setExpectedException('yii\base\InvalidConfigException');
$out = DateRangePicker::begin([]);
}
public function testDateRangePickerRegisterPluginScriptMethod()
{
$class = new \ReflectionClass('tests\\overrides\\TestDateRangePicker');
$method = $class->getMethod('registerClientScript');
$method->setAccessible(true);
$model = new Post();
$model->create_time = 1425807308;
$widget = TestDateRangePicker::begin(
[
'form' => new ActiveForm(),
'model' => $model,
'attribute' => 'date_from',
'attributeTo' => 'date_to',
'language' => 'es',
'clientEvents' => [
'changeDate' => new JsExpression('function(ev){console.log(ev);}')
]
]
);
$class->getProperty('language')->setValue($widget, 'es');
$view = $this->getView();
$widget->setView($view);
$method->invoke($widget);
$test = <<<JS
;jQuery('#post-date_from').parent().parent().closest('.field-post-date_from').removeClass('field-post-date_from');
;jQuery('#post-date_from').parent().parent().datepicker({"language":"es"});
;jQuery('#post-date_from').parent().parent().on('changeDate', function(ev){console.log(ev);});
JS;
$this->assertEquals($test, $view->js[View::POS_READY]['test-daterangepicker-js']);
}
public function testWidget()
{
$model = new Post();
$view = Yii::$app->getView();
$content = $view->render('//daterangepicker-widget', ['model' => $model]);
$actual = $view->render('//layouts/main', ['content' => $content]);
$expected = file_get_contents(__DIR__ . '/data/test-daterangepicker-widget.bin');
$this->assertEquals($expected, $actual);
}
}
================================================
FILE: tests/functional/TestCase.php
================================================
<?php
namespace tests;
use yii\helpers\ArrayHelper;
use yii\web\View;
/**
* This is the base class for all tests.
*/
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
public static $params;
/**
* Mock application prior running tests.
*/
protected function setUp()
{
$this->mockWebApplication(
[
'components' => [
'request' => [
'class' => 'yii\web\Request',
'url' => '/test',
'enableCsrfValidation' => false,
],
'response' => [
'class' => 'yii\web\Response',
],
],
]
);
}
/**
* Clean up after test.
* By default the application created with [[mockApplication]] will be destroyed.
*/
protected function tearDown()
{
parent::tearDown();
$this->destroyApplication();
}
protected function mockApplication($config = [], $appClass = '\yii\console\Application')
{
new $appClass(
ArrayHelper::merge(
[
'id' => 'testapp',
'basePath' => __DIR__,
'vendorPath' => $this->getVendorPath(),
],
$config
)
);
}
protected function mockWebApplication($config = [], $appClass = '\yii\web\Application')
{
new $appClass(ArrayHelper::merge([
'id' => 'testapp',
'basePath' => __DIR__,
'vendorPath' => $this->getVendorPath(),
'components' => [
'request' => [
'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq',
'scriptFile' => __DIR__ .'/index.php',
'scriptUrl' => '/index.php',
],
'assetManager' => [
'class' => 'tests\AssetManager',
'basePath' => '@tests/assets',
'baseUrl' => '/',
]
]
], $config));
}
protected function getVendorPath()
{
return dirname(dirname(__DIR__)) . '/vendor';
}
/**
* Destroys application in Yii::$app by setting it to null.
*/
protected function destroyApplication()
{
\Yii::$app = null;
}
/**
* Creates a view for testing purposes
*
* @return View
*/
protected function getView()
{
$view = new View();
$view->setAssetManager(new AssetManager([
'basePath' => '@tests/assets',
'baseUrl' => '/',
]));
return $view;
}
/**
* Asserting two strings equality ignoring line endings
*
* @param string $expected
* @param string $actual
*/
public function assertEqualsWithoutLE($expected, $actual)
{
$expected = str_replace("\r\n", "\n", $expected);
$actual = str_replace("\r\n", "\n", $actual);
$this->assertEquals($expected, $actual);
}
}
================================================
FILE: tests/functional/assets/.gitignore
================================================
*
!.gitignore
================================================
FILE: tests/functional/bootstrap.php
================================================
<?php
error_reporting(-1);
define('YII_ENABLE_ERROR_HANDLER', false);
define('YII_DEBUG', true);
$_SERVER['SCRIPT_NAME'] = '/' . __DIR__;
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
Yii::setAlias('@tests', __DIR__);
require_once(__DIR__ . '/TestCase.php');
================================================
FILE: tests/functional/models/Post.php
================================================
<?php
namespace tests\models;
use yii\db\ActiveRecord;
class Post extends ActiveRecord
{
public $date_from;
public $date_to;
public $create_time;
public static $db;
public static function getDb()
{
return self::$db;
}
}
================================================
FILE: tests/functional/overrides/TestDatePicker.php
================================================
<?php
namespace tests\overrides;
use dosamigos\datepicker\DatePicker;
use dosamigos\datepicker\DatePickerAsset;
use yii\helpers\Json;
use yii\web\View;
class TestDatePicker extends DatePicker
{
/**
* Registers required script for the plugin to work as a DateTimePicker
*/
public function registerClientScript()
{
$view = $this->getView();
if ($this->language !== null) {
$this->clientOptions['language'] = $this->language;
DatePickerAsset::register($view)->js[] = 'js/locales/bootstrap-datepicker.' . $this->language . '.js';
} else {
DatePickerAsset::register($view);
}
$id = $this->options['id'];
$selector = ";jQuery('#$id')";
if ($this->addon || $this->inline) {
$selector .= ".parent()";
}
$options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : '';
if ($this->inline) {
$this->clientEvents['changeDate'] = "function (e){ jQuery('#$id').val(e.format());}";
}
$js[] = "$selector.datepicker($options);";
if (!empty($this->clientEvents)) {
foreach ($this->clientEvents as $event => $handler) {
$js[] = "$selector.on('$event', $handler);";
}
}
$view->registerJs(implode("\n", $js), View::POS_READY, 'test-datepicker-js');
}
}
================================================
FILE: tests/functional/overrides/TestDatePickerLanguageAsset.php
================================================
<?php
namespace tests\overrides;
use dosamigos\datepicker\DatePickerLanguageAsset;
class TestDatePickerLanguageAsset extends DatePickerLanguageAsset
{
public $depends = [
'tests\overrides\TestDateRangePickerAsset'
];
}
================================================
FILE: tests/functional/overrides/TestDateRangePicker.php
================================================
<?php
namespace tests\overrides;
use dosamigos\datepicker\DateRangePicker;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\web\View;
class TestDateRangePicker extends DateRangePicker
{
/**
* Registers required script for the plugin to work as a DateTimePicker
*/
public function registerClientScript()
{
$view = $this->getView();
if($this->language !== null) {
$this->clientOptions['language'] = $this->language;
TestDatePickerLanguageAsset::register($view)->js[] = 'bootstrap-datepicker.' . $this->language . '.min.js';
} else {
TestDateRangePickerAsset::register($view);
}
$id = $this->options['id'];
$selector = ";jQuery('#$id').parent()";
if($this->form && $this->hasModel()) {
$selector .= '.parent()';
$class = "field-" . Html::getInputId($this->model, $this->attribute);
$js[] = "$selector.closest('.$class').removeClass('$class');";
}
$options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : '';
$js[] = "$selector.datepicker($options);";
if (!empty($this->clientEvents)) {
foreach ($this->clientEvents as $event => $handler) {
$js[] = "$selector.on('$event', $handler);";
}
}
$view->registerJs(implode("\n", $js), View::POS_READY, 'test-daterangepicker-js');
}
}
================================================
FILE: tests/functional/overrides/TestDateRangePickerAsset.php
================================================
<?php
/**
*
* TestDateRangePickerAssset.php
*
* Date: 20/03/15
* Time: 13:38
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
*/
namespace tests\overrides;
use dosamigos\datepicker\DateRangePickerAsset;
class TestDateRangePickerAsset extends DateRangePickerAsset
{
public $sourcePath = '@tests/../../src/assets';
}
================================================
FILE: tests/functional/views/datepicker-widget.php
================================================
<?php
use dosamigos\datepicker\DatePicker;
/* @var $this yii\web\View */
/* @var $model tests\models\Post */
?>
<?= DatePicker::widget([
'model' => $model,
'attribute' => 'create_time',
]) ?>
================================================
FILE: tests/functional/views/daterangepicker-widget.php
================================================
<?php
use tests\overrides\TestDateRangePicker;
/* @var $this yii\web\View */
/* @var $model tests\models\Post */
?>
<?= TestDateRangePicker::widget([
'model' => $model,
'attribute' => 'date_from',
'attributeTo' => 'date_to'
]) ?>
================================================
FILE: tests/functional/views/layouts/main.php
================================================
<?php
/* @var $this \yii\web\View */
/* @var $content string */
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html>
<head>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
================================================
FILE: tests/functional/views/layouts/rawlayout.php
================================================
<?php
/* @var $this \yii\web\View */
?><?php $this->beginPage(); ?>1<?php $this->head(); ?>2<?php $this->beginBody(); ?>3<?php $this->endBody(); ?>4<?php $this->endPage(); ?>
gitextract_2641p111/
├── .gitattributes
├── .gitignore
├── .scrutinizer.yml
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── composer.json
├── phpunit.xml.dist
├── src/
│ ├── DatePicker.php
│ ├── DatePickerAsset.php
│ ├── DatePickerLanguageAsset.php
│ ├── DatePickerTrait.php
│ ├── DateRangePicker.php
│ ├── DateRangePickerAsset.php
│ └── assets/
│ └── css/
│ └── bootstrap-daterangepicker.css
└── tests/
└── functional/
├── AssetManager.php
├── DatePickerAssetTest.php
├── DatePickerLanguageAssetTest.php
├── DatePickerTest.php
├── DateRangePickerAssetTest.php
├── DateRangePickerTest.php
├── TestCase.php
├── assets/
│ └── .gitignore
├── bootstrap.php
├── models/
│ └── Post.php
├── overrides/
│ ├── TestDatePicker.php
│ ├── TestDatePickerLanguageAsset.php
│ ├── TestDateRangePicker.php
│ └── TestDateRangePickerAsset.php
└── views/
├── datepicker-widget.php
├── daterangepicker-widget.php
└── layouts/
├── main.php
└── rawlayout.php
SYMBOL INDEX (51 symbols across 18 files)
FILE: src/DatePicker.php
class DatePicker (line 21) | class DatePicker extends InputWidget
method init (line 42) | public function init()
method run (line 61) | public function run()
method registerClientScript (line 87) | public function registerClientScript()
FILE: src/DatePickerAsset.php
class DatePickerAsset (line 19) | class DatePickerAsset extends AssetBundle
FILE: src/DatePickerLanguageAsset.php
class DatePickerLanguageAsset (line 19) | class DatePickerLanguageAsset extends AssetBundle
FILE: src/DatePickerTrait.php
type DatePickerTrait (line 17) | trait DatePickerTrait
FILE: src/DateRangePicker.php
class DateRangePicker (line 22) | class DateRangePicker extends InputWidget
method init (line 60) | public function init()
method run (line 81) | public function run()
method registerClientScript (line 123) | public function registerClientScript()
FILE: src/DateRangePickerAsset.php
class DateRangePickerAsset (line 19) | class DateRangePickerAsset extends AssetBundle
FILE: tests/functional/AssetManager.php
class AssetManager (line 13) | class AssetManager extends \yii\web\AssetManager
method hash (line 21) | public function hash($path) {
FILE: tests/functional/DatePickerAssetTest.php
class DatePickerAssetTest (line 9) | class DatePickerAssetTest extends TestCase
method testRegister (line 11) | public function testRegister()
FILE: tests/functional/DatePickerLanguageAssetTest.php
class DatePickerLanguageAssetTest (line 9) | class DatePickerLanguageAssetTest extends TestCase
method testRegister (line 11) | public function testRegister()
FILE: tests/functional/DatePickerTest.php
class DatePickerTest (line 13) | class DatePickerTest extends TestCase
method testRenderWithModel (line 16) | public function testRenderWithModel()
method testRenderWithNameAndValue (line 29) | public function testRenderWithNameAndValue()
method testRenderInline (line 41) | public function testRenderInline()
method testRenderWithSize (line 54) | public function testRenderWithSize()
method testDatePickerRegisterPluginScriptMethod (line 68) | public function testDatePickerRegisterPluginScriptMethod()
method testWidget (line 99) | public function testWidget()
FILE: tests/functional/DateRangePickerAssetTest.php
class DateRangePickerAssetTest (line 8) | class DateRangePickerAssetTest extends TestCase
method testRegister (line 10) | public function testRegister()
FILE: tests/functional/DateRangePickerTest.php
class DateRangePickerTest (line 13) | class DateRangePickerTest extends TestCase
method testRenderWithModel (line 16) | public function testRenderWithModel()
method testRenderWithNameAndValue (line 34) | public function testRenderWithNameAndValue()
method testRenderWithSize (line 48) | public function testRenderWithSize()
method testWrongConfig (line 62) | public function testWrongConfig() {
method testDateRangePickerRegisterPluginScriptMethod (line 68) | public function testDateRangePickerRegisterPluginScriptMethod()
method testWidget (line 102) | public function testWidget()
FILE: tests/functional/TestCase.php
class TestCase (line 11) | abstract class TestCase extends \PHPUnit_Framework_TestCase
method setUp (line 18) | protected function setUp()
method tearDown (line 40) | protected function tearDown()
method mockApplication (line 46) | protected function mockApplication($config = [], $appClass = '\yii\con...
method mockWebApplication (line 60) | protected function mockWebApplication($config = [], $appClass = '\yii\...
method getVendorPath (line 81) | protected function getVendorPath()
method destroyApplication (line 89) | protected function destroyApplication()
method getView (line 99) | protected function getView()
method assertEqualsWithoutLE (line 115) | public function assertEqualsWithoutLE($expected, $actual)
FILE: tests/functional/models/Post.php
class Post (line 8) | class Post extends ActiveRecord
method getDb (line 16) | public static function getDb()
FILE: tests/functional/overrides/TestDatePicker.php
class TestDatePicker (line 9) | class TestDatePicker extends DatePicker
method registerClientScript (line 14) | public function registerClientScript()
FILE: tests/functional/overrides/TestDatePickerLanguageAsset.php
class TestDatePickerLanguageAsset (line 7) | class TestDatePickerLanguageAsset extends DatePickerLanguageAsset
FILE: tests/functional/overrides/TestDateRangePicker.php
class TestDateRangePicker (line 9) | class TestDateRangePicker extends DateRangePicker
method registerClientScript (line 14) | public function registerClientScript()
FILE: tests/functional/overrides/TestDateRangePickerAsset.php
class TestDateRangePickerAsset (line 18) | class TestDateRangePickerAsset extends DateRangePickerAsset
Condensed preview — 35 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (49K chars).
[
{
"path": ".gitattributes",
"chars": 395,
"preview": "# Path-based git attributes\n# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html\n\n# Ignore all test and"
},
{
"path": ".gitignore",
"chars": 285,
"preview": "build\n#composer.lock\ndocs\nvendor\n\n# cache directories\nThumbs.db\n*.DS_Store\n*.empty\n\n#phpstorm project files\n.idea\n\n#netb"
},
{
"path": ".scrutinizer.yml",
"chars": 911,
"preview": "filter:\n excluded_paths: [tests/*]\nchecks:\n php:\n code_rating: true\n remove_extra_empty_lines: true\n"
},
{
"path": ".travis.yml",
"chars": 493,
"preview": "language: php\n\nphp:\n - 5.5\n - 5.6\n\ninstall:\n - composer self-update\n - composer global require \"fxp/composer-asset-p"
},
{
"path": "CHANGELOG.md",
"chars": 132,
"preview": "# Changelog\n\n## 1.0.5 - 2015-04-02\n\n## Changed \n- Added CHANGELOG.md file\n\n## Fixed \n- Fixed asset registration bug when"
},
{
"path": "CONTRIBUTING.md",
"chars": 1240,
"preview": "# Contributing\n\nContributions are **welcome** and will be fully **credited**.\n\nWe accept contributions via Pull Requests"
},
{
"path": "LICENSE.md",
"chars": 1554,
"preview": "# The BSD License (BSD)\n\nCopyright (c) 2013-2015, 2amigOS! Consulting Group LLC.\n\n> Redistribution and use in source and"
},
{
"path": "README.md",
"chars": 4987,
"preview": "Bootstrap DatePicker Widget for Yii2\n====================================\n\n[ 2013-2016 2amigOS! Consulting Group LLC\n * @link http://2amigos.us\n * @license htt"
},
{
"path": "src/DatePickerAsset.php",
"chars": 748,
"preview": "<?php\n/**\n * @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC\n * @link http://2amigos.us\n * @license htt"
},
{
"path": "src/DatePickerLanguageAsset.php",
"chars": 646,
"preview": "<?php\n/**\n * @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC\n * @link http://2amigos.us\n * @license htt"
},
{
"path": "src/DatePickerTrait.php",
"chars": 1309,
"preview": "<?php\n/**\n * @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC\n * @link http://2amigos.us\n * @license htt"
},
{
"path": "src/DateRangePicker.php",
"chars": 5378,
"preview": "<?php\n/**\n * @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC\n * @link http://2amigos.us\n * @license htt"
},
{
"path": "src/DateRangePickerAsset.php",
"chars": 718,
"preview": "<?php\n/**\n * @copyright Copyright (c) 2013-2016 2amigOS! Consulting Group LLC\n * @link http://2amigos.us\n * @license htt"
},
{
"path": "src/assets/css/bootstrap-daterangepicker.css",
"chars": 624,
"preview": "/*!\n * Custom styling. Removing padding when using DateRangePicker.\n */\n.datepicker {\n z-index: 1151 !important;\n}\n\n."
},
{
"path": "tests/functional/AssetManager.php",
"chars": 573,
"preview": "<?php\n/**\n * @link https://github.com/2amigos/yii2-date-picker-widget\n * @copyright Copyright (c) 2013-2016 2amigOS! Con"
},
{
"path": "tests/functional/DatePickerAssetTest.php",
"chars": 877,
"preview": "<?php\n\nnamespace tests;\n\n\nuse dosamigos\\datepicker\\DatePickerAsset;\nuse yii\\web\\AssetBundle;\n\nclass DatePickerAssetTest "
},
{
"path": "tests/functional/DatePickerLanguageAssetTest.php",
"chars": 750,
"preview": "<?php\n\nnamespace tests;\n\n\nuse tests\\overrides\\TestDatePickerLanguageAsset;\nuse yii\\web\\AssetBundle;\n\nclass DatePickerLan"
},
{
"path": "tests/functional/DatePickerTest.php",
"chars": 3809,
"preview": "<?php\n\nnamespace tests;\n\n\nuse dosamigos\\datepicker\\DatePicker;\nuse tests\\models\\Post;\nuse tests\\overrides\\TestDatePicker"
},
{
"path": "tests/functional/DateRangePickerAssetTest.php",
"chars": 834,
"preview": "<?php\n\nnamespace tests;\n\nuse tests\\overrides\\TestDateRangePickerAsset;\nuse yii\\web\\AssetBundle;\n\nclass DateRangePickerAs"
},
{
"path": "tests/functional/DateRangePickerTest.php",
"chars": 4280,
"preview": "<?php\n\nnamespace tests;\n\nuse Yii;\nuse dosamigos\\datepicker\\DateRangePicker;\nuse tests\\models\\Post;\nuse tests\\overrides\\T"
},
{
"path": "tests/functional/TestCase.php",
"chars": 3127,
"preview": "<?php\n\nnamespace tests;\n\nuse yii\\helpers\\ArrayHelper;\nuse yii\\web\\View;\n\n/**\n * This is the base class for all tests.\n *"
},
{
"path": "tests/functional/assets/.gitignore",
"chars": 14,
"preview": "*\n!.gitignore\n"
},
{
"path": "tests/functional/bootstrap.php",
"chars": 369,
"preview": "<?php\nerror_reporting(-1);\ndefine('YII_ENABLE_ERROR_HANDLER', false);\ndefine('YII_DEBUG', true);\n$_SERVER['SCRIPT_NAME']"
},
{
"path": "tests/functional/models/Post.php",
"chars": 262,
"preview": "<?php\n\nnamespace tests\\models;\n\n\nuse yii\\db\\ActiveRecord;\n\nclass Post extends ActiveRecord\n{\n public $date_from;\n "
},
{
"path": "tests/functional/overrides/TestDatePicker.php",
"chars": 1406,
"preview": "<?php\nnamespace tests\\overrides;\n\nuse dosamigos\\datepicker\\DatePicker;\nuse dosamigos\\datepicker\\DatePickerAsset;\nuse yii"
},
{
"path": "tests/functional/overrides/TestDatePickerLanguageAsset.php",
"chars": 238,
"preview": "<?php\n\nnamespace tests\\overrides;\n\nuse dosamigos\\datepicker\\DatePickerLanguageAsset;\n\nclass TestDatePickerLanguageAsset "
},
{
"path": "tests/functional/overrides/TestDateRangePicker.php",
"chars": 1448,
"preview": "<?php\nnamespace tests\\overrides;\n\nuse dosamigos\\datepicker\\DateRangePicker;\nuse yii\\helpers\\Html;\nuse yii\\helpers\\Json;\n"
},
{
"path": "tests/functional/overrides/TestDateRangePickerAsset.php",
"chars": 401,
"preview": "<?php\n/**\n *\n * TestDateRangePickerAssset.php\n *\n * Date: 20/03/15\n * Time: 13:38\n * @author Antonio Ramirez <amigo.cobo"
},
{
"path": "tests/functional/views/datepicker-widget.php",
"chars": 203,
"preview": "<?php\n\nuse dosamigos\\datepicker\\DatePicker;\n\n/* @var $this yii\\web\\View */\n/* @var $model tests\\models\\Post */\n?>\n\n<?= D"
},
{
"path": "tests/functional/views/daterangepicker-widget.php",
"chars": 244,
"preview": "<?php\nuse tests\\overrides\\TestDateRangePicker;\n\n/* @var $this yii\\web\\View */\n/* @var $model tests\\models\\Post */\n?>\n\n<?"
},
{
"path": "tests/functional/views/layouts/main.php",
"chars": 276,
"preview": "<?php\n/* @var $this \\yii\\web\\View */\n/* @var $content string */\n?>\n\n<?php $this->beginPage() ?>\n<!DOCTYPE html>\n<html>\n<"
},
{
"path": "tests/functional/views/layouts/rawlayout.php",
"chars": 175,
"preview": "<?php\n/* @var $this \\yii\\web\\View */\n?><?php $this->beginPage(); ?>1<?php $this->head(); ?>2<?php $this->beginBody(); ?>"
}
]
About this extraction
This page contains the full source code of the 2amigos/yii2-date-picker-widget GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 35 files (43.8 KB), approximately 12.1k tokens, and a symbol index with 51 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.