Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+64 -17
View File
@@ -2,9 +2,9 @@
/**
* @brief Translatable text input class for Form Builder
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 25 Mar 2013
* @version SVN_VERSION_NUMBER
*/
@@ -31,6 +31,7 @@ class _Translatable extends FormAbstract
'editor' => array(...), // If this needs to be an editor rather than a textbox, all the options of \IPS\Helpers\Form\Editor are available here
'textArea' => FALSE, // Makes a textarea rather than a textbox
'placeholder' => 'Example', // Placeholder
'sprintf' => array(), // sprintf options - useful when doing dynamic replacements (such as {var} which should be converted to %1$s or %s on save).
);
* @endcode
*/
@@ -38,13 +39,14 @@ class _Translatable extends FormAbstract
'key' => NULL,
'editor' => NULL,
'textArea' => FALSE,
'placeholder' => NULL
'placeholder' => NULL,
'sprintf' => NULL
);
/**
* @brief Editors
*/
protected $editors = array();
protected $editors = NULL;
/**
* Constructor
@@ -69,7 +71,14 @@ class _Translatable extends FormAbstract
$v = $v['word_custom'] ?: $v['word_default'];
if ( $v or !isset( $values[ $k ] ) )
{
$values[ $k ] = $v;
if ( is_array( $this->options['sprintf'] ) )
{
$values[ $k ] = vsprintf( $v, $this->options['sprintf'] );
}
else
{
$values[ $k ] = $v;
}
}
}
}
@@ -86,20 +95,35 @@ class _Translatable extends FormAbstract
$this->value = $values;
}
/* Init editors */
if ( isset( $this->options['editor'] ) )
{
foreach ( \IPS\Lang::getEnabledLanguages() as $lang )
{
$options = $this->options['editor'];
$options['autoSaveKey'] .= $lang->id;
$this->editors[ $lang->id ] = new Editor( "{$this->name}[{$lang->id}]", isset( $this->value[ $lang->id ] ) ? $this->value[ $lang->id ] : NULL, $this->required, $options );
}
}
/* Add flags.css */
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'flags.css', 'core', 'global' ) );
}
/**
* Get editors
*
* @return array
*/
protected function _getEditors()
{
if ( isset( $this->options['editor'] ) )
{
if ( $this->editors === NULL )
{
foreach ( \IPS\Lang::getEnabledLanguages() as $lang )
{
$options = $this->options['editor'];
$options['autoSaveKey'] .= $lang->id;
$this->editors[ $lang->id ] = new Editor( "{$this->name}[{$lang->id}]", isset( $this->value[ $lang->id ] ) ? $this->value[ $lang->id ] : NULL, $this->required, $options );
}
}
return $this->editors;
}
else
{
return array();
}
}
/**
* Get HTML
@@ -108,7 +132,30 @@ class _Translatable extends FormAbstract
*/
public function html()
{
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->translatable( $this->name, \IPS\Lang::getEnabledLanguages(), $this->value, $this->editors, $this->options['placeholder'], $this->options['textArea'], $this->required );
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->translatable( $this->name, \IPS\Lang::getEnabledLanguages(), $this->value, $this->_getEditors(), $this->options['placeholder'], $this->options['textArea'], $this->required );
}
/**
* Get Value
*
* @return string
*/
public function getValue()
{
if ( isset( $this->options['editor'] ) )
{
$return = array();
foreach ( $this->_getEditors() as $languageId => $editor )
{
$return[ $languageId ] = $editor->getValue();
}
return $return;
}
else
{
return parent::getValue();
}
}
/**