/// <summary>
    /// PreRender event handler.
    /// </summary>
    void Page_PreRender(object sender, EventArgs e)
    {
        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = (CMSContext.ViewMode == ViewModeEnum.Preview) ? ViewModeEnum.Preview : this.PageManager.ViewMode;

            switch (viewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
                // Set enabled
                if (this.selPath != null)
                {
                    this.selPath.Enabled = (viewMode == ViewModeEnum.Edit);
                }

                if (this.lblError != null)
                {
                    this.lblError.Visible = (this.lblError.Text != "");
                }
                this.lblTitle.Text = this.ImageTitle;
                break;
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// Sets the view mode.
    /// </summary>
    /// <param name="viewMode">The view mode</param>
    private void SetViewMode(ViewModeEnum viewMode)
    {
        if (PortalHelper.IsOnSiteEditingEnabled(SiteContext.CurrentSiteName) && AuthenticationHelper.IsAuthenticated())
        {
            // Remove the "viewmode" param from url and redirect
            string returnUrl = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "viewmode");

            PortalContext.ViewMode = viewMode;

            // Switch view mode
            if (viewMode.IsEditLive())
            {
                //  Handle default alias path
                if (URLRewritingContext.CurrentPageInfoSource == PageInfoSource.DefaultAliasPath)
                {
                    string aliasPath = PageInfoProvider.GetDefaultAliasPath(RequestContext.CurrentDomain, SiteContext.CurrentSiteName);
                    if (!String.IsNullOrEmpty(aliasPath))
                    {
                        string query = URLHelper.GetQuery(returnUrl);
                        returnUrl = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(aliasPath));
                        returnUrl = URLHelper.AppendQuery(returnUrl, query);
                    }
                }
            }
            else if (is404)
            {
                // Redirect to the root document when page not found
                returnUrl = ResolveUrl("~/");
            }

            // Redirect to the URL
            URLHelper.Redirect(returnUrl);
        }
    }
Beispiel #3
0
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        ucUIToolbar.ModuleName  = MODULE_NAME;
        ucUIToolbar.ElementName = ELEMENT_NAME;

        // Set the viewmode according the the URL param
        if (ViewMode.IsLiveSite() && QueryHelper.Contains("viewmode"))
        {
            ViewModeEnum queryStringViewMode = ViewModeCode.GetPageEnumFromString(QueryHelper.GetString("viewmode", "livesite"));
            if (queryStringViewMode.IsEditLive())
            {
                SetViewMode(queryStringViewMode);
            }
        }

        if (ViewMode.IsEditLive())
        {
            // Check if there is required a redirect to the specific document
            if (QueryHelper.Contains("onsitenodeid"))
            {
                int          nodeId       = QueryHelper.GetInteger("onsitenodeid", 0);
                TreeProvider treeProvider = new TreeProvider();
                TreeNode     node         = treeProvider.SelectSingleNode(nodeId);
                string       url          = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(node.NodeAliasPath, string.Empty /* ensure getting the link (not the linked document) */, node.NodeSiteName, RequestContext.CurrentURLLangPrefix));
                URLHelper.Redirect(url);
            }
        }

        base.OnInit(e);
    }
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        ucUIToolbar.ModuleName  = MODULE_NAME;
        ucUIToolbar.ElementName = ELEMENT_NAME;

        // Set the viewmode according the the URL param
        if (ViewMode.IsLiveSite() && QueryHelper.Contains("viewmode"))
        {
            ViewModeEnum queryStringViewMode = ViewModeCode.GetPageEnumFromString(QueryHelper.GetString("viewmode", "livesite"));
            if (queryStringViewMode.IsEditLive())
            {
                SetViewMode(queryStringViewMode);
            }
        }

        if (ViewMode.IsEditLive())
        {
            // Check if there is required a redirect to the specific document
            if (QueryHelper.Contains("onsitenodeid"))
            {
                var nodeId       = QueryHelper.GetInteger("onsitenodeid", 0);
                var treeProvider = new TreeProvider();
                var node         = treeProvider.SelectSingleNode(nodeId);
                var url          = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(node));
                URLHelper.Redirect(url);
            }
        }

        base.OnInit(e);
    }
Beispiel #5
0
    protected override void OnInit(EventArgs e)
    {
        // Initialize viewmode
        viewMode = this.PageManager.ViewMode;

        base.OnInit(e);
    }
Beispiel #6
0
    /// <summary>
    /// PreRender event handler.
    /// </summary>
    private void Page_PreRender(object sender, EventArgs e)
    {
        if (!StopProcessing)
        {
            ViewModeEnum viewMode = (PortalContext.ViewMode.IsPreview()) ? ViewModeEnum.Preview : ViewMode;

            switch (ViewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
                // Set enabled
                if (selPath != null)
                {
                    selPath.Enabled = (ViewMode.IsEdit());
                }

                if (lblError != null)
                {
                    lblError.Visible = (lblError.Text != "");
                }
                lblTitle.Text = HTMLHelper.HTMLEncode(ImageTitle);
                break;
            }
        }
    }
        public ControllerPreview()
        {
            InitializeComponent();
            this._viewMode        = ViewModeEnum.Controller;
            this._controllerImage = this.BackgroundImage;
            this._consoleImage    = this.LogoImagePanel.BackgroundImage;

            this.BackgroundImage = this._controllerImage;
        }
    /// <summary>
    /// Registers the control scripts
    /// </summary>
    protected void RegisterScripts()
    {
        // Include javascript only in live site or preview mode
        ViewModeEnum viewMode = PortalContext.ViewMode;

        if (viewMode != ViewModeEnum.Design)
        {
            RegisterLinkedFiles();
            RegisterInlineScript();
        }
    }
Beispiel #9
0
        public async Task <IHttpActionResult> GetEmendamenti(BaseRequest <EmendamentiDto> model)
        {
            try
            {
                var atto = await _logicAtti.GetAtto(model.id);

                if (atto == null)
                {
                    return(NotFound());
                }

                model.param.TryGetValue("CLIENT_MODE", out object CLIENT_MODE); // per trattazione aula
                model.param.TryGetValue("VIEW_MODE", out object viewMode);      // per vista preview/griglia
                ViewModeEnum VIEW_MODE = ViewModeEnum.GRID;
                if (viewMode != null)
                {
                    Enum.TryParse(viewMode.ToString(), out VIEW_MODE);
                }
                var session = await GetSession();

                var persona = await _logicPersone.GetPersona(session);

                var ricerca_presidente_regione = await _logicAdmin.GetUtenti(new BaseRequest <PersonaDto>
                {
                    page   = 1,
                    size   = 1,
                    filtro = new List <FilterStatement <PersonaDto> >
                    {
                        new FilterStatement <PersonaDto>
                        {
                            PropertyId = nameof(PersonaDto.Ruoli),
                            Operation  = Operation.EqualTo,
                            Value      = (int)RuoliIntEnum.Presidente_Regione,
                            Connector  = FilterStatementConnector.And
                        }
                    }
                }, session
                                                                             , Request.RequestUri);

                var presidente = ricerca_presidente_regione.Results.First();
                var results    =
                    await _logicEm.GetEmendamenti(model, persona, Convert.ToInt16(CLIENT_MODE), (int)VIEW_MODE, presidente, Request.RequestUri);

                results.Atto = Mapper.Map <ATTI, AttiDto>(atto);
                return(Ok(results));
            }
            catch (Exception e)
            {
                Log.Error("GetEmendamenti", e);
                return(ErrorHandler(e));
            }
        }
    private static void SetViewMode()
    {
        var viewMode = QueryHelper.GetString("viewMode", string.Empty);

        if (!string.IsNullOrEmpty(viewMode))
        {
            ViewModeEnum mode = ViewModeCode.FromString(viewMode);
            if (mode != ViewModeEnum.Unknown)
            {
                PortalContext.SetRequestViewMode(mode);
            }
        }
    }
    /// <summary>
    /// PreRender event handler.
    /// </summary>
    private void Page_PreRender(object sender, EventArgs e)
    {
        if (!StopProcessing)
        {
            ViewModeEnum viewMode = (PortalContext.ViewMode.IsPreview()) ? ViewModeEnum.Preview : ViewMode;

            switch (viewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
                // Set enabled
                if (htmlValue != null)
                {
                    htmlValue.Enabled = IsEnabled(viewMode);
                }
                if (txtValue != null)
                {
                    txtValue.Enabled = IsEnabled(viewMode);
                }

                if (mShowToolbar && IsEnabled(viewMode))
                {
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ScriptHelper.TOOLBAR_SCRIPT_KEY, ScriptHelper.ToolbarScript);
                }

                if (lblError != null)
                {
                    lblError.Visible = (lblError.Text != "");
                }

                if (lblTitle != null)
                {
                    lblTitle.Text    = RegionTitle;
                    lblTitle.Visible = (lblTitle.Text != "");
                }

                // Allow to select text in the source editor area
                if (DesignPanel != null)
                {
                    ScriptHelper.RegisterStartupScript(this, typeof(string), "onselectstart", "document.getElementById('" + DesignPanel.ClientID + "').parentNode.onselectstart = function() { return true; };", true);
                }

                break;
            }
        }
    }
    /// <summary>
    /// Translates object to new culture.
    /// </summary>
    protected void btnTranslate_Click(object sender, EventArgs e)
    {
        if (TranslationServiceHelper.IsAuthorizedToTranslateDocument(Node, MembershipContext.AuthenticatedUser))
        {
            try
            {
                // Submits the document to translation service
                string err = translationElem.SubmitToTranslation();
                if (string.IsNullOrEmpty(err))
                {
                    // Refresh page
                    string script;
                    if (RequiresDialog)
                    {
                        string url = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(Node) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture);
                        script = "window.top.location = " + ScriptHelper.GetString(url) + ";";
                    }
                    else
                    {
                        ViewModeEnum mode = ViewModeEnum.Edit;
                        if (!TreePathUtils.IsMenuItemType(Node.NodeClassName) && (PortalContext.ViewMode != ViewModeEnum.EditLive))
                        {
                            mode = ViewModeEnum.EditForm;
                        }
                        script = "if (FramesRefresh) { FramesRefresh(" + Node.NodeID + ", '" + mode + "'); }";
                    }

                    ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(script));
                }
                else
                {
                    ShowError(err);
                }
            }
            catch (Exception ex)
            {
                ShowError(GetString("ContentRequest.TranslationFailed"), ex.Message);
                TranslationServiceHelper.LogEvent(ex);
            }
        }
        else
        {
            RedirectToAccessDenied("CMS.Content", "SubmitForTranslation");
        }
    }
Beispiel #13
0
    /// <summary>
    /// PreRender event handler.
    /// </summary>
    void Page_PreRender(object sender, EventArgs e)
    {
        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = (CMSContext.ViewMode == ViewModeEnum.Preview) ? ViewModeEnum.Preview : this.PageManager.ViewMode;

            switch (viewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
                // Set enabled
                if (this.htmlValue != null)
                {
                    this.htmlValue.Enabled = (viewMode == ViewModeEnum.Edit);
                }
                if (this.txtValue != null)
                {
                    this.txtValue.Enabled = (viewMode == ViewModeEnum.Edit);
                }

                if (mShowToolbar && (viewMode == ViewModeEnum.Edit))
                {
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ScriptHelper.TOOLBAR_SCRIPT_KEY, ScriptHelper.ToolbarScript);
                }

                if (this.lblError != null)
                {
                    this.lblError.Visible = (this.lblError.Text != "");
                }

                this.lblTitle.Text    = this.RegionTitle;
                this.lblTitle.Visible = (this.lblTitle.Text != "");

                // Allow to select text in the source editor area
                if (pnlDesign != null)
                {
                    ScriptHelper.RegisterStartupScript(this, typeof(string), "onselectstart", "document.getElementById('" + pnlDesign.ClientID + "').parentNode.onselectstart = function() { return true; };", true);
                }

                break;
            }
        }
    }
Beispiel #14
0
    /// <summary>
    /// Loads data to editable image.
    /// </summary>
    protected void LoadImageData(ViewModeEnum mode)
    {
        // Set view mode
        PortalContext.ViewMode = mode;

        // Initialize editable image properties
        imageContent.DisplaySelectorTextBox = false;
        imageContent.SelectOnlyPublished    = false;

        // Ensure loading image
        if (!string.IsNullOrEmpty(content))
        {
            if (content.StartsWithCSafe("<image>"))
            {
                // Initialize editable image
                imageContent.LoadContent(content);
            }
        }
    }
Beispiel #15
0
        private void SetCache(int page, int size, OrdinamentoEnum ordine, ViewModeEnum view)
        {
            HttpContext.Cache.Insert(
                "OrdinamentoEM",
                (int)ordine,
                null,
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.NotRemovable,
                (key, value, reason) => { Console.WriteLine("Cache removed"); }
                );

            HttpContext.Cache.Insert(
                "ViewMode",
                view,
                null,
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.NotRemovable,
                (key, value, reason) => { Console.WriteLine("Cache removed"); }
                );

            HttpContext.Cache.Insert(
                "Page",
                page,
                null,
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.NotRemovable,
                (key, value, reason) => { Console.WriteLine("Cache removed"); }
                );

            HttpContext.Cache.Insert(
                "Size",
                size,
                null,
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.NotRemovable,
                (key, value, reason) => { Console.WriteLine("Cache removed"); }
                );
        }
    /// <summary>
    /// Registers the control scripts
    /// </summary>
    protected void RegisterScripts()
    {
        // Include javascript only in live site or preview mode
        ViewModeEnum viewMode = PortalContext.ViewMode;

        if (viewMode != ViewModeEnum.Design)
        {
            // Register jQuery script
            if (IncludeJQuery)
            {
                ScriptHelper.RegisterJQuery(this.Page);
            }

            // Register linked files
            RegisterLinkedFiles();

            // Register inline script
            RegisterInlineScript();
        }
    }
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        combinationSelector.UniSelector.UseUniSelectorAutocomplete = false;
        currentUser = MembershipContext.AuthenticatedUser;

        // Set the selected combination (from cookie by default)
        MVTestInfo mvTestInfo = MVTestInfoProvider.GetRunningTest(DocumentContext.CurrentAliasPath, SiteContext.CurrentSiteID, DocumentContext.CurrentDocumentCulture.CultureCode);

        // Get the cookie name
        if (mvTestInfo != null)
        {
            // Get a cookie name for the mvt test
            cookieTestName = CookieName.GetMVTCookieName(mvTestInfo.MVTestName);
        }
        else
        {
            // Get a template cookie name (used just in CMSDesk when no test is running)
            cookieTestName = CookieName.GetNoMVTCookieName(DocumentContext.CurrentDocument.GetUsedPageTemplateId());
        }

        // Move cookies expiration to next 30 days
        HttpCookie cookieMVTTest = CookieHelper.GetExistingCookie(cookieTestName);

        if (cookieMVTTest != null)
        {
            CookieHelper.SetValue(cookieMVTTest.Name, cookieMVTTest.Value, cookieMVTTest.Path, DateTime.Now.AddDays(30), false);
        }

        base.OnInit(e);

        viewMode = PortalContext.ViewMode;

        // Check permissions
        if ((currentUser == null) ||
            (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design") && PortalContext.IsDesignMode(viewMode)) ||
            (!currentUser.IsAuthorizedPerResource("CMS.MVTest", "Read")))
        {
            stopProcessing = true;
        }
    }
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        currentUser = CMSContext.CurrentUser;

        // Set the selected combination (from cookie by default)
        MVTestInfo mvTestInfo = MVTestInfoProvider.GetRunningTest(CMSContext.CurrentAliasPath, CMSContext.CurrentSiteID, CMSContext.CurrentDocumentCulture.CultureCode);

        // Get the cookie name
        if (mvTestInfo != null)
        {
            // Get a cookie name for the mvt test
            cookieTestName = "CMSMVT" + mvTestInfo.MVTestName.ToLower();
        }
        else
        {
            // Get a template cookie name (used just in CMSDesk when no test is running)
            cookieTestName = "CMSNoTestMVT" + CMSContext.CurrentDocument.DocumentPageTemplateID;
        }

        // Move cookies expiration to next 30 days
        HttpCookie cookieMVTTest = CookieHelper.GetExistingCookie(cookieTestName);

        if (cookieMVTTest != null)
        {
            CookieHelper.SetValue(cookieMVTTest.Name, cookieMVTTest.Value, cookieMVTTest.Path, DateTime.Now.AddDays(30), false);
        }

        base.OnInit(e);

        viewMode = CMSContext.ViewMode;

        // Check permissions
        if ((currentUser == null) ||
            (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design") && ((viewMode == ViewModeEnum.Design) || (viewMode == ViewModeEnum.DesignDisabled))) ||
            (!currentUser.IsAuthorizedPerResource("CMS.MVTest", "Read")))
        {
            stopProcessing = true;
        }
    }
    /// <summary>
    /// Sets the view mode.
    /// </summary>
    /// <param name="viewMode">The view mode</param>
    private void SetViewMode(ViewModeEnum viewMode)
    {
        if (PortalHelper.IsOnSiteEditingEnabled(SiteContext.CurrentSiteName) && AuthenticationHelper.IsAuthenticated())
        {
            // Remove the "viewmode" param from url and redirect
            var returnUrl = GetURLWithoutViewMode();

            PortalContext.ViewMode = viewMode;

            // Switch view mode
            if (viewMode.IsEditLive() && (URLRewritingContext.CurrentPageInfoSource == PageInfoSource.DefaultAliasPath))
            {
                returnUrl = GetUrlOfDocumentWithDefaultAliasPath();
            }
            else if (is404)
            {
                // Redirect to the root document when page not found
                returnUrl = ResolveUrl("~/");
            }

            // Redirect to the URL
            URLHelper.Redirect(UrlResolver.ResolveUrl(returnUrl));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DocumentManager.Tree.CombineWithDefaultCulture = false;
        if (Node != null)
        {
            // Register script files
            ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Content/CMSDesk/ContentEditFrameset.js");

            // Document from different site
            if (Node.NodeSiteID != CMSContext.CurrentSiteID)
            {
                URLHelper.Redirect(GetPageNotAvailable(string.Empty, false, Node.DocumentName));
            }

            ViewModeEnum currentMode = UpdateViewMode(CMSContext.ViewMode);

            // Check the product mode
            if (currentMode == ViewModeEnum.Product)
            {
                // Document type has to be marked as a product
                DataClassInfo classObj = DataClassInfoProvider.GetDataClass(Node.NodeClassName);
                if ((classObj == null) || !classObj.ClassIsProduct)
                {
                    CMSContext.ViewMode = ViewModeEnum.Properties;
                }
            }

            // Get the name for automatic title
            name = (Node.NodeAliasPath == "/" ? CMSContext.CurrentSite.DisplayName : Node.GetDocumentName());
        }
        else
        {
            // Document does not exist -> redirect to new culture version creation dialog
            RedirectToNewCultureVersionPage();
        }
    }
Beispiel #21
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            StartupPath = System.Windows.Forms.Application.StartupPath + '\\';

            DockIcon.Register(StartupPath + "Container-Empty.png", null, false);
            if (!DockIcon.IsRegistered)
            {
                Shutdown();
                return;
            }

            DockIcon.KeepInDock  = true;
            DockIcon.Exposable   = false;
            DockIcon.Activatable = true;

            Settings.Initialize(DockIcon.SettingsPath + "settings.xml");

            #region Get Previous Icon

            var iconName = DockIcon.IconName;
            if (string.IsNullOrEmpty(iconName))
            {
                iconName = StartupPath + "Container-Empty.png";
            }
            if (string.IsNullOrEmpty(Settings.Icon) || ((iconName != StartupPath + "Container-Empty.png") && (iconName != StartupPath + "Container-Opened.png")))
            {
                Settings.Icon = iconName;
                Settings.Save();
            }

            #endregion

            #region Init Path

            Path = Settings.Path;
            if (!Directory.Exists(Path))
            {
                Path = StartupPath;
            }
            if (Path.LastIndexOf('\\') < Path.Length - 1)
            {
                Path += '\\';
            }

            #endregion

            #region Start With View Mode

            if ((e.Args.Length >= 3) && (e.Args[0] == "-viewMode"))
            {
                Path = e.Args[2];
                if (Path.LastIndexOf('\\') < Path.Length - 1)
                {
                    Path += '\\';
                }
                if (!((e.Args.Length == 4) && (e.Args[3] == "-notSetPath")))
                {
                    Settings.Path = Path;
                }

                Directories = Directory.GetDirectories(Path);
                Files       = Directory.GetFiles(Path);

                DockIcon.Title = null;
                DockIcon.AddFolderWatcher(1, DockIcon.FolderWatcherActions.FileAdded | DockIcon.FolderWatcherActions.FileModified | DockIcon.FolderWatcherActions.FolderAdded, Path);

                switch (e.Args[1])
                {
                case "fan":
                    ViewMode   = ViewModeEnum.Fan;
                    MainWindow = new ContainerPublic.FanView();
                    break;

                case "list":
                    ViewMode = ViewModeEnum.List;
                    Shutdown();
                    return;

                //break;

                default:
                    ViewMode   = ViewModeEnum.Grid;
                    MainWindow = new ContainerPublic.GridView();
                    break;
                }

                MainWindow.Show();
                return;
            }

            #endregion

            #region Dropped files & directories into the stack

            if ((e.Args.Length > 0) && !((e.Args.Length == 1) && Directory.Exists(e.Args[0])))
            {
                var droppedFiles = true;
                foreach (var file in e.Args)
                {
                    if (!File.Exists(file) && !Directory.Exists(file))
                    {
                        droppedFiles = false;
                        break;
                    }
                }
                if (droppedFiles)
                {
                    var fileOperation = new SHFileOpStruct();
                    fileOperation.hwnd = IntPtr.Zero;

                    fileOperation.wFunc = FO_Func.FO_MOVE;
                    if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control)
                    {
                        fileOperation.wFunc = FO_Func.FO_COPY;
                    }

                    fileOperation.pFrom                 = StringArrayToMultiString(e.Args);
                    fileOperation.pTo                   = StringArrayToMultiString(new string[] { Path });
                    fileOperation.hNameMappings         = IntPtr.Zero;
                    fileOperation.fAnyOperationsAborted = 0;
                    fileOperation.fFlags                = 0;
                    fileOperation.lpszProgressTitle     = null;

                    SHFileOperation(ref fileOperation);

                    Shutdown();
                    return;
                }
            }

            #endregion

            #region Start With Directory

            if ((e.Args.Length > 0) && Directory.Exists(e.Args[0]))
            {
                Path = e.Args[0];
                if (Path.LastIndexOf('\\') < Path.Length - 1)
                {
                    Path += '\\';
                }
                if (!((e.Args.Length == 2) && (e.Args[1] == "-notSetPath")))
                {
                    Settings.Path = Path;
                }
            }

            #endregion

            #region Default

            Directories = Directory.GetDirectories(Path);
            Files       = Directory.GetFiles(Path);

            if (Directories.Length + Files.Length <= FanView.MaxItems)
            {
                ViewMode = ViewModeEnum.Fan;
            }
            else if (Directories.Length + Files.Length <= GridView.MaxItems)
            {
                ViewMode = ViewModeEnum.Grid;
            }
            else
            {
                //ViewMode = ViewModeEnum.List;
                ViewMode = ViewModeEnum.Grid;
            }

            DockIcon.Title = null;
            DockIcon.AddFolderWatcher(1, DockIcon.FolderWatcherActions.FileAdded | DockIcon.FolderWatcherActions.FileModified | DockIcon.FolderWatcherActions.FolderAdded, Path);

            switch (ViewMode)
            {
            case ViewModeEnum.Fan:
                MainWindow = new ContainerPublic.FanView();
                break;

            case ViewModeEnum.List:
                Shutdown();
                return;

            //break;

            default:
                MainWindow = new ContainerPublic.GridView();
                break;
            }

            MainWindow.Show();

            #endregion
        }
Beispiel #22
0
    /// <summary>
    /// PreRender event handler.
    /// </summary>
    void Page_PreRender(object sender, EventArgs e)
    {
        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = (CMSContext.ViewMode == ViewModeEnum.Preview) ? ViewModeEnum.Preview : this.PageManager.ViewMode;

            switch (viewMode)
            {
                case ViewModeEnum.Edit:
                case ViewModeEnum.EditDisabled:
                    // Set enabled
                    if (this.selPath != null)
                    {
                        this.selPath.Enabled = (viewMode == ViewModeEnum.Edit);
                    }

                    if (this.lblError != null)
                    {
                        this.lblError.Visible = (this.lblError.Text != "");
                    }
                    this.lblTitle.Text = this.ImageTitle;
                    break;
            }
        }
    }
Beispiel #23
0
 /// <summary>
 /// Indicates whether this control should be enabled and editing allowed.
 /// </summary>
 /// <param name="viewMode">The view mode.</param>
 private bool IsEnabled(ViewModeEnum viewMode)
 {
     return((viewMode.IsEdit()) && DocumentManager.AllowSave);
 }
Beispiel #24
0
    /// <summary>
    /// Loads data to editable image.
    /// </summary>
    protected void LoadImageData(ViewModeEnum mode)
    {
        // Set view mode
        PortalContext.ViewMode = mode;

        // Initialize editable image properties
        imageContent.DisplaySelectorTextBox = false;
        imageContent.SelectOnlyPublished = false;

        // Ensure loading image
        if (!string.IsNullOrEmpty(content))
        {
            if (content.StartsWith("<image>"))
            {
                // Initialize editable image
                imageContent.LoadContent(content);
            }
        }
    }
    /// <summary>
    /// Saves widget properties.
    /// </summary>
    public bool Save()
    {
        if (VariantID > 0)
        {
            // Check MVT/CP security
            if (!CheckPermissions("Manage"))
            {
                DisplayError("general.modifynotallowed");
                return(false);
            }
        }

        // Save the data
        if ((CurrentPageInfo != null) && (mTemplateInstance != null) && SaveForm(formCustom))
        {
            ViewModeEnum viewMode = PortalContext.ViewMode;

            // Check manage permission for non-livesite version
            if (!viewMode.IsLiveSite() && viewMode != ViewModeEnum.DashboardWidgets && viewMode != ViewModeEnum.UserWidgets)
            {
                if (CurrentUser.IsAuthorizedPerDocument(CurrentPageInfo.NodeID, CurrentPageInfo.ClassName, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Allowed)
                {
                    DisplayError("general.modifynotallowed");
                    return(false);
                }

                // Check design permissions
                if (PortalContext.IsDesignMode(viewMode, false) && !PortalContext.CurrentUserIsDesigner)
                {
                    RedirectToAccessDenied("CMS.Design", "Design");
                }
            }

            PageTemplateInfo pti = mTemplateInstance.ParentPageTemplate;
            if (PortalContext.IsDesignMode(viewMode) && SynchronizationHelper.IsCheckedOutByOtherUser(pti))
            {
                string   userName = null;
                UserInfo ui       = UserInfoProvider.GetUserInfo(pti.Generalized.IsCheckedOutByUserID);
                if (ui != null)
                {
                    userName = HTMLHelper.HTMLEncode(ui.GetFormattedUserName(IsLiveSite));
                }

                DisplayError(string.Format(GetString("ObjectEditMenu.CheckedOutByAnotherUser"), pti.TypeInfo.ObjectType, pti.DisplayName, userName));
                return(false);
            }

            // Get the zone
            mWebPartZoneInstance = mTemplateInstance.EnsureZone(ZoneId);

            if (mWebPartZoneInstance != null)
            {
                mWebPartZoneInstance.WidgetZoneType = ZoneType;

                // Add new widget
                if (IsNewWidget)
                {
                    bool isLayoutZone = (QueryHelper.GetBoolean("layoutzone", false));
                    int  widgetID     = ValidationHelper.GetInteger(WidgetId, 0);

                    // Create new widget instance
                    mWidgetInstance = PortalHelper.AddNewWidget(widgetID, ZoneId, ZoneType, isLayoutZone, mTemplateInstance);
                }

                // Ensure handling of the currently edited object (if not exists -> redirect)
                UIContext.EditedObject = mWidgetInstance;

                mWidgetInstance.XMLVersion = 1;
                if (IsNewVariant)
                {
                    mWidgetInstance = mWidgetInstance.Clone();

                    // Check whether the editor widgets have been already customized
                    if (CurrentPageInfo.DocumentTemplateInstance.WebPartZones.Count == 0)
                    {
                        // There are no customized editor widgets yet => copy the default editor widgets from the page template under the document (to enable customization)

                        // Save to the document as editor admin changes
                        TreeNode node = DocumentHelper.GetDocument(CurrentPageInfo.DocumentID, mTreeProvider);

                        // Extract and set the document web parts
                        node.SetValue("DocumentWebParts", mTemplateInstance.GetZonesXML(WidgetZoneTypeEnum.Editor));

                        // Save the document
                        DocumentHelper.UpdateDocument(node, mTreeProvider);
                    }
                }

                bool isLayoutWidget = ((mWebPartInfo != null) && ((WebPartTypeEnum)mWebPartInfo.WebPartType == WebPartTypeEnum.Layout));

                // Get basicform's datarow and update widget
                SaveFormToWidget(formCustom, mTemplateInstance, isLayoutWidget);

                // Ensure unique id for new widget variant or layout widget
                if (IsNewVariant || (isLayoutWidget && IsNewWidget))
                {
                    string controlId = GetUniqueWidgetId(mWidgetInfo.WidgetName);

                    if (!string.IsNullOrEmpty(controlId))
                    {
                        mWidgetInstance.ControlID = controlId;
                    }
                    else
                    {
                        DisplayError("Unable to generate unique widget id.");
                        return(false);
                    }
                }

                // Allow set dashboard in design mode
                if ((ZoneType == WidgetZoneTypeEnum.Dashboard) && String.IsNullOrEmpty(PortalContext.DashboardName))
                {
                    viewMode = ViewModeEnum.Design;
                    PortalContext.SetViewMode(ViewModeEnum.Design);
                }

                bool isWidgetVariant = (VariantID > 0) || IsNewVariant;
                if (!isWidgetVariant)
                {
                    // Save the changes
                    if ((viewMode.IsEdit(true) || viewMode.IsEditLive()) && (ZoneType == WidgetZoneTypeEnum.Editor))
                    {
                        if (DocumentManager.AllowSave)
                        {
                            // Store the editor widgets in the temporary interlayer
                            PortalContext.SaveEditorWidgets(CurrentPageInfo.DocumentID, mTemplateInstance.GetZonesXML(WidgetZoneTypeEnum.Editor));
                        }
                    }
                    else
                    {
                        // Save the changes
                        CMSPortalManager.SaveTemplateChanges(CurrentPageInfo, mTemplateInstance, ZoneType, viewMode, mTreeProvider);
                    }
                }
                else if ((viewMode.IsEdit()) && (ZoneType == WidgetZoneTypeEnum.Editor))
                {
                    Hashtable properties = WindowHelper.GetItem("variantProperties") as Hashtable;

                    VariantHelper.SaveWebPartVariantChanges(mWidgetInstance, VariantID, 0, VariantMode, properties);

                    // Log widget variant synchronization
                    TreeNode node = DocumentHelper.GetDocument(CurrentPageInfo.DocumentID, mTreeProvider);
                    DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, mTreeProvider);
                }
            }

            // Reload the form (because of macro values set only by JS)
            formCustom.ReloadData();

            // Display info message
            ShowChangesSaved();

            // Clear the cached web part
            CacheHelper.TouchKey("webpartinstance|" + InstanceGUID.ToString().ToLowerCSafe());

            return(true);
        }

        return(false);
    }
Beispiel #26
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            partPlaceholder.CheckPermissions = CheckPermissions;
            partPlaceholder.CacheMinutes     = CacheMinutes;

            // Load content only when default page template or path is defined
            string templateName = PageTemplate;
            string path         = Path;

            if ((templateName != "") || (path != ""))
            {
                ViewModeEnum viewMode = ViewModeEnum.Unknown;

                // Process template only if the control is on the last hierarchy page
                PageInfo         currentPage = PagePlaceholder.PageInfo;
                PageInfo         usePage;
                PageTemplateInfo ti = null;

                if (String.IsNullOrEmpty(path))
                {
                    // Use the same page
                    usePage = PagePlaceholder.PageInfo;

                    if (UseDefaultTemplateOnSubPages || (currentPage.ChildPageInfo == null) || (currentPage.ChildPageInfo.UsedPageTemplateInfo == null) || (currentPage.ChildPageInfo.UsedPageTemplateInfo.PageTemplateId == 0))
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }
                else
                {
                    // Resolve the path first
                    path = MacroResolver.ResolveCurrentPath(path);

                    // Get specific page
                    usePage = PageInfoProvider.GetPageInfo(SiteContext.CurrentSiteName, path, LocalizationContext.PreferredCultureCode, null, SiteContext.CurrentSite.CombineWithDefaultCulture);
                    if (PortalManager.ViewMode != ViewModeEnum.LiveSite)
                    {
                        viewMode = ViewModeEnum.Preview;

                        // Set design mode for document's placeholder if is currently displayed
                        TreeNode tn = DocumentContext.CurrentDocument;
                        if ((tn != null) && (PortalContext.ViewMode == ViewModeEnum.Design) && tn.NodeAliasPath.EqualsCSafe(path, true))
                        {
                            viewMode = ViewModeEnum.Design;
                        }

                        // Get latest version data of current document content
                        if (usePage != null)
                        {
                            usePage.LoadVersion();
                        }
                    }

                    // Get the appropriate page template
                    if (String.IsNullOrEmpty(templateName))
                    {
                        ti = (usePage != null) ? usePage.UsedPageTemplateInfo : null;
                    }
                    else
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }

                if ((usePage != null) && (ti != null))
                {
                    // If same template as current page, avoid cycling
                    if (ti.PageTemplateId == currentPage.UsedPageTemplateInfo.PageTemplateId)
                    {
                        lblError.Text    = GetString("WebPart.PagePlaceHolder.CurrentTemplateNotAllowed");
                        lblError.Visible = true;
                    }
                    else
                    {
                        usePage = usePage.Clone();

                        // Setup the page template
                        int templateId = ti.PageTemplateId;

                        usePage.SetPageTemplateId(templateId);
                        usePage.UsedPageTemplateInfo = ti;

                        // Load the current page info with the template and document
                        if (viewMode != ViewModeEnum.Unknown)
                        {
                            partPlaceholder.ViewMode = viewMode;
                        }

                        partPlaceholder.UsingDefaultPageTemplate = !string.IsNullOrEmpty(templateName);
                        partPlaceholder.UsingDefaultDocument     = !string.IsNullOrEmpty(path);
                        partPlaceholder.PageLevel = PagePlaceholder.PageLevel;
                        partPlaceholder.LoadContent(usePage);
                    }
                }
            }
        }
    }
Beispiel #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            chkWebParts.Checked = PortalHelper.DisplayContentInDesignMode;
        }

        tabQuery = QueryHelper.GetString("tabspecific", null);

        chkWebParts.Attributes.Add("onclick", "SaveSettings()");
        chkWebParts.Text = GetString("EditTabs.DisplayContent");

        ltlScript.Text += ScriptHelper.GetScript("function SaveSettings() { __theFormPostData = ''; WebForm_InitCallback(); " + ClientScript.GetCallbackEventReference(this, "'save'", "RefreshContent", null) + "; }");

        // Initialize tabs
        tabsModes.OnTabCreated += tabModes_OnTabCreated;
        tabsModes.SelectedTab = 0;
        tabsModes.UrlTarget = "contenteditview";

        // Process the page mode
        currentUser = CMSContext.CurrentUser;

        // Current Node ID
        nodeId = QueryHelper.GetInteger("nodeid", 0);

        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
        TreeNode node = tree.SelectSingleNode(nodeId);
        if (node != null)
        {
            // Product tab
            DataClassInfo classObj = DataClassInfoProvider.GetDataClass(node.NodeClassName);
            if (classObj != null)
            {
                showProductTab = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".ProductTabEnabled") && classObj.ClassIsProduct;
            }

            // Initialize required variables
            authorizedPerDesign = currentUser.IsAuthorizedPerResource("CMS.Design", "Design");
            isWireframe = node.NodeClassName.Equals("CMS.Wireframe", StringComparison.InvariantCultureIgnoreCase);

            // Get page template information
            PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, node.NodeAliasPath, node.DocumentCulture, node.DocumentUrlPath, false);
            if ((pi != null) && (pi.PageTemplateInfo != null))
            {
                PageTemplateInfo pti = pi.PageTemplateInfo;

                isPortalPage = pti.IsPortal;
                isMasterPage = isPortalPage && ((node.NodeAliasPath == "/") || pti.ShowAsMasterTemplate);
                designEnabled = ((pti.PageTemplateType == PageTemplateTypeEnum.Portal) || (pti.PageTemplateType == PageTemplateTypeEnum.AspxPortal));
            }

            // Do not show design tab for CMS.File
            if (node.NodeClassName.Equals("CMS.File", StringComparison.InvariantCultureIgnoreCase))
            {
                designEnabled = false;
            }

            // Update view mode
            UpdateViewMode(ViewModeEnum.Edit);

            // Get the page mode
            currentMode = CMSContext.ViewMode;
        }
    }
    /// <summary>
    /// Sets the view mode.
    /// </summary>
    /// <param name="viewMode">The view mode</param>
    private void SetViewMode(ViewModeEnum viewMode)
    {
        if (PortalHelper.IsOnSiteEditingEnabled(SiteContext.CurrentSiteName) && AuthenticationHelper.IsAuthenticated())
        {
            // Remove the "viewmode" param from url and redirect
            var returnUrl = GetURLWithoutViewMode();

            PortalContext.ViewMode = viewMode;

            // Switch view mode
            if (viewMode.IsEditLive() && (URLRewritingContext.CurrentPageInfoSource == PageInfoSource.DefaultAliasPath))
            {
                returnUrl = GetUrlOfDocumentWithDefaultAliasPath();
            }
            else if (is404)
            {
                // Redirect to the root document when page not found
                returnUrl = ResolveUrl("~/");
            }

            // Redirect to the URL
            URLHelper.Redirect(returnUrl);
        }
    }
Beispiel #29
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do nothing
        }
        else
        {
            this.partPlaceholder.CheckPermissions = this.CheckPermissions;
            this.partPlaceholder.CacheMinutes     = this.CacheMinutes;

            // Load content only when default page template or path is defined
            string templateName = this.PageTemplate;
            string path         = this.Path;

            if ((templateName != "") || (path != ""))
            {
                ViewModeEnum viewMode = ViewModeEnum.Unknown;

                // Process template only if the control is on the last hierarchy page
                PageInfo         currentPage = this.PagePlaceholder.PageInfo;
                PageInfo         usePage     = null;
                PageTemplateInfo ti          = null;

                if (String.IsNullOrEmpty(path))
                {
                    // Use the same page
                    usePage = this.PagePlaceholder.PageInfo;

                    if (this.UseDefaultTemplateOnSubPages || (currentPage.ChildPageInfo == null) || (currentPage.ChildPageInfo.PageTemplateInfo == null) || (currentPage.ChildPageInfo.PageTemplateInfo.PageTemplateId == 0))
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }
                else
                {
                    // Resolve the path first
                    path = CMSContext.ResolveCurrentPath(path);

                    // Get specific page
                    usePage = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, path, CMSContext.PreferredCultureCode, null, false);
                    if (this.PortalManager.ViewMode != ViewModeEnum.LiveSite)
                    {
                        viewMode = ViewModeEnum.Preview;

                        // Get current document content
                        if (usePage != null)
                        {
                            TreeNode node = DocumentHelper.GetDocument(usePage.DocumentId, null);
                            if (node != null)
                            {
                                usePage.LoadVersion(node);
                            }
                        }
                    }

                    // Get the appropriate page template
                    if (String.IsNullOrEmpty(templateName))
                    {
                        ti = usePage.PageTemplateInfo;
                    }
                    else
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }

                if ((usePage != null) && (ti != null))
                {
                    // If same template as current page, avoid cycling
                    if (ti.PageTemplateId == currentPage.PageTemplateInfo.PageTemplateId)
                    {
                        this.lblError.Text    = GetString("WebPart.PagePlaceHolder.CurrentTemplateNotAllowed");
                        this.lblError.Visible = true;
                    }
                    else
                    {
                        usePage = usePage.Clone();
                        usePage.DocumentPageTemplateID = ti.PageTemplateId;
                        usePage.PageTemplateInfo       = ti;


                        // Load the current page info with the template and document
                        if (viewMode != ViewModeEnum.Unknown)
                        {
                            this.partPlaceholder.ViewMode = viewMode;
                        }

                        this.partPlaceholder.UsingDefaultPageTemplate = true;
                        this.partPlaceholder.PageLevel = this.PagePlaceholder.PageLevel;
                        this.partPlaceholder.LoadContent(usePage, true);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Creates new culture version of object.
    /// </summary>
    protected void btnCreateDocument_Click(object sender, EventArgs e)
    {
        if (radCopy.Checked)
        {
            string   sourceCulture    = copyCulturesElem.Value.ToString();
            TreeNode actualSourceNode = DocumentHelper.GetDocument(NodeID, sourceCulture, Tree);
            TreeNode sourceNode       = actualSourceNode.IsLink ? DocumentHelper.GetDocument(Tree.GetOriginalNode(actualSourceNode), Tree) : actualSourceNode;

            if (sourceNode != null)
            {
                if (chkSaveBeforeEditing.Checked && (Node != null))
                {
                    // Create the version first
                    TreeNode newCulture = TreeNode.New(Node.ClassName);

                    // The 'DocumentABTestConfiguration' is excluded from copying node to another culture as A/B test is linked to the culture specific node
                    var excludedColumns = new[] { "DocumentABTestConfiguration" };

                    DocumentHelper.CopyNodeData(sourceNode, newCulture, new CopyNodeDataSettings(true, excludedColumns)
                    {
                        ResetChanges = true
                    });

                    if (string.Equals(Node.ClassName, "cms.blogpost", StringComparison.InvariantCultureIgnoreCase))
                    {
                        // Ensure blog post hierarchy if node is blog post
                        newCulture.DocumentCulture = RequiredCulture;
                        DocumentHelper.EnsureBlogPostHierarchy(newCulture, DocumentHelper.GetDocument(newCulture.NodeParentID, TreeProvider.ALL_CULTURES, Tree), Tree);
                    }

                    var settings = new NewCultureDocumentSettings(newCulture, RequiredCulture, Tree)
                    {
                        CopyAttachments       = true,
                        CopyCategories        = true,
                        ClearAttachmentFields = false
                    };

                    try
                    {
                        DocumentHelper.InsertNewCultureVersion(settings);
                    }
                    catch (Exception ex)
                    {
                        // Catch possible exceptions
                        LogAndShowError("Content", "NEWCULTUREVERSION", ex);
                        return;
                    }

                    // Make sure document is published when versioning without workflow is applied
                    var workflow = newCulture.GetWorkflow();
                    if ((workflow != null) && workflow.WorkflowAutoPublishChanges && !workflow.UseCheckInCheckOut(newCulture.NodeSiteName))
                    {
                        newCulture.MoveToPublishedStep();
                    }

                    // Refresh page
                    if (RequiresDialog)
                    {
                        string url = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(newCulture) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture);
                        ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(" wopener.location = " + ScriptHelper.GetString(url) + "; CloseDialog();"));
                    }
                    else
                    {
                        ViewModeEnum mode = ViewModeEnum.Edit;
                        if (!TreePathUtils.IsMenuItemType(Node.NodeClassName) && (PortalContext.ViewMode != ViewModeEnum.EditLive))
                        {
                            mode = ViewModeEnum.EditForm;
                        }
                        ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript("if (FramesRefresh) { FramesRefresh(" + Node.NodeID + ", '" + mode + "'); }"));
                    }
                }
                else
                {
                    var url = GetEditUrl(Node);
                    url = URLHelper.AddParameterToUrl(url, "sourcedocumentid", sourceNode.DocumentID.ToString());

                    if (RequiresDialog)
                    {
                        // Reload new page after save
                        url = URLHelper.AddParameterToUrl(url, "reloadnewpage", "true");
                    }

                    // Provide information about actual node
                    if (actualSourceNode.IsLink)
                    {
                        url = URLHelper.AddParameterToUrl(url, "sourcenodeid", actualSourceNode.NodeID.ToString());
                    }
                    URLHelper.ResponseRedirect(url);
                }
            }
            else
            {
                ShowError(GetString("transman.notallowedcreate"));
            }
        }
        else
        {
            var url = GetEditUrl(Node);

            if (RequiresDialog)
            {
                // Reload new page after save
                url = URLHelper.AddParameterToUrl(url, "reloadnewpage", "true");
            }

            URLHelper.ResponseRedirect(url);
        }
    }
    /// <summary>
    /// Check preview link context
    /// </summary>
    /// <param name="pageInfo">Page info</param>
    /// <param name="viewMode">View mode</param>
    /// <param name="documentUrl">Indicates if document URL should be checked</param>
    private static void CheckPreviewLink(PageInfo pageInfo, ViewModeEnum viewMode, bool documentUrl)
    {
        if (VirtualContext.IsPreviewLinkInitialized)
        {
            if (pageInfo != null)
            {
                Guid previewGuid = ValidationHelper.GetGuid(VirtualContext.GetItem(VirtualContext.PARAM_WF_GUID), Guid.Empty);
                if (previewGuid != Guid.Empty)
                {
                    // Force preview mode
                    if ((viewMode == ViewModeEnum.Preview) || (viewMode == ViewModeEnum.LiveSite))
                    {
                        // Preview link is valid
                        if (pageInfo.DocumentWorkflowCycleGUID == previewGuid)
                        {
                            if (documentUrl)
                            {
                                return;
                            }
                            // Additional check for links within the document
                            else if (VirtualContext.ValidatePreviewHash(URLHelper.CurrentRelativePath))
                            {
                                return;
                            }
                        }

                        // Reset the virtual context
                        VirtualContext.Reset();

                        // GUID values don't match
                        URLHelper.Redirect("~/CMSMessages/AccessDenied.aspx?message={$virtualcontext.accessdenied$}");
                    }
                }
            }
        }
    }
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        combinationSelector.UniSelector.UseUniSelectorAutocomplete = false;
        currentUser = MembershipContext.AuthenticatedUser;

        // Set the selected combination (from cookie by default)
        MVTestInfo mvTestInfo = MVTestInfoProvider.GetRunningTest(DocumentContext.CurrentAliasPath, SiteContext.CurrentSiteID, DocumentContext.CurrentDocumentCulture.CultureCode);

        // Get the cookie name
        if (mvTestInfo != null)
        {
            // Get a cookie name for the mvt test
            cookieTestName = CookieName.GetMVTCookieName(mvTestInfo.MVTestName);
        }
        else
        {
            // Get a template cookie name (used just in CMSDesk when no test is running)
            cookieTestName = CookieName.GetNoMVTCookieName(DocumentContext.CurrentDocument.GetUsedPageTemplateId());
        }

        // Move cookies expiration to next 30 days
        HttpCookie cookieMVTTest = CookieHelper.GetExistingCookie(cookieTestName);
        if (cookieMVTTest != null)
        {
            CookieHelper.SetValue(cookieMVTTest.Name, cookieMVTTest.Value, cookieMVTTest.Path, DateTime.Now.AddDays(30), false);
        }

        base.OnInit(e);

        viewMode = PortalContext.ViewMode;

        // Check permissions
        if ((currentUser == null)
            || (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design") && PortalContext.IsDesignMode(viewMode))
            || (!currentUser.IsAuthorizedPerResource("CMS.MVTest", "Read")))
        {
            stopProcessing = true;
        }
    }
Beispiel #33
0
    /// <summary>
    /// Overriden CreateChildControls method.
    /// </summary>
    protected override void CreateChildControls()
    {
        SetupControl();

        this.Controls.Clear();
        base.CreateChildControls();

        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = this.PageManager.ViewMode;

            // Create controls by actual page mode
            switch (viewMode)
            {
                case ViewModeEnum.Edit:
                case ViewModeEnum.EditDisabled:

                    // Main editor panel
                    this.pnlEditor = new Panel();
                    this.pnlEditor.ID = "pnlEditor";
                    this.pnlEditor.CssClass = "EditableTextEdit EditableText_" + this.ID;
                    this.Controls.Add(pnlEditor);

                    // Title label
                    this.lblTitle = new Label();
                    this.lblTitle.EnableViewState = false;
                    this.lblTitle.CssClass = "EditableTextTitle";
                    this.pnlEditor.Controls.Add(this.lblTitle);

                    // Error label
                    this.lblError = new Label();
                    this.lblError.EnableViewState = false;
                    this.lblError.CssClass = "EditableTextError";
                    this.pnlEditor.Controls.Add(this.lblError);

                    // Display the region control based on the region type
                    switch (this.RegionType)
                    {
                        case CMSEditableRegionTypeEnum.HtmlEditor:
                            // HTML Editor
                            this.htmlValue = new CMSHtmlEditor();
                            this.htmlValue.IsLiveSite = false;
                            this.htmlValue.ID = "htmlValue";
                            this.htmlValue.AutoDetectLanguage = false;
                            this.htmlValue.DefaultLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

                            // Set direction
                            this.htmlValue.Config["ContentsLangDirection"] = "ltr";

                            if (CultureHelper.IsPreferredCultureRTL())
                            {
                                this.htmlValue.Config["ContentsLangDirection"] = "rtl";
                            }

                            // Set the language
                            try
                            {
                                System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(DataHelper.GetNotEmpty(CMSContext.CurrentUser.PreferredUICultureCode, CMSContext.PreferredCultureCode));
                                this.htmlValue.DefaultLanguage = ci.TwoLetterISOLanguageName;
                            }
                            catch
                            {
                            }

                            this.htmlValue.AutoDetectLanguage = false;
                            this.htmlValue.Enabled = (viewMode == ViewModeEnum.Edit);

                            if (viewMode == ViewModeEnum.EditDisabled)
                            {
                                this.pnlEditor.Controls.Add(new LiteralControl("<div style=\"width: 98%\">"));
                                this.pnlEditor.Controls.Add((Control)this.htmlValue);
                                this.pnlEditor.Controls.Add(new LiteralControl("</div>"));
                            }
                            else
                            {
                                this.pnlEditor.Controls.Add((Control)this.htmlValue);
                            }
                            break;

                        case CMSEditableRegionTypeEnum.TextArea:
                        case CMSEditableRegionTypeEnum.TextBox:
                            // TextBox
                            this.txtValue = new TextBox();
                            this.txtValue.ID = "txtValue";
                            this.txtValue.CssClass = "EditableTextTextBox";

                            this.txtValue.Enabled = (viewMode == ViewModeEnum.Edit);
                            this.pnlEditor.Controls.Add(this.txtValue);
                            break;
                    }
                    break;

                default:
                    // Display content in non editing modes
                    this.ltlContent = new Literal();
                    this.ltlContent.ID = "ltlContent";
                    this.ltlContent.EnableViewState = false;
                    this.Controls.Add(this.ltlContent);
                    break;
            }
        }
    }
Beispiel #34
0
    /// <summary>
    /// Overriden CreateChildControls method.
    /// </summary>
    protected override void CreateChildControls()
    {
        SetupControl();

        this.Controls.Clear();
        base.CreateChildControls();

        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = this.PageManager.ViewMode;

            // Create controls by actual page mode
            switch (viewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:

                // Main editor panel
                this.pnlEditor          = new Panel();
                this.pnlEditor.ID       = "pnlEditor";
                this.pnlEditor.CssClass = "EditableTextEdit EditableText_" + this.ID;
                this.Controls.Add(pnlEditor);

                // Title label
                this.lblTitle = new Label();
                this.lblTitle.EnableViewState = false;
                this.lblTitle.CssClass        = "EditableTextTitle";
                this.pnlEditor.Controls.Add(this.lblTitle);

                // Error label
                this.lblError = new Label();
                this.lblError.EnableViewState = false;
                this.lblError.CssClass        = "EditableTextError";
                this.pnlEditor.Controls.Add(this.lblError);

                // Display the region control based on the region type
                switch (this.RegionType)
                {
                case CMSEditableRegionTypeEnum.HtmlEditor:
                    // HTML Editor
                    this.htmlValue                    = new CMSHtmlEditor();
                    this.htmlValue.IsLiveSite         = false;
                    this.htmlValue.ID                 = "htmlValue";
                    this.htmlValue.AutoDetectLanguage = false;
                    this.htmlValue.DefaultLanguage    = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

                    // Set direction
                    this.htmlValue.Config["ContentsLangDirection"] = "ltr";

                    if (CultureHelper.IsPreferredCultureRTL())
                    {
                        this.htmlValue.Config["ContentsLangDirection"] = "rtl";
                    }

                    // Set the language
                    try
                    {
                        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(DataHelper.GetNotEmpty(CMSContext.CurrentUser.PreferredUICultureCode, CMSContext.PreferredCultureCode));
                        this.htmlValue.DefaultLanguage = ci.TwoLetterISOLanguageName;
                    }
                    catch
                    {
                    }

                    this.htmlValue.AutoDetectLanguage = false;
                    this.htmlValue.Enabled            = (viewMode == ViewModeEnum.Edit);

                    if (viewMode == ViewModeEnum.EditDisabled)
                    {
                        this.pnlEditor.Controls.Add(new LiteralControl("<div style=\"width: 98%\">"));
                        this.pnlEditor.Controls.Add((Control)this.htmlValue);
                        this.pnlEditor.Controls.Add(new LiteralControl("</div>"));
                    }
                    else
                    {
                        this.pnlEditor.Controls.Add((Control)this.htmlValue);
                    }
                    break;

                case CMSEditableRegionTypeEnum.TextArea:
                case CMSEditableRegionTypeEnum.TextBox:
                    // TextBox
                    this.txtValue          = new TextBox();
                    this.txtValue.ID       = "txtValue";
                    this.txtValue.CssClass = "EditableTextTextBox";

                    this.txtValue.Enabled = (viewMode == ViewModeEnum.Edit);
                    this.pnlEditor.Controls.Add(this.txtValue);
                    break;
                }
                break;

            default:
                // Display content in non editing modes
                this.ltlContent    = new Literal();
                this.ltlContent.ID = "ltlContent";
                this.ltlContent.EnableViewState = false;
                this.Controls.Add(this.ltlContent);
                break;
            }
        }
    }
    /// <summary>
    /// PreRender event handler.
    /// </summary>
    void Page_PreRender(object sender, EventArgs e)
    {
        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = (CMSContext.ViewMode == ViewModeEnum.Preview) ? ViewModeEnum.Preview : this.PageManager.ViewMode;

            switch (viewMode)
            {
                case ViewModeEnum.Edit:
                case ViewModeEnum.EditDisabled:
                    // Set enabled
                    if (this.htmlValue != null)
                    {
                        this.htmlValue.Enabled = (viewMode == ViewModeEnum.Edit);
                    }
                    if (this.txtValue != null)
                    {
                        this.txtValue.Enabled = (viewMode == ViewModeEnum.Edit);
                    }

                    if (mShowToolbar && (viewMode == ViewModeEnum.Edit))
                    {
                        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ScriptHelper.TOOLBAR_SCRIPT_KEY, ScriptHelper.ToolbarScript);
                    }

                    if (this.lblError != null)
                    {
                        this.lblError.Visible = (this.lblError.Text != "");
                    }

                    this.lblTitle.Text = this.RegionTitle;
                    this.lblTitle.Visible = (this.lblTitle.Text != "");

                    break;
            }
        }
    }
Beispiel #36
0
    /// <summary>
    /// Overriden CreateChildControls method.
    /// </summary>
    protected override void CreateChildControls()
    {
        this.Controls.Clear();
        base.CreateChildControls();

        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = this.PageManager.ViewMode;

            // Create controls by actual page mode
            switch (viewMode)
            {
                case ViewModeEnum.Edit:
                case ViewModeEnum.EditDisabled:
                    // Main editor panel
                    this.pnlEditor = new Panel();
                    this.pnlEditor.ID = "pnlEditor";
                    this.pnlEditor.CssClass = "EditableImageEdit EditableImage_" + this.ID;
                    if (this.ImageWidth > 0)
                    {
                        this.pnlEditor.Style.Add(HtmlTextWriterStyle.Width, this.ImageWidth.ToString() + "px;");
                        //this.pnlEditor.Width = new Unit(this.DialogWidth); // Causes Invalid cast on Render
                    }
                    this.Controls.Add(pnlEditor);

                    // Title label
                    this.lblTitle = new Label();
                    this.lblTitle.EnableViewState = false;
                    this.lblTitle.CssClass = "EditableTextTitle";
                    this.pnlEditor.Controls.Add(this.lblTitle);

                    // Error label
                    this.lblError = new Label();
                    this.lblError.EnableViewState = false;
                    this.lblError.CssClass = "EditableTextError";
                    this.pnlEditor.Controls.Add(this.lblError);

                    // Add image selector
                    this.selPath = new ImageSelector(null, true);
                    this.selPath.Culture = CMSContext.CurrentUser.PreferredUICultureCode;
                    this.selPath.EnableOpenInFull = false;
                    this.selPath.ID = "selPath";
                    this.selPath.UseImagePath = true;
                    this.selPath.ImageCssClass = this.ImageCssClass;
                    this.selPath.ImageStyle = this.ImageStyle;
                    this.selPath.ShowTextBox = this.DisplaySelectorTextBox;
                    this.selPath.DefaultValue = this.DefaultImage;

                    // Dialog configuration
                    this.selPath.DialogConfig.ResizeToHeight = this.ResizeToHeight;
                    this.selPath.DialogConfig.ResizeToWidth = this.ResizeToWidth;
                    this.selPath.DialogConfig.ResizeToMaxSideSize = this.ResizeToMaxSideSize;

                    this.pnlEditor.Controls.Add(this.selPath);

                    this.selPath.Enabled = (viewMode == ViewModeEnum.Edit);
                    this.selPath.IsLiveSite = (viewMode == ViewModeEnum.LiveSite);
                    break;

                default:
                    // Display content in non editing modes
                    this.imgImage = new Image();
                    this.imgImage.ID = "imgImage";
                    this.imgImage.GenerateEmptyAlternateText = true;
                    if (this.ImageCssClass != "")
                    {
                        this.imgImage.CssClass = this.ImageCssClass;
                    }
                    if (this.ImageStyle != "")
                    {
                        this.imgImage.Attributes.Add("style", this.ImageStyle);
                    }

                    this.imgImage.AlternateText = this.AlternateText;
                    this.imgImage.ToolTip = this.AlternateText;
                    this.imgImage.EnableViewState = false;
                    this.Controls.Add(this.imgImage);
                    break;
            }
        }
    }
    /// <summary>
    /// Sets the view mode.
    /// </summary>
    /// <param name="viewMode">The view mode</param>
    private void SetViewMode(ViewModeEnum viewMode)
    {
        if (PortalHelper.IsOnSiteEditingEnabled(CMSContext.CurrentSiteName) && UserInfoProvider.IsAuthenticated())
        {
            // Remove the "viewmode" param from url and redirect
            string returnUrl = URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, "viewmode");

            CMSContext.ViewMode = viewMode;

            // Switch view mode
            if (viewMode == ViewModeEnum.EditLive)
            {
                //  Handle default alias path
                if (URLRewriter.CurrentPageInfoSource == PageInfoSource.DefaultAliasPath)
                {
                    string aliasPath = PageInfoProvider.GetDefaultAliasPath(URLHelper.GetCurrentDomain(), CMSContext.CurrentSiteName);
                    if (!String.IsNullOrEmpty(aliasPath))
                    {
                        string query = URLHelper.GetQuery(returnUrl);
                        returnUrl = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(aliasPath));
                        returnUrl = URLHelper.AppendQuery(returnUrl, query);
                    }
                }
            }
            else if (is404)
            {
                // Redirect to the root document when page not found
                returnUrl = ResolveUrl("~/");
            }

            // Redirect to the URL
            URLHelper.Redirect(returnUrl, false, null);
        }
    }
Beispiel #38
0
        public async Task <ActionResult> RiepilogoEmendamenti(Guid id, ClientModeEnum mode = ClientModeEnum.GRUPPI,
                                                              OrdinamentoEnum ordine       = OrdinamentoEnum.Presentazione, ViewModeEnum view = ViewModeEnum.GRID, int page = 1,
                                                              int size = 50)
        {
            var apiGateway = new ApiGateway(_Token);
            EmendamentiViewModel model;
            var view_require_my_sign = Convert.ToBoolean(Request.QueryString["require_my_sign"]);

            if (Session["RicaricaFiltri"] is bool)
            {
                if (Convert.ToBoolean(Session["RicaricaFiltri"]))
                {
                    Session["RicaricaFiltri"] = false; //reset sessione
                    if (Session["RiepilogoEmendamenti"] is EmendamentiViewModel old_model)
                    {
                        try
                        {
                            if (HttpContext.User.IsInRole(RuoliExt.Amministratore_PEM) ||
                                HttpContext.User.IsInRole(RuoliExt.Segreteria_Assemblea))
                            {
                                return(View("RiepilogoEM_Admin", old_model));
                            }

                            return(View("RiepilogoEM", old_model));
                        }
                        catch (Exception e)
                        {
                            Session["RiepilogoEmendamenti"] = null;
                        }
                    }
                }
            }

            SetCache(page, size, ordine, view);

            var composeModel = await ComposeModel(id, mode, ordine, view, page, size, view_require_my_sign);

            Session["RiepilogoEmendamenti"] = composeModel;

            if (HttpContext.User.IsInRole(RuoliExt.Amministratore_PEM) ||
                HttpContext.User.IsInRole(RuoliExt.Segreteria_Assemblea))
            {
                return(View("RiepilogoEM_Admin", composeModel));
            }
            return(View("RiepilogoEM", composeModel));
        }
Beispiel #39
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Content/CMSDesk/ContentEditFrameset.js");

        // Current Node ID
        int nodeId = QueryHelper.GetInteger("nodeid", 0);

        ViewModeEnum currentMode = ViewModeEnum.Edit;

        // Get the node
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        tree.CombineWithDefaultCulture = false;

        TreeNode node = DocumentHelper.GetDocument(nodeId, CMSContext.PreferredCultureCode, tree);

        if (node != null)
        {
            currentMode = CMSContext.ViewMode;

            // Check the product mode
            if (currentMode == ViewModeEnum.Product)
            {
                bool showProductTab = false;

                // Product tab has to be allowed in settings and also the doc. type has to be marked as a product
                DataClassInfo classObj = DataClassInfoProvider.GetDataClass(node.NodeClassName);
                if (classObj != null)
                {
                    showProductTab = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".ProductTabEnabled") && classObj.ClassIsProduct;
                }

                if (!showProductTab)
                {
                    currentMode         = ViewModeEnum.Properties;
                    CMSContext.ViewMode = ViewModeEnum.Properties;
                }
            }

            // Get the name for automatic title
            string name = (node.NodeAliasPath == "/" ? CMSContext.CurrentSite.DisplayName : node.DocumentName);
            if (!String.IsNullOrEmpty(name))
            {
                ScriptHelper.RegisterTitleScript(this, ResHelper.LocalizeString(name));
            }
        }
        else
        {
            // Document does not exist -> redirect to new culture version creation dialog
            URLHelper.Redirect("~/CMSModules/Content/CMSDesk/New/NewCultureVersion.aspx" + URLHelper.Url.Query);
        }

        switch (ValidationHelper.GetString(Request.QueryString["action"], "edit").ToLower())
        {
        case "properties":
            viewpage = "~/CMSModules/Content/CMSDesk/Properties/default.aspx";
            string tab = QueryHelper.GetString("tab", null);
            if (!string.IsNullOrEmpty(tab))
            {
                tabspage = URLHelper.RemoveParameterFromUrl(tabspage, "tab");
                tabspage = URLHelper.AddParameterToUrl(tabspage, "tabspecific", tab);
            }
            break;

        case "product":
            viewpage = "~/CMSModules/Ecommerce/Pages/Content/Product/Product_Selection.aspx";
            break;

        default:
            // Set the radio buttons
            switch (currentMode)
            {
            case ViewModeEnum.Product:
                viewpage = "~/CMSModules/Ecommerce/Pages/Content/Product/Product_Selection.aspx";
                break;

            case ViewModeEnum.Properties:
                viewpage = "~/CMSModules/Content/CMSDesk/Properties/default.aspx";
                break;

            default:
                viewpage = "~/CMSModules/Content/CMSDesk/Edit/editframeset.aspx";
                break;
            }
            break;
        }

        viewpage += URLHelper.Url.Query;

        // Split mode enabled
        if (CMSContext.DisplaySplitMode)
        {
            viewpage = GetSplitViewUrl(viewpage);
        }

        viewpage = ResolveUrl(viewpage);
    }
Beispiel #40
0
        private async Task <EmendamentiViewModel> ComposeModel(Guid id, ClientModeEnum mode,
                                                               OrdinamentoEnum ordine, ViewModeEnum view, int page,
                                                               int size, bool view_require_my_sign)
        {
            try
            {
                var apiGateway = new ApiGateway(_Token);
                EmendamentiViewModel model;
                if (view_require_my_sign == false)
                {
                    model = await apiGateway.Emendamento.Get(id, mode, ordine, page, size);
                }
                else
                {
                    model = await apiGateway.Emendamento.Get_RichiestaPropriaFirma(id, mode, ordine, page, size);
                }
                model.ViewMode = view;
                if (view == ViewModeEnum.PREVIEW)
                {
                    foreach (var emendamentiDto in model.Data.Results)
                    {
                        emendamentiDto.BodyEM =
                            await apiGateway.Emendamento.GetBody(emendamentiDto.UIDEM, TemplateTypeEnum.HTML);
                    }
                }

                if (HttpContext.User.IsInRole(RuoliExt.Amministratore_PEM) ||
                    HttpContext.User.IsInRole(RuoliExt.Segreteria_Assemblea))
                {
                    return(model);
                }

                if (mode == ClientModeEnum.GRUPPI)
                {
                    foreach (var emendamentiDto in model.Data.Results)
                    {
                        if (emendamentiDto.IDStato <= (int)StatiEnum.Depositato)
                        {
                            if (emendamentiDto.ConteggioFirme > 0)
                            {
                                emendamentiDto.Firmatari = await Utility.GetFirmatariEM(
                                    await apiGateway.Emendamento.GetFirmatari(emendamentiDto.UIDEM,
                                                                              FirmeTipoEnum.TUTTE),
                                    _CurrentUser.UID_persona, FirmeTipoEnum.TUTTE, _Token, true);
                            }

                            emendamentiDto.Destinatari =
                                await Utility.GetDestinatariNotifica(
                                    await apiGateway.Emendamento.GetInvitati(emendamentiDto.UIDEM), _Token);
                        }
                    }
                }

                return(model);
            }
            catch (Exception e)
            {
                Log.Error("ComposeModel", e);
                throw;
            }
        }
 /// <summary>
 /// Indicates whether this control should be enabled and editing allowed.
 /// </summary>
 /// <param name="viewMode">The view mode.</param>
 private bool IsEnabled(ViewModeEnum viewMode)
 {
     return (viewMode.IsEdit()) && DocumentManager.AllowSave;
 }
Beispiel #42
0
    /// <summary>
    /// PreRender event handler.
    /// </summary>
    void Page_PreRender(object sender, EventArgs e)
    {
        if (!this.StopProcessing)
        {
            // Initialize viewmode
            viewMode = (CMSContext.ViewMode == ViewModeEnum.Preview) ? ViewModeEnum.Preview : this.PageManager.ViewMode;

            switch (viewMode)
            {
                case ViewModeEnum.Edit:
                case ViewModeEnum.EditDisabled:
                    // Set enabled
                    if (this.htmlValue != null)
                    {
                        this.htmlValue.Enabled = (viewMode == ViewModeEnum.Edit);
                    }
                    if (this.txtValue != null)
                    {
                        this.txtValue.Enabled = (viewMode == ViewModeEnum.Edit);
                    }

                    if (mShowToolbar && (viewMode == ViewModeEnum.Edit))
                    {
                        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ScriptHelper.TOOLBAR_SCRIPT_KEY, ScriptHelper.ToolbarScript);
                    }

                    if (this.lblError != null)
                    {
                        this.lblError.Visible = (this.lblError.Text != "");
                    }

                    this.lblTitle.Text = this.RegionTitle;
                    this.lblTitle.Visible = (this.lblTitle.Text != "");

                    // Allow to select text in the source editor area
                    if (pnlDesign != null)
                    {
                        ScriptHelper.RegisterStartupScript(this, typeof(string), "onselectstart", "document.getElementById('" + pnlDesign.ClientID + "').parentNode.onselectstart = function() { return true; };", true);
                    }

                    break;
            }
        }
    }
Beispiel #43
0
    protected override void OnInit(EventArgs e)
    {
        // Initialize viewmode
        viewMode = this.PageManager.ViewMode;

        base.OnInit(e);
    }
Beispiel #44
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            StartupPath = System.Windows.Forms.Application.StartupPath + '\\';

            DockIcon.Register(StartupPath + "Container-Empty.png", null, false);
            if (!DockIcon.IsRegistered)
            {
                Shutdown();
                return;
            }

            DockIcon.KeepInDock = true;
            DockIcon.Exposable = false;
            DockIcon.Activatable = true;

            Settings.Initialize(DockIcon.SettingsPath + "settings.xml");

            #region Get Previous Icon

            var iconName = DockIcon.IconName;
            if (string.IsNullOrEmpty(iconName))
            {
                iconName = StartupPath + "Container-Empty.png";
            }
            if (string.IsNullOrEmpty(Settings.Icon) || ((iconName != StartupPath + "Container-Empty.png") && (iconName != StartupPath + "Container-Opened.png")))
            {
                Settings.Icon = iconName;
                Settings.Save();
            }

            #endregion

            #region Init Path

            Path = Settings.Path;
            if (!Directory.Exists(Path))
            {
                Path = StartupPath;
            }
            if (Path.LastIndexOf('\\') < Path.Length - 1)
            {
                Path += '\\';
            }

            #endregion

            #region Start With View Mode

            if ((e.Args.Length >= 3) && (e.Args[0] == "-viewMode"))
            {
                Path = e.Args[2];
                if (Path.LastIndexOf('\\') < Path.Length - 1)
                {
                    Path += '\\';
                }
                if (!((e.Args.Length == 4) && (e.Args[3] == "-notSetPath")))
                {
                    Settings.Path = Path;
                }

                Directories = Directory.GetDirectories(Path);
                Files = Directory.GetFiles(Path);

                DockIcon.Title = null;
                DockIcon.AddFolderWatcher(1, DockIcon.FolderWatcherActions.FileAdded | DockIcon.FolderWatcherActions.FileModified | DockIcon.FolderWatcherActions.FolderAdded, Path);

                switch (e.Args[1])
                {
                    case "fan":
                        ViewMode = ViewModeEnum.Fan;
                        MainWindow = new ContainerPublic.FanView();
                        break;

                    case "list":
                        ViewMode = ViewModeEnum.List;
                        Shutdown();
                        return;
                    //break;

                    default:
                        ViewMode = ViewModeEnum.Grid;
                        MainWindow = new ContainerPublic.GridView();
                        break;
                }

                MainWindow.Show();
                return;
            }

            #endregion

            #region Dropped files & directories into the stack

            if ((e.Args.Length > 0) && !((e.Args.Length == 1) && Directory.Exists(e.Args[0])))
            {
                var droppedFiles = true;
                foreach (var file in e.Args)
                {
                    if (!File.Exists(file) && !Directory.Exists(file))
                    {
                        droppedFiles = false;
                        break;
                    }
                }
                if (droppedFiles)
                {
                    var fileOperation = new SHFileOpStruct();
                    fileOperation.hwnd = IntPtr.Zero;

                    fileOperation.wFunc = FO_Func.FO_MOVE;
                    if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control)
                    {
                        fileOperation.wFunc = FO_Func.FO_COPY;
                    }

                    fileOperation.pFrom = StringArrayToMultiString(e.Args);
                    fileOperation.pTo = StringArrayToMultiString(new string[] { Path });
                    fileOperation.hNameMappings = IntPtr.Zero;
                    fileOperation.fAnyOperationsAborted = 0;
                    fileOperation.fFlags = 0;
                    fileOperation.lpszProgressTitle = null;

                    SHFileOperation(ref fileOperation);

                    Shutdown();
                    return;
                }
            }

            #endregion

            #region Start With Directory

            if ((e.Args.Length > 0) && Directory.Exists(e.Args[0]))
            {
                Path = e.Args[0];
                if (Path.LastIndexOf('\\') < Path.Length - 1)
                {
                    Path += '\\';
                }
                if (!((e.Args.Length == 2) && (e.Args[1] == "-notSetPath")))
                {
                    Settings.Path = Path;
                }
            }

            #endregion

            #region Default

            Directories = Directory.GetDirectories(Path);
            Files = Directory.GetFiles(Path);

            if (Directories.Length + Files.Length <= FanView.MaxItems)
            {
                ViewMode = ViewModeEnum.Fan;
            }
            else if (Directories.Length + Files.Length <= GridView.MaxItems)
            {
                ViewMode = ViewModeEnum.Grid;
            }
            else
            {
                //ViewMode = ViewModeEnum.List;
                ViewMode = ViewModeEnum.Grid;
            }

            DockIcon.Title = null;
            DockIcon.AddFolderWatcher(1, DockIcon.FolderWatcherActions.FileAdded | DockIcon.FolderWatcherActions.FileModified | DockIcon.FolderWatcherActions.FolderAdded, Path);

            switch (ViewMode)
            {
                case ViewModeEnum.Fan:
                    MainWindow = new ContainerPublic.FanView();
                    break;

                case ViewModeEnum.List:
                    Shutdown();
                    return;
                    //break;

                default:
                    MainWindow = new ContainerPublic.GridView();
                    break;
            }

            MainWindow.Show();

            #endregion
        }
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        currentUser = CMSContext.CurrentUser;

        // Set the selected combination (from cookie by default)
        MVTestInfo mvTestInfo = MVTestInfoProvider.GetRunningTest(CMSContext.CurrentAliasPath, CMSContext.CurrentSiteID, CMSContext.CurrentDocumentCulture.CultureCode);

        // Get the cookie name
        if (mvTestInfo != null)
        {
            // Get a cookie name for the mvt test
            cookieTestName = "CMSMVT" + mvTestInfo.MVTestName.ToLower();
        }
        else
        {
            // Get a template cookie name (used just in CMSDesk when no test is running)
            cookieTestName = "CMSNoTestMVT" + CMSContext.CurrentDocument.DocumentPageTemplateID;
        }

        // Move cookies expiration to next 30 days
        HttpCookie cookieMVTTest = CookieHelper.GetExistingCookie(cookieTestName);
        if (cookieMVTTest != null)
        {
            CookieHelper.SetValue(cookieMVTTest.Name, cookieMVTTest.Value, cookieMVTTest.Path, DateTime.Now.AddDays(30), false);
        }

        base.OnInit(e);

        viewMode = CMSContext.ViewMode;

        // Check permissions
        if ((currentUser == null)
            || (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design") && ((viewMode == ViewModeEnum.Design) || (viewMode == ViewModeEnum.DesignDisabled)))
            || (!currentUser.IsAuthorizedPerResource("CMS.MVTest", "Read")))
        {
            stopProcessing = true;
        }
    }