From f6e06da4c68917dafb057bf7fe19f884a3e148c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 4 Jan 2015 20:41:04 +0100 Subject: [ticket/13455] Update calls to `request_var()` PHPBB3-13455 --- phpBB/phpbb/captcha/plugins/captcha_abstract.php | 14 +++++---- phpBB/phpbb/captcha/plugins/gd.php | 12 +++---- phpBB/phpbb/captcha/plugins/qa.php | 40 +++++++++++++----------- phpBB/phpbb/captcha/plugins/recaptcha.php | 14 ++++----- 4 files changed, 43 insertions(+), 37 deletions(-) (limited to 'phpBB/phpbb/captcha') diff --git a/phpBB/phpbb/captcha/plugins/captcha_abstract.php b/phpBB/phpbb/captcha/plugins/captcha_abstract.php index 24ed7f939d..2c0b95411e 100644 --- a/phpBB/phpbb/captcha/plugins/captcha_abstract.php +++ b/phpBB/phpbb/captcha/plugins/captcha_abstract.php @@ -34,12 +34,12 @@ abstract class captcha_abstract function init($type) { - global $config, $db, $user; + global $config, $db, $user, $request; // read input - $this->confirm_id = request_var('confirm_id', ''); - $this->confirm_code = request_var('confirm_code', ''); - $refresh = request_var('refresh_vc', false) && $config['confirm_refresh']; + $this->confirm_id = $request->variable('confirm_id', ''); + $this->confirm_code = $request->variable('confirm_code', ''); + $refresh = $request->variable('refresh_vc', false) && $config['confirm_refresh']; $this->type = (int) $type; @@ -125,7 +125,7 @@ abstract class captcha_abstract { foreach ($this->captcha_vars as $captcha_var => $template_var) { - $variables .= '&' . rawurlencode($captcha_var) . '=' . request_var($captcha_var, (int) $config[$captcha_var]); + $variables .= '&' . rawurlencode($captcha_var) . '=' . $request->variable($captcha_var, (int) $config[$captcha_var]); } } @@ -350,7 +350,9 @@ abstract class captcha_abstract function is_solved() { - if (request_var('confirm_code', false) && $this->solved === 0) + global $request; + + if ($request->variable('confirm_code', false) && $this->solved === 0) { $this->validate(); } diff --git a/phpBB/phpbb/captcha/plugins/gd.php b/phpBB/phpbb/captcha/plugins/gd.php index 5fe94af9df..1727dcc1bb 100644 --- a/phpBB/phpbb/captcha/plugins/gd.php +++ b/phpBB/phpbb/captcha/plugins/gd.php @@ -53,7 +53,7 @@ class gd extends captcha_abstract function acp_page($id, &$module) { - global $db, $user, $auth, $template, $phpbb_log; + global $db, $user, $auth, $template, $phpbb_log, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/board'); @@ -70,14 +70,14 @@ class gd extends captcha_abstract $form_key = 'acp_captcha'; add_form_key($form_key); - $submit = request_var('submit', ''); + $submit = $request->variable('submit', ''); if ($submit && check_form_key($form_key)) { $captcha_vars = array_keys($this->captcha_vars); foreach ($captcha_vars as $captcha_var) { - $value = request_var($captcha_var, 0); + $value = $request->variable($captcha_var, 0); if ($value >= 0) { $config->set($captcha_var, $value); @@ -95,7 +95,7 @@ class gd extends captcha_abstract { foreach ($this->captcha_vars as $captcha_var => $template_var) { - $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; + $var = (isset($_REQUEST[$captcha_var])) ? $request->variable($captcha_var, 0) : $config[$captcha_var]; $template->assign_var($template_var, $var); } @@ -109,7 +109,7 @@ class gd extends captcha_abstract function execute_demo() { - global $config; + global $config, $request; $config_old = $config; @@ -121,7 +121,7 @@ class gd extends captcha_abstract foreach ($this->captcha_vars as $captcha_var => $template_var) { - $config->set($captcha_var, request_var($captcha_var, (int) $config[$captcha_var])); + $config->set($captcha_var, $request->variable($captcha_var, (int) $config[$captcha_var])); } parent::execute_demo(); $config = $config_old; diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index a545cccbac..657cfe9217 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -58,14 +58,14 @@ class qa */ function init($type) { - global $config, $db, $user; + global $config, $db, $user, $request; // load our language file $user->add_lang('captcha_qa'); // read input - $this->confirm_id = request_var('qa_confirm_id', ''); - $this->answer = utf8_normalize_nfc(request_var('qa_answer', '', true)); + $this->confirm_id = $request->variable('qa_confirm_id', ''); + $this->answer = utf8_normalize_nfc($request->variable('qa_answer', '', true)); $this->type = (int) $type; $this->question_lang = $user->lang_name; @@ -544,9 +544,9 @@ class qa */ function check_answer() { - global $db; + global $db, $request; - $answer = ($this->question_strict) ? utf8_normalize_nfc(request_var('qa_answer', '', true)) : utf8_clean_string(utf8_normalize_nfc(request_var('qa_answer', '', true))); + $answer = ($this->question_strict) ? utf8_normalize_nfc($request->variable('qa_answer', '', true)) : utf8_clean_string(utf8_normalize_nfc($request->variable('qa_answer', '', true))); $sql = 'SELECT answer_text FROM ' . $this->table_captcha_answers . ' @@ -598,7 +598,9 @@ class qa */ function is_solved() { - if (request_var('qa_answer', false) && $this->solved === 0) + global $request; + + if ($request->variable('qa_answer', false) && $this->solved === 0) { $this->validate(); } @@ -611,7 +613,7 @@ class qa */ function acp_page($id, &$module) { - global $db, $user, $auth, $template, $phpbb_log; + global $db, $user, $auth, $template, $phpbb_log, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/board'); @@ -627,9 +629,9 @@ class qa $form_key = 'acp_captcha'; add_form_key($form_key); - $submit = request_var('submit', false); - $question_id = request_var('question_id', 0); - $action = request_var('action', ''); + $submit = $request->variable('submit', false); + $question_id = $request->variable('question_id', 0); + $action = $request->variable('action', ''); // we have two pages, so users might want to navigate from one to the other $list_url = $module->u_action . "&configure=1&select_captcha=" . $this->get_service_name(); @@ -675,10 +677,10 @@ class qa { // okay, show the editor $error = false; - $input_question = request_var('question_text', '', true); - $input_answers = request_var('answers', '', true); - $input_lang = request_var('lang_iso', '', true); - $input_strict = request_var('strict', false); + $input_question = $request->variable('question_text', '', true); + $input_answers = $request->variable('answers', '', true); + $input_lang = $request->variable('lang_iso', '', true); + $input_strict = $request->variable('strict', false); $langs = $this->get_languages(); foreach ($langs as $lang => $entry) @@ -826,11 +828,13 @@ class qa */ function acp_get_question_input() { - $answers = utf8_normalize_nfc(request_var('answers', '', true)); + global $request; + + $answers = utf8_normalize_nfc($request->variable('answers', '', true)); $question = array( - 'question_text' => request_var('question_text', '', true), - 'strict' => request_var('strict', false), - 'lang_iso' => request_var('lang_iso', ''), + 'question_text' => $request->variable('question_text', '', true), + 'strict' => $request->variable('strict', false), + 'lang_iso' => $request->variable('lang_iso', ''), 'answers' => (strlen($answers)) ? explode("\n", $answers) : '', ); diff --git a/phpBB/phpbb/captcha/plugins/recaptcha.php b/phpBB/phpbb/captcha/plugins/recaptcha.php index 369c84e7df..98132ab47d 100644 --- a/phpBB/phpbb/captcha/plugins/recaptcha.php +++ b/phpBB/phpbb/captcha/plugins/recaptcha.php @@ -37,12 +37,12 @@ class recaptcha extends captcha_abstract function init($type) { - global $config, $db, $user; + global $config, $db, $user, $request; $user->add_lang('captcha_recaptcha'); parent::init($type); - $this->challenge = request_var('recaptcha_challenge_field', ''); - $this->response = request_var('recaptcha_response_field', ''); + $this->challenge = $request->variable('recaptcha_challenge_field', ''); + $this->response = $request->variable('recaptcha_response_field', ''); } public function is_available() @@ -75,7 +75,7 @@ class recaptcha extends captcha_abstract function acp_page($id, &$module) { - global $config, $db, $template, $user, $phpbb_log; + global $config, $db, $template, $user, $phpbb_log, $request; $captcha_vars = array( 'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY', @@ -87,14 +87,14 @@ class recaptcha extends captcha_abstract $form_key = 'acp_captcha'; add_form_key($form_key); - $submit = request_var('submit', ''); + $submit = $request->variable('submit', ''); if ($submit && check_form_key($form_key)) { $captcha_vars = array_keys($captcha_vars); foreach ($captcha_vars as $captcha_var) { - $value = request_var($captcha_var, ''); + $value = $request->variable($captcha_var, ''); if ($value) { $config->set($captcha_var, $value); @@ -112,7 +112,7 @@ class recaptcha extends captcha_abstract { foreach ($captcha_vars as $captcha_var => $template_var) { - $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, '') : ((isset($config[$captcha_var])) ? $config[$captcha_var] : ''); + $var = (isset($_REQUEST[$captcha_var])) ? $request->variable($captcha_var, '') : ((isset($config[$captcha_var])) ? $config[$captcha_var] : ''); $template->assign_var($template_var, $var); } -- cgit v1.2.1 From abcb2680eec86dc8016c489ebc7362e29be9e4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Mon, 2 Feb 2015 21:35:46 +0100 Subject: [ticket/13455] Remove unnecessary calls to `utf8_normalize_nfc()` PHPBB3-13455 --- phpBB/phpbb/captcha/plugins/qa.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/captcha') diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index 657cfe9217..b4586f1234 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -65,7 +65,7 @@ class qa // read input $this->confirm_id = $request->variable('qa_confirm_id', ''); - $this->answer = utf8_normalize_nfc($request->variable('qa_answer', '', true)); + $this->answer = $request->variable('qa_answer', '', true); $this->type = (int) $type; $this->question_lang = $user->lang_name; @@ -546,7 +546,7 @@ class qa { global $db, $request; - $answer = ($this->question_strict) ? utf8_normalize_nfc($request->variable('qa_answer', '', true)) : utf8_clean_string(utf8_normalize_nfc($request->variable('qa_answer', '', true))); + $answer = ($this->question_strict) ? $request->variable('qa_answer', '', true) : utf8_clean_string($request->variable('qa_answer', '', true)); $sql = 'SELECT answer_text FROM ' . $this->table_captcha_answers . ' @@ -830,7 +830,7 @@ class qa { global $request; - $answers = utf8_normalize_nfc($request->variable('answers', '', true)); + $answers = $request->variable('answers', '', true); $question = array( 'question_text' => $request->variable('question_text', '', true), 'strict' => $request->variable('strict', false), -- cgit v1.2.1 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 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
<!-- <!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook V4.1//EN"> -->
<chapter id="customization">
  <title>Customising Bugzilla</title>

  <section id="cust-templates">
    <title>Template Customization</title>
    
    <para>
      Administrators can configure the look and feel of Bugzilla without
      having to edit Perl files or face the nightmare of massive merge
      conflicts when they upgrade to a newer version in the future.
    </para>
    
    <para>
      Templatization also makes localized versions of Bugzilla possible, 
      for the first time. It's possible to have Bugzilla's UI language 
      determined by the user's browser. More information is available in
      <xref linkend="template-http-accept"/>.
    </para>
    
    <section id="template-directory">
      <title>Template Directory Structure</title>
      <para>
        The template directory structure starts with top level directory 
        named <filename>template</filename>, which contains a directory
        for each installed localization. The next level defines the
        language used in the templates. Bugzilla comes with English
        templates, so the directory name is <filename>en</filename>,
        and we will discuss <filename>template/en</filename> throughout
        the documentation. Below <filename>template/en</filename> is the
        <filename>default</filename> directory, which contains all the
        standard templates shipped with Bugzilla.
      </para>

      <warning>
        <para>
          A directory <filename>data/templates</filename> also exists;
          this is where Template Toolkit puts the compiled versions of
          the templates from either the default or custom directories.
          <emphasis>Do not</emphasis> directly edit the files in this
          directory, or all your changes will be lost the next time
          Template Toolkit recompiles the templates.
        </para>
      </warning>
    </section>

    <section id="template-method">
      <title>Choosing a Customization Method</title>
      <para>
        If you want to edit Bugzilla's templates, the first decision
        you must make is how you want to go about doing so. There are two
        choices, and which you use depends mainly on the scope of your 
        modifications, and the method you plan to use to upgrade Bugzilla.
      </para> 

      <para>
        The first method of making customizations is to directly edit the
        templates found in <filename>template/en/default</filename>.
        This is probably the best way to go about it if you are going to
        be upgrading Bugzilla through CVS, because if you then execute
        a <command>cvs update</command>, any changes you have made will
        be merged automagically with the updated versions.
      </para>

      <note>
        <para>
          If you use this method, and CVS conflicts occur during an
          update, the conflicted templates (and possibly other parts
          of your installation) will not work until they are resolved.
        </para>
      </note>

      <para>
        The second method is to copy the templates to be modified
        into a mirrored directory structure under 
        <filename>template/en/custom</filename>. Templates in this
        directory structure automatically override any identically-named
        and identically-located templates in the 
        <filename>default</filename> directory. 
      </para>

      <note>
        <para>
          The <filename>custom</filename> directory does not exist
          at first and must be created if you want to use it.
        </para>
      </note>

      <para>
        The second method of customization should be used if you 
        use the overwriting method of upgrade, because otherwise 
        your changes will be lost.  This method may also be better if
        you are using the CVS method of upgrading and are going to make major
        changes, because it is guaranteed that the contents of this directory
        will not be touched during an upgrade, and you can then decide whether
        to continue using your own templates, or make the effort to merge your
        changes into the new versions by hand.
      </para>

      <para>
        Using this method, your installation may break if incompatible
        changes are made to the template interface.  Such changes should
        be documented in the release notes, provided you are using a
        stable release of Bugzilla.  If you use using unstable code, you will
        need to deal with this one yourself, although if possible the changes
        will be mentioned before they occur in the deprecations section of the
        previous stable release's release notes.
      </para>

      <note>
        <para>
          Regardless of which method you choose, it is recommended that
          you run <command>./checksetup.pl</command> after creating or
          editing any templates in the <filename>template/en/default</filename>
          directory, and after editing any templates in the 
          <filename>custom</filename> directory.
        </para>
      </note>

      <warning>
        <para>
          It is <emphasis>required</emphasis> that you run 
          <command>./checksetup.pl</command> after creating a new
          template in the <filename>custom</filename> directory. Failure
          to do so will raise an incomprehensible error message.
        </para>
      </warning>
    </section>
    
    <section id="template-edit">
      <title>How To Edit Templates</title>
      
      <note>
        <para>
          If you are making template changes that you intend on submitting back
          for inclusion in standard Bugzilla, you should read the relevant
          sections of the 
          <ulink url="http://www.bugzilla.org/docs/developer.html">Developers'
          Guide</ulink>.
        </para>
      </note>
      
      <para>
        The syntax of the Template Toolkit language is beyond the scope of
        this guide. It's reasonably easy to pick up by looking at the current 
        templates; or, you can read the manual, available on the
        <ulink url="http://www.template-toolkit.org">Template Toolkit home
        page</ulink>.
      </para>
      
      <para>
        One thing you should take particular care about is the need
        to properly HTML filter data that has been passed into the template.
        This means that if the data can possibly contain special HTML characters
        such as &lt;, and the data was not intended to be HTML, they need to be
        converted to entity form, i.e. &amp;lt;.  You use the 'html' filter in the
        Template Toolkit to do this.  If you forget, you may open up
        your installation to cross-site scripting attacks.
      </para>

      <para>
        Also note that Bugzilla adds a few filters of its own, that are not
        in standard Template Toolkit.  In particular, the 'url_quote' filter
        can convert characters that are illegal or have special meaning in URLs,
        such as &amp;, to the encoded form, i.e. %26.  This actually encodes most
        characters (but not the common ones such as letters and numbers and so
        on), including the HTML-special characters, so there's never a need to
        HTML filter afterwards.
      </para>
 
      <para>
        Editing templates is a good way of doing a <quote>poor man's custom
        fields</quote>.
        For example, if you don't use the Status Whiteboard, but want to have
        a free-form text entry box for <quote>Build Identifier</quote>,
        then you can just
        edit the templates to change the field labels. It's still be called
        status_whiteboard internally, but your users don't need to know that.
      </para>
      
    </section>
            
    
    <section id="template-formats">
      <title>Template Formats and Types</title>
      
      <para>
        Some CGI's have the ability to use more than one template. For example,
        <filename>buglist.cgi</filename> can output itself as RDF, or as two 
        formats of HTML (complex and simple). The mechanism that provides this 
        feature is extensible.
      </para>

      <para>
        Bugzilla can support different types of output, which again can have 
        multiple formats. In order to request a certain type, you can append 
        the &amp;ctype=&lt;contenttype&gt; (such as rdf or html) to the 
        <filename>&lt;cginame&gt;.cgi</filename> URL. If you would like to 
        retrieve a certain format, you can use the &amp;format=&lt;format&gt; 
        (such as simple or complex) in the URL.
      </para>
      
      <para>
        To see if a CGI supports multiple output formats and types, grep the
        CGI for <quote>get_format</quote>. If it's not present, adding
        multiple format/type support isn't too hard - see how it's done in
        other CGIs, e.g. config.cgi.
      </para>
      
      <para>
        To make a new format template for a CGI which supports this, 
        open a current template for
        that CGI and take note of the INTERFACE comment (if present.) This 
        comment defines what variables are passed into this template. If 
        there isn't one, I'm afraid you'll have to read the template and
        the code to find out what information you get. 
      </para>     
  
      <para>
        Write your template in whatever markup or text style is appropriate.
      </para>
      
      <para>
        You now need to decide what content type you want your template
        served as. The content types are defined in the
        <filename>Bugzilla/Constants.pm</filename> file in the 
        <filename>contenttypes</filename>
        constant. If your content type is not there, add it. Remember
        the three- or four-letter tag assigned to your content type. 
        This tag will be part of the template filename.
      </para>

      <note>
        <para>
          After adding or changing a content type, it's suitable to edit
          <filename>Bugzilla/Constants.pm</filename> in order to reflect
          the changes. Also, the file should be kept up to date after an
          upgrade if content types have been customized in the past. 
        </para>
      </note>
      
      <para>
        Save the template as <filename>&lt;stubname&gt;-&lt;formatname&gt;.&lt;contenttypetag&gt;.tmpl</filename>. 
        Try out the template by calling the CGI as 
        <filename>&lt;cginame&gt;.cgi?format=&lt;formatname&gt;&amp;ctype=&lt;type&gt;</filename> .
      </para>       
    </section>
    
    
    <section id="template-specific">
      <title>Particular Templates</title>
      
      <para>
        There are a few templates you may be particularly interested in
        customizing for your installation.
      </para>
      
      <para>
        <command>index.html.tmpl</command>:
        This is the Bugzilla front page.
      </para>      

      <para>
        <command>global/header.html.tmpl</command>:
        This defines the header that goes on all Bugzilla pages.
        The header includes the banner, which is what appears to users
        and is probably what you want to edit instead.  However the
        header also includes the HTML HEAD section, so you could for
        example add a stylesheet or META tag by editing the header.
      </para>

      <para>
        <command>global/banner.html.tmpl</command>:
        This contains the <quote>banner</quote>, the part of the header
        that appears
        at the top of all Bugzilla pages.  The default banner is reasonably
        barren, so you'll probably want to customize this to give your
        installation a distinctive look and feel.  It is recommended you
        preserve the Bugzilla version number in some form so the version 
        you are running can be determined, and users know what docs to read.
      </para>

      <para>
        <command>global/footer.html.tmpl</command>:
        This defines the footer that goes on all Bugzilla pages.  Editing
        this is another way to quickly get a distinctive look and feel for
        your Bugzilla installation.
      </para>

      <para>
        <command>global/variables.none.tmpl</command>:
        This defines a list of terms that may be changed in order to
        <quote>brand</quote> the Bugzilla instance In this way, terms
        like <quote>bugs</quote> can be replaced with <quote>issues</quote>
        across the whole Bugzilla installation. The name
        <quote>Bugzilla</quote> and other words can be customized as well.
      </para>

      <para>
        <command>list/table.html.tmpl</command>:
        This template controls the appearance of the bug lists created
        by Bugzilla. Editing this template allows per-column control of 
        the width and title of a column, the maximum display length of
        each entry, and the wrap behaviour of long entries.
        For long bug lists, Bugzilla inserts a 'break' every 100 bugs by
        default; this behaviour is also controlled by this template, and
        that value can be modified here.
       </para>

      <para>
        <command>bug/create/user-message.html.tmpl</command>:
        This is a message that appears near the top of the bug reporting page.
        By modifying this, you can tell your users how they should report
        bugs.
      </para>

      <para>
        <command>bug/process/midair.html.tmpl</command>:
        This is the page used if two people submit simultaneous changes to the
        same bug.  The second person to submit their changes will get this page
        to tell them what the first person did, and ask if they wish to
        overwrite those changes or go back and revisit the bug.  The default
        title and header on this page read "Mid-air collision detected!"  If
        you work in the aviation industry, or other environment where this
        might be found offensive (yes, we have true stories of this happening)
        you'll want to change this to something more appropriate for your
        environment.
      </para>

      <para>
        <command>bug/create/create.html.tmpl</command> and
        <command>bug/create/comment.txt.tmpl</command>:
        You may not wish to go to the effort of creating custom fields in
        Bugzilla, yet you want to make sure that each bug report contains
        a number of pieces of important information for which there is not
        a special field. The bug entry system has been designed in an
        extensible fashion to enable you to add arbitrary HTML widgets,
        such as drop-down lists or textboxes, to the bug entry page
        and have their values appear formatted in the initial comment.
        A hidden field that indicates the format should be added inside
        the form in order to make the template functional. Its value should
        be the suffix of the template filename. For example, if the file
        is called <filename>create-cust.html.tmpl</filename>, then
        <programlisting>&lt;input type="hidden" name="format" value="cust"&gt;</programlisting>
        should be used inside the form.
      </para>

      <para>  
        An example of this is the mozilla.org 
        <ulink url="http://landfill.bugzilla.org/bugzilla-tip/enter_bug.cgi?product=WorldControl&amp;format=guided">guided 
        bug submission form</ulink>. The code for this comes with the Bugzilla
        distribution as an example for you to copy. It can be found in the
        files 
        <filename>create-guided.html.tmpl</filename> and
        <filename>comment-guided.html.tmpl</filename>.
      </para>  

      <para>
        So to use this feature, create a custom template for 
        <filename>enter_bug.cgi</filename>. The default template, on which you
        could base it, is 
        <filename>custom/bug/create/create.html.tmpl</filename>.
        Call it <filename>create-&lt;formatname&gt;.html.tmpl</filename>, and
        in it, add widgets for each piece of information you'd like
        collected - such as a build number, or set of steps to reproduce.
      </para>

      <para>
        Then, create a template like 
        <filename>custom/bug/create/comment.txt.tmpl</filename>, and call it 
        <filename>comment-&lt;formatname&gt;.txt.tmpl</filename>. This 
        template should reference the form fields you have created using
        the syntax <filename>[% form.&lt;fieldname&gt; %]</filename>. When a 
        bug report is
        submitted, the initial comment attached to the bug report will be
        formatted according to the layout of this template.
      </para> 

      <para>
        For example, if your custom enter_bug template had a field
        <programlisting>&lt;input type="text" name="buildid" size="30"&gt;</programlisting>
        and then your comment.txt.tmpl had
        <programlisting>BuildID: [% form.buildid %]</programlisting>
        then something like
        <programlisting>BuildID: 20020303</programlisting>
        would appear in the initial comment.
      </para>            
    </section>          


    <section id="template-http-accept">
      <title>Configuring Bugzilla to Detect the User's Language</title>

      <para>Bugzilla honours the user's Accept: HTTP header. You can install
      templates in other languages, and Bugzilla will pick the most appropriate
      according to a priority order defined by you. Many
      language templates can be obtained from <ulink 
      url="http://www.bugzilla.org/download.html#localizations"/>. Instructions
      for submitting new languages are also available from that location.
      </para>

      <para>After untarring the localizations (or creating your own) in the 
      <filename class="directory">BUGZILLA_ROOT/template</filename> directory,
      you must update the <option>languages</option> parameter to contain any
      localizations you'd like to permit. You may also wish to set the
      <option>defaultlanguage</option> parameter to something other than
      <quote>en</quote> if you don't want English to be the default language.
      </para>
    </section>
      
  </section>

  <section id="cust-hooks">
    <title>The Bugzilla Extension Mechanism</title>
        
    <warning>
      <para>
        Custom extensions require Template Toolkit version 2.12 or
        above, or the application of a patch.  See <ulink
        url="http://bugzilla.mozilla.org/show_bug.cgi?id=239112">bug
        239112</ulink> for details.
      </para>
    </warning>
       
    <para>
      Extensions are a way for extensions to Bugzilla to insert code
      into the standard Bugzilla templates and source files
      without modifying these files themselves.  The extension mechanism 
      defines a consistent API for extending the standard templates and source files 
      in a way that cleanly separates standard code from extension code.  
      Hooks reduce merge conflicts and make it easier to write extensions that work 
      across multiple versions of Bugzilla, making upgrading a Bugzilla installation 
      with installed extensions easier. Furthermore, they make it easy to install 
      and remove extensions as each extension is nothing more than a 
      simple directory structure. 
    </para>
    
    <para>
      There are two main types of hooks: code hooks and template hooks. Code 
      hooks allow extensions to invoke code at specific points in various 
      source files, while template hooks allow extensions to add elements to 
      the Bugzilla user interface. 
    </para>

    <para>
      A hook is just a named place in a standard source or template file
      where extension source code or template files for that hook get processed. 
      Each extension has a corresponding directory in the Bugzilla directory 
      tree (<filename>BUGZILLA_ROOT/extensions/extension_name</filename>).  Hooking 
      an extension source file or template to a hook is as simple as putting 
      the extension file into extension's template or code directory. 
      When Bugzilla processes the source file or template and reaches the hook, 
      it will process all extension files in the hook's directory. 
      The hooks themselves can be added into any source file or standard template 
      upon request by extension authors.
    </para>
    
    <para>
      To use hooks to extend Bugzilla, first make sure there is
      a hook at the appropriate place within the source file or template you 
      want to extend. The exact appearence of a hook depends on if the hook 
      is a code hook or a template hook. 
    </para>
    
    <para>
      Code hooks appear in Bugzilla source files as a single method call 
      in the format <literal role="code">Bugzilla::Hook->process("<varname>name</varname>");</literal>.
      for instance, <filename>enter_bug.cgi</filename> may invoke the hook 
      "<varname>enter_bug-defaultvars</varname>". Thus, a source file at 
      <filename>BUGZILLA_ROOT/extensions/EXTENSION_NAME/code/enter_bug-entrydefaultvars.pl</filename>
      will be automatically invoked when the code hook is reached. 
    </para>
   
    <para>  
      Template hooks appear in the standard Bugzilla templates as a 
      single directive in the format
      <literal role="code">[% Hook.process("<varname>name</varname>") %]</literal>,
      where <varname>name</varname> is the unique name of the hook.
    </para>

    <para>
      If you aren't sure what you want to extend or just want to browse the 
      available hooks, either use your favorite multi-file search
      tool (e.g. <command>grep</command>) to search the standard templates
      for occurrences of <methodname>Hook.process</methodname> or the source 
      files for occurrences of <methodname>Bugzilla::Hook::process</methodname>.
    </para>

    <para>
      If there is no hook at the appropriate place within the Bugzilla 
      source file or template you want to extend,
      <ulink url="http://bugzilla.mozilla.org/enter_bug.cgi?product=Bugzilla&amp;component=User%20Interface">file
      a bug requesting one</ulink>, specifying:
    </para>

    <simplelist>
      <member>the source or template file for which you are 
          requesting a hook;</member>
      <member>
        where in the file you would like the hook to be placed
        (line number/position for latest version of the file in CVS
        or description of location);
      </member>
      <member>the purpose of the hook;</member>
      <member>a link to information about your extension, if any.</member>
    </simplelist>

    <para>
      The Bugzilla reviewers will promptly review each hook request,
      name the hook, add it to the template or source file, and check 
      the new version of the template into CVS.
    </para>

    <para>
      You may optionally attach a patch to the bug which implements the hook
      and check it in yourself after receiving approval from a Bugzilla
      reviewer.  The developers may suggest changes to the location of the
      hook based on their analysis of your needs or so the hook can satisfy
      the needs of multiple extensions, but the process of getting hooks
      approved and checked in is not as stringent as the process for general
      changes to Bugzilla, and any extension, whether released or still in
      development, can have hooks added to meet their needs.