1: IDENTIFICATION DIVISION.
2: CLASS-ID. CLASS-THIS AS "Service" INHERITS CLASS-WEBSERVICE
3: CUSTOM-ATTRIBUTE CA-WEBSERVICE CA-WEBSERVICEBINDING.
4: ENVIRONMENT DIVISION.
5: CONFIGURATION SECTION.
6: SPECIAL-NAMES.
7: CUSTOM-ATTRIBUTE CA-WEBSERVICE
8: CLASS CLASS-WEBSERVICEATTRIBUTE
9: PROPERTY PROP-NAMESPACE IS N"http://www.williamsportwebdeveloper.com"
10: CUSTOM-ATTRIBUTE CA-WEBSERVICEBINDING
11: CLASS CLASS-WEBSERVICEBINDINGATTR
12: PROPERTY PROP-CONFORMSTO IS PROP-BASICPROFILE1_1 OF ENUM-WSIPROFILES
13: CUSTOM-ATTRIBUTE CA-WEBMETHOD
14: CLASS CLASS-WEBMETHODATTRIBUTE
15: .
16: REPOSITORY.
17: CLASS CLASS-STRING AS "System.String"
18: CLASS CLASS-WEBMETHODATTRIBUTE AS "System.Web.Services.WebMethodAttribute"
19: CLASS CLASS-WEBSERVICE AS "System.Web.Services.WebService"
20: CLASS CLASS-WEBSERVICEATTRIBUTE AS "System.Web.Services.WebServiceAttribute"
21: CLASS CLASS-WEBSERVICEBINDINGATTR AS "System.Web.Services.WebServiceBindingAttribute"
22: CLASS CLASS-SQLPROCEDURE AS "Microsoft.SqlServer.Server.SqlProcedureAttribute"
23: CLASS CLASS-XML AS "System.Xml.XmlDocument"
24: CLASS CLASS-STRING-BUILDER AS "System.Text.StringBuilder"
25: ENUM ENUM-WSIPROFILES AS "System.Web.Services.WsiProfiles"
26: PROPERTY PROP-BASICPROFILE1_1 AS "BasicProfile1_1"
27: PROPERTY PROP-CONFORMSTO AS "ConformsTo"
28: PROPERTY PROP-NAMESPACE AS "Namespace"
29: .
30: OBJECT.
31: DATA DIVISION.
32: WORKING-STORAGE SECTION.
33: 01 MSG PIC X(1200).
34: 01 WK-BROTHEL-NAME PIC X(255).
35: 01 WK-STREET PIC X(255).
36: 01 WK-CITY PIC X(255).
37: 01 WK-POSTAL-CODE PIC X(6).
38: 01 WK-PHONE PIC X(255).
39: 01 WK-LINK PIC X(255).
40: 01 WK-LATITUDE PIC X(50).
41: 01 WK-LONGITUDE PIC X(50).
42: 01 WK-STRING OBJECT REFERENCE CLASS-STRING.
43: 01 WK-STRING-BUILDER OBJECT REFERENCE CLASS-STRING-BUILDER.
44: PROCEDURE DIVISION.
45:
46: METHOD-ID. NEW.
47: PROCEDURE DIVISION.
48: *> Uncomment the following line if using designed components.
49: *> INVOKE SELF "InitializeComponent".
50: END METHOD NEW.
51:
52: METHOD-ID. GET-BROTHELS AS "GetBrothels" CUSTOM-ATTRIBUTE CA-WEBMETHOD.
53: DATA DIVISION.
54: WORKING-STORAGE SECTION.
55: *> There must be enough fields for the number of columns.
56: EXEC SQL BEGIN DECLARE SECTION END-EXEC.
57: 01 BROTHEL-LIST.
58: 02 BROTHEL-NAME PIC X(255).
59: 02 STREET PIC X(255).
60: 02 CITY PIC X(255).
61: 02 POSTAL-CODE PIC X(6).
62: 02 PHONE PIC X(25).
63: 02 LINK PIC X(255).
64: 02 LATITUDE PIC X(50).
65: 02 LONGITUDE PIC X(50).
66: 01 NUMBER-OF-RECORDS PIC S9(9) COMP-5.
67: 01 SQLINFOA.
68: 02 SQLERRD PIC S9(9) COMP-5 OCCURS 6 TIMES.
69: 01 SQLSTATE PIC X(5).
70: EXEC SQL END DECLARE SECTION END-EXEC.
71: LINKAGE SECTION.
72: 01 RET-VAL OBJECT REFERENCE CLASS-STRING.
73: 01 RET-VAL-XML OBJECT REFERENCE CLASS-XML.
74: PROCEDURE DIVISION RETURNING RET-VAL-XML.
75: EXEC SQL WHENEVER NOT FOUND GO TO :P-END END-EXEC.
76: EXEC SQL
77: DECLARE CUR1 CURSOR FOR SELECT BrothelName, Street, City, PostalCode, Phone, Link, Latitude, Longitude FROM ErosCenters
78: END-EXEC.
79: P-START.
80: EXEC SQL CONNECT TO 'SERVER1' AS 'CNN1' END-EXEC.
81: EXEC SQL
82: SELECT COUNT(*) INTO :NUMBER-OF-RECORDS FROM ErosCenters
83: END-EXEC.
84: EXEC SQL OPEN CUR1 END-EXEC.
85: *> CREATE AN STRING BUILDER OBJECT
86: INVOKE CLASS-STRING-BUILDER "NEW" RETURNING WK-STRING-BUILDER.
87: *> CALL THE OBJECT METHOD
88: SET WK-STRING TO "<ErosCenters>"
89: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
90: PERFORM P-LOOP NUMBER-OF-RECORDS TIMES.
91: P-LOOP.
92: EXEC SQL
93: FETCH CUR1 INTO :BROTHEL-LIST
94: END-EXEC.
95: *> MOVE SQLERRD(3) TO MSG.
96: *> MOVE BROTHEL-LIST TO MSG.
97: MOVE BROTHEL-NAME TO WK-BROTHEL-NAME.
98: MOVE STREET TO WK-STREET.
99: MOVE CITY TO WK-CITY.
100: MOVE POSTAL-CODE TO WK-POSTAL-CODE.
101: MOVE PHONE TO WK-PHONE.
102: MOVE LINK TO WK-LINK.
103: MOVE LATITUDE TO WK-LATITUDE.
104: MOVE LONGITUDE TO WK-LONGITUDE.
105: *> CONSTRUCT XML STRING
106: SET WK-STRING TO CLASS-STRING::"Concat"(N"<Brothel><Name>" WK-BROTHEL-NAME N"</Name>").
107: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
108: SET WK-STRING TO CLASS-STRING::"Concat"(N"<Street>" WK-STREET N"</Street>").
109: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
110: SET WK-STRING TO CLASS-STRING::"Concat"(N"<City>" WK-CITY N"</City>").
111: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
112: SET WK-STRING TO CLASS-STRING::"Concat"(N"<PostalCode>" WK-POSTAL-CODE N"</PostalCode>").
113: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
114: SET WK-STRING TO CLASS-STRING::"Concat"(N"<Phone>" WK-PHONE N"</Phone>").
115: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
116: SET WK-STRING TO CLASS-STRING::"Concat"(N"<Link>" WK-LINK N"</Link>").
117: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
118: SET WK-STRING TO CLASS-STRING::"Concat"(N"<Latitude>" WK-LATITUDE N"</Latitude>").
119: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
120: SET WK-STRING TO CLASS-STRING::"Concat"(N"<Longitude>" WK-LONGITUDE N"</Longitude></Brothel>").
121: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
122: P-END.
123: SET WK-STRING TO "</ErosCenters>"
124: INVOKE WK-STRING-BUILDER "Append" USING BY VALUE WK-STRING.
125: EXEC SQL CLOSE CUR1 END-EXEC.
126: EXEC SQL ROLLBACK WORK END-EXEC.
127: EXEC SQL DISCONNECT DEFAULT END-EXEC.
128: *> INVOKE SELF "GetData" .
129: *> CREATE AN XMLDOCUMENT OBJECT
130: INVOKE CLASS-XML "NEW" RETURNING RET-VAL-XML.
131: *> CALL THE OBJECT METHOD
132: SET WK-STRING TO WK-STRING-BUILDER::"ToString".
133: INVOKE RET-VAL-XML "LoadXml" USING BY VALUE WK-STRING.
134: END METHOD GET-BROTHELS.
135:
136: METHOD-ID. GET-DATA AS "GetData".
137: PROCEDURE DIVISION.
138: MOVE "Hello" & " World" TO MSG.
139: END METHOD GET-DATA.
140:
141: END OBJECT.
142: END CLASS CLASS-THIS.
Elgg Threaded Blog Comments
I have finally finished my work on a threaded comment system for Elgg 1.2. You can download the plugin at http://community.elgg.org/pg/plugins/rsrobbins/read/228544/threaded-blog-comments This must completely replace the existing blog plugin because the change from an annotation comment to an ElggObject comment is more extensive than a view can handle. But I tried to follow the Elgg way of doing things as much as possible.
The Threaded Blog Comments plugin allows you to reply to a specific blog comment so you can create comment threads without using some hack like the @ ampersand sign (made popular by Twitter). A comment that is a reply to a previous comment will appear underneath and indented. This makes it much easier to have a conversation in the comments. In addition to the nesting of comments, I also added pagination controls for comments which was not a feature of the original comment system.
Much of this work is based on the similar customization I did for Ning before they killed their platform for third party developers. And prior to that I developed this style of nested comments for YouTube videos using the YouTube API which you can see at http://www.williamsportwebdeveloper.com/YouComment.aspx. The legacy of this prior work is that the Elgg version still uses a XML feed. So you also get a RSS feed for a blog’s comments as a bonus.
If I don’t go back to work any time soon, I’ll work on applying this customization to Elgg 1.5. I will also see about implementing nested comments for other types of content besides blogs.