Exemplo n.º 1
0
    /// <summary>
    /// Validates inputs.
    /// </summary>
    /// <returns>True if valid</returns>
    private bool ValidateEntries()
    {
        string codeName = txtName.Text.Trim();
        // Validate
        string errorMessage = new Validator().NotEmpty(codeName, GetString("general.invalidcodename")).IsRegularExp(codeName, ValidationHelper.CodenameRegExp.ToString(), GetString("general.invalidcodename")).Result;

        if (errorMessage != string.Empty)
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
            return(false);
        }
        else
        {
            string       value       = null;
            EditingForms editingForm = (EditingForms)Convert.ToInt32(drpEditControl.SelectedValue);

            // Check content
            switch (editingForm)
            {
            case EditingForms.TextArea:
                value = txtAreaContent.Text.Trim();
                break;

            case EditingForms.HTMLEditor:
                value = htmlContent.ResolvedValue;
                break;

            case EditingForms.EditableImage:
                value = imageContent.GetContent();
                break;

            case EditingForms.TextBox:
                value = txtContent.Text.Trim();
                break;
            }

            errorMessage = new Validator().NotEmpty(value, GetString("EditableContent.NotEmpty")).Result;

            if (!String.IsNullOrEmpty(errorMessage))
            {
                lblError.Visible = true;
                lblError.Text    = errorMessage;
                return(false);
            }
        }
        return(true);
    }
Exemplo n.º 2
0
    private void DocumentManager_OnAfterAction(object sender, DocumentManagerEventArgs e)
    {
        EditingForms editingForm = (EditingForms)Convert.ToInt32(drpEditControl.SelectedValue);

        // Code name
        string codeName = txtName.Text.Trim().ToLowerCSafe();

        if (txtName.Text != string.Empty)
        {
            keyName = codeName;
        }

        // Refresh tree
        if (createNew)
        {
            ltlScript.Text +=
                ScriptHelper.GetScript("parent.frames['tree'].location.replace('" +
                                       ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/Advanced/EditableContent/tree.aspx") + "?nodeid=" +
                                       node.NodeID + "&selectednodename=" + codeName + "&selectednodetype=" + keyType +
                                       "');SelectNode('" + codeName + "', '" + keyType + "')");
            if (editingForm == EditingForms.EditableImage)
            {
                ltlScript.Text +=
                    ScriptHelper.GetScript("SelectNodeAfterImageSave(" + ScriptHelper.GetString(keyName) + ", '" + keyType + "');");
            }
        }
        else
        {
            if (e.ActionName == DocumentComponentEvents.UNDO_CHECKOUT)
            {
                // Refresh content
                content                   = GetContent();
                txtAreaContent.Text       = content;
                htmlContent.ResolvedValue = content;
                txtContent.Text           = content;
            }

            ltlScript.Text +=
                ScriptHelper.GetScript("RefreshNode(" + ScriptHelper.GetString(codeName) + ", '" + keyType + "', " + node.NodeID + ");");
        }
        createNew = false;
    }
Exemplo n.º 3
0
    private void DocumentManager_OnValidateData(object sender, DocumentManagerEventArgs e)
    {
        string codeName = txtName.Text.Trim();
        // Validate
        string errorMessage = new Validator().NotEmpty(codeName, GetString("general.invalidcodename")).IsRegularExp(codeName, ValidationHelper.CodenameRegExp.ToString(), GetString("general.invalidcodename")).Result;

        if (errorMessage == string.Empty)
        {
            string       value       = null;
            EditingForms editingForm = (EditingForms)Convert.ToInt32(drpEditControl.SelectedValue);

            // Check content
            switch (editingForm)
            {
            case EditingForms.TextArea:
                value = txtAreaContent.Text.Trim();
                break;

            case EditingForms.HTMLEditor:
                value = htmlContent.ResolvedValue;
                break;

            case EditingForms.EditableImage:
                value = imageContent.GetContent();
                break;

            case EditingForms.TextBox:
                value = txtContent.Text.Trim();
                break;
            }

            errorMessage = new Validator().NotEmpty(value, GetString("EditableContent.NotEmpty")).Result;
        }

        if (!String.IsNullOrEmpty(errorMessage))
        {
            e.ErrorMessage = errorMessage;
            e.IsValid      = false;
        }
    }
Exemplo n.º 4
0
    private void DocumentManager_OnSaveData(object sender, DocumentManagerEventArgs e)
    {
        EditingForms editingForm = (EditingForms)Convert.ToInt32(drpEditControl.SelectedValue);

        // Get content to save
        switch (editingForm)
        {
        case EditingForms.TextArea:
            content = txtAreaContent.Text.Trim();
            break;

        case EditingForms.HTMLEditor:
            content = htmlContent.ResolvedValue;
            break;

        case EditingForms.EditableImage:
            content = imageContent.GetContent();
            break;

        case EditingForms.TextBox:
            content = txtContent.Text.Trim();
            break;
        }

        if (!QueryHelper.GetBoolean("imagesaved", false))
        {
            createNew = !node.DocumentContent.EditableWebParts.Contains(keyName) &&
                        !node.DocumentContent.EditableRegions.ContainsKey(keyName);
        }

        // Code name
        string codeName = txtName.Text.Trim().ToLowerCSafe();

        // Set PageInfo
        switch (keyType)
        {
        case EditableContentType.webpart:
            if (!createNew)
            {
                // If editing -> remove old
                node.DocumentContent.EditableWebParts.Remove(keyName);
            }

            if (!node.DocumentContent.EditableWebParts.ContainsKey(codeName))
            {
                node.DocumentContent.EditableWebParts.Add(codeName, content);
            }
            else
            {
                ShowError(GetString("EditableContent.ItemExists"));
                return;
            }
            break;

        case EditableContentType.region:
            if (!createNew)
            {
                // If editing -> remove old
                node.DocumentContent.EditableRegions.Remove(keyName);
            }

            if (!node.DocumentContent.EditableRegions.ContainsKey(codeName))
            {
                node.DocumentContent.EditableRegions.Add(codeName, content);
            }
            else
            {
                ShowError(GetString("EditableContent.ItemExists"));
                return;
            }
            break;
        }

        // Get content
        content = node.DocumentContent.GetContentXml();
        node.UpdateOriginalValues();
        node.SetValue("DocumentContent", content);
    }
Exemplo n.º 5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        // Check modify permissions
        if (!IsAuthorizedToModify())
        {
            return;
        }

        EditingForms editingForm = (EditingForms)Convert.ToInt32(drpEditControl.SelectedValue);

        // Get content to save
        switch (editingForm)
        {
        case EditingForms.TextArea:
            content = txtAreaContent.Text.Trim();
            break;

        case EditingForms.HTMLEditor:
            content = htmlContent.ResolvedValue;
            break;

        case EditingForms.EditableImage:
            content = imageContent.GetContent();
            break;

        case EditingForms.TextBox:
            content = txtContent.Text.Trim();
            break;
        }

        if (!ValidateEntries())
        {
            return;
        }

        if (!QueryHelper.GetBoolean("imagesaved", false))
        {
            createNew = !node.DocumentContent.EditableWebParts.Contains(keyName) &&
                        !node.DocumentContent.EditableRegions.ContainsKey(keyName);
        }

        // Code name
        string codeName = txtName.Text.Trim().ToLower();

        // Set PageInfo
        switch (keyType)
        {
        case EditableContentType.webpart:
            if (!createNew)
            {
                // If editing -> remove old
                node.DocumentContent.EditableWebParts.Remove(keyName);
            }

            if (!node.DocumentContent.EditableWebParts.ContainsKey(codeName))
            {
                node.DocumentContent.EditableWebParts.Add(codeName, content);
            }
            else
            {
                // Set error label
                lblError.Visible = true;
                lblError.Text    = GetString("EditableContent.ItemExists");
                return;
            }
            break;

        case EditableContentType.region:
            if (!createNew)
            {
                // If editing -> remove old
                node.DocumentContent.EditableRegions.Remove(keyName);
            }

            if (!node.DocumentContent.EditableRegions.ContainsKey(codeName))
            {
                node.DocumentContent.EditableRegions.Add(codeName, content);
            }
            else
            {
                // Set error label
                lblError.Visible = true;
                lblError.Text    = GetString("EditableContent.ItemExists");
                return;
            }
            break;
        }

        // Save node
        SaveNode();

        if (txtName.Text != string.Empty)
        {
            keyName = codeName;
        }

        // Reload menu
        menuElem.Node = node;
        menuElem.ReloadMenu();

        // Inform user
        lblInfo.Text    = GetString("general.changessaved");
        lblInfo.Visible = true;

        // Refresh tree
        if (createNew)
        {
            ltlScript.Text +=
                ScriptHelper.GetScript("parent.frames['tree'].location.replace('" +
                                       ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/Advanced/EditableContent/tree.aspx") + "?nodeid=" +
                                       nodeId + "&selectednodename=" + codeName + "&selectednodetype=" + keyType +
                                       "');SelectNode('" + codeName + "', '" + keyType + "')");
            if (editingForm == EditingForms.EditableImage)
            {
                ltlScript.Text +=
                    ScriptHelper.GetScript("SelectNodeAfterImageSave(" + ScriptHelper.GetString(keyName) + ", '" + keyType + "');");
            }
        }
        else
        {
            ltlScript.Text +=
                ScriptHelper.GetScript("RefreshNode(" + ScriptHelper.GetString(codeName) + ", '" + keyType + "', " + nodeId + ");");
        }
        createNew = false;
    }