|
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * Add default templates including default system template |
4 | | - * |
5 | 4 | */ |
6 | | -echo '<h2>'.s('Default templates suit').'</h2>'; |
7 | 5 |
|
| 6 | +/** |
| 7 | + * Define template contents |
| 8 | + */ |
8 | 9 | $systemTemplate = <<<EOD |
9 | 10 | <div style="margin:0; text-align:center; width:100%; background:#EEE;min-width:240px;height:100%;"><br /> |
10 | 11 | <div style="width:96%;margin:0 auto; border-top:6px solid #369;border-bottom: 6px solid #369;background:#DEF;" > |
|
406 | 407 | </html> |
407 | 408 | EOD; |
408 | 409 |
|
409 | | -echo formStart(); |
410 | | -echo ' |
411 | | - <div> |
412 | | - <input type="radio" name="template" value="systemTemplate" checked>System template<br> |
413 | | - <input type="radio" name="template" value="templateWithLogo">Template with logo<br> |
414 | | - <input type="radio" name="template" value="simpleResponsiveTemplate">Simple responsive template<br> |
415 | | - <input type="submit" value="Select" name="Submit"> |
416 | | - </form> |
417 | | -</div>'; |
418 | | - |
| 410 | +/** |
| 411 | + * Handle requests to add template |
| 412 | + */ |
419 | 413 | if (isset($_POST['Submit'])) { |
420 | 414 | $radioVal = $_POST['template']; |
421 | 415 | switch ($radioVal) { |
|
432 | 426 | $content = $simpleResponsiveTemplate; |
433 | 427 | break; |
434 | 428 | } |
435 | | - $exists = Sql_Fetch_Row_Query(sprintf('select * from %s where title = "%s"', |
436 | | - $GLOBALS['tables']['template'], $title)); |
| 429 | + $exists = Sql_Fetch_Row_Query(sprintf(' |
| 430 | + select |
| 431 | + * |
| 432 | + from |
| 433 | + %s |
| 434 | + where |
| 435 | + title = "%s"' |
| 436 | + , $GLOBALS['tables']['template'] |
| 437 | + , $title |
| 438 | + )); |
| 439 | + $messages = '<div class="actionresult alert alert-info">'; |
437 | 440 | if ($exists[0]) { |
438 | | - echo '<p>' . s('This default template already exists') . '</p>'; |
439 | | - echo '<p>' . PageLinkButton('templates', s('Go back to templates')) . '</p>'; |
| 441 | + $messages .= s('This default template already exists'); |
| 442 | + $messages .= '</div>'; |
| 443 | + echo $messages; |
| 444 | + echo '<p>'; |
| 445 | + echo PageLinkButton('templates', s('Go back to templates')); |
| 446 | + echo '</p>'; |
440 | 447 | } else { |
441 | 448 | Sql_Query(sprintf('insert into %s (title,template,listorder) values("%s","%s",0)', |
442 | 449 | $GLOBALS['tables']['template'], $title, addslashes($content))); |
443 | 450 | $newid = Sql_Insert_Id(); |
444 | 451 | if ($title === 'System Template') { |
445 | 452 | saveConfig('systemmessagetemplate', $newid); |
446 | 453 | } |
447 | | - echo '<p>' . s('The selected default template has been added as template with ID') . ' ' . $newid . ' </p>'; |
448 | | - echo '<p>' . PageLinkButton('templates', s('Go back to templates')) . '</p>'; |
449 | | - echo '<p>' . PageLinkButton('template&id=' . $newid, s('Edit the added template')) . '</p>'; |
| 454 | + $messages .= s('The selected default template has been added as template with ID') . ' ' . $newid . ' '; |
| 455 | + $messages .= '</div>'; |
| 456 | + echo $messages; |
| 457 | + echo '<p>'; |
| 458 | + echo '' . PageLinkButton('templates', s('Go back to templates')) . ''; |
| 459 | + echo '' . PageLinkButton('template&id=' . $newid, s('Edit the added template')) . ''; |
| 460 | + echo '</p>'; |
450 | 461 | } |
451 | 462 | } |
| 463 | + |
| 464 | +/** |
| 465 | + * Print page contents |
| 466 | + */ |
| 467 | +echo '<h2>'.s('Default templates suit').'</h2>'; |
| 468 | + |
| 469 | +echo formStart(); |
| 470 | +echo ' |
| 471 | + <div> |
| 472 | + <input type="radio" name="template" value="systemTemplate" checked>System template<br> |
| 473 | + <input type="radio" name="template" value="templateWithLogo">Template with logo<br> |
| 474 | + <input type="radio" name="template" value="simpleResponsiveTemplate">Simple responsive template<br> |
| 475 | + <input type="submit" value="Select" name="Submit"> |
| 476 | + </form> |
| 477 | +</div>'; |
0 commit comments