Search in sources :

Example 61 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class ContentListViewerWidgetAction method validateLink.

protected void validateLink() {
    String pageLink = this.getWidget().getConfig().getProperty(IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK);
    boolean existsPageLink = pageLink != null && this.getPage(pageLink) != null;
    String linkDescrParamPrefix = IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK_DESCR + "_";
    if (existsPageLink || this.isMultilanguageParamValued(linkDescrParamPrefix)) {
        if (!existsPageLink) {
            this.addFieldError(IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK, this.getText("error.widget.listViewer.pageLink.required"));
        }
        Lang defaultLang = this.getLangManager().getDefaultLang();
        String defaultLinkDescrParam = linkDescrParamPrefix + defaultLang.getCode();
        String defaultLinkDescr = this.getWidget().getConfig().getProperty(defaultLinkDescrParam);
        if (defaultLinkDescr == null || defaultLinkDescr.length() == 0) {
            String[] args = { defaultLang.getDescr() };
            this.addFieldError(defaultLinkDescrParam, this.getText("error.widget.listViewer.defaultLangLink.required", args));
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 62 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class PageAction method checkTitles.

protected void checkTitles() {
    this.updateTitles();
    Iterator<Lang> langsIter = this.getLangManager().getLangs().iterator();
    while (langsIter.hasNext()) {
        Lang lang = langsIter.next();
        String title = (String) this.getTitles().get(lang.getCode());
        if (null == title || title.trim().length() == 0) {
            String[] args = { lang.getDescr() };
            String titleKey = "lang" + lang.getCode();
            this.addFieldError(titleKey, this.getText("error.page.insertTitle", args));
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 63 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class BaseAction method getTitle.

/**
 * Return a title by current lang.
 * @param defaultValue The default value returned in case there is no valid title in properties.
 * @param titles The titles.
 * @return The title.
 */
public String getTitle(String defaultValue, Properties titles) {
    if (null == titles)
        return defaultValue;
    Lang currentLang = this.getCurrentLang();
    String title = titles.getProperty(currentLang.getCode());
    if (null == title) {
        Lang defaultLang = this.getLangManager().getDefaultLang();
        title = titles.getProperty(defaultLang.getCode());
    }
    if (null == title) {
        title = defaultValue;
    }
    return title;
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 64 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class BaseAction method getCurrentLang.

/**
 * Return the current system language used in the back-end interface. If this language does not
 * belong to those known by the system the default language is returned. A log line will
 * report the problem.
 * @return The current language.
 */
public Lang getCurrentLang() {
    Locale locale = this.getLocale();
    String langCode = locale.getLanguage();
    Lang currentLang = this.getLangManager().getLang(langCode);
    if (null != currentLang) {
        return currentLang;
    } else {
        _logger.info("Required Lang '{}' invalid", langCode);
        return this.getLangManager().getDefaultLang();
    }
}
Also used : Locale(java.util.Locale) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 65 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class EntityAttributeConfigAction method fillAttributeFields.

/**
 * Fill attribute fields.
 *
 * @param attribute The attribute to edit with the form values.
 * @return A custom return code in the attribute neads a extra
 * configuration, else null.
 */
@Override
protected String fillAttributeFields(AttributeInterface attribute) {
    super.fillAttributeFields(attribute);
    AttributeInterface nestedType = null;
    if (attribute instanceof AbstractListAttribute) {
        AbstractListAttribute listAttribute = (AbstractListAttribute) attribute;
        if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT && listAttribute.getNestedAttributeTypeCode().equals(this.getListNestedType())) {
            if (listAttribute instanceof ListAttribute) {
                Lang defaultLang = this.getLangManager().getDefaultLang();
                // Composite Element
                nestedType = ((ListAttribute) listAttribute).addAttribute(defaultLang.getCode());
                ((ListAttribute) listAttribute).getAttributeList(defaultLang.getCode()).clear();
            } else {
                // Composite Element
                nestedType = ((MonoListAttribute) listAttribute).addAttribute();
                ((MonoListAttribute) listAttribute).getAttributes().clear();
            }
        } else {
            nestedType = this.getAttributePrototype(this.getListNestedType());
            if (nestedType != null) {
                nestedType.setName(this.getAttributeName());
            } else {
                _logger.info("******** List Type NULL!!!!");
            }
        }
        listAttribute.setNestedAttributeType(nestedType);
        nestedType.setName(attribute.getName());
    }
    if ((attribute instanceof CompositeAttribute) || (nestedType != null && nestedType instanceof CompositeAttribute)) {
        CompositeAttribute composite = ((attribute instanceof CompositeAttribute) ? (CompositeAttribute) attribute : (CompositeAttribute) nestedType);
        if (null != nestedType) {
            this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM, (AbstractListAttribute) attribute);
        }
        this.getRequest().getSession().setAttribute(ICompositeAttributeConfigAction.COMPOSITE_ATTRIBUTE_ON_EDIT_SESSION_PARAM, composite);
        return "configureCompositeAttribute";
    }
    if (nestedType != null) {
        this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM, (AbstractListAttribute) attribute);
        this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ELEMENT_ON_EDIT_SESSION_PARAM, nestedType);
        return "configureListElementAttribute";
    }
    return null;
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Lang(com.agiletec.aps.system.services.lang.Lang) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Aggregations

Lang (com.agiletec.aps.system.services.lang.Lang)90 ArrayList (java.util.ArrayList)15 ApsProperties (com.agiletec.aps.util.ApsProperties)14 IPage (com.agiletec.aps.system.services.page.IPage)12 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 RequestContext (com.agiletec.aps.system.RequestContext)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)8 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HashMap (java.util.HashMap)6 ServletRequest (javax.servlet.ServletRequest)6 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)4 Category (com.agiletec.aps.system.services.category.Category)4 Properties (java.util.Properties)4 JspException (javax.servlet.jsp.JspException)4 StringField (org.apache.lucene.document.StringField)4