Skip to content

Commit

Permalink
Support for Symphony 2.5+
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo committed Dec 22, 2014
1 parent b382f97 commit 6c9a259
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ is, unless otherwise specified, released under the MIT licence as follows:

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

Copyright 2008-2012 Alistair Kearney, Allen Chang, Scott Hughes
Copyright 2008-2014 Alistair Kearney, Allen Chang, Scott Hughes

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Number Field

- Version: 1.6.1
- Author: Symphony Team ([email protected])
- Release Date: 25th February, 2013
- Requirements: Symphony 2.3.2

## Overview

Input field that provides built-in number validation and numeric sorting.

## Installation
Expand Down
9 changes: 6 additions & 3 deletions extension.meta.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension id="numberfield" status="released" xmlns="http://symphony-cms.com/schemas/extension/1.0">
<extension id="numberfield" status="released" xmlns="http://getsymphony.com/schemas/extension/1.0">
<name>Number Field</name>
<description>Dedicated number storage</description>
<repo type="github">https://github.com/symphonycms/numberfield</repo>
<url type="discuss">http://symphony-cms.com/discuss/thread/144/</url>
<url type="discuss">http://getsymphony.com/discuss/thread/144/</url>
<types>
<type>Field Types</type>
</types>
<authors>
<author>
<name github="symphonycms" symphony="team">Symphony Team</name>
<website>http://symphony-cms.com</website>
<website>http://getsymphony.com</website>
</author>
</authors>
<releases>
<release version="1.7" date="2014-12-22" min="2.5">
- Support Symphony 2.5+
</release>
<release version="1.6.1" date="2013-02-25" min="2.3.2" max="2.4.x">
- Update `ImportableField` support
- Add Russian language
Expand Down
52 changes: 49 additions & 3 deletions fields/field.number.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function prepareImportValue($data, $mode, $entry_id = null) {
*/
public function getExportModes() {
return array(
'getUnformatted' => ExportableField::UNFORMATTED,
'getUnformatted' => ExportableField::UNFORMATTED,
'getPostdata' => ExportableField::POSTDATA
);
}
Expand Down Expand Up @@ -192,6 +192,52 @@ public function prepareExportValue($data, $mode, $entry_id = null) {
Filtering:
-------------------------------------------------------------------------*/

/**
* Returns the keywords that this field supports for filtering. Note
* that no filter will do a simple 'straight' match on the value.
*
* @since Symphony 2.6.0
* @return array
*/
public function fetchFilterableOperators()
{
return array(
array(
'title' => 'is',
'filter' => ' ',
'help' => __('Find values that are an exact match for the given number.')
),
array(
'title' => 'less than',
'filter' => 'less than ',
'help' => __('Less than %s', array('<code>$x</code>'))
),
array(
'title' => 'equal to or less than',
'filter' => 'equal to or less than ',
'help' => __('Equal to or less than %s', array('<code>$x</code>'))
),
array(
'title' => 'greater than',
'filter' => 'greater than ',
'help' => __('Greater than %s', array('<code>$x</code>'))
),
array(
'title' => 'equal to or greater than',
'filter' => 'equal to or greater than ',
'help' => __('Equal to or greater than %s', array('<code>$x</code>'))
),
array(
'title' => 'between',
'filter' => 'x to y',
'help' => __('Find values between two values with, %s to %s', array(
'<code>$x</code>',
'<code>$y</code>'
))
),
);
}

public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) {
$field_id = $this->get('id');
$expression = " `t$field_id`.`value` ";
Expand All @@ -205,7 +251,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = fal
}

// Equal to or less/greater than X
else if(preg_match('/^(equal to or )?(less|greater) than (-?(?:\d+(?:\.\d+)?|\.\d+))$/i', $data[0], $match)) {
else if(preg_match('/^(equal to or )?(less|greater) than\s*(-?(?:\d+(?:\.\d+)?|\.\d+))$/i', $data[0], $match)) {

switch($match[2]) {
case 'less':
Expand All @@ -229,7 +275,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = fal
}

// Look for <=/< or >=/> symbols
else if(preg_match('/^(=?[<>]=?) (-?(?:\d+(?:\.\d+)?|\.\d+))$/i', $data[0], $match)) {
else if(preg_match('/^(=?[<>]=?)\s*(-?(?:\d+(?:\.\d+)?|\.\d+))$/i', $data[0], $match)) {

$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) ";
$where .= sprintf(
Expand Down

0 comments on commit 6c9a259

Please sign in to comment.