Version 4.7.13
This commit is contained in:
1 parent
fd22d99e69
commit
7124a02564
954 files changed
+29277
-59308
No files matched your search
+63
-7
@@ -1439,7 +1439,7 @@ class _Lang extends \IPS\Node\Model
|
||||
|
||||
$buttons = array_merge( $buttons, parent::getButtons( $url, $subnode ) );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'languages', 'lang_words' ) AND !$this->marketplace_id )
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'languages', 'lang_words' ) )
|
||||
{
|
||||
$buttons['upload'] = array(
|
||||
'icon' => 'upload',
|
||||
@@ -1751,9 +1751,47 @@ class _Lang extends \IPS\Node\Model
|
||||
*/
|
||||
public function stripVLETags( $output )
|
||||
{
|
||||
/* We accidentally called stripVLE for each response, even if VLE was disabled, which had a side effect of casting everything to a string which we really want and need */
|
||||
if ( ! static::vleActive() )
|
||||
{
|
||||
if( !\is_array( $output ) )
|
||||
{
|
||||
return (string) $output;
|
||||
}
|
||||
|
||||
$replacement = array();
|
||||
foreach ( $output as $key => $value )
|
||||
{
|
||||
$replacement[ $key ] = $this->stripVLETags( $value );
|
||||
}
|
||||
|
||||
return $replacement;
|
||||
}
|
||||
|
||||
if( !\is_array( $output ) )
|
||||
{
|
||||
return preg_replace( "/#VLE#.+?#\!#\[(.+?)\]#\!##/", "$1", $output );
|
||||
preg_match_all( '/#VLE#(.+?)#!#/', (string) $output, $matches, PREG_SET_ORDER );
|
||||
|
||||
foreach( $matches as $match )
|
||||
{
|
||||
$replace = $match[1]; /* Possibly better than nothing */
|
||||
|
||||
if ( isset( $this->words[$match[1]] ) )
|
||||
{
|
||||
$replace = $this->words[$match[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$replace = $this->get( $match[1] );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
}
|
||||
$output = str_replace( $match[0], $replace, $output );
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
$replacement = array();
|
||||
@@ -2033,12 +2071,9 @@ class _Lang extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
/* Add VLE tags */
|
||||
if ( $values[ 'vle' ] and $replacement and isset( \IPS\Request::i(
|
||||
)->cookie[ 'vle_editor' ] ) and \IPS\Request::i()->cookie[ 'vle_editor' ] and \IPS\Member::loggedIn(
|
||||
)->hasAcpRestriction( 'core', 'languages', 'lang_words' )
|
||||
)
|
||||
if ( $values[ 'vle' ] and $replacement and static::vleActive() )
|
||||
{
|
||||
$replacement = "#VLE#{$values['key']}#!#[{$replacement}]#!##";
|
||||
$replacement = "#VLE#{$values['key']}#!#";
|
||||
}
|
||||
|
||||
if ( isset( $values[ 'options' ][ 'returnInto' ] ) )
|
||||
@@ -2106,4 +2141,25 @@ class _Lang extends \IPS\Node\Model
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'word_custom', NULL, FALSE, array( 'textArea' => TRUE ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the visual language editor active?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function vleActive(): bool
|
||||
{
|
||||
return isset( \IPS\Request::i()->cookie[ 'vle_editor' ] ) and \IPS\Request::i()->cookie[ 'vle_editor' ] and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'languages', 'lang_words' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of keys > values for the VLE
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function vleForJson(): array
|
||||
{
|
||||
/* if we're using IN_DEV, this is all of the strings, so... good luck I guess */
|
||||
return $this->words;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user