Represents a combined list and collection of Form Elements.
Inheritance: Dictionary
コード例 #1
0
 protected override FormElementCollection AddFormElements()
 {
     FormElementCollection fec = new FormElementCollection();
     fec.Add(new TextFormElement("Title", "Title", "The title of the section"));
     fec.Add(new TextAreaFormElement("Text", "Your Content", null, 5));
     return fec;
 }
コード例 #2
0
        public void Login(string username, string password, bool forceLogin = false)
        {
            string culture = Properties.Resources.Culture.ToString();
            long day = DateTime.Now.Ticks / TimeSpan.TicksPerDay;
            
            if (day > _lastLogin || culture != _lastCulture)
            {
                forceLogin = true;
            }

            if (!_isLoggedIn || forceLogin)
            {
                Log.Info("Login to Amazon " + Properties.Resources.AmazonRootUrl);
                _isLoggedIn = false;
                _lastCulture = culture;
                var loginDoc = Load(Properties.Resources.AmazonLoginUrl);
                var formElements = new FormElementCollection(loginDoc);
                string postUrl = loginDoc.GetElementbyId("ap_signin_form").Attributes["action"].Value;
                formElements["email"] = username;
                formElements["password"] = password;
                formElements["create"] = "0";
                Thread.Sleep(1500);
                string login = GetWebData(postUrl, formElements.AssemblePostPayload(), cc, null, null, false, false, userAgent);
                // TODO add login check
                _isLoggedIn = true;
                _lastLogin = day;
                Log.Info("Login complete");
            }
        }
コード例 #3
0
ファイル: PlainTextBox.cs プロジェクト: chartek/graffiticms
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection fec = new FormElementCollection();
            fec.Add(new TextFormElement("Title", "Description", "This field will not be displayed on your site."));
            fec.Add(
                new TextAreaFormElement("Text", "Content",
                                        "Any content you enter in this field will be displayed on your site's sidebar. (HTML is allowed)",
                                        10));

            return fec;
        }
コード例 #4
0
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection fec = new FormElementCollection();
            fec.Add(AddTitleElement());

            ListFormElement lfe = new ListFormElement("numberOfPosts", "Number of Posts", "The number of most recent posts to list");
            lfe.Add(new ListItemFormElement("3", "3"));
            lfe.Add(new ListItemFormElement("5", "5", true));
            lfe.Add(new ListItemFormElement("10", "10"));
            fec.Add(lfe);

            ListFormElement lfeCats = new ListFormElement("categoryId", "Filter by Category", "Do you want to filter by a category?");
            lfeCats.Add(new ListItemFormElement("All Categories", "-1", CategoryId == -1));
            foreach (Category c in new CategoryController().GetTopLevelCachedCategories())
            {
                lfeCats.Add(new ListItemFormElement(c.Name, c.Id.ToString(), c.Id == CategoryId));
                if (c.HasChildren)
                {
                    foreach (Category child in c.Children)
                    {
                        lfeCats.Add(new ListItemFormElement("--" + child.Name, child.Id.ToString(), child.Id == CategoryId));
                    }
                }
            }

            fec.Add(lfeCats);

            fec.Add(new CheckFormElement("showExcerpt", "Show Excerpt", "Do you want to display a short excerpt", false));

            return fec;
        }
コード例 #5
0
ファイル: Widget.cs プロジェクト: chartek/graffiticms
 /// <summary>
 /// This method can be overriden to control what elements are rendered on the edit screen.
 /// </summary>
 protected override FormElementCollection AddFormElements()
 {
     FormElementCollection fec = new FormElementCollection();
     fec.Add(AddTitleElement());
     return fec;
 }
コード例 #6
0
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection fec = new FormElementCollection();
            fec.Add(new CheckFormElement("enableCommentRSS", "Enable Comment RSS Feed", "Generates a RSS feed that contains feedback received for all posts. Can be found at /feed/comments/", false));
            fec.Add(new CheckFormElement("enablePings", "Enable Pings", "Enables automatic notification to services that new content is available.", false));
            fec.Add(new CheckFormElement("enableTrackbacks", "Enable Trackbacks", "If enabled, Graffiti will automatically send trackbacks and pingbacks, and accept them for posts that have new comments enabled.", false));
            fec.Add(new CheckFormElement("enableGeoRSS", "Enable GeoRSS", "If enabled a custom field will be created to enter the geographic location of each post. If one is not entered, the default GeoRSS location (below) will be used.", false));
            fec.Add(new TextAreaFormElement("pingUrls", "Ping Service Urls", "Enter the URLs of all the services Graffiti should ping when you add or edit a post. Put each URL on a new line.", 3));
            fec.Add(new TextFormElement("geoRSSLocation", "Default GeoRSS Location (lattitude longitude)", "If a location is not entered in the custom GeoRSS field when writing a post, this value will be used in the GeoRSS element in RSS feeds. Enter a lattitude and longitude in the format: 45.256 -71.92."));

            return fec;
        }
コード例 #7
0
 protected override FormElementCollection AddFormElements()
 {
     var fe = new FormElementCollection
                  {
                      new TextFormElement("Title", "Widget Title", string.Empty),
                      new TextFormElement("MinHitCount", "Minimum number of hits before display",
                                          "(Suggest: 30; Defaults to 30 if left blank; Use 0 for all links)"),
                      new TextFormElement("Post404Id", "Post ID of the 404 Page to Display",
                                          "Edit your 404, and check the end of the URL for <b>posts/write/?id=100</b> (100 is the post id)"),
                      new CheckFormElement("ClearStatistics",
                                           "Clear 404 Statistics on Widget Update",
                                           "Checked: Clear all 404Stats on Widget Update<br /> Unchecked: Keep Current Stats",false)
                  };
     return fe;
 }
コード例 #8
0
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection fec = new FormElementCollection();
            fec.Add(new TextFormElement("title", "Name", "Give your list of items a name"));
            fec.Add(new TextFormElement("amazonid", "Amazon Id", "Please enter your Amazon Seller Id"));
            fec.Add(new TextAreaFormElement("amazonLinkItems", "Items", "Copy a link from amazon on each line", 5));
            ListFormElement lfe = new ListFormElement("show", "Items to Show", "How many items do you want to show at a time?");
            lfe.Add(new ListItemFormElement("All", "-1", true));
            lfe.Add(new ListItemFormElement("All (random)", "0"));
            lfe.Add(new ListItemFormElement("1 random item", "1"));
            lfe.Add(new ListItemFormElement("3 random items", "3"));
            lfe.Add(new ListItemFormElement("5 random items", "5"));
            fec.Add(lfe);

            return fec;
        }
コード例 #9
0
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection fec = new FormElementCollection();
            fec.Add(AddTitleElement());

            fec.Add(new TextFormElement("FeedUri", "Feed", "The Url of the feed you wish to display"));
            ListFormElement lfe = new ListFormElement("itemsToDisplay", "Number of Posts", "(how many posts do you want to display?)");
            lfe.Add(new ListItemFormElement("1","1"));
            lfe.Add(new ListItemFormElement("3", "3", true));
            lfe.Add(new ListItemFormElement("5", "5"));
            lfe.Add(new ListItemFormElement("7", "7"));
            fec.Add(lfe);

            return fec;
        }
コード例 #10
0
        /// <summary>
        /// Adds the form elements.
        /// </summary>
        /// <returns></returns>
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection form = new FormElementCollection();

            ListFormElement itemsToDisplay = new ListFormElement("itemstodisplay", "Number of Photos", "(how many photos do you want to display?)");
            itemsToDisplay.Add(new ListItemFormElement("3", "3"));
            itemsToDisplay.Add(new ListItemFormElement("6", "6", true));
            itemsToDisplay.Add(new ListItemFormElement("9", "9"));

            form.Add(AddTitleElement());
            form.Add(new TextFormElement("nickname", "NickName", "(your SmugMug nickname)"));
            form.Add(itemsToDisplay);

            return form;
        }
コード例 #11
0
 /// <summary>
 /// Saves the form elements collection by parsing the HTML document
 /// </summary>
 private void SaveHtmlDocument(HtmlDocument document)
 {
     _htmlDoc     = document;
     FormElements = new FormElementCollection(_htmlDoc);
 }
コード例 #12
0
        public void Login(string username, string password, bool forceLogin = false)
        {
            string culture = Resources.Culture.ToString();
            long   day     = DateTime.Now.Ticks / TimeSpan.TicksPerDay;

            if (day > _lastLogin || culture != _lastCulture)
            {
                forceLogin = true;
            }

            if (!_isLoggedIn || forceLogin)
            {
                Log.Info("Login to Amazon " + Resources.AmazonRootUrl);
                _isLoggedIn  = false;
                _lastCulture = culture;

                // Load the main page inside a WebBrowser control to retrieve all dynamically created cookies (session ids by JS)
                _cc = GetCookies(Resources.AmazonLoginUrl);

                var loginDoc     = Load(Resources.AmazonLoginUrl);
                var formElements = new FormElementCollection(loginDoc);
                // There can appear different login pages, using other names for form / controls
                var loginForm = loginDoc.GetElementbyId("ap_signin_form") ?? loginDoc.DocumentNode.SelectNodes("//*[@name='signIn']").FirstOrDefault();
                if (loginForm == null)
                {
                    Log.Error("AmazonBrowserSession: Failed to get login form!");
                    return;
                }
                // Copy over all input elements
                foreach (var inputElement in loginForm.SelectNodes("//input"))
                {
                    var name  = inputElement.Attributes["name"];
                    var value = inputElement.Attributes["value"];
                    if (name != null && value != null)
                    {
                        formElements[name.Value] = value.Value;
                    }
                }
                if (formElements.ContainsKey("email"))
                {
                    formElements["email"]    = username;
                    formElements["password"] = password;
                    formElements["create"]   = "0";
                }
                else
                {
                    // 2nd variant of login form
                    formElements["ap_email"]    = username;
                    formElements["ap_password"] = password;
                }

                NameValueCollection headers = new NameValueCollection();
                headers["Accept"]          = "text/html, application/xhtml+xml, image/jxr, */*";
                headers["Accept-Language"] = "de-DE";
                headers["Cache-Control"]   = "no-cache";
                headers["User-Agent"]      = UserAgent;

                string postUrl = loginForm.Attributes["action"].Value;
                //Thread.Sleep(500);
                string login = GetWebData(postUrl, formElements.AssemblePostPayload(), _cc, Resources.AmazonLoginUrl, null, false, false, UserAgent, null, headers);

                var reCustomer    = new Regex("\"customerID\":\"([^\"]*)\"");
                var customerMatch = reCustomer.Match(login);
                if (customerMatch.Groups.Count > 1)
                {
                    _customerId = customerMatch.Groups[1].Value;
                    _isLoggedIn = true;
                    _lastLogin  = day;
                }
                Log.Info("Login complete");
            }
        }
コード例 #13
0
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection fec = new FormElementCollection();
            fec.Add(AddTitleElement());
            ListFormElement lfe = new ListFormElement("numberOFcomments", "Number of Comments", "The number of most recent comments to list");
            lfe.Add(new ListItemFormElement("3", "3"));
            lfe.Add(new ListItemFormElement("5", "5", true));
            lfe.Add(new ListItemFormElement("10", "10"));
            fec.Add(lfe);

            return fec;
        }
コード例 #14
0
ファイル: TwitterWidget.cs プロジェクト: chartek/graffiticms
 protected override FormElementCollection AddFormElements()
 {
     FormElementCollection fec = new FormElementCollection();
     fec.Add(AddTitleElement());
     fec.Add(new TextFormElement("username", "UserName", "(your twitter username)"));
     ListFormElement lfe = new ListFormElement("itemsToDisplay", "Number of Tweets", "(how many tweets do you want to display?)");
     lfe.Add(new ListItemFormElement("1", "1"));
     lfe.Add(new ListItemFormElement("2", "2"));
     lfe.Add(new ListItemFormElement("3", "3", true));
     lfe.Add(new ListItemFormElement("4", "4"));
     lfe.Add(new ListItemFormElement("5", "5"));
     fec.Add(lfe);
     fec.Add(new CheckFormElement("displayFollowMe", "Display 'Follow Me on Twitter' link", null, true));
     return fec;
 }
コード例 #15
0
 //We need to override this to present the user with a useful form. By default
 //this method would have rendered the title and data element. The data would have been a textarea
 //which would have worked, but would have been overkill.
 protected override FormElementCollection AddFormElements()
 {
     FormElementCollection fec = new FormElementCollection();
     fec.Add(new TextFormElement("tagname", "Gamer Tag", "Please enter your XBox 360 Gamer Tag"));
     return fec;
 }
コード例 #16
0
        public void Login(string username, string password, bool forceLogin = false)
        {
            string culture = Resources.Culture.ToString();
            long day = DateTime.Now.Ticks / TimeSpan.TicksPerDay;

            if (day > _lastLogin || culture != _lastCulture)
            {
                forceLogin = true;
            }

            if (!_isLoggedIn || forceLogin)
            {
                Log.Info("Login to Amazon " + Resources.AmazonRootUrl);
                _isLoggedIn = false;
                _lastCulture = culture;

                // Load the main page inside a WebBrowser control to retrieve all dynamically created cookies (session ids by JS)
                _cc = GetCookies(Resources.AmazonLoginUrl);

                var loginDoc = Load(Resources.AmazonLoginUrl);
                var formElements = new FormElementCollection(loginDoc);
                // There can appear different login pages, using other names for form / controls
                var loginForm = loginDoc.GetElementbyId("ap_signin_form") ?? loginDoc.DocumentNode.SelectNodes("//*[@name='signIn']").FirstOrDefault();
                if (loginForm == null)
                {
                    Log.Error("AmazonBrowserSession: Failed to get login form!");
                    return;
                }
                // Copy over all input elements
                foreach (var inputElement in loginForm.SelectNodes("//input"))
                {
                    var name = inputElement.Attributes["name"];
                    var value = inputElement.Attributes["value"];
                    if (name != null && value != null)
                        formElements[name.Value] = value.Value;
                }
                if (formElements.ContainsKey("email"))
                {
                    formElements["email"] = username;
                    formElements["password"] = password;
                    formElements["create"] = "0";
                }
                else
                {
                    // 2nd variant of login form
                    formElements["ap_email"] = username;
                    formElements["ap_password"] = password;
                }

                NameValueCollection headers = new NameValueCollection();
                headers["Accept"] = "text/html, application/xhtml+xml, image/jxr, */*";
                headers["Accept-Language"] = "de-DE";
                headers["Cache-Control"] = "no-cache";
                headers["User-Agent"] = UserAgent;

                string postUrl = loginForm.Attributes["action"].Value;
                //Thread.Sleep(500);
                string login = GetWebData(postUrl, formElements.AssemblePostPayload(), _cc, Resources.AmazonLoginUrl, null, false, false, UserAgent, null, headers);

                var reCustomer = new Regex("\"customerID\":\"([^\"]*)\"");
                var customerMatch = reCustomer.Match(login);
                if (customerMatch.Groups.Count > 1)
                {
                    _customerId = customerMatch.Groups[1].Value;
                    _isLoggedIn = true;
                    _lastLogin = day;
                }
                Log.Info("Login complete");
            }
        }
コード例 #17
0
ファイル: CategoryLink.cs プロジェクト: chartek/graffiticms
 protected override FormElementCollection AddFormElements()
 {
     FormElementCollection fec = new FormElementCollection();
     fec.Add(AddTitleElement());
     fec.Add(new TextAreaFormElement("LinkData", "Links", "Add one link per line using the format Text | Link", 10));
     return fec;
 }
コード例 #18
0
ファイル: SearchWidget.cs プロジェクト: chartek/graffiticms
 protected override FormElementCollection AddFormElements()
 {
     FormElementCollection fec = new FormElementCollection();
     fec.Add(new TextFormElement("title", "Search Text", "Text for the search box title"));
     return fec;
 }
コード例 #19
0
 /// <summary>
 /// Saves the form elements collection by parsing the HTML document
 /// </summary>
 private void SaveHtmlDocument(HtmlDocument document)
 {
     _htmlDoc = document;
     FormElements = new FormElementCollection(_htmlDoc);
 }
コード例 #20
0
 protected override FormElementCollection AddFormElements()
 {
     FormElementCollection fec = new FormElementCollection();
     fec.Add(AddTitleElement());
     fec.Add(new TextFormElement("username", "UserName", "(your Del.icio.us username)"));
     ListFormElement lfe = new ListFormElement("itemsToDisplay", "Number of Links", "(how many links do you want to display?)");
     lfe.Add(new ListItemFormElement("1","1"));
     lfe.Add(new ListItemFormElement("3", "3"));
     lfe.Add(new ListItemFormElement("5", "5", true));
     lfe.Add(new ListItemFormElement("10", "10"));
     fec.Add(lfe);
     return fec;
 }
コード例 #21
0
ファイル: TagCloudWidget.cs プロジェクト: chartek/graffiticms
        protected override FormElementCollection AddFormElements()
        {
            FormElementCollection fec = new FormElementCollection();
            fec.Add(AddTitleElement());
            ListFormElement lfe = new ListFormElement("minNumberOfPosts", "Minimum Number of Posts", "The minimum number of posts a tag must be found in.");
            lfe.Add(new ListItemFormElement("No Minimum", "-1"));
            lfe.Add(new ListItemFormElement("1", "1", true));
            lfe.Add(new ListItemFormElement("2", "2"));
            lfe.Add(new ListItemFormElement("3", "3"));
            lfe.Add(new ListItemFormElement("5", "5"));
            lfe.Add(new ListItemFormElement("10", "10"));
            fec.Add(lfe);

            ListFormElement lfeMax = new ListFormElement("maxNumberOfTags", "Maximum number of Tags", "The maximum number of tags to display. If selected only the most popular tags will be returned.");
            lfeMax.Add(new ListItemFormElement("No Maximum", "-1"));
            lfeMax.Add(new ListItemFormElement("25", "25", true));
            lfeMax.Add(new ListItemFormElement("50", "50"));
            lfeMax.Add(new ListItemFormElement("100", "100"));
            fec.Add(lfeMax);

            return fec;
        }