]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Updates from dkl review of chapters 5 and 6.
authorGervase Markham <gerv@gerv.net>
Tue, 25 Nov 2014 14:04:31 +0000 (14:04 +0000)
committerGervase Markham <gerv@gerv.net>
Tue, 25 Nov 2014 14:04:31 +0000 (14:04 +0000)
docs/en/rst/customizing/languages.rst
docs/en/rst/customizing/templates.rst
docs/en/rst/customizing/writing-extensions.rst
docs/en/rst/integrating/apis.rst

index 8360c606482cbf5cf06705d6a44fb7b17a1e9fa6..01586d3fe9e29979da0b977543cd62ec78360ead 100644 (file)
@@ -5,7 +5,10 @@ Bugzilla's templates can be localized, although it's a `big job
 <https://wiki.mozilla.org/Bugzilla:L10n:Guide>`_. If you have
 a localized set of templates for your version of Bugzilla, Bugzilla can 
 support multiple languages at once. In that case, Bugzilla honours the user's
-``Accept-Language`` HTTP header when deciding which language to serve.
+``Accept-Language`` HTTP header when deciding which language to serve. If
+multiple languages are installed, a menu will display in the header allowing
+the user to manually select a different language. If they do this, their
+choice will override the ``Accept-Language`` header.
 
 Many language templates can be obtained from
 `the localization section of the Bugzilla website
index 7c13f7780851cb0f78a5ae38ce3eeb42e12de946..d06f6a9a68ccb0290e16ea4c1f4c47c92d8adc12 100644 (file)
@@ -22,9 +22,9 @@ the documentation. Below :file:`template/en` is the
 :file:`default` directory, which contains all the
 standard templates shipped with Bugzilla.
 
-.. warning:: A directory :file:`data/templates` also exists;
-   this is where Template Toolkit puts the compiled versions of
-   the templates. *Do not* directly edit the files in this
+.. warning:: A directory :file:`data/template` also exists;
+   this is where Template Toolkit puts the compiled versions (i.e. Perl code)
+   of the templates. *Do not* directly edit the files in this
    directory, or all your changes will be lost the next time
    Template Toolkit recompiles the templates.
 
@@ -48,10 +48,16 @@ modifications, and the method you plan to use to upgrade Bugzilla.
    not exist by default and must be created if you want to use it.)
 
 #. You can use the hooks built into many of the templates to add or modify
-   the UI from an :ref:`extension <extensions>`. Hooks generally don't go away and have
-   a stable interface. 
+   the UI from an :ref:`extension <extensions>`. Hooks generally don't go away
+   and have a stable interface. 
+
+The third method is the best if there are hooks in the appropriate places
+and the change you want to do is possible using hooks. It's not very easy
+to modify existing UI using hooks; they are most commonly used for additions.
+You can make modifications if you add JS code which then makes the
+modifications when the page is loaded. You can remove UI by adding CSS to hide
+it.
 
-The third method is the best if there are hooks in the appropriate places.
 Unlike code hooks, there is no requirement to document template hooks, so
 you just have to open up the template and see (search for ``Hook.process``).
 
@@ -104,7 +110,8 @@ to cross-site scripting attacks.
 
 
 You should run :command:`./checksetup.pl` after editing any templates. Failure
-to do so may mean your changes are not picked up.
+to do so may mean either that your changes are not picked up, or that the
+permissions on the edited files are wrong so the webserver can't read them. 
 
 .. _template-formats:
 
@@ -224,7 +231,7 @@ customizing for your installation.
     such as drop-down lists or textboxes, to the bug entry page
     and have their values appear formatted in the initial comment.
 
-    An example of this is the mozilla.org `guided bug submission form
+    An example of this is the `guided bug submission form
     <http://landfill.bugzilla.org/bugzilla-tip/enter_bug.cgi?product=WorldControl;format=guided>`_.
     The code for this comes with the Bugzilla distribution as an example for
     you to copy. It can be found in the files
@@ -244,39 +251,39 @@ customizing for your installation.
     So to use this feature, create a custom template for
     :file:`enter_bug.cgi`. The default template, on which you
     could base it, is
-    :file:`custom/bug/create/create.html.tmpl`.
-    Call it :file:`create-<formatname>.html.tmpl`, and
-    in it, add widgets for each piece of information you'd like
+    :file:`default/bug/create/create.html.tmpl`.
+    Call it :file:`custom/bug/create/create-<formatname>.html.tmpl`, and
+    in it, add form inputs for each piece of information you'd like
     collected - such as a build number, or set of steps to reproduce.
 
-    Then, create a template like
-    :file:`custom/bug/create/comment.txt.tmpl`, and call it
-    :file:`comment-<formatname>.txt.tmpl`. This
-    template should reference the form fields you have created using
-    the syntax :file:`[% form.<fieldname> %]`. When a
-    bug report is
+    Then, create a template based on
+    :file:`default/bug/create/comment.txt.tmpl`, and call it
+    :file:`custom/bug/create/comment-<formatname>.txt.tmpl`.
+    It needs a couple of lines of boilerplate at the top like this::
+
+        [% USE Bugzilla %]
+        [% cgi = Bugzilla.cgi %
+
+    Then, this template can reference the form fields you have created using
+    the syntax ``[% cgi.param("field_name") %]``. When a bug report is
     submitted, the initial comment attached to the bug report will be
     formatted according to the layout of this template.
 
-    For example, if your custom enter_bug template had a field
-
-    ::
+    For example, if your custom enter_bug template had a field::
 
         <input type="text" name="buildid" size="30">
 
-    and then your comment.txt.tmpl had
+    and then your comment.txt.tmpl had::
 
-    ::
-
-        BuildID: [% form.buildid %]
+        [% USE Bugzilla %]
+        [% cgi = Bugzilla.cgi %]
+        Build Identifier: [%+ cgi.param("buildid") %]
 
-    then something like
-
-    ::
+    then something like::
 
-        BuildID: 20140303
+        Build Identifier: 20140303
 
     would appear in the initial comment.
 
-    This system allows you to gather tructured data in bug reports without
+    This system allows you to gather structured data in bug reports without
     the overhead and UI complexity of a large number of custom fields.
index 107147b15ce5076e8c43bd45b601018c65fb9001..297319e55cfd92fdf50ad5e323b22dbd07f21516 100644 (file)
@@ -6,8 +6,27 @@ Writing Extensions
 See the `Bugzilla Extension
 documentation <../html/api/Bugzilla/Extension.html>`_ for the core
 documentation on how to write an Extension. It would make sense to read
-the section on :ref:`templates`. This section explains how to achieve some
-common tasks using the Extension APIs.
+the section on :ref:`templates`. There is also a sample extension in
+:file:`$BUGZILLA_HOME/extensions/Example/` which gives examples of how to
+use all the code hooks.
+
+This section explains how to achieve some common tasks using the Extension APIs.
+
+Adding A New Page to Bugzilla
+=============================
+
+There are occasions where it's useful to add a new page to Bugzilla which
+has little or no relation to other pages, and perhaps doesn't use very much
+Bugzilla data. A help page, or a custom report for example. The best mechanism
+for this is to use :file:`page.cgi` and the ``page_before_template`` hook.
+
+Altering Data On An Existing Page
+=================================
+
+The ``template_before_process`` hook can be used to tweak the data displayed
+on a particular existing page, if you know what template is used. It has
+access to all the template variables before they are passed to the templating
+engine.
 
 Adding New Fields To Bugs
 =========================
@@ -80,6 +99,16 @@ define the UI strings for the panel. See the templates in
 template in :file:`template/en/default/admin/params` in your extension's
 directory.
 
+You can access param values from Templates using::
+
+    [% Param('param_name') %]
+
+and from code using:
+
+.. code-block:: perl
+
+    Bugzilla->params->{'param_name'}
+
 Adding User Preferences
 =======================
 
index 97c4fa1510cfd38f3c1da7f28966dda413dcb250..ee5e230de8e941f2c35894312c041b4c64105edb 100644 (file)
@@ -18,8 +18,8 @@ Ad-Hoc APIs
 
 Various pages on Bugzilla are available in machine-parseable formats as well
 as HTML. For example, bugs can be downloaded as XML, and buglists as CSV.
-While the team attempts not to break these ad-hoc APIs, they should not be
-used for new code.
+CSV is useful for spreadsheet import. There should be links on the HTML page
+to alternate data formats where they are available.
 
 XML-RPC
 =======
@@ -29,6 +29,8 @@ Bugzilla has an `XML-RPC API
 This will receive no further updates and will be removed in a future version
 of Bugzilla.
 
+Endpoint: :file:`/xmlrpc.cgi`
+
 JSON-RPC
 ========
 
@@ -37,6 +39,8 @@ Bugzilla has a `JSON-RPC API
 This will receive no further updates and will be removed in a future version
 of Bugzilla.
 
+Endpoint: :file:`/jsonrpc.cgi`
+
 REST
 ====
 
@@ -47,6 +51,8 @@ current REST API is version 1. It is stable, and so will not be changed in a
 backwardly-incompatible way. **This is the currently-recommended API for
 new development.**
 
+Endpoint: :file:`/rest`
+
 BzAPI/BzAPI-Compatible REST
 ===========================