using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;

namespace testEditor
{
	/// <summary>
	/// Summary description for pageIndex.
	/// </summary>
	public class pageIndex : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lblIndex;
		protected testEditor.webheader ucHeader;

		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here

			ucHeader.pageTitle = "Learning Object Editing Toolkit";


			if (!Page.IsPostBack)
			{
				populateIndex();
			}
		}

		private void populateIndex()
		{
			string lopath = Request.PhysicalApplicationPath + "UserFiles\\";
			string[] loList = Directory.GetDirectories(lopath);
			
			if (loList.Length > 0)
			{
				lblIndex.Text = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" width=\"100%\">";

				for (int i=0; i < loList.Length; i++)
				{
					string loName = loList[i].Substring(loList[i].LastIndexOf("\\")+1);
					string lowerNm = loName.ToLower();
					
					//to add more words to be ignored later
					if ((!lowerNm.Equals("flash")) && (!lowerNm.Equals("image")) && (!lowerNm.Equals("file")))
					{
						lblIndex.Text += "<tr><td class=\"tdnoborder\"><a href=\"LOedit.aspx?title=" + loName + "&action=view\">" + loName + "</a></td></tr>";
					}

				}
				lblIndex.Text += "</table>";
			}
		}



		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}
