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 ugTransformations_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            string isManager = IsSiteManager ? "&sitemanager=true" : String.Empty;

            URLHelper.Redirect(String.Format(
                                   "HierarchicalTransformations_Transformations_Edit.aspx?guid={0}&objectid={1}&templatetype={2}&editonlycode={3}&tabmode={4}&instanceguid={5}&aliaspath={6}{7}",
                                   actionArgument,
                                   TransInfo.TransformationID,
                                   TemplateType,
                                   mDialogMode,
                                   QueryHelper.GetInteger("tabmode", 0),
                                   QueryHelper.GetGuid("instanceguid", Guid.Empty),
                                   QueryHelper.GetString("aliaspath", ""), isManager)
                               );
        }
        if (actionName == "delete")
        {
            HierarchicalTransformations transf = LoadTransformation();
            transf.DeleteTransformation(new Guid(Convert.ToString(actionArgument)));
            TransInfo.TransformationHierarchicalXML = transf.GetXML();
            TransformationInfoProvider.SetTransformation(TransInfo);

            //Reloads data
            ugTransformations.ReloadData();
        }
    }
    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";
        }
    }
Example #4
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>
 /// 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);
         }
     }
 }
    private void InitializeAddress()
    {
        if (Customer == null)
        {
            return;
        }

        var addresses = AddressInfoProvider.GetAddresses(Customer.CustomerID).ToArray();

        foreach (AddressInfo addr in addresses)
        {
            if (!this.IsPostBack)
            {
                var li = new ListItem(addr.AddressID.ToString());
                li.Value = addr.AddressID.ToString();

                this.hiddenAddressesList.Items.Add(li);
                li.Selected = CurrentCartAddress != null ? CurrentCartAddress.AddressID == addr.AddressID : addresses.FirstOrDefault().Equals(addr);
            }

            var transformation = TransformationInfoProvider.GetTransformation("kda.checkoutpage.ShippingAddress");

            var resolver = MacroResolver.GetInstance();
            resolver.SetNamedSourceData("ShippingAddress", addr);
            resolver.SetNamedSourceData("StateCode", addr.GetStateCode());
            resolver.SetNamedSourceData("Checked", (CurrentCartAddress != null ? CurrentCartAddress.AddressID == addr.AddressID : addresses.FirstOrDefault().Equals(addr)) ? "checked":"");
            htmlContent.Text += resolver.ResolveMacros(transformation.TransformationCode);
        }
    }
        public void Update(Status status)
        {
            if (MainWindow.IsShuttingDown)
            {
                return;
            }
            Dispatcher.Invoke(() => {
                if (!status.Ready)
                {
                    _started = false;
                    MainPanel.Children.Clear();
                    return;
                }

                if (!_started)
                {
                    _started = true;
                    TransformationInfoProvider.GetAllTransformations().ToList().ForEach(pair => {
                        var transformation = pair.Value;
                        if (CreationMode.On)
                        {
                            CreationMode.Transformations.Add(transformation);
                        }
                        MainPanel.Children.Add(new TransformationGrid(transformation));
                    });
                }

                if (!CreationMode.On)
                {
                    TransformationInfoProvider.UpdateTransformations();
                }
            });
        }
    public void GenerateDefaultTransformation(DefaultTransformationTypeEnum transformCode)
    {
        if (String.IsNullOrEmpty(ClassName))
        {
            ClassName = DataClassInfoProvider.GetClassName(ClassID);
        }

        // Gets Xml schema of the document type
        DataClassInfo dci     = DataClassInfoProvider.GetDataClassInfo(ClassName);
        string        formDef = string.Empty;

        if (dci != null)
        {
            formDef = dci.ClassFormDefinition;
        }

        // Gets transformation type
        TransformationTypeEnum transformType = TransformationInfoProvider.GetTransformationTypeEnum(drpType.SelectedValue);

        // Writes the result to the text box
        if (transformType == TransformationTypeEnum.Html)
        {
            txtCode.Visible         = false;
            tbWysiwyg.Visible       = true;
            tbWysiwyg.ResolvedValue = TransformationInfoProvider.GenerateTransformationCode(formDef, transformType, ClassName, transformCode);
        }
        else
        {
            tbWysiwyg.Visible = false;
            txtCode.Visible   = true;
            txtCode.Text      = TransformationInfoProvider.GenerateTransformationCode(formDef, transformType, ClassName, transformCode);
        }
    }
    /// <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.ToLowerCSafe() == "edit")
        {
            int transID = ValidationHelper.GetInteger(actionArgument, 0);
            if (transID != 0)
            {
                var ti = TransformationInfoProvider.GetTransformation(transID);
                if (ti != null)
                {
                    var url = EditPageUrl;

                    var query = String.Format(
                        "objectid={0}&parentobjectid={1}&displaytitle=false&hash={2}{3}",
                        transID,
                        ClassID,
                        QueryHelper.GetHash("?objectid=" + transID + "&parentobjectid=" + ClassID),
                        (ModuleID > 0 ? "&moduleid=" + ModuleID : String.Empty)
                        );

                    url = URLHelper.AppendQuery(url, query);

                    URLHelper.Redirect(url);
                }
            }
        }
        else if (actionName.ToLowerCSafe() == "delete")
        {
            int transformationId = ValidationHelper.GetInteger(actionArgument, -1);
            if (transformationId > 0)
            {
                TransformationInfoProvider.DeleteTransformation(transformationId);
            }
        }
    }
Example #10
0
 /// <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();
                 }
             }
         }
     }
 }
    /// <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();
            }
        }
    }
Example #12
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);
    }
        public static void UpdateTransformationsInfo(bool showTransformationImage)
        {
            var updatedTransformationInfo = TransformationInfoProvider.GetTransformationsInfo();

            TransformationInfoProvider.GetAllTransformations().Values.ToList().ForEach(transformation => {
                UpdateTransformationInfo(transformation, showTransformationImage, updatedTransformationInfo);
            });
        }
Example #14
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 btnOK_Click(object sender, EventArgs e)
    {
        //Validate data
        string errorMessage = new Validator().NotEmpty(ucTransformations.Value, GetString("transformationedit.erroremptytransformation")).Result;

        if ((errorMessage == "") && (txtLevel.Text.Trim() != String.Empty) && (!ValidationHelper.IsInteger(txtLevel.Text)))
        {
            errorMessage = GetString("development.invalidtransformationlevel");
        }

        if (String.IsNullOrEmpty(txtLevel.Text))
        {
            txtLevel.Text = "-1";
        }

        int level = ValidationHelper.GetInteger(txtLevel.Text, -1);

        if (level < -1)
        {
            errorMessage = GetString("development.invalidtransformationlevel");
        }

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

        //Fill the info
        if (mHierInfo == null)
        {
            mHierInfo        = new HierarchicalTransformationInfo();
            mHierInfo.ItemID = Guid.NewGuid();
        }


        mHierInfo.ItemLevel          = ValidationHelper.GetInteger(txtLevel.Text, 0);
        mHierInfo.TransformationName = ucTransformations.Value.ToString();
        mHierInfo.Value    = ucClassSelector.Value.ToString();
        mHierInfo.ItemType = HierarchicalTransformations.StringToUniViewItemType(drpTemplateType.SelectedValue);

        if ((mTransformations != null) && (TransInfo != null))
        {
            mTransformations.SetTransformation(mHierInfo);
            TransInfo.TransformationHierarchicalXML = mTransformations.GetXML();
            TransformationInfoProvider.SetTransformation(TransInfo);
            HierarchicalID = mHierInfo.ItemID;

            RaiseOnSaved();
        }

        lblInfo.Visible  = true;
        lblError.Visible = false;
    }
Example #16
0
    private void DisplayCouponCodes()
    {
        var transformation = TransformationInfoProvider.GetTransformation(CouponCodeTransformationName);

        if (transformation != null)
        {
            rptrCouponCodes.ItemTemplate = TransformationHelper.LoadTransformation(rptrCouponCodes, transformation.TransformationFullName);
        }

        rptrCouponCodes.DataSource = GetViewModel();
        rptrCouponCodes.DataBind();
    }
    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"));
    }
    /// <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);
                }
            }
        }
    }
Example #19
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"),
        });
    }
Example #20
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"));
        }
    }
    /// <summary>
    /// Renders script for custom transformation.
    /// </summary>
    /// <param name="renderer">Instance of Strands script renderer</param>
    /// <param name="template">Selected template</param>
    /// <exception cref="StrandsException">Transformation does not exist</exception>
    private void RenderCustomTransformation(StrandsScriptRenderer renderer, StrandsWebTemplateData template)
    {
        var transformation = TransformationInfoProvider.GetTransformation(CustomTransformation);

        if (transformation == null)
        {
            throw new StrandsException("[StrandsRecommendations.ParseRecommendationTemplate]: Cannot load the transformation specified in the web part.", ResHelper.GetString("strands.recommendations.transformations.errorloadingtransformation"));
        }
        if (transformation.TransformationType != TransformationTypeEnum.jQuery)
        {
            throw new StrandsException("[StrandsRecommendations.ParseRecommendationTemplate]: Transformation type has to be of type jQuery.", ResHelper.GetString("strands.recommendations.transformations.wrongtype"));
        }

        renderer.RenderCustomizedRendererScript(transformation, template.ID, strandsRecs.ClientID);
    }
    /// <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;
            }
        }
    }
Example #23
0
    /// <summary>
    /// Initialize filter.
    /// </summary>
    private void Initialize()
    {
        if (!String.IsNullOrEmpty(SelectedValue))
        {
            DataClassInfo selectedClass = null;

            switch (FilterMode)
            {
            case TransformationInfo.OBJECT_TYPE:
                var transformation = TransformationInfoProvider.GetTransformation(SelectedValue);
                if (transformation != null)
                {
                    selectedClass = DataClassInfoProvider.GetDataClassInfo(transformation.TransformationClassID);
                }
                break;

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

            // If selected object is under custom class, change selected class type
            if (selectedClass != null)
            {
                if (selectedClass.ClassIsCustomTable)
                {
                    var selectedItem = ControlsHelper.FindItemByValue(drpClassType, CUSTOM_TABLE, false);

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

                uniSelector.Value = selectedClass.ClassID;
            }
        }
    }
Example #24
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;
            }
        }
    }
Example #25
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;
    }
Example #26
0
    protected void ugTransformations_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            string isManager = IsSiteManager ? "&sitemanager=true" : String.Empty;
            URLHelper.Redirect("HierarchicalTransformations_Transformations_Edit.aspx?guid=" + actionArgument + "&transid=" + TransInfo.TransformationID + "&templatetype=" + TemplateType + "&editonlycode=" + mDialogMode + "&tabmode=" + QueryHelper.GetInteger("tabmode", 0) + isManager);
        }
        if (actionName == "delete")
        {
            HierarchicalTransformations transf = LoadTransformation();
            transf.DeleteTransformation(new Guid(Convert.ToString(actionArgument)));
            TransInfo.TransformationHierarchicalXML = transf.GetXML();
            TransformationInfoProvider.SetTransformation(TransInfo);

            //Reloads data
            ugTransformations.ReloadData();
        }
    }
    /// <summary>
    /// Gets the transformation object for current context
    /// </summary>
    private TransformationInfo GetTransformation()
    {
        var ti = TransformationInfoProvider.GetTransformation(QueryHelper.GetInteger("objectid", 0));

        if (ti == null)
        {
            // Load transformation by name
            ti = TransformationInfoProvider.GetTransformation(QueryHelper.GetString("objectid", ""));

            // Setup context properly
            var ctx = Control.UIContext;

            ctx.EditedObject = ti;
            ctx.ObjectID     = ti.TransformationID;
        }

        return(ti);
    }
Example #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;
    }
    /// <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);
        }
    }