Skip to content

Commit

Permalink
Merge pull request #17 from twiro/integration
Browse files Browse the repository at this point in the history
Release 1.3
  • Loading branch information
twiro committed Mar 21, 2016
2 parents 531e262 + cd82351 commit a636944
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 72 deletions.
10 changes: 10 additions & 0 deletions LICENCE.TXT
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
All source code included in the „Slider Field“ Symphony
Extension archive is, unless otherwise specified, released under the MIT
licence as follows:

----- begin license block -----

Copyright 2010-2016 Giel Berkers, Roman Klein

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand All @@ -15,3 +23,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

----- end license block -----
8 changes: 6 additions & 2 deletions assets/slider.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
/* SYMPHONY : FIELD SETTINGS
----------------------------------------------------------- */


div.field-slider input {
.field-slider input {
display: none;
}

.field-slider i {
color: #222;
}





Expand Down
6 changes: 3 additions & 3 deletions assets/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
var label = $(".slider-field-label-value", this);
var range = input.data('range') == 1;
var connect = (range) ? true : false;
var min = parseInt(input.data('min-range'));
var max = parseInt(input.data('max-range'));
var step = parseInt(input.data('increment-value'));
var min = parseInt(input.data('minRange'));
var max = parseInt(input.data('maxRange'));
var step = parseInt(input.data('incrementValue'));
var value = input.val();
var values = input.val().split('-');

Expand Down
12 changes: 8 additions & 4 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
<name github="twiro" symphony="roman">Roman Klein</name>
<website>http://romanklein.com</website>
</author>
<author>
<name github="TwistedInteractive" symphony="TwistedInteractive">Twisted Interactive</name>
<website>http://www.twisted.nl</website>
</author>
</authors>
<releases>
<release version="1.3" date="2016-03-21" min="2.3.0" max="2.x.x">
- Added support for publish filtering (Symphony 2.6+)
- Improved Field Validation (fixes [#13](https://github.com/twiro/slider/issues/13]))
- Enabled datasource parameters
</release>
<release version="1.2" date="2016-03-10" min="2.3.0" max="2.5.x">
- Added prepareTableValue (2.5 compatibility)
</release>
Expand All @@ -38,4 +39,7 @@
</release>
<release version="0.2" date="2011-12-16" min="2.3.0" />
</releases>
<media>
<item type="image" url="https://cloud.githubusercontent.com/assets/870227/13916199/71cc4c68-ef59-11e5-9810-c217b6e64aa9.png">Publish Area UI</item>
</media>
</extension>
86 changes: 61 additions & 25 deletions fields/field.slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,45 @@ public function createTable() {
}
}

public function canFilter() {
return true;
}

public function canFilter(){
public function allowDatasourceParamOutput() {
return true;
}

public function fetchFilterableOperators() {
return array(
array(
'title' => 'is',
'filter' => ' ',
'help' => __('Find values that are an exact match for the given number(s).')
),
array(
'title' => 'less than',
'filter' => 'less than ',
'help' => __('Less than %s', array('<code>$x</code>'))
),
array(
'title' => 'greater than',
'filter' => 'greater than ',
'help' => __('Greater than %s', array('<code>$x</code>'))
),
array(
'title' => 'between',
'filter' => '',
'help' => __('Find values between two values with %s to %s', array(
'<code>$x</code>',
'<code>$y</code>'
))
),
);
}

public function fetchSuggestionTypes() {
return array('static');
}


/*-------------------------------------------------------------------------------------------------
Expand All @@ -68,34 +102,37 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {

parent::displaySettingsPanel($wrapper, $errors);

/* Field Sort Order */
$sortorder = $this->get('sortorder');

/* Fieldset & Group */
$fieldset = new XMLElement('fieldset');
$group = new XMLElement('div', NULL, array('class' => 'two columns'));

/* Minimum Value */
$min_label = Widget::Label(__('Minimum value'));
$min_label->setAttribute('class', 'column');
$min_label->appendChild(Widget::Input('fields['.$this->get('sortorder').'][min_value]', $this->get('min_range')));
if (isset($errors['min_value'])) {
$group->appendChild(Widget::Error($min_label, $errors['min_value']));
$min_label->appendChild(Widget::Input('fields['.$sortorder.'][min_range]', $this->get('min_range')));
if (isset($errors['min_range'])) {
$group->appendChild(Widget::Error($min_label, $errors['min_range']));
} else {
$group->appendChild($min_label);
}

/* Maximum Value */
$max_label = Widget::Label(__('Maximum value'));
$max_label->setAttribute('class', 'column');
$max_label->appendChild(Widget::Input('fields['.$this->get('sortorder').'][max_value]', $this->get('max_range')));
if (isset($errors['max_value'])) {
$group->appendChild(Widget::Error($max_label, $errors['max_value']));
$max_label->appendChild(Widget::Input('fields['.$sortorder.'][max_range]', $this->get('max_range')));
if (isset($errors['max_range'])) {
$group->appendChild(Widget::Error($max_label, $errors['max_range']));
} else {
$group->appendChild($max_label);
}

/* Start Value */
$start_label = Widget::Label(__('Start Value'));
$start_label->setAttribute('class', 'column');
$start_label->appendChild(Widget::Input('fields['.$this->get('sortorder').'][start_value]', $this->get('start_value')));
$start_label->appendChild(Widget::Input('fields['.$sortorder.'][start_value]', $this->get('start_value')));
if (isset($errors['start_value'])) {
$group->appendChild(Widget::Error($start_label, $errors['start_value']));
} else {
Expand All @@ -105,7 +142,7 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
/* Incremental Value */
$inc_label = Widget::Label(__('Incremental value'));
$inc_label->setAttribute('class', 'column');
$inc_label->appendChild(Widget::Input('fields['.$this->get('sortorder').'][increment_value]', $this->get('increment_value')));
$inc_label->appendChild(Widget::Input('fields['.$sortorder.'][increment_value]', $this->get('increment_value')));
if (isset($errors['increment_value'])) {
$group->appendChild(Widget::Error($inc_label, $errors['increment_value']));
} else {
Expand All @@ -115,7 +152,7 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
/* Enable Range Mode */
$range_label = Widget::Label();
$range_label->setAttribute('class', 'column');
$attributes = array('type'=>'checkbox', 'name'=>'fields['.$this->get('sortorder').'][range]', 'value'=>'yes');
$attributes = array('type'=>'checkbox', 'name'=>'fields['.$sortorder.'][range]', 'value'=>'yes');
if($this->get('range') == 1) {$attributes['checked'] = 'checked';}
$range_checkbox = new XMLElement('input', ' '.__('Enable range mode <i>(Adds a second handle for selecting a value range)</i>'), $attributes);
$range_label->appendChild($range_checkbox);
Expand All @@ -125,7 +162,6 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
$wrapper->appendChild($fieldset);

/* Fieldset (Default Settings) */

$fieldset = new XMLElement('fieldset');
$this->appendShowColumnCheckbox($fieldset);
$wrapper->appendChild($fieldset);
Expand All @@ -142,26 +178,26 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
*/

public function checkFields(&$errors, $checkForDuplicates=true) {

if(!is_array($errors)) $errors = array();

$check['min_value'] = $this->get('min_value');
$check['max_value'] = $this->get('max_value');
$check['min_range'] = $this->get('min_range');
$check['max_range'] = $this->get('max_range');
$check['start_value'] = $this->get('start_value');
$check['increment_value'] = $this->get('increment_value');

// Validate Minimum Value
if($check['min_value'] == '') {
$errors['min_value'] = __('Minimum Value must not be empty. Please fill in a natural number.');
} else if (!preg_match('/^[0-9]+$/', $check['min_value'])) {
$errors['min_value'] = __('Minimum Value must be a natural number.');
if($check['min_range'] == '') {
$errors['min_range'] = __('Minimum Value must not be empty. Please fill in a natural number.');
} else if (!preg_match('/^[0-9]+$/', $check['min_range'])) {
$errors['min_range'] = __('Minimum Value must be a natural number.');
}

// Validate Maximum Value
if($check['max_value'] == '') {
$errors['max_value'] = __('Maximum Value must not be empty. Please fill in a natural number.');
} else if (!preg_match('/^[0-9]+$/', $check['max_value'])) {
$errors['max_value'] = __('Maximum Value must be a natural number.');
if($check['max_range'] == '') {
$errors['max_range'] = __('Maximum Value must not be empty. Please fill in a natural number.');
} else if (!preg_match('/^[0-9]+$/', $check['max_range'])) {
$errors['max_range'] = __('Maximum Value must be a natural number.');
}

// Validate Start Value
Expand Down Expand Up @@ -193,9 +229,9 @@ public function commit() {
$fields = array();
$fields['field_id'] = $id;
$fields['range'] = $this->get('range') == false ? 0 : 1;
$fields['min_range'] = $this->get('min_value');
$fields['max_range'] = $this->get('max_value');
$fields['start_value'] = $this->get('start_value') == '' ? $this->get('min_value') : $this->get('start_value');
$fields['min_range'] = $this->get('min_range');
$fields['max_range'] = $this->get('max_range');
$fields['start_value'] = $this->get('start_value') == '' ? $this->get('min_range') : $this->get('start_value');
$fields['increment_value'] = $this->get('increment_value') == '' ? '0' : $this->get('increment_value');

Symphony::Database()->query("DELETE FROM `tbl_fields_".$this->handle()."` WHERE `field_id` = '$id' LIMIT 1");
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

A slider with a configurable value range (minimum – maximum, e.g. `0``100`) that can either be used with a single handle (select a single value, e.g. `50`) or with two handles (select a value range, e.g. `40``50`).

![Symphony CMS Slider Field - Publish Area UI](https://cloud.githubusercontent.com/assets/870227/13916199/71cc4c68-ef59-11e5-9810-c217b6e64aa9.png)


## 1. Installation

Expand Down Expand Up @@ -62,3 +64,9 @@ Entries filtered by slider field will be returned as result …
* ... if the entry's slider defines a **single value** that lies **within** a **range of filter values**.
* ... if the entry's slider defines a **value range** and a **single filter value** is **within** that range.
* ... if the entry's slider defines a **value range** that lies **within** a **range of filter values**.



## 4. Acknowledgements ##

This extension was originally developed by [Giel Berkers](https://github.com/kanduvisla) for [Twisted Interactive](https://github.com/TwistedInteractive).
76 changes: 38 additions & 38 deletions tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@

## Tests – Single Values

###### Performed with Slider Field 1.2 and Symphony CMS 2.3.1, 2.4.0 and 2.5.2
###### Performed with Slider Field 1.3 and Symphony CMS 2.3.1, 2.4.0, 2.5.2 (DF only) and 2.6.2 (DF and PF)

| Nr. | Filter Mode | Filter Value | Expected Result | DF | PF |
| :--- | :--- | :--- | :--- | :--- | :--- |
| 1.1 | **is** | `0` | **1** | :white_check_mark: | |
| 1.2 | **is** | `1` | **2** | :white_check_mark: | |
| 1.3 | **is** | `99` | **4** | :white_check_mark: | |
| 1.4 | **is** | `99, 100` | **4**, **5** | :white_check_mark: | |
| 1.5 | **is** | `99 + 100` || :white_check_mark: | |
| 2.1 | **less than** | `less than 0` || :white_check_mark: | |
| 2.2 | **less than** | `less than 10` | **1**, **2**, **3** | :white_check_mark: | |
| 2.3 | **less than** | `< 100` | **1**, **2**, **3**, **4** | :white_check_mark: | |
| 3.1 | **greater than** | `greater than 0` | **2**, **3**, **4**, **5** | :white_check_mark: | |
| 3.2 | **greater than** | `greater than 10` | **4**, **5** | :white_check_mark: | |
| 3.3 | **greater than** | `> 100` || :white_check_mark: | |
| 3.4 | **greater than** + **less than** | `> 1 + < 100` | **3**, **4** | :white_check_mark: | |
| 4.1 | **between** | `0 to 1` | **1**, **2** | :white_check_mark: | |
| 4.2 | **between** | `0 to 10` | **1**, **2**, **3** | :white_check_mark: | |
| 4.3 | **between** | `0 to 100` | **1**, **2**, **3**, **4**, **5** | :white_check_mark: | |
| 4.3 | **between** | `1-99` | **2**, **3**, **4** | :white_check_mark: | |
| 4.4 | **between** | `0-1, 99-100` | **1**, **2**, **4**, **5** | :white_check_mark: | |
| 1.1 | **is** | `0` | **1** | :white_check_mark: | :white_check_mark: |
| 1.2 | **is** | `1` | **2** | :white_check_mark: | :white_check_mark: |
| 1.3 | **is** | `99` | **4** | :white_check_mark: | :white_check_mark: |
| 1.4 | **is** | `99, 100` | **4**, **5** | :white_check_mark: | :white_check_mark: |
| 1.5 | **is** | `99 + 100` || :white_check_mark: | :x: |
| 2.1 | **less than** | `less than 0` || :white_check_mark: | :white_check_mark: |
| 2.2 | **less than** | `less than 10` | **1**, **2**, **3** | :white_check_mark: | :white_check_mark: |
| 2.3 | **less than** | `< 100` | **1**, **2**, **3**, **4** | :white_check_mark: | |
| 3.1 | **greater than** | `greater than 0` | **2**, **3**, **4**, **5** | :white_check_mark: | :white_check_mark: |
| 3.2 | **greater than** | `greater than 10` | **4**, **5** | :white_check_mark: | :white_check_mark: |
| 3.3 | **greater than** | `> 100` || :white_check_mark: | |
| 3.4 | **greater than** + **less than** | `> 1 + < 100` | **3**, **4** | :white_check_mark: | |
| 4.1 | **between** | `0 to 1` | **1**, **2** | :white_check_mark: | :white_check_mark: |
| 4.2 | **between** | `0 to 10` | **1**, **2**, **3** | :white_check_mark: | :white_check_mark: |
| 4.3 | **between** | `0 to 100` | **1**, **2**, **3**, **4**, **5** | :white_check_mark: | :white_check_mark: |
| 4.3 | **between** | `1-99` | **2**, **3**, **4** | :white_check_mark: | :white_check_mark: |
| 4.4 | **between** | `0-1, 99-100` | **1**, **2**, **4**, **5** | :white_check_mark: | :white_check_mark: |

<sup>
<strong>DF</strong> = Datasource Filtering
Expand All @@ -63,29 +63,29 @@

## Tests – Value Range

###### Performed with Slider Field 1.2 and Symphony CMS 2.3.1, 2.4.0 and 2.5.2
###### Performed with Slider Field 1.3 and Symphony CMS 2.3.1, 2.4.0, 2.5.2 (DF only) and 2.6.2 (DF and PF)

| Nr. | Filter Mode | Filter Value | Expected Result | DF | PF |
| :--- | :--- | :--- | :--- | :--- | :--- |
| 1.1 | **is** | `0` | **1** | :white_check_mark: | |
| 1.2 | **is** | `1` | **1**, **2** | :white_check_mark: | |
| 1.3 | **is** | `99` | **4** | :white_check_mark: | |
| 1.4 | **is** | `99, 100` | **4**, **5** | :white_check_mark: | |
| 1.5 | **is** | `99 + 100` | **4** | :white_check_mark: | |
| 2.1 | **less than** | `less than 0` || :white_check_mark: | |
| 2.2 | **less than** | `less than 10` | **1** | :white_check_mark: | |
| 2.3 | **less than** | `< 100` | **1**, **2**, **3** | :white_check_mark: | |
| 3.1 | **greater than** | `greater than 0` | **2**, **3**, **4**, **5** | :white_check_mark: | |
| 3.2 | **greater than** | `greater than 10` | **4**, **5** | :white_check_mark: | |
| 3.3 | **greater than** | `> 100` || :white_check_mark: | |
| 3.4 | **greater than** + **less than** | `> 1 + < 100` | **3** | :white_check_mark: | |
| 4.1 | **between** | `0 to 1` | **1** | :white_check_mark: | |
| 4.2 | **between** | `0 to 10` || :white_check_mark: | |
| 4.3 | **between** | `9 to 10` | **2**, **3** | :white_check_mark: | |
| 4.4 | **between** | `50-75` | **3**, **4** | :white_check_mark: | |
| 4.4 | **between** | `0-100` || :white_check_mark: | |
| 4.5 | **between** | `0-1, 50-75` | **1**, **3**, **4** | :white_check_mark: | |
| 4.6 | **between** | `50-75 + 80-90` | **3**, **4** | :white_check_mark: | |
| 1.1 | **is** | `0` | **1** | :white_check_mark: | :white_check_mark: |
| 1.2 | **is** | `1` | **1**, **2** | :white_check_mark: | :white_check_mark: |
| 1.3 | **is** | `99` | **4** | :white_check_mark: | :white_check_mark: |
| 1.4 | **is** | `99, 100` | **4**, **5** | :white_check_mark: | :white_check_mark: |
| 1.5 | **is** | `99 + 100` | **4** | :white_check_mark: | :white_check_mark: |
| 2.1 | **less than** | `less than 0` || :white_check_mark: | :white_check_mark: |
| 2.2 | **less than** | `less than 10` | **1** | :white_check_mark: | :white_check_mark: |
| 2.3 | **less than** | `< 100` | **1**, **2**, **3** | :white_check_mark: | |
| 3.1 | **greater than** | `greater than 0` | **2**, **3**, **4**, **5** | :white_check_mark: | :white_check_mark: |
| 3.2 | **greater than** | `greater than 10` | **4**, **5** | :white_check_mark: | :white_check_mark: |
| 3.3 | **greater than** | `> 100` || :white_check_mark: | |
| 3.4 | **greater than** + **less than** | `> 1 + < 100` | **3** | :white_check_mark: | |
| 4.1 | **between** | `0 to 1` | **1** | :white_check_mark: | :white_check_mark: |
| 4.2 | **between** | `0 to 10` || :white_check_mark: | :white_check_mark: |
| 4.3 | **between** | `9 to 10` | **2**, **3** | :white_check_mark: | :white_check_mark: |
| 4.4 | **between** | `50-75` | **3**, **4** | :white_check_mark: | :white_check_mark: |
| 4.4 | **between** | `0-100` || :white_check_mark: | :white_check_mark: |
| 4.5 | **between** | `0-1, 50-75` | **1**, **3**, **4** | :white_check_mark: | :white_check_mark: |
| 4.6 | **between** | `50-75 + 80-90` | **3**, **4** | :white_check_mark: | :white_check_mark: |

<sup>
<strong>DF</strong> = Datasource Filtering
Expand Down

0 comments on commit a636944

Please sign in to comment.