예제 #1
0
        /// <summary>
        /// obtem a informacao sobre a pagina do pedido
        /// </summary>
        /// <param name="sectionInfo">a informao da seco corrente</param>
        /// <param name="requestPath">o path da request</param>
        /// <returns>o objecto PageInfo com a informao da pgina ou ento
        /// <code>null</code> se a pgina no for encontrada</returns>
        private PageInfo getPageInfo(SectionInfo sectionInfo, MasterSkinInfo masterSkinInfo, string requestPath)
        {
            // obter o ficheiro do pedido
            string requestFile = OrionGlobals.getPageName(requestPath);

            // se for uma seco ou subsecco
            if (requestFile.ToLower() == "/default.aspx")
            {
                return(new PageInfo(
                           -1,
                           sectionInfo.sectionParentId,
                           sectionInfo.sectionName,
                           sectionInfo.sectionTitle,
                           masterSkinInfo.masterSkinName,
                           sectionInfo.sectionDescription,
                           sectionInfo.sectionContent
                           ));
            }

            PageInfo pageInfo;

            pageInfo = NamedPageUtility.getNamedPageInfo(requestFile.ToLower());
            if (pageInfo != null)
            {
                return(pageInfo);
            }

            // se tudo falhar kaboom, big kaboom
            return(null);
        }
예제 #2
0
        /// <summary>Verifica se o pedido  do Wiki e se for trata-o</summary>
        private bool CheckWiki(IPrincipal user)
        {
            Log.log("Checking Wiki...");
            SectionInfo sectionInfo = (SectionInfo)Context.Items["SectionInfo"];

            if (sectionInfo == null)
            {
                Log.log("   sectionInfo == null");
                return(true);
            }

            if (sectionInfo.sectionName != "Wiki")
            {
                Log.log("   sectionInfo.sectionName != Wiki");
                return(false);
            }

#if WIKI
            Log.log("User can edit wiki? " + user.IsInRole("admin"));
            if (false && user.IsInRole("admin"))
            {
                string newPath = HttpContext.Current.Request.RawUrl;
                Log.log("Going to rewrite path to {0}", newPath);
                Context.RewritePath(newPath);
                return(true);
            }
#endif
            return(true);
        }
예제 #3
0
        /// <summary>
        /// verifica se o utilizador pode ver ou n a página corrente
        /// </summary>
        /// <returns><code>true</code> se o utilizador puder ver a página, <code>false</code> caso contrário</returns>
        private bool canView()
        {
            Log.log("Checking 'canView'...");
            SectionInfo sectionInfo = (SectionInfo)Context.Items["SectionInfo"];

            if (sectionInfo == null)
            {
                Log.log("[false] sectionInfo is null");
                return(false);
            }

            string[] sectionRoles = sectionInfo.sectionRoles;

            if (null == sectionRoles)
            {
                return(true);
            }

            bool toReturn = false;

            for (int i = 0; i < sectionRoles.Length; ++i)
            {
                if (Context.User.IsInRole(sectionRoles[i]))
                {
                    toReturn = true;
                }
            }

            return(toReturn);
        }
예제 #4
0
        private bool isSectionGood(SectionInfo sectionInfo)
        {
            if (!sectionInfo.isVisible || sectionInfo.sectionParentId == 2 || sectionInfo.sectionParentId == 1 || sectionInfo.sectionParentId == -1)
            {
                return(false);
            }

            if ((sectionInfo.sectionId == 5 && currentSectionInfo.sectionId == 3))
            {
                return(false);
            }

            if (sectionInfo.sectionId == 5 && (currentSectionInfo.sectionId != 5 && currentSectionInfo.sectionParentId != 5))
            {
                return(false);
            }

            //contemplar o pai contemplar os filhos                                              contemplar os irmos e no ser a seco planetas
            if (sectionInfo.sectionId == currentSectionInfo.sectionParentId || sectionInfo.sectionParentId == currentSectionInfo.sectionId || (sectionInfo.sectionParentId == currentSectionInfo.sectionParentId && currentSectionInfo.sectionId != 5) || currentSectionInfo.sectionId == sectionInfo.sectionId)
            {
                return(true);
            }

            return(false);
        }
예제 #5
0
        /// <summary>
        /// inicializa a skin
        /// </summary>
        /// <param name="skin">o control que representa a skin</param>
        override protected void initializeSkin(Control skin)
        {
            currentSectionInfo = (SectionInfo)Context.Items["SectionInfo"];

            placeholder = (PlaceHolder)getControl(skin, "placeholder");

            if (currentSectionInfo.isVisible)
            {
                repeater = (Repeater)getControl(skin, "menu");

                ArrayList subSections = getSubSections();

                if (subSections.Count > 0)
                {
                    placeholder.Visible = true;
                    repeater.DataSource = subSections;
                    repeater.DataBind();
                    return;
                }
            }
            placeholder.Visible = false;
        }
예제 #6
0
        protected override void OnInit(EventArgs e)
        {
            Context.Trace.Write("BasePageModule", "OnInit");

            Control skin;

            // Determinar a skin pedida
            SectionInfo sectionInfo = (SectionInfo)HttpContext.Current.Items["SectionInfo"];
            PageInfo    pageInfo    = (PageInfo)HttpContext.Current.Items["PageInfo"];

            masterSkinInfo = (MasterSkinInfo)HttpContext.Current.Items["MasterSkinInfo"];

            string skinFileName;

            if (_sectionContent != string.Empty && sectionInfo.sectionContent != _sectionContent)
            {
                _fileName = "InvalidAccess.ascx";
            }
            else
            {
                _fileName = _fileName == null?pageInfo.pageName:_fileName;
            }

            skinFileName = String.Format("{0}{1}/content/{2}.ascx", OrionGlobals.AppPath, masterSkinInfo.masterSkinName, _fileName);

            if (!File.Exists(HttpContext.Current.Server.MapPath(skinFileName)))
            {
                masterSkinInfo = MasterSkinUtility.getDefaultMasterSkinInfo();
                skinFileName   = String.Format("{0}{1}/content/{2}.ascx", OrionGlobals.AppPath, masterSkinInfo.masterSkinName, _fileName);
            }

            Context.Trace.Write("BasePageModule", "Loading Module: " + skinFileName);
            try {
                skin = Page.LoadControl(skinFileName);
            } catch (Exception ex) {
                throw new Exception("Error Loading " + skinFileName + " - " + ex.Message, ex);
            }
            Controls.Add(skin);
        }
예제 #7
0
        /// <summary>
        /// retorna a informao da seco baseado no path do pedido
        /// </summary>
        /// <param name="requestPath">path do pedido</param>
        /// <returns>a section do path</returns>
        public static SectionInfo getSectionInfoFromFullPath(string requestPath)
        {
            Log.log("Setting up requestPath '{0}'...", requestPath);
            requestPath = requestPath.Replace(OrionGlobals.InternalAppPath, OrionGlobals.AppPath);
            requestPath = requestPath.Replace(OrionGlobals.InternalAppPath, OrionGlobals.AppPath);
            Log.log("\tGot: '{0}'", requestPath);

            UtilityCollection sectionCollection = getAllSections();

            Log.log("Getting SectionInfo for '{0}'", requestPath);
            SectionInfo info = (SectionInfo)sectionCollection[requestPath];

#if DEBUG
            if (info == null)
            {
                Log.log("\tNot Found!");
            }
            else
            {
                Log.log("\tFound!");
            }
#endif
            return(info);
        }
예제 #8
0
        protected string getSectionLink(RepeaterItem item)
        {
            SectionInfo info = (SectionInfo)((DictionaryEntry)item.DataItem).Value;

            return(info.sectionPath);
        }
예제 #9
0
        /// <summary>
        /// obtem a informacao sobre a pagina do pedido
        /// </summary>
        /// <param name="sectionInfo">a informao da seco corrente</param>
        /// <param name="requestPath">o path da request</param>
        /// <returns>o objecto PageInfo com a informao da pgina ou ento
        /// <code>null</code> se a pgina no for encontrada</returns>
        private PageInfo getPageInfo(SectionInfo sectionInfo, MasterSkinInfo masterSkinInfo, string requestPath)
        {
            // obter o ficheiro do pedido
                string requestFile = OrionGlobals.getPageName(requestPath);

                // se for uma seco ou subsecco
                if (requestFile.ToLower() == "/default.aspx")
                    return new PageInfo(
                        -1,
                        sectionInfo.sectionParentId,
                        sectionInfo.sectionName,
                        sectionInfo.sectionTitle,
                        masterSkinInfo.masterSkinName,
                        sectionInfo.sectionDescription,
                        sectionInfo.sectionContent
                    );

                PageInfo pageInfo;

                pageInfo = NamedPageUtility.getNamedPageInfo( requestFile.ToLower() );
                if(pageInfo != null)
                    return pageInfo;

                // se tudo falhar kaboom, big kaboom
                return null;
        }
예제 #10
0
        private bool isSectionGood( SectionInfo sectionInfo)
        {
            if( !sectionInfo.isVisible || sectionInfo.sectionParentId == 2 || sectionInfo.sectionParentId == 1 || sectionInfo.sectionParentId == -1 )
                return false;

            if( (sectionInfo.sectionId == 5 && currentSectionInfo.sectionId == 3) )
                return false;

            if( sectionInfo.sectionId == 5 && ( currentSectionInfo.sectionId != 5 && currentSectionInfo.sectionParentId != 5 )  ) {
                return false;
            }

            //contemplar o pai contemplar os filhos                                              contemplar os irmos e no ser a seco planetas
            if( sectionInfo.sectionId == currentSectionInfo.sectionParentId || sectionInfo.sectionParentId == currentSectionInfo.sectionId || ( sectionInfo.sectionParentId == currentSectionInfo.sectionParentId && currentSectionInfo.sectionId != 5 ) || currentSectionInfo.sectionId == sectionInfo.sectionId )
                return true;

            return false;
        }
예제 #11
0
        /// <summary>
        /// inicializa a skin
        /// </summary>
        /// <param name="skin">o control que representa a skin</param>
        protected override void initializeSkin(Control skin)
        {
            currentSectionInfo = (SectionInfo)Context.Items["SectionInfo"];

            placeholder = (PlaceHolder)getControl(skin,"placeholder");

            if( currentSectionInfo.isVisible ) {
                repeater = (Repeater)getControl(skin,"menu");

                ArrayList subSections = getSubSections();

                if( subSections.Count > 0 ) {
                    placeholder.Visible = true;
                    repeater.DataSource = subSections;
                    repeater.DataBind();
                    return;
                }
            }
            placeholder.Visible = false;
        }
예제 #12
0
        private void Application_BeginRequest(Object source, EventArgs e)
        {
            //obter o HttpContext
            HttpContext Context = HttpContext.Current;

            // verificar o wiki
            string path = CheckWiki(Context.Request.Path);

            // obter os paths do ficheiro e da base
            string requestPath     = OrionGlobals.removePathInfo(path);
            string requestBasePath = OrionGlobals.getSectionPath(requestPath);

            Log.log("Request to: {0}", requestPath);

            try {
                //Descobrir qual a seco pedida e adiciona-la ao Items
                Log.log("Checking for {0} section... ", requestPath);
                SectionInfo sectionInfo = SectionUtility.getSectionInfoFromFullPath(requestPath);
                if (sectionInfo == null)
                {
                    Log.log("\tsectionInfo is null");
                    //normalmente acontece quando e named page
                    sectionInfo = SectionUtility.getSectionInfoFromBasePath(requestBasePath);
                }
                else
                {
                    Log.log("\tsectionInfo ok");
                }

                //quando  imagem cai aqui ou outra coisa qq que n seja seco
                if (sectionInfo == null)
                {
                    Log.log("\tsectionInfo is null");
                    return;
                }

                //adiciona aos items a Items
                Context.Items["SectionInfo"] = sectionInfo;
                Log.log("\tSectionInfo: {0}", sectionInfo.sectionName);

                //Descobrir qual a skin corrente
                MasterSkinInfo masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId(sectionInfo.sectionSkinId);
                if (masterSkinInfo == null)
                {
                    masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId(1);
                }

                //adiciona o nmero da skin (Caso a skin tenha vrios esquemas de cor)
                storeSkinNumber(masterSkinInfo.masterSkinCount);

                //adiciona aos items a Items
                Context.Items["MasterSkinInfo"] = masterSkinInfo;

                PageInfo pageInfo = getPageInfo(sectionInfo, masterSkinInfo, requestPath);
                if (pageInfo != null)
                {
                    Context.Items["PageInfo"] = pageInfo;
                    Chronos.Utils.Log.log("Request: " + requestPath);

                    Log.log("Rewriting Path to '{0}'...", OrionGlobals.UrlBasePage);
                    if (requestPath.IndexOf(".aspx") >= 0)
                    {
                        Log.log("\tDone!");
                        Context.RewritePath(OrionGlobals.UrlBasePage);
                    }
                    else
                    {
                        Log.log("\tNot rewrited! '{0}' isn't aspx", requestPath);
                    }
                }
                else
                {
                    Log.log("PageInfo is null for '{0}'", requestPath);
                }
            } catch (Exception exception) {
                try {
                    ExceptionLog.log(exception);
                } catch (Exception exp) {
                    HttpContext.Current.Cache[OrionGlobals.SessionId + "AlnitakException"] = new ExceptionInfo(exp);;
                }

                //mostrar a pgina de erro global
                HttpContext.Current.Server.Transfer(OrionGlobals.resolveBase(OrionGlobals.getConfigurationValue("pagePath", "globalError")));
            }
        }