Change references to numeric child/parent IDs which can now be text
[contractdashboard.git] / cutenews / inc / wizards.mdu
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<?PHP
if($member_db[1] != 1){ msg("error", "Access Denied", "You don't have permission for this section"); }

if($action == "" or !$action){

$wizard_options = <<<HTMLWIZARDS
<ol>
<li style="margin-bottom:5px;"><a href='$PHP_SELF?mod=wizards&action=rss'><b>Rss</b> Setup and Integration</a></li>
<li><a href='$PHP_SELF?mod=wizards&action=news'>Integrate <b>News</b> into your site</a></li>
</ol>

HTMLWIZARDS;

   msg("wizard", "Choose Wizard", "$wizard_options");
}


// ********************************************************************************
// Initiate the News Integration Wizard
// ********************************************************************************
if($action == "news"){

//Gather the Templates
        $templates_list = array();
        if(!$handle = opendir("./data")){ /*die("<center>Can not open directory $cutepath/data ");*/ }
                   while (false !== ($file = readdir($handle))){
                           if(eregi(".tpl", $file)){
                    $file_arr                 = explode(".", $file);
                $templates_list[]= $file_arr[0];
                           }
                   }
        closedir($handle);

        $templates_html = "<select name=w_template>";
        foreach($templates_list as $single_template){
                if($single_template != "rss"){

                   if($single_template == "Default"){
                   $templates_html .= "<option selected value=\"$single_template\">$single_template</option>";
                   }else{
                   $templates_html .= "<option value=\"$single_template\">$single_template</option>";
                   }

                }
        }
        $templates_html .= "</select>";

//Gather the Categories
    $cat_lines = file("./data/category.db.php");
    if($cat_lines){
            $cat_html = "<select style='display:;' name=w_category[] id=category multiple>";
    foreach($cat_lines as $single_line){
            $cat_arr = explode("|", $single_line);
            $cat_html .= "<option value=\"$cat_arr[0]\">(ID:$cat_arr[0]) $cat_arr[1]</option>\n";
    }
            $cat_html .= "</select><br><label for=allcategory><input id=allcategory onClick=\"if(this.checked){getElementById('category').style.display='none';}else{getElementById('category').style.display='';}\" type=checkbox value='yes' name='w_allcategory'> Or Show from All Categories</label>";
    }else{
            $cat_html = "You have no categories";
    }

echoheader("wizard", "News Integration Wizard");

echo<<<WIZARDHTML
<table border=0 cellpading=0 cellspacing=0 width=100% height=100%><form method="post" action="$PHP_SELF"><tr><td >

<table cellspacing="0" cellpadding="3" width="645" height="100%" border="0" style="border-collapse: collapse" bordercolor="#111111"><tr>
  <td width="639" colspan="2">



Welcome to the News Integration Wizard. This tool will help you to integrate the
news that you have published using CuteNews, into your existing Webpage. <br>
&nbsp;</td></tr>
  <tr>
    <td bgcolor="#F7F6F4" style="padding:3px; border-bottom:1px solid gray;" width="639" colspan="2">
<b><font size="2">Quick Customization...</font></b></td>
  </tr>
  <tr>
    <td width="356" >



<b><br>



Number of Active News to Display:</b></td>
    <td width="277" rowspan="2"  valign="top" align="center">



<br>
<input style="text-align: center" name="w_number" size="11"></td>
  </tr>
  <tr>
    <td width="356" style="padding-left:10px;  ">



<p align="justify"><i>if the active news are less then the specified number to show, the rest of the
news will be fetched from the archives (if any)</i></td>
  </tr>
  <tr>
    <td width="356" >



<b><br>
Template to Use When Displaying News:</b></td>
    <td width="277" rowspan="2"  valign="top" align="center">



<br>
$templates_html

</td>
  </tr>
  <tr>
    <td width="356" style="padding-left:10px;  ">



<p align="justify"><i>using different templates you can customize the look of
your news, comments etc.</i></td>
  </tr>
  <tr>
    <td width="356" >



<b><br>
Categories to Show News From:</b></td>
    <td width="277" rowspan="2"  valign="top" align="center">



<br>
$cat_html
</td>
  </tr>
  <tr>
    <td width="356" style="padding-left:10px;  ">



<p align="justify"><i>you can specify only from which categories news will be
displayed, hold CTRL to select multiple categories (if any)<br>
&nbsp;</i></td>
  </tr>
  <tr>
    <td bgcolor="#F7F6F4" style="padding:3px; border-bottom:1px solid gray; " width="639" colspan="2">
<b><font size="2">Advanced Settings...</font></b></td>
  </tr>
  <tr>
    <td width="356" >



<b><br>
Start 'Displaying' From...</b></td>
    <td width="277" rowspan="2"  align="center" valign="top">



<br>
<input name="w_start_from" size="11" style="text-align: center"></td>
  </tr>
  <tr>
    <td width="356" style="padding-left:10px;  ">



<i>if Set, the displaying of the news will be started from the specified number
(eg. if set to 2 - the first 2 news will be skipped and the rest shown)</i></td>
  </tr>
  <tr>
    <td width="356" >



<b><br>
Reverse News Order:</b></td>
    <td width="277" rowspan="2"  align="center" valign="top">



<br>
&nbsp;<input type=checkbox value="yes" name="w_reverse"></td>
  </tr>
  <tr>
    <td width="356" style="padding-left:10px;  ">



<i>if Yes, the order of which the news are shown will be reversed</i></td>
  </tr>
  <tr>
    <td width="356" >



<b><br>
Show Only Active News:</b></td>
    <td width="277" rowspan="2"  align="center" valign="top">



<br>
<input type=checkbox value="yes" name="w_only_active"></td>
  </tr>
  <tr>
    <td width="356" style="padding-left:10px;  ">



<i>if Yes, even if the number of news you requested to be shown is bigger than
all active news, no news from the archives will be shown</i></td>
  </tr>
  <tr>
    <td width="356">



<b><br>
Static Include:</b></td>
    <td width="277" rowspan="2" align="center" valign="top">



<br>
<input type=checkbox value="yes" name="w_static"></td>
  </tr>
  <tr>
    <td width="356" style="padding-left:10px;">



<i>if Yes, the news will be displayed but will not show the full story and
comment pages when requested. useful for <a href=# onclick="javascript:Help('multiple_includes')">multiple includes</a>.</i></td>
  </tr>
  <tr>
    <td width="639" colspan="2">



&nbsp;</td>
  </tr>
  <tr>
    <td width="639" colspan="2" style="border-top:1px solid gray; padding-top:10px;">

<center><input type=submit style="font-weight:bold;" value="Proceed to Integration >>"></center>

&nbsp;</td>
  </tr>
</table>

<input type=hidden name=mod value=wizards>
<input type=hidden name=action value=news_step2>

</td></tr></form></table>
WIZARDHTML;

echofooter();
}
// ********************************************************************************
// Show The News Integration Code
// ********************************************************************************
if($action == "news_step2"){
echoheader("wizard", "News Integration");

$the_code = '&lt;?PHP'."\n";

// Try to determine include path
$include_path = dirname(dirname(__FILE__)) .'/show_news.php';


if($w_number and $w_number != ''){
   $the_code .= '$number='.$w_number.";\n";
}


if($w_template != 'Default'){
   $the_code .= '$template="'.$w_template."\";\n";
}


// Get ready with Categories (if any)
if($w_allcategory != 'yes'  and isset($w_category) and $w_category != ''){
   $i=0;
   foreach($w_category as $category){
          $i++;
          $my_category .= "$category";
          if(count($w_category) != $i){ $my_category .= ','; }
   }
   if(count($w_category) > 1){ $the_code .= '$category="'.$my_category."\";\n"; }
   else{ $the_code .= '$category='.$my_category.";\n"; }
}


if($w_reverse == 'yes'){
   $the_code .= "\$reverse=TRUE;\n";
}

if($w_only_active == 'yes'){
   $the_code .= "\$only_active=TRUE;\n";
}

if($w_static == 'yes'){
   $the_code .= "\$static=TRUE;\n";
}

if($w_start_from and $w_start_from != ''){
   $the_code .= "\$start_from=$w_start_from;\n";
}

$the_code .= "include(\"$include_path\");\n?&gt;";
echo"CuteNews determined your full path to show_news.php to be: '<b>$include_path</b>'<br>
If for some reasons the include path is incorrect or does not work, please determine<br>
the relative path for including <i>show_news.php</i> yourself or
consult your administrator.<br>
<br>
<center>To show your news, insert (copy & paste) the code into some of your pages (*.php) :<br><br>
<textarea style='sfont-weight:bold;' cols=70 rows=10>$the_code</textarea></center><br>";


echofooter();
}
// ********************************************************************************
// Initiate the RSS Wizard
// ********************************************************************************
if($action == "rss"){
echoheader("wizard", "RSS Set-Up Wizard");

echo"Rich Site Summary (sometimes referred to as Really Simple Syndication);<br>
RSS allows a web developer to share the content on his/her site. RSS repackages the web content <br>
as a list of data items, to which you can subscribe from a directory of RSS publishers. <br>
RSS 'feeds' can be read with a web browser or special RSS reader called a content aggregator.
<br><br><input onClick=\"document.location='$PHP_SELF?mod=wizards&action=rss_step2';\" type=button value='Proceed with RSS Configuration >>'><br><br>
";

echofooter();
}
// ********************************************************************************
// Show the RSS config
// ********************************************************************************
if($action == "rss_step2"){
include("./data/rss_config.php");

if($rss_language == '' or !$rss_language){ $rss_language = 'en-us'; }
if($rss_encoding == '' or !$rss_encoding){ $rss_encoding = 'UTF-8'; }

echoheader("wizard", "RSS Configuration");
echo<<<HTML

    <table border=0 height=1 width=617 cellspacing="0" cellpadding="0">
     <form method=POST action="index.php">
     <td height="21" width=400 bgcolor=#F7F6F4 >
         &nbsp;<b>URL of the page where you include your news</b><br>
         &nbsp;<i>example: http://mysite.com/news.php</i><br>
         &nbsp;<i>or: $config_http_script_dir/example2.php</i>
     <td height="21"  bgcolor=#F7F6F4 colspan=2>
     <input name="rss_news_include_url" value="$rss_news_include_url" type=text size=30>
     <tr>

     <td height="21" >
     <br>
         &nbsp;Title of the RSS feed
     <td height="21" colspan=2>
     <br>
     <input name="rss_title" value="$rss_title" size=30 >
     </tr>


     <tr>
     <td height="21" bgcolor=#F7F6F4 >
     <br>
         &nbsp;Character Encoding (default: <i>UTF-8</i>)
     <td height="21" colspan=2 bgcolor=#F7F6F4 >
     <br>
          <input name="rss_encoding" value="$rss_encoding" size=20 >
     </tr>



     <tr>
     <td height="21" >
     <br>
         &nbsp;Language (default: <i>en-us</i>)
     <td height="21">
     <br>
          <input name="rss_language" value="$rss_language" size=5 >
     </tr>


     <tr>
     <td height="1" colspan="2" colspan=3>
     <br /><br><input type=submit style="font-weight:bold; font-size:110%;" value="Save Configurations and Proceed >>" accesskey="s"> &nbsp;
     <input style="font-size:90%;" onClick="document.location='$PHP_SELF?mod=wizards&action=customizerss';" type=button value='Skip to Customization >>'>
     </tr>

     <input type=hidden name=mod value=wizards>
     <input type=hidden name=action value=dosaverss>
     </form>
     </table>



HTML;

echofooter();
}

// ********************************************************************************
// Save the RSS Configuration
// ********************************************************************************
if($action == "dosaverss"){
if(!eregi("http://", "$rss_news_include_url")){ msg("error","Error", "The URL where you include your news must start with <b>http://</b> "); }

    $handler = fopen("./data/rss_config.php", "w") or msg("error", "Error", "Can not open file ./data/rss_config.php");
    fwrite($handler, "<?PHP \n\n//RSS Configurations (Auto Generated file)\n\n");

    fwrite($handler, "\$rss_news_include_url = \"".htmlspecialchars($rss_news_include_url)."\";\n\n");
    fwrite($handler, "\$rss_title = \"".htmlspecialchars($rss_title)."\";\n\n");
    fwrite($handler, "\$rss_encoding = \"".htmlspecialchars($rss_encoding)."\";\n\n");
    fwrite($handler, "\$rss_language = \"".htmlspecialchars($rss_language)."\";\n\n");

    fwrite($handler, "?>");
    fclose($handler);

    msg("wizard", "RSS Configuration Saved", "The configurations were saved successfuly.<br><br><input onClick=\"document.location='$PHP_SELF?mod=wizards&action=customizerss';\" type=button value='Proceed With RSS Customization >>'>");
}
// ********************************************************************************
// Save the RSS Configuration
// ********************************************************************************
if($action == "customizerss"){
echoheader("wizard", "RSS Customization");


//
// Detect the categories (if any)
//
   $cat_lines = file("./data/category.db.php");
   if(count($cat_lines) > 0){
           $cat_options .= "<select style=\"\" id=categories multiple size=5>   \n";
           foreach($cat_lines as $single_line){
                   $cat_arr = explode("|", $single_line);
                   $cat_options .= "<option value=\"$cat_arr[0]\">(ID:$cat_arr[0]) $cat_arr[1]</option>\n";
           }
       $cat_options .= "</select> <br><label for=allcategories><input onClick=\"if(this.checked){getElementById('categories').style.display='none';}else{getElementById('categories').style.display='';}\" type=checkbox id=allcategories value=yes>Or show from all Categories</label>";
   }else{
       $cat_options = "You do not have any categories. <input type=hidden id=categories><input type=hidden id=allcategories>";
   }





//
// Show the HTML
//
echo<<<HTMLECHO
<SCRIPT type="text/javascript">
function generateCode(){
sbox = document.getElementById('categories');
var categoryString = '';
var firstDone = 0;

        for (var i=0; i<sbox.length; i++) {
                        if (sbox[i].selected) {

                                if(firstDone == 1){ categoryString = categoryString + ','; }
                                categoryString = categoryString + sbox[i].value;

                                firstDone = 1;

                        }
        }

var number = document.getElementById('number').value;

var string = '$config_http_script_dir/rss.php';

if(document.getElementById('allcategories').checked || categoryString == ''){
        if(number != ''){ string += '?number='+number; }

}else{
         string += '?category=' + categoryString;
        if(number != ''){ string += '&number='+number; }
}



//alert(string);

var htmlcode = '<a title="RSS Feed" href="' + string + '">\\n<img src="$config_http_script_dir/skins/images/rss_icon.gif" border=0  />\\n</a>';

document.getElementById('result').value = htmlcode;


}

</SCRIPT>

<table cellspacing="0" cellpadding="5" width="647" height="100%" border="0" style="border-collapse: collapse" bordercolor="#111111"><tr>
  <td width="647" colspan="3">After You have configured your RSS options, the
  RSS feed is ready to be used.<br>
  <br>
  URL Address of your RSS: <b><a href="$config_http_script_dir/rss.php">
  $config_http_script_dir/rss.php</a><br>
&nbsp;</b></td></tr>
  <tr>
    <td bgcolor="#F7F6F4" style="border-bottom:1px solid gray;" width="647" colspan="3"><b><font size="2">&nbsp;Customizing
    your RSS feed:</font></b></td>
  </tr>
  <tr>
    <td width="647" colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td width="58">&nbsp;</td><td width="393">Number of articles to be shown in
    the RSS (default:10):</td><td width="196"><input id=number size=5 type="text" size="20"></td>
  </tr>
  <tr>
    <td width="58">&nbsp;</td><td width="393">Show articles only from these
    categories:</td><td width="196">






$cat_options





    </td>
  </tr>
  <tr>
    <td colspan="3" style="padding:40px;">After you have selected your preferred settings, click the
    'Generate HTML Code' button and you are ready to insert this code into your
    page. The generated code will be of a linked RSS image that will be pointing
    to your RSS feed (rss.php).

    </td>
  </tr>
  <tr>
    <td width="647" colspan="3">
    <p align="center">
    <input type=button value="Generate HTML Code" onClick="generateCode();" style="font-weight: bold; font-size:120%;" ><br>
    <br>
    <textarea id=result rows="5" cols="100"></textarea> </td>
  </tr>
  <tr>
    <td width="647" colspan="3">&nbsp;</td>
  </tr>
</table>
HTMLECHO;

echofooter();
}

?>