Esempio n. 1
0
    /// <summary>
    /// Add translation control to the list of action buttons
    /// </summary>
    /// <param name="tsi">Translation service object used to initialize the control</param>
    /// <param name="siteName">Site name to check for service availability</param>
    private void AddTranslationControl(TranslationServiceInfo tsi, string siteName)
    {
        string arg = "'##SERVICE##|' + document.getElementById('" + (TranslationElementClientID ?? InputClientID) + @"').value";

        if (TranslationServiceHelper.IsServiceAvailable(tsi.TranslationServiceName, siteName))
        {
            var ctrl = new CMSAccessibleButton();
            cntElem.ActionsContainer.Controls.Add(ctrl);

            ctrl.IconCssClass = "icon-" + tsi.TranslationServiceName.ToLowerCSafe();
            ctrl.ToolTip      = string.Format("{0} {1}", ResHelper.GetString("translations.translateusing"), tsi.TranslationServiceDisplayName);

            // Get callback reference for translation
            string cbRef = Page.ClientScript.GetCallbackEventReference(this, arg.Replace("##SERVICE##", tsi.TranslationServiceName), "SetValueToTextBox", "'" + InputClientID + ";" + ctrl.ClientID + "_icon;" + ctrl.IconCssClass + "'", true);
            ctrl.OnClientClick = "StartProgress('" + ctrl.ClientID + "_icon'); " + cbRef + ";return false;";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Unigrid
        gridElem.HideControlForZeroRows = false;
        gridElem.OrderBy              = "KeyOrder";
        gridElem.OnAction            += KeyAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
        gridElem.ZeroRowsText         = GetString("settings.group.nokeysfound");

        if (Category != null)
        {
            string catIdStr = Category.CategoryID.ToString();

            // Action buttons
            var rightPanel = cpCategory.RightPanel;

            // Edit action
            var editButton = new CMSAccessibleButton
            {
                ToolTip      = GetString("general.edit"),
                IconCssClass = "icon-edit",
                IconOnly     = true
            };

            editButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("edit", catIdStr));
            rightPanel.Controls.Add(editButton);

            if (AllowEdit)
            {
                // Delete action
                var deleteButton = new CMSAccessibleButton
                {
                    ToolTip       = GetString("general.delete"),
                    IconCssClass  = "icon-bin",
                    IconOnly      = true,
                    OnClientClick = string.Format("if (!confirm({0})) {{ return false; }}", ScriptHelper.GetString(GetString("Development.CustomSettings.GroupDeleteConfirmation")))
                };

                deleteButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("delete", catIdStr));
                rightPanel.Controls.Add(deleteButton);

                // Move up action
                var moveUpButton = new CMSAccessibleButton
                {
                    ToolTip      = GetString("general.moveup"),
                    IconCssClass = "icon-chevron-up",
                    IconOnly     = true
                };

                moveUpButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("moveup", catIdStr));
                rightPanel.Controls.Add(moveUpButton);

                // Move down action
                var moveDownButton = new CMSAccessibleButton
                {
                    ToolTip      = GetString("general.movedown"),
                    IconCssClass = "icon-chevron-down",
                    IconOnly     = true
                };

                moveDownButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("movedown", catIdStr));
                rightPanel.Controls.Add(moveDownButton);

                // Setup "Add key" button
                btnNewKey.Text   = ResHelper.GetString("Development.CustomSettings.NewKey");
                btnNewKey.Click += CreateNewKey;

                cprModuleInfoRow.Visible = false;
                cprRow01.Visible         = true;
            }
            else
            {
                ResourceInfo currentModule  = ResourceInfoProvider.GetResourceInfo(ModuleID);
                ResourceInfo categoryModule = ResourceInfoProvider.GetResourceInfo(Category.CategoryResourceID);

                // Show warning if current module is in development mode, if not global warning is shown on the top of page
                if ((categoryModule != null) && (currentModule != null) && currentModule.ResourceIsInDevelopment)
                {
                    lblAnotherModule.Text    = HTMLHelper.HTMLEncode(String.Format(GetString("settingscategory.disablededitting"), categoryModule.ResourceDisplayName));
                    cprModuleInfoRow.Visible = true;
                }
                else
                {
                    cprModuleInfoRow.Visible = false;
                }

                cprRow01.Visible = false;
            }

            gridElem.ShowObjectMenu = AllowEdit;

            // Panel title for group
            cpCategory.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(Category.CategoryDisplayName));

            // Filter out only records for this group
            gridElem.WhereCondition = "KeyCategoryID = " + Category.CategoryID;
        }

        // Apply site filter if required.
        if (!string.IsNullOrEmpty(gridElem.WhereCondition))
        {
            gridElem.WhereCondition += " AND ";
        }

        gridElem.WhereCondition += "SiteID IS NULL";
    }
Esempio n. 3
0
    /// <summary>
    /// UniGrid data bound.
    /// </summary>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSAccessibleButton btn = null;

        DataRowView drv = parameter as DataRowView;

        switch (sourceName.ToLowerCSafe())
        {
        // Display delete button
        case "delete":
            btn = (CMSGridActionButton)sender;
            btn.OnClientClick = string.Format("dialogParams_{0} = '{1}';{2};return false;",
                                              ClientID,
                                              btn.CommandArgument,
                                              Page.ClientScript.GetCallbackEventReference(this, "dialogParams_" + ClientID, "Delete", null));

            // Display delete button only for users with appropriate permission
            if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD)
            {
                drv = ((GridViewRow)parameter).DataItem as DataRowView;
                if (ValidationHelper.GetInteger(drv["AccountSiteID"], 0) > 0)
                {
                    btn.Enabled = modifySite;
                }
                else
                {
                    btn.Enabled = modifyGlobal;
                }
            }
            else
            {
                btn.Enabled = modifyPermission;
            }
            if (!btn.Enabled)
            {
                btn.Enabled = false;
            }
            break;

        // Display information if account is merged
        case "accountmergedwithaccountid":
            int mergedIntoSite   = ValidationHelper.GetInteger(drv["AccountMergedWithAccountID"], 0);
            int mergedIntoGlobal = ValidationHelper.GetInteger(drv["AccountGlobalAccountID"], 0);
            int siteID           = ValidationHelper.GetInteger(drv["AccountSiteID"], 0);
            if (((siteID > 0) && (mergedIntoSite > 0)) || ((siteID == 0) && (mergedIntoGlobal > 0)))
            {
                return(GetString("general.yes"));
            }
            return(null);

        case "primarycontactname":
            string name = ValidationHelper.GetString(drv["PrimaryContactFullName"], "");
            if (!string.IsNullOrEmpty(name.Trim()))
            {
                string contactDetailsDialogURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", ValidationHelper.GetInteger(drv["AccountPrimaryContactID"], 0));

                var placeholder = new PlaceHolder();
                placeholder.Controls.Add(new Label
                {
                    Text     = HTMLHelper.HTMLEncode(name),
                    CssClass = "contactmanagement-accountlist-primarycontact"
                });

                placeholder.Controls.Add(new CMSGridActionButton
                {
                    IconCssClass  = "icon-edit",
                    OnClientClick = ScriptHelper.GetModalDialogScript(contactDetailsDialogURL, "ContactDetail"),
                    ToolTip       = GetString("om.contact.viewdetail")
                });

                return(placeholder);
            }
            return(null);
        }
        return(null);
    }
    protected void ThumbnailsViewControl_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        #region "Load the item data"

        var data = new DataRowContainer((DataRowView)e.Item.DataItem);

        string fileNameColumn = FileNameColumn;
        string className = "";

        bool isContent = (SourceType == MediaSourceEnum.Content);

        bool isContentFile = isContent && data.GetValue("ClassName").ToString().EqualsCSafe("cms.file", true);
        bool notAttachment = isContent && !(isContentFile && (data.GetValue("AttachmentGUID") != DBNull.Value));
        if (notAttachment)
        {
            className = DataClassInfoProvider.GetDataClassInfo((int)data.GetValue("NodeClassID")).ClassDisplayName;

            fileNameColumn = "DocumentName";
        }

        // Get information on file
        string fileName = HTMLHelper.HTMLEncode(data.GetValue(fileNameColumn).ToString());
        string ext = HTMLHelper.HTMLEncode(notAttachment ? className : data.GetValue(FileExtensionColumn).ToString().TrimStart('.'));
        string argument = RaiseOnGetArgumentSet(data);

        // Get full media library file name
        bool isInDatabase = true;
        string fullFileName = GetFileName(data);

        IDataContainer importedMediaData = null;

        if (SourceType == MediaSourceEnum.MediaLibraries)
        {
            importedMediaData = RaiseOnFileIsNotInDatabase(fullFileName);
            isInDatabase = (importedMediaData != null);
        }

        bool libraryFolder = ((SourceType == MediaSourceEnum.MediaLibraries) && IsFullListingMode && (data.GetValue(FileExtensionColumn).ToString().ToLowerCSafe() == "<dir>"));
        bool libraryUiFolder = libraryFolder && !((DisplayMode == ControlDisplayModeEnum.Simple) && isInDatabase);

        int width = 0;
        int height = 0;
        // Get thumb preview image dimensions
        int[] thumbImgDimension = { 0, 0 };
        if (ImageHelper.IsSupportedByImageEditor(ext))
        {
            // Width & height
            if (data.ContainsColumn(FileWidthColumn))
            {
                width = ValidationHelper.GetInteger(data.GetValue(FileWidthColumn), 0);
            }
            else if (isInDatabase && importedMediaData.ContainsColumn(FileWidthColumn))
            {
                width = ValidationHelper.GetInteger(importedMediaData.GetValue(FileWidthColumn), 0);
            }

            if (data.ContainsColumn(FileHeightColumn))
            {
                height = ValidationHelper.GetInteger(data.GetValue(FileHeightColumn), 0);
            }
            else if (isInDatabase && importedMediaData.ContainsColumn(FileHeightColumn))
            {
                height = ValidationHelper.GetInteger(importedMediaData.GetValue(FileHeightColumn), 0);
            }

            thumbImgDimension = CMSDialogHelper.GetThumbImageDimensions(height, width, MaxThumbImgHeight, MaxThumbImgWidth);
        }

        // Preview parameters
        IconParameters previewParameters = null;
        if ((SourceType == MediaSourceEnum.MediaLibraries) && isInDatabase)
        {
            previewParameters = RaiseOnGetThumbsItemUrl(importedMediaData, true, thumbImgDimension[0], thumbImgDimension[1], 0, notAttachment);
        }
        else
        {
            previewParameters = RaiseOnGetThumbsItemUrl(data, true, thumbImgDimension[0], thumbImgDimension[1], 0, notAttachment);
        }

        // Item parameters
        IconParameters selectUrlParameters = RaiseOnGetThumbsItemUrl(data, false, 0, 0, 0, notAttachment);
        bool isSelectable = CMSDialogHelper.IsItemSelectable(SelectableContent, ext, isContentFile);

        #endregion

        #region "Standard controls and actions"

        // Load file name
        Label lblName = e.Item.FindControl("lblFileName") as Label;
        if (lblName != null)
        {
            lblName.Text = fileName;
        }

        // Initialize SELECT button
        var btnWarning = e.Item.FindControl("btnWarning") as CMSAccessibleButton;
        if (btnWarning != null)
        {
            // If media file not imported yet - display warning sign
            if (isSelectable && (SourceType == MediaSourceEnum.MediaLibraries) && ((DisplayMode == ControlDisplayModeEnum.Simple) && !isInDatabase && !libraryFolder && !libraryUiFolder))
            {
                btnWarning.ToolTip = GetString("media.file.import");
                btnWarning.OnClientClick = String.Format("ColorizeRow({0}); SetAction('importfile',{1}); RaiseHiddenPostBack(); return false;", ScriptHelper.GetString(GetColorizeID(data)), ScriptHelper.GetString(fullFileName));
            }
            else
            {
                PlaceHolder plcWarning = e.Item.FindControl("plcWarning") as PlaceHolder;
                if (plcWarning != null)
                {
                    plcWarning.Visible = false;
                }
            }
        }

        // Initialize SELECTSUBDOCS button
        var btnSelectSubDocs = e.Item.FindControl("btnSelectSubDocs") as CMSAccessibleButton;
        if (btnSelectSubDocs != null)
        {
            if (IsFullListingMode && (SourceType == MediaSourceEnum.Content))
            {
                int nodeId = ValidationHelper.GetInteger(data.GetValue("NodeID"), 0);

                btnSelectSubDocs.ToolTip = GetString("dialogs.list.actions.showsubdocuments");

                // Check if item is selectable, if not remove select action button
                btnSelectSubDocs.OnClientClick = String.Format("SetParentAction('{0}'); return false;", nodeId);
            }
            else
            {
                PlaceHolder plcSelectSubDocs = e.Item.FindControl("plcSelectSubDocs") as PlaceHolder;
                if (plcSelectSubDocs != null)
                {
                    plcSelectSubDocs.Visible = false;
                }
            }
        }

        // Initialize VIEW button
        var btnView = e.Item.FindControl("btnView") as CMSAccessibleButton;
        if (btnView != null)
        {
            if (!notAttachment && !libraryFolder)
            {
                if (String.IsNullOrEmpty(selectUrlParameters.Url))
                {
                    btnView.OnClientClick = "return false;";
                    btnView.Attributes["style"] = "cursor:default;";
                    btnView.Enabled = false;
                }
                else
                {
                    btnView.ToolTip = GetString("dialogs.list.actions.view");
                    btnView.OnClientClick = String.Format("javascript: window.open({0}); return false;", ScriptHelper.GetString(URLHelper.ResolveUrl(selectUrlParameters.Url)));
                }
            }
            else
            {
                btnView.Visible = false;
            }
        }

        // Initialize EDIT button
        var btnContentEdit = e.Item.FindControl("btnContentEdit") as CMSAccessibleButton;
        if (btnContentEdit != null)
        {
            btnContentEdit.ToolTip = GetString("general.edit");

            Guid guid = Guid.Empty;

            if (SourceType == MediaSourceEnum.MediaLibraries && !libraryFolder && !libraryUiFolder)
            {
                // Media files coming from FS
                if (!data.ContainsColumn("FileGUID"))
                {
                    if ((DisplayMode == ControlDisplayModeEnum.Simple) && !isInDatabase)
                    {
                        btnContentEdit.Attributes["style"] = "cursor: default;";
                        btnContentEdit.Enabled = false;
                    }
                    else
                    {
                        btnContentEdit.OnClientClick = String.Format("$cmsj('#hdnFileOrigName').attr('value', {0}); SetAction('editlibraryui', {1}); RaiseHiddenPostBack(); return false;", ScriptHelper.GetString(EnsureFileName(fileName)), ScriptHelper.GetString(fileName));
                    }
                }
                else
                {
                    guid = ValidationHelper.GetGuid(data.GetValue("FileGUID"), Guid.Empty);
                    btnContentEdit.ScreenReaderDescription = String.Format("{0}|MediaFileGUID={1}&sitename={2}", ext, guid, GetSiteName(data, true));
                    btnContentEdit.PreRender += img_PreRender;
                }
            }
            else if (SourceType == MediaSourceEnum.MetaFile)
            {
                // If MetaFiles being displayed set EDIT action
                string metaExtension = ValidationHelper.GetString(data.GetValue("MetaFileExtension"), string.Empty).ToLowerCSafe();
                Guid metaGuid = ValidationHelper.GetGuid(data.GetValue("MetaFileGUID"), Guid.Empty);

                btnContentEdit.ScreenReaderDescription = String.Format("{0}|metafileguid={1}", metaExtension, metaGuid);
                btnContentEdit.PreRender += img_PreRender;
            }
            else if (!notAttachment && !libraryFolder && !libraryUiFolder)
            {
                string nodeid = "";
                if (SourceType == MediaSourceEnum.Content)
                {
                    nodeid = "&nodeId=" + data.GetValue("NodeID");

                    // Get the node workflow
                    VersionHistoryID = ValidationHelper.GetInteger(data.GetValue("DocumentCheckedOutVersionHistoryID"), 0);
                }

                guid = ValidationHelper.GetGuid(data.GetValue("AttachmentGUID"), Guid.Empty);
                btnContentEdit.ScreenReaderDescription = String.Format("{0}|AttachmentGUID={1}&sitename={2}{3}{4}", ext, guid, GetSiteName(data, false), nodeid, ((VersionHistoryID > 0) ? "&versionHistoryId=" + VersionHistoryID : ""));
                btnContentEdit.PreRender += img_PreRender;
            }
            else
            {
                btnContentEdit.Visible = false;
            }
        }

        #endregion

        #region "Special actions"

        // If attachments being displayed show additional actions
        if (SourceType == MediaSourceEnum.DocumentAttachments)
        {
            // Initialize EDIT button
            var btnEdit = e.Item.FindControl("btnEdit") as CMSAccessibleButton;
            if (btnEdit != null)
            {
                if (!notAttachment)
                {
                    btnEdit.ToolTip = GetString("general.edit");

                    // Get file extension
                    string extension = ValidationHelper.GetString(data.GetValue("AttachmentExtension"), "").ToLowerCSafe();
                    Guid guid = ValidationHelper.GetGuid(data.GetValue("AttachmentGUID"), Guid.Empty);

                    btnEdit.ScreenReaderDescription = String.Format("{0}|AttachmentGUID={1}&sitename={2}&versionHistoryId={3}", extension, guid, GetSiteName(data, false), VersionHistoryID);
                    btnEdit.PreRender += img_PreRender;
                }
            }

            // Initialize UPDATE button
            var dfuElem = e.Item.FindControl("dfuElem") as DirectFileUploader;
            if (dfuElem != null)
            {
                GetAttachmentUpdateControl(ref dfuElem, data);
            }

            // Setup external edit
            var ctrl = ExternalEditHelper.LoadExternalEditControl(e.Item.FindControl("plcExtEdit"), FileTypeEnum.Attachment, null, data, IsLiveSite, TreeNodeObj, true);
            if (ctrl != null)
            {
                ctrl.CssClass = null;
            }

            // Initialize DELETE button
            var btnDelete = e.Item.FindControl("btnDelete") as CMSAccessibleButton;
            if (btnDelete != null)
            {
                btnDelete.ToolTip = GetString("general.delete");

                // Initialize command
                btnDelete.OnClientClick = String.Format("if(DeleteConfirmation() == false){{return false;}} SetAction('attachmentdelete','{0}'); RaiseHiddenPostBack(); return false;", data.GetValue("AttachmentGUID"));
            }

            var plcContentEdit = e.Item.FindControl("plcContentEdit") as PlaceHolder;
            if (plcContentEdit != null)
            {
                plcContentEdit.Visible = false;
            }
        }
        else if ((SourceType == MediaSourceEnum.MediaLibraries) && !data.ContainsColumn("FileGUID") && ((DisplayMode == ControlDisplayModeEnum.Simple) && !libraryFolder && !libraryUiFolder))
        {
            // Initialize DELETE button
            var btnDelete = e.Item.FindControl("btnDelete") as CMSAccessibleButton;
            if (btnDelete != null)
            {
                btnDelete.ToolTip = GetString("general.delete");
                btnDelete.OnClientClick = String.Format("if(DeleteMediaFileConfirmation() == false){{return false;}} SetAction('deletefile',{0}); RaiseHiddenPostBack(); return false;", ScriptHelper.GetString(fullFileName));
            }

            // Hide attachment specific actions
            PlaceHolder plcAttachmentUpdtAction = e.Item.FindControl("plcAttachmentUpdtAction") as PlaceHolder;
            if (plcAttachmentUpdtAction != null)
            {
                plcAttachmentUpdtAction.Visible = false;
            }
        }
        else
        {
            PlaceHolder plcAttachmentActions = e.Item.FindControl("plcAttachmentActions") as PlaceHolder;
            if (plcAttachmentActions != null)
            {
                plcAttachmentActions.Visible = false;
            }
        }

        #endregion

        #region "Library update action"

        if ((SourceType == MediaSourceEnum.MediaLibraries) && (DisplayMode == ControlDisplayModeEnum.Simple))
        {
            // Initialize UPDATE button
            var dfuElemLib = e.Item.FindControl("dfuElemLib") as DirectFileUploader;
            if (dfuElemLib != null)
            {
                Panel pnlDisabledUpdate = (e.Item.FindControl("pnlDisabledUpdate") as Panel);
                if (pnlDisabledUpdate != null)
                {
                    bool hasModifyPermission = RaiseOnGetModifyPermission(data);
                    if (isInDatabase && hasModifyPermission)
                    {
                        GetLibraryUpdateControl(ref dfuElemLib, importedMediaData);

                        pnlDisabledUpdate.Visible = false;
                    }
                    else
                    {
                        pnlDisabledUpdate.Controls.Clear();

                        var disabledIcon = new CMSAccessibleButton
                        {
                            EnableViewState = false,
                            Enabled = false,
                            IconCssClass = "icon-arrow-up-line",
                            IconOnly = true
                        };

                        pnlDisabledUpdate.Controls.Add(disabledIcon);

                        dfuElemLib.Visible = false;
                    }
                }
            }

            // Setup external edit
            if (isInDatabase)
            {
                ExternalEditHelper.LoadExternalEditControl(e.Item.FindControl("plcExtEditMfi"), FileTypeEnum.MediaFile, GetSiteName(data, true), importedMediaData, IsLiveSite, null, true);
            }
        }
        else if (((SourceType == MediaSourceEnum.Content) && (DisplayMode == ControlDisplayModeEnum.Default) && !notAttachment && !libraryFolder && !libraryUiFolder))
        {
            // Setup external edit
            if (data.ContainsColumn("AttachmentGUID"))
            {
                LoadExternalEditControl(e.Item, FileTypeEnum.Attachment);
            }
        }
        else if (((SourceType == MediaSourceEnum.MediaLibraries) && (DisplayMode == ControlDisplayModeEnum.Default) && !libraryFolder && !libraryUiFolder))
        {
            // Setup external edit
            if (data.ContainsColumn("FileGUID"))
            {
                LoadExternalEditControl(e.Item, FileTypeEnum.MediaFile);
            }
        }
        else
        {
            var plcLibraryUpdtAction = e.Item.FindControl("plcLibraryUpdtAction") as PlaceHolder;
            if (plcLibraryUpdtAction != null)
            {
                plcLibraryUpdtAction.Visible = false;
            }
        }

        if ((SourceType == MediaSourceEnum.MediaLibraries) && libraryFolder && IsFullListingMode)
        {
            // Initialize SELECT SUB-FOLDERS button
            var btn = e.Item.FindControl("imgSelectSubFolders") as CMSAccessibleButton;
            if (btn != null)
            {
                btn.Visible = true;
                btn.ToolTip = GetString("dialogs.list.actions.showsubfolders");
                btn.OnClientClick = String.Format("SetLibParentAction({0}); return false;", ScriptHelper.GetString(fileName));
            }
        }
        else
        {
            var plcSelectSubFolders = e.Item.FindControl("plcSelectSubFolders") as PlaceHolder;
            if (plcSelectSubFolders != null)
            {
                plcSelectSubFolders.Visible = false;
            }
        }

        #endregion

        #region "File image"

        // Selectable area
        Panel pnlItemInageContainer = e.Item.FindControl("pnlThumbnails") as Panel;
        if (pnlItemInageContainer != null)
        {
            if (isSelectable)
            {
                if ((DisplayMode == ControlDisplayModeEnum.Simple) && !isInDatabase)
                {
                    if (libraryFolder || libraryUiFolder)
                    {
                        pnlItemInageContainer.Attributes["onclick"] = String.Format("SetAction('morefolderselect', {0}); RaiseHiddenPostBack(); return false;", ScriptHelper.GetString(fileName));
                    }
                    else
                    {
                        pnlItemInageContainer.Attributes["onclick"] = String.Format("ColorizeRow({0}); SetAction('importfile', {1}); RaiseHiddenPostBack(); return false;", ScriptHelper.GetString(GetColorizeID(data)), ScriptHelper.GetString(fullFileName));
                    }
                }
                else
                {
                    pnlItemInageContainer.Attributes["onclick"] = String.Format("ColorizeRow({0}); SetSelectAction({1}); return false;", ScriptHelper.GetString(GetColorizeID(data)), ScriptHelper.GetString(String.Format("{0}|URL|{1}", argument, selectUrlParameters.Url)));
                }
                pnlItemInageContainer.Attributes["style"] = "cursor:pointer;";
            }
            else
            {
                pnlItemInageContainer.Attributes["style"] = "cursor:default;";
            }
        }

        // Image area
        Image imgFile = e.Item.FindControl("imgFile") as Image;
        if (imgFile != null)
        {
            string chset = Guid.NewGuid().ToString();
            var previewUrl = previewParameters.Url;
            previewUrl = URLHelper.AddParameterToUrl(previewUrl, "chset", chset);

            // Add latest version requirement for live site
            int versionHistoryId = VersionHistoryID;
            if (IsLiveSite && (versionHistoryId > 0))
            {
                // Add requirement for latest version of files for current document
                string newparams = String.Format("latestforhistoryid={0}&hash={1}", versionHistoryId, ValidationHelper.GetHashString("h" + versionHistoryId));

                previewUrl += "&" + newparams;
            }

            if (String.IsNullOrEmpty(previewParameters.IconClass))
            {
                imgFile.ImageUrl = previewUrl;
                imgFile.AlternateText = TextHelper.LimitLength(fileName, 10);
                imgFile.Attributes["title"] = fileName.Replace("\"", "\\\"");

                // Ensure tooltip - only text description
                if (isInDatabase)
                {
                    UIHelper.EnsureTooltip(imgFile, previewUrl, width, height, GetTitle(data, isContentFile), fileName, ext, GetDescription(data, isContentFile), null, 300);
                }
            }
            else
            {
                var imgIcon = e.Item.FindControl(("imgFileIcon")) as Label;
                if ((imgIcon != null) && imgIcon.Controls.Count < 1)
                {
                    className = ValidationHelper.GetString(data.GetValue("ClassName"), String.Empty);
                    var icon = UIHelper.GetDocumentTypeIcon(null, className, previewParameters.IconClass, previewParameters.IconSize);

                    imgIcon.Controls.Add(new LiteralControl(icon));

                    // Ensure tooltip - only text description
                    if (isInDatabase)
                    {
                        UIHelper.EnsureTooltip(imgIcon, previewUrl, width, height, GetTitle(data, isContentFile), fileName, ext, GetDescription(data, isContentFile), null, 300);
                    }

                    imgFile.Visible = false;
                }
            }
        }

        #endregion

        // Display only for ML UI
        if ((DisplayMode == ControlDisplayModeEnum.Simple) && !libraryFolder)
        {
            PlaceHolder plcSelectionBox = e.Item.FindControl("plcSelectionBox") as PlaceHolder;
            if (plcSelectionBox != null)
            {
                plcSelectionBox.Visible = true;

                // Multiple selection check-box
                CMSCheckBox chkSelected = e.Item.FindControl("chkSelected") as CMSCheckBox;
                if (chkSelected != null)
                {
                    chkSelected.ToolTip = GetString("general.select");
                    chkSelected.InputAttributes["alt"] = fullFileName;

                    HiddenField hdnItemName = e.Item.FindControl("hdnItemName") as HiddenField;
                    if (hdnItemName != null)
                    {
                        hdnItemName.Value = fullFileName;
                    }
                }
            }
        }
    }
    /// <summary>
    /// Add translation control to the list of action buttons
    /// </summary>
    /// <param name="tsi">Translation service object used to initialize the control</param>
    /// <param name="siteName">Site name to check for service availability</param>
    private void AddTranslationControl(TranslationServiceInfo tsi, string siteName)
    {
        string arg = "'##SERVICE##|' + document.getElementById('" + (TranslationElementClientID ?? InputClientID) + @"').value";
        if (TranslationServiceHelper.IsServiceAvailable(tsi.TranslationServiceName, siteName))
        {
            var ctrl = new CMSAccessibleButton();
            cntElem.ActionsContainer.Controls.Add(ctrl);

            ctrl.IconCssClass = "icon-" + tsi.TranslationServiceName.ToLowerCSafe();
            ctrl.ToolTip = string.Format("{0} {1}", ResHelper.GetString("translations.translateusing"), tsi.TranslationServiceDisplayName);

            // Get callback reference for translation
            string cbRef = Page.ClientScript.GetCallbackEventReference(this, arg.Replace("##SERVICE##", tsi.TranslationServiceName), "SetValueToTextBox", "'" + InputClientID + ";" + ctrl.ClientID + "_icon;" + ctrl.IconCssClass + "'", true);
            ctrl.OnClientClick = "StartProgress('" + ctrl.ClientID + "_icon'); " + cbRef + ";return false;";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Unigrid
        gridElem.HideControlForZeroRows = false;
        gridElem.OrderBy = "KeyOrder";
        gridElem.OnAction += KeyAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
        gridElem.ZeroRowsText = GetString("settings.group.nokeysfound");

        if (Category != null)
        {
            string catIdStr = Category.CategoryID.ToString();

            // Action buttons
            var rightPanel = cpCategory.RightPanel;

            // Edit action
            var editButton = new CMSAccessibleButton
            {
                ToolTip = GetString("general.edit"),
                IconCssClass = "icon-edit",
                IconOnly = true
            };

            editButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("edit", catIdStr));
            rightPanel.Controls.Add(editButton);

            if (AllowEdit)
            {
                // Delete action
                var deleteButton = new CMSAccessibleButton
                {
                    ToolTip = GetString("general.delete"),
                    IconCssClass = "icon-bin",
                    IconOnly = true,
                    OnClientClick = string.Format("if (!confirm({0})) {{ return false; }}", ScriptHelper.GetString(GetString("Development.CustomSettings.GroupDeleteConfirmation")))
                };

                deleteButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("delete", catIdStr));
                rightPanel.Controls.Add(deleteButton);

                // Move up action
                var moveUpButton = new CMSAccessibleButton
                {
                    ToolTip = GetString("general.moveup"),
                    IconCssClass = "icon-chevron-up",
                    IconOnly = true
                };

                moveUpButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("moveup", catIdStr));
                rightPanel.Controls.Add(moveUpButton);

                // Move down action
                var moveDownButton = new CMSAccessibleButton
                {
                    ToolTip = GetString("general.movedown"),
                    IconCssClass = "icon-chevron-down",
                    IconOnly = true
                };

                moveDownButton.Click += (eventSender, args) => CategoryActionPerformed(eventSender, new CommandEventArgs("movedown", catIdStr));
                rightPanel.Controls.Add(moveDownButton);

                // Setup "Add key" button
                btnNewKey.Text = ResHelper.GetString("Development.CustomSettings.NewKey");
                btnNewKey.Click += CreateNewKey;

                cprModuleInfoRow.Visible = false;
                cprRow01.Visible = true;
            }
            else
            {
                ResourceInfo currentModule = ResourceInfoProvider.GetResourceInfo(ModuleID);
                ResourceInfo categoryModule = ResourceInfoProvider.GetResourceInfo(Category.CategoryResourceID);

                // Show warning if current module is in development mode, if not global warning is shown on the top of page
                if ((categoryModule != null) && (currentModule != null) && currentModule.ResourceIsInDevelopment)
                {
                    lblAnotherModule.Text = String.Format(GetString("settingscategory.disablededitting"), categoryModule.ResourceDisplayName);
                    cprModuleInfoRow.Visible = true;
                }
                else
                {
                    cprModuleInfoRow.Visible = false;
                }

                cprRow01.Visible = false;
            }

            gridElem.ShowObjectMenu = AllowEdit;

            // Panel title for group
            cpCategory.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(Category.CategoryDisplayName));

            // Filter out only records for this group
            gridElem.WhereCondition = "KeyCategoryID = " + Category.CategoryID;
        }

        // Apply site filter if required.
        if (!string.IsNullOrEmpty(gridElem.WhereCondition))
        {
            gridElem.WhereCondition += " AND ";
        }

        gridElem.WhereCondition += "SiteID IS NULL";
    }