Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
339
modules/faq/LICENSE.txt
Normal file
339
modules/faq/LICENSE.txt
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
84
modules/faq/README.txt
Normal file
84
modules/faq/README.txt
Normal file
|
@ -0,0 +1,84 @@
|
|||
CONTENTS OF THIS FILE
|
||||
----------------------
|
||||
|
||||
* Introduction
|
||||
* Installation
|
||||
* Configuration
|
||||
* Known Issues
|
||||
- No FAQs appear after module upgrade
|
||||
- <p> tags appear in FAQ question text
|
||||
- Clicking on category links takes user to front page
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
------------
|
||||
Maintainer: Stella Power (http://drupal.org/user/66894)
|
||||
|
||||
Documentation: http://drupal.org/node/129209
|
||||
|
||||
The Frequently Asked Questions (faq) module allows users with the 'administer
|
||||
faq' permission to create question and answer pairs which they want displayed on
|
||||
the 'faq' page. The 'faq' page is automatically generated from the FAQ nodes
|
||||
configured and the layout of this page can be modified on the settings page.
|
||||
Users will need the 'view faq' permission to view the 'faq' page.
|
||||
|
||||
There are 2 blocks included in this module, one shows a list of FAQ categories
|
||||
while the other can show a configurable number of recent FAQs added.
|
||||
|
||||
Note the function theme_faq_highlights(), which shows the last X recently
|
||||
created FAQs, used by one of the blocks, can also be called in a php-filtered
|
||||
node if desired.
|
||||
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
1. Copy faq folder to modules directory.
|
||||
2. At admin/build/modules enable the faq module.
|
||||
3. Enable permissions at admin/user/permissions.
|
||||
4. Configure the module at admin/settings/faq.
|
||||
|
||||
|
||||
UPGRADE NOTICE
|
||||
---------------
|
||||
When using categorized FAQ nodes, the disabling of the FAQ module causes the
|
||||
vocabulary to lose the association with the FAQ content type. This results in no
|
||||
FAQ nodes being displayed when you re-enable the FAQ module. Before opening an
|
||||
issue, please verify that this setting is still in place.
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
-------------
|
||||
Once the module is activated, you can create your question and answer pairs by
|
||||
creating FAQ nodes (Create content >> FAQ). This allows you to edit the
|
||||
question and answer text. In addition, if the 'Taxonomy' module is enabled and
|
||||
there are some terms configured for the FAQ node type, it will also be possible
|
||||
to put the questions into different categories when editing.
|
||||
|
||||
|
||||
KNOWN ISSUES
|
||||
-------------
|
||||
No FAQs appear after module upgrade
|
||||
-----------------------------------
|
||||
When using categorized FAQ nodes, the disabling of the FAQ module causes the
|
||||
vocabulary to lose the association with the FAQ content type. This results in no
|
||||
FAQ nodes being displayed when you re-enable the FAQ module. Before opening an
|
||||
issue, please verify that this setting is still in place.
|
||||
|
||||
<p> tags appear in FAQ question text
|
||||
------------------------------------
|
||||
When using WYSIWYG editors, such as TinyMCE and FCKeditor, <p> and other HTML
|
||||
tags may appear in the displayed question text. This is because the faq title or
|
||||
question input box is a textarea and not a textfield, so the faq module can
|
||||
accommodate longer question texts. The p-tags come from the WYSIWYG editor used
|
||||
and not the FAQ module. This is because TinyMCE, and other WYSIWYG editors,
|
||||
attach themselves to all textareas on a given page. Details on how to prevent
|
||||
this can be found at http://drupal.org/node/294708
|
||||
|
||||
Clicking on category links takes user to front page
|
||||
---------------------------------------------------
|
||||
Reported for Drupal 5, unconfirmed for Drupal 6.
|
||||
Instead of being taken to the categorized faq page, the front page is displayed
|
||||
when the user clicks on a faq category. This is something to do with the
|
||||
pathauto module and can be easily fixed by doing a bulk update of paths for the
|
||||
faq vocabulary.
|
||||
|
497
modules/faq/faq.admin.inc
Normal file
497
modules/faq/faq.admin.inc
Normal file
|
@ -0,0 +1,497 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Administrative page callbacks for the faq module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates the settings form for the FAQ module.
|
||||
*
|
||||
* @param $op
|
||||
* Default value is NULL; determines what are the permissions of the current
|
||||
* user on the FAQ.
|
||||
* @return
|
||||
* The output, which contains the HTML code for the settings form generated by
|
||||
* drupal_get_form() function.
|
||||
*/
|
||||
function faq_settings_page($op = NULL) {
|
||||
|
||||
$output = drupal_get_form('faq_general_settings_form');
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a form to edit the page header and descriptive text.
|
||||
*
|
||||
* @return
|
||||
* The general settings form code stored in the $form variable, before
|
||||
* converted to HTML.
|
||||
*/
|
||||
function faq_general_settings_form() {
|
||||
$form['faq_title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Title'),
|
||||
'#default_value' => variable_get('faq_title', 'Frequently Asked Questions'),
|
||||
);
|
||||
|
||||
$form['body_filter']['faq_description'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('FAQ Description'),
|
||||
'#default_value' => variable_get('faq_description', ''),
|
||||
'#description' => t('Your FAQ description. This will be placed at the top of the page, above the questions and can serve as an introductory text.'),
|
||||
'#rows' => 5,
|
||||
);
|
||||
$form['body_filter']['faq_description_format'] = filter_form(variable_get('faq_description_format', ''), NULL, array('faq_description_format'));
|
||||
$form['faq_custom_breadcrumbs'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Create custom breadcrumbs for the FAQ'),
|
||||
'#description' => t('This option set the breadcrumb path to "%home > %faqtitle > category trail".', array('%home' => t('Home'), '%faqtitle' => variable_get('faq_title', 'Frequently Asked Questions'))),
|
||||
'#default_value' => variable_get('faq_custom_breadcrumbs', TRUE),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the elements for the FAQ Settings page - Questions tab.
|
||||
*
|
||||
* @return
|
||||
* The form code inside the $form array.
|
||||
*/
|
||||
function faq_questions_settings_form() {
|
||||
|
||||
drupal_add_js(array('faq' => array('faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE))), 'setting');
|
||||
drupal_add_js(array('faq' => array('faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE))), 'setting');
|
||||
drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');
|
||||
|
||||
$display_options['questions_inline'] = t('Questions inline');
|
||||
$display_options['questions_top'] = t('Clicking on question takes user to answer further down the page');
|
||||
$display_options['hide_answer'] = t('Clicking on question opens/hides answer under question');
|
||||
$display_options['new_page'] = t('Clicking on question opens the answer in a new page');
|
||||
|
||||
$form['faq_display'] = array(
|
||||
'#type' => 'radios',
|
||||
'#options' => $display_options,
|
||||
'#title' => t('Page layout'),
|
||||
'#description' => t('This controls how the questions and answers are displayed on the page and what happens when someone clicks on the question.'),
|
||||
'#default_value' => variable_get('faq_display', 'questions_top'),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Miscellaneous layout settings'),
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_question_listing'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => array('ol' => t('Ordered list'), 'ul' => t('Unordered list')),
|
||||
'#title' => t('Questions listing style'),
|
||||
'#description' => t("This allows to select how the questions listing is presented. It only applies to the layouts: 'Clicking on question takes user to answer further down the page' and 'Clicking on question opens the answer in a new page'. An ordered listing would number the questions, whereas an unordered list will have a bullet to the left of each question."),
|
||||
'#default_value' => variable_get('faq_question_listing', 'ul'),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_qa_mark'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Label questions and answers'),
|
||||
'#description' => t('This option is only valid for the "Questions Inline" and "Clicking on question takes user to answer further down the page" layouts. It labels all questions on the faq page with the "question label" setting and all answers with the "answer label" setting. For example these could be set to "Q:" and "A:".'),
|
||||
'#default_value' => variable_get('faq_qa_mark', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_question_label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Question Label'),
|
||||
'#description' => t('The label to pre-pend to the question text in the "Questions Inline" layout if labelling is enabled.'),
|
||||
'#default_value' => variable_get('faq_question_label', 'Q:'),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_answer_label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Answer Label'),
|
||||
'#description' => t('The label to pre-pend to the answer text in the "Questions Inline" layout if labelling is enabled.'),
|
||||
'#default_value' => variable_get('faq_answer_label', 'A:'),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_question_length'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Question length'),
|
||||
'#options' => array('long' => t('Display longer text'), 'short' => t('Display short text'), 'both' => t('Display both short and long questions')),
|
||||
'#description' => t("The length of question text to display on the FAQ page. The short question will always be displayed in the FAQ blocks."),
|
||||
'#default_value' => variable_get('faq_question_length', 'short'),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_question_long_form'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow long question text to be configured'),
|
||||
'#default_value' => variable_get('faq_question_long_form', 1),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_hide_qa_accordion'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use accordion effect for "opens/hides answer under question" layout'),
|
||||
'#description' => t('This enables an "accordion" style effect where when a question is clicked, the answer appears beneath, and is then hidden when another question is opened.'),
|
||||
'#default_value' => variable_get('faq_hide_qa_accordion', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_show_expand_all'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show "expand / collapse all" links for collapsed questions'),
|
||||
'#description' => t('The links will only be displayed if using the "opens/hides answer under question" or "opens/hides questions and answers under category" layouts.'),
|
||||
'#default_value' => variable_get('faq_show_expand_all', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_use_teaser'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use answer teaser'),
|
||||
'#description' => t("This enables the display of the answer teaser text instead of the full answer when using the 'Questions inline' or 'Clicking on question takes user to answer further down the page' display options. This is useful when you have long descriptive text. The user can see the full answer by clicking on the question."),
|
||||
'#default_value' => variable_get('faq_use_teaser', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_show_node_links'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show node links'),
|
||||
'#description' => t('This enables the display of links under the answer text on the faq page. Examples of these links include "Read more", "Add comment".'),
|
||||
'#default_value' => variable_get('faq_show_node_links', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_back_to_top'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('"Back to Top" link text'),
|
||||
'#description' => t('This allows the user to change the text displayed for the links which return the user to the top of the page on certain page layouts. Defaults to "Back to Top". Leave blank to have no link.'),
|
||||
'#default_value' => variable_get('faq_back_to_top', 'Back to Top'),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_disable_node_links'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Disable question links to nodes'),
|
||||
'#description' => t('This allows the user to prevent the questions being links to the faq node in all layouts except "Clicking on question opens the answer in a new page".'),
|
||||
'#default_value' => variable_get('faq_disable_node_links', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_questions_misc']['faq_default_sorting'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default sorting for unordered FAQs'),
|
||||
'#options' => array('DESC' => t('Date Descending'), 'ASC' => t('Date Ascending')),
|
||||
'#description' => t("This controls the default ordering behaviour for new FAQ nodes which haven't been assigned a position."),
|
||||
'#default_value' => variable_get('faq_default_sorting', 'DESC'),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the elements for the FAQ Settings page - categories tab.
|
||||
*
|
||||
* @return
|
||||
* The form code inside the $form array.
|
||||
*/
|
||||
function faq_categories_settings_form() {
|
||||
if (!module_exists("taxonomy")) {
|
||||
drupal_set_message(t('Categorization of questions will not work without the "taxonomy" module being enabled.'), 'error');
|
||||
}
|
||||
drupal_add_js(array('faq' => array('faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE))), 'setting');
|
||||
drupal_add_js(array('faq' => array('faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE))), 'setting');
|
||||
drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');
|
||||
|
||||
// Set up a hidden variable.
|
||||
$form['faq_display'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => variable_get('faq_display', 'questions_top'),
|
||||
);
|
||||
|
||||
$form['faq_use_categories'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Categorize questions'),
|
||||
'#description' => t('This allows the user to display the questions according to the categories configured on the add/edit FAQ page. Use of sub-categories is only recommended for large lists of questions. The Taxonomy module must be enabled and you must configure a FAQ vocabulary at <a href="@url">Content Management > Taxonomy</a>.', array('@url' => url('admin/content/taxonomy'))),
|
||||
'#default_value' => variable_get('faq_use_categories', FALSE),
|
||||
);
|
||||
|
||||
$category_options['none'] = t("Don't display");
|
||||
$category_options['categories_inline'] = t('Categories inline');
|
||||
$category_options['hide_qa'] = t('Clicking on category opens/hides questions and answers under category');
|
||||
$category_options['new_page'] = t('Clicking on category opens the questions/answers in a new page');
|
||||
|
||||
$form['faq_category_display'] = array(
|
||||
'#type' => 'radios',
|
||||
'#options' => $category_options,
|
||||
'#title' => t('Categories layout'),
|
||||
'#description' => t('This controls how the categories are displayed on the page and what happens when someone clicks on the category.'),
|
||||
'#default_value' => variable_get('faq_category_display', 'categories_inline'),
|
||||
);
|
||||
|
||||
$form['faq_category_misc'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Miscellaneous layout settings'),
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['faq_category_misc']['faq_category_listing'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => array('ol' => t('Ordered list'), 'ul' => t('Unordered list')),
|
||||
'#title' => t('Categories listing style'),
|
||||
'#description' => t("This allows to select how the categories listing is presented. It only applies to the 'Clicking on category opens the questions/answers in a new page' layout. An ordered listing would number the categories, whereas an unordered list will have a bullet to the left of each category."),
|
||||
'#default_value' => variable_get('faq_category_listing', 'ul'),
|
||||
);
|
||||
|
||||
$form['faq_category_misc']['faq_category_hide_qa_accordion'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use accordion effect for "opens/hides questions and answers under category" layout'),
|
||||
'#description' => t('This enables an "accordion" style effect where when a category is clicked, the questions appears beneath, and is then hidden when another category is opened.'),
|
||||
'#default_value' => variable_get('faq_category_hide_qa_accordion', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_category_misc']['faq_count'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show FAQ count'),
|
||||
'#description' => t('This displays the number of questions in a category after the category name.'),
|
||||
'#default_value' => variable_get('faq_count', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_category_misc']['faq_answer_category_name'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display category name for answers'),
|
||||
'#description' => t("This allows the user to toggle the visibility of the category name above each answer section for the 'Clicking on question takes user to answer further down the page' question/answer display."),
|
||||
'#default_value' => variable_get('faq_answer_category_name', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_category_misc']['faq_group_questions_top'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t("Group questions and answers for 'Categories inline'"),
|
||||
'#description' => t("This controls how categories are implemented with the 'Clicking on question takes user to answer further down the page' question/answer display."),
|
||||
'#default_value' => variable_get('faq_group_questions_top', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_category_misc']['faq_hide_child_terms'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Only show sub-categories when parent category is selected'),
|
||||
'#description' => t("This allows the user more control over how and when sub-categories are displayed. It does not affect the 'Categories inline' display."),
|
||||
'#default_value' => variable_get('faq_hide_child_terms', FALSE),
|
||||
);
|
||||
|
||||
$form['faq_category_misc']['faq_show_term_page_children'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show sub-categories on FAQ category pages'),
|
||||
'#description' => t("Sub-categories with 'faq' nodes will be displayed on the per category FAQ page. This will also happen if 'Only show sub-categories when parent category is selected' is set."),
|
||||
'#default_value' => variable_get('faq_show_term_page_children', FALSE),
|
||||
);
|
||||
|
||||
if (module_exists('taxonomy')) {
|
||||
$form['faq_category_advanced'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Advanced category settings'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
$vocab_options = array();
|
||||
$vocabularies = taxonomy_get_vocabularies('faq');
|
||||
foreach ($vocabularies as $vid => $vobj) {
|
||||
$vocab_options[$vid] = $vobj->name;
|
||||
}
|
||||
if (!empty($vocab_options)) {
|
||||
$form['faq_category_advanced']['faq_omit_vocabulary'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Omit vocabulary'),
|
||||
'#description' => t('Terms from these vocabularies will be <em>excluded</em> from the FAQ pages.'),
|
||||
'#default_value' => variable_get('faq_omit_vocabulary', array()),
|
||||
'#options' => $vocab_options,
|
||||
'#multiple' => TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
$form['faq_category_advanced']['faq_enable_term_links'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable FAQ taxonomy links'),
|
||||
'#description' => t('Node links to taxonomy terms will be re-written to point at the FAQ pages instead.'),
|
||||
'#default_value' => variable_get('faq_enable_term_links', 1),
|
||||
);
|
||||
}
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the elements for the FAQ Settings page - order tab.
|
||||
*
|
||||
* @param $form_state
|
||||
* Store the submitted form values.
|
||||
* @return
|
||||
* The form code, before being converted to HTML format.
|
||||
*/
|
||||
function faq_order_settings_form($form_state, $category = NULL) {
|
||||
$order = $date_order = '';
|
||||
|
||||
drupal_add_js(array('faq' => array('faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE))), 'setting');
|
||||
drupal_add_js(array('faq' => array('faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE))), 'setting');
|
||||
drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');
|
||||
drupal_add_css(drupal_get_path('module', 'faq') .'/faq.css');
|
||||
|
||||
$use_categories = variable_get('faq_use_categories', FALSE);
|
||||
if (!$use_categories) {
|
||||
$step = "order";
|
||||
}
|
||||
elseif (!isset($form_state['values']) && empty($category)) {
|
||||
$step = "categories";
|
||||
}
|
||||
else {
|
||||
$step = "order";
|
||||
}
|
||||
$form['step'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $step,
|
||||
);
|
||||
|
||||
// Categorized q/a.
|
||||
if ($step == "categories") {
|
||||
|
||||
// Get list of categories.
|
||||
$vocabularies = taxonomy_get_vocabularies('faq');
|
||||
$options = array();
|
||||
foreach ($vocabularies as $vid => $vobj) {
|
||||
$tree = taxonomy_get_tree($vid);
|
||||
foreach ($tree as $term) {
|
||||
if (!taxonomy_term_count_nodes($term->tid, 'faq')) {
|
||||
continue;
|
||||
}
|
||||
$options[$term->tid] = faq_tt("taxonomy:term:$term->tid:name", $term->name);
|
||||
$form['choose_cat']['faq_category'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Choose a category'),
|
||||
'#description' => t('Choose a category that you wish to order the questions for.'),
|
||||
'#options' => $options,
|
||||
'#multiple' => FALSE,
|
||||
);
|
||||
|
||||
$form['choose_cat']['search'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Search'),
|
||||
'#submit' => array('faq_order_settings_choose_cat_form_submit'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$default_sorting = variable_get('faq_default_sorting', 'DESC');
|
||||
$default_weight = 0;
|
||||
if ($default_sorting != 'DESC') {
|
||||
$default_weight = 1000000;
|
||||
}
|
||||
|
||||
$options = array();
|
||||
if (!empty($form_state['values']['faq_category'])) {
|
||||
$category = $form_state['values']['faq_category'];
|
||||
}
|
||||
|
||||
// Uncategorized ordering.
|
||||
if (empty($category)) {
|
||||
$category = 0;
|
||||
// Descending.
|
||||
if ($default_sorting == 'DESC') {
|
||||
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 ORDER BY effective_weight ASC, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $category);
|
||||
}
|
||||
// Ascending.
|
||||
else {
|
||||
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 ORDER BY effective_weight ASC, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $category);
|
||||
}
|
||||
}
|
||||
// Categorized ordering.
|
||||
else {
|
||||
// Descending.
|
||||
if ($default_sorting == 'DESC') {
|
||||
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY effective_weight ASC, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $category, $category);
|
||||
}
|
||||
// Ascending.
|
||||
else {
|
||||
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY effective_weight ASC, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $category, $category);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while ($node = db_fetch_object($result)) {
|
||||
$options[$node->nid] = check_plain($node->title);
|
||||
}
|
||||
|
||||
$form['weight']['faq_category'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $category,
|
||||
);
|
||||
|
||||
// Show table ordering form.
|
||||
$form['order_no_cats']['#tree'] = TRUE;
|
||||
$form['order_no_cats']['#theme'] = 'faq_draggable_question_order_table';
|
||||
|
||||
$i = 0;
|
||||
foreach ($options as $nid => $title) {
|
||||
$form['order_no_cats'][$i]['nid'] = array('#type' => 'hidden', '#value' => $nid);
|
||||
$form['order_no_cats'][$i]['title'] = array('#value' => $title);
|
||||
$form['order_no_cats'][$i]['sort'] = array('#type' => 'weight', '#delta' => count($options), '#default_value' => $i);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save order'),
|
||||
'#weight' => 3,
|
||||
'#submit' => array('faq_order_settings_reorder_form_submit'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function set the rebuild of the form in the FAQ Settings - Weight tab.
|
||||
*
|
||||
* @param $form
|
||||
* Array, containing the form structure.
|
||||
* @param &$form_state
|
||||
* The 'rebuild' key inside $form_state['rebuild'] structure, overrides the
|
||||
* 'redirect' key: when it is set to TRUE, the form will be rebuilt from
|
||||
* scratch and displayed on screen.
|
||||
*/
|
||||
function faq_order_settings_choose_cat_form_submit($form, &$form_state) {
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the options set by the user in the FAQ Settings - Weight tab.
|
||||
*
|
||||
* @param $form
|
||||
* Array, containing the form structure.
|
||||
* @param &$form_state
|
||||
* $form_state['values'] stores the submitted values from the form.
|
||||
*/
|
||||
function faq_order_settings_reorder_form_submit($form, &$form_state) {
|
||||
if ($form_state['values']['op'] == t('Save order') && !empty($form_state['values']['order_no_cats'])) {
|
||||
|
||||
foreach ($form_state['values']['order_no_cats'] as $i => $faq) {
|
||||
$nid = $faq['nid'];
|
||||
$index = $faq['sort'];
|
||||
$result = db_query("DELETE FROM {faq_weights} WHERE tid = %d AND nid = %d", $form_state['values']['faq_category'], $nid);
|
||||
$result = db_query("INSERT INTO {faq_weights} (tid, nid, weight) VALUES(%d, %d, %d)", $form_state['values']['faq_category'], $nid, $index);
|
||||
|
||||
// If node translation module enabled, update order of the translation
|
||||
// node counterparts.
|
||||
if (module_exists('translation')) {
|
||||
$node = node_load($nid);
|
||||
if ($node->tnid) {
|
||||
$translations = translation_node_get_translations($node->tnid);
|
||||
if (!empty($translations)) {
|
||||
foreach ($translations as $language => $tnode) {
|
||||
$result = db_query("DELETE FROM {faq_weights} WHERE tid = %d AND nid = %d", $form_state['values']['faq_category'], $tnode->nid);
|
||||
$result = db_query("INSERT INTO {faq_weights} (tid, nid, weight) VALUES(%d, %d, %d)", $form_state['values']['faq_category'], $tnode->nid, $index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drupal_set_message(t('Configuration has been updated.'));
|
||||
}
|
||||
}
|
||||
|
63
modules/faq/faq.css
Normal file
63
modules/faq/faq.css
Normal file
|
@ -0,0 +1,63 @@
|
|||
.faq-category-indent {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.faq-more-link {
|
||||
font-size: 0.85em;
|
||||
margin-left: 30em;
|
||||
margin-top: 0;
|
||||
margin-bottom: -1.25em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.faq-top-link {
|
||||
font-size: 0.8em;
|
||||
margin-top:0;
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 1.0em;
|
||||
}
|
||||
|
||||
.faq-question {
|
||||
padding-top: 5px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.faq-answer {
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.faq-answer .faq-answer-label {
|
||||
float: left;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
|
||||
.faq-dl-hide-answer {
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
img.faq-tax-image {
|
||||
float: left;
|
||||
padding: 0px 3px 0px 3px;
|
||||
}
|
||||
|
||||
div.faq-detailed-question {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.faq .collapsible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.faq .collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.faq #faq-expand-all {
|
||||
text-align: right;
|
||||
display: none;
|
||||
}
|
||||
.faq #faq-expand-all a.faq-expand-all-link,
|
||||
.faq #faq-expand-all a.faq-collapse-all-link {
|
||||
display: none;
|
||||
}
|
10
modules/faq/faq.info
Normal file
10
modules/faq/faq.info
Normal file
|
@ -0,0 +1,10 @@
|
|||
name = Frequently Asked Questions
|
||||
description = "Manages configuration of questions for a FAQ page."
|
||||
package = Core - extended
|
||||
core = 6.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-02-22
|
||||
version = "6.x-1.13"
|
||||
core = "6.x"
|
||||
project = "faq"
|
||||
datestamp = "1329951344"
|
170
modules/faq/faq.install
Normal file
170
modules/faq/faq.install
Normal file
|
@ -0,0 +1,170 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* FAQ module install file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the 'faq_weights' and 'faq_questions' table structures.
|
||||
*
|
||||
* @return
|
||||
* The schema which contains the structure for the faq module's tables.
|
||||
*/
|
||||
function faq_schema() {
|
||||
$schema['faq_weights'] = array(
|
||||
'description' => 'A table containing the weight of each faq node by category.',
|
||||
'fields' => array(
|
||||
'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The primary identifier for a term or category. This will be 0 for non-categorized nodes.'),
|
||||
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The primary identifier for a node.'),
|
||||
'weight' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'description' => 'A number representing the weight of a node. Nodes with lower weight values will appear above those with higher weight values.'),
|
||||
),
|
||||
'primary key' => array('nid', 'tid'),
|
||||
);
|
||||
|
||||
$schema['faq_questions'] = array(
|
||||
'description' => 'A table containing the long question text of each faq node revision.',
|
||||
'fields' => array(
|
||||
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The primary identifier for a node.'),
|
||||
'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The primary identifier for a node revision.'),
|
||||
'question' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE, 'description' => 'The faq short question text.'),
|
||||
'detailed_question' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE, 'description' => 'The faq long question text.'),
|
||||
),
|
||||
'primary key' => array('nid', 'vid'),
|
||||
);
|
||||
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*
|
||||
* Inserts the FAQ module's schema in the SQL database.
|
||||
*/
|
||||
function faq_install() {
|
||||
drupal_install_schema('faq');
|
||||
variable_set('node_options_faq', array('status'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall().
|
||||
*
|
||||
* Remove the variables, nodes and schema corresponding to the FAQ module.
|
||||
*/
|
||||
function faq_uninstall() {
|
||||
// Delete the variables we created.
|
||||
// General settings.
|
||||
variable_del('faq_title');
|
||||
variable_del('faq_description');
|
||||
variable_del('faq_description_format');
|
||||
// Questions page.
|
||||
variable_del('faq_display');
|
||||
variable_del('faq_question_listing');
|
||||
variable_del('faq_qa_mark');
|
||||
variable_del('faq_question_label');
|
||||
variable_del('faq_answer_label');
|
||||
variable_del('faq_question_length');
|
||||
variable_del('faq_hide_qa_accordion');
|
||||
variable_del('faq_show_expand_all');
|
||||
variable_del('faq_use_teaser');
|
||||
variable_del('faq_show_node_links');
|
||||
variable_del('faq_back_to_top');
|
||||
variable_del('faq_disable_node_links');
|
||||
variable_del('faq_default_sorting');
|
||||
// Categories page.
|
||||
variable_del('faq_use_categories');
|
||||
variable_del('faq_category_display');
|
||||
variable_del('faq_category_listing');
|
||||
variable_del('faq_category_hide_qa_accordion');
|
||||
variable_del('faq_count');
|
||||
variable_del('faq_answer_category_name');
|
||||
variable_del('faq_group_questions_top');
|
||||
variable_del('faq_hide_child_terms');
|
||||
variable_del('faq_show_term_page_children');
|
||||
variable_del('faq_omit_vocabulary');
|
||||
variable_del('faq_enable_term_links');
|
||||
// Block settings.
|
||||
variable_del('faq_block_recent_faq_count');
|
||||
variable_del('faq_block_random_faq_count');
|
||||
// Custom breadcrumbs control
|
||||
variable_del('faq_custom_breadcrumbs');
|
||||
|
||||
// Deprecated.
|
||||
variable_del('faq_more_link');
|
||||
|
||||
drupal_uninstall_schema('faq');
|
||||
|
||||
// Clear the cache tables.
|
||||
cache_clear_all('*', 'cache', TRUE);
|
||||
cache_clear_all('*', 'cache_filter', TRUE);
|
||||
cache_clear_all('*', 'cache_menu', TRUE);
|
||||
cache_clear_all('*', 'cache_page', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 'faq_weights' table in order to upgrade from older installations.
|
||||
*
|
||||
* Should have been created with faq_update_600x() naming convention, but too
|
||||
* late now.
|
||||
*
|
||||
* @return
|
||||
* An array containing the structure of the SQL schema.
|
||||
*/
|
||||
function faq_update_1() {
|
||||
$schema['faq_weights'] = array(
|
||||
'description' => 'A table containing the weight of each faq node by category.',
|
||||
'fields' => array(
|
||||
'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
||||
'weight' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
|
||||
),
|
||||
'primary key' => array('nid', 'tid'),
|
||||
);
|
||||
|
||||
$ret = array();
|
||||
db_create_table($ret, 'faq_weights', $schema['faq_weights']);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 'faq_questions' table in order to upgrade from older installations.
|
||||
*
|
||||
* Should have been created with faq_update_600x() naming convention, but too
|
||||
* late now.
|
||||
*
|
||||
* @return
|
||||
* An array containing the results of the update.
|
||||
*/
|
||||
function faq_update_2() {
|
||||
$schema['faq_questions'] = array(
|
||||
'description' => 'A table containing the long question text of each faq node revision.',
|
||||
'fields' => array(
|
||||
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The primary identifier for a node.'),
|
||||
'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The primary identifier for a node revision.'),
|
||||
'question' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE, 'description' => 'The faq long question text.'),
|
||||
),
|
||||
'primary key' => array('nid', 'vid'),
|
||||
);
|
||||
|
||||
$ret = array();
|
||||
db_create_table($ret, 'faq_questions', $schema['faq_questions']);
|
||||
|
||||
$ret[] = update_sql("INSERT INTO {faq_questions} (nid, vid, question) SELECT r.nid, r.vid, r.title FROM {node_revisions} r, {node} n WHERE n.nid = r.nid AND n.type = 'faq'");
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the 'detailed_question' column to the 'faq_questions' table.
|
||||
*
|
||||
* @return
|
||||
* An array containing the results of the update.
|
||||
*/
|
||||
function faq_update_6003() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'faq_questions', 'detailed_question', array('type' => 'text', 'size' => 'normal', 'not null' => TRUE));
|
||||
$ret[] = update_sql("UPDATE {faq_questions} SET detailed_question = question");
|
||||
return $ret;
|
||||
}
|
272
modules/faq/faq.js
Normal file
272
modules/faq/faq.js
Normal file
|
@ -0,0 +1,272 @@
|
|||
|
||||
function teaser_handler(event) {
|
||||
if ($("input[name=faq_display]:checked").val() != "new_page") {
|
||||
if ($("input[name=faq_use_teaser]:checked").val() == 1) {
|
||||
$("input[name=faq_more_link]").removeAttr("disabled");
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_more_link]").attr("disabled", "disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function faq_display_handler(event) {
|
||||
// Enable / disable "questions_inline" and "questions_top" only settings.
|
||||
if ($("input[name=faq_display]:checked").val() == "questions_inline" || $("input[name=faq_display]:checked").val() == "questions_top") {
|
||||
$("input[name=faq_back_to_top]").removeAttr("disabled");
|
||||
$("input[name=faq_qa_mark]").removeAttr("disabled");
|
||||
// Enable / disable label settings according to "qa_mark" setting.
|
||||
if ($("input[name=faq_qa_mark]:checked").val() == 1) {
|
||||
$("input[name=faq_question_label]").removeAttr("disabled");
|
||||
$("input[name=faq_answer_label]").removeAttr("disabled");
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_question_label]").attr("disabled", "disabled");
|
||||
$("input[name=faq_answer_label]").attr("disabled", "disabled");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_back_to_top]").attr("disabled", "disabled");
|
||||
$("input[name=faq_qa_mark]").attr("disabled", "disabled");
|
||||
$("input[name=faq_question_label]").attr("disabled", "disabled");
|
||||
$("input[name=faq_answer_label]").attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
// Enable / disable "hide_answer" only settings.
|
||||
if ($("input[name=faq_display]:checked").val() != "hide_answer") {
|
||||
$("input[name=faq_hide_qa_accordion]").attr("disabled", "disabled");
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_hide_qa_accordion]").removeAttr("disabled");
|
||||
}
|
||||
|
||||
// Enable / disable "new_page" only settings.
|
||||
if ($("input[name=faq_display]:checked").val() != "new_page") {
|
||||
$("input[name=faq_use_teaser]").removeAttr("disabled");
|
||||
$("input[name=faq_more_link]").removeAttr("disabled");
|
||||
$("input[name=faq_disable_node_links]").removeAttr("disabled");
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_use_teaser]").attr("disabled", "disabled");
|
||||
$("input[name=faq_more_link]").attr("disabled", "disabled");
|
||||
$("input[name=faq_disable_node_links]").attr("disabled", "disabled");
|
||||
}
|
||||
teaser_handler(event);
|
||||
|
||||
// Enable / disable "new_page" and "questions_top" only settings.
|
||||
if ($("input[name=faq_display]:checked").val() == "new_page" ||
|
||||
$("input[name=faq_display]:checked").val() == "questions_top") {
|
||||
$("select[name=faq_question_listing]").removeAttr("disabled");
|
||||
}
|
||||
else {
|
||||
$("select[name=faq_question_listing]").attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function qa_mark_handler(event) {
|
||||
if ($("input[name=faq_display]:checked").val() == "questions_inline") {
|
||||
// Enable / disable label settings according to "qa_mark" setting.
|
||||
if ($("input[name=faq_qa_mark]:checked").val() == 1) {
|
||||
$("input[name=faq_question_label]").removeAttr("disabled");
|
||||
$("input[name=faq_answer_label]").removeAttr("disabled");
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_question_label]").attr("disabled", "disabled");
|
||||
$("input[name=faq_answer_label]").attr("disabled", "disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function questions_top_handler(event) {
|
||||
$("input[name=faq_display]").val() == "questions_top" ?
|
||||
$("input[name=faq_group_questions_top]").removeAttr("disabled"):
|
||||
$("input[name=faq_group_questions_top]").attr("disabled", "disabled");
|
||||
|
||||
$("input[name=faq_display]").val() == "questions_top" ?
|
||||
$("input[name=faq_answer_category_name]").removeAttr("disabled"):
|
||||
$("input[name=faq_answer_category_name]").attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
|
||||
function child_term_handler(event) {
|
||||
if ($("input[name=faq_hide_child_terms]:checked").val() == 1) {
|
||||
$("input[name=faq_show_term_page_children]").attr("disabled", "disabled");
|
||||
}
|
||||
else if ($("input[name=faq_category_display]:checked").val() != "categories_inline") {
|
||||
$("input[name=faq_show_term_page_children]").removeAttr("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function categories_handler(event) {
|
||||
if ($("input[name=faq_display]").val() == "questions_top") {
|
||||
$("input[name=faq_category_display]:checked").val() == "categories_inline" ?
|
||||
$("input[name=faq_group_questions_top]").removeAttr("disabled"):
|
||||
$("input[name=faq_group_questions_top]").attr("disabled", "disabled");
|
||||
$("input[name=faq_category_display]:checked").val() == "new_page" ?
|
||||
$("input[name=faq_answer_category_name]").attr("disabled", "disabled"):
|
||||
$("input[name=faq_answer_category_name]").removeAttr("disabled");
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_group_questions_top]").attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
// Enable / disable "hide_qa" only settings.
|
||||
if ($("input[name=faq_category_display]:checked").val() != "hide_qa") {
|
||||
$("input[name=faq_category_hide_qa_accordion]").attr("disabled", "disabled");
|
||||
}
|
||||
else {
|
||||
$("input[name=faq_category_hide_qa_accordion]").removeAttr("disabled");
|
||||
}
|
||||
|
||||
$("input[name=faq_category_display]:checked").val() == "categories_inline" ?
|
||||
$("input[name=faq_hide_child_terms]").attr("disabled", "disabled"):
|
||||
$("input[name=faq_hide_child_terms]").removeAttr("disabled");
|
||||
$("input[name=faq_category_display]:checked").val() == "categories_inline" ?
|
||||
$("input[name=faq_show_term_page_children]").attr("disabled", "disabled"):
|
||||
$("input[name=faq_show_term_page_children]").removeAttr("disabled");
|
||||
$("input[name=faq_category_display]:checked").val() == "new_page" ?
|
||||
$("select[name=faq_category_listing]").removeAttr("disabled"):
|
||||
$("select[name=faq_category_listing]").attr("disabled", "disabled");
|
||||
|
||||
child_term_handler();
|
||||
}
|
||||
|
||||
Drupal.behaviors.initFaqModule = function (context) {
|
||||
// Hide/show answer for a question.
|
||||
var faq_hide_qa_accordion = Drupal.settings.faq.faq_hide_qa_accordion;
|
||||
$('div.faq-dd-hide-answer', context).addClass("collapsible collapsed");
|
||||
|
||||
if (!faq_hide_qa_accordion) {
|
||||
$('div.faq-dd-hide-answer:not(.faq-processed)', context).addClass('faq-processed').hide();
|
||||
}
|
||||
|
||||
$('div.faq-dt-hide-answer:not(.faq-processed)', context).addClass('faq-processed').click(function() {
|
||||
if (faq_hide_qa_accordion) {
|
||||
$('div.faq-dt-hide-answer').not($(this)).removeClass('faq-qa-visible');
|
||||
}
|
||||
$(this).toggleClass('faq-qa-visible');
|
||||
$(this).parent().addClass('faq-viewed');
|
||||
$('div.faq-dd-hide-answer').not($(this).next('div.faq-dd-hide-answer')).addClass("collapsed");
|
||||
if (!faq_hide_qa_accordion) {
|
||||
$(this).next('div.faq-dd-hide-answer').slideToggle('fast', function() {
|
||||
$(this).parent().toggleClass('expanded');
|
||||
});
|
||||
}
|
||||
$(this).next('div.faq-dd-hide-answer').toggleClass("collapsed");
|
||||
|
||||
// Change the fragment, too, for permalink/bookmark.
|
||||
// To keep the current page from scrolling, refs
|
||||
// http://stackoverflow.com/questions/1489624/modifying-document-location-hash-without-page-scrolling/1489802#1489802
|
||||
var hash = $(this).find('a').attr('id');
|
||||
var fx, node = $('#' + hash);
|
||||
if (node.length) {
|
||||
fx = $('<div></div>')
|
||||
.css({position: 'absolute', visibility: 'hidden', top: $(window).scrollTop() + 'px'})
|
||||
.attr('id', hash)
|
||||
.appendTo(document.body);
|
||||
node.attr('id', '');
|
||||
}
|
||||
document.location.hash = hash;
|
||||
if (node.length) {
|
||||
fx.remove();
|
||||
node.attr('id', hash);
|
||||
}
|
||||
|
||||
// Scroll the page if the collapsed FAQ is not visible.
|
||||
// If we have the toolbar so the title may be hidden by the bar.
|
||||
var mainScrollTop = Math.max($('html', context).scrollTop(), $('body', context).scrollTop());
|
||||
// We compute mainScrollTop because the behaviour is different on FF, IE and CR
|
||||
if (mainScrollTop > $(this).offset().top) {
|
||||
$('html, body', context).animate({
|
||||
scrollTop: $(this).offset().top
|
||||
}, 1);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Show any question identified by a fragment
|
||||
if (/^#\w+$/.test(document.location.hash)) {
|
||||
$('div.faq-dt-hide-answer > ' + document.location.hash).parent().triggerHandler('click');
|
||||
}
|
||||
|
||||
// Hide/show q/a for a category.
|
||||
var faq_category_hide_qa_accordion = Drupal.settings.faq.faq_category_hide_qa_accordion;
|
||||
$('div.faq-qa-hide', context).addClass("collapsible collapsed");
|
||||
if (!faq_category_hide_qa_accordion) {
|
||||
$('div.faq-qa-hide', context).hide();
|
||||
}
|
||||
$('div.faq-qa-header .faq-header:not(.faq-processed)', context).addClass('faq-processed').click(function() {
|
||||
if (faq_category_hide_qa_accordion) {
|
||||
$('div.faq-qa-header .faq-header').not($(this)).removeClass('faq-category-qa-visible');
|
||||
}
|
||||
$(this).toggleClass('faq-category-qa-visible');
|
||||
$('div.faq-qa-hide').not($(this).parent().next('div.faq-qa-hide')).addClass("collapsed");
|
||||
if (!faq_category_hide_qa_accordion) {
|
||||
$(this).parent().next('div.faq-qa-hide').slideToggle('fast', function() {
|
||||
$(this).parent().toggleClass('expanded');
|
||||
});
|
||||
}
|
||||
$(this).parent().next('div.faq-qa-hide').toggleClass("collapsed");
|
||||
|
||||
// Scroll the page if the collapsed FAQ is not visible.
|
||||
// If we have the toolbar so the title may be hidden by the bar.
|
||||
var mainScrollTop = Math.max($('html', context).scrollTop(), $('body', context).scrollTop());
|
||||
// We compute mainScrollTop because the behaviour is different on FF, IE and CR
|
||||
if (mainScrollTop > $(this).offset().top) {
|
||||
$('html, body', context).animate({
|
||||
scrollTop: $(this).offset().top
|
||||
}, 1);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// Show expand all link.
|
||||
if (!faq_hide_qa_accordion && !faq_category_hide_qa_accordion) {
|
||||
$('#faq-expand-all', context).show();
|
||||
$('#faq-expand-all a.faq-expand-all-link', context).show();
|
||||
|
||||
// Add collapse link click event.
|
||||
$('#faq-expand-all a.faq-collapse-all-link:not(.faq-processed)', context).addClass('faq-processed').click(function () {
|
||||
$(this).hide();
|
||||
$('#faq-expand-all a.faq-expand-all-link').show();
|
||||
$('div.faq-qa-hide').slideUp('slow', function() {
|
||||
$(this).removeClass('expanded');
|
||||
});
|
||||
$('div.faq-dd-hide-answer').slideUp('slow', function() {
|
||||
$(this).removeClass('expanded');
|
||||
});
|
||||
});
|
||||
|
||||
// Add expand link click event.
|
||||
$('#faq-expand-all a.faq-expand-all-link:not(.faq-processed)', context).addClass('faq-processed').click(function () {
|
||||
$(this).hide();
|
||||
$('#faq-expand-all a.faq-collapse-all-link').show();
|
||||
$('div.faq-qa-hide').slideDown('slow', function() {
|
||||
$(this).addClass('expanded');
|
||||
});
|
||||
$('div.faq-dd-hide-answer').slideDown('slow', function() {
|
||||
$(this).addClass('expanded');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Handle faq_category_settings_form.
|
||||
faq_display_handler();
|
||||
questions_top_handler();
|
||||
categories_handler();
|
||||
teaser_handler();
|
||||
$("input[name=faq_display]:not(.faq-processed)", context).addClass('faq-processed').bind("click", faq_display_handler);
|
||||
$("input[name=faq_qa_mark]:not(.faq-processed)", context).addClass('faq-processed').bind("click", qa_mark_handler);
|
||||
$("input[name=faq_use_teaser]:not(.faq-processed)", context).addClass('faq-processed').bind("click", teaser_handler);
|
||||
$("input[name=faq_category_display]:not(.faq-processed)", context).addClass('faq-processed').bind("click", categories_handler);
|
||||
$("input[name=faq_hide_child_terms]:not(.faq-processed)", context).addClass('faq-processed').bind("click", child_term_handler);
|
||||
}
|
||||
|
||||
|
1520
modules/faq/faq.module
Normal file
1520
modules/faq/faq.module
Normal file
File diff suppressed because it is too large
Load diff
281
modules/faq/faq.test
Normal file
281
modules/faq/faq.test
Normal file
|
@ -0,0 +1,281 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test FAQ functionality Base test class. All tests inherits this one.
|
||||
* Hugely based on code from the test file block.test by boombatower
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class that is extended by test cases.
|
||||
*/
|
||||
class FaqTestCase extends DrupalWebTestCase {
|
||||
|
||||
|
||||
protected $admin_user, $faq_user;
|
||||
protected $taxonomy;
|
||||
protected $term, $faq1, $faq2;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('FAQ functionality'),
|
||||
'description' => t('Base class. No tests here.'),
|
||||
'group' => t('Frequently Asked Questions'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
|
||||
// Install FAQ Module.
|
||||
parent::setUp('taxonomy', 'faq');
|
||||
|
||||
// Create and log in user with administer taxonomy permissions.
|
||||
$this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'administer faq', 'administer faq order', 'administer blocks'));
|
||||
$this->faq_user = $this->drupalCreateUser(array('create faq', 'edit faq', 'delete faq content', 'view faq page', 'access content'));
|
||||
$this->view_faq_user = $this->drupalCreateUser(array('view faq page', 'access content'));
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
// Set up the vocab and terms.
|
||||
$this->setupTaxonomy();
|
||||
|
||||
// Categorize questions.
|
||||
$this->drupalPost('admin/settings/faq/categories', array('faq_use_categories' => '1'), t('Save configuration'));
|
||||
|
||||
// Set answer_user as default expert.
|
||||
$roles = $this->faq_user->roles;
|
||||
end($roles); // Set to last role (the unique one)
|
||||
|
||||
// Start all tests logged out.
|
||||
$this->drupalLogout();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear the whole thing down again
|
||||
*/
|
||||
function tearDown() {
|
||||
|
||||
// Things to tidy up like vars and stuff
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random string of ASCII numeric characters (values 48 to 57).
|
||||
*
|
||||
* @param $length
|
||||
* Length of random string to generate .
|
||||
* @return
|
||||
* Randomly generated string.
|
||||
*/
|
||||
protected static function randomNumber($length = 8) {
|
||||
$str = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$str .= chr(mt_rand(48, 57));
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that current user has no access to page.
|
||||
*
|
||||
* @param $url
|
||||
* URL to verify.
|
||||
*/
|
||||
function faqVerifyNoAccess($url) {
|
||||
// Test that page returns 403 Access Denied
|
||||
$this->drupalGet($url);
|
||||
$this->assertResponse(403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the taxonomy - all vocabularies and stuff
|
||||
* Values also stored in protected variable $tax
|
||||
*/
|
||||
function setupTaxonomy() {
|
||||
|
||||
// Create vocabulary.
|
||||
$this->taxonomy = array();
|
||||
$this->taxonomy['name'] = $this->randomName(8); // Create taxonomy vocabulary name
|
||||
$this->taxonomy['description'] = $this->randomName(64);
|
||||
$this->taxonomy['nodes[faq]'] = '1'; // Assign vocab to FAQ node types
|
||||
$this->taxonomy['tags'] = '1'; // Users may create tags
|
||||
$this->taxonomy['multiple'] = '1'; // may have more than one tag
|
||||
$this->taxonomy['required'] = '1'; // but minimum 1 tag
|
||||
$this->drupalPost('admin/content/taxonomy/add/vocabulary', $this->taxonomy, t('Save'));
|
||||
$this->assertText(t('Created new vocabulary @name', array('@name' => $this->taxonomy['name'])));
|
||||
|
||||
$this->assertText(t('FAQ'));
|
||||
|
||||
// Add term
|
||||
// Click the last occurrence of the link.
|
||||
$this->clickLink(t('add terms'), substr_count($this->drupalGetContent(), 'add terms') - 1);
|
||||
$this->assertText(t('Add term to @name', array('@name' => $this->taxonomy['name']) ));
|
||||
|
||||
$url = parse_url($this->getUrl());
|
||||
if ($url['query'] == '') {
|
||||
$array = split('/', $url['path']);
|
||||
$this->taxonomy['id'] = $array[4];
|
||||
}
|
||||
else {
|
||||
$array = split('/', $url['query']);
|
||||
$this->taxonomy['id'] = $array[3];
|
||||
}
|
||||
$this->pass(var_export($array, TRUE));
|
||||
|
||||
$url = $this->getUrl();
|
||||
$this->term = array();
|
||||
$this->term['name'] = $this->randomName(8); // Create taxonomy vocabulary name
|
||||
$this->term['description'] = $this->randomName(64);
|
||||
$this->drupalPost($url, $this->term, t('Save'));
|
||||
$this->assertText(t('Created new term @name', array('@name' => $this->term['name'])));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FaqAccessTestClass extends FaqTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Access to FAQ pages'),
|
||||
'description' => t('Access to pages by anonymous user and logged in user with rights.'),
|
||||
'group' => t('Frequently Asked Questions'),
|
||||
);
|
||||
}
|
||||
|
||||
function testFaqAccess() {
|
||||
|
||||
// Verify that anonymous user has no access to the faq page
|
||||
$this->faqVerifyNoAccess('faq');
|
||||
|
||||
// Create and login user
|
||||
$normal_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($normal_user);
|
||||
|
||||
// Verify that logged in user has no access to the faq page
|
||||
$this->faqVerifyNoAccess('faq');
|
||||
$this->drupalLogout();
|
||||
|
||||
$this->drupalLogin($this->view_faq_user);
|
||||
|
||||
// Verify that the faq page is visible and available but empty
|
||||
$this->drupalGet('faq');
|
||||
$this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CRUDFaqTestCase extends FaqTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('CRUD FAQ node'),
|
||||
'description' => t('Create, Read, Update and Delete a FAQ node.'),
|
||||
'group' => t('Frequently Asked Questions'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating a FAQ node
|
||||
*/
|
||||
function testFaqCreate() {
|
||||
|
||||
// Log in user with create FAQ permissions
|
||||
$this->drupalLogin($this->faq_user);
|
||||
|
||||
// Fill in the Create FAQ node 1 form and post it
|
||||
$this->faq1 = array();
|
||||
$this->faq1['title'] = $this->randomName(8);
|
||||
$this->faq1['taxonomy[tags][1]'] = $this->term['name']; // Add existing term
|
||||
$this->faq1['detailed_question'] = $this->randomName(16);
|
||||
$this->faq1['body'] = $this->randomName(16);
|
||||
$this->drupalPost('node/add/faq', $this->faq1, t('Save'));
|
||||
|
||||
// Check that new FAQ node has actually been created
|
||||
$this->assertText(t('FAQ @title has been created.', array('@title' => $this->faq1['title'])));
|
||||
|
||||
// Fill in the Create FAQ node 2 form and post it
|
||||
$this->faq2 = array();
|
||||
$this->faq2['title'] = $this->randomName(8);
|
||||
$this->faq2['taxonomy[tags][1]'] = $this->randomName(8); // Add new term
|
||||
$this->faq2['detailed_question'] = $this->randomName(16);
|
||||
$this->faq2['body'] = $this->randomName(16);
|
||||
$this->drupalPost('node/add/faq', $this->faq2, t('Save'));
|
||||
|
||||
// Check that new FAQ node has actually been created
|
||||
$this->assertText(t('FAQ @title has been created.', array('@title' => $this->faq2['title'])));
|
||||
|
||||
$this->drupalLogout();
|
||||
|
||||
// Check that the FAQ page is available and that the correct term is listed as grouping for the new FAQ node
|
||||
$this->drupalLogin($this->view_faq_user);
|
||||
$this->drupalGet('faq');
|
||||
$this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
|
||||
$this->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.'));
|
||||
$this->assertText($this->faq1['taxonomy[tags][1]'], t('Term for node 1 available on FAQ page.'));
|
||||
$this->assertText($this->faq2['title'], t('Created FAQ node 2 available on FAQ page.'));
|
||||
$this->assertText($this->faq2['taxonomy[tags][1]'], t('Term for node 2 available on FAQ page.'));
|
||||
|
||||
// Navigate to FAQ node created on FAQ page
|
||||
$this->clickLink(t($this->faq1['title']));
|
||||
$this->assertText(t($this->faq1['body']));
|
||||
|
||||
// Log in user with administer FAQ settings.
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
// Enable categorisation of FAQ nodes
|
||||
// faq_use_categories
|
||||
$conf = array();
|
||||
$conf['faq_use_categories'] = '1'; // Enable categorised FAQs
|
||||
$this->drupalPost('admin/settings/faq/categories', $conf, t('Save configuration'));
|
||||
$this->drupalLogout();
|
||||
|
||||
$this->drupalLogin($this->view_faq_user);
|
||||
$this->drupalGet('faq');
|
||||
$this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
|
||||
$this->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.'));
|
||||
$this->assertText($this->faq1['taxonomy[tags][1]'], t('Term for node 1 not available on FAQ page.'));
|
||||
$this->assertText($this->faq2['title'], t('Created FAQ node 2 available on FAQ page.'));
|
||||
$this->assertText($this->faq2['taxonomy[tags][1]'], t('Term for node 2 not available on FAQ page.'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test editing and deleting of an FAQ node.
|
||||
*/
|
||||
public function testFaqEditDelete() {
|
||||
|
||||
// Log in user with create FAQ permissions
|
||||
$this->drupalLogin($this->faq_user);
|
||||
|
||||
// Create a FAQ node.
|
||||
$edit = array();
|
||||
$edit['title'] = $this->randomName(8);
|
||||
$edit['taxonomy[tags][' . $this->taxonomy['id'] . ']'] = $this->randomName(8);
|
||||
$edit['detailed_question'] = $this->randomName(64);
|
||||
$edit['body'] = $this->randomString(264);
|
||||
$this->drupalPost('node/add/faq', $edit, t('Save'));
|
||||
$this->assertText(t('FAQ @title has been created.', array('@title' => $edit['title'])));
|
||||
|
||||
// Check status for FAQ node - should be published
|
||||
$node = $this->drupalGetNodeByTitle($edit['title']);
|
||||
$this->assertTrue($node->status);
|
||||
|
||||
// Update FAQ
|
||||
$this->drupalGet('node/' . $node->nid . '/edit'); // Open edit page with node
|
||||
$edit2['title'] = 'title-' . $this->randomName(8);
|
||||
$edit2['body'] = 'body-' . $this->randomName(64);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', array('title' => $edit2['title'], 'body' => $edit2['body']), t('Save'));
|
||||
$this->assertText(t('FAQ @title has been updated.', array('@title' => $edit2['title'])));
|
||||
$this->assertText($edit2['title'], 'Title has changed');
|
||||
$this->assertText($edit2['body'], 'Body has changed');
|
||||
|
||||
// Delete FAQ
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', array(), t('Delete'));
|
||||
$this->assertText(t('Are you sure you want to delete @title?', array('@title' => $edit2['title'])));
|
||||
$this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
|
||||
$this->assertText(t('FAQ @title has been deleted.', array('@title' => $edit2['title'])));
|
||||
}
|
||||
}
|
||||
|
136
modules/faq/includes/faq-category-hide-answer.tpl.php
Normal file
136
modules/faq/includes/faq-category-hide-answer.tpl.php
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the FAQ page if set to show/hide categorized answers when
|
||||
* the question is clicked.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $display_header
|
||||
* Boolean value controlling whether a header should be displayed.
|
||||
* $header_title
|
||||
* The category title.
|
||||
* $category_depth
|
||||
* The term or category depth.
|
||||
* $description
|
||||
* The current page's description.
|
||||
* $term_image
|
||||
* The HTML for the category image. This is empty if the taxonomy image module
|
||||
* is not enabled or there is no image associated with the term.
|
||||
* $display_faq_count
|
||||
* Boolean value controlling whether or not the number of faqs in a category
|
||||
* should be displayed.
|
||||
* $question_count
|
||||
* The number of questions in category.
|
||||
* $nodes
|
||||
* An array of nodes to be displayed.
|
||||
* Each node stored in the $nodes array has the following information:
|
||||
* $node['question'] is the question text.
|
||||
* $node['body'] is the answer text.
|
||||
* $node['links'] represents the node links, e.g. "Read more".
|
||||
* $use_teaser
|
||||
* Whether $node['body'] contains the full body or just the teaser text.
|
||||
* $container_class
|
||||
* The class attribute of the element containing the sub-categories, either
|
||||
* 'faq-qa' or 'faq-qa-hide'. This is used by javascript to open/hide
|
||||
* a category's faqs.
|
||||
* $subcat_list
|
||||
* An array of sub-categories. Each sub-category stored in the $subcat_list
|
||||
* array has the following information:
|
||||
* $subcat['link'] is the link to the sub-category.
|
||||
* $subcat['description'] is the sub-category description.
|
||||
* $subcat['count'] is the number of questions in the sub-category.
|
||||
* $subcat['term_image'] is the sub-category (taxonomy) image.
|
||||
* $subcat_list_style
|
||||
* The style of the sub-category list, either ol or ul (ordered or unordered).
|
||||
* $subcat_body_list
|
||||
* The sub-categories faqs, recursively themed (by this template).
|
||||
*/
|
||||
|
||||
if ($category_depth > 0) {
|
||||
$hdr = 'h6';
|
||||
}
|
||||
else {
|
||||
$hdr = 'h5';
|
||||
}
|
||||
|
||||
?><div class="faq-category-group">
|
||||
<!-- category header with title, link, image, description, and count of
|
||||
questions inside -->
|
||||
<div class="faq-qa-header">
|
||||
<?php if ($display_header): ?>
|
||||
<<?php print $hdr; ?> class="faq-header">
|
||||
<?php print $term_image; ?>
|
||||
<?php print $header_title; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $question_count; ?>)
|
||||
<?php endif; ?>
|
||||
</<?php print $hdr; ?>>
|
||||
|
||||
<?php else: ?>
|
||||
<?php print $term_image; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($description)): ?>
|
||||
<div class="faq-qa-description"><?php print $description ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($term_image)): ?>
|
||||
<div class="clear-block"></div>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-qa-header -->
|
||||
|
||||
<?php if (!empty($subcat_list)): ?>
|
||||
<!-- list subcategories, with title, link, description, count -->
|
||||
<div class="item-list">
|
||||
<<?php print $subcat_list_style; ?> class="faq-category-list">
|
||||
<?php foreach ($subcat_list as $i => $subcat): ?>
|
||||
<li>
|
||||
<?php print $subcat['link']; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $subcat['count']; ?>)
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($subcat['description'])): ?>
|
||||
<div class="faq-qa-description"><?php print $subcat['description']; ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="clear-block"></div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</<?php print $subcat_list_style; ?>>
|
||||
</div> <!-- Close div: item-list -->
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="<?php print $container_class; ?>">
|
||||
|
||||
<!-- include subcategories -->
|
||||
<?php if (count($subcat_body_list)): ?>
|
||||
<?php foreach ($subcat_body_list as $i => $subcat_html): ?>
|
||||
<div class="faq-category-indent"><?php print $subcat_html; ?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- list questions (in title link) and answers (in body) -->
|
||||
<div class="faq-dl-hide-answer">
|
||||
<?php if (count($nodes)): ?>
|
||||
<?php foreach ($nodes as $i => $node): ?>
|
||||
<div class="faq-question-answer">
|
||||
<div class="faq-question faq-dt-hide-answer">
|
||||
<?php print $node['question']; ?>
|
||||
</div> <!-- Close div: faq-question faq-dt-hide-answer -->
|
||||
|
||||
<div class="faq-answer faq-dd-hide-answer">
|
||||
<?php print $node['body']; ?>
|
||||
<?php if (isset($node['links'])): ?>
|
||||
<?php print $node['links']; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-answer faq-dd-hide-answer -->
|
||||
</div> <!-- Close div: faq-question-answer -->
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-dl-hide-answer -->
|
||||
|
||||
</div> <!-- Close div: faq-qa / faq-qa-hide -->
|
||||
|
||||
</div> <!-- Close div: faq-category-group -->
|
126
modules/faq/includes/faq-category-new-page.tpl.php
Normal file
126
modules/faq/includes/faq-category-new-page.tpl.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the FAQ page if set to show the categorized answer in a
|
||||
* new page.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $display_header
|
||||
* Boolean value controlling whether a header should be displayed.
|
||||
* $header_title
|
||||
* The category title.
|
||||
* $category_depth
|
||||
* The term or category depth.
|
||||
* $description
|
||||
* The current page's description.
|
||||
* $term_image
|
||||
* The HTML for the category image. This is empty if the taxonomy image module
|
||||
* is not enabled or there is no image associated with the term.
|
||||
* $display_faq_count
|
||||
* Boolean value controlling whether or not the number of faqs in a category
|
||||
* should be displayed.
|
||||
* $question_count
|
||||
* The number of questions in category.
|
||||
* $question_list
|
||||
* An array of questions.
|
||||
* $question_list_style, either ol or ul
|
||||
* The style of the question list, either ol or ul (ordered or unordered).
|
||||
* $container_class
|
||||
* The class attribute of the element containing the sub-categories, either
|
||||
* 'faq-qa' or 'faq-qa-hide'. This is used by javascript to open/hide
|
||||
* a category's faqs.
|
||||
* $subcat_list
|
||||
* An array of sub-categories. Each sub-category stored in the $subcat_list
|
||||
* array has the following information:
|
||||
* $subcat['link'] is the link to the sub-category.
|
||||
* $subcat['description'] is the sub-category description.
|
||||
* $subcat['count'] is the number of questions in the sub-category.
|
||||
* $subcat['term_image'] is the sub-category (taxonomy) image.
|
||||
* $subcat_list_style
|
||||
* The style of the sub-category list, either ol or ul (ordered or unordered).
|
||||
* $subcat_body_list
|
||||
* The sub-categories faqs, recursively themed (by this template).
|
||||
*/
|
||||
|
||||
if ($category_depth > 0) {
|
||||
$hdr = 'h6';
|
||||
}
|
||||
else {
|
||||
$hdr = 'h5';
|
||||
}
|
||||
|
||||
?><div class="faq-category-group">
|
||||
<!-- category header with title, link, image, description, and count of
|
||||
questions inside -->
|
||||
<div class="faq-qa-header">
|
||||
<?php if ($display_header): ?>
|
||||
<<?php print $hdr; ?> class="faq-header">
|
||||
<?php print $term_image; ?>
|
||||
<?php print $header_title; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $question_count; ?>)
|
||||
<?php endif; ?>
|
||||
</<?php print $hdr; ?>>
|
||||
|
||||
<?php else: ?>
|
||||
<?php print $term_image; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($description)): ?>
|
||||
<div class="faq-qa-description"><?php print $description ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($term_image)): ?>
|
||||
<div class="clear-block"></div>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-qa-header -->
|
||||
|
||||
<!-- list subcategories, with title, link, description, count -->
|
||||
<?php if (!empty($subcat_list)): ?>
|
||||
<div class="item-list">
|
||||
<<?php print $subcat_list_style; ?> class="faq-category-list">
|
||||
<?php foreach ($subcat_list as $i => $subcat): ?>
|
||||
<li>
|
||||
<?php print $subcat['link']; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $subcat['count']; ?>)
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($subcat['description'])): ?>
|
||||
<div class="faq-qa-description"><?php print $subcat['description']; ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="clear-block"></div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</<?php print $subcat_list_style; ?>>
|
||||
</div> <!-- Close div: item-list -->
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="<?php print $container_class; ?>">
|
||||
|
||||
<!-- include subcategories -->
|
||||
<?php if (count($subcat_body_list)): ?>
|
||||
<?php foreach ($subcat_body_list as $i => $subcat_html): ?>
|
||||
<div class="faq-category-indent"><?php print $subcat_html; ?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- list questions (in title link) and answers (in body) -->
|
||||
<?php if (!empty($question_list)): ?>
|
||||
<div class="item-list">
|
||||
<<?php print $question_list_style; ?> class="faq-category-list">
|
||||
<?php foreach ($question_list as $i => $question_link): ?>
|
||||
<li>
|
||||
<?php print $question_link; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</<?php print $question_list_style; ?>>
|
||||
</div> <!-- Close div: item-list -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</div> <!-- Close div: faq-qa / faq-qa-hide -->
|
||||
|
||||
</div> <!-- Close div: faq-category-group -->
|
145
modules/faq/includes/faq-category-questions-inline.tpl.php
Normal file
145
modules/faq/includes/faq-category-questions-inline.tpl.php
Normal file
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the FAQ page if set to show categorized questions inline.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $display_header
|
||||
* Boolean value controlling whether a header should be displayed.
|
||||
* $header_title
|
||||
* The category title.
|
||||
* $category_depth
|
||||
* The term or category depth.
|
||||
* $description
|
||||
* The current page's description.
|
||||
* $term_image
|
||||
* The HTML for the category image. This is empty if the taxonomy image module
|
||||
* is not enabled or there is no image associated with the term.
|
||||
* $display_faq_count
|
||||
* Boolean value controlling whether or not the number of faqs in a category
|
||||
* should be displayed.
|
||||
* $question_count
|
||||
* The number of questions in category.
|
||||
* $nodes
|
||||
* An array of nodes to be displayed.
|
||||
* Each node stored in the $nodes array has the following information:
|
||||
* $node['question'] is the question text.
|
||||
* $node['body'] is the answer text.
|
||||
* $node['links'] represents the node links, e.g. "Read more".
|
||||
* $use_teaser
|
||||
* Whether $node['body'] contains the full body or just the teaser text.
|
||||
* $container_class
|
||||
* The class attribute of the element containing the sub-categories, either
|
||||
* 'faq-qa' or 'faq-qa-hide'. This is used by javascript to open/hide
|
||||
* a category's faqs.
|
||||
* $question_label
|
||||
* The label to prepend to the question text.
|
||||
* $answer_label
|
||||
* The label to prepend to the answer text.
|
||||
* $subcat_list
|
||||
* An array of sub-categories. Each sub-category stored in the $subcat_list
|
||||
* array has the following information:
|
||||
* $subcat['link'] is the link to the sub-category.
|
||||
* $subcat['description'] is the sub-category description.
|
||||
* $subcat['count'] is the number of questions in the sub-category.
|
||||
* $subcat['term_image'] is the sub-category (taxonomy) image.
|
||||
* $subcat_list_style
|
||||
* The style of the sub-category list, either ol or ul (ordered or unordered).
|
||||
* $subcat_body_list
|
||||
* The sub-categories faqs, recursively themed (by this template).
|
||||
*/
|
||||
|
||||
if ($category_depth > 0) {
|
||||
$hdr = 'h6';
|
||||
}
|
||||
else {
|
||||
$hdr = 'h5';
|
||||
}
|
||||
|
||||
?>
|
||||
<a name="top"></a>
|
||||
<div class="faq-category-group">
|
||||
<!-- category header with title, link, image, description, and count of
|
||||
questions inside -->
|
||||
<div class="faq-qa-header">
|
||||
<?php if ($display_header): ?>
|
||||
<<?php print $hdr; ?> class="faq-header">
|
||||
<?php print $term_image; ?>
|
||||
<?php print $header_title; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $question_count; ?>)
|
||||
<?php endif; ?>
|
||||
</<?php print $hdr; ?>>
|
||||
|
||||
<?php else: ?>
|
||||
<?php print $term_image; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($description)): ?>
|
||||
<div class="faq-qa-description"><?php print $description ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($term_image)): ?>
|
||||
<div class="clear-block"></div>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-qa-header -->
|
||||
|
||||
<!-- list subcategories, with title, link, description, count -->
|
||||
<?php if (!empty($subcat_list)): ?>
|
||||
<div class="item-list">
|
||||
<<?php print $subcat_list_style; ?> class="faq-category-list">
|
||||
<?php foreach ($subcat_list as $i => $subcat): ?>
|
||||
<li>
|
||||
<?php print $subcat['link']; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $subcat['count']; ?>)
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($subcat['description'])): ?>
|
||||
<div class="faq-qa-description"><?php print $subcat['description']; ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="clear-block"></div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</<?php print $subcat_list_style; ?>>
|
||||
</div> <!-- Close div: item-list -->
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="<?php print $container_class; ?>">
|
||||
|
||||
<!-- include subcategories -->
|
||||
<?php if (count($subcat_body_list)): ?>
|
||||
<?php foreach ($subcat_body_list as $i => $subcat_html): ?>
|
||||
<div class="faq-category-indent"><?php print $subcat_html; ?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- list questions (in title link) and answers (in body) -->
|
||||
<div>
|
||||
<?php if (count($nodes)): ?>
|
||||
<?php foreach ($nodes as $i => $node): ?>
|
||||
<div class="faq-question">
|
||||
<?php if (!empty($question_label)): ?>
|
||||
<strong class="faq-question-label"><?php print $question_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $node['question']; ?>
|
||||
</div> <!-- Close div: faq-question -->
|
||||
|
||||
<div class="faq-answer">
|
||||
<?php if (!empty($answer_label)): ?>
|
||||
<strong class="faq-answer-label"><?php print $answer_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $node['body']; ?>
|
||||
<?php if (isset($node['links'])): ?>
|
||||
<?php print $node['links']; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-answer -->
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div -->
|
||||
|
||||
</div> <!-- Close div: faq-qa / faq-qa-hide -->
|
||||
|
||||
</div> <!-- Close div: faq-category-group -->
|
135
modules/faq/includes/faq-category-questions-top-answers.tpl.php
Normal file
135
modules/faq/includes/faq-category-questions-top-answers.tpl.php
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the answers section of the FAQ page if set to show
|
||||
* categorized questions at the top of the page.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $display_answers
|
||||
* Whether or not there should be any output.
|
||||
* $display_header
|
||||
* Boolean value controlling whether a header should be displayed.
|
||||
* $header_title
|
||||
* The category title.
|
||||
* $category_name
|
||||
* The name of the category.
|
||||
* $answer_category_name
|
||||
* Whether the category name should be displayed with the answers.
|
||||
* $group_questions_top
|
||||
* Whether the questions and answers should be grouped together.
|
||||
* $category_depth
|
||||
* The term or category depth.
|
||||
* $description
|
||||
* The current page's description.
|
||||
* $term_image
|
||||
* The HTML for the category image. This is empty if the taxonomy image module
|
||||
* is not enabled or there is no image associated with the term.
|
||||
* $display_faq_count
|
||||
* Boolean value controlling whether or not the number of faqs in a category
|
||||
* should be displayed.
|
||||
* $question_count
|
||||
* The number of questions in category.
|
||||
* $nodes
|
||||
* An array of nodes to be displayed.
|
||||
* Each node stored in the $nodes array has the following information:
|
||||
* $node['question'] is the question text.
|
||||
* $node['body'] is the answer text.
|
||||
* $node['links'] represents the node links, e.g. "Read more".
|
||||
* $use_teaser
|
||||
* Whether $node['body'] contains the full body or just the teaser text.
|
||||
* $question_label
|
||||
* The question label, intended to be pre-pended to the question text.
|
||||
* $answer_label
|
||||
* The answer label, intended to be pre-pended to the answer text.
|
||||
* $container_class
|
||||
* The class attribute of the element containing the sub-categories, either
|
||||
* 'faq-qa' or 'faq-qa-hide'. This is used by javascript to open/hide
|
||||
* a category's faqs.
|
||||
* $subcat_body_list
|
||||
* The sub-categories faqs, recursively themed (by this template).
|
||||
*/
|
||||
|
||||
|
||||
if ($category_depth > 0) {
|
||||
$hdr = 'h6';
|
||||
}
|
||||
else {
|
||||
$hdr = 'h5';
|
||||
}
|
||||
|
||||
$depth = 0;
|
||||
|
||||
?><?php if ($display_answers): ?>
|
||||
<?php if ($answer_category_name): ?>
|
||||
<?php while ($depth < $category_depth): ?>
|
||||
<div class="faq-category-indent">
|
||||
<?php $depth++; endwhile; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="faq-category-menu">
|
||||
|
||||
<?php if ($display_header): ?>
|
||||
<<?php print $hdr; ?> class="faq-header">
|
||||
<?php print $term_image; ?>
|
||||
<?php print $category_name; ?>
|
||||
</<?php print $hdr; ?>>
|
||||
<div class="clear-block"></div>
|
||||
<div class="faq-category-group">
|
||||
<div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$answer_category_name || $display_header): ?>
|
||||
|
||||
<!-- Include subcategories. -->
|
||||
<?php if (count($subcat_body_list)): ?>
|
||||
<?php foreach ($subcat_body_list as $i => $subcat_html): ?>
|
||||
<?php print $subcat_html; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$display_header): ?>
|
||||
<div class="faq-category-group">
|
||||
<div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- List questions (in title link) and answers (in body). -->
|
||||
<?php if (count($nodes)): ?>
|
||||
<?php foreach ($nodes as $i => $node): ?>
|
||||
|
||||
<div class="faq-question">
|
||||
<?php if (!empty($question_label)): ?>
|
||||
<strong class="faq-question-label"><?php print $question_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $node['question']; ?>
|
||||
</div> <!-- Close div: faq-question -->
|
||||
|
||||
<div class="faq-answer">
|
||||
<?php if (!empty($answer_label)): ?>
|
||||
<strong class="faq-answer-label"><?php print $answer_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $node['body']; ?>
|
||||
<?php if (isset($node['links'])): ?>
|
||||
<?php print $node['links']; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-answer -->
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div> <!-- Close div -->
|
||||
</div> <!-- Close div: faq-category-group -->
|
||||
</div>
|
||||
|
||||
<?php if ($answer_category_name): ?>
|
||||
<?php while ($depth > 0): ?>
|
||||
</div> <!-- Close div: faq-category-indent -->
|
||||
<?php $depth--; endwhile; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif; // if display_answers
|
180
modules/faq/includes/faq-category-questions-top.tpl.php
Normal file
180
modules/faq/includes/faq-category-questions-top.tpl.php
Normal file
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the questions section of the FAQ page if set to show
|
||||
* categorized questions at the top of the page.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $display_header
|
||||
* Boolean value controlling whether a header should be displayed.
|
||||
* $header_title
|
||||
* The category title.
|
||||
* $category_name
|
||||
* The name of the category.
|
||||
* $answer_category_name
|
||||
* Whether the category name should be displayed with the answers.
|
||||
* $group_questions_top
|
||||
* Whether the questions and answers should be grouped together.
|
||||
* $category_depth
|
||||
* The term or category depth.
|
||||
* $description
|
||||
* The current page's description.
|
||||
* $term_image
|
||||
* The HTML for the category image. This is empty if the taxonomy image module
|
||||
* is not enabled or there is no image associated with the term.
|
||||
* $display_faq_count
|
||||
* Boolean value controlling whether or not the number of faqs in a category
|
||||
* should be displayed.
|
||||
* $question_count
|
||||
* The number of questions in category.
|
||||
* $nodes
|
||||
* An array of nodes to be displayed.
|
||||
* Each node stored in the $nodes array has the following information:
|
||||
* $node['question'] is the question text.
|
||||
* $node['body'] is the answer text.
|
||||
* $node['links'] represents the node links, e.g. "Read more".
|
||||
* $use_teaser
|
||||
* Whether $node['body'] contains the full body or just the teaser text.
|
||||
* $container_class
|
||||
* The class attribute of the element containing the sub-categories, either
|
||||
* 'faq-qa' or 'faq-qa-hide'. This is used by javascript to open/hide
|
||||
* a category's faqs.
|
||||
* $question_list
|
||||
* An array of question links.
|
||||
* $question_list_style
|
||||
* The style of the question list, ul for unordered, ol for ordered.
|
||||
* $subcat_list
|
||||
* An array of sub-categories. Each sub-category stored in the $subcat_list
|
||||
* array has the following information:
|
||||
* $subcat['link'] is the link to the sub-category.
|
||||
* $subcat['description'] is the sub-category description.
|
||||
* $subcat['count'] is the number of questions in the sub-category.
|
||||
* $subcat['term_image'] is the sub-category (taxonomy) image.
|
||||
* $subcat_list_style
|
||||
* The style of the sub-category list, either ol or ul (ordered or unordered).
|
||||
* $subcat_body_list
|
||||
* The sub-categories faqs, recursively themed (by this template).
|
||||
*/
|
||||
|
||||
if ($category_depth > 0) {
|
||||
$hdr = 'h6';
|
||||
}
|
||||
else {
|
||||
$hdr = 'h5';
|
||||
}
|
||||
|
||||
?>
|
||||
<a name="top"></a>
|
||||
<div class="faq-category-menu">
|
||||
|
||||
<!-- category header with title, link, image, description, and count of questions inside -->
|
||||
<div class="faq-qa-header">
|
||||
<?php if ($display_header): ?>
|
||||
<<?php print $hdr; ?> class="faq-header">
|
||||
<?php print $term_image; ?>
|
||||
<?php print $header_title; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $question_count; ?>)
|
||||
<?php endif; ?>
|
||||
</<?php print $hdr; ?>>
|
||||
<?php else: ?>
|
||||
<?php print $term_image; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($description)): ?>
|
||||
<div class="faq-qa-description"><?php print $description ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($term_image)): ?>
|
||||
<div class="clear-block"></div>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-qa-header -->
|
||||
|
||||
|
||||
<?php if (!empty($subcat_list)): ?>
|
||||
<!-- list subcategories, with title, link, description, count -->
|
||||
<div class="item-list">
|
||||
<<?php print $subcat_list_style; ?> class="faq-category-list">
|
||||
<?php foreach ($subcat_list as $i => $subcat): ?>
|
||||
<li>
|
||||
<?php print $subcat['link']; ?>
|
||||
<?php if ($display_faq_count): ?>
|
||||
(<?php print $subcat['count']; ?>)
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($subcat['description'])): ?>
|
||||
<div class="faq-qa-description"><?php print $subcat['description']; ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="clear-block"></div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</<?php print $subcat_list_style; ?>>
|
||||
</div> <!-- Close div: item-list -->
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="<?php print $container_class; ?>">
|
||||
|
||||
<?php // include subcategories ?>
|
||||
<?php if (count($subcat_body_list)): ?>
|
||||
<?php foreach ($subcat_body_list as $i => $subcat_html): ?>
|
||||
<div class="faq-category-indent"><?php print $subcat_html; ?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // list question links ?>
|
||||
<?php if (!empty($question_list)): ?>
|
||||
<div class="item-list">
|
||||
<<?php print $question_list_style; ?> class="faq-ul-questions-top">
|
||||
<?php foreach ($question_list as $i => $question_link): ?>
|
||||
<li>
|
||||
<?php print $question_link; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</<?php print $question_list_style; ?>>
|
||||
</div> <!-- Close div: item-list -->
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$group_questions_top && $category_display != 'hide_qa'): ?>
|
||||
</div> <!-- Close div: faq-qa / faq-qa-hide -->
|
||||
</div> <!-- Close div: faq-category-menu -->
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($answer_category_name): ?>
|
||||
<!-- Display header before answers in some layouts. -->
|
||||
<<?php print $hdr; ?> class="faq-header">
|
||||
<?php print $term_image; ?>
|
||||
<?php print $category_name; ?>
|
||||
</<?php print $hdr; ?>>
|
||||
<div class="clear-block"></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // List questions (in title link) and answers (in body). ?>
|
||||
<div class="faq-category-group">
|
||||
<div>
|
||||
|
||||
<?php if (count($nodes)): ?>
|
||||
<?php foreach ($nodes as $i => $node): ?>
|
||||
|
||||
<div class="faq-question"><?php // Strong question label here? ?>
|
||||
<?php print $node['question']; ?>
|
||||
</div> <!-- Close div: faq-question -->
|
||||
|
||||
<div class="faq-answer">
|
||||
<strong><?php print $answer_label; ?></strong>
|
||||
<?php print $node['body']; ?>
|
||||
<?php if (isset($node['links'])): ?>
|
||||
<?php print $node['links']; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-answer -->
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</div> <!-- Close div -->
|
||||
</div> <!-- Close div: faq-category-group -->
|
||||
|
||||
<?php if ($group_questions_top || $category_display == 'hide_qa'): ?>
|
||||
</div> <!-- Close div: faq-qa / faq-qa-hide -->
|
||||
</div> <!-- Close div: faq-category-menu -->
|
||||
<?php
|
||||
endif;
|
39
modules/faq/includes/faq-hide-answer.tpl.php
Normal file
39
modules/faq/includes/faq-hide-answer.tpl.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the FAQ page if set to show/hide the answers when the
|
||||
* question is clicked.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $nodes
|
||||
* The array of nodes to be displayed.
|
||||
* Each $node array contains the following information:
|
||||
* $node['question'] is the question text.
|
||||
* $node['body'] is the answer text.
|
||||
* $node['links'] represents the node links, e.g. "Read more".
|
||||
* $use_teaser
|
||||
* Is true if $node['body'] is a teaser.
|
||||
*/
|
||||
?><div>
|
||||
<?php if (count($nodes)): ?>
|
||||
<?php foreach ($nodes as $node): ?>
|
||||
<?php // Cycle through each of the nodes. We now have the variable $node to work with. ?>
|
||||
<div class="faq-question-answer">
|
||||
<div class="faq-question faq-dt-hide-answer">
|
||||
<?php print $node['question']; ?>
|
||||
</div> <!-- Close div: faq-question faq-dt-hide-answer -->
|
||||
|
||||
<div class="faq-answer faq-dd-hide-answer">
|
||||
<?php print $node['body']; ?>
|
||||
<?php if (isset($node['links'])): ?>
|
||||
<?php print $node['links']; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-answer faq-dd-hide-answer -->
|
||||
</div> <!-- Close div: faq-question-answer -->
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div -->
|
20
modules/faq/includes/faq-new-page.tpl.php
Normal file
20
modules/faq/includes/faq-new-page.tpl.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the FAQ page if set to show the answer in a new page.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $list_style
|
||||
* The style of the list, either ol or ul (ordered list or unordered list).
|
||||
* $list_items
|
||||
* An array of nodes to be displayed in the list.
|
||||
* $list
|
||||
* Pre-formatted list.
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
print $list;
|
49
modules/faq/includes/faq-questions-inline.tpl.php
Normal file
49
modules/faq/includes/faq-questions-inline.tpl.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the FAQ page if set to show the questions inline.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $nodes
|
||||
* The array of nodes to be displayed.
|
||||
* Each node stored in the $nodes array has the following information:
|
||||
* $node['question'] is the question text.
|
||||
* $node['body'] is the answer text.
|
||||
* $node['links'] represents the node links, e.g. "Read more".
|
||||
* $question_label
|
||||
* The question label, intended to be pre-pended to the question text.
|
||||
* $answer_label
|
||||
* The answer label, intended to be pre-pended to the answer text.
|
||||
* $use_teaser
|
||||
* Tells whether $node['body'] contains the full body or just the teaser
|
||||
*/
|
||||
?>
|
||||
<a name="top"></a>
|
||||
<div>
|
||||
<?php if (count($nodes)): ?>
|
||||
<?php foreach ($nodes as $node): ?>
|
||||
<?php // Cycle through the $nodes array so that we now have a $node variable to work with. ?>
|
||||
<br />
|
||||
<div class="faq-question">
|
||||
<?php if (!empty($question_label)): ?>
|
||||
<strong class="faq-question-label"><?php print $question_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $node['question']; ?>
|
||||
</div> <!-- Close div: faq-question -->
|
||||
|
||||
<div class="faq-answer">
|
||||
<?php if (!empty($answer_label)): ?>
|
||||
<strong class="faq-answer-label"><?php print $answer_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $node['body']; ?>
|
||||
<?php if (isset($node['links'])): ?>
|
||||
<?php print $node['links']; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div: faq-answer -->
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div> <!-- Close div -->
|
56
modules/faq/includes/faq-questions-top.tpl.php
Normal file
56
modules/faq/includes/faq-questions-top.tpl.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template file for the FAQ page if set to show the questions in a list at the
|
||||
* top.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available variables:
|
||||
*
|
||||
* $questions_list
|
||||
* Pre-formatted list of questions.
|
||||
* $questions
|
||||
* An array of questions to use for producing the question list at the top.
|
||||
* $answers
|
||||
* An array of answers to use for producing the main body of text.
|
||||
* $answers[$key]['question'] is the question text.
|
||||
* $answers[$key]['body'] is the answer text.
|
||||
* $answers[$key]['links'] represents the node links, e.g. "Read more".
|
||||
* $use_teaser
|
||||
* Is true if $answer['body'] is a teaser.
|
||||
* $list_style
|
||||
* Represents the style of list, ul for unordered, ol for ordered.
|
||||
* $question_label
|
||||
* The question label, intended to be pre-pended to the question text.
|
||||
* $answer_label
|
||||
* The answer label, intended to be pre-pended to the answer text.
|
||||
* $limit
|
||||
* Represents the number of items.
|
||||
*/
|
||||
?>
|
||||
<a name="top"></a>
|
||||
<?php print $questions_list ?>
|
||||
<br />
|
||||
<?php $key = 0; ?>
|
||||
<?php while ($key < $limit): ?>
|
||||
<?php // Cycle through all the answers and "more" links. $key will represent the applicable position in the arrays. ?>
|
||||
<div class="faq-question">
|
||||
<?php if (!empty($question_label)): ?>
|
||||
<strong class="faq-question-label"><?php print $question_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $answers[$key]['question']; ?>
|
||||
</div> <!-- Close div: faq-question -->
|
||||
|
||||
<div class="faq-answer">
|
||||
<?php if (!empty($answer_label)): ?>
|
||||
<strong class="faq-answer-label"><?php print $answer_label; ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php print $answers[$key]['body']; ?>
|
||||
<?php print $answers[$key]['links']; ?>
|
||||
</div> <!-- Close div: faq-answer -->
|
||||
<?php // Increment $key to move on to the next position. ?>
|
||||
<?php $key++; ?>
|
||||
<?php
|
||||
endwhile;
|
148
modules/faq/includes/faq.hide_answer.inc
Normal file
148
modules/faq/includes/faq.hide_answer.inc
Normal file
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* FAQ page callbacks for the "hide answer" layouts.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create FAQ page if set to show/hide answer when question is clicked.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
function template_preprocess_faq_hide_answer(&$variables) {
|
||||
$data = $variables['data'];
|
||||
$this_page = $_GET['q'];
|
||||
|
||||
// Fetch configuration.
|
||||
$teaser = variable_get('faq_use_teaser', FALSE);
|
||||
$links = variable_get('faq_show_node_links', FALSE);
|
||||
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
|
||||
|
||||
$nodes = array();
|
||||
$count = 0;
|
||||
foreach ($data as $node) {
|
||||
$anchor = 'n' . $node->nid;
|
||||
faq_view_question($nodes[$count], $node, $this_page, $anchor);
|
||||
faq_view_answer($nodes[$count], $node, array(), $teaser, $links);
|
||||
$count++;
|
||||
}
|
||||
$variables['use_teaser'] = $teaser;
|
||||
$variables['nodes'] = $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create categorized FAQ page if set to show answer when question is clicked.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
function template_preprocess_faq_category_hide_answer(&$variables) {
|
||||
$data = $variables['data'];
|
||||
$category_display = $variables['category_display'];
|
||||
$term = $variables['term'];
|
||||
$parent_term = $variables['parent_term'];
|
||||
$class = $variables['class'];
|
||||
|
||||
// Fetch configuration.
|
||||
$teaser = variable_get('faq_use_teaser', FALSE);
|
||||
$variables['use_teaser'] = $teaser;
|
||||
$links = variable_get('faq_show_node_links', FALSE);
|
||||
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
|
||||
$display_faq_count = variable_get('faq_count', FALSE);
|
||||
$hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
|
||||
$show_term_page_children = variable_get('faq_show_term_page_children', FALSE);
|
||||
$default_sorting = variable_get('faq_default_sorting', 'DESC');
|
||||
|
||||
// Initialise some variables.
|
||||
$default_weight = 0;
|
||||
if ($default_sorting != 'DESC') {
|
||||
$default_weight = 1000000;
|
||||
}
|
||||
$this_page = $_GET['q'];
|
||||
$get_child_terms = 0;
|
||||
// Check if we're on a faq page.
|
||||
if (arg(0) == 'faq') {
|
||||
// Check if we're on a categorized faq page.
|
||||
if (is_numeric(arg(1))) {
|
||||
$get_child_terms = arg(1);
|
||||
}
|
||||
}
|
||||
// Force some settings in case we're processing a special faq question list
|
||||
// created by a custom call to faq_page().
|
||||
elseif (!empty($parent_term)) {
|
||||
$get_child_terms = $parent_term->tid;
|
||||
$show_term_page_children = TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Get number of questions, and account for hidden sub-categories.
|
||||
$count = 0;
|
||||
if ($display_faq_count && $hide_child_terms) {
|
||||
$count = taxonomy_term_count_nodes($term->tid, 'faq');
|
||||
}
|
||||
$variables['display_faq_count'] = $display_faq_count;
|
||||
|
||||
// Get taxonomy image.
|
||||
$variables['term_image'] = '';
|
||||
if (module_exists('taxonomy_image')) {
|
||||
$variables['term_image'] = taxonomy_image_display($term->tid, array('class' => 'faq-tax-image'));
|
||||
}
|
||||
|
||||
// Configure header.
|
||||
$variables['category_depth'] = $term->depth;
|
||||
$variables['category_name'] = check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name));
|
||||
if ($category_display == 'hide_qa') {
|
||||
$variables['header_title'] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), "faq/$term->tid");
|
||||
}
|
||||
else {
|
||||
$variables['header_title'] = check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name));
|
||||
}
|
||||
|
||||
// Configure category description.
|
||||
$variables['description'] = check_markup(faq_tt("taxonomy:term:$term->tid:description", $term->description));
|
||||
|
||||
// Get list of sub-categories if necessary.
|
||||
$child_categories = array();
|
||||
if (($show_term_page_children || $hide_child_terms) && $category_display == 'new_page') {
|
||||
$child_categories = faq_view_child_category_headers($term);
|
||||
}
|
||||
$variables['subcat_list'] = $child_categories;
|
||||
$variables['subcat_list_style'] = variable_get('faq_category_listing', 'ul');
|
||||
|
||||
// Configure class (faq-qa or faq-qa-hide).
|
||||
if ($get_child_terms == $term->tid) {
|
||||
$variables['container_class'] = 'faq-qa';
|
||||
}
|
||||
else {
|
||||
$variables['container_class'] = $class;
|
||||
}
|
||||
|
||||
// Configure sub-category bodies (theme recursively).
|
||||
$variables['subcat_body_list'] = array();
|
||||
if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) {
|
||||
$variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_hide_answer', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term);
|
||||
}
|
||||
|
||||
if (!count($data)) {
|
||||
$variables['question_count'] = $count;
|
||||
$variables['nodes'] = array();
|
||||
return;
|
||||
}
|
||||
|
||||
$nodes = array();
|
||||
foreach ($data as $node) {
|
||||
if (!$hide_child_terms) {
|
||||
$count++;
|
||||
}
|
||||
$node_var = array();
|
||||
$anchor = 't' . $term->tid . 'n' . $node->nid;
|
||||
faq_view_question($node_var, $node, $this_page, $anchor);
|
||||
faq_view_answer($node_var, $node, array(), $teaser, $links);
|
||||
$nodes[] = $node_var;
|
||||
}
|
||||
$variables['nodes'] = $nodes;
|
||||
$variables['question_count'] = $count;
|
||||
}
|
||||
|
134
modules/faq/includes/faq.new_page.inc
Normal file
134
modules/faq/includes/faq.new_page.inc
Normal file
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* FAQ page callbacks for the "new page" layouts.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create FAQ page if set to show the answer in a new page.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
function template_preprocess_faq_new_page(&$variables) {
|
||||
$items = array();
|
||||
$data = $variables['data'];
|
||||
|
||||
foreach ($data as $node) {
|
||||
$items[] = l($node->title, "node/$node->nid");
|
||||
}
|
||||
|
||||
$list_style = variable_get('faq_question_listing', 'ul');
|
||||
$variables['list_style'] = $list_style;
|
||||
$variables['list_items'] = $items;
|
||||
|
||||
$variables['list'] = theme('item_list', $items, NULL, $list_style, array("class" => "faq-question-listing"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create categorized FAQ page if set to show answer in a new page.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
|
||||
function template_preprocess_faq_category_new_page(&$variables) {
|
||||
$data = $variables['data'];
|
||||
$category_display = $variables['category_display'];
|
||||
$term = $variables['term'];
|
||||
$parent_term = $variables['parent_term'];
|
||||
$class = $variables['class'];
|
||||
$this_page = $_GET['q'];
|
||||
|
||||
// Fetch configuration.
|
||||
$display_faq_count = variable_get('faq_count', FALSE);
|
||||
$hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
|
||||
$show_term_page_children = variable_get('faq_show_term_page_children', FALSE);
|
||||
|
||||
// Initialise some variables.
|
||||
$get_child_terms = 0;
|
||||
// Check if we're on a faq page.
|
||||
if (arg(0) == 'faq') {
|
||||
// Check if we're on a categorized faq page.
|
||||
if (is_numeric(arg(1))) {
|
||||
$get_child_terms = arg(1);
|
||||
}
|
||||
}
|
||||
// Force some settings in case we're processing a special faq question list
|
||||
// created by a custom call to faq_page().
|
||||
elseif (!empty($parent_term)) {
|
||||
$get_child_terms = $parent_term->tid;
|
||||
$show_term_page_children = TRUE;
|
||||
}
|
||||
|
||||
$default_sorting = variable_get('faq_default_sorting', 'DESC');
|
||||
$default_weight = 0;
|
||||
if ($default_sorting != 'DESC') {
|
||||
$default_weight = 1000000;
|
||||
}
|
||||
|
||||
// Get number of questions, and account for hidden sub-categories.
|
||||
$count = 0;
|
||||
if ($display_faq_count && $hide_child_terms) {
|
||||
$count = taxonomy_term_count_nodes($term->tid, 'faq');
|
||||
}
|
||||
$variables['display_faq_count'] = $display_faq_count;
|
||||
|
||||
// Get taxonomy image.
|
||||
$variables['term_image'] = '';
|
||||
if (module_exists('taxonomy_image')) {
|
||||
$variables['term_image'] = taxonomy_image_display($term->tid, array('class' => 'faq-tax-image'));
|
||||
}
|
||||
|
||||
// Configure header.
|
||||
$variables['category_depth'] = $term->depth;
|
||||
if ($category_display == 'hide_qa') {
|
||||
$variables['header_title'] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), "faq/$term->tid");
|
||||
}
|
||||
else {
|
||||
$variables['header_title'] = check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name));
|
||||
}
|
||||
|
||||
// Configure category description.
|
||||
$variables['description'] = check_markup(faq_tt("taxonomy:term:$term->tid:description", $term->description));
|
||||
|
||||
// Get list of sub-categories if necessary.
|
||||
$child_categories = array();
|
||||
if (($show_term_page_children || $hide_child_terms) && $category_display == 'new_page') {
|
||||
$child_categories = faq_view_child_category_headers($term);
|
||||
}
|
||||
$variables['subcat_list'] = $child_categories;
|
||||
$variables['subcat_list_style'] = variable_get('faq_category_listing', 'ul');
|
||||
|
||||
// Configure class (faq-qa or faq-qa-hide).
|
||||
if ($get_child_terms == $term->tid) {
|
||||
$variables['container_class'] = 'faq-qa';
|
||||
}
|
||||
else {
|
||||
$variables['container_class'] = $class;
|
||||
}
|
||||
|
||||
// Configure sub-category bodies (theme recursively).
|
||||
$variables['subcat_body_list'] = array();
|
||||
if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) {
|
||||
$variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_new_page', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term);
|
||||
}
|
||||
|
||||
if (!count($data)) {
|
||||
$variables['question_count'] = $count;
|
||||
return;
|
||||
}
|
||||
|
||||
$nodes = array();
|
||||
foreach ($data as $node) {
|
||||
if (!$hide_child_terms) {
|
||||
$count++;
|
||||
}
|
||||
$nodes[] = l($node->title, "node/$node->nid");
|
||||
}
|
||||
$variables['question_list'] = $nodes;
|
||||
$variables['question_list_style'] = variable_get('faq_question_listing', 'ul');
|
||||
$variables['question_count'] = $count;
|
||||
}
|
||||
|
168
modules/faq/includes/faq.questions_inline.inc
Normal file
168
modules/faq/includes/faq.questions_inline.inc
Normal file
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* FAQ page callbacks for the "questions inline" layouts.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create the FAQ page if set to show the questions inline.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
function template_preprocess_faq_questions_inline(&$variables) {
|
||||
$data = $variables['data'];
|
||||
|
||||
// Fetch configuration.
|
||||
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
|
||||
$teaser = variable_get('faq_use_teaser', FALSE);
|
||||
$links = variable_get('faq_show_node_links', FALSE);
|
||||
|
||||
// Configure "back to top" link.
|
||||
$this_page = $_GET['q'];
|
||||
$back_to_top = faq_init_back_to_top($this_page);
|
||||
|
||||
// Configure labels.
|
||||
$variables['question_label'] = '';
|
||||
$variables['answer_label'] = '';
|
||||
if (variable_get('faq_qa_mark', FALSE)) {
|
||||
$variables['question_label'] = check_plain(variable_get('faq_question_label', "Q:"));
|
||||
$variables['answer_label'] = check_plain(variable_get('faq_answer_label', "A:"));
|
||||
}
|
||||
|
||||
$nodes = array();
|
||||
$count = 0;
|
||||
foreach ($data as $node) {
|
||||
$anchor = 'n' . $node->nid;
|
||||
faq_view_question($nodes[$count], $node, NULL, $anchor);
|
||||
faq_view_answer($nodes[$count], $node, $back_to_top, $teaser, $links);
|
||||
$count++;
|
||||
}
|
||||
$variables['use_teaser'] = $teaser;
|
||||
$variables['nodes'] = $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create categorized FAQ page if set to show/hide the questions inline.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
function template_preprocess_faq_category_questions_inline(&$variables) {
|
||||
$data = $variables['data'];
|
||||
$category_display = $variables['category_display'];
|
||||
$term = $variables['term'];
|
||||
$parent_term = $variables['parent_term'];
|
||||
$class = $variables['class'];
|
||||
|
||||
// Fetch configuration.
|
||||
$teaser = variable_get('faq_use_teaser', FALSE);
|
||||
$links = variable_get('faq_show_node_links', FALSE);
|
||||
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
|
||||
$display_faq_count = variable_get('faq_count', FALSE);
|
||||
$hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
|
||||
$show_term_page_children = variable_get('faq_show_term_page_children', FALSE);
|
||||
$default_sorting = variable_get('faq_default_sorting', 'DESC');
|
||||
|
||||
// Initialise some variables.
|
||||
$default_weight = 0;
|
||||
if ($default_sorting != 'DESC') {
|
||||
$default_weight = 1000000;
|
||||
}
|
||||
$this_page = $_GET['q'];
|
||||
$get_child_terms = 0;
|
||||
// Check if we're on a faq page.
|
||||
if (arg(0) == 'faq') {
|
||||
// Check if we're on a categorized faq page.
|
||||
if (is_numeric(arg(1))) {
|
||||
$get_child_terms = arg(1);
|
||||
}
|
||||
}
|
||||
// Force some settings in case we're processing a special faq question list
|
||||
// created by a custom call to faq_page().
|
||||
elseif (!empty($parent_term)) {
|
||||
$get_child_terms = $parent_term->tid;
|
||||
$show_term_page_children = TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Configure "back to top" link.
|
||||
$back_to_top = faq_init_back_to_top($this_page);
|
||||
|
||||
// Configure labels.
|
||||
$variables['question_label'] = '';
|
||||
$variables['answer_label'] = '';
|
||||
if (variable_get('faq_qa_mark', FALSE)) {
|
||||
$variables['question_label'] = check_plain(variable_get('faq_question_label', "Q:"));
|
||||
$variables['answer_label'] = check_plain(variable_get('faq_answer_label', "A:"));
|
||||
}
|
||||
|
||||
// Get number of questions, and account for hidden sub-categories.
|
||||
$count = 0;
|
||||
if ($display_faq_count && $hide_child_terms) {
|
||||
$count = taxonomy_term_count_nodes($term->tid, 'faq');
|
||||
}
|
||||
$variables['display_faq_count'] = $display_faq_count;
|
||||
|
||||
// Get taxonomy image.
|
||||
$variables['term_image'] = '';
|
||||
if (module_exists('taxonomy_image')) {
|
||||
$variables['term_image'] = taxonomy_image_display($term->tid, array('class' => 'faq-tax-image'));
|
||||
}
|
||||
|
||||
// Configure header.
|
||||
$variables['category_depth'] = $term->depth;
|
||||
if ($category_display == 'hide_qa') {
|
||||
$variables['header_title'] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), "faq/$term->tid");
|
||||
}
|
||||
else {
|
||||
$variables['header_title'] = check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name));
|
||||
}
|
||||
|
||||
// Configure category description.
|
||||
$variables['description'] = check_markup(faq_tt("taxonomy:term:$term->tid:description", $term->description));
|
||||
|
||||
// Get list of sub-categories if necessary.
|
||||
$child_categories = array();
|
||||
if (($show_term_page_children || $hide_child_terms) && $category_display == 'new_page') {
|
||||
$child_categories = faq_view_child_category_headers($term);
|
||||
}
|
||||
$variables['subcat_list'] = $child_categories;
|
||||
$variables['subcat_list_style'] = variable_get('faq_category_listing', 'ul');
|
||||
|
||||
// Configure class (faq-qa or faq-qa-hide).
|
||||
if ($get_child_terms == $term->tid) {
|
||||
$variables['container_class'] = 'faq-qa';
|
||||
}
|
||||
else {
|
||||
$variables['container_class'] = $class;
|
||||
}
|
||||
|
||||
// Configure sub-category bodies (theme recursively).
|
||||
$variables['subcat_body_list'] = array();
|
||||
if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) {
|
||||
$variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_inline', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term);
|
||||
}
|
||||
|
||||
if (!count($data)) {
|
||||
$variables['question_count'] = $count;
|
||||
return;
|
||||
}
|
||||
|
||||
$nodes = array();
|
||||
foreach ($data as $node) {
|
||||
if (!$hide_child_terms) {
|
||||
$count++;
|
||||
}
|
||||
$node_var = array();
|
||||
$anchor = 't' . $term->tid . 'n' . $node->nid;
|
||||
faq_view_question($node_var, $node, NULL, $anchor);
|
||||
faq_view_answer($node_var, $node, $back_to_top, $teaser, $links);
|
||||
$nodes[] = $node_var;
|
||||
}
|
||||
$variables['nodes'] = $nodes;
|
||||
$variables['question_count'] = $count;
|
||||
$variables['use_teaser'] = $teaser;
|
||||
}
|
||||
|
282
modules/faq/includes/faq.questions_top.inc
Normal file
282
modules/faq/includes/faq.questions_top.inc
Normal file
|
@ -0,0 +1,282 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* FAQ page callbacks for the "questions top" layouts.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create the structure of the page, when the questions are to be shown on top.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
* @return
|
||||
* A variable holding the HTML formatted page.
|
||||
*/
|
||||
function template_preprocess_faq_questions_top(&$variables) {
|
||||
$data = $variables['data'];
|
||||
|
||||
// Fetch configuration.
|
||||
$teaser = variable_get('faq_use_teaser', FALSE);
|
||||
$links = variable_get('faq_show_node_links', FALSE);
|
||||
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
|
||||
|
||||
// Configure labels.
|
||||
$variables['question_label'] = '';
|
||||
$variables['answer_label'] = '';
|
||||
if (variable_get('faq_qa_mark', FALSE)) {
|
||||
$variables['question_label'] = check_plain(variable_get('faq_question_label', "Q:"));
|
||||
$variables['answer_label'] = check_plain(variable_get('faq_answer_label', "A:"));
|
||||
}
|
||||
|
||||
// Configure "back to top" link.
|
||||
$this_page = $_GET['q'];
|
||||
$back_to_top = faq_init_back_to_top($this_page);
|
||||
|
||||
// Loop through results.
|
||||
$questions = array();
|
||||
$answers = array();
|
||||
$key = 0;
|
||||
foreach ($data as $node) {
|
||||
$anchor = 'n' . $node->nid;
|
||||
$questions[$key] = l($node->title, $this_page, array('fragment' => $anchor));
|
||||
faq_view_question($answers[$key], $node, NULL, $anchor);
|
||||
faq_view_answer($answers[$key], $node, $back_to_top, $teaser, $links);
|
||||
$key++;
|
||||
}
|
||||
$variables['limit'] = $key;
|
||||
|
||||
$list_style = variable_get('faq_question_listing', 'ul');
|
||||
$variables['list_style'] = $list_style;
|
||||
$variables['use_teaser'] = $teaser;
|
||||
$variables['questions'] = $questions;
|
||||
$variables['answers'] = $answers;
|
||||
$variables['questions_list'] = theme('item_list', $questions, NULL, $list_style, array("class" => "faq-ul-questions-top"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create categorized questions for FAQ page if set to show questions on top.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
function template_preprocess_faq_category_questions_top(&$variables) {
|
||||
$data = $variables['data'];
|
||||
$category_display = $variables['category_display'];
|
||||
$term = $variables['term'];
|
||||
$parent_term = $variables['parent_term'];
|
||||
$class = $variables['class'];
|
||||
|
||||
// Fetch configuration.
|
||||
$teaser = variable_get('faq_use_teaser', FALSE);
|
||||
$links = variable_get('faq_show_node_links', FALSE);
|
||||
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
|
||||
$display_faq_count = variable_get('faq_count', FALSE);
|
||||
$hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
|
||||
$show_term_page_children = variable_get('faq_show_term_page_children', FALSE);
|
||||
$group_questions_top = variable_get('faq_group_questions_top', FALSE);
|
||||
$default_sorting = variable_get('faq_default_sorting', 'DESC');
|
||||
|
||||
// Initialise some variables.
|
||||
$default_weight = 0;
|
||||
if ($default_sorting != 'DESC') {
|
||||
$default_weight = 1000000;
|
||||
}
|
||||
$this_page = $_GET['q'];
|
||||
$get_child_terms = 0;
|
||||
// Check if we're on a faq page.
|
||||
if (arg(0) == 'faq') {
|
||||
// Check if we're on a categorized faq page.
|
||||
if (is_numeric(arg(1))) {
|
||||
$get_child_terms = arg(1);
|
||||
}
|
||||
}
|
||||
// Force some settings in case we're processing a special faq question list
|
||||
// created by a custom call to faq_page().
|
||||
elseif (!empty($parent_term)) {
|
||||
$get_child_terms = $parent_term->tid;
|
||||
$show_term_page_children = TRUE;
|
||||
}
|
||||
|
||||
// Configure "back to top" link.
|
||||
$back_to_top = faq_init_back_to_top($this_page);
|
||||
|
||||
// Get number of questions, and account for hidden sub-categories.
|
||||
$count = 0;
|
||||
if ($display_faq_count && $hide_child_terms) {
|
||||
$count = taxonomy_term_count_nodes($term->tid, 'faq');
|
||||
}
|
||||
$variables['display_faq_count'] = $display_faq_count;
|
||||
|
||||
// Get taxonomy image.
|
||||
$variables['term_image'] = '';
|
||||
if (module_exists('taxonomy_image')) {
|
||||
$variables['term_image'] = taxonomy_image_display($term->tid, array('class' => 'faq-tax-image'));
|
||||
}
|
||||
|
||||
// Configure header.
|
||||
$variables['category_depth'] = $term->depth;
|
||||
$variables['category_name'] = check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name));
|
||||
if ($category_display == 'hide_qa') {
|
||||
$variables['header_title'] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), "faq/$term->tid");
|
||||
}
|
||||
else {
|
||||
$variables['header_title'] = check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name));
|
||||
}
|
||||
|
||||
// Configure category description.
|
||||
$variables['description'] = check_markup(faq_tt("taxonomy:term:$term->tid:description", $term->description));
|
||||
|
||||
// Get list of sub-categories if necessary.
|
||||
$child_categories = array();
|
||||
if (($show_term_page_children || $hide_child_terms) && $category_display == 'new_page') {
|
||||
$child_categories = faq_view_child_category_headers($term);
|
||||
}
|
||||
$variables['subcat_list'] = $child_categories;
|
||||
$variables['subcat_list_style'] = variable_get('faq_category_listing', 'ul');
|
||||
|
||||
// Configure class (faq-qa or faq-qa-hide).
|
||||
if ($get_child_terms == $term->tid) {
|
||||
$variables['container_class'] = 'faq-qa';
|
||||
}
|
||||
else {
|
||||
$variables['container_class'] = $class;
|
||||
}
|
||||
|
||||
// Configure sub-category bodies (theme recursively).
|
||||
$variables['subcat_body_list'] = array();
|
||||
if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) {
|
||||
$variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term);
|
||||
}
|
||||
|
||||
if (!count($data)) {
|
||||
$variables['question_count'] = $count;
|
||||
return;
|
||||
}
|
||||
|
||||
$questions = array();
|
||||
$nodes = array();
|
||||
foreach ($data as $node) {
|
||||
if (!$hide_child_terms) {
|
||||
$count++;
|
||||
}
|
||||
$anchor = 't' . $term->tid . 'n' . $node->nid;
|
||||
$node_var = array();
|
||||
faq_view_question($node_var, $node, NULL, $anchor);
|
||||
if ($group_questions_top || $category_display == 'hide_qa') {
|
||||
faq_view_answer($node_var, $node, $back_to_top, $teaser, $links);
|
||||
}
|
||||
$nodes[] = $node_var;
|
||||
$questions[] = l($node->title, $this_page, array('fragment' => $anchor));
|
||||
}
|
||||
$variables['question_count'] = $count;
|
||||
$variables['use_teaser'] = $teaser;
|
||||
$variables['question_list'] = $questions;
|
||||
$variables['question_list_style'] = variable_get('faq_question_listing', 'ul');
|
||||
|
||||
$variables['group_questions_top'] = $group_questions_top;
|
||||
if ($group_questions_top || $category_display == "hide_qa") {
|
||||
$variables['nodes'] = $nodes;
|
||||
$variables['answer_category_name'] = variable_get('faq_answer_category_name', FALSE);
|
||||
}
|
||||
else {
|
||||
$variables['nodes'] = array();
|
||||
$variables['answer_category_name'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create categorized answers for FAQ page if set to show the questions on top.
|
||||
*
|
||||
* @param &$variables
|
||||
* Array reference of arguments given to the theme() function.
|
||||
*/
|
||||
function template_preprocess_faq_category_questions_top_answers(&$variables) {
|
||||
$data = $variables['data'];
|
||||
$category_display = $variables['category_display'];
|
||||
$term = $variables['term'];
|
||||
$parent_term = $variables['parent_term'];
|
||||
$class = $variables['class'];
|
||||
|
||||
// Fetch configuration.
|
||||
$teaser = variable_get('faq_use_teaser', FALSE);
|
||||
$links = variable_get('faq_show_node_links', FALSE);
|
||||
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
|
||||
$hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
|
||||
$show_term_page_children = variable_get('faq_show_term_page_children', FALSE);
|
||||
$group_questions_top = variable_get('faq_group_questions_top', FALSE);
|
||||
$default_sorting = variable_get('faq_default_sorting', 'DESC');
|
||||
|
||||
// Configure labels.
|
||||
$variables['question_label'] = '';
|
||||
$variables['answer_label'] = '';
|
||||
if (variable_get('faq_qa_mark', FALSE)) {
|
||||
$variables['question_label'] = check_plain(variable_get('faq_question_label', "Q:"));
|
||||
$variables['answer_label'] = check_plain(variable_get('faq_answer_label', "A:"));
|
||||
}
|
||||
|
||||
// Initialise some variables.
|
||||
$default_weight = 0;
|
||||
if ($default_sorting != 'DESC') {
|
||||
$default_weight = 1000000;
|
||||
}
|
||||
|
||||
$variables['group_questions_top'] = $group_questions_top;
|
||||
if ($group_questions_top || $category_display == "hide_qa") {
|
||||
$variables['display_answers'] = FALSE;
|
||||
$variables['category_depth'] = 0;
|
||||
return;
|
||||
}
|
||||
$variables['display_answers'] = TRUE;
|
||||
|
||||
$this_page = $_GET['q'];
|
||||
$get_child_terms = 0;
|
||||
// Check if we're on a faq page.
|
||||
if (arg(0) == 'faq') {
|
||||
// Check if we're on a categorized faq page.
|
||||
if (is_numeric(arg(1))) {
|
||||
$get_child_terms = arg(1);
|
||||
}
|
||||
}
|
||||
// Force some settings in case we're processing a special faq question list
|
||||
// created by a custom call to faq_page().
|
||||
elseif (!empty($parent_term)) {
|
||||
$get_child_terms = $parent_term->tid;
|
||||
$show_term_page_children = TRUE;
|
||||
}
|
||||
|
||||
// Configure "back to top" link.
|
||||
$back_to_top = faq_init_back_to_top($this_page);
|
||||
|
||||
// Get taxonomy image.
|
||||
$variables['term_image'] = '';
|
||||
if (module_exists('taxonomy_image')) {
|
||||
$variables['term_image'] = taxonomy_image_display($term->tid, array('class' => 'faq-tax-image'));
|
||||
}
|
||||
|
||||
// Configure sub-category bodies (theme recursively).
|
||||
$variables['subcat_body_list'] = array();
|
||||
if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) {
|
||||
$variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top_answers', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term);
|
||||
}
|
||||
|
||||
|
||||
$nodes = array();
|
||||
foreach ($data as $node) {
|
||||
$node_var = array();
|
||||
$anchor = 't' . $term->tid . 'n' . $node->nid;
|
||||
faq_view_question($node_var, $node, NULL, $anchor);
|
||||
faq_view_answer($node_var, $node, $back_to_top, $teaser, $links);
|
||||
$nodes[] = $node_var;
|
||||
}
|
||||
$variables['use_teaser'] = $teaser;
|
||||
$variables['nodes'] = $nodes;
|
||||
$variables['category_name'] = check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name));
|
||||
$variables['category_depth'] = $term->depth;
|
||||
$variables['display_header'] = FALSE;
|
||||
$variables['answer_category_name'] = variable_get('faq_answer_category_name', FALSE);
|
||||
if ($variables['answer_category_name'] && taxonomy_term_count_nodes($term->tid, 'faq')) {
|
||||
$variables['display_header'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
132
modules/faq/views/faq.views.inc
Normal file
132
modules/faq/views/faq.views.inc
Normal file
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Exposes faq module's database tables to views.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_data().
|
||||
*/
|
||||
function faq_views_data() {
|
||||
// faq_questions table.
|
||||
$data['faq_questions']['table']['group'] = t('FAQ');
|
||||
$data['faq_questions']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'nid',
|
||||
'field' => 'nid',
|
||||
),
|
||||
);
|
||||
$data['faq_questions']['question'] = array(
|
||||
'title' => t('FAQ short question'),
|
||||
'help' => t('The short question text for FAQ nodes.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
);
|
||||
$data['faq_questions']['detailed_question'] = array(
|
||||
'title' => t('FAQ detailed question'),
|
||||
'help' => t('The long question text for FAQ nodes.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// faq_weights table.
|
||||
$data['faq_weights']['table']['group'] = t('FAQ');
|
||||
$data['faq_weights']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'nid',
|
||||
'field' => 'nid',
|
||||
),
|
||||
'term_data' => array(
|
||||
'left_field' => 'tid',
|
||||
'field' => 'tid',
|
||||
),
|
||||
);
|
||||
$data['faq_weights']['tid'] = array(
|
||||
'title' => t('FAQ category tid'),
|
||||
'help' => t('The tid of the FAQ node.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
'zero is null' => FALSE,
|
||||
),
|
||||
'filter' => array(
|
||||
'title' => t('Tid'),
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
'hierarchy table' => 'term_hierarchy',
|
||||
'numeric' => TRUE,
|
||||
'skip base' => 'term_data',
|
||||
'allow empty' => TRUE,
|
||||
'zero is null' => FALSE,
|
||||
),
|
||||
'relationship' => array(
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('category'),
|
||||
'base' => 'term_node',
|
||||
'base field' => 'tid',
|
||||
'skip base' => 'term_data',
|
||||
),
|
||||
);
|
||||
$data['faq_weights']['category'] = array(
|
||||
'title' => t('FAQ category'),
|
||||
'help' => t('The term of the FAQ node.'),
|
||||
'real field' => 'tid',
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_term_node_tid',
|
||||
'click sortable' => TRUE,
|
||||
'zero is null' => TRUE,
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_term_node_tid',
|
||||
'name table' => 'term_data',
|
||||
'name field' => 'name',
|
||||
'empty field name' => t('Uncategorized'),
|
||||
'numeric' => TRUE,
|
||||
'skip base' => 'term_data',
|
||||
'zero is null' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'title' => t('Term'),
|
||||
'handler' => 'views_handler_filter_term_node_tid',
|
||||
'hierarchy table' => 'term_hierarchy',
|
||||
'numeric' => TRUE,
|
||||
'skip base' => 'term_data',
|
||||
'allow empty' => TRUE,
|
||||
'zero is null' => FALSE,
|
||||
),
|
||||
);
|
||||
$data['faq_weights']['weight'] = array(
|
||||
'title' => t('FAQ weight'),
|
||||
'help' => t('The weight of the FAQ node.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
Reference in a new issue