예제 #1
0
        public void RenderViewSummary(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            string ControlId = "Contacts_" + page.ID.ToString() + "_" + identifier.ToString() + langToRenderFor.shortCode;

            ContactsDb             db   = new ContactsDb();
            ContactPlaceholderData data = db.getContactPlaceholderData(page, identifier, true);

            // -- before getContacts, process the form
            string addFormHtml = "";

            if (page.currentUserCanWrite)
            {
                addFormHtml = getAddEditContactForm(data, new ContactData(), page, identifier, langToRenderFor);
            }

            int[]         categoryIdsToDisplay = getCategoryIdsToDisplay(data);
            string[]      orgsToDisplay        = getOrgNamesToDisplay();
            ContactData[] contacts             = ContactData.getContacts(data, categoryIdsToDisplay, orgsToDisplay);

            StringBuilder html = new StringBuilder();

            html.Append("<table width=\"100%\"><tr>");
            html.Append("<td valign=\"top\">");
            html.Append(getSummaryDisplay(data, contacts, langToRenderFor, page));
            html.Append("</td>");
            html.Append("<td valign=\"top\">");
            if (contacts.Length > 1)
            {
                html.Append(getSummaryDisplayFilterForm(data, contacts, page, identifier));
            }
            html.Append("</td>");
            html.Append("</tr>");
            html.Append("</table>");
            if (page.currentUserCanWrite)
            {
                html.Append("<p>" + addFormHtml + "</p>");
            }

            writer.Write(html.ToString());
        } // RenderViewSummary
예제 #2
0
        private void RenderViewIndividual(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            ContactsDb             db   = new ContactsDb();
            ContactPlaceholderData data = db.getContactPlaceholderData(page, identifier, true);

            int contactId = PageUtils.getFromForm(CurrentContactIdFormName, -1);

            ContactData contactToView = ContactData.getContact(contactId);

            bool canEdit = page.currentUserCanWrite;

            string backUrl = page.Url;

            writer.Write("<p><a href=\"" + backUrl + "\">&#171; back to contact listing</a></p>");
            // -- begin output
            if (canEdit)
            {
                writer.Write(getAddEditContactForm(data, contactToView, page, identifier, langToRenderFor));
            }
            else
            {
                StringBuilder html = new StringBuilder();
                html.Append("<table border=\"0\">");

                string dividerLineHtml = getDividerLineHtml(2);

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td colspan=\"2\" align=\"center\"><h2>" + StringUtils.JoinNonBlanks(" ", new string[] { contactToView.firstName, contactToView.lastName }) + "</h2></td>");

                html.Append(dividerLineHtml);

                string colspan = "1";

                html.Append("<td>Categories:</td>");
                ContactDataCategory[] allCategories = ContactDataCategory.getAllContactCategories();
                html.Append("<td colspan=\"" + colspan + "\">");
                int cbid = 0;
                foreach (ContactDataCategory cat in allCategories)
                {
                    bool   check = (contactToView.contactCategoryIds.IndexOf(cat.CategoryId) > -1);
                    string cb    = PageUtils.getCheckboxHtml(cat.Title, "category", "category" + cbid.ToString(), cat.CategoryId.ToString(), check);
                    html.Append(cb + "<br />");
                    cbid++;
                } // foreach
                html.Append("</td>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Title:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.title + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Organization:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.organizationName + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Address 1:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.address1 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Address 2:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.address2 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>City:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.city + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Province/State:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.provinceState + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Postal/Zip Code:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.postalZipCode + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Phone Number 1:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.phoneNumber1 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Phone Number 2:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.phoneNumber2 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Fax Number:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.faxNumber + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Mobile Number:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.mobileNumber + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                string emailDisplay = "";
                if (contactToView.emailAddress.Trim() != "")
                {
                    emailDisplay = "<a href=\"mailto:" + contactToView.SpamEncodedEmailAddress + "\">" + contactToView.SpamEncodedEmailAddress + "</a>";
                }

                html.Append("<tr>");
                html.Append("<td>Email Address:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + emailDisplay + "</td>");
                html.Append("</tr>");

                html.Append("</table>");

                writer.Write(html.ToString());
            }
        }
예제 #3
0
        public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            string ControlId = "Contacts_" + page.ID.ToString() + "_" + identifier.ToString() + langToRenderFor.shortCode;

            ContactsDb             db   = new ContactsDb();
            ContactPlaceholderData data = new ContactPlaceholderData();

            data = db.getContactPlaceholderData(page, identifier, true);

            string action = PageUtils.getFromForm(ControlId + "_action", "");

            if (String.Compare(action, "saveNewValues", true) == 0)
            {
                data.numColumnsToShow        = PageUtils.getFromForm(ControlId + "numColumnsToShow", data.numColumnsToShow);
                data.forceFilterToCategoryId = PageUtils.getFromForm(ControlId + "forceFilterToCategoryId", data.forceFilterToCategoryId);
                data.nameDisplayMode         = (ContactPlaceholderData.ContactNameDisplayMode)PageUtils.getFromForm(ControlId + "nameDisplayMode", typeof(ContactPlaceholderData.ContactNameDisplayMode), data.nameDisplayMode);

                data.allowFilterByCategory = PageUtils.getFromForm(ControlId + "allowFilterByCategory", false);
                data.allowFilterByCompany  = PageUtils.getFromForm(ControlId + "allowFilterByCompany", false);

                data.accessLevelToAddContacts  = (BaseCmsPlaceholder.AccessLevel)PageUtils.getFromForm(ControlId + "accessLevelToAddContacts", typeof(BaseCmsPlaceholder.AccessLevel), data.accessLevelToAddContacts);
                data.accessLevelToEditContacts = (BaseCmsPlaceholder.AccessLevel)PageUtils.getFromForm(ControlId + "accessLevelToEditContacts", typeof(BaseCmsPlaceholder.AccessLevel), data.accessLevelToEditContacts);
                db.saveUpdatedContactPlaceholderData(page, identifier, data);
            }


            StringBuilder html = new StringBuilder();

            html.Append("Contacts Display Configuration:");


            html.Append("<table>");

            html.Append("<tr>");
            html.Append("<td>Force Category filter to display: </td>");
            html.Append("<td>");
            ContactDataCategory[] allCats = ContactDataCategory.getAllContactCategories();
            NameValueCollection   options = new NameValueCollection();

            options.Add("-1", "do not force category to filter");
            foreach (ContactDataCategory cat in allCats)
            {
                options.Add(cat.CategoryId.ToString(), cat.Title);
            } // foreach
            html.Append(PageUtils.getDropDownHtml(ControlId + "forceFilterToCategoryId", ControlId + "forceFilterToCategoryId", options, data.forceFilterToCategoryId.ToString()));
            html.Append("</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Allow filter by: </td>");
            html.Append("<td>");
            html.Append(PageUtils.getCheckboxHtml("Category", ControlId + "allowFilterByCategory", ControlId + "allowFilterByCategory", true.ToString(), data.allowFilterByCompany));
            html.Append("<br>");
            html.Append(PageUtils.getCheckboxHtml("Company Name", ControlId + "allowFilterByCompany", ControlId + "allowFilterByCompany", true.ToString(), data.allowFilterByCompany));
            html.Append("</td>");
            html.Append("</tr>");


            html.Append("<tr>");
            html.Append("<td>Number of columns: </td>");
            html.Append("<td>");
            html.Append(PageUtils.getInputTextHtml(ControlId + "numColumnsToShow", ControlId + "numColumnsToShow", data.numColumnsToShow.ToString(), 3, 5));
            html.Append("</td>");
            html.Append("</tr>");

            html.Append("<tr>");
            html.Append("<td>Name display format: </td>");
            html.Append("<td>");
            html.Append(PageUtils.getDropDownHtml(ControlId + "nameDisplayMode", ControlId + "nameDisplayMode", Enum.GetNames(typeof(ContactPlaceholderData.ContactNameDisplayMode)), Enum.GetName(typeof(ContactPlaceholderData.ContactNameDisplayMode), data.nameDisplayMode)));
            html.Append("</td>");
            html.Append("</tr>");

            // -- deprecated items
            PageUtils.getHiddenInputHtml(ControlId + "accessLevelToAddContacts", Enum.GetName(typeof(BaseCmsPlaceholder.AccessLevel), BaseCmsPlaceholder.AccessLevel.CmsAuthor));
            PageUtils.getHiddenInputHtml(ControlId + "accessLevelToEditContacts", Enum.GetName(typeof(BaseCmsPlaceholder.AccessLevel), BaseCmsPlaceholder.AccessLevel.CmsAuthor));

            html.Append("</table>");

            html.Append(PageUtils.getHiddenInputHtml(ControlId + "_action", "saveNewValues"));

            writer.Write(html.ToString());
        } // RenderEditSummary