Exemplo n.º 1
0
        public PageFilesPlaceholderData getPageFilesData(CmsPage page, int identifier, CmsLanguage langToRenderFor, bool createNewIfDoesNotExist)
        {
            if (page.ID < 0 || identifier < 0)
            {
                return(new PageFilesPlaceholderData());
            }

            string sql = "select tabularDisplayLinkMode, sortDirection, sortColumn, numFilesToShowPerPage, accessLevelToAddFiles, accessLevelToEditFiles ";

            sql += " from pagefiles c ";
            sql += " where c.pageid = " + page.ID.ToString() + " and c.identifier = " + identifier.ToString() + " and langShortCode like '" + dbEncode(langToRenderFor.shortCode) + "' and deleted is null;";
            DataSet ds = this.RunSelectQuery(sql);

            if (this.hasSingleRow(ds))
            {
                DataRow dr = ds.Tables[0].Rows[0];
                PageFilesPlaceholderData data = new PageFilesPlaceholderData();
                data.tabularDisplayLinkMode = (PageFilesPlaceholderData.TabularDisplayLinkMode)Enum.Parse(typeof(PageFilesPlaceholderData.TabularDisplayLinkMode), dr["tabularDisplayLinkMode"].ToString());
                data.sortDirection          = (PageFilesPlaceholderData.SortDirection)Enum.Parse(typeof(PageFilesPlaceholderData.SortDirection), dr["sortDirection"].ToString());
                data.sortColumn             = (PageFilesPlaceholderData.SortColumn)Enum.Parse(typeof(PageFilesPlaceholderData.SortColumn), dr["sortColumn"].ToString());
                data.accessLevelToAddFiles  = (BaseCmsPlaceholder.AccessLevel)Enum.Parse(typeof(BaseCmsPlaceholder.AccessLevel), dr["accessLevelToAddFiles"].ToString());
                data.accessLevelToEditFiles = (BaseCmsPlaceholder.AccessLevel)Enum.Parse(typeof(BaseCmsPlaceholder.AccessLevel), dr["accessLevelToEditFiles"].ToString());
                data.numFilesToShowPerPage  = Convert.ToInt32(dr["numFilesToShowPerPage"]);
                return(data);
            }
            else
            {
                if (createNewIfDoesNotExist)
                {
                    return(createNewPageFilesData(page, identifier, langToRenderFor));
                }
                else
                {
                    throw new Exception("getPageFilesData database error: placeholder does not exist");
                }
            }
            return(new PageFilesPlaceholderData());
        } // getFlashObject
Exemplo n.º 2
0
        } // getFlashObject

        public PageFilesPlaceholderData createNewPageFilesData(CmsPage page, int identifier, CmsLanguage lang)
        {
            PageFilesPlaceholderData data = new PageFilesPlaceholderData();

            string sql = "insert into pagefiles (pageid, identifier, langShortCode, tabularDisplayLinkMode, sortDirection, sortColumn, numFilesToShowPerPage, accessLevelToAddFiles, accessLevelToEditFiles) values (";

            sql  = sql + page.ID.ToString() + "," + identifier.ToString() + ", '" + dbEncode(lang.shortCode) + "', ";
            sql  = sql + "'" + Enum.GetName(typeof(PageFilesPlaceholderData.TabularDisplayLinkMode), data.tabularDisplayLinkMode) + "', ";
            sql  = sql + "'" + Enum.GetName(typeof(PageFilesPlaceholderData.SortDirection), data.sortDirection) + "', ";
            sql  = sql + "'" + Enum.GetName(typeof(PageFilesPlaceholderData.SortColumn), data.sortColumn) + "', ";
            sql  = sql + data.numFilesToShowPerPage.ToString() + ", ";
            sql  = sql + "'" + Enum.GetName(typeof(BaseCmsPlaceholder.AccessLevel), data.accessLevelToAddFiles) + "', ";
            sql  = sql + "'" + Enum.GetName(typeof(BaseCmsPlaceholder.AccessLevel), data.accessLevelToEditFiles) + "' ";
            sql += "); ";

            int newId = this.RunInsertQuery(sql);

            if (newId > -1)
            {
                page.setLastUpdatedDateTimeToNow();
            }

            return(data);
        } // createNewPageFilesData
Exemplo n.º 3
0
        } // createNewPageFilesData

        public bool saveUpdatedPageFilesData(CmsPage page, int identifier, CmsLanguage lang, PageFilesPlaceholderData data)
        {
            string sql = "update pagefiles set ";

            sql += " tabularDisplayLinkMode = '" + Enum.GetName(typeof(PageFilesPlaceholderData.TabularDisplayLinkMode), data.tabularDisplayLinkMode) + "', ";
            sql += " sortDirection = '" + Enum.GetName(typeof(PageFilesPlaceholderData.SortDirection), data.sortDirection) + "', ";
            sql += " sortColumn = '" + Enum.GetName(typeof(PageFilesPlaceholderData.SortColumn), data.sortColumn) + "', ";
            sql += " numFilesToShowPerPage = " + data.numFilesToShowPerPage.ToString() + ", ";
            sql += " accessLevelToAddFiles = '" + Enum.GetName(typeof(BaseCmsPlaceholder.AccessLevel), data.accessLevelToAddFiles) + "', ";
            sql += " accessLevelToEditFiles = '" + Enum.GetName(typeof(BaseCmsPlaceholder.AccessLevel), data.accessLevelToEditFiles) + "' ";
            sql += " where pageid = " + page.ID.ToString();
            sql += " AND langShortCode like '" + dbEncode(lang.shortCode) + "' ";
            sql += " AND identifier = " + identifier.ToString() + "; ";

            int numAffected = this.RunUpdateQuery(sql);

            if (numAffected > 0)
            {
                return(page.setLastUpdatedDateTimeToNow());
            }
            else
            {
                return(false);
            }
        } // saveUpdatedPageFilesData
Exemplo n.º 4
0
        public PageFilesItemData[] getPageFilesItemDatas(CmsPage page, int identifier, CmsLanguage pageLanguage, PageFilesPlaceholderData data)
        {
            string sql = "select PageFileItemId, PageId, Identifier, langShortCode, Filename, Title, Abstract, Author, FileSize, LastModified, CreatorUsername from pagefileitem ";

            sql += " where PageId = " + page.ID.ToString() + " and Identifier=" + identifier.ToString() + " and langShortCode like '" + pageLanguage.shortCode + "' and deleted is null ";

            if (data.sortColumn != PageFilesPlaceholderData.SortColumn.NoSorting)
            {
                switch (data.sortColumn)
                {
                case PageFilesPlaceholderData.SortColumn.Filename:
                    sql += " order by Filename ";
                    break;

                case PageFilesPlaceholderData.SortColumn.Title:
                    sql += " order by Title ";
                    break;

                case PageFilesPlaceholderData.SortColumn.FileSize:
                    sql += " order by FileSize ";
                    break;

                case PageFilesPlaceholderData.SortColumn.DateLastModified:
                    sql += " order by LastModified ";
                    break;

                default:
                    throw new ArgumentException("Invalid PageFilesData.SortColumn specified");
                    break;
                } // switch
                switch (data.sortDirection)
                {
                case PageFilesPlaceholderData.SortDirection.Ascending:
                    sql += " ASC ";
                    break;

                case PageFilesPlaceholderData.SortDirection.Descending:
                    sql += " DESC ";
                    break;

                default:
                    throw new ArgumentException("invalid PageFilesData.SortDirection specified");
                    break;
                } // switch
            }     // if sorting is enabled

            // -- run the query
            DataSet ds = this.RunSelectQuery(sql);

            if (this.hasRows(ds))
            {
                List <PageFilesItemData> ret = new List <PageFilesItemData>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    ret.Add(getItemDataFromDataRow(dr));
                } // foreach
                return(ret.ToArray());
            }     // if has data
            return(new PageFilesItemData[0]);
        }         // getPageFilesItemDatas