348 lines
10 KiB
Diff
348 lines
10 KiB
Diff
Index: FilterUtil/filter/filter.default.class.php
|
|
===================================================================
|
|
--- FilterUtil/filter/filter.default.class.php (revision 15)
|
|
+++ FilterUtil/filter/filter.default.class.php (working copy)
|
|
@@ -40,7 +40,7 @@
|
|
$this->activateOperators(array('eq', 'ne', 'lt', 'le', 'gt', 'ge', 'like', 'null', 'notnull'));
|
|
}
|
|
|
|
- if ($config['default'] == true || count($this->fields) <= 0) {
|
|
+ if ((isset($config['default']) && $config['default'] == true) || count($this->fields) <= 0) {
|
|
$this->default = true;
|
|
}
|
|
}
|
|
@@ -55,8 +55,9 @@
|
|
{
|
|
static $ops = array('eq', 'ne', 'lt', 'le', 'gt', 'ge', 'like', 'null', 'notnull');
|
|
if (is_array($op)) {
|
|
- foreach($op as $v)
|
|
+ foreach ($op as $v) {
|
|
$this->activateOperators($v);
|
|
+ }
|
|
} elseif (!empty($op) && array_search($op, $this->ops) === false && array_search($op, $ops) !== false) {
|
|
$this->ops[] = $op;
|
|
}
|
|
@@ -65,15 +66,17 @@
|
|
public function addFields($fields)
|
|
{
|
|
if (is_array($fields)) {
|
|
- foreach($fields as $fld)
|
|
+ foreach ($fields as $fld) {
|
|
$this->addFields($fld);
|
|
+ }
|
|
} elseif (!empty($fields) && $this->fieldExists($fields)
|
|
&& array_search($fields, $this->fields) === false) {
|
|
$this->fields[] = $fields;
|
|
}
|
|
}
|
|
|
|
- public function getFields() {
|
|
+ public function getFields()
|
|
+ {
|
|
return $this->fields;
|
|
}
|
|
|
|
@@ -111,7 +114,7 @@
|
|
}
|
|
switch ($op) {
|
|
case 'ne':
|
|
- return array('where' => $this->column[$field]." <> '" . $value . "'");
|
|
+ return array('where' => $this->column[$field] . " != '" . $value . "'");
|
|
break;
|
|
case 'lt':
|
|
return array('where' => $this->column[$field]." < '" . $value . "'");
|
|
@@ -132,7 +135,7 @@
|
|
return array('where' => $this->column[$field]." = '' OR ".$this->column[$field]." IS NULL");
|
|
break;
|
|
case 'notnull':
|
|
- return array('where' => $this->column[$field]." <> '' AND ".$this->column[$field]." IS NOT NULL");
|
|
+ return array('where' => $this->column[$field] . " != '' AND " . $this->column[$field] . " IS NOT NULL");
|
|
break;
|
|
case 'eq':
|
|
return array('where' => $this->column[$field]." = '" . $value . "'");
|
|
Index: FilterUtil/filter/filter.replaceName.class.php
|
|
===================================================================
|
|
--- FilterUtil/filter/filter.replaceName.class.php (revision 15)
|
|
+++ FilterUtil/filter/filter.replaceName.class.php (working copy)
|
|
@@ -27,8 +27,9 @@
|
|
public function __construct($config)
|
|
{
|
|
parent::__construct($config);
|
|
- if (isset($config['pair']) && is_array($config['pair']))
|
|
+ if (isset($config['pair']) && is_array($config['pair'])) {
|
|
$this->addPair($config['pair']);
|
|
+ }
|
|
}
|
|
|
|
/**
|
|
@@ -37,12 +38,14 @@
|
|
* @param mixed $pair Replace Pair
|
|
* @access public
|
|
*/
|
|
- public function addPair($pair) {
|
|
+ public function addPair($pair)
|
|
+ {
|
|
foreach ($pair as $f => $r) {
|
|
- if (is_array($r))
|
|
+ if (is_array($r)) {
|
|
$this->addPair($r);
|
|
- else
|
|
+ } else {
|
|
$this->pair[$f] = $r;
|
|
+ }
|
|
}
|
|
}
|
|
|
|
Index: FilterUtil/filter/filter.category.class.php
|
|
===================================================================
|
|
--- FilterUtil/filter/filter.category.class.php (revision 15)
|
|
+++ FilterUtil/filter/filter.category.class.php (working copy)
|
|
@@ -53,14 +53,16 @@
|
|
public function addFields($fields)
|
|
{
|
|
if (is_array($fields)) {
|
|
- foreach($fields as $fld)
|
|
+ foreach ($fields as $fld) {
|
|
$this->addFields($fld);
|
|
+ }
|
|
} elseif (!empty($fields) && !$this->fieldExists($fields) && array_search($fields, $this->fields) === false) {
|
|
$this->fields[] = $fields;
|
|
}
|
|
}
|
|
|
|
- public function getFields() {
|
|
+ public function getFields()
|
|
+ {
|
|
return $this->fields;
|
|
}
|
|
|
|
@@ -73,8 +75,9 @@
|
|
public function activateOperators($op)
|
|
{
|
|
if (is_array($op)) {
|
|
- foreach($op as $v)
|
|
+ foreach ($op as $v) {
|
|
$this->activateOperators($v);
|
|
+ }
|
|
} elseif (!empty($op) && array_search($op, $this->ops) === false && array_search($op, $this->availableOperators()) !== false) {
|
|
$this->ops[] = $op;
|
|
}
|
|
@@ -89,8 +92,9 @@
|
|
public function getOperators()
|
|
{
|
|
$fields = $this->getFields();
|
|
- if ($this->default == true)
|
|
+ if ($this->default == true) {
|
|
$fields[] = '-';
|
|
+ }
|
|
$ops = array();
|
|
foreach ($this->ops as $op) {
|
|
$ops[$op] = $fields;
|
|
@@ -104,7 +108,8 @@
|
|
* @see CategoryUtil
|
|
* @param mixed $property Category Property
|
|
*/
|
|
- public function setProperty($property) {
|
|
+ public function setProperty($property)
|
|
+ {
|
|
$this->property = (array) $property;
|
|
}
|
|
|
|
@@ -149,4 +154,4 @@
|
|
}
|
|
return array('where' => $where);
|
|
}
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|
|
Index: FilterUtil/filter/filter.date.class.php
|
|
===================================================================
|
|
--- FilterUtil/filter/filter.date.class.php (revision 15)
|
|
+++ FilterUtil/filter/filter.date.class.php (working copy)
|
|
@@ -53,8 +53,9 @@
|
|
public function activateOperators($op)
|
|
{
|
|
if (is_array($op)) {
|
|
- foreach($op as $v)
|
|
+ foreach ($op as $v) {
|
|
$this->activateOperators($v);
|
|
+ }
|
|
} elseif (!empty($op) && array_search($op, $this->ops) === false && array_search($op, $this->availableOperators()) !== false) {
|
|
$this->ops[] = $op;
|
|
}
|
|
@@ -63,15 +64,17 @@
|
|
public function addFields($fields)
|
|
{
|
|
if (is_array($fields)) {
|
|
- foreach($fields as $fld)
|
|
+ foreach ($fields as $fld) {
|
|
$this->addFields($fld);
|
|
+ }
|
|
} elseif (!empty($fields) && $this->fieldExists($fields)
|
|
&& array_search($fields, $this->fields) === false) {
|
|
$this->fields[] = $fields;
|
|
}
|
|
}
|
|
|
|
- public function getFields() {
|
|
+ public function getFields()
|
|
+ {
|
|
return $this->fields;
|
|
}
|
|
|
|
@@ -84,8 +87,9 @@
|
|
public function getOperators()
|
|
{
|
|
$fields = $this->getFields();
|
|
- if ($this->default == true)
|
|
+ if ($this->default == true) {
|
|
$fields[] = '-';
|
|
+ }
|
|
$ops = array();
|
|
foreach ($this->ops as $op) {
|
|
$ops[$op] = $fields;
|
|
@@ -142,7 +146,8 @@
|
|
return $time;
|
|
}
|
|
|
|
- private function makePeriod($date, $type) {
|
|
+ private function makePeriod($date, $type)
|
|
+ {
|
|
$datearray = getdate($date);
|
|
switch($type) {
|
|
case 'year':
|
|
@@ -154,8 +159,8 @@
|
|
$to = strtotime('+1 month', $from);
|
|
break;
|
|
/**case 'week':
|
|
- $from = DateUtil::getDatetime("substr ($date, 0, strpos ($date, ' '));
|
|
- $to = DateUtil::getDatetime("$from +1 year");
|
|
+ $from = DateUtil::getDatetime(substr($date, 0, strpos($date, ' '));
|
|
+ $to = DateUtil::getDatetime($from . ' +1 year');
|
|
break;*/
|
|
case 'day':
|
|
case 'tomorrow':
|
|
@@ -176,9 +181,11 @@
|
|
return array($from, $to);
|
|
}
|
|
|
|
- public function GetSQL($field, $op, $value) {
|
|
- if (array_search($op, $this->ops) === false || array_search($field, $this->fields) === false)
|
|
+ public function GetSQL($field, $op, $value)
|
|
+ {
|
|
+ if (array_search($op, $this->ops) === false || array_search($field, $this->fields) === false) {
|
|
return '';
|
|
+ }
|
|
$type = 'point';
|
|
if (preg_match('~^(year|month|week|day|hour|min):\s*(.*)$~i', $value, $res)) {
|
|
$type = strtolower($res[1]);
|
|
@@ -204,7 +211,7 @@
|
|
list($from, $to) = $this->makePeriod($time, $type);
|
|
$where = $this->column[$field].' < \''.DateUtil::getDatetime($from).'\' AND '.$this->column[$field].' >= \''.DateUtil::getDatetime($to).'\'';
|
|
} else {
|
|
- $where = $this->column[$field].' <> \''.DateUtil::getDatetime($time).'\'';
|
|
+ $where = $this->column[$field] . ' != \'' . DateUtil::getDatetime($time) . '\'';
|
|
}
|
|
break;
|
|
case 'gt':
|
|
@@ -231,4 +238,4 @@
|
|
|
|
}
|
|
}
|
|
-?>
|
|
\ No newline at end of file
|
|
+?>
|
|
Index: FilterUtil/FilterUtil_Common.class.php
|
|
===================================================================
|
|
--- FilterUtil/FilterUtil_Common.class.php (revision 15)
|
|
+++ FilterUtil/FilterUtil_Common.class.php (working copy)
|
|
@@ -89,7 +89,7 @@
|
|
*/
|
|
protected function setTable($table)
|
|
{
|
|
- $pntable =& pnDBGetTables();
|
|
+ $pntable = pnDBGetTables();
|
|
|
|
if (!isset($pntable[$table]) || !isset($pntable[$table . '_column'])) {
|
|
return false;
|
|
@@ -113,7 +113,7 @@
|
|
*/
|
|
protected function setJoin(&$join)
|
|
{
|
|
- $this->join =& $join;
|
|
+ $this->join = $join;
|
|
$this->addJoinToColumn();
|
|
}
|
|
|
|
@@ -125,11 +125,11 @@
|
|
*/
|
|
protected function addJoinToColumn()
|
|
{
|
|
- if (count($this->join) <= 0)
|
|
+ if (count($this->join) < 1) {
|
|
return;
|
|
|
|
- $pntable =& pnDBGetTables();
|
|
- $c =& $this->column;
|
|
+ $pntable = pnDBGetTables();
|
|
+ $c = $this->column;
|
|
// reset column array...
|
|
$c = $pntable[$this->pntable.'_column'];
|
|
// now add alias "tbl" to all fields
|
|
@@ -140,7 +140,7 @@
|
|
// add fields of all joins
|
|
$alias = 'a';
|
|
foreach ($this->join as &$join) {
|
|
- $jc =& $pntable[$join['join_table'].'_column'];
|
|
+ $jc = $pntable[$join['join_table'].'_column'];
|
|
foreach ($join['join_field'] as $k => $f) {
|
|
$a = $join['object_field_name'][$k];
|
|
if (isset($c[$a])) {
|
|
@@ -182,6 +182,6 @@
|
|
{
|
|
$config['table'] = $this->pntable;
|
|
$config['module'] = $this->module;
|
|
- $config['join'] =& $this->join;
|
|
+ $config['join'] = $this->join;
|
|
}
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|
|
Index: FilterUtil/FilterUtil_Plugin.class.php
|
|
===================================================================
|
|
--- FilterUtil/FilterUtil_Plugin.class.php (revision 15)
|
|
+++ FilterUtil/FilterUtil_Plugin.class.php (working copy)
|
|
@@ -101,7 +101,7 @@
|
|
$obj = new $class($config);
|
|
|
|
$this->plg[] = $obj;
|
|
- $obj =& end($this->plg);
|
|
+ $obj = end($this->plg);
|
|
$obj->setID(key($this->plg));
|
|
$this->registerPlugin(key($this->plg));
|
|
|
|
@@ -119,7 +119,7 @@
|
|
*/
|
|
private function registerPlugin($k)
|
|
{
|
|
- $obj =& $this->plg[$k];
|
|
+ $obj = $this->plg[$k];
|
|
if ($obj instanceof FilterUtil_Build) {
|
|
$ops = $obj->getOperators();
|
|
if (isset($ops) && is_array($ops)) {
|
|
@@ -187,7 +187,7 @@
|
|
public function replace($field, $op, $value)
|
|
{
|
|
foreach ($this->replaces as $k) {
|
|
- $obj =& $this->plg[$k];
|
|
+ $obj = $this->plg[$k];
|
|
list($field, $op, $value) = $obj->replace($field, $op, $value);
|
|
}
|
|
|
|
@@ -218,4 +218,4 @@
|
|
return '';
|
|
}
|
|
}
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|