protected void Page_Load(object sender, EventArgs e) { headerActions.ActionPerformed += OnActionPerformed; headerActions.PanelCssClass = PanelCssClass; // Create header actions SaveAction save = new SaveAction(); headerActions.AddAction(save); // Print mPrintAction = new HeaderAction { Text = GetString("Analytics_Report.Print"), Enabled = PrintEnabled, ButtonStyle = ButtonStyle.Default, }; headerActions.AddAction(mPrintAction); var cui = MembershipContext.AuthenticatedUser; // Report subscription enabled test GeneralizedInfo ri = BaseAbstractInfoProvider.GetInfoByName(PredefinedObjectType.REPORT, ReportName); if (ri != null) { bool enableSubscription = ValidationHelper.GetBoolean(ri.GetValue("ReportEnableSubscription"), true); // Show enable subscription only for users with subscribe or modify. enableSubscription &= (cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || cui.IsAuthorizedPerResource("cms.reporting", "modify")); if (enableSubscription) { // Subscription mSubscriptionAction = new HeaderAction { Text = GetString("notifications.subscribe"), ButtonStyle = ButtonStyle.Default, }; headerActions.AddAction(mSubscriptionAction); } } }
protected void Page_Load(object sender, EventArgs e) { objectType = UIContextHelper.GetObjectType(UIContext); CloneItemButton.Visible = DisplayCloneButton; // Pass tabindex int tabIndex = ValidationHelper.GetInteger(UIContext["TabIndex"], 0); if (tabIndex != 0) { tabIndexStr = "&tabindex=" + tabIndex; } String editElem = ValidationHelper.GetString(UIContext["itemEdit"], String.Empty); String categoryElem = ValidationHelper.GetString(UIContext["categoryedit"], String.Empty); categoryPathColumn = ValidationHelper.GetString(UIContext["pathColumn"], String.Empty); categoryParentColumn = ValidationHelper.GetString(UIContext["categoryparentcolumn"], String.Empty); categoryObjectType = ValidationHelper.GetString(UIContext["parentobjecttype"], String.Empty); itemParentColumn = ValidationHelper.GetString(UIContext["parentColumn"], String.Empty); newItem = ValidationHelper.GetString(UIContext["newitem"], String.Empty); if (!ValidateInput()) { return; } itemLocation = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ResourceName, editElem), "?tabslayout=horizontal&displaytitle=false"); categoryLocation = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ResourceName, categoryElem), "?tabslayout=horizontal&displaytitle=false"); RegisterExportScript(); RegisterTreeScript(); InitTree(); // Setup menu action scripts String newItemText = newItem.StartsWithCSafe("javascript", true) ? newItem : "NewItem('item'); return false;"; AddButon.Actions.Add(new CMSButtonAction { Text = GetString(objectType + ".newitem"), OnClientClick = newItemText }); AddButon.Actions.Add(new CMSButtonAction { Text = GetString("development.tree.newcategory"), OnClientClick = "NewItem('category'); return false;" }); DeleteItemButton.OnClientClick = "DeleteItem(); return false;"; ExportItemButton.OnClientClick = "ExportObject(); return false;"; CloneItemButton.OnClientClick = "if ((selectedItemId > 0) && (selectedItemType == 'item')) { modalDialog('" + URLHelper.ResolveUrl("~/CMSModules/Objects/Dialogs/CloneObjectDialog.aspx?reloadall=1&displaytitle=" + UIContext["displaytitle"] + "&objecttype=" + objectType + "&objectid=") + "' + selectedItemId, 'Clone item', 750, 470); } return false;"; // Tooltips DeleteItemButton.ToolTip = GetString("development.tree.deleteselected"); ExportItemButton.ToolTip = GetString("exportobject.title"); CloneItemButton.ToolTip = GetString(objectType + ".clone"); // URLs for menu actions String script = "var doNotReloadContent = false;\n"; // Script for deleting widget or category string delPostback = ControlsHelper.GetPostBackEventReference(this, "##"); string deleteScript = "function DeleteItem() { \n" + " if ((selectedItemId > 0) && (selectedItemParent > 0) && " + " confirm(" + ScriptHelper.GetLocalizedString("general.deleteconfirmation") + ")) {\n " + delPostback.Replace("'##'", "selectedItemType+';'+selectedItemId+';'+selectedItemParent") + ";\n" + "}\n" + "}\n"; script += deleteScript; // Preselect tree item if (!RequestHelper.IsPostBack()) { int parentobjectid = QueryHelper.GetInteger("parentobjectid", 0); int objectID = QueryHelper.GetInteger("objectID", 0); // Select category if (parentobjectid > 0) { BaseInfo biParent = BaseAbstractInfoProvider.GetInfoById(categoryObjectType, parentobjectid); if (biParent != null) { String path = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty); int parentID = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0); script += SelectAfterLoad(path, parentobjectid, "category", parentID, true, true); } } // Select item else if (objectID > 0) { BaseInfo bi = BaseAbstractInfoProvider.GetInfoById(objectType, objectID); if (bi != null) { script += SelectItem(bi); } } else { // Selection by hierarchy URL BaseInfo biSel = UIContext.EditedObject as BaseInfo; BaseInfo biParent = UIContext.EditedObjectParent as BaseInfo; // Check for category selection if ((biParent != null) && (biParent.TypeInfo.ObjectType == categoryObjectType)) { String path = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty); int parentID = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0); script += SelectAfterLoad(path, biParent.Generalized.ObjectID, "category", parentID, false, true); } // Check for item selection else if ((biSel != null) && (biSel.TypeInfo.ObjectType == objectType)) { script += SelectItem(biSel); } else { // Select root by default BaseInfo bi = BaseAbstractInfoProvider.GetInfoByName(categoryObjectType, "/"); if (bi != null) { script += SelectAfterLoad("/", bi.Generalized.ObjectID, "category", 0, true, true); } } } } ltlScript.Text += ScriptHelper.GetScript(script); }
/// <summary> /// Imports default metafiles which were changed in the new version. /// </summary> /// <param name="upgradeFolder">Folder where the generated metafiles.xml file is</param> private static void ImportMetaFiles(string upgradeFolder) { try { // To get the file use Phobos - Generate files button, Metafile settings. // Choose only those object types which had metafiles in previous version and these metafiles changed to the new version. String xmlPath = Path.Combine(upgradeFolder, "metafiles.xml"); if (File.Exists(xmlPath)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(xmlPath); XmlNode metaFilesNode = xDoc.SelectSingleNode("MetaFiles"); if (metaFilesNode != null) { String filesDirectory = Path.Combine(upgradeFolder, "Metafiles"); using (new CMSActionContext { LogEvents = false }) { foreach (XmlNode metaFile in metaFilesNode) { // Load metafiles information from XML String objType = metaFile.Attributes["ObjectType"].Value; String groupName = metaFile.Attributes["GroupName"].Value; String codeName = metaFile.Attributes["CodeName"].Value; String fileName = metaFile.Attributes["FileName"].Value; String extension = metaFile.Attributes["Extension"].Value; String fileGUID = metaFile.Attributes["FileGUID"].Value; String title = (metaFile.Attributes["Title"] != null) ? metaFile.Attributes["Title"].Value : null; String description = (metaFile.Attributes["Description"] != null) ? metaFile.Attributes["Description"].Value : null; // Try to find correspondent info object BaseInfo infoObject = BaseAbstractInfoProvider.GetInfoByName(objType, codeName); if (infoObject != null) { int infoObjectId = infoObject.Generalized.ObjectID; // Check if metafile exists InfoDataSet <MetaFileInfo> metaFilesSet = MetaFileInfoProvider.GetMetaFilesWithoutBinary(infoObjectId, objType, groupName, "MetaFileGUID = '" + fileGUID + "'", null); if (DataHelper.DataSourceIsEmpty(metaFilesSet)) { // Create new metafile if does not exists String mfFileName = String.Format("{0}.{1}", fileGUID, extension.TrimStart('.')); MetaFileInfo mfInfo = new MetaFileInfo(Path.Combine(filesDirectory, mfFileName), infoObjectId, objType, groupName); mfInfo.MetaFileGUID = ValidationHelper.GetGuid(fileGUID, Guid.NewGuid()); // Set correct properties mfInfo.MetaFileName = fileName; if (title != null) { mfInfo.MetaFileTitle = title; } if (description != null) { mfInfo.MetaFileDescription = description; } // Save new meta file MetaFileInfoProvider.SetMetaFileInfo(mfInfo); } } } // Remove existing files after successful finish String[] files = Directory.GetFiles(upgradeFolder); foreach (String file in files) { File.Delete(file); } } } } } catch (Exception ex) { EventLogProvider.LogException(EventLogSource, "IMPORTMETAFILES", ex); } }
protected override void OnPreRender(EventArgs e) { string dataCodeName = string.IsNullOrEmpty(ManageDataCodeName) ? QueryHelper.GetString("dataCodeName", string.Empty) : ManageDataCodeName; string deleteDialogUrl = ResolveUrl("~/CMSModules/Reporting/WebAnalytics/Analytics_ManageData.aspx"); deleteDialogUrl = URLHelper.AddParameterToUrl(deleteDialogUrl, "statcodename", URLHelper.URLEncode(dataCodeName)); deleteDialogUrl = URLHelper.AddParameterToUrl(deleteDialogUrl, "hash", QueryHelper.GetHash(deleteDialogUrl)); string deleteScript = string.Format("modalDialog('{0}','AnalyticsManageData',{1},{2});", deleteDialogUrl, 680, 350); string printDialogUrl = string.Format("{0}?reportname={1}¶meters={2}", ResolveUrl(PrintPageURL), ReportName, AnalyticsHelper.GetQueryStringParameters(ReportParameters)); string printScript = string.Format("myModalDialog('{0}&UILang={1}&hash={2}','PrintReport {3}',800,700);return false", printDialogUrl, CultureInfo.CurrentUICulture.IetfLanguageTag, QueryHelper.GetHash(printDialogUrl), ReportName); string subscriptionScript = String.Format("modalDialog('{0}?reportname={1}¶meters={2}&interval={3}','Subscription',{4},{5});return false", ResolveUrl("~/CMSModules/Reporting/Dialogs/EditSubscription.aspx"), ReportName, AnalyticsHelper.GetQueryStringParameters(ReportParameters), HitsIntervalEnumFunctions.HitsConversionToString(SelectedInterval), AnalyticsHelper.SUBSCRIPTION_WINDOW_WIDTH, AnalyticsHelper.SUBSCRIPTION_WINDOW_HEIGHT); string refreshScript = "function RefreshPage() {" + ControlsHelper.GetPostBackEventReference(this, "") + "};"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshScript", ScriptHelper.GetScript(refreshScript)); // Register special script for print window ScriptHelper.RegisterPrintDialogScript(Page); ScriptHelper.RegisterDialogScript(Page); headerActions.PanelCssClass = PanelCssClass; // Create header actions SaveAction save = new SaveAction(Page); headerActions.ActionsList.Add(save); // Print HeaderAction print = new HeaderAction { Text = GetString("Analytics_Report.Print"), OnClientClick = printScript, Enabled = PrintEnabled, ButtonStyle = ButtonStyle.Default, }; headerActions.ActionsList.Add(print); var cui = MembershipContext.AuthenticatedUser; // Manage data if (cui.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageData") && DisplayManageData) { HeaderAction delete = new HeaderAction { Text = GetString("Analytics_Report.ManageData"), OnClientClick = deleteScript, ButtonStyle = ButtonStyle.Default, }; headerActions.ActionsList.Add(delete); } // Report subscription enabled test GeneralizedInfo ri = BaseAbstractInfoProvider.GetInfoByName(PredefinedObjectType.REPORT, ReportName); if (ri != null) { bool enableSubscription = ValidationHelper.GetBoolean(ri.GetValue("ReportEnableSubscription"), true); // Show enable subscription only for users with subscribe or modify. enableSubscription &= (cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || cui.IsAuthorizedPerResource("cms.reporting", "modify")); if (enableSubscription) { // Subscription HeaderAction subscription = new HeaderAction { Text = GetString("notifications.subscribe"), OnClientClick = subscriptionScript, ButtonStyle = ButtonStyle.Default, }; headerActions.ActionsList.Add(subscription); } } base.OnPreRender(e); }