/// <summary>
    /// Transformes CAML xml fragment trough XSL stylesheet.
    /// </summary>
    /// <param name="caml">Source xml = CAML fragment</param>
    /// <param name="ti">Transformation</param>
    /// <returns>Transformed text</returns>
    public static string TransformCAML(XmlNode caml, TransformationInfo ti)
    {
        XslCompiledTransform xslTransform = new XslCompiledTransform();

        // Read stylesheet code from transformation
        StringReader stream = new StringReader(ti.TransformationCode);
        XmlTextReader xmlReader = new XmlTextReader(stream);
        xslTransform.Load(xmlReader);

        // Create XMLDocument from CAML fragment
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(caml.InnerXml);

        StringWriter transformed = new StringWriter();
        xslTransform.Transform(xmlDoc, null, transformed);

        return transformed.ToString();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check security
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Design", "Design.WebPartProperties", "WebPartProperties.General", "WebPartProperties.EditTransformations" }, CMSContext.CurrentSiteName))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Design.WebPartProperties;WebPartProperties.General;WebPartProperties.EditTransformations");
        }

        UserInfo ui = CMSContext.CurrentUser;

        // If site manager set directly (or window not in dialog mode) -  set site manager flag to unigrid
        // In some cases dialog mode may be used in site manager (hier. transformation)
        bool isSiteManager = QueryHelper.GetBoolean("sitemanager", false);

        if ((isSiteManager || !mDialogMode) && ui.UserSiteManagerAdmin)
        {
            ucTransf.IsSiteManager = true;
        }

        CurrentMaster.Title.Visible = true;

        int    transformationID = QueryHelper.GetInteger("transID", 0);
        string selectedTemplate = QueryHelper.GetString("templatetype", String.Empty);

        if (!String.IsNullOrEmpty(ucTransf.SelectedItemType))
        {
            selectedTemplate = ucTransf.SelectedItemType;
        }
        Guid guid          = QueryHelper.GetGuid("guid", Guid.Empty);
        bool showInfoLabel = QueryHelper.GetBoolean("showinfo", false);

        TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationID);

        ucTransf.ShowInfoLabel  = showInfoLabel;
        ucTransf.TransInfo      = ti;
        ucTransf.HierarchicalID = guid;

        //Set breadcrumbs
        string[,] tabs = new string[2, 4];
        tabs[0, 0]     = GetString("documenttype_edit_transformation_list.titlelist");
        tabs[0, 1]     = ResolveUrl(String.Format("~/CMSModules/DocumentTypes/Pages/Development/HierarchicalTransformations_Transformations.aspx?transID={0}&templatetype={1}&editonlycode={2}&tabmode={3}&aliaspath={4}&instanceguid={5}",
                                                  ti.TransformationID, selectedTemplate, mDialogMode, QueryHelper.GetInteger("tabmode", 0), QueryHelper.GetString("aliaspath", String.Empty), QueryHelper.GetGuid("instanceguid", Guid.Empty)));
        tabs[0, 2] = "";

        tabs[1, 0] = GetString("documenttype_edit_transformation_list.edit");
        tabs[1, 1] = "";
        tabs[1, 2] = "";

        CurrentMaster.Title.HelpTopicName = "partialhierarchicalTransformation_tab";
        CurrentMaster.Title.HelpName      = "helpTopic";

        CurrentMaster.Title.Breadcrumbs = tabs;

        if (mDialogMode)
        {
            pnlContainer.CssClass = "PageContent";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(this);

        TransformationInfo ti = EditedObject as TransformationInfo;

        if (ti != null)
        {
            UserInfo ui               = CMSContext.CurrentUser;
            bool     isSiteManager    = QueryHelper.GetBoolean("sitemanager", false) && ui.UserSiteManagerAdmin;
            string   isSiteManagerStr = isSiteManager ? "&sitemanager=true" : String.Empty;
            SetTab(0, GetString("general.transformations"), "HierarchicalTransformations_Transformations.aspx?transid=" + ti.TransformationID + "&editonlycode=" + mDialogMode + "&tabmode=" + QueryHelper.GetInteger("tabmode", 0) + isSiteManagerStr, "SetHelpTopic('helpTopic','hierarchicalTransformation_tab')");
            if (!mDialogMode)
            {
                SetTab(1, GetString("general.general"), "HierarchicalTransformations_General.aspx?transid=" + ti.TransformationID, "SetHelpTopic('helpTopic','newedit_hierarchical_transformation')");

                InitBreadcrumbs(2);
                SetBreadcrumb(0, GetString("documenttype_edit_transformation_list.title"), ResolveUrl("~/CMSModules/DocumentTypes/Pages/Development/DocumentType_edit_Transformation_list.aspx?documenttypeid=" + ti.TransformationClassID), "content", null);
                SetBreadcrumb(1, ti.TransformationName + " (" + GetString("transformation.hierarchical") + ")", null, null, null);
            }
            else
            {
                SetTitle("Design/Selectors/selecttransformation.png", GetString("transformationedit.title"), "hierarchicalTransformation_tab", "helpTopic");
            }
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        transformationInfo = UIContext.EditedObject as TransformationInfo;
        user = MembershipContext.AuthenticatedUser;

        if (!RequestHelper.IsPostBack())
        {
            DropDownListInit();

            if (transformationInfo != null)
            {
                // Fills form with transformation information
                drpType.SelectedValue = transformationInfo.TransformationType.ToStringRepresentation();
                txtCSS.Text           = transformationInfo.TransformationCSS;

                if (transformationInfo.TransformationType == TransformationTypeEnum.Html)
                {
                    tbWysiwyg.ResolvedValue = transformationInfo.TransformationCode;
                    tbWysiwyg.Visible       = true;
                }
                else
                {
                    txtCode.Text    = transformationInfo.TransformationCode;
                    txtCode.Visible = true;
                }
            }
            else
            {
                txtCode.Visible = true;
            }
        }
    }
    /// <summary>
    /// Creates URL for editing.
    /// </summary>
    /// <param name="resourceName">Resource name</param>
    /// <param name="elementName">Element name</param>
    /// <param name="transformation">Transformation object info</param>
    private String GetEditUrl(string resourceName, string elementName, TransformationInfo transformation)
    {
        var uiChild = UIElementInfoProvider.GetUIElementInfo(resourceName, elementName);

        if (uiChild != null)
        {
            string url   = String.Empty;
            string query = RequestContext.CurrentQueryString;

            if (!DialogMode)
            {
                url = UIContextHelper.GetElementUrl(uiChild, UIContext);
                url = URLHelper.AppendQuery(url, query);
            }
            else
            {
                url = UIContextHelper.GetElementDialogUrl(uiChild, 0, query);
            }


            return(URLHelper.AppendQuery(url, "objectid=" + transformation.TransformationID));
        }

        return(String.Empty);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Creates URL for editing.
    /// </summary>
    /// <param name="resourceName">Resource name</param>
    /// <param name="elementName">Element name</param>
    /// <param name="transformation">Transformation object info</param>
    private String GetEditUrl(string resourceName, string elementName, TransformationInfo transformation)
    {
        var uiChild = UIElementInfoProvider.GetUIElementInfo(resourceName, elementName);

        if (uiChild != null)
        {
            string url   = String.Empty;
            string query = RequestContext.CurrentQueryString;
            // Remove parentobjectid parameter to prevent from duplicating (URL generated by UIContextHelper.GetElementUrl already contains it).
            query = URLHelper.RemoveUrlParameter(query, "parentobjectid");

            if (!DialogMode)
            {
                url = UIContextHelper.GetElementUrl(uiChild, UIContext);
                url = URLHelper.AppendQuery(url, query);
                // Remove hash parameter as it's useless in non-dialog mode.
                url = URLHelper.RemoveParameterFromUrl(url, "hash");
            }
            else
            {
                url = ApplicationUrlHelper.GetElementDialogUrl(uiChild, 0, query);
            }


            return(URLHelper.AppendQuery(url, "objectid=" + transformation.TransformationID));
        }

        return(String.Empty);
    }
Ejemplo n.º 7
0
        private void SetRotateValue(object data)
        {
            BeginUpdate();

            var nodeBuilder   = new NodeBuilder(Parent);
            var mouseRotation = TransformationInterpreter.GetRotateTrsf((Point3D)data);
            var sketchNode    = NodeBuilderUtils.FindBaseSketchNode(Parent);

            var document = sketchNode.Root.Get <DocumentContextInterpreter>().Document;

            if (!NodeUtils.NodeIsOnSketch(nodeBuilder))
            {
                var list        = NodeBuilderUtils.GetAllContained3DNodesIndexes(nodeBuilder.Node).Distinct().ToList();
                var sketchNodes = new List <Node>();
                foreach (var nodeIndex in list)
                {
                    var node             = document.Root[nodeIndex.Key];
                    var shapeNodeBuilder = new NodeBuilder(node);
                    if (FunctionNames.GetSolids().Contains(nodeBuilder.FunctionName))
                    {
                        continue;
                    }

                    var affectedSketchNode = shapeNodeBuilder.Dependency[0].ReferenceBuilder.Node;

                    if (affectedSketchNode != null)
                    {
                        var nb1 = new NodeBuilder(affectedSketchNode);
                        if (nb1.Dependency[2].Reference == null)
                        {
                            sketchNodes.Add(affectedSketchNode);
                        }
                    }
                }

                document.Transact();
                foreach (var solid in sketchNodes)
                {
                    var nb          = new NodeBuilder(solid);
                    var trsfCurrent = nb.Node.Get <TransformationInterpreter>().CurrTransform;
                    trsfCurrent = trsfCurrent.Multiplied(mouseRotation);
                    // we need to invert the transformation to make it positive for the x-axis
                    trsfCurrent = trsfCurrent.Inverted;

                    var transformationInfo = new TransformationInfo
                    {
                        SketchIndex    = solid.Index,
                        Transformation = mouseRotation,
                        TrsfIndex      = TransformationInfo.maxTrsfIndex,
                        RefSketchIndex = -2
                    };
                    TransformationInfo.maxTrsfIndex++;
                    TransformationInterpreter.Transformations.Add(transformationInfo);
                    nb.Node.Set <TransformationInterpreter>().CurrTransform = trsfCurrent;
                    nb.ExecuteFunction();
                }
                document.Commit("Rotated");
            }
            EndVisualUpdate("Rotate object");
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Handles the UniGrid's OnAction event.
 /// </summary>
 /// <param name="actionName">Name of item (button) that throws event</param>
 /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
 protected void uniGrid_OnAction(string actionName, object actionArgument)
 {
     if (actionName.ToLower() == "edit")
     {
         int transID = ValidationHelper.GetInteger(actionArgument, 0);
         if (transID != 0)
         {
             TransformationInfo ti = TransformationInfoProvider.GetTransformation(transID);
             if (ti != null)
             {
                 if (ti.TransformationIsHierarchical)
                 {
                     string isManager = IsSiteManager ? "&sitemanager=true" : String.Empty;
                     URLHelper.Redirect(ResolveUrl("~/CMSModules/DocumentTypes/Pages/Development/HierarchicalTransformations_Frameset.aspx?transid=" + transID + "&classid=" + this.ClassID.ToString() + "&tabmode=1" + isManager));
                 }
                 else
                 {
                     URLHelper.Redirect(this.EditPageUrl + "?transformationid=" + transID.ToString() + "&classid=" + this.ClassID.ToString() + "&hash=" + QueryHelper.GetHash("?transformationid=" + transID + "&classid=" + ClassID));
                 }
             }
         }
     }
     else if (actionName.ToLower() == "delete")
     {
         int transformationId = ValidationHelper.GetInteger(actionArgument, -1);
         if (transformationId > 0)
         {
             TransformationInfoProvider.DeleteTransformation(transformationId);
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (dialogMode)
        {
            ScriptHelper.RegisterWOpenerScript(Page);
        }

        // Check permissions for web part properties UI

        // Check for UI permissions
        if (!CurrentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Design", "Design.WebPartProperties", "WebPartProperties.General", "WebPartProperties.EditTransformations" }, CMSContext.CurrentSiteName))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Design.WebPartProperties;WebPartProperties.General;WebPartProperties.EditTransformations");
        }

        // In case of opening via web part uni selector and transformation is hierarchical - redirect to hierarchical transformation
        string transName = QueryHelper.GetString("name", string.Empty);

        TransformationInfo hti = TransformationInfoProvider.GetTransformation(transName);

        if (hti != null)
        {
            if (hti.TransformationIsHierarchical)
            {
                URLHelper.Redirect(ResolveUrl(string.Format("~/CMSModules/DocumentTypes/Pages/Development/HierarchicalTransformations_Transformations.aspx?transID={0}&editonlycode={1}&aliaspath={2}&instanceguid={3}", hti.TransformationID, QueryHelper.GetInteger("editonlycode", 0),
                                                            QueryHelper.GetString("aliaspath", String.Empty), QueryHelper.GetGuid("instanceguid", Guid.Empty))));
            }
        }
    }
    protected void editElem_OnAfterSave(object sender, EventArgs e)
    {
        TransformationInfo ti = editElem.EditedObject as TransformationInfo;

        if (ti != null)
        {
            string tpar = (DialogMode) ? "name=" + ti.TransformationFullName : "transformationid=" + ti.TransformationID;

            string editPage = null;
            if (IsCustomTable)
            {
                editPage = URLHelper.GetAbsoluteUrl("~/CMSModules/CustomTables/CustomTable_Edit_Transformation_Frameset.aspx?" + tpar + "&" + Request.QueryString);
            }
            else
            {
                editPage = URLHelper.GetAbsoluteUrl("~/CMSModules/DocumentTypes/Pages/Development/DocumentType_Edit_Transformation_Frameset.aspx?" + tpar + "&" + Request.QueryString);
            }

            // If dialog mode redirect after, selector is updated
            if (DialogMode)
            {
                RegisterChangeSelector();
                ScriptHelper.RegisterStartupScript(Page, typeof(String), "RedirectParent", ScriptHelper.GetScript("location ='" + editPage + "';"));
            }
            else
            {
                URLHelper.Redirect(editPage);
            }
        }
    }
 /// <summary>
 /// Initializes the control properties.
 /// </summary>
 protected void SetupControl()
 {
     if (StopProcessing)
     {
         viewElem.StopProcessing = true;
         repElem.StopProcessing  = true;
     }
     else
     {
         // Get transformation name
         string transformationName = String.IsNullOrEmpty(TransformationName) ? SelectedItemTransformationName : TransformationName;
         if (!string.IsNullOrEmpty(transformationName))
         {
             // Get transformation info
             TransformationInfo transformation = TransformationInfoProvider.GetTransformation(transformationName);
             // Get type of transformation
             if (transformation != null)
             {
                 if (transformation.TransformationType == TransformationTypeEnum.Xslt)
                 {
                     // XSLT transformations (transform locally)
                     isAscx = false;
                     UseXSLT();
                 }
                 else
                 {
                     // Other transformations (display using repeater)
                     UseStandard();
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TreeNode currentDocument = DocumentContext.CurrentDocument;

        if (currentDocument != null)
        {
            // Get document type transformation
            string             transformationName = currentDocument.NodeClassName + ".attachment";
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationName);
            // If transformation not present, use default from the Root document type
            if (ti == null)
            {
                transformationName = "cms.root.attachment";
                ti = TransformationInfoProvider.GetTransformation(transformationName);
            }

            if (ti == null)
            {
                throw new Exception("[DocumentAttachments]: Default transformation '" + transformationName + "' doesn't exist!");
            }

            ucAttachments.TransformationName = transformationName;
            ucAttachments.SiteName           = SiteContext.CurrentSiteName;
            ucAttachments.Path         = currentDocument.NodeAliasPath;
            ucAttachments.CultureCode  = currentDocument.DocumentCulture;
            ucAttachments.OrderBy      = "AttachmentOrder, AttachmentName";
            ucAttachments.PageSize     = 0;
            ucAttachments.GetBinary    = false;
            ucAttachments.CacheMinutes = SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSite + ".CMSCacheMinutes");
        }
    }
    /// <summary>
    /// Registers script for transformation selector update. It's usable on dialog mode.
    /// </summary>
    /// <param name="closeDialog">If true, dialog is closed after save</param>
    private void RegisterChangeSelector()
    {
        string script = String.Empty;

        TransformationInfo ti = editElem.EditedObject as TransformationInfo;

        // Check for selector ID
        string selector = QueryHelper.GetString("selectorid", string.Empty);

        if (!string.IsNullOrEmpty(selector))
        {
            // Add selector refresh
            script = string.Format(@"if (wopener && wopener.US_SelectNewValue_{0}) {{wopener.US_SelectNewValue_{0}('{1}'); }}",
                                   selector, ti.TransformationFullName);
        }

        if (closeOnSave)
        {
            script += "CloseDialog();";
        }

        if (script != String.Empty)
        {
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "UpdateSelector", ScriptHelper.GetScript(script));
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// Load transformations with dependence.
    /// </summary>
    protected void LoadTransformations()
    {
        if (!String.IsNullOrEmpty(TransformationName))
        {
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(TransformationName);

            if (ti != null)
            {
                // Setting up the common BasicUniView properties
                shoppingCartUniView.HierarchicalDisplayMode = HierarchicalDisplayModeEnum.Inner;
                shoppingCartUniView.RelationColumnID        = "CartItemGuid";

                if (ti.TransformationIsHierarchical)
                {
                    // Setting up the hierarchical transformation.
                    HierarchicalTransformations ht = new HierarchicalTransformations("CartItemGUID");
                    ht.LoadFromXML(ti.TransformationHierarchicalXMLDocument);
                    // Setting up the BasicUniView
                    shoppingCartUniView.Transformations = ht;
                    shoppingCartUniView.UseNearestItemForHeaderAndFooter = true;
                }
                else
                {
                    // Setting up the BasicUniView with a non-hierarchical transformation
                    shoppingCartUniView.ItemTemplate = TransformationHelper.LoadTransformation(shoppingCartUniView, ti.TransformationFullName);
                }

                // Makes sure new data is loaded if the date changes and transformation needs to be reloaded
                shoppingCartUniView.DataBind();
            }
        }
    }
Ejemplo n.º 15
0
    private bool SetDialogMode()
    {
        if (!string.IsNullOrEmpty(mTransformationName))
        {
            // Error message variable
            string errorMessage = null;

            // Get transformation info
            ti = TransformationInfoProvider.GetTransformation(mTransformationName);
            if (ti != null)
            {
                transformationId = ti.TransformationID;
                mClassName       = DataClassInfoProvider.GetClassName(ti.TransformationClassID);

                // Check if document type is registered under current site
                DataSet ds = ClassSiteInfoProvider.GetClassSites("ClassID", "ClassID = " + ti.TransformationClassID + " AND SiteID = " + CMSContext.CurrentSiteID, null, -1);
                if (DataHelper.DataSourceIsEmpty(ds) && !user.UserSiteManagerAdmin)
                {
                    // Set error message
                    errorMessage = GetString("formcontrols_selecttransformation.classnotavailablesite").Replace("%%code%%", HTMLHelper.HTMLEncode(mClassName));
                }
                else
                {
                    tbTransformationName.ReadOnly = true;
                }
            }
            else
            {
                // Set error message
                errorMessage = GetString("formcontrols_selecttransformation.transofrmationnotexist").Replace("%%code%%", HTMLHelper.HTMLEncode(mTransformationName));
            }

            // Hide panel Menu and write error message
            if (!String.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
                pnlCheckOutInfo.Visible = plcControl.Visible = false;
                pnlContent.CssClass     = "PageContent";
                return(true);
            }
        }
        else
        {
            // Set page title
            mCurrentMaster.Title.TitleText  = GetString("documenttype_edit_transformation_edit.newtransformation");
            mCurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Transformation/transformation_new.png");

            // Display class selector
            UseClassSelector     = true;
            filter.SelectedValue = QueryHelper.GetString("selectedvalue", null);
            filter.FilterMode    = SettingsObjectType.TRANSFORMATION;
        }

        pnlContent.CssClass = "PageContent";

        SetDialogButtons();

        return(false);
    }
Ejemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int transID = QueryHelper.GetInteger("transid", 0);

        if (transID != 0)
        {
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(transID);
            ucTransf.TransInfo = ti;
        }
    }
    protected void editElem_OnAfterSave(object sender, EventArgs e)
    {
        TransformationInfo ti = editElem.EditedObject as TransformationInfo;

        if (ti != null)
        {
            string editPage = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "EditTransformation"), "parentobjectid=" + ClassID + "&classID=" + ClassID + "&objectid=" + ti.TransformationID + "&displaytitle=false&saved=1");

            URLHelper.Redirect(editPage);
        }
    }
Ejemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TransformationInfo ti = EditedObject as TransformationInfo;

        // Set breadcrumbs
        SetBreadcrumb(0, GetString("DocumentType_Edit_Transformation_Edit.Transformations"), ResolveUrl("CustomTable_Edit_Transformation_List.aspx?customtableid=" + ti.TransformationClassID), "_parent", null);
        SetBreadcrumb(1, ti.TransformationName, null, null, null);

        // Set general tab
        SetTab(0, GetString("general.general"), URLHelper.RemoveParameterFromUrl("CustomTable_Edit_Transformation_Edit.aspx" + URLHelper.Url.Query, "saved"), "SetHelpTopic('helpTopic', 'customtable_edit_newedit_transformation');");
    }
Ejemplo n.º 19
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (TransInfo == null)
        {
            TransInfo = new TransformationInfo();
        }

        string codeName = txtName.Text.Trim();
        //Test if codename not empty
        string errorMessage = new Validator().NotEmpty(codeName, rfvCodeName.ErrorMessage).Result;

        //Test right format
        if ((errorMessage == "") && (!ValidationHelper.IsIdentifier(codeName.Trim())))
        {
            errorMessage = GetString("general.erroridentificatorformat");
        }

        if (errorMessage != String.Empty)
        {
            lblError.Text    = errorMessage;
            lblError.Visible = true;
            return;
        }

        TransInfo.TransformationName = txtName.Text;

        //If edit no DocumentTypeID is set
        if (DocumentTypeID != 0)
        {
            TransInfo.TransformationClassID = DocumentTypeID;
        }

        //Save new Transformation
        TransformationInfo ti = TransformationInfoProvider.GetTransformation(TransInfo.TransformationFullName);

        if ((ti != null) && (ti.TransformationID != TransInfo.TransformationID))
        {
            lblError.Text    = GetString("DocumentType_Edit_Transformation_Edit.UniqueTransformationNameDocType");
            lblError.Visible = true;
            return;
        }

        //Write info
        TransInfo.TransformationIsHierarchical = true;
        TransformationInfoProvider.SetTransformation(TransInfo);

        lblInfo.Visible = true;

        RaiseOnSaved();

        // Reload header if changes were saved
        ScriptHelper.RefreshTabHeader(Page, GetString("general.general"));
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (TransInfo == null)
        {
            TransInfo = new TransformationInfo();
        }

        string codeName = txtName.Text.Trim();
        //Test if codename not empty
        string errorMessage = new Validator().NotEmpty(codeName, rfvCodeName.ErrorMessage).Result;

        //Test right format
        if ((errorMessage == "") && (!ValidationHelper.IsIdentifier(codeName.Trim())))
        {
            errorMessage = GetString("general.erroridentificatorformat");
        }

        if (errorMessage != String.Empty)
        {
            lblError.Text = errorMessage;
            lblError.Visible = true;
            return;
        }

        TransInfo.TransformationName = txtName.Text;

        //If edit no DocumentTypeID is set
        if (DocumentTypeID != 0)
        {
            TransInfo.TransformationClassID = DocumentTypeID;
        }

        //Save new Transformation
        TransformationInfo ti = TransformationInfoProvider.GetTransformation(TransInfo.TransformationFullName);
        if ((ti != null) && (ti.TransformationID != TransInfo.TransformationID))
        {
            lblError.Text = GetString("DocumentType_Edit_Transformation_Edit.UniqueTransformationNameDocType");
            lblError.Visible = true;
            return;
        }

        //Write info
        TransInfo.TransformationIsHierarchical = true;
        TransformationInfoProvider.SetTransformation(TransInfo);

        lblInfo.Visible = true;

        RaiseOnSaved();

        // Reload header if changes were saved
        ScriptHelper.RefreshTabHeader(Page, GetString("general.general"));
    }
Ejemplo n.º 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check security
        var currentUser = MembershipContext.AuthenticatedUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Design", new[] { "Design", "Design.WebPartProperties", "WebPartProperties.General", "WebPartProperties.EditTransformations" }, SiteContext.CurrentSiteName))
        {
            RedirectToUIElementAccessDenied("CMS.Design", "Design.WebPartProperties;WebPartProperties.General;WebPartProperties.EditTransformations");
        }

        UserInfo ui = MembershipContext.AuthenticatedUser;

        // If site manager set directly (or window not in dialog mode) -  set site manager flag to unigrid
        // In some cases dialog mode may be used in site manager (hier. transformation)
        bool isSiteManager = QueryHelper.GetBoolean("sitemanager", false);

        if ((isSiteManager || !editOnlyCode) && ui.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
        {
            ucTransf.IsSiteManager = true;
        }

        PageTitle.Visible = true;

        int    transformationID = QueryHelper.GetInteger("objectid", 0);
        string selectedTemplate = QueryHelper.GetString("templatetype", String.Empty);

        if (!String.IsNullOrEmpty(ucTransf.SelectedItemType))
        {
            selectedTemplate = ucTransf.SelectedItemType;
        }
        Guid guid          = QueryHelper.GetGuid("guid", Guid.Empty);
        bool showInfoLabel = QueryHelper.GetBoolean("showinfo", false);

        TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationID);

        ucTransf.ShowInfoLabel  = showInfoLabel;
        ucTransf.TransInfo      = ti;
        ucTransf.HierarchicalID = guid;

        //Set breadcrumbs
        PageBreadcrumbs.Items.Add(new BreadcrumbItem
        {
            Text        = GetString("documenttype_edit_transformation_list.titlelist"),
            RedirectUrl = ResolveUrl(String.Format("~/CMSModules/DocumentTypes/Pages/Development/HierarchicalTransformations_Transformations.aspx?objectid={0}&templatetype={1}&editonlycode={2}&tabmode={3}&aliaspath={4}&instanceguid={5}",
                                                   ti.TransformationID, selectedTemplate, editOnlyCode, QueryHelper.GetInteger("tabmode", 0), QueryHelper.GetString("aliaspath", String.Empty), QueryHelper.GetGuid("instanceguid", Guid.Empty)))
        });

        PageBreadcrumbs.Items.Add(new BreadcrumbItem
        {
            Text = GetString("documenttype_edit_transformation_list.edit"),
        });
    }
    /// <summary>
    /// Binds data to basic repeater.
    /// </summary>
    protected void BindData()
    {
        // Dataset = connects repeater with data source
        if (UseClassicDataset)
        {
            BasicRepeater.DataSource = SPDataSource.DataSource;

            if (!DataHelper.DataSourceIsEmpty(BasicRepeater.DataSource))
            {
                // Set proper transformations
                LoadTransformations();

                BasicRepeater.DataBind();
            }
        }
        // XSLT
        else
        {
            XmlNode caml      = SPDataSource.DataSource as XmlNode;
            string  transName = TransformationName;

            // If selected item is set
            if (SPDataSource.IsSelected && !String.IsNullOrEmpty(SelectedItemTransformationName))
            {
                transName = SelectedItemTransformationName;
            }

            // Get transformation info
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(transName);

            if ((caml != null) && (ti != null))
            {
                // Check it is XSLT transformation
                if (ti.TransformationType != TransformationTypeEnum.Xslt)
                {
                    DisplayError(string.Format(GetString("sharepoint.XSL"), ti.TransformationFullName));
                    return;
                }

                try
                {
                    ltlTransformedOutput.Text = SharePointFunctions.TransformCAML(caml, ti);
                }
                catch (Exception ex)
                {
                    // Show error
                    DisplayError(string.Format(GetString("sharepoint.XSLTError") + ResHelper.Colon + " " + ex.Message));
                    DisplayError("XSLT error: " + ex.Message);
                }
            }
        }
    }
Ejemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ucAttachments    = Page.LoadUserControl("~/CMSModules/Content/Controls/Attachments/AttachmentLightboxGallery.ascx") as CMSUserControl;
        ucAttachments.ID = "ctrlAttachments";
        plcAttachmentLightBox.Controls.Add(ucAttachments);

        TreeNode currentDocument = DocumentContext.CurrentDocument;

        if (currentDocument != null)
        {
            // Get document type transformation
            string             transformationName         = currentDocument.NodeClassName + ".AttachmentLightbox";
            string             selectedTransformationName = currentDocument.NodeClassName + ".AttachmentLightboxDetail";
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationName);

            // If transformation not present, use default from the Root document type
            if (ti == null)
            {
                transformationName = "cms.root.AttachmentLightbox";
                ti = TransformationInfoProvider.GetTransformation(transformationName);
            }
            if (ti == null)
            {
                throw new Exception("[DocumentAttachments]: Default transformation '" + transformationName + "' doesn't exist!");
            }
            ti = TransformationInfoProvider.GetTransformation(selectedTransformationName);

            // If transformation not present, use default from the Root document type
            if (ti == null)
            {
                selectedTransformationName = "cms.root.AttachmentLightboxDetail";
                ti = TransformationInfoProvider.GetTransformation(selectedTransformationName);
            }
            if (ti == null)
            {
                throw new Exception("[DocumentAttachments]: Default transformation '" + selectedTransformationName + "' doesn't exist!");
            }

            ucAttachments.SetValue("TransformationName", transformationName);
            ucAttachments.SetValue("SelectedItemTransformationName", selectedTransformationName);
            ucAttachments.SetValue("SiteName", SiteContext.CurrentSiteName);
            ucAttachments.SetValue("Path", currentDocument.NodeAliasPath);
            ucAttachments.SetValue("CultureCode", currentDocument.DocumentCulture);
            ucAttachments.SetValue("OrderBy", "AttachmentOrder, AttachmentName");
            ucAttachments.SetValue("PageSize", 0);
            ucAttachments.SetValue("GetBinary", false);
            ucAttachments.SetValue("CacheMinutes", SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSite + ".CMSCacheMinutes"));
        }
    }
    protected void editElem_OnBeforeSave(object sender, EventArgs e)
    {
        TransformationInfo tinfo = editElem.EditedObject as TransformationInfo;

        if (tinfo != null)
        {
            if (ClassID > 0)
            {
                tinfo.TransformationClassID = ClassID;
            }
            else
            {
                tinfo.TransformationClassID = filter.ClassId;
            }
        }
    }
Ejemplo n.º 25
0
    /// <summary>
    /// Initialize filter.
    /// </summary>
    public void Initialize()
    {
        if (!String.IsNullOrEmpty(SelectedValue))
        {
            switch (FilterMode)
            {
            case TransformationInfo.OBJECT_TYPE:
                TransformationInfo ti = TransformationInfoProvider.GetTransformation(SelectedValue);
                if (ti != null)
                {
                    mSelectedClass = DataClassInfoProvider.GetDataClassInfo(ti.TransformationClassID);
                }
                break;

            case QueryInfo.OBJECT_TYPE:
                var q = QueryInfoProvider.GetQueryInfo(SelectedValue, throwException: false);
                if (q != null)
                {
                    mSelectedClass = DataClassInfoProvider.GetDataClassInfo(q.ClassID);
                }
                break;
            }

            // If selected object is under custom class, change selected class type
            if (mSelectedClass != null)
            {
                if (mSelectedClass.ClassIsCustomTable)
                {
                    lblDocType.ResourceString = "queryselection.customtable";
                    ListItem selectedItem = ControlsHelper.FindItemByValue(drpClassType, "customtables", false);

                    // Select item which is already loaded in drop-down list
                    if (selectedItem != null)
                    {
                        drpClassType.SelectedValue = selectedItem.Value;
                    }
                }
                else if (!mSelectedClass.ClassIsDocumentType)
                {
                    mSelectedClass = null;
                    return;
                }

                uniSelector.Value = mSelectedClass.ClassID;
            }
        }
    }
Ejemplo n.º 26
0
    /// <summary>
    /// Initialize filter.
    /// </summary>
    public void Initialize()
    {
        if (!String.IsNullOrEmpty(SelectedValue))
        {
            switch (FilterMode)
            {
            case PortalObjectType.TRANSFORMATION:
                TransformationInfo ti = TransformationInfoProvider.GetTransformation(SelectedValue);
                if (ti != null)
                {
                    mSelectedClass = DataClassInfoProvider.GetDataClass(ti.TransformationClassID);
                }
                break;

            case SettingsObjectType.QUERY:
                Query q = QueryProvider.GetQuery(SelectedValue, false);
                if (q != null)
                {
                    mSelectedClass = DataClassInfoProvider.GetDataClass(q.QueryClassId);
                }
                break;
            }

            // If selected object is under custom class, change selected class type
            if (mSelectedClass != null)
            {
                if (mSelectedClass.ClassIsCustomTable)
                {
                    lblDocType.Text = ResHelper.GetString("queryselection.customtable");
                    ListItem selectedItem = ControlsHelper.FindItemByValue(drpClassType, "customtables", false);

                    // Select item which is already loaded in drop-down list
                    if (selectedItem != null)
                    {
                        drpClassType.SelectedValue = selectedItem.Value;
                    }
                }
                else if (!mSelectedClass.ClassIsDocumentType)
                {
                    mSelectedClass = null;
                    return;
                }

                uniSelector.Value = mSelectedClass.ClassID;
            }
        }
    }
Ejemplo n.º 27
0
    private void GetParameters()
    {
        // Gets classID from querystring, used when creating new transformation
        mClassId = QueryHelper.GetInteger(ParameterName, 0);
        if (mClassId > 0)
        {
            mClassName = DataClassInfoProvider.GetClassName(mClassId);
        }

        // Gets transformationID from querystring, used when editing transformation
        transformationId = QueryHelper.GetInteger("transformationid", 0);
        if (transformationId > 0)
        {
            // Get the transformation
            ti = TransformationInfoProvider.GetTransformation(transformationId);
            CMSPage.EditedObject = ti;

            mTransformationName = ti.TransformationName;

            mClassName = DataClassInfoProvider.GetClassName(ti.TransformationClassID);
            mClassId   = DataClassInfoProvider.GetDataClass(mClassName).ClassID;

            if (!RequestHelper.IsPostBack())
            {
                // Shows that the new transformation was created or updated successfully
                if (QueryHelper.GetBoolean("saved", false))
                {
                    ShowInfo(GetString("General.ChangesSaved"));
                }
            }
        }
        else
        {
            ti.TransformationFullName = string.Empty;
        }

        DialogMode = QueryHelper.GetBoolean("editonlycode", false);

        if (DialogMode)
        {
            mTransformationName = QueryHelper.GetString("name", string.Empty);
        }

        EditMode = mTransformationName != string.Empty;
    }
Ejemplo n.º 28
0
    /// <summary>
    /// Retrieves the stylesheets of the web part layout from the database.
    /// </summary>
    /// <param name="layoutFullName">Layout full name</param>
    /// <returns>The stylesheet data (plain version only)</returns>
    private static CMSOutputResource GetTransformation(string transformationFullName)
    {
        TransformationInfo transformationInfo = TransformationInfoProvider.GetTransformation(transformationFullName);

        if (transformationInfo == null)
        {
            return(null);
        }

        // Build the result
        CMSOutputResource resource = new CMSOutputResource()
        {
            Data         = HTMLHelper.ResolveCSSUrls(transformationInfo.TransformationCSS, URLHelper.ApplicationPath),
            LastModified = transformationInfo.TransformationLastModified,
            Etag         = transformationInfo.TransformationVersionGUID
        };

        return(resource);
    }
    private void InitEditedObject()
    {
        if (PersistentEditedObject != null)
        {
            transformation = PersistentEditedObject as TransformationInfo;
            return;
        }

        if (transformationId > 0)
        {
            transformation = TransformationInfoProvider.GetTransformation(transformationId);
        }
        else
        {
            transformation = TransformationInfoProvider.GetTransformation(transformationName);
        }

        PersistentEditedObject = transformation;
    }
    private void InitEditedObject()
    {
        if (PersistentEditedObject != null)
        {
            transformation = PersistentEditedObject as TransformationInfo;
            return;
        }

        if (transformationId > 0)
        {
            transformation = TransformationInfoProvider.GetTransformation(transformationId);
        }
        else
        {
            transformation = TransformationInfoProvider.GetTransformation(transformationName);
        }

        PersistentEditedObject = transformation;
    }
    /// <summary>
    /// Displays multibuy and order discounts summary based on provided transformation.
    /// </summary>
    private void DisplayOrderDiscountSummary()
    {
        if (!string.IsNullOrEmpty(OrderDiscountSummaryTransformationName))
        {
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(OrderDiscountSummaryTransformationName);

            if (ti == null)
            {
                return;
            }

            uvMultiBuySummary.Visible      = true;
            uvMultiBuySummary.DataSource   = ShoppingCart.OrderRelatedDiscountSummaryItems;
            uvMultiBuySummary.ItemTemplate = CMSAbstractDataProperties.LoadTransformation(uvMultiBuySummary, ti.TransformationFullName);

            // Makes sure new data is loaded if the date changes and transformation needs to be reloaded
            uvMultiBuySummary.DataBind();
            uvMultiBuySummary.ReloadData(true);
        }
    }
    /// <summary>
    /// Returns true if user control is valid.
    /// </summary>
    public override bool IsValid()
    {
        // If macro or special value, do not validate
        string value = uniSelector.TextBoxSelect.Text.Trim();

        if (!ContextResolver.ContainsMacro(value) && (value != string.Empty))
        {
            // Check if culture exists
            TransformationInfo ti = TransformationInfoProvider.GetTransformation(value);
            if (ti == null)
            {
                ValidationError = GetString("formcontrols_selecttransformation.notexist").Replace("%%code%%", value);
                return(false);
            }
            else
            {
                return(true);
            }
        }
        return(true);
    }
Ejemplo n.º 33
0
    /// <summary>
    /// Transformes CAML xml fragment trough XSL stylesheet.
    /// </summary>
    /// <param name="caml">Source xml = CAML fragment</param>
    /// <param name="ti">Transformation</param>
    /// <returns>Transformed text</returns>
    public static string TransformCAML(XmlNode caml, TransformationInfo ti)
    {
        XslCompiledTransform xslTransform = new XslCompiledTransform();

        // Read stylesheet code from transformation
        StringReader  stream    = new StringReader(ti.TransformationCode);
        XmlTextReader xmlReader = new XmlTextReader(stream);

        xslTransform.Load(xmlReader);

        // Create XMLDocument from CAML fragment
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.LoadXml(caml.InnerXml);

        StringWriter transformed = new StringWriter();

        xslTransform.Transform(xmlDoc, null, transformed);

        return(transformed.ToString());
    }
Ejemplo n.º 34
0
	// Color animation
	public IEnumerator DoAlphaAnimation(GameObject target, TransformationInfo transformationInfo, bool isLooping, bool isReversed)
	{			
		if(target != null)
		{
			yield return 1;
			
			Color fromValue = Color.white;
			Color toValue = Color.white;
			
			EZAnimation.EASING_TYPE currentEasing = transformationInfo.NormalEasing;
			if(isReversed)
				currentEasing = transformationInfo.ReverseEasing;

			// All animation
			foreach(TransformationKeyInfo transformationKeyInfo in transformationInfo.TransformationKeyList)
			{
				if(target != null)
				{
					// Relative animation
					if(transformationKeyInfo.IsRelative)
					{							
						// Reverse
						if(isReversed)
						{
							toValue = transformationKeyInfo.FromColor;
						}
						else
						{
							toValue = transformationKeyInfo.ToColor;
						}
					}
					else
					{
						// Reverse
						if(isReversed)
						{
							fromValue = transformationKeyInfo.ToColor;
							toValue = transformationKeyInfo.FromColor;
						}
						else
						{
							fromValue = transformationKeyInfo.FromColor;
							toValue = transformationKeyInfo.ToColor;
						}
					}
					 
					// Repeat on all child
					float duration = GetDuration(transformationKeyInfo.Duration);
					DoAlphaAnimationRecursive(target.transform, fromValue, toValue, currentEasing, duration);
					
					// Wait the animation starting to display sprite hidden at sprite
					yield return new WaitForSeconds(0.1f);
					if(target != null)
						Misc.SetVisibleSpriteHiddenAtStart(transform);
					
					// Wait the animation end
					yield return new WaitForSeconds(Mathf.Clamp01(duration-0.1f));
				}
			}
		
			// Re call if loop
			if(isLooping && target != null && m_isPlaying)
				m_manager.StartCoroutine(DoAlphaAnimation(target, transformationInfo, isLooping, isReversed));
			else
			{
				// Check if the rollover is visible
				if(toValue.a > 0)
					m_isVisible = true;	
				else
					m_isVisible = false;
			}
		}
	}
    /// <summary>
    /// Creates URL for editing.
    /// </summary>
    /// <param name="resourceName">Resource name</param>
    /// <param name="elementName">Element name</param>
    /// <param name="transformation">Transformation object info</param>
    private String GetEditUrl(string resourceName, string elementName, TransformationInfo transformation)
    {
        var uiChild = UIElementInfoProvider.GetUIElementInfo(resourceName, elementName);
        if (uiChild != null)
        {
            string url = String.Empty;
            string query = RequestContext.CurrentQueryString;

            if (!DialogMode)
            {
                url = UIContextHelper.GetElementUrl(uiChild, UIContext);
                url = URLHelper.AppendQuery(url, query);
            }
            else
            {
                url = UIContextHelper.GetElementDialogUrl(uiChild, 0, query);
            }

            return URLHelper.AppendQuery(url, "objectid=" + transformation.TransformationID);
        }

        return String.Empty;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSMasterPage currentMaster = Page.Master as CMSMasterPage;

        if (FullscreenMode)
        {
            txtCode.TopOffset = 40;
        }

        // Check master page
        if (currentMaster == null)
        {
            throw new Exception("Page using this control must have CMSMasterPage master page.");
        }

        ti = CMSContext.EditedObject as TransformationInfo;
        LabelsInit();

        user = CMSContext.CurrentUser;

        if (!RequestHelper.IsPostBack())
        {
            DropDownListInit();

            if (ti != null)
            {
                // Fills form with transformation information
                drpType.SelectedValue = ti.TransformationType.ToString();
                txtCSS.Text = ti.TransformationCSS;

                if (ti.TransformationType == TransformationTypeEnum.Html)
                {
                    tbWysiwyg.ResolvedValue = ti.TransformationCode;
                    tbWysiwyg.Visible = true;
                }
                else
                {
                    txtCode.Text = ti.TransformationCode;
                    txtCode.Visible = true;
                }
            }
            else
            {
                txtCode.Visible = true;
            }
        }

        // Set correct help topic for custom tables
        if (!string.IsNullOrEmpty(ClassName))
        {
            DataClassInfo classInfo = DataClassInfoProvider.GetDataClass(ClassName);
            if ((classInfo != null) && classInfo.ClassIsCustomTable)
            {
                currentMaster.Title.HelpTopicName = "customtable_edit_newedit_transformation";
            }
        }

        txtCode.Editor.Width = new Unit("99%");
        txtCode.Editor.Height = new Unit("300px");
        txtCode.NamespaceUsings = new List<string> { "Transformation" };

        if (IsAscx)
        {
            DataClassInfo classInfo = DataClassInfoProvider.GetDataClass(ClassID);
            if (classInfo != null)
            {
                if (classInfo.ClassIsCustomTable)
                {
                    txtCode.ASCXRootObject = CustomTableItem.New(classInfo.ClassName);
                }
                else
                {
                    CMS.DocumentEngine.TreeNode node = CMS.DocumentEngine.TreeNode.New(classInfo.ClassName);
                    txtCode.ASCXRootObject = node;

                    // Prioritize doc. types fields
                    ContextResolver resolver = ContextResolver.GetInstance();
                    foreach (string prop in node.Generalized.PrioritizedProperties)
                    {
                        resolver.PrioritizeProperty(prop);
                    }
                    txtCode.Resolver = resolver;
                }
            }

            if (!RequestHelper.IsPostBack() && IsChecked)
            {
                ShowMessage();
            }
        }

        txtCode.Resolver.SetNamedSourceData("DataItemCount", "");
        txtCode.Resolver.SetNamedSourceData("DataItemIndex", "");
        txtCode.Resolver.SetNamedSourceData("DisplayIndex", "");

        // Hide/Display CSS section
        plcCssLink.Visible = String.IsNullOrEmpty(txtCSS.Text.Trim());

        SetEditor();
    }
    /// <summary>
    /// Creates default transformations for the classid.
    /// </summary>
    /// <param name="classId">Class id</param>
    /// <param name="isDocument">Indicates if transformations for document should be created</param>
    private void CreateDefaultTransformations(int classId, bool isDocument)
    {
        using (CMSActionContext context = new CMSActionContext())
        {
            // Disable logging of tasks
            context.DisableLogging();

            // Create default transformation
            TransformationInfo ti = new TransformationInfo();

            string classFormDefinition = DataClassInfoProvider.GetDataClassInfo(ClassName).ClassFormDefinition;

            ti.TransformationName = ValidationHelper.GetCodeName(GetString("TransformationName.Default"));
            ti.TransformationFullName = ClassName + "." + ti.TransformationName;
            ti.TransformationCode = TransformationInfoProvider.GenerateTransformationCode(classFormDefinition, TransformationTypeEnum.Ascx, ClassName);
            ti.TransformationType = TransformationTypeEnum.Ascx;
            ti.TransformationClassID = classId;

            // Set default transformation in DB
            TransformationInfoProvider.SetTransformation(ti);

            // Create preview transformation which has the same transformation code
            ti = ti.Clone(true);

            ti.TransformationName = ValidationHelper.GetCodeName(GetString("TransformationName.Preview"));
            ti.TransformationFullName = ClassName + "." + ti.TransformationName;

            // Set default transformation in DB
            TransformationInfoProvider.SetTransformation(ti);

            // Test if class is standard document type
            if (isDocument)
            {
                // Create RSS transformation
                ti = ti.Clone(true);

                ti.TransformationName = ValidationHelper.GetCodeName(GetString("TransformationName.RSS"));
                ti.TransformationFullName = ClassName + "." + ti.TransformationName;
                ti.TransformationCode = TransformationInfoProvider.GenerateTransformationCode(classFormDefinition, TransformationTypeEnum.Ascx, ClassName, DefaultTransformationTypeEnum.RSS);

                // Set RSS transformation in DB
                TransformationInfoProvider.SetTransformation(ti);

                // Create Atom transformation
                ti = ti.Clone(true);

                ti.TransformationName = ValidationHelper.GetCodeName(GetString("TransformationName.Atom"));
                ti.TransformationFullName = ClassName + "." + ti.TransformationName;
                ti.TransformationCode = TransformationInfoProvider.GenerateTransformationCode(classFormDefinition, TransformationTypeEnum.Ascx, ClassName, DefaultTransformationTypeEnum.Atom);

                // Set Atom transformation in DB
                TransformationInfoProvider.SetTransformation(ti);
            }
        }
    }
Ejemplo n.º 38
0
	// Scale
	public IEnumerator DoScaleAnimation(GameObject target, TransformationInfo transformationInfo, bool isLooping)
	{	
		if(target != null)
		{
			Vector3 fromValue = Vector3.zero;
			Vector3 toValue = Vector3.zero;
			
			// All animation
			foreach(TransformationKeyInfo transformationKeyInfo in transformationInfo.TransformationKeyList)
			{
				if(target != null)
				{
					if(transformationKeyInfo.IsRelative)
					{
						fromValue = target.transform.localScale;
						toValue = transformationKeyInfo.To;
					}
					else
					{
						fromValue = transformationKeyInfo.From;
						toValue = transformationKeyInfo.To;
					}	
						
					float duration = GetDuration(transformationKeyInfo.Duration);
					AnimateScale.Do(target,EZAnimation.ANIM_MODE.FromTo, fromValue, toValue, EZAnimation.GetInterpolator(transformationInfo.NormalEasing), duration,0f, null, null);
					yield return new WaitForSeconds(duration);
				}
			}
		
			// Re call if loop
			if(isLooping && target != null)
				m_manager.StartCoroutine(DoScaleAnimation(target, transformationInfo, isLooping));
		}
	}
    private void GetParameters()
    {
        // Gets classID from querystring, used when creating new transformation
        mClassId = QueryHelper.GetInteger(ParameterName, 0);
        if (mClassId > 0)
        {
            mClassName = DataClassInfoProvider.GetClassName(mClassId);
        }

        // Gets transformationID from querystring, used when editing transformation
        transformationId = QueryHelper.GetInteger("transformationid", 0);
        if (transformationId > 0)
        {
            // Get the transformation
            ti = TransformationInfoProvider.GetTransformation(transformationId);
            CMSPage.EditedObject = ti;

            mTransformationName = ti.TransformationName;

            mClassName = DataClassInfoProvider.GetClassName(ti.TransformationClassID);
            mClassId = DataClassInfoProvider.GetDataClass(mClassName).ClassID;

            if (!RequestHelper.IsPostBack())
            {
                // Shows that the new transformation was created or updated successfully
                if (QueryHelper.GetBoolean("saved", false))
                {
                    ShowInfo(GetString("General.ChangesSaved"));
                }
            }
        }
        else
        {
            ti.TransformationFullName = string.Empty;
        }

        DialogMode = QueryHelper.GetBoolean("editonlycode", false);

        if (DialogMode)
        {
            mTransformationName = QueryHelper.GetString("name", string.Empty);
        }

        EditMode = mTransformationName != string.Empty;
    }
Ejemplo n.º 40
0
	// Screen Position
	public IEnumerator DoScreenPositionAnimation(GameObject target, TransformationInfo transformationInfo, bool isLooping, bool isReversed)
	{	
		if(target != null)
		{
			m_isMoving = true;
			Vector3 fromValue = Vector3.zero;
			Vector3 toValue = Vector3.zero;
			
			EZAnimation.EASING_TYPE currentEasing = transformationInfo.NormalEasing;
			if(isReversed)
				currentEasing = transformationInfo.ReverseEasing;

			// All animation
			foreach(TransformationKeyInfo transformationKeyInfo in transformationInfo.TransformationKeyList)
			{
				if(target != null)
				{
					if(transformationKeyInfo.IsRelative)
					{	
						fromValue = target.GetComponent<EZScreenPlacement>().screenPos;
						
						// Reverse
						if(isReversed)
							toValue = fromValue - transformationKeyInfo.To;
						else
							toValue = fromValue + transformationKeyInfo.To;
					}
					else
					{
						if(isReversed)
						{
							fromValue = transformationKeyInfo.To;
							toValue = transformationKeyInfo.From;
						}
						else
						{
							fromValue = transformationKeyInfo.From;
							toValue = transformationKeyInfo.To;
						}
					}
					
					float duration = GetDuration(transformationKeyInfo.Duration);
					AnimateScreenPosition.Do(target,EZAnimation.ANIM_MODE.FromTo, fromValue, toValue, EZAnimation.GetInterpolator(currentEasing), duration,0f, null, null);	
					yield return new WaitForSeconds(duration);
				}
			}
		
			// Re call if loop
			if(isLooping && target != null)
				m_manager.StartCoroutine(DoScreenPositionAnimation(target, transformationInfo, isLooping, isReversed));
			else
				m_isMoving = false;
		}
	}
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    private void InitHeaderActions(TransformationInfo ti)
    {
        // Header actions
        string[,] actions = new string[4, 11];

        // Save button
        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = GetString("General.Save");
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = "true";

        if (SettingsKeyProvider.UsingVirtualPathProvider || (ti != null) && (ti.TransformationType == TransformationTypeEnum.Xslt))
        {
            // CheckOut
            actions[1, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[1, 1] = GetString("General.CheckOutToFile");
            actions[1, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkout.png");
            actions[1, 6] = "checkout";
            actions[1, 10] = "false";

            // CheckIn
            actions[2, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[2, 1] = GetString("General.CheckInFromFile");
            actions[2, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkin.png");
            actions[2, 6] = "checkin";
            actions[2, 10] = "false";

            // UndoCheckOut
            actions[3, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[3, 1] = GetString("General.UndoCheckout");
            actions[3, 2] = string.Concat("return confirm(", ScriptHelper.GetString(GetString("General.ConfirmUndoCheckOut")), ");");
            actions[3, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/undocheckout.png");
            actions[3, 6] = "undocheckout";
            actions[3, 10] = "false";

            if (ti.TransformationID != 0)
            {
                if (ti.TransformationCheckedOutByUserID > 0)
                {
                    // Checked out by current machine
                    if (string.Equals(ti.TransformationCheckedOutMachineName, HTTPHelper.MachineName, StringComparison.OrdinalIgnoreCase))
                    {
                        actions[2, 10] = "true";
                    }
                    if (user.UserSiteManagerAdmin)
                    {
                        actions[3, 10] = "true";
                    }
                }
                else
                {
                    actions[1, 10] = "true";
                }
            }
        }

        mCurrentMaster.HeaderActions.LinkCssClass = "ContentSaveLinkButton";
        mCurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        mCurrentMaster.HeaderActions.Actions = actions;
    }
        /// <summary>
        /// Does not perform any operations yet on the AST.
        /// </summary>
        private void RetrieveOverridenNamespaceNames()
        {
            new MultiPurposeASTWalker(this.node,
                delegate (SyntaxNode astNode)
                {
                    var typeDeclarationNode = astNode as BaseTypeDeclarationSyntax;

                    // Recognizing only classes, enums and interfaces
                    var classNode = astNode as ClassDeclarationSyntax;
                    var enumNode = astNode as EnumDeclarationSyntax;
                    var interfaceNode = astNode as InterfaceDeclarationSyntax;
                    if (classNode == null && enumNode == null && interfaceNode == null)
                    {
                        return false;
                    }

                    var helper = new AttributeLists(typeDeclarationNode);
                    return RetrieveScriptNamespaceAttribute(helper) != null;
                },
                delegate (SyntaxNode astNode)
                {
                    var typeDeclarationNode = astNode as BaseTypeDeclarationSyntax;
                    var scriptNamespaceAttributeHelper = RetrieveScriptNamespaceAttribute(new AttributeLists(typeDeclarationNode));

                    AttributeListSyntax scriptNamespaceAttributeListSyntax = scriptNamespaceAttributeHelper.AttributeDecoration.AttributeList; // The list where ScriptNamespace belongs to
                    AttributeSyntax scriptNamespaceAttributeSyntax = scriptNamespaceAttributeHelper.AttributeDecoration.AttributeNode; // The ScriptNamespace attribute

                    // We create a new class node with the attribute removed
                    SeparatedSyntaxList<AttributeSyntax> newAttributeListSyntaxAttributes = scriptNamespaceAttributeListSyntax.Attributes.Remove(scriptNamespaceAttributeSyntax);
                    AttributeListSyntax newAttributeListSyntax = SyntaxFactory.AttributeList(newAttributeListSyntaxAttributes);

                    SyntaxList<AttributeListSyntax> newAttributeLists = typeDeclarationNode.AttributeLists.Remove(scriptNamespaceAttributeListSyntax);
                    newAttributeLists = newAttributeLists.Add(newAttributeListSyntax);

                    BaseTypeDeclarationSyntax newTypeDeclarationSyntax = typeDeclarationNode.RemoveNode(scriptNamespaceAttributeListSyntax, SyntaxRemoveOptions.KeepNoTrivia);

                    if (newTypeDeclarationSyntax as ClassDeclarationSyntax != null)
                    {
                        (newTypeDeclarationSyntax as ClassDeclarationSyntax).WithAttributeLists(newAttributeLists);
                    }
                    else if (newTypeDeclarationSyntax as InterfaceDeclarationSyntax != null)
                    {
                        (newTypeDeclarationSyntax as InterfaceDeclarationSyntax).WithAttributeLists(newAttributeLists);
                    }
                    else if (newTypeDeclarationSyntax as EnumDeclarationSyntax != null)
                    {
                        (newTypeDeclarationSyntax as EnumDeclarationSyntax).WithAttributeLists(newAttributeLists);
                    }
                    else
                    {
                        throw new InvalidOperationException("Not recognized type at rearrangement phase. Expecting classes and interfaces only!");
                    }

                    // Asserting that the overriden namespace has a proper value
                    if (string.IsNullOrEmpty(scriptNamespaceAttributeHelper.OverridenNamespace) ||
                        string.IsNullOrWhiteSpace(scriptNamespaceAttributeHelper.OverridenNamespace))
                    {
                        throw new InvalidOperationException("The ScriptNamespace attribute contains an overriden namespace value which cannot be accepted!");
                    }

                    var info = new TransformationInfo()
                    {
                        OriginalNode = typeDeclarationNode,
                        TransformedNode = newTypeDeclarationSyntax,
                        OriginalNamespace = this.compilation != null
                            ? this.compilation.GetSemanticModel(this.tree).GetDeclaredSymbol(typeDeclarationNode).ContainingNamespace.ToString()
                            : null,
                        OverridenNamespace = scriptNamespaceAttributeHelper.OverridenNamespace
                    };

                    this.transformationInfos.Add(info);
                })
                .Start();
        }
    private bool SetDialogMode()
    {
        if (!string.IsNullOrEmpty(mTransformationName))
        {
            // Error message variable
            string errorMessage = null;

            // Get transformation info
            ti = TransformationInfoProvider.GetTransformation(mTransformationName);
            if (ti != null)
            {
                transformationId = ti.TransformationID;
                mClassName = DataClassInfoProvider.GetClassName(ti.TransformationClassID);

                // Check if document type is registered under current site
                DataSet ds = ClassSiteInfoProvider.GetClassSites("ClassID", "ClassID = " + ti.TransformationClassID + " AND SiteID = " + CMSContext.CurrentSiteID, null, -1);
                if (DataHelper.DataSourceIsEmpty(ds) && !user.UserSiteManagerAdmin)
                {
                    // Set error message
                    errorMessage = GetString("formcontrols_selecttransformation.classnotavailablesite").Replace("%%code%%", HTMLHelper.HTMLEncode(mClassName));
                }
                else
                {
                    tbTransformationName.ReadOnly = true;
                }
            }
            else
            {
                // Set error message
                errorMessage = GetString("formcontrols_selecttransformation.transofrmationnotexist").Replace("%%code%%", HTMLHelper.HTMLEncode(mTransformationName));
            }

            // Hide panel Menu and write error message
            if (!String.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
                pnlCheckOutInfo.Visible = plcControl.Visible = false;
                pnlContent.CssClass = "PageContent";
                return true;
            }
        }
        else
        {
            // Set page title
            mCurrentMaster.Title.TitleText = GetString("documenttype_edit_transformation_edit.newtransformation");
            mCurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Transformation/transformation_new.png");

            // Display class selector
            UseClassSelector = true;
            filter.SelectedValue = QueryHelper.GetString("selectedvalue", null);
            filter.FilterMode = SettingsObjectType.TRANSFORMATION;
        }

        pnlContent.CssClass = "PageContent";

        SetDialogButtons();

        return false;
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        ti = UIContext.EditedObject as TransformationInfo;
        user = MembershipContext.AuthenticatedUser;

        if (!RequestHelper.IsPostBack())
        {
            DropDownListInit();

            if (ti != null)
            {
                // Fills form with transformation information
                drpType.SelectedValue = ti.TransformationType.ToString();
                txtCSS.Text = ti.TransformationCSS;

                if (ti.TransformationType == TransformationTypeEnum.Html)
                {
                    tbWysiwyg.ResolvedValue = ti.TransformationCode;
                    tbWysiwyg.Visible = true;
                }
                else
                {
                    txtCode.Text = ti.TransformationCode;
                    txtCode.Visible = true;
                }
            }
            else
            {
                txtCode.Visible = true;
            }
        }
    }
Ejemplo n.º 45
0
	// Color animation
	public IEnumerator DoColorAnimation(GameObject target, TransformationInfo transformationInfo, bool isLooping, bool isReversed)
	{			
		if(target != null)
		{
			yield return 1;
			
			Color fromValue = Color.white;
			Color toValue = Color.white;
			
			EZAnimation.EASING_TYPE currentEasing = transformationInfo.NormalEasing;
			if(isReversed)
				currentEasing = transformationInfo.ReverseEasing;

			// All animation
			foreach(TransformationKeyInfo transformationKeyInfo in transformationInfo.TransformationKeyList)
			{
				if(target != null)
				{
					// Relative animation
					/*if(transformationKeyInfo.IsRelative)
					{	
						fromValue = target.renderer.material.color;
						
						// Reverse
						Vector3 newValue = Vector3.zero;
						if(isReversed)
						{
							newValue = new Vector3(fromValue.r, fromValue.g, fromValue.b) - transformationKeyInfo.To;
							toValue = new Color(newValue.x, newValue.y, newValue.z);
						}
						else
						{
							newValue =  new Vector3(fromValue.r, fromValue.g, fromValue.b) + transformationKeyInfo.To;
							toValue = new Color(newValue.x, newValue.y, newValue.z);
						}
					}
					else
					{*/
						fromValue = transformationKeyInfo.FromColor;
						toValue = transformationKeyInfo.ToColor;
					//}
					 
					float duration = GetDuration(transformationKeyInfo.Duration);
					test(target.transform, fromValue, toValue, currentEasing, duration);
					yield return new WaitForSeconds(duration);
				}
			}
		
			// Re call if loop
			if(isLooping && target != null)
				m_manager.StartCoroutine(DoColorAnimation(target, transformationInfo, isLooping, isReversed));
		}
	}