MvxLang binding syntax for SharedTextSource - mvvm

I'm using the MvvmCross Json Localisation plugin. Everything works well for View Model specific resource files using a TextSource property on the View Models.
I've added SharedTextSource and ErrorTextSource properties on the View Models however I can't find an example of how to use the Android MvxLang binding shortcut with these. I think it's something like:
local:MvxLang="Text Buy, Path=SharedTextSource"
However I get told "You cannot specify ConverterParameter more than once". Do I have to use the longhand binding for shared and error text sources?
Incidendally, MvvmCross is one of the best frameworks I've ever used.

The parser for Lang bindings is in https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Binding/Parse/Binding/Lang/MvxLanguageBindingParser.cs
It parses 4 things for each Lang binding:
Key - the text lookup - used as parameter to the Converter
Source - defaults to "TextSource" - essentially this is used as the binding Path
Converter - the value converter used (defaults to "Language")
FallbackValue - the value to use for missing Source - useful for design time data
So for your binding, you can use
lang:MvxLang="Text Buy, Source=SharedTextSource"

Related

How to access Method Names from source object in Rule Definition

In our implementation of the Rules Engine we have a test form similar to Rule Test Form on the online demo on "Business Rules Engine Demo". What we would like to do is conditionally show only the Test Fields for the items in use in the rule. We are doing this by grabbing the rule.definition JSON from the ruleeditor then look for the items which we can conditionally create using AngularJS's ng-if directive. This works great with Fields. If the user selects a method, our method of parsing the string is failing. What it appears is the Field Names are stored in the JSON as plain text however the Method Names are not. Is there a way we can configure the control to either A not encrypt the method names or is there a way that we can tap into the encryption to identify if a method is in use in our rule? Thanks in advance.
Methods and actions can have overloads which the Code Effects rule editor supports. Therefore, we can't have multiple menu entries with the same name. Instead, we use a signature hash on all in-rule methods and rule actions regardless of whether it has an overload or not to make them unique on the client.
You need to have either the Full Source or the Editor Source license in order to change the code to either stop that hashing, or tap into the process, or implement it your own way. You don't have that option with any other Code Effects perpetual license.

Cannot initialize model with custom CombiTable1D without instance of Modelica CombiTable1D

My objective is to create a 1D/2D lookup table that can read a variable sized array in JSON file without having to specify a statically sized Modelica array parameter.
I started out by trying to extend ExternData to implement a custom table based on a suggestion in a github issue: https://github.com/modelica-3rdparty/ExternData/issues/34#issuecomment-718552210
The steps outlined were:
Create your own copy of a CombiTable, modify it to accept a data access object and a stable name, see code snippet below
Create a duplicate of the ExternalCombiTable1D, which instead references your own CombiTable data object
Create a c-function which reads the data directly from the json and stores it into a table object, which is then passed to the MSL
function ModelicaStandardTables_CombiTable1D_init2
I've implemented all three steps to make a custom CombiTable1D block which populates a dynamic sized table from ExternData JSON functions. Package code below:
https://github.com/vsskanth/ExternData.CustomTable
In this package, there are 3 experiments of relevance to this issue. All experiments compile but only only one experiment works:
ExternData.Examples.JSONTestVariableArrayBroken.mo - Single instance of custom CombiTable1D - does not initialize
ExternData.Examples.JSONTestArrayCombi2DBroken.mo - Custom CombiTable1D and instance of Modelica CombiTable2D - does not initialize
ExternData.Examples.JSONTestVariableArrayWorking.mo - Custom CombiTable1D and a couple instances of Modelica CombiTable1D - works as expected
I am trying to find out why my custom CombiTable1D implementation initializes and runs only when there is at least one instance of Modelica CombiTable1D present in the experiment. I made sure to link ModelicaStandardTables.h and ModelicaStandardTables.lib libraries in my own implementation, checked for warnings in dsbuild.txt and compilation seems to be fine.
For some reason, the constructor function for the custom ExternalCombiTable1D external object (ExternData.Types.ExternalCombiTable1D) does not return and hence the custom CombiTable1D block (ExternData.Tables.CombiTable1D) is not able to initialize when there are no instances of Modelica CombiTable1D tables in the model.
I would appreciate any thoughts on why this is happening and how to overcome it.
IDE - Dymola 2021x
OS - Windows 10
Compiler - Visual Studio 2019
#tbeu has been generous enough to add JSON support to
https://github.com/tbeu/ModelicaTableAdditions which renders this issue moot since I can just use that package with ExternData.
Its still interesting as to why this happens though. Seems like a Dymola translation bug.

Is there any difference between the syntax used for TypoScript constants and the syntax for "Extension Configuration"?

For both "TypoScript constants" and "Extension Configuration" (as defined in ext_conf_template.txt) use a common syntax. They are documented here:
Constants (in "TypoScript Template Reference")
Extension Configuration (in "TYPO3 Explained")
An example:
# cat=basic; type=string; label=Some title
title =
Line 1 describes data type, category etc. of the variable.
Alternatively, we might have something like this:
tx_plugins.my_plugin {
# cat=basic; type=string; label=Some title
title =
}
Besides this rather simple example, there are some more things you can do with this.
Where TypoScript constants and Extension Configuration are stored and how they are used is completely different, but I am wondering if we just look at the syntax and the features you can use - is it the same?
e.g.
the available datatypes (boolean, integer etc.)
that you can't use multiline values
that you can use environment variables
how to access files
how to do localization
The reason I ask: To streamline the documentation and also I use this in my own extensions.
Short Answer
The syntax used for TS template constants and extension configuration is the same but there are some minor differences for the available types currently.
Deep Analysis
Extension Configuration
For TYPO3 CMS version 6 the extension manager and configuration was rewriten from scratch based on Extbase and using the FormEngine. Available types are:
int: integer values
int+: positive integer values only
integer: alias for int
color: color picker
wrap: wrap, lines are separated finally by | for the saved value
offset: offset field
options: select
boolean: checkbox
user: user function is used for rendering
small: small text field
string: text field
input: alias for string, only for backwards compatibility, many extensions depend on that
default: alias for string, only for backwards compatibility, many extensions depend on that
Source is available here: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/ViewHelpers/Form/TypoScriptConstantsViewHelper.php#L36
TypoScript Template Constant Editor
On the other hand the TypoScript template constant editor was never rewriten to make use of the FormEngine and has it's own implementation. Here the following types are additionally available:
comment: a checkbox to switch a constant
files: file selection
Source is available here: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php#L993
Other Questions
that you can't use multiline values
That's almost true for the TS constant editor but there is the wrap type to achieve a multiline like functionality. For the extension configuration there are the small and string types.
For the other questions I'm currently not aware of and have to investigate a little bit deeper first:
that you can use environment variables
how to access files
how to do localization
As Typoscript is a configuration it can be used in multiple ways. And TYPO3 uses it differntly. So you have to diferentiate.
Constants can be used only for frontend rendering. there they are a shortcut to use a given value in different places.
Or to easily configure something (extension) without knowledge of detailed setup. Therefore you have the Constant-Editor where you can define constants which got a special information/ comment. It's like the TCA, a help to build forms and automaticaly have some validators for data. as TS-constants only are strings which can be used in the setup you do not have real data types. it is just a configuration to have some validation in the Constant-Editor.
Aside from some recursive replacement (up to a level of 10) of constants in constants definition you have no further options to compute a value.
In Typoscript setup you have (meanwhile) stdWrap funtionality nearly everywhere.
But especially extensions don't evaluate it everywhere. so in some places you have an extension configuration in setup where you only can insert fixed strings. (like in the constants)
on the other hand:
how can an extension be configured (with TYPO3-tools)?
Aside from the Typoscript setup (where you can use the constants), which primarily is used for the frontend rendering (*) you have a global option to configure extensions with the extension manager.
This data is stored serialized in typo3conf/LocalConfiguration.php. since TYPO3 9 unserialized.
It can be accessed in frontend and backend and works globaly, while the frontend typoscript or TSconfig is dependend on the page (and user).
This brings us to the third part of configuration: TSconfig
We have page-TSconfig and user-TSconfig. In pages, be_users and be_groups you can define a configuration with typoscript syntax. This can be enhanced with 'global' PHP code of extensions which inject further configuration in ext_localconf.php and ext_tables.php (or the successors in /Configuration/TCA/ and /Configuration/TCA/Overrides/)
(*) some extensions evaluate the frontend typoscript for configuration of backend modules or plugins-options

Use DAMP datatypes as Macro Parameters in Umbraco

I'm just starting to look at using the DAMP media picker within Umbraco. I'd like to be able to create a custom Macro that can be used in the Editor. Within that Macro I'd like users to be able to pick one or more Media items (i.e. a set of images for an Image Gallery).
The DAMP Media Pickers let me do exactly this, be the relevant DataTypes only seem to be available as Generic Properties of Document Types.
Is there a way to use the DAMP media Pickers from within as Custom Macro Parameters.
I've searched around and can find very little on what would be a very useful feature.
From reading some of the DAMP source code (http://damp.codeplex.com/SourceControl/changeset/view/b3b45c70ce29#DAMP.RazorModel/DAMP_Item.cs) it looks like the DAMP node picker will be stored just like a ucomponents multinodepicker.
If so then DAMP pickers (like multinodepickers) should be stored as XML - and can then be used as a macro parameter (http://our.umbraco.org/projects/backoffice-extensions/ucomponents/questionssuggestions/19682-Can-I-pass-a-MultiNode-as-Parameter-to-Macro)
Alternatively would a propertyTypePickerMultiple work (http://our.umbraco.org/forum/developers/xslt/8135-Looping-through-all-values-of-a-propertyTypePickerMultiple-in-XSLT)

i18n in Symfony Forms

Is there any way I can use the format_number_choice function inside of a actions file. In fact I need to use it for a Form error message.
'max_size' => 'File is too large (maximum is %max_size% bytes).',
In English it's simply "bytes", but in other languages the syntax changes after a certain value (for example if the number is greater than 20 it's: "20 of bytes").
I can use parenthesis, of course, but if the framework offers support for doing this specific thing, why not to use it?!
The way it's currently implemented in the 1.4 branch, you can define only one translation per message using il18n XML files.
What you could do is create a custom validator which inherits the current validator (sfValidatorFile in your example) and does the size checking in the doClean method before calling its parent's method.
I suggest you take a look at the source to see how it works : sfValidatorFile
The correct way to handle number ranges for translation is explained here in the Definitive Guide. I won't reproduce it here as the documentation itself is clear and concise. Note however that the string is not extracted automatically by the i18n-extract task, so you need to add it manually - again, the documentation explains this.
So yes, you can use the format_number_choice() function inside an action - you just need to load the helper inside the action like this:
sfContext::getInstance()->getConfiguration()->loadHelpers('I18N');