File: blog.vspx

package info (click to toggle)
virtuoso-opensource 6.1.4%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 245,116 kB
  • sloc: ansic: 639,631; sql: 439,225; xml: 287,085; java: 61,048; sh: 38,723; cpp: 36,889; cs: 25,240; php: 12,562; yacc: 9,036; lex: 7,149; makefile: 6,093; jsp: 4,447; awk: 1,643; perl: 1,017; ruby: 1,003; python: 329
file content (356 lines) | stat: -rw-r--r-- 13,485 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<?xml version="1.0"?>
<!--
 -  
 -  $Id: blog.vspx,v 1.2 2006/08/16 00:04:14 source Exp $
 -
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -  
 -  Copyright (C) 1998-2006 OpenLink Software
 -  
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -  
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -  
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -  
 -  
-->
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../demo.css"/>
</head>
<body>
<v:page name="pagecal1" xmlns:v="http://www.openlinksw.com/vspx/">
<v:variable name="tdate" type="date" default="NULL"/>
<v:variable name="newpost" type="int" default="1"/>
<v:variable name="postid" type="varchar" default="null"/>
<v:variable name="blogid" type="varchar" default="'home'" persist="1"/>
<v:variable name="uid" type="varchar" default="'dav'" persist="1"/>
<v:variable name="nuid" type="varchar" default="2" persist="1"/>
<v:variable name="uname" type="varchar" default="'Anonimous'"/>
      <v:variable name="adays" type="any" default="null"/>

<v:on-init>
  self.tdate := now ();
  if (get_keyword ('tdate', params) &lt;&gt; '')
    {
      declare cal vspx_calendar;
      self.tdate := stringdate (get_keyword ('tdate', params));
      cal := self.vc_find_descendant_control ('cal1');
      cal.cal_date := self.tdate;
    }
</v:on-init>

    <!-- LOGIN -->
    <v:login name="login1" realm="blog" mode="url"
	     user-password-check="BLOG..blog_user_password_check">
      <v:template type="if-no-login" redirect="login.vspx" />
      <v:template type="if-login" />
      <v:after-data-bind>
      <![CDATA[
	if (self.vc_authenticated)
	  {
	    self.uid := connection_get ('vspx_user');
	    self.blogid := (select top 1 BI_BLOG_ID from BLOG..SYS_BLOG_INFO, SYS_USERS where BI_OWNER = U_ID and U_NAME = self.uid order by 1);
	    self.nuid := atoi (self.blogid);
	  }
	connection_set ('blogid', self.blogid);
	connection_set ('uid', self.uid);
	self.uname := coalesce ((select U_FULL_NAME from SYS_USERS where U_NAME = self.uid), self.uname);
       ]]>
      </v:after-data-bind>
    </v:login>
    <!-- END LOGIN -->

<P>&amp;nbsp;</P> <!-- place to put a logo -->
<div align="center">
<div align="left" style="margin-left: 100px;"><H2><?V self.uname ?>'s Weblog</H2></div>
<v:form name="form1" type="simple" action="blog.vspx" >
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
  <td valign="top">
  <table border="0" cellpadding="0" cellspacing="0" width="70%">
    <tr>
      <td>
	   <table width="80%" border="0" cellspacing="0" cellpadding="4" class="tableentry">
	      <tr>
		<td valign="top">
                   <v:textarea name="msg" xhtml_rows="10" xhtml_cols="70">
		     <v:after-data-bind>
		       if ({?'pid'} is not null)
		         {
			   declare exit handler for sqlstate '*' { goto endb;  };
			   control.ufl_value := (select B_CONTENT from BLOG..SYS_BLOGS where B_BLOG_ID = self.blogid and B_POST_ID = {?'pid'});
			   self.newpost := 0;
			   self.postid := {?'pid'};
			endb:;
			 }
		     </v:after-data-bind>
		   </v:textarea>
		   <p style="color: red;"><v:error-summary /></p>
		</td>
	      </tr>
	      <tr>
		<td valign="top">
                   <v:button name="save" action="simple" value="Post to Weblog" >
		     <v:on-post>
		     declare msg vspx_textarea;
                     msg := self.msg;
		     if (msg.ufl_value &lt;&gt; '')
		       {
			 if (self.newpost)
			   {
			     insert into BLOG..SYS_BLOGS (B_APPKEY, B_POST_ID, B_BLOG_ID, B_TS, B_CONTENT, B_USER_ID)
				 values ('appKey', cast (sequence_next ('blogger.postid') as varchar),
				     self.blogid, now (), msg.ufl_value, self.nuid);
			   }
			 else
			   {
			     update BLOG..SYS_BLOGS set B_CONTENT = msg.ufl_value where B_POST_ID = self.postid and B_BLOG_ID = self.blogid;
			   }
		       }
                     else
		       {
			 self.vc_is_valid := 0;
			 msg.vc_error_message := 'Can not post to weblog an empty message';
			 return;
		       }
		     self.newpost := 1;
		     {
		       self.ds.vc_data_bind (e);
		     }
 		     msg.ufl_value := '';
		     </v:on-post>
		   </v:button>
		</td>
	      </tr>
           </table>
      </td>
    </tr>
    <tr>
      <td>
      &amp;nbsp;
      </td>
    </tr>
    <tr>
      <td>
       <!-- DATASET -->
      <table cellspacing="0" cellpadding="0">
       <tr bgcolor="DCDCDC">
         <td>
      <v:data-set name="ds"
      	sql='select B_CONTENT, B_TS, B_POST_ID from BLOG..SYS_BLOGS where B_BLOG_ID = :blogid
		and year(B_TS) = year(:dt) and month(B_TS) = month(:dt) and dayofmonth(B_TS) = dayofmonth(:dt)
		order by B_TS desc'
      	nrows="10" scrollable="0">
        <v:param name="blogid" value="--self.blogid"/>
        <v:param name="dt" value="--self.tdate"/>
        <v:template name="template1" type="simple" name-to-remove="table" set-to-remove="bottom">
          <table border="0" cellspacing="1" cellpadding="5" class="tableresult">
	    <tr><td colspan="4" align="center">
	         <v:label name="label03" value="--b_tit_fmt (self.tdate)" format="%s"/>
	        </td>
  	    </tr>
          </table>
        </v:template>
        <v:template name="template2" type="repeat" name-to-remove="" set-to-remove="">
          <v:template name="template7" type="if-not-exists" name-to-remove="table" set-to-remove="both">
            <table>
              <tr bgcolor="FFFFFF">
                <td align="center" colspan="4">
                  <b>No postings</b>
                </td>
              </tr>
            </table>
          </v:template>
          <v:template name="template4" type="browse" name-to-remove="table" set-to-remove="both">
            <table>
              <tr bgcolor="FFFFFF">
	        <td>
		  <v:check-box name="cb1" value="--cal_icell (control, 2)" group-name="cb1">
		    <v:after-data-bind>
		      control.ufl_selected := 0;
		    </v:after-data-bind>
		  </v:check-box>
		</td>
                <td align="left" >
                  <v:label name="label5" value="--cal_icell (control, 0)" format="%s"/>
                </td>
                <td align="left" nowrap="1" colspan="1">
                  <v:label name="label6" value="--cal_icell (control, 1)" format="%s" fmt-function="b_date_fmt"/>
                </td>
                <td nowrap="1">
		<v:url name="edit" value="EDIT" url="--concat ('blog.vspx?pid=', cal_icell (control, 2), '&amp;tdate=', datestring(coalesce(self.tdate, now())))" />
                </td>
              </tr>
            </table>
          </v:template>
        </v:template>
        <v:template name="template8" type="simple" name-to-remove="table" set-to-remove="top">
            <table>
            </table>
        </v:template>
      </v:data-set>
        </td>
	</tr>
	<tr><td>&amp;nbsp;</td></tr>
	<tr><td>
	  <v:button action="simple" name="delete" value="Delete">
	    <v:on-post>
	      declare i, deleted int;
              i := 0; deleted := 0;
	      while (1)
                {
                  i := position ('cb1', params, i);
		  if (i = 0)
		    goto endp;
                  deleted := deleted + 1;
                  delete from BLOG..SYS_BLOGS where B_BLOG_ID = self.blogid and B_POST_ID = params[i];
                  i := i + 1;
		}
             endp:

	      if (deleted &gt; 0)
	        {
                  self.ds.vc_data_bind (e);
	        }
	    </v:on-post>
	  </v:button>
	</td></tr>
	</table>
       <!-- END DATASET -->
      </td>
    </tr>
  </table>
  </td>
  <td valign="top" width="130">
    <div>
    <v:calendar name="cal1" initial-date="--coalesce (self.tdate, now())">
                  <v:before-data-bind><![CDATA[
	    set isolation = 'committed';
	    declare adays any;
	    declare m, y int;
	    declare dt date;


	    dt := coalesce (control.cal_date, self.fordate);
	    m := month (dt);
	    y := year (dt);

	    adays := vector ();
	    for select distinct dayofmonth (B_TS) DDAY from BLOG..SYS_BLOGS
	      where B_BLOG_ID = self.blogid and year (B_TS) = y and month (B_TS) = m do
	      {
	        adays := vector_concat (adays, vector (cast (DDAY as varchar)));
	      }
	    self.adays := adays;]]></v:before-data-bind>
      <v:after-data-bind>
       self.tdate := control.cal_date;
      </v:after-data-bind>
      <v:template type="simple" name="chead1" name-to-remove="table" set-to-remove="bottom">
      <table border="0" cellpadding="1" cellspacing="0" id="calendar">
        <tr>
         <td align="center">
	  <v:button name="pmon" value="&amp;lt;" action="simple" style="url">
	    <v:on-post>
	    declare cal vspx_calendar;
	    declare ctrl vspx_control;
	    cal := control.vc_parent.vc_parent;
	    cal.cal_date := dateadd ('month', -1, cal.cal_date);
	    ctrl := cal;
	    ctrl.vc_data_bind (e);
            ctrl := self.vc_find_descendant_control ('ds');
	    ctrl.vc_data_bind (e);
	    </v:on-post>
	  </v:button>
	 </td>
 	 <td colspan="5" align="center"><B>
           <?V monthname((control.vc_parent as vspx_calendar).cal_date) ?>
	   <?V year((control.vc_parent as vspx_calendar).cal_date) ?>
	   </B>
	 </td>
         <td align="center">
	  <v:button name="nmon" value="&amp;gt;" action="simple" style="url">
	    <v:on-post>
	    declare cal vspx_calendar;
	    declare ctrl vspx_control;
	    cal := control.vc_parent.vc_parent;
	    cal.cal_date := dateadd ('month', 1, cal.cal_date);
	    ctrl := cal;
	    ctrl.vc_data_bind (e);
            ctrl := self.vc_find_descendant_control ('ds');
	    ctrl.vc_data_bind (e);
	    </v:on-post>
	  </v:button>
	 </td>
	 </tr>
        <tr><td class="realsmall">Sun</td><td class="realsmall">Mon</td><td class="realsmall">Tue</td><td class="realsmall">Wed</td><td class="realsmall">Thu</td><td class="realsmall">Fri</td><td class="realsmall">Sat</td></tr>
      </table>
      </v:template>
      <v:template type="repeat" name="cbody1" name-to-remove="" set-to-remove="">
      <v:template type="browse" name="crow1" name-to-remove="table" set-to-remove="both">
      <table>
                        <tr>
                          <td class="&lt;?V cell_fmt((control as vspx_row_template).te_rowset[0], self.adays) ?>">
                            <v:button style="url" action="simple" name="b1" value="--cal_icell(control, 0)" active="--position(control.ufl_value, self.adays)"/>
                          </td>
                          <td class="&lt;?V cell_fmt((control as vspx_row_template).te_rowset[1], self.adays) ?>">
                            <v:button style="url" action="simple" name="b2" value="--cal_icell(control, 1)" active="--position(control.ufl_value, self.adays)"/>
                          </td>
                          <td class="&lt;?V cell_fmt((control as vspx_row_template).te_rowset[2], self.adays) ?>">
                            <v:button style="url" action="simple" name="b3" value="--cal_icell(control, 2)" active="--position(control.ufl_value, self.adays)"/>
                          </td>
                          <td class="&lt;?V cell_fmt((control as vspx_row_template).te_rowset[3], self.adays) ?>">
                            <v:button style="url" action="simple" name="b4" value="--cal_icell(control, 3)" active="--position(control.ufl_value, self.adays)"/>
                          </td>
                          <td class="&lt;?V cell_fmt((control as vspx_row_template).te_rowset[4], self.adays) ?>">
                            <v:button style="url" action="simple" name="b5" value="--cal_icell(control, 4)" active="--position(control.ufl_value, self.adays)"/>
                          </td>
                          <td class="&lt;?V cell_fmt((control as vspx_row_template).te_rowset[5], self.adays) ?>">
                            <v:button style="url" action="simple" name="b6" value="--cal_icell(control, 5)" active="--position(control.ufl_value, self.adays)"/>
                          </td>
                          <td class="&lt;?V cell_fmt((control as vspx_row_template).te_rowset[6], self.adays) ?>">
                            <v:button style="url" action="simple" name="b7" value="--cal_icell(control, 6)" active="--position(control.ufl_value, self.adays)"/>
                          </td>
                        </tr>
      </table>
      </v:template>
      </v:template>
      <v:template type="simple" name="cbott1" name-to-remove="table" set-to-remove="top">
      <table>
      </table>
      </v:template>
    </v:calendar>
   </div>
   <div align="center">
   <v:url name="work" url="bridge.vspx" value="Blogger Bridge" />
   </div>
  </td>
</tr>
</table>
      <v:on-post>
      declare cal vspx_calendar;
      cal := control.vc_find_control ('cal1');
      if (cal.vc_focus and cal.cal_selected is not null)
       {
         declare ctrl vspx_control;
	 self.tdate := cal.cal_selected;
         ctrl := control.vc_find_control ('ds');
         ctrl.vc_data_bind (e);
       }
      </v:on-post>
</v:form>
</div>

</v:page>
</body>
</html>