Version 4.7.13
This commit is contained in:
1 parent
fd22d99e69
commit
7124a02564
954 files changed
+29277
-59308
No files matched your search
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace IPS\Helpers\Chart;
|
||||
|
||||
use IPS\Member;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
@@ -107,6 +109,16 @@ abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
*/
|
||||
public $showIntervals = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow user to adjust date range
|
||||
*/
|
||||
public $showDateRange = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Show save button
|
||||
*/
|
||||
public $showSave = TRUE;
|
||||
|
||||
/**
|
||||
* @brief If a warning about timezones needs to be shown
|
||||
*/
|
||||
@@ -367,48 +379,80 @@ abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
try
|
||||
{
|
||||
/* If we have filters, we can save them */
|
||||
if( \count( $this->availableFilters ) > 0 or $this->customFiltersForm )
|
||||
{
|
||||
/* Generate a form so we can save our filters as a new saved chart */
|
||||
$this->form = new \IPS\Helpers\Form;
|
||||
$this->form->class = 'ipsForm_vertical';
|
||||
/* Generate a form so we can save our filters as a new saved chart */
|
||||
$this->form = new \IPS\Helpers\Form;
|
||||
$this->form->class = 'ipsForm_vertical';
|
||||
|
||||
if ( $this->customFiltersForm )
|
||||
if ( $this->customFiltersForm )
|
||||
{
|
||||
if ( $customValues = $this->getCustomFiltersForm()->values( TRUE ) )
|
||||
{
|
||||
if ( $customValues = $this->getCustomFiltersForm()->values( TRUE ) )
|
||||
foreach( $customValues as $key => $value )
|
||||
{
|
||||
foreach( $customValues as $key => $value )
|
||||
{
|
||||
$this->form->hiddenValues['customform_' . $key ] = $value;
|
||||
}
|
||||
$this->form->hiddenValues['customform_' . $key ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a sub selector from a node form, add on the identifier and pass off to the form to show the ajax */
|
||||
if ( \IPS\Request::i()->_nodeSelectName )
|
||||
/* If we have a sub selector from a node form, add on the identifier and pass off to the form to show the ajax */
|
||||
if ( \IPS\Request::i()->_nodeSelectName )
|
||||
{
|
||||
\IPS\Request::i()->_nodeSelectName = $this->identifier . \IPS\Request::i()->_nodeSelectName;
|
||||
return (string) $this->getCustomFiltersForm();
|
||||
}
|
||||
|
||||
/* We have an existing chart ID */
|
||||
if( isset( \IPS\Request::i()->chartId ) AND \IPS\Request::i()->chartId != '_default' )
|
||||
{
|
||||
$title = '';
|
||||
|
||||
foreach( $this->loadAvailableChartTabs() as $chart )
|
||||
{
|
||||
\IPS\Request::i()->_nodeSelectName = $this->identifier . \IPS\Request::i()->_nodeSelectName;
|
||||
return (string) $this->getCustomFiltersForm();
|
||||
if( $chart['chart_id'] == \IPS\Request::i()->chartId )
|
||||
{
|
||||
$title = $chart['chart_title'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* We have an existing chart ID */
|
||||
if( isset( \IPS\Request::i()->chartId ) AND \IPS\Request::i()->chartId != '_default' )
|
||||
$custom = array();
|
||||
$chartFilters = ( isset( \IPS\Request::i()->chartFilters ) and \IPS\Request::i()->chartFilters ) ? \IPS\Request::i()->chartFilters : array();
|
||||
$this->timescale = $chart['chart_timescale'] ?? 'monthly';
|
||||
|
||||
foreach( \IPS\Request::i() as $key => $value )
|
||||
{
|
||||
$title = '';
|
||||
|
||||
foreach( $this->loadAvailableChartTabs() as $chart )
|
||||
if ( \mb_substr( $key, 0, 11 ) === 'customform_' )
|
||||
{
|
||||
if( $chart['chart_id'] == \IPS\Request::i()->chartId )
|
||||
{
|
||||
$title = $chart['chart_title'];
|
||||
break;
|
||||
}
|
||||
$custom[ preg_replace( '#' . $this->identifier . '#', '', $key ) ] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->form->add( new \IPS\Helpers\Form\Text( 'custom_chart_title', $title, TRUE ) );
|
||||
|
||||
if( $values = $this->form->values() )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_saved_charts', array( 'chart_title' => $values['custom_chart_title'] ), array( 'chart_id=? AND chart_member=?', \IPS\Request::i()->chartId, \IPS\Member::loggedIn()->member_id ) );
|
||||
|
||||
/* And then return the output we need */
|
||||
\IPS\Output::i()->json( array(
|
||||
'title' => $values['custom_chart_title']
|
||||
) );
|
||||
}
|
||||
|
||||
/* And we want to save our filter updates */
|
||||
if( isset( \IPS\Request::i()->saveFilters ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_saved_charts', array( 'chart_configuration' => json_encode( array_merge( $chartFilters, $custom ) ), 'chart_timescale' => \IPS\Request::i()->timescale ?? $this->timescale ?? 'monthly' ), array( 'chart_id=? AND chart_member=?', \IPS\Request::i()->chartId, \IPS\Member::loggedIn()->member_id ) );
|
||||
}
|
||||
}
|
||||
/* We are not viewing a saved chart */
|
||||
else
|
||||
{
|
||||
$this->form->add( new \IPS\Helpers\Form\Text( 'custom_chart_title', NULL, TRUE ) );
|
||||
|
||||
if( $values = $this->form->values() )
|
||||
{
|
||||
$custom = array();
|
||||
$chartFilters = ( isset( \IPS\Request::i()->chartFilters ) and \IPS\Request::i()->chartFilters ) ? \IPS\Request::i()->chartFilters : array();
|
||||
|
||||
foreach( \IPS\Request::i() as $key => $value )
|
||||
{
|
||||
if ( \mb_substr( $key, 0, 11 ) === 'customform_' )
|
||||
@@ -417,74 +461,40 @@ abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
}
|
||||
}
|
||||
|
||||
$this->form->add( new \IPS\Helpers\Form\Text( 'custom_chart_title', $title, TRUE ) );
|
||||
$chartFilters = ( isset( \IPS\Request::i()->chartFilters ) and \IPS\Request::i()->chartFilters ) ? \IPS\Request::i()->chartFilters : array();
|
||||
|
||||
/* Store the new chart */
|
||||
$id = \IPS\Db::i()->insert( 'core_saved_charts', array(
|
||||
'chart_member' => \IPS\Member::loggedIn()->member_id,
|
||||
'chart_controller' => \IPS\Request::i()->app . '_' . \IPS\Request::i()->module . '_' . \IPS\Request::i()->controller . ( \IPS\Request::i()->tab ? '_' . \IPS\Request::i()->tab : '' ),
|
||||
'chart_configuration' => json_encode( array_merge( $chartFilters, $custom ) ),
|
||||
'chart_timescale' => \IPS\Request::i()->timescale ?? $this->timescale ?? 'monthly',
|
||||
'chart_title' => $values['custom_chart_title'],
|
||||
) );
|
||||
|
||||
if( $values = $this->form->values() )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_saved_charts', array( 'chart_title' => $values['custom_chart_title'] ), array( 'chart_id=? AND chart_member=?', \IPS\Request::i()->chartId, \IPS\Member::loggedIn()->member_id ) );
|
||||
/* Set some input parameters */
|
||||
$this->url = $this->url->setQueryString( 'chartId', $id );
|
||||
\IPS\Request::i()->chartId = $id;
|
||||
\IPS\Request::i()->filters = array( $this->identifier => \IPS\Request::i()->chartFilters );
|
||||
|
||||
/* And then return the output we need */
|
||||
\IPS\Output::i()->json( array(
|
||||
'title' => $values['custom_chart_title']
|
||||
) );
|
||||
}
|
||||
|
||||
/* And we want to save our filter updates */
|
||||
if( isset( \IPS\Request::i()->saveFilters ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_saved_charts', array( 'chart_configuration' => json_encode( array_merge( $chartFilters, $custom ) ) ), array( 'chart_id=? AND chart_member=?', \IPS\Request::i()->chartId, \IPS\Member::loggedIn()->member_id ) );
|
||||
}
|
||||
}
|
||||
/* We are not viewing a saved chart */
|
||||
else
|
||||
{
|
||||
$this->form->add( new \IPS\Helpers\Form\Text( 'custom_chart_title', NULL, TRUE ) );
|
||||
$this->currentFilters = \IPS\Request::i()->filters;
|
||||
|
||||
if( $values = $this->form->values() )
|
||||
if ( isset( \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
$custom = array();
|
||||
foreach( \IPS\Request::i() as $key => $value )
|
||||
{
|
||||
if ( \mb_substr( $key, 0, 11 ) === 'customform_' )
|
||||
{
|
||||
$custom[ preg_replace( '#' . $this->identifier . '#', '', $key ) ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$chartFilters = ( isset( \IPS\Request::i()->chartFilters ) and \IPS\Request::i()->chartFilters ) ? \IPS\Request::i()->chartFilters : array();
|
||||
|
||||
/* Store the new chart */
|
||||
$id = \IPS\Db::i()->insert( 'core_saved_charts', array(
|
||||
'chart_member' => \IPS\Member::loggedIn()->member_id,
|
||||
'chart_controller' => \IPS\Request::i()->app . '_' . \IPS\Request::i()->module . '_' . \IPS\Request::i()->controller . ( \IPS\Request::i()->tab ? '_' . \IPS\Request::i()->tab : '' ),
|
||||
'chart_configuration' => json_encode( array_merge( $chartFilters, $custom ) ),
|
||||
'chart_title' => $values['custom_chart_title'],
|
||||
) );
|
||||
|
||||
/* Set some input parameters */
|
||||
$this->url = $this->url->setQueryString( 'chartId', $id );
|
||||
\IPS\Request::i()->chartId = $id;
|
||||
\IPS\Request::i()->filters = array( $this->identifier => \IPS\Request::i()->chartFilters );
|
||||
|
||||
$this->currentFilters = \IPS\Request::i()->filters;
|
||||
|
||||
if ( isset( \IPS\Request::i()->filters[ $this->identifier ] ) )
|
||||
{
|
||||
$this->url = $this->url->setQueryString( 'filters', array( $this->identifier => $this->currentFilters ) );
|
||||
}
|
||||
|
||||
/* Reset form, since template looks for it and it should not be set for a saved chart */
|
||||
$this->form = new \IPS\Helpers\Form;
|
||||
$this->form->class = 'ipsForm_vertical';
|
||||
$this->form->add( new \IPS\Helpers\Form\Text( 'custom_chart_title', $values['custom_chart_title'], TRUE ) );
|
||||
|
||||
/* And then return the output we need */
|
||||
\IPS\Output::i()->json( array(
|
||||
'tabHref' => $this->url->stripQueryString( 'filters' ),
|
||||
'chartId' => $id,
|
||||
'tabId' => md5( $this->url->acpQueryString() ),
|
||||
) );
|
||||
$this->url = $this->url->setQueryString( 'filters', array( $this->identifier => $this->currentFilters ) );
|
||||
}
|
||||
|
||||
/* Reset form, since template looks for it and it should not be set for a saved chart */
|
||||
$this->form = new \IPS\Helpers\Form;
|
||||
$this->form->class = 'ipsForm_vertical';
|
||||
$this->form->add( new \IPS\Helpers\Form\Text( 'custom_chart_title', $values['custom_chart_title'], TRUE ) );
|
||||
|
||||
/* And then return the output we need */
|
||||
\IPS\Output::i()->json( array(
|
||||
'tabHref' => $this->url->stripQueryString( 'filters' ),
|
||||
'chartId' => $id,
|
||||
'tabId' => md5( $this->url->acpQueryString() ),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,8 +517,14 @@ abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
else
|
||||
{
|
||||
$chartOutput = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->dynamicChart( $this, $output );
|
||||
|
||||
/* If we're not showing filter tabs, just return here. */
|
||||
if ( !$this->showFilterTabs )
|
||||
{
|
||||
return $chartOutput;
|
||||
}
|
||||
|
||||
if( ( \count( $this->availableFilters ) > 0 or $this->customFiltersForm ) AND ( !\IPS\Request::i()->isAjax() OR ( \IPS\Request::i()->tab AND !\IPS\Request::i()->chartId ) ) )
|
||||
if( !\IPS\Request::i()->isAjax() OR ( \IPS\Request::i()->tab AND !\IPS\Request::i()->chartId ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $this->getChartTabs(), ( isset( \IPS\Request::i()->chartId ) ) ? \IPS\Request::i()->chartId : NULL, $chartOutput, $this->url, 'chartId', 'ipsTabs_small ipsTabs_contained' );
|
||||
}
|
||||
@@ -527,11 +543,21 @@ abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
\IPS\IPS::exceptionHandler( $e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Show filter tabs
|
||||
*/
|
||||
public $showFilterTabs = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Cached tab data
|
||||
*/
|
||||
protected $availableChartTabs = NULL;
|
||||
|
||||
/**
|
||||
* @Brief Extension
|
||||
*/
|
||||
public $extension = NULL;
|
||||
|
||||
/**
|
||||
* Retrieve tabs based on saved charts
|
||||
@@ -559,11 +585,31 @@ abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
if( $this->availableChartTabs === NULL )
|
||||
{
|
||||
$this->availableChartTabs = iterator_to_array( \IPS\Db::i()->select( '*', 'core_saved_charts', array( 'chart_member=? AND chart_controller=?', \IPS\Member::loggedIn()->member_id, \IPS\Request::i()->app . '_' . \IPS\Request::i()->module . '_' . \IPS\Request::i()->controller . ( \IPS\Request::i()->tab ? '_' . \IPS\Request::i()->tab : '' ) ) ) );
|
||||
if ( $this->extension !== NULL )
|
||||
{
|
||||
$this->availableChartTabs = iterator_to_array( \IPS\Db::i()->select( '*', 'core_saved_charts', array( 'chart_member=? AND chart_controller=?', \IPS\Member::loggedIn()->member_id, $this->extension->controller ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->availableChartTabs = iterator_to_array( \IPS\Db::i()->select( '*', 'core_saved_charts', array( 'chart_member=? AND chart_controller=?', \IPS\Member::loggedIn()->member_id, \IPS\Request::i()->app . '_' . \IPS\Request::i()->module . '_' . \IPS\Request::i()->controller . ( \IPS\Request::i()->tab ? '_' . \IPS\Request::i()->tab : '' ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->availableChartTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set extension
|
||||
*
|
||||
* @param \IPS\core\Statistics\Chart $ext Extension
|
||||
* @return void
|
||||
*/
|
||||
public function setExtension( \IPS\core\Statistics\Chart $ext )
|
||||
{
|
||||
$this->extension = $ext;
|
||||
|
||||
$this->availableChartTabs = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip URL Filter
|
||||
@@ -685,10 +731,22 @@ abstract class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
$rawHeaders = $this->headers;
|
||||
}
|
||||
|
||||
|
||||
/* Ok this is a very horrible hack to get the language hashes converted into the real names and in a format
|
||||
that we can then reparse later. */
|
||||
$uglyHack = '';
|
||||
foreach( $rawHeaders AS $data )
|
||||
{
|
||||
$headers[] = $data['label'];
|
||||
$uglyHack .= str_replace( "\n", " ", $data['label'] ) . "\n";
|
||||
}
|
||||
|
||||
/* This really is awful */
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $uglyHack );
|
||||
|
||||
foreach( explode( "\n", trim( $uglyHack ) ) as $label )
|
||||
{
|
||||
/* Now we have the true string, eg: News, Now! instead of a language hash, eg: 77e90423a7642378a1590420cd66a465 so fputcsv can escape it correctly */
|
||||
$headers[] = $label;
|
||||
}
|
||||
fputcsv( $fh, $headers );
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ class _Editor extends FormAbstract
|
||||
|
||||
/* Don't minimize if we have a value */
|
||||
$name = isset( $options['editorId'] ) ? $options['editorId'] : $name;
|
||||
if ( ( !isset( $options['minimizeWithContent'] ) or !$options['minimizeWithContent'] ) and ( $defaultValue or \IPS\Request::i()->$name or ( isset( \IPS\Request::i()->cookie['vle_editor'] ) and \IPS\Request::i()->cookie['vle_editor'] ) ) )
|
||||
if ( ( !isset( $options['minimizeWithContent'] ) or !$options['minimizeWithContent'] ) and ( $defaultValue or \IPS\Request::i()->$name or ( \IPS\Lang::vleActive() ) ) )
|
||||
{
|
||||
$options['minimize'] = NULL;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class _Email extends Text
|
||||
public $childDefaultOptions = array(
|
||||
'accountEmail' => FALSE,
|
||||
'htmlAutocomplete' => "email",
|
||||
'bypassProfanity' => \IPS\Helpers\Form\Text::BYPASS_PROFANITY_ALL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -65,6 +66,12 @@ class _Email extends Text
|
||||
/* Check Banned and Allowed Emails only if the data are not coming from an administrator */
|
||||
if ( !\IPS\Member::loggedIn()->isAdmin() )
|
||||
{
|
||||
/* Check it's not known to be undeliverable */
|
||||
if ( \IPS\Email::emailIsBlocked( $value ) )
|
||||
{
|
||||
throw new \DomainException( 'member_email_blocked_info' );
|
||||
}
|
||||
|
||||
/* Check it's not a banned address */
|
||||
foreach ( \IPS\Db::i()->select( 'ban_content', 'core_banfilters', array( "ban_type=?", 'email' ) ) as $bannedEmail )
|
||||
{
|
||||
|
||||
@@ -51,22 +51,27 @@ class _Member extends Text
|
||||
public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array(), $customValidationCode=NULL, $prefix=NULL, $suffix=NULL, $id=NULL )
|
||||
{
|
||||
$this->defaultOptions['autocomplete'] = array(
|
||||
'source' => 'app=core&module=system&controller=ajax&do=findMember',
|
||||
'resultItemTemplate' => 'core.autocomplete.memberItem',
|
||||
'commaTrigger' => false,
|
||||
'unique' => true,
|
||||
'minAjaxLength' => 3,
|
||||
'disallowedCharacters' => array(),
|
||||
'lang' => 'mem_optional',
|
||||
'source' => 'app=core&module=system&controller=ajax&do=findMember',
|
||||
'resultItemTemplate' => 'core.autocomplete.memberItem',
|
||||
'commaTrigger' => false,
|
||||
'unique' => true,
|
||||
'minAjaxLength' => 3,
|
||||
'disallowedCharacters' => array(),
|
||||
'lang' => 'mem_optional',
|
||||
);
|
||||
if( \count( $options ) and array_key_exists( 'multiple', $options ) and $options['multiple'] > 0 )
|
||||
if (\count($options) and array_key_exists('multiple', $options) and $options['multiple'] > 0)
|
||||
{
|
||||
$this->defaultOptions['autocomplete']['maxItems'] = $options['multiple'];
|
||||
}
|
||||
elseif ( !array_key_exists( 'multiple', $options ) )
|
||||
} elseif (!array_key_exists('multiple', $options))
|
||||
{
|
||||
$this->defaultOptions['autocomplete']['maxItems'] = $this->childDefaultOptions['multiple'];
|
||||
}
|
||||
|
||||
/* Explicitly merge autocomplete options */
|
||||
if( array_key_exists('autocomplete', $options ) )
|
||||
{
|
||||
$options['autocomplete'] = array_merge( $options['autocomplete'], $this->defaultOptions['autocomplete'] );
|
||||
}
|
||||
|
||||
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ class _Text extends TextArea
|
||||
'resultItemTemplate'=> 'core.foo.bar', // Can be used to specify a custom JavaScript template to use for the result
|
||||
'minAjaxLength' => 3, // Minimum length of value before sending AJAX lookup call
|
||||
'disallowedCharacters' => array(), // An array of disallowed characters (default < > ' ")
|
||||
'minimized' => TRUE // Whether the autocomplete shows a 'choose' link to activate. Existing values or required = true will always override this.
|
||||
'minimized' => TRUE // Whether the autocomplete shows a 'choose' link to activate. Existing values or required = true will always override this.
|
||||
'alphabetical' => FALSE, // Force values to be sorted alphabetically.
|
||||
),
|
||||
'placeholder' => 'e.g. ...', // A placeholder (NB: Will only work on compatible browsers)
|
||||
'regex' => '/[A-Z]+/i', // RegEx of acceptable value
|
||||
@@ -202,6 +203,11 @@ class _Text extends TextArea
|
||||
{
|
||||
$return = array_filter( array_map( 'trim', explode( "\n", $return ) ) );
|
||||
}
|
||||
|
||||
if ( \is_array( $return ) AND isset( $this->options['autocomplete']['alphabetical'] ) AND $this->options['autocomplete']['alphabetical'] )
|
||||
{
|
||||
natcasesort( $return );
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove all invisible characters if this is a username */
|
||||
|
||||
@@ -244,7 +244,8 @@ class _Upload extends FormAbstract
|
||||
|
||||
/* If there is an error, an exception will be thrown and will be caught below like normal */
|
||||
\IPS\File::validateUpload( $fileArray, $this->options['allowedFileTypes'], $this->options['maxFileSize'] );
|
||||
|
||||
|
||||
$exif = NULL;
|
||||
if ( $fileObj->isImage() )
|
||||
{
|
||||
try
|
||||
@@ -254,6 +255,7 @@ class _Upload extends FormAbstract
|
||||
if( $image::exifSupported() )
|
||||
{
|
||||
$image->setExifData( $fileObj->contents() );
|
||||
$exif = $image->parseExif();
|
||||
}
|
||||
|
||||
$hasBeenResized = $image->resizeToMax( $this->options['image']['maxWidth'] ?? NULL, $this->options['image']['maxHeight'] ?? NULL );
|
||||
@@ -266,16 +268,17 @@ class _Upload extends FormAbstract
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
|
||||
$insertId = \IPS\Db::i()->insert( 'core_files_temp', array(
|
||||
'upload_key' => md5( $this->name . session_id() ),
|
||||
'filename' => $fileObj->originalFilename,
|
||||
'mime' => \IPS\File::getMimeType( $fileObj->originalFilename ),
|
||||
'contents' => (string) $fileObj,
|
||||
'time' => time(),
|
||||
'storage_extension' => $this->options['storageExtension']
|
||||
'storage_extension' => $this->options['storageExtension'],
|
||||
'exif' => $exif ? json_encode( $exif ) : NULL
|
||||
) );
|
||||
|
||||
|
||||
if ( $this->options['callback'] )
|
||||
{
|
||||
$callbackFunction = $this->options['callback'];
|
||||
@@ -466,7 +469,7 @@ class _Upload extends FormAbstract
|
||||
|
||||
/* The html() method is called more than once, however $this->value is wiped out so if it was an attachments array all of the array properties are lost */
|
||||
$templateFunction = $this->template;
|
||||
$this->builtHtml = $templateFunction( $this->name, $this->value, $this->options['minimize'], $maxFileSize, $this->options['maxFiles'], $this->maxChunkSize, $this->options['totalMaxSize'], $this->options['allowedFileTypes'], $uploadKey, $this->options['multiple'], $this->options['postKey'], $this->options['temporary'] or ( isset( \IPS\Request::i()->cookie['vle_editor'] ) and \IPS\Request::i()->cookie['vle_editor'] ), $this->options['template'], $existing, $this->options['default'], $this->options['supportsDelete'], $maxImageDims, $this->options['allowStockPhotos'] );
|
||||
$this->builtHtml = $templateFunction( $this->name, $this->value, $this->options['minimize'], $maxFileSize, $this->options['maxFiles'], $this->maxChunkSize, $this->options['totalMaxSize'], $this->options['allowedFileTypes'], $uploadKey, $this->options['multiple'], $this->options['postKey'], $this->options['temporary'] or ( \IPS\Lang::vleActive() ), $this->options['template'], $existing, $this->options['default'], $this->options['supportsDelete'], $maxImageDims, $this->options['allowStockPhotos'] );
|
||||
return $this->builtHtml;
|
||||
}
|
||||
|
||||
@@ -721,8 +724,9 @@ class _Upload extends FormAbstract
|
||||
{
|
||||
$options = $this->options;
|
||||
$canBeModerated = $options['canBeModerated'];
|
||||
$exifData = array();
|
||||
|
||||
$fileObjects = \IPS\File::createFromUploads( $this->options['storageExtension'], $fieldName, $this->options['allowedFileTypes'], $this->options['maxFileSize'], $this->options['totalMaxSize'], 0, function( $contents, $filename, $i ) use ( $options, &$requiresModeration, $canBeModerated )
|
||||
$fileObjects = \IPS\File::createFromUploads( $this->options['storageExtension'], $fieldName, $this->options['allowedFileTypes'], $this->options['maxFileSize'], $this->options['totalMaxSize'], 0, function( $contents, $filename, $i ) use ( $options, &$requiresModeration, $canBeModerated, &$exifData )
|
||||
{
|
||||
$ext = mb_strtolower( mb_substr( $filename, mb_strrpos( $filename, '.' ) + 1 ) );
|
||||
|
||||
@@ -740,6 +744,7 @@ class _Upload extends FormAbstract
|
||||
/* If type JPG, image handler may strip meta data on image output */
|
||||
if( $hasBeenResized OR $image->hasBeenRotated OR $image->type == 'jpeg' )
|
||||
{
|
||||
$exifData[ $i ] = $image->parseExif();
|
||||
$contents = (string) $image;
|
||||
}
|
||||
}
|
||||
@@ -748,14 +753,14 @@ class _Upload extends FormAbstract
|
||||
|
||||
return $contents;
|
||||
}, $this->options['storageContainer'], $this->options['obscure'] );
|
||||
|
||||
|
||||
foreach ( $fileObjects as $i => $fileObj )
|
||||
{
|
||||
$exif = NULL;
|
||||
|
||||
if( \IPS\Image::exifSupported() and $fileObj->isImage() and $fileObj->exifData )
|
||||
if( isset( $exifData[ $i ] ) AND $fileExifData = $exifData[ $i ] OR ( \IPS\Image::exifSupported() and $fileObj->isImage() and $fileExifData = $fileObj->exifData ) )
|
||||
{
|
||||
$exif = json_encode( $fileObj->exifData );
|
||||
$exif = json_encode( $fileExifData );
|
||||
}
|
||||
|
||||
$data = $this->populateTempData( array(
|
||||
|
||||
@@ -452,8 +452,8 @@ class _Content extends Table
|
||||
{
|
||||
$itemIds[] = $item->$idField;
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_reputation_index', array( 'rep_class=? AND ' . \IPS\Db::i()->in( 'item_id', $itemIds ), $class::$commentClass ) ) as $react )
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_reputation_index', array( 'rep_class=? AND ' . \IPS\Db::i()->in( 'item_id', $itemIds ), $class::$commentClass ), NULL, 1000 ) as $react )
|
||||
{
|
||||
$reactions[ $react['item_id'] ][] = $react;
|
||||
}
|
||||
@@ -1078,7 +1078,7 @@ class _Content extends Table
|
||||
$class = $this->class;
|
||||
|
||||
/* ID and Title columns should be ascending */
|
||||
if( $column != $this->defaultSortBy AND ( $column == $class::$databaseColumnId OR $column == $class::$databaseColumnMap[ 'title' ] ) )
|
||||
if( isset( $class::$databaseColumnMap[ 'title' ] ) AND $column != $this->defaultSortBy AND ( $column == $class::$databaseColumnId OR $column == $class::$databaseColumnMap[ 'title' ] ) )
|
||||
{
|
||||
return 'asc';
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ class _Db extends Table
|
||||
}
|
||||
|
||||
/* Count results (for pagination) */
|
||||
$count = $this->db->select( 'count(*)', $this->table, $where );
|
||||
$count = $this->db->select( 'count(*)', $this->table, $where, NULL, NULL, $this->groupBy );
|
||||
if ( \count( $this->joins ) )
|
||||
{
|
||||
foreach( $this->joins as $join )
|
||||
@@ -324,7 +324,9 @@ class _Db extends Table
|
||||
$count->join( $join['from'], ( isset( $join['where'] ) ? $join['where'] : null ), ( isset( $join['type'] ) ) ? $join['type'] : 'LEFT' );
|
||||
}
|
||||
}
|
||||
$count = $count->first();
|
||||
|
||||
$count = $this->groupBy ? $count->count() : $count->first();
|
||||
|
||||
$selectPrefix = ( $this->groupBy ) ? '' : $this->table . '.*, ';
|
||||
|
||||
/* Now get column headers */
|
||||
|
||||
Reference in new issue
Block a user