コード例 #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            currentNode = (Node)Context.Items["currentNode"];
            if (currentNode == null)
            {
                throw new DuryTools.ErrorHandler("currentNode not found!");
            }

            if (SFGlobal.IsUserCMS())
            {
                publicSuffix = "";
            }


            DataSet ds = dal.execDataSet("SELECT showTemplate,title,body FROM SimpleArticles " + publicSuffix + " WHERE nodeID = " + currentNode.Id);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                Page.ShowTemplate = (dr["showTemplate"] != System.DBNull.Value) ? (bool)dr["showTemplate"] : false;
                Page.PageTitle    = dr["title"].ToString();
                body.Text         = dr["body"].ToString();
            }
            else
            {
                body.Text = "content not found in database.";
            }
        }
コード例 #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // load the article control
            Node currentNode = (Node)Context.Items["currentNode"];

            if (SFGlobal.IsUserCMS())
            {
                publicSuffix = "";
            }
            BaseArticle article;

            //SFGlobal.SetLangSession();

            if (Session["lang"] != null)
            {
                lang = Session["lang"].ToString();                //Context.Items["lang"];
            }
            else
            {
                lang = SFGlobal.DefaultLanguage;
            }

            string  sql = string.Format("SELECT b.title, b.summary, b.body, b.dateModified, b.templateID ,b.summary, b.keywords FROM " + this.articleBodyTable + this.publicSuffix + " b INNER JOIN " + this.articleContainerTable + this.publicSuffix + " a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (b.lang = '{1}')", currentNode.Id.ToString(), lang);
            DataSet ds  = SFGlobal.DAL.execDataSet(sql);
            string  title;

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow             dr = ds.Tables[0].Rows[0];
                ArticleTemplateInfo at = SFGlobal.GetArticleTemplate((int)dr["templateID"]);
                article = (BaseArticle)Page.LoadControl(SFGlobal.NodeTemplateLocation + "\\" + at.Src + ".ascx");
                article.ArticleTitle = dr["title"].ToString();
                article.ArticleBody  = dr["body"].ToString();
                article.LastModified = (dr["dateModified"] != DBNull.Value) ? (DateTime)dr["dateModified"] : System.DateTime.Now;
                article.Keywords     = dr["keywords"].ToString();
                article.Summary      = dr["summary"].ToString();
                title = dr["title"].ToString();
            }
            else
            {
                ArticleTemplateInfo at = SFGlobal.GetArticleTemplate(1);
                article = (BaseArticle)Page.LoadControl(SFGlobal.NodeTemplateLocation + "\\" + at.Src + ".ascx");
                article.ArticleTitle = "problem!";
                article.ArticleBody  = "article doesn't exist for this node.";
                title = "BIG PROBLEM!";
            }
            articleHolder.Controls.Add(article);

            /*
             * Node p = currentNode.parent;
             * if (p.parent != null)
             *      while(p.parent != null)
             *      {
             *              title = ": " + p.getName(SFGlobal.DefaultLanguage) + title;
             *              p = p.parent;
             *      }
             */
        }
コード例 #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Node currentNode = (Node)Context.Items["currentNode"];

            if (!SFGlobal.IsUserCMS())
            {
                publicSuffix = "_public";
            }
            string linkLocation = (string)dal.execScalar("SELECT linkURL FROM Links" + publicSuffix + " WHERE nodeID = " + currentNode.Id);

            if (linkLocation != null)
            {
                Response.Redirect(linkLocation);
            }
            else
            {
                //Response.Write("Uh oh! problem with links");
                //throw new ErrorHandler("Problem loading node (type=links). Most likely caused by unpublished Link");
            }
        }
コード例 #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            currentNode = (Node)Context.Items["currentNode"];
            lang        = SFGlobal.CurrentCulture.Name;
            rank        = SFGlobal.IsNumeric(Page.CustomQueryString["page"]) ? int.Parse(Page.CustomQueryString["page"]) : 1;
            string sql     = "";
            string columns = "TOP 1 templateID, title, summary, keywords, body, dateModified ";

            if (SFGlobal.IsUserCMS())
            {
                sql = "SELECT " + columns + " FROM " + dbTable + " WHERE nodeID={0} AND lang='{1}' AND rank = {2} ORDER BY preview DESC, publish DESC, dateModified DESC, version DESC";
            }
            else
            {
                dbTable += SFGlobal.PublicSuffix;
                sql      = "SELECT " + columns + " FROM " + dbTable + " WHERE nodeID = {0}AND lang = '{1}' and rank = {2}";
            }
            sql = String.Format(sql, currentNode.Id, lang, rank);
            DataRow dr = SFGlobal.DAL.execDataRow(sql);

            if (dr != null)
            {
                article = loadArticle((int)dr["templateID"]);
                article.ArticleTitle = dr["title"].ToString();
                article.ArticleBody  = dr["body"].ToString();
                article.Keywords     = dr["keywords"].ToString();
                article.Summary      = dr["summary"].ToString();
                article.LastModified = (DateTime)dr["dateModified"];
            }
            else
            {
                article              = loadArticle(1);
                article.ArticleBody  = String.Format("<h2>Article not Found.</h2><p>There is no Article for this node yet. Publish a new article</p>");
                article.ArticleTitle = "Error!";
                article.Keywords     = "ERROR";
                article.Summary      = "ERROR";
                article.LastModified = DateTime.Now;
                //throw new DuryTools.ErrorHandler("Problem loading article. Possible causes: haven't published yet, no article for this language");
            }
            holder.Controls.Add(article);
        }
コード例 #5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            currentNode = (Node)Context.Items["currentNode"];             // get our current node from the context stack
            string sql = "";
            object id  = null;


            // lets give the CMS user special treatment
            if (SFGlobal.IsUserCMS())
            {
                publicSuffix = "";
                // see if there is a preview assigned to this node
                //sql = "SELECT b.versionNumber, b.pageNumber, b.title, b.summary, b.body, b.dateModified, b.templateID, b.keywords FROM  sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = " + currentNode.Id + ") AND (a.lang = '" + lang + "') AND (b.preview = 1)";
                id = SFGlobal.DAL.execScalar(String.Format("SELECT b.id FROM sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (b.preview = 1) AND (a.lang = '{1}')", currentNode.Id, this.lang));
                Response.Write("1=" + id);


                // otherwise show the article set for publish
                if (id == null)
                {
                    id = SFGlobal.DAL.execScalar(String.Format("SELECT b.id FROM sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (a.lang = '{1}') AND (b.publish = 1)", currentNode.Id, this.lang));
                    Response.Write("2=" + id);
                }


                // otherwise show the greatest version number
                if (id == null)
                {
                    id = SFGlobal.DAL.execScalar(String.Format("SELECT TOP 1 b.id FROM sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (a.lang = '{1}') ORDER BY b.versionNumber DESC", currentNode.Id, this.lang));
                    Response.Write("3=" + id);
                }
            }
            else
            {
                //id = (int)SFGlobal.DAL.execScalar(String.Format("SELECT TOP 1 b.id FROM sf_ArticlePages" + this.publicSuffix + " b INNER JOIN sf_Articles" + this.publicSuffix + " a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (a.lang = '{1}')", currentNode.Id, this.lang));
            }

            if (id == null)
            {
                throw new DuryTools.ErrorHandler("can't find article for this node! help!");
            }
            else
            {
                DataSet ds = SFGlobal.DAL.execDataSet("SELECT * FROM sf_ArticlePages" + this.publicSuffix + " WHERE id = " + id.ToString());
                if (ds.Tables[0].Rows.Count >= 1)
                {
                    DataRow             dr = ds.Tables[0].Rows[0];
                    ArticleTemplateInfo at = SFGlobal.GetArticleTemplate((int)dr["templateID"]);
                    article = (BaseArticle)Page.LoadControl(SFGlobal.NodeTemplateLocation + "\\" + at.Src + ".ascx");
                    article.ArticleTitle = dr["title"].ToString();
                    article.ArticleBody  = dr["body"].ToString();
                    article.LastModified = (dr["dateModified"] != DBNull.Value) ? (DateTime)dr["dateModified"] : System.DateTime.Now;
                    article.Keywords     = dr["keywords"].ToString();
                    article.Summary      = dr["summary"].ToString();
                    //title = dr["title"].ToString();
                    holder.Controls.Add(article);

                    Response.Write(Page.CustomQueryString["page"]);
                }
                else
                {
                    throw new DuryTools.ErrorHandler("Can't load article id: " + id.ToString());
                }
            }

            //DataSet ds = SFGlobal.DAL.execDataSet(sql);
            //Response.Write(ds.Tables[0].Rows.Count);
        }