Esempio n. 1
0
        public void AddRevision(WikiRevision rev)
        {
            tl curr = null;

            if (root.children.Count == 0)
            {
                List <tl> l = new List <tl>();
                tl        t = new tl();
                t.type     = 0;
                t.count    = 1;
                t.rand     = Tools.FullRandom();
                t.revision = rev;
                l.Add(t);
                RevisionGroup(l);
            }
            else
            {
                curr = root.children[root.children.Count - 1];
                if (!curr.user.Equals(rev.user))
                {
                    curr      = new tl();
                    curr.type = 0;
                }
                tl t = new tl();
                t.type     = 1;
                t.revision = rev;
                t.rand     = Tools.FullRandom();
                curr.children.Add(t);
                curr.count++;
            }
        }
Esempio n. 2
0
 public void AddRevision(WikiRevision rev)
 {
     list.Add(rev);
     curr         = rev;
     last_flagged = rev.flagged;
     if (!is_flagged && rev.flagged)
     {
         is_flagged = true;
     }
 }
Esempio n. 3
0
        public void UpdateRwStatus()
        {
            stable = null;
            for (int a = 0; a < list.Count; a++)
            {
                if (list[a].flagged)
                {
                    if (stable == null)
                    {
                        stable = list[a];
                    }
                    else if (stable.revid < list[a].revid)
                    {
                        stable = list[a];
                    }
                }
            }
            if (stable != null)
            {
                flagged_rev = stable.revid; is_flagged = true;
            }
            else
            {
                is_flagged = false; last_flagged = false;
            }

            if (stable != null)
            {
                for (int a = 0; a < list.Count; a++)
                {
                    if (list[a].revid <= stable.revid)
                    {
                        list[a].flagged = true;
                    }
                    else
                    {
                        list[a].flagged = false;
                    }
                }
            }
        }
Esempio n. 4
0
        public void SetReviewed(long revid)
        {
            for (int a = 0; a < list.Count; a++)
            {
                if (list[a].revid == revid)
                {
                    if (stable != null && stable.revid < revid)
                    {
                        stable      = list[a];
                        flagged_rev = revid;
                    }

                    is_flagged      = true;
                    list[a].flagged = true;

                    if (a == list.Count - 1)
                    {
                        last_flagged = true;
                    }

                    break;
                }
            }
        }
Esempio n. 5
0
        public static DiffTemporaryResult __GetDiff(CoreOperations aw, WikiRevision from, WikiRevision to, Element el, bool pro_info = false)
        {
            DiffTemporaryResult result = null;

            try
            {
                String title = el.title;
                title = title.Replace(' ', '_');
                SweepNetPage page = el.page;
                if (page.list.Count == 0)
                {
                    return(result);
                }
                String data = "";
                long   start_id, end_id;
                if (from == null)
                {
                    from = to; to = null;
                }
                bool textflag = false;

                if (from == null || to == null || from.revid == to.revid)
                {
                    data = aw.HTTP_W_REQUEST("index.php?oldid=" + (from != null ? from.revid : to.revid) + "&action=raw&ctype=text/css");
                    if (data.Equals("") || data.Equals("/* Empty */"))
                    {
                        return(result);
                    }
                    data     = "<tr width=\"100%\"><td width=\"100%\" colspan=\"4\">" + HttpUtility.HtmlEncode(data).Replace("\n", "<br />") + "</td></tr>";
                    start_id = -1; end_id = el.page.curr.revid;
                }
                else
                {
                    data = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&titles=" + HttpUtility.UrlEncode(title) + "&rvstartid=" + from.revid + "&rvlimit=1&rvdiffto=" + to.revid);
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(data);
                    XmlNode currentNode;
                    currentNode = xmlDoc.DocumentElement.SelectSingleNode("query");
                    if (currentNode == null)
                    {
                        return(result);
                    }
                    currentNode = currentNode.SelectSingleNode("pages");
                    if (currentNode == null)
                    {
                        return(result);
                    }
                    currentNode = currentNode.SelectSingleNode("page");
                    if (currentNode == null)
                    {
                        return(result);
                    }
                    currentNode = currentNode.SelectSingleNode("revisions");
                    if (currentNode == null)
                    {
                        return(result);
                    }
                    currentNode = currentNode.SelectSingleNode("rev");
                    if (currentNode == null)
                    {
                        return(result);
                    }
                    currentNode = currentNode.SelectSingleNode("diff");
                    if (currentNode == null)
                    {
                        return(result);
                    }
                    data = currentNode.InnerText;

                    start_id = page.flagged_rev + 1; end_id = el.page.curr.revid;
                }

                String diffrez = "<html><head>" + i18n.GetText("diff_head" + Options.GetOption("diff_style")) + "</head><body width=\"100%\">";

                if (pro_info)
                {
                    diffrez += "<table width=\"100%\" border=\"0\" valign=\"top\"><tr>";
                    diffrez += "<td width=\"" + (to != null ? "50" : "100") + "%\" valign=\"top\">" + DateTime.Parse(from.timestamp).ToString("dd/MM/yyyy HH:mm") + " " + from.user + "" + (to != null ? "<br />" : "") + " [" + from.size + " байт]" + (from.minor ? " [m] " : "") + " (" + HttpUtility.HtmlEncode(from.comm) + ")" + "</td>";
                    if (to != null)
                    {
                        diffrez += "<td valign=\"top\">" + DateTime.Parse(to.timestamp).ToString("dd/MM/yyyy HH:mm") + " " + to.user + "<br /> [" + to.size + " байт]" + (to.minor ? " [m] " : "") + " (" + HttpUtility.HtmlEncode(to.comm) + ")" + "</td>";
                    }
                    diffrez += "</tr></table>";
                }
                else
                {
                    diffrez += "<table width=\"100%\" border=\"0\"><tr><td colspan=\"2\">" + String.Format("{0} edits have been made by: {1}".T(), (page.GeCountOfEdits(start_id, end_id)), Tools.GetColoredListOfUsers(page.GetHashtableofcontributors(start_id, end_id))) /*page.GetContributors(1).ToArray())*/;
                    if (page.unflagged_count == 1)
                    {
                        diffrez += "; " + "Summary".T() + ": \"" + HttpUtility.HtmlEncode(page.GetLastRevision().comm) + "\"";
                    }
                    diffrez += @"<span id=""authors""></span>";//"<!--SPACE_FOR_AUTHORS_BEGINNING--><!--SPACE_FOR_AUTHORS_ENDING-->";
                    diffrez += "</td></tr><tr><td align=\"left\" valign=\"bottom\">" + (page.is_flagged ? "Stable revision".T() : "First revision".T()) + " — " + Tools.ConvertTimestampToDate(page.list[0].timestamp) + "</td><td align=\"right\" valign=\"bottom\">Текущая — " + Tools.ConvertTimestampToDate(page.list[page.list.Count - 1].timestamp) + "</td></tr></table>";
                }

                if (!WBcallback.CheckVisbleChanges(data) && !data.Equals(""))
                {
                    diffrez += "<div align=\"center\"><b>" + "No noticeable changes".T() + "</b></div>";
                }
                diffrez += "<table width=\"100%\" style=\"border-top: solid #000000 1px;\">";
                diffrez += "<col width=\"2%\" valign=\"top\"><col width=\"46%\" valign=\"top\"><col width=\"2%\" valign=\"top\"><col width=\"46%\" valign=\"top\">";
                List <DiffPiece> pieces = DiffEditor.SplitIntoPieces(ref data);
                diffrez += data.Equals("") ? "<td colspan=\"4\"><!--diff_is_empty-->" + "These revisions are the same".T() + "</td>" : data;
                diffrez += "</table>";
                diffrez += "<br/><script>";
                diffrez += "</script></body></html>";
                diffrez  = Tools.ReplaceFirst(diffrez, "<span class=\"diffchange", "<span id=\"first_difference\" class=\"diffchange");

                diffrez = (Options.GetOptionInt("check_links") == 1 ? WBcallback.ProcessPage(diffrez) : diffrez);

                return(new DiffTemporaryResult(diffrez, pieces));
            }
            catch (Exception) {
                return(result);
            }
        }
Esempio n. 6
0
        public static String __GetView(CoreOperations aw, WikiRevision rev, Element el, bool pro_info = false)
        {
            try
            {
                String title = el.title;
                title = title.Replace(' ', '_');
                SweepNetPage page = el.page;
                if (page.list.Count == 0)
                {
                    return("");
                }
                String data = "";
                long   start_id;

                if (el.stable_id < 1)
                {
                    data     = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&rvprop=content&titles=" + HttpUtility.UrlEncode(title) + "&rvlimit=1&rvparse=1");
                    start_id = -1;
                }
                else
                {
                    data     = aw.HTTP_W_REQUEST("api.php?format=xml&action=query&prop=revisions&rvprop=content&titles=" + HttpUtility.UrlEncode(title) + "&rvstartid=" + el.stable_id + "&rvlimit=1&rvparse=1");
                    start_id = page.flagged_rev;
                }
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(data);
                XmlNode currentNode;
                currentNode = xmlDoc.DocumentElement.SelectSingleNode("query");
                if (currentNode == null)
                {
                    return("");
                }
                currentNode = currentNode.SelectSingleNode("pages");
                if (currentNode == null)
                {
                    return("");
                }
                currentNode = currentNode.SelectSingleNode("page");
                if (currentNode == null)
                {
                    return("");
                }
                currentNode = currentNode.SelectSingleNode("revisions");
                if (currentNode == null)
                {
                    return("");
                }
                currentNode = currentNode.SelectSingleNode("rev");
                if (currentNode == null)
                {
                    return("");
                }
                data = currentNode.InnerText;
                if (data.Equals("") || data == null)
                {
                    data = "-1";
                }


                String diffrez = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>";
                if (pro_info)
                {
                    diffrez += "<table width=\"100%\" border=\"0\" valign=\"top\"><tr>";
                    diffrez += "<td width=\"100%\" valign=\"top\">" + DateTime.Parse(rev.timestamp).ToString("dd/MM/yyyy HH:mm") + " " + rev.user + " [" + rev.size + " байт]" + (rev.minor ? " [m] " : "") + " (" + HttpUtility.HtmlEncode(rev.comm) + ")" + "</td>";
                    diffrez += "</tr></table>";
                }
                else
                {
                    if (page.unflagged_count == 1)
                    {
                        diffrez += "; " + "Summary".T() + ": \"" + HttpUtility.HtmlEncode(page.GetLastRevision().comm) + "\"";
                    }
                    diffrez += "</td></tr><tr><td align=\"left\" valign=\"bottom\">" + "Stable revision".T() + " — " + Tools.ConvertTimestampToDate(page.list[0].timestamp) + "</td><td align=\"right\" valign=\"bottom\">Текущая — " + Tools.ConvertTimestampToDate(page.list[page.list.Count - 1].timestamp) + "</td></tr></table>";
                }
                diffrez += "<table width=\"100%\" style=\"border-top: solid #000000 1px;\">";
                diffrez += "<tr width=\"100%\"><td>" + data + "</td></tr>";
                diffrez += "</table><br/></body></html>";

                return(diffrez);
            }
            catch (Exception) { /*MessageBox.Show(e.Message+"\r\n\r\n"+e.StackTrace);*/ return(""); }
        }
Esempio n. 7
0
 public String GetRevFlags(WikiRevision rev)
 {
     return("[" + (rev.diffsize > 0?"+":"") + rev.diffsize + "]" + (rev.minor?" [m]":""));
 }
Esempio n. 8
0
        public bool LoadRevision(long start, bool withstart = true, bool loadtext = false)
        {
            prev_opt.updated = true; prev_opt.start = start; prev_opt.withstart = withstart; prev_opt.loadtext = loadtext;

            list.Clear();
            List <WikiRevision> l = new List <WikiRevision>();
            WikiRevision        tmp;
            WikiRevision        prev = null;
            long first_start         = start;

            try
            {
                long next = -1;
                start = -1;
st:

                String data = mysite.GetPageHTM(mysite.indexPath + "api.php?format=xml&action=query&prop=revisions|flagged&rvdir=older" + (start < 1 ? "" : "&rvstartid=" + start + "") + (first_start < 1?"":"&rvendid=" + first_start) + "&rvlimit=500&titles=" + HttpUtility.UrlEncode(title) + "&rvprop=ids|timestamp|user|comment|flags|size" + (loadtext ? "|content" : ""));
                //  Process.Start("http://ru.wikipedia.org/w/" +  "api.php?format=xml&action=query&prop=revisions|flagged&rvdir=older" + (start < 1 ? "" : "&rvstartid=" + start + "") + (first_start<1?"":"&rvendid="+first_start)+"&rvlimit=500&titles=" + HttpUtility.UrlEncode(title) + "&rvprop=ids|timestamp|user|comment|flags|size" + (loadtext ? "|content" : ""));
                // MessageBox.Show(data);
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(data);
                XmlNode currentNode;
                // updating = false;
                currentNode = xmlDoc.DocumentElement.SelectSingleNode("query");
                if (currentNode == null)
                {
                    return(false);
                }

                next = -1;
                XmlNode cn = xmlDoc.DocumentElement.SelectSingleNode("query-continue");
                if (cn != null)
                {
                    cn   = cn.SelectSingleNode("revisions");
                    next = Convert.ToInt64(cn.Attributes.GetNamedItem("rvstartid").Value);
                }

                currentNode = currentNode.SelectSingleNode("pages");
                if (currentNode == null)
                {
                    return(false);
                }
                currentNode = currentNode.SelectSingleNode("page");
                if (currentNode == null)
                {
                    return(false);
                }

                XmlNode fr = currentNode.SelectSingleNode("flagged");
                if (fr != null)
                {
                    flagged_rev = Convert.ToInt32(fr.Attributes.GetNamedItem("stable_revid").Value);
                }
                if (flagged_rev > 0)
                {
                    is_flagged = true;
                }


                ns = currentNode.Attributes.GetNamedItem("ns").Value;

                currentNode = currentNode.SelectSingleNode("revisions");
                if (currentNode == null)
                {
                    return(false);
                }
                bool enought = false;
                foreach (XmlNode el in currentNode.SelectNodes("rev"))
                {
                    tmp       = new WikiRevision();
                    tmp.revid = Convert.ToInt64(el.Attributes.GetNamedItem("revid").Value);
                    if (tmp.revid == start && withstart == false)
                    {
                        continue;
                    }
                    tmp.rand = Tools.FullRandom();
                    if (tmp.revid > maxid)
                    {
                        maxid = tmp.revid;
                    }
                    tmp.comm      = el.Attributes.GetNamedItem("comment").Value;
                    tmp.user      = el.Attributes.GetNamedItem("user").Value;
                    tmp.timestamp = el.Attributes.GetNamedItem("timestamp").Value;
                    tmp.minor     = el.Attributes.GetNamedItem("minor") != null;
                    tmp.size      = Convert.ToInt32(el.Attributes.GetNamedItem("size").Value);
                    if (prev != null)
                    {
                        prev.diffsize = prev.size - tmp.size;
                    }
                    prev = tmp;
                    if (loadtext)
                    {
                        tmp.text = el.InnerText;
                    }
                    if (tmp.revid <= flagged_rev)
                    {
                        tmp.flagged = true;
                    }
                    l.Add(tmp);

                    if (tmp.flagged)
                    {
                        enought = true; break;
                    }
                    /* */
                }
                if (next != -1 && enought == false)
                {
                    start = next;
                    goto st;
                }
            }
            catch (Exception)
            {
                list.Clear();
            }


            for (int a = l.Count - 1; a >= 0; a--)
            {
                tmp = l[a];

                if (tmp.revid == flagged_rev)
                {
                    flagged_size = tmp.size;
                }

                last_flagged = tmp.flagged;
                last_size    = tmp.size;
                if (tmp.flagged == false)
                {
                    unflagged_count++;
                }
                if (tmp.flagged == true && (stable == null || stable.revid < tmp.revid))
                {
                    stable = tmp;
                }
                if (curr == null || curr.revid < tmp.revid)
                {
                    curr = tmp;
                }
                list.Add(tmp);
            }

            return(list.Count > 0);
        }