Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Helpers\Form;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -37,7 +37,7 @@ class _Item extends FormAbstract
|
||||
'minAjaxLength' => int // Number of characters to type before selector appears
|
||||
* 'where' => array // Array of additional where array( array( 'foo=?', 1 ) )
|
||||
* );
|
||||
* @encode
|
||||
* @endcode
|
||||
*/
|
||||
protected $defaultOptions = array(
|
||||
'class' => NULL,
|
||||
@@ -49,17 +49,7 @@ class _Item extends FormAbstract
|
||||
'minAjaxLength' => 3,
|
||||
'where' => array()
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
call_user_func_array( 'parent::__construct', func_get_args() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get HTML
|
||||
*
|
||||
@@ -88,12 +78,12 @@ class _Item extends FormAbstract
|
||||
$field = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['title'];
|
||||
$where = array( array( $field . " LIKE CONCAT('%', ?, '%')", \IPS\Request::i()->q ) );
|
||||
$idField = $class::$databaseColumnId;
|
||||
if ( isset( $class::$databaseColumnMap['container'] ) and is_array( $this->options['containerIds'] ) and count( $this->options['containerIds'] ) )
|
||||
if ( isset( $class::$databaseColumnMap['container'] ) and \is_array( $this->options['containerIds'] ) and \count( $this->options['containerIds'] ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'], $this->options['containerIds'] ) );
|
||||
}
|
||||
|
||||
if ( isset( $this->options['where'] ) and count( $this->options['where'] ) )
|
||||
if ( isset( $this->options['where'] ) and \count( $this->options['where'] ) )
|
||||
{
|
||||
$where = array_merge( $where, $this->options['where'] );
|
||||
}
|
||||
@@ -102,7 +92,7 @@ class _Item extends FormAbstract
|
||||
{
|
||||
$results[] = array(
|
||||
'id' => $item->$idField,
|
||||
'html' => call_user_func( $template, $item )
|
||||
'html' => $template( $item )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,12 +137,20 @@ class _Item extends FormAbstract
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->value = ( is_string( $this->value ) ) ? explode( ',', $this->value ) : $this->value;
|
||||
/* $this->value may be a single, numeric, ID, so look for that to avoid a Countable error */
|
||||
if ( \is_numeric( $this->value ) )
|
||||
{
|
||||
$this->value = array( $this->value );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->value = ( \is_string( $this->value ) ) ? explode( ',', $this->value ) : $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $this->value ) )
|
||||
if ( \count( $this->value ) )
|
||||
{
|
||||
if ( is_array( $this->options['orderResults'] ) )
|
||||
if ( \is_array( $this->options['orderResults'] ) )
|
||||
{
|
||||
if ( isset( $itemClass::$databaseColumnMap[ $this->options['orderResults'][0] ] ) )
|
||||
{
|
||||
@@ -180,11 +178,11 @@ class _Item extends FormAbstract
|
||||
*/
|
||||
public static function stringValue( $value )
|
||||
{
|
||||
if ( is_array( $value ) )
|
||||
if ( \is_array( $value ) )
|
||||
{
|
||||
return implode( ',', array_keys( $value ) );
|
||||
}
|
||||
elseif ( is_object( $value ) )
|
||||
elseif ( \is_object( $value ) )
|
||||
{
|
||||
return $value->_id;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user