Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 jpm 1
<?
2
//------------------------------------------------------------------------------
3
// FICHIER : $RCSfile: page.php,v $
4
// AUTEUR  : $Author: jpm $
5
// VERSION : $Revision: 1.1 $
6
// DATE    : $Date: 2004-06-16 15:04:58 $
7
//------------------------------------------------------------------------------
8
// GSite - Web site management in PHP - documents application
9
//
10
// Copyright (C) 2001 COUDOUNEAU Laurent (lc@gsite.org)
11
//
12
// This library is free software; you can redistribute it and/or
13
// modify it under the terms of the GNU Lesser General Public
14
// License as published by the Free Software Foundation; either
15
// version 2.1 of the License, or (at your option) any later version.
16
//
17
// This library is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
// Lesser General Public License for more details.
21
//
22
// You should have received a copy of the GNU Lesser General Public
23
// License along with this library; if not, write to the Free Software
24
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
//------------------------------------------------------------------------------
26
//------------------------------------------------------------------------------
27
 
28
//==============================================================================
29
//==============================================================================
30
 
31
function listPages ($db, $project, $locale,
32
                    $baseURL, $baseURLjs, $baseHidden,
33
                    $adminProject, $adminLocale, $adminAnnu,
34
                    $userLevel,
35
                    $menu1id, $menu2id, $upperid, $docid, $pageid,
36
                    $doccmd,
37
                    $menuview, $menu1open, $menu2open, $upperopen, $docopen, $pageopen,
38
                    $parentDocId) {
39
  //----------------------------------------------------------------------------
40
  // Labels.
41
 
42
  $cancelLabel  = "Annuler";
43
  $showLabel    = "Modifier le document";
44
  $deleteLabel  = "Supprimer";
45
  $addPageLabel = "Ajouter une page";
46
  $docLabel     = "Modifier les paragraphes associés";
47
 
48
  //----------------------------------------------------------------------------
49
  // Build full URL.
50
 
51
  $fullURL =
52
    $baseURL.
53
    '&amp;menuview='.$menuview.
54
    '&amp;menu1id='.$menu1id.
55
    '&amp;menu1open='.$menu1open.
56
    '&amp;menu2id='.$menu2id.
57
    '&amp;menu2open='.$menu2open.
58
    '&amp;upperid='.$upperid.
59
    '&amp;upperopen='.$upperopen;
60
 
61
  $fullURLjs =
62
    $baseURLjs.
63
    '&menuview='.$menuview.
64
    '&menu1id='.$menu1id.
65
    '&menu1open='.$menu1open.
66
    '&menu2id='.$menu2id.
67
    '&menu2open='.$menu2open.
68
    '&upperid='.$upperid.
69
    '&upperopen='.$upperopen;
70
 
71
  //----------------------------------------------------------------------------
72
  // Javascript.
73
 
74
  $goMsg = addslashes ("Supprimer");
75
 
76
  js_register ('deletePage',
77
    "  function deletePage (iDocId, iPageId) {"."\n".
78
    "    var url = '$fullURLjs'+'&doccmd=delpage&docopen=1&docid='+iDocId+'&pageid='+iPageId;"."\n".
79
    "    if (window.confirm ('$goMsg')) document.location = url;"."\n".
80
    "  }"."\n"
81
  );
82
 
83
  js_register ('openUpdatePar',
84
    "  function openUpdatePar (sURL, iWidth, iHeight) {"."\n".
85
    "    var sArgs = 'toolbar=0'+"."\n".
86
    "                ',hotkeys=0'+"."\n".
87
    "                ',location=1'+"."\n".
88
    "                ',directories=0'+"."\n".
89
    "                ',menubar=0'+"."\n".
90
    "                ',personalbar=0'+"."\n".
91
    "                ',status=1'+"."\n".
92
    "                ',scrollbars=1'+"."\n".
93
    "                ',resizable=1'+"."\n".
94
    "                ',screenX=150'+"."\n".
95
    "                ',screenY=20'+"."\n".
96
    "                ',left=150'+"."\n".
97
    "                ',top=20'+"."\n".
98
    "                ',width='+iWidth+"."\n".
99
    "                ',height='+iHeight;"."\n".
100
    "\n".
101
    "    var wWindow = open (sURL, 'updpar', sArgs);"."\n".
102
    "    wWindow.window.focus ();"."\n".
103
    "  }"."\n"
104
  );
105
 
106
  js_register ('updatePar',
107
    "  function updatePar (iDocId, iPageId) {"."\n".
108
    "    var swidth  = screen.width;"."\n".
109
    "    var width   = swidth * 0.80;"."\n".
110
    "    var height  = width  * 0.75;"."\n".
111
    "\n".
112
    "    var popsize = 0;"."\n".
113
    "\n".
114
    "    if (swidth >=  640) popsize = 0;"."\n".
115
    "    if (swidth >=  800) popsize = 1;"."\n".
116
    "    if (swidth >= 1024) popsize = 2;"."\n".
117
    "    if (swidth >= 1280) popsize = 3;"."\n".
118
    "    if (swidth >= 1600) popsize = 4;"."\n".
119
    "\n".
120
    "    var sURL ="."\n".
121
    "       'noyau/applications_noyau/documents/docpopup.php'+"."\n".
122
    "       '?project=$project'+"."\n".
123
    "       '&module=documents%2Fdocpopup'+"."\n".
124
    "       '&popsize='+popsize+"."\n".
125
    "       '&docid='+iDocId+"."\n".
126
    "       '&pageid='+iPageId+"."\n".
127
    "       '&admannu=$adminAnnu'+"."\n".
128
    "       '&admproject=$adminProject'+"."\n".
129
    "       '&admlocale=$adminLocale';"."\n".
130
    "    "."\n".
131
    "    openUpdatePar (sURL, width, height)"."\n".
132
    "  }"."\n"
133
  );
134
 
135
  //----------------------------------------------------------------------------
136
  // Begin of pages table.
137
 
138
  $outputText = '';
139
 
140
  $outputText .= "\n".'<TABLE summary="" cellspacing="3" cellpadding="0" border="0">';
141
 
142
  //----------------------------------------------------------------------------
143
  // Dump admin icons.
144
 
145
  $pagesMainIcons = '';
146
 
147
  $pagesMainIcons .=
148
    "\n".
149
    '<A href="'.$fullURL.'&amp;docid='.$parentDocId.'&amp;docopen=1&amp;doccmd=addpage">'.
150
    '<IMG src="noyau/applications_noyau/documents/presentations/images/addcross.gif" alt="'.$addPageLabel.'" width="16" height="16" border="0">'.
151
    '</A>';
152
 
153
  $outputText .= "\n".'      <TR>';
154
  $outputText .= "\n".'        <TD colspan="9" align="left" valign="middle">'.$pagesMainIcons.'</TD>';
155
  $outputText .= "\n".'      </TR>';
156
 
157
  //----------------------------------------------------------------------------
158
  // Get pages.
159
 
160
  $query =
161
    "select * from GEN_PAGE".
162
    " where GP_ID_DOCUMENT=$parentDocId".
163
    " order by GP_ORDRE";
164
 
165
  $PAGEresult = $db->query ($query);
166
 
167
  if (DB::isError ($PAGEresult)) {
168
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
169
  }
170
 
171
  //----------------------------------------------------------------------------
172
  // Dump pages.
173
 
174
  while ($PAGErow = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT)) {
175
    //--------------------------------------------------------------------------
176
    // Page open ?
177
 
178
    /*
179
    To manage only one page...
180
    $pageIsOpen = ($pageopen == 1) && ($PAGErow->GP_ID == $pageid);
181
    */
182
 
183
    $pageIsOpen = true;
184
 
185
    //--------------------------------------------------------------------------
186
    // Get page data.
187
 
188
    $title = htmlentities ($PAGErow->GP_TITRE);
189
    $id    = ($userLevel == level_admin ? '('.$PAGErow->GP_ID.')&nbsp;': '');
190
    $appl  = htmlentities ($PAGErow->GP_APPLICATION);
191
    $args1 = htmlentities ($PAGErow->GP_ARGUMENT);
192
 
193
    if (strlen ($PAGErow->GP_ARGUMENT) > 40) {
194
      $args2 = htmlentities (substr ($PAGErow->GP_ARGUMENT, 0, 40)).'&nbsp;...';
195
 
196
    } else if ($PAGErow->GP_ARGUMENT == '') {
197
      $args2 = '(...)';
198
 
199
    } else {
200
      $args2 = $args1;
201
    }
202
 
203
    //-- Icons.
204
    $icons1 = '&nbsp;&nbsp;';
205
    $icons2 = '&nbsp;&nbsp;';
206
    $icons3 = '&nbsp;&nbsp;';
207
 
208
    //-- URL to go back to this page.
209
    $pageHREF =
210
      $fullURL.
211
      '&amp;docid='.$parentDocId.
212
      '&amp;docopen='.$docopen.
213
      '&amp;pageid='.$PAGErow->GP_ID;
214
 
215
    //-- Less or more icon.
216
 
217
    $pageOpenHREF = $pageHREF;
218
    $lessOrMore   = '';
219
 
220
    //--------------------------------------------------------------------------
221
    // Switch page command...
222
 
223
    if (($doccmd == 'updpagetitle') && ($PAGErow->GP_ID == $pageid)) {
224
      //------------------------------------------------------------------------
225
      // Update page title.
226
 
227
      //-- Page title.
228
      $title =
229
        '<INPUT type="text" name="page_title" size="30" maxlength="48" value="'.$title.'" class="contentDocument">'.
230
        '<INPUT type="hidden" name="doccmd" value="commitupdpagetitle">';
231
 
232
      //-- Page application.
233
      $appl =
234
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageappl" class="anchor">'.
235
        ($PAGErow->GP_APPLICATION == '' ? '(...)' : $appl).
236
        '</A>';
237
 
238
      //-- Application arguments.
239
      $args =
240
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageargs" class="anchor">'.
241
        $args2.
242
        '</A>';
243
 
244
      //-- Cancel and update icons.
245
      $icons1 .=
246
        '<INPUT type="image" src="Local/icons/validate.gif">';
247
 
248
      $icons1 .=
249
        '<A'."\n".'href="'.$pageOpenHREF.'">'.
250
        '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0"></A>';
251
 
252
    } else if (($doccmd == 'updpageappl') && ($PAGErow->GP_ID == $pageid)) {
253
      //------------------------------------------------------------------------
254
      // Update page application.
255
 
256
      //-- Page title.
257
      $title =
258
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpagetitle" class="anchor">'.
259
        ($PAGErow->GP_TITRE == '' ? '(...)' : $title).
260
        '</A>';
261
 
262
      //-- Page application.
263
      $appl =
264
        '<INPUT type="text" name="page_appl" size="10" maxlength="32" value="'.$appl.'" class="contentDocument">'.
265
        '<INPUT type="hidden" name="doccmd" value="commitupdpageappl">';
266
 
267
      //-- Application arguments.
268
      $args =
269
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageargs" class="anchor">'.
270
        $args2.
271
        '</A>';
272
 
273
      //-- Cancel and update icons.
274
      $icons2 .=
275
        '<INPUT type="image" src="noyau/applications_noyau/documents/presentations/images/validate.gif">';
276
 
277
      $icons2 .=
278
        '<A'."\n".'href="'.$pageOpenHREF.'">'.
279
        '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0"></A>';
280
 
281
    } else if (($doccmd == 'updpageargs') && ($PAGErow->GP_ID == $pageid)) {
282
      //------------------------------------------------------------------------
283
      // Update page arguments.
284
 
285
      //-- Page title.
286
      $title =
287
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpagetitle" class="anchor">'.
288
        ($PAGErow->GP_TITRE == '' ? '(...)' : $title).
289
        '</A>';
290
 
291
      //-- Page application.
292
      $appl =
293
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageappl" class="anchor">'.
294
        ($PAGErow->GP_APPLICATION == '' ? '(...)' : $appl).
295
        '</A>';
296
 
297
      //-- Application arguments.
298
      $args =
299
        '<INPUT type="text" name="page_args" size="48" maxlength="255" value="'.$args1.'" class="contentDocument">'.
300
        '<INPUT type="hidden" name="doccmd" value="commitupdpageargs">';
301
 
302
      //-- Cancel and update icons.
303
      $icons3 .=
304
        '<INPUT type="image" src="noyau/applications_noyau/documents/presentations/images/validate.gif">';
305
 
306
      $icons3 .=
307
        '<A'."\n".'href="'.$pageOpenHREF.'">'.
308
        '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0"></A>';
309
 
310
    } else {
311
      //------------------------------------------------------------------------
312
      // Show page data.
313
 
314
      $title =
315
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpagetitle" class="anchor">'.
316
        ($PAGErow->GP_TITRE == '' ? '(...)' : $title).
317
        '</A>';
318
 
319
      $appl =
320
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageappl" class="anchor">'.
321
        ($PAGErow->GP_APPLICATION == '' ? '(...)' : $appl).
322
        '</A>';
323
 
324
      $args =
325
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageargs" class="anchor">'.
326
        $args2.
327
        '</A>';
328
    }
329
 
330
    //--------------------------------------------------------------------------
331
    // Page admin icons.
332
 
333
    $icons4 = '';
334
 
335
    if ($pageIsOpen) {
336
      if ($PAGErow->GP_APPLICATION == 'txt') {
337
        $icons4 .=
338
          '<A'."\n".'href="javascript:updatePar ('.$parentDocId.', '.$PAGErow->GP_ID.')">'.
339
          '<IMG src="noyau/applications_noyau/documents/presentations/images/doc.gif" alt="'.$docLabel.'" width="16" height="16" border="0"></A>';
340
 
341
      } else {
342
        $icons4 .=
343
          '<IMG src="noyau/applications_noyau/documents/presentations/images/vide.gif" alt="" width="16" height="16" border="0">';
344
      }
345
 
346
      $icons4 .=
347
        '<A'."\n".'href="'.$pageOpenHREF.'&amp;doccmd=showpage">'.
348
        '<IMG src="noyau/applications_noyau/documents/presentations/images/see.gif" alt="'.$showLabel.'" width="16" height="16" border="0"></A>';
349
 
350
      $icons4 .=
351
        '<A'."\n".'href="'.$pageOpenHREF.'&amp;doccmd=uppage">'.
352
        '<IMG src="noyau/applications_noyau/documents/presentations/images/up-arrow.gif" alt="" width="16" height="16" border="0"></A>';
353
 
354
      $icons4 .=
355
        '<A'."\n".'href="'.$pageOpenHREF.'&amp;doccmd=dnpage">'.
356
        '<IMG src="noyau/applications_noyau/documents/presentations/images/down-arrow.gif" alt="" width="16" height="16" border="0"></A>';
357
 
358
      $icons4 .=
359
        '<A'."\n".'href="javascript:deletePage ('.$parentDocId.', '.$PAGErow->GP_ID.');">'.
360
        '<IMG src="noyau/applications_noyau/documents/presentations/images/trash.gif" alt="'.$deleteLabel.'" width="16" height="16" border="0"></A>';
361
    }
362
 
363
    //--------------------------------------------------------------------------
364
    // Dump page data.
365
 
366
    $outputText .= "\n".'  <TR>';
367
    $outputText .= "\n".'    <TD align="left" valign="middle" class="contentDocument">'.$lessOrMore.'</TD>';
368
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$title.'</TD>';
369
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons1.'</TD>';
370
    $outputText .= "\n".'    <TD align="right" valign="top" class="contentDocument">'.$id.'</TD>';
371
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$appl.'</TD>';
372
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons2.'</TD>';
373
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$args.'</TD>';
374
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons3.'</TD>';
375
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons4.'</TD>';
376
    $outputText .= "\n".'  </TR>';
377
  }
378
 
379
  //----------------------------------------------------------------------------
380
  // End of pages table.
381
 
382
  $outputText .= "\n".'</TABLE>';
383
 
384
  return $outputText;
385
}
386
 
387
//==============================================================================
388
//==============================================================================
389
 
390
function checkPage ($db, $docid, $pageid) {
391
  //----------------------------------------------------------------------------
392
  // Get page.
393
 
394
  $query = "select * from GEN_PAGE where GP_ID=$pageid";
395
 
396
  $PAGEresult = $db->query ($query);
397
 
398
  if (DB::isError($PAGEresult)) {
399
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
400
  }
401
 
402
  $PAGErow = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT);
403
 
404
  $PAGEresult->free() ;
405
 
406
  if (! $PAGErow) return null;
407
 
408
  //----------------------------------------------------------------------------
409
  // Page is OK ?
410
 
411
  if ($PAGErow->GP_ID_DOCUMENT != $docid) return null;
412
 
413
  return $PAGErow;
414
}
415
 
416
//==============================================================================
417
//==============================================================================
418
 
419
function addPage ($db,
420
                  $userLevel,
421
                  $docid) {
422
  //----------------------------------------------------------------------------
423
  // Check document.
424
 
425
  $DOCrow = checkDocument ($db, $userLevel, $docid);
426
  if (! $DOCrow) return;
427
 
428
  //----------------------------------------------------------------------------
429
  // Get max order.
430
 
431
  $query =
432
    "select GP_ORDRE from GEN_PAGE".
433
    " where GP_ID_DOCUMENT=$docid".
434
    " order by GP_ORDRE desc".
435
    " limit 1";
436
 
437
  $PAGEresult = $db->query ($query);
438
 
439
  if (DB::isError ($PAGEresult)) {
440
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
441
  }
442
 
443
  $row = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT);
444
 
445
  $maxOrder = ($PAGEresult->numRows() == 0 ? 1 : $row->GP_ORDRE + 1);
446
 
447
  $PAGEresult->free();
448
 
449
  //----------------------------------------------------------------------------
450
  // Add page.
451
 
452
  $query =
453
    "insert into GEN_PAGE set ".
454
    "GP_TITRE='?????'".
455
    ", GP_ID_DOCUMENT=$docid".
456
    ", GP_ORDRE=$maxOrder";
457
 
458
  $PAGEresult = $db->query ($query);
459
 
460
  if (DB::isError ($PAGEresult)) {
461
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
462
  }
463
}
464
 
465
//==============================================================================
466
//==============================================================================
467
 
468
function commitUpdatePageTitle ($db, $userLevel,
469
                                $docid, $pageid, $pageTitle) {
470
  //----------------------------------------------------------------------------
471
  // Check document.
472
 
473
  $DOCrow = checkDocument ($db, $userLevel, $docid);
474
  if (! $DOCrow) return;
475
 
476
  //----------------------------------------------------------------------------
477
  // Check page.
478
 
479
  $PAGErow = checkPage ($db, $docid, $pageid);
480
  if (! $PAGErow) return;
481
 
482
  //----------------------------------------------------------------------------
483
  // Update page title.
484
 
485
  $query = "update GEN_PAGE set GP_TITRE='$pageTitle' where GP_ID=$pageid";
486
 
487
  $PAGEresult = $db->query ($query);
488
 
489
  if (DB::isError ($PAGEresult)) {
490
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
491
  }
492
}
493
 
494
//==============================================================================
495
//==============================================================================
496
 
497
function commitUpdatePageApplication ($db, $userLevel,
498
                                      $docid, $pageid, $pageAppl) {
499
  //----------------------------------------------------------------------------
500
  // Check document.
501
 
502
  $DOCrow = checkDocument ($db, $userLevel, $docid);
503
  if (! $DOCrow) return;
504
 
505
  //----------------------------------------------------------------------------
506
  // Check page.
507
 
508
  $PAGErow = checkPage ($db, $docid, $pageid);
509
  if (! $PAGErow) return;
510
 
511
  //----------------------------------------------------------------------------
512
  // Update page title.
513
 
514
  $query = "update GEN_PAGE set GP_APPLICATION='$pageAppl' where GP_ID=$pageid";
515
 
516
  $PAGEresult = $db->query ($query);
517
 
518
  if (DB::isError ($PAGEresult)) {
519
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
520
  }
521
}
522
 
523
//==============================================================================
524
//==============================================================================
525
 
526
function commitUpdatePageArguments ($db, $userLevel,
527
                                    $docid, $pageid, $pageArgs) {
528
  //----------------------------------------------------------------------------
529
  // Check document.
530
 
531
  $DOCrow = checkDocument ($db, $userLevel, $docid);
532
  if (! $DOCrow) return;
533
 
534
  //----------------------------------------------------------------------------
535
  // Check page.
536
 
537
  $PAGErow = checkPage ($db, $docid, $pageid);
538
  if (! $PAGErow) return;
539
 
540
  //----------------------------------------------------------------------------
541
  // Update page title.
542
 
543
  $query = "update GEN_PAGE set GP_ARGUMENT='$pageArgs' where GP_ID=$pageid";
544
 
545
  $PAGEresult = $db->query ($query);
546
 
547
  if (DB::isError ($PAGEresult)) {
548
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
549
  }
550
}
551
 
552
//==============================================================================
553
//==============================================================================
554
 
555
function movePage ($db, $userLevel,
556
                   $docid, $pageid,
557
                   $up) {
558
  //----------------------------------------------------------------------------
559
  // Check document.
560
 
561
  $DOCrow = checkDocument ($db, $userLevel, $docid);
562
  if (! $DOCrow) return;
563
 
564
  //----------------------------------------------------------------------------
565
  // Check page.
566
 
567
  $PAGErow = checkPage ($db, $docid, $pageid);
568
  if (! $PAGErow) return;
569
 
570
  //----------------------------------------------------------------------------
571
  // Get previous page.
572
 
573
  $query =
574
    "select * from GEN_PAGE".
575
    " where GP_ID_DOCUMENT=$docid".
576
    ($up
577
    ? " and GP_ORDRE < $PAGErow->GP_ORDRE order by GP_ORDRE desc"
578
    : " and GP_ORDRE > $PAGErow->GP_ORDRE order by GP_ORDRE asc");
579
 
580
  $PAGEresult = $db->query ($query);
581
 
582
  if (DB::isError ($PAGEresult)) {
583
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
584
  }
585
 
586
  $NEXTPAGErow = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT);
587
 
588
  $PAGEresult->free() ;
589
 
590
  //----------------------------------------------------------------------------
591
  // Update pages.
592
 
593
  if (! $NEXTPAGErow) return;
594
 
595
  $query =
596
    "update GEN_PAGE ".
597
    "set GP_ORDRE=$NEXTPAGErow->GP_ORDRE".
598
    " where GP_ID=$PAGErow->GP_ID";
599
 
600
  $result = $db->query ($query);
601
 
602
  if (DB::isError ($result)) {
603
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
604
  }
605
 
606
  $query =
607
    "update GEN_PAGE ".
608
    "set GP_ORDRE=$PAGErow->GP_ORDRE".
609
    " where GP_ID=$NEXTPAGErow->GP_ID";
610
 
611
  $result = $db->query ($query);
612
 
613
  if (DB::isError ($result)) {
614
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
615
  }
616
}
617
 
618
//==============================================================================
619
//==============================================================================
620
 
621
function deletePage ($db, $locale,
622
                     $userLevel,
623
                     $docid, $pageid) {
624
  //----------------------------------------------------------------------------
625
  // Check document.
626
 
627
  $DOCrow = checkDocument ($db, $userLevel, $docid);
628
  if (! $DOCrow) return;
629
 
630
  //----------------------------------------------------------------------------
631
  // Check page.
632
 
633
  $PAGErow = checkPage ($db, $docid, $pageid);
634
  if (! $PAGErow) return;
635
 
636
  //----------------------------------------------------------------------------
637
  // We have linked paragraphs ?
638
 
639
  $query =
640
    "select count(P_INDEX) as COUNT ".
641
    "from txt_PARAGRAPH ".
642
    "where P_PAGE=$PAGErow->GP_ID";
643
 
644
  $result = $db->query ($query);
645
 
646
  if (DB::isError ($result)) {
647
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
648
  }
649
 
650
  $row = $result->fetchRow(DB_FETCHMODE_OBJECT);
651
 
652
  if ($row && ($row->COUNT > 0)) {
653
    return "Il reste des paragraphes attachés à cette page";
654
  }
655
 
656
  //----------------------------------------------------------------------------
657
  // Delete page.
658
 
659
  $query = "delete from GEN_PAGE where GP_ID=$PAGErow->GP_ID";
660
 
661
  $result = $db->query ($query);
662
 
663
  if (DB::isError ($result)) {
664
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
665
  }
666
 
667
  return '';
668
}
669
 
670
//==============================================================================
671
//==============================================================================
672
 
673
function showPage ($db, $locale,
674
                   $baseURL, $baseURLjs, $baseHidden,
675
                   $userLevel,
676
                   $menu1id, $menu2id, $upperid, $docid, $pageid,
677
                   $menuview, $menu1open, $menu2open, $upperopen, $docopen, $pageopen) {
678
  //----------------------------------------------------------------------------
679
  // Labels.
680
 
681
  $cancelLabel = "Supprimer";
682
 
683
  //----------------------------------------------------------------------------
684
  // Check document.
685
 
686
  $DOCrow = checkDocument ($db, $userLevel, $docid);
687
  if (! $DOCrow) return '';
688
 
689
  //----------------------------------------------------------------------------
690
  // Check page.
691
 
692
  $PAGErow = checkPage ($db, $docid, $pageid);
693
  if (! $PAGErow) return '';
694
 
695
  //----------------------------------------------------------------------------
696
  // Dump form.
697
 
698
  $outputText = '';
699
 
700
  $outputText .= "\n".'<TR>';
701
  $outputText .= "\n".'  <TD>';
702
  $outputText .= "\n".'    <FORM name="updform" action="index.php" method="POST">';
703
  $outputText .= "\n".'      <TABLE summary="" cellspacing="0" cellpadding="0" border="0" align="center">';
704
 
705
  $titleLabel = "Titre";
706
  $applLabel  = "Application";
707
  $argsLabel  = "Arguments";
708
  $setLabel   = "Set";
709
  $ndxLabel   = "Indexé";
710
 
711
  $outputText .= "\n".'<TR>';
712
  $outputText .= "\n".'  <TD class="contentLabel">'.$titleLabel.'&nbsp;:&nbsp;</TD>';
713
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
714
  $outputText .= "\n".'     class="contentInput" type="text" name="page_title" size="48" maxlength="48"';
715
  $outputText .= "\n".'     value="'.htmlentities ($PAGErow->GP_TITRE).'"></TD>';
716
  $outputText .= "\n".'</TR>';
717
 
718
  $outputText .= "\n".'<TR>';
719
  $outputText .= "\n".'  <TD class="contentLabel">'.$applLabel.'&nbsp;:&nbsp;</TD>';
720
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
721
  $outputText .= "\n".'     class="contentInput" type="text" name="page_appl" size="32" maxlength="32"';
722
  $outputText .= "\n".'     value="'.htmlentities ($PAGErow->GP_APPLICATION).'"></TD>';
723
  $outputText .= "\n".'</TR>';
724
 
725
  $outputText .= "\n".'<TR>';
726
  $outputText .= "\n".'  <TD class="contentLabel">'.$argsLabel.'&nbsp;:&nbsp;</TD>';
727
  $outputText .= "\n".'  <TD class="contentInput"><TEXTAREA';
728
  $outputText .= "\n".'     class="contentInput" name="page_args" rows="10" cols="64">'.htmlentities ($PAGErow->GP_ARGUMENT).'</TEXTAREA></TD>';
729
  $outputText .= "\n".'</TR>';
730
 
731
  $outputText .= "\n".'<TR>';
732
  $outputText .= "\n".'  <TD class="contentLabel">'.$setLabel.'&nbsp;:&nbsp;</TD>';
733
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
734
  $outputText .= "\n".'     class="contentInput" type="text" name="page_set" size="32" maxlength="32"';
735
  $outputText .= "\n".'     value="'.htmlentities ($PAGErow->GP_SET).'"></TD>';
736
  $outputText .= "\n".'</TR>';
737
 
738
  $outputText .= "\n".'<TR>';
739
  $outputText .= "\n".'  <TD class="contentLabel">'.$ndxLabel.'&nbsp;:&nbsp;</TD>';
740
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
741
  $outputText .= "\n".'     class="contentInput" type="checkbox" name="page_ndx"';
742
  if ($PAGErow->GP_INDEXE) $outputText .= "\n".'     checked';
743
  $outputText .= "\n".'     ></TD>';
744
  $outputText .= "\n".'</TR>';
745
 
746
  //----------------------------------------------------------------------------
747
  // Icons.
748
 
749
  $outputText .= "\n".'<TR><TD colspan="2">&nbsp;</TD></TR>';
750
 
751
  $closeURL =
752
    $baseURL.
753
    '&amp;menuview='.$menuview.
754
    '&amp;menu1id='.$menu1id.
755
    '&amp;menu1open='.$menu1open.
756
    '&amp;menu2id='.$menu2id.
757
    '&amp;menu2open='.$menu2open.
758
    '&amp;upperid='.$upperid.
759
    '&amp;upperopen='.$upperopen.
760
    '&amp;docid='.$docid.
761
    '&amp;pageid='.$pageid.
762
    '&amp;docopen='.$docopen.
763
    '&amp;pageopen='.$pageopen;
764
 
765
  $goIcon     = '<INPUT type="image" src="noyau/applications_noyau/documents/presentations/images/validate.gif">';
766
  $cancelIcon = '<A href="'.$closeURL.'">'.
767
                '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0">'.
768
                '</A>';
769
 
770
  $outputText .= "\n".'<TR>';
771
  $outputText .= "\n".'  <TD colspan="2" align="center"><TABLE summary="" width="100%" border="0" cellpadding="0" cellspacing="0">';
772
  $outputText .= "\n".'      <TR>';
773
  $outputText .= "\n".'        <TD align="center">'.$goIcon.'</TD>';
774
  $outputText .= "\n".'        <TD align="center">'.$cancelIcon.'</TD>';
775
  $outputText .= "\n".'      </TR>';
776
  $outputText .= "\n".'    </TABLE></TD>';
777
  $outputText .= "\n".'</TR>';
778
 
779
  $outputText .= "\n".'      </TABLE>';
780
 
781
  //----------------------------------------------------------------------------
782
  // Hidden values.
783
 
784
  $outputText .= "\n".'  <INPUT type="hidden" name="menuview"  value="'.$menuview.'">';
785
  $outputText .= "\n".'  <INPUT type="hidden" name="menu1id"   value="'.$menu1id.'">';
786
  $outputText .= "\n".'  <INPUT type="hidden" name="menu2id"   value="'.$menu2id.'">';
787
  $outputText .= "\n".'  <INPUT type="hidden" name="upperid"   value="'.$upperid.'">';
788
  $outputText .= "\n".'  <INPUT type="hidden" name="docid"     value="'.$docid.'">';
789
  $outputText .= "\n".'  <INPUT type="hidden" name="pageid"    value="'.$pageid.'">';
790
  $outputText .= "\n".'  <INPUT type="hidden" name="menu1open" value="'.$menu1open.'">';
791
  $outputText .= "\n".'  <INPUT type="hidden" name="menu2open" value="'.$menu2open.'">';
792
  $outputText .= "\n".'  <INPUT type="hidden" name="upperopen" value="'.$upperopen.'">';
793
  $outputText .= "\n".'  <INPUT type="hidden" name="docopen"   value="'.$docopen.'">';
794
  $outputText .= "\n".'  <INPUT type="hidden" name="pageopen"  value="'.$pageopen.'">';
795
  $outputText .= "\n".'  <INPUT type="hidden" name="doccmd"   value="commitupdpage">';
796
  $outputText .= $baseHidden;
797
 
798
  $outputText .= "\n".'    </FORM>';
799
  $outputText .= "\n".'  </TD>';
800
  $outputText .= "\n".'</TR>';
801
 
802
  return $outputText;
803
}
804
 
805
//==============================================================================
806
//==============================================================================
807
 
808
function commitUpdatePage ($db, $userLevel,
809
                           $docid, $pageid) {
810
  //----------------------------------------------------------------------------
811
  // Check document.
812
 
813
  $DOCrow = checkDocument ($db, $userLevel, $docid);
814
  if (! $DOCrow) return;
815
 
816
  //----------------------------------------------------------------------------
817
  // Check page.
818
 
819
  $PAGErow = checkPage ($db, $docid, $pageid);
820
  if (! $PAGErow) return;
821
 
822
  //----------------------------------------------------------------------------
823
  // Update page.
824
 
825
  global $page_title;
826
  global $page_appl;
827
  global $page_args;
828
  global $page_set;
829
  global $page_ndx;
830
 
831
  $pageindexed = (isset ($page_ndx) ? 1 : 0);
832
 
833
  $query =
834
    "update GEN_PAGE ".
835
    "set GP_TITRE='$page_title'".
836
    ", GP_APPLICATION='$page_appl'".
837
    ", GP_ARGUMENT='$page_args'".
838
    ", GP_SET='$page_set'".
839
    ", GP_INDEXE=$pageindexed".
840
    " where GP_ID=$pageid";
841
 
842
  $result = $db->query ($query);
843
 
844
  if (DB::isError ($result)) {
845
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
846
  }
847
}
848
 
849
 
850
?>