Sulu CMS 1.6: Is there a possibility to limit the number of images in media_selection? - sulu

Is there a possibility to limit the number of selectable images for the media_selection content type? According to the documentation there is none, but maybe there is still a way?
Reason is, that I want to allow to add an image to a text, but only one.
Maybe:
<property name="image" type="media_selection">
<param name="maxSelectionAmount" value="1"/>
</property>

There is nothing like that at the moment... What we have implement in the alphas of 2.0 is that the is a separate single_media_selection content type. This works well for limiting the assigned medias to one but still doesn't allow to restrict to an arbitrary number.

Related

ObservableValidator in .NET MAUI Toolkit - doc for EventTriggerBehavior?

In the .NET MAUI Community Toolkit MVVM samples there is this XAML:
<Grid>
<muxc:InfoBar
x:Name="SuccessInfoBar"
Title="Success"
Message="The form was filled in correctly."
Severity="Success">
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="FormSubmissionCompleted" SourceObject="{x:Bind ViewModel}">
<interactions:ChangePropertyAction
PropertyName="IsOpen"
TargetObject="{x:Bind SuccessInfoBar}"
Value="True" />
<interactions:ChangePropertyAction
PropertyName="IsOpen"
TargetObject="{x:Bind FailureInfoBar}"
Value="False" />
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</muxc:InfoBar>
Can you tell me where I find documentation on EventTriggerBehavior? Or for that matter, where I find interactivity and Interaction.Behaviors and ChangePropertyAction?
I don't see this documented, despite searching.
Also, while I have you, this same code says
SourceObject="{x:Bind ViewModel}
Is Bind the same things as Binding?
EventTriggerBehavior: Listens for a specific event on its source and executes an action when the event is fired, it has two configurable properties (EventName and SourceObject).
ChangePropertyAction: Action that will change a specified property to a specified value when invoked.
For more information about Behaviors, you can check the documentation: XamlBehaviors
Regarding Bind and Binding, the {x:Bind} markup extension official document explains:
The {x:Bind} markup extension—new for Windows 10—is an alternative to
{Binding}. {x:Bind} runs in less time and less memory than {Binding}
and supports better debugging.
The difference to note is that the default mode of {x:Bind} is OneTime, which is different from {Binding}, whose default mode is OneWay.
For a comprehensive comparison between {x:Bind} and {Binding}, you can read Data binding in depth.

Transformation of machineKey tag

We have to transform tag in which "decryptionKey" and "validationKey" will be different for our development and test environments.
We have tried to give different variables for validationKey and decryptionKey but confused with the xdt: Transform and xdt: Locator attribute as they will occur once in the same tag.
Suppose following is the web.config machineKey tag,
<machineKey decryptionKey="012345678910111213141516"
validation="SHA1" validationKey="235487512547896321458778996325456965542126364586965" />
We have to give transformation something like following,
<machineKey decryptionKey="#{DecryptionKey}#"
validation="SHA1"
validationKey="#{ValidationKey}#"
xdt:Transform="SetAttributes"
xdt:Locator="Match(decryptionKey)"
xdt:Transform="SetAttributes"
xdt:Locator="Match(validationKey)" />
Need this kind of a solution in which we have to give multiple variables within a single tag.
To set multiple attributes, you need to pass them into SetAttributes as a comma-delimited list.
This is documented here
However, if you are actually replacing all of the attributes, it might just be easier/cleaner to use xdt:Transform="Replace" and set the entire tag value in each configuration.

Setting a default list of items in project_attribute in a GNAT GPS Plugin

I'm working on a custom GNAT GPS plugin (for GPS 6.1.2).
My plugin XML creates a project attribute "example_list_of_files".
This is a list of strings, that correspond the names of Ada files in the project.
I want to default the entries in that list to "a.adb","b.adb","c.adb". However I've been unable to find the correct syntax for this. Instead i end up with a single string of all the values.
What i want to see is what happens when you manually add three elements, as shown below:
Here is the code for this example:
GPS.parse_xml('<?xml version="1.0" ?>' + """
<my_plugin>
<project_attribute
name="example_list_of_files"
label="example_list_of_files"
description="A description...."
package="MyPackage"
editor_page="MyPage"
editor_section="Build"
hide_in="wizard library_wizard"
omit_if_default="false"
list="true"
base_name_only="true">
<string type="file" filter="project" default="'a.adb','b.adb','c.adb' " />
</project_attribute>
</my_plugin>""");
Notice the string element with the project attribute default. Instead of a list of entries in the project manager it gives me a single entry, containing the string "'a.adb', 'b.adb', 'c.adb'".
Anyone got any ideas? I've also tried multiple string elements, adding brackets, braces, square-brackets, space separators, prefixing with 'array(' with no luck.
thanks
Matt
It seems indeed this is not supported. The standard plug-in projects.py has several list attributes, but all of them have a single value as the default. I'll check what can be done to improve here.
However, your approach might be wrong in the first place. The default you are setting only concerns the project editor. That means that if a user uses a default project (like project default is end default) and never goes through the project editor, your attribute example_list_of_files will in fact not exist (and have a default empty value). So it seems that this should in fact be handled in your plug-in, when you query the value of the attribute (like via GPS.Project.get_attribute_as_list). If that function returns an empty list, then use ("a.adb", "b.adb", "c.adb") instead. That way, things work fine even with a default, unedited project.
From the GPS User's Guide:
The tag accepts the following attributes:
[...]
list (boolean, default false)
If true, the project attribute contains a list of values, as opposed
to a single value. An example is the list of source directories in
standard projects.
In your example:
<string type="file" filter="project" default="'a.adb','b.adb','c.adb' " />
This is a single string value. Instead, you should specify a list of string values, like this:
<string type="file" filter="project" default="a.adb" />
<string type="file" filter="project" default="b.adb" />
<string type="file" filter="project" default="c.adb" />

Nutch crawler: Configure to accept only pages in English

How can I configure the Nutch crawler to crawl only English pages?
This is what I set in nutch-site.xml, but it does not work:
<property>
<name>http.accept.language</name>
<value>en-us,en-gb,en;q=0.7,*;q=0.3</value>
<description>Value of the "Accept-Language" request header field. This allows selecting non-English language as default one to retrieve. It is a useful setting for search engines build for certain national group.
</description>
</property>
The value you set: <value>en-us,en-gb,en;q=0.7,*;q=0.3</value> means that it prefers English but other languages (*) still there. For crawling only English pages, you should set value as below:
<value>en-us,en-gb,en</value>
To make sure, change the value in nutch-default.xml as well.
Hope this helps
-Le Quoc Do

Creating a working copy for Plone 4 custom content types

I have created a custom Plone content type in my package i.e. my.product.
I am in need of integrating a working copy support: so that a "published" document (in my case, a published content type) stays online while it is being edited. Basically, I want to take advantage of 'Working Copy Support (Iterate)' provided by plone.app.iterate to achieve what is explained here. This will provide me with ability to check-in/check-out my changes.
Is this possible in Plone 4 with custom content types using Archetypes? How would one go about it if yes?
I added the following two files inside my.product/my/product/profiles/default folder and it appears to work:
diff_tool.xml
<?xml version="1.0"?>
<object>
<difftypes>
<type portal_type="MyCustomType">
<field name="any" difftype="Compound Diff for AT types"/>
</type>
</difftypes>
</object>
repositorytool.xml
<?xml version="1.0"?>
<repositorytool>
<policymap>
<type name="MyCustomType">
<policy name="at_edit_autoversion"/>
<policy name="version_on_revert"/>
</type>
</policymap>
</repositorytool>
I have never used plone.app.iterate, but this is the generic approach how to solve the problem.
Actions are installed by plone.app.iterate GenericSetup profile. You can see actions here:
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/profiles/default/actions.xml
Pay note to the line *available_expr* which tells when to show the action or not. It points to helper view with the conditition.
The view is defined here
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/browser/configure.zcml#L7
The checks that are performed for the content item if it's archiveable
https://github.com/plone/plone.app.iterate/blob/master/plone/app/iterate/browser/control.py#L47
Most likely the failure comes from if not interfaces.IIterateAware.providedBy condition. Your custom contennt must declare this interface. However, you can confirm this putting a pdb breakpoint in checkin_allowed(self) and step it though line-by-line and see what happens with your content type.