diff --git a/modules/faq/faq.admin.inc b/modules/faq/faq.admin.inc deleted file mode 100644 index e5889c5..0000000 --- a/modules/faq/faq.admin.inc +++ /dev/null @@ -1,497 +0,0 @@ - '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 Content Management > Taxonomy.', 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 excluded 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.')); - } -} - diff --git a/modules/faq/faq.css b/modules/faq/faq.css deleted file mode 100644 index 8f2f54f..0000000 --- a/modules/faq/faq.css +++ /dev/null @@ -1,63 +0,0 @@ -.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; -} diff --git a/modules/faq/faq.info b/modules/faq/faq.info deleted file mode 100644 index b0e2cc8..0000000 --- a/modules/faq/faq.info +++ /dev/null @@ -1,10 +0,0 @@ -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" diff --git a/modules/faq/faq.install b/modules/faq/faq.install deleted file mode 100644 index 24f3af8..0000000 --- a/modules/faq/faq.install +++ /dev/null @@ -1,170 +0,0 @@ - '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; -} diff --git a/modules/faq/faq.js b/modules/faq/faq.js deleted file mode 100644 index 9f07fb1..0000000 --- a/modules/faq/faq.js +++ /dev/null @@ -1,272 +0,0 @@ - -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 = $('
') - .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); -} - - diff --git a/modules/faq/faq.module b/modules/faq/faq.module deleted file mode 100644 index 6c21067..0000000 --- a/modules/faq/faq.module +++ /dev/null @@ -1,1520 +0,0 @@ -'. t("This module allows users with the 'create faq' permission to create question and answer pairs which will be 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 page' permission in order to view the 'faq' page.") .'

'. - '

'. t("To create a question and answer, the user must create a 'FAQ' node (Create content >> FAQ). This screen allows the user to edit the question and answer text. 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.") .'

'. - '

'. t("The 'Frequently Asked Questions' settings configuration screen will allow users with 'administer faq' permissions to specify different layouts of the questions and answers.") .'

'. - '

'. t("All users with 'view faq page' permissions will be able to view the generated FAQ page at 'www.example.com/faq'.") .'

'; - return $output; - case 'admin/modules#description': - return t('Allows the user to configure the layout of questions and answers on a FAQ page.'); - } -} - -/** - * Implements hook_perm(). - */ -function faq_perm() { - return array('administer faq', 'view faq page', 'edit own faq', 'edit faq', 'create faq', 'administer faq order', 'delete faq content', 'delete own faq content'); -} - - -/** - * Implements hook_access(). - */ -function faq_access($op, $node, $account = NULL) { - global $user; - if (empty($account)) { - $account = $user; - } - - if ($op != 'create') { - $node = (object)$node; - } - if ($op == 'create') { - if (user_access('create faq')) { - return TRUE; - } - } - elseif ($op == 'update') { - if (user_access('edit faq')) { - return TRUE; - } - elseif (user_access('edit own faq') && $account->uid == $node->uid) { - return TRUE; - } - } - elseif ($op == 'delete') { - if (user_access('delete faq content')) { - return TRUE; - } - elseif (user_access('delete own faq content') && $account->uid == $node->uid) { - return TRUE; - } - } -} - -/** - * Implements hook_menu(). - */ -function faq_menu() { - $items = array(); - - $items['faq'] = array( - 'title' => 'Frequently Asked Questions', - 'page callback' => 'faq_page', - 'access callback' => 'user_access', - 'access arguments' => array('view faq page'), - 'weight' => 1, - ); - - $items['faq/list'] = array( - 'title' => 'List', - 'page callback' => 'faq_page', - 'access callback' => 'user_access', - 'access arguments' => array('view faq page'), - 'weight' => -10, - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); - - $items['faq/order'] = array( - 'title' => 'Order', - 'description' => 'Allows the user to configure the order of questions and answers on a FAQ page.', - 'file' => 'faq.admin.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('faq_order_settings_form'), - 'access callback' => 'user_access', - 'access arguments' => array('administer faq order'), - 'type' => MENU_LOCAL_TASK, - 'weight' => -8, - ); - - $items['faq/%'] = array( - 'title' => 'Frequently Asked Questions', - 'page callback' => 'faq_page', - 'page arguments' => array(1), - 'access callback' => 'user_access', - 'access arguments' => array('view faq page'), - 'type' => MENU_CALLBACK, - ); - - $items['faq/%/list'] = array( - 'title' => 'List', - 'page callback' => 'faq_page', - 'page arguments' => array(1), - 'access callback' => 'user_access', - 'access arguments' => array('view faq page'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - - $items['faq/%/order'] = array( - 'title' => 'Order', - 'description' => 'Allows the user to configure the order of questions and answers on a FAQ page.', - 'file' => 'faq.admin.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('faq_order_settings_form', 1), - 'access callback' => 'user_access', - 'access arguments' => array('administer faq order'), - 'type' => MENU_LOCAL_TASK, - 'weight' => -8, - ); - - $items['admin/settings/faq'] = array( - 'title' => 'Frequently Asked Questions', - 'description' => 'Allows the user to configure the layout of questions and answers on a FAQ page.', - 'file' => 'faq.admin.inc', - 'page callback' => 'faq_settings_page', - 'access callback' => 'user_access', - 'access arguments' => array('administer faq'), - ); - $items['admin/settings/faq/general'] = array( - 'title' => 'General', - 'description' => 'Allows the user to configure the header and descriptive text for the FAQ page.', - 'file' => 'faq.admin.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('faq_general_settings_form'), - 'access callback' => 'user_access', - 'access arguments' => array('administer faq'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - $items['admin/settings/faq/questions'] = array( - 'title' => 'Questions', - 'description' => 'Allows the user to configure the layout of questions and answers on a FAQ page.', - 'file' => 'faq.admin.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('faq_questions_settings_form'), - 'access callback' => 'user_access', - 'access arguments' => array('administer faq'), - 'type' => MENU_LOCAL_TASK, - 'weight' => -9, - ); - $items['admin/settings/faq/categories'] = array( - 'title' => 'Categories', - 'description' => 'Allows the user to configure the layout of questions and answers using categories on a FAQ page.', - 'file' => 'faq.admin.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('faq_categories_settings_form'), - 'access callback' => 'user_access', - 'access arguments' => array('administer faq'), - 'type' => MENU_LOCAL_TASK, - 'weight' => -8, - ); - return $items; -} - -/** - * Implements hook_node_info(). - * - * Defines the FAQ node/content type. - * @return - * An array, containing the title, module name and the description. - */ -function faq_node_info() { - return array( - 'faq' => array( - 'name' => t('FAQ'), - 'module' => 'faq', - 'description' => t('A frequently asked question and its answer.'), - 'title_label' => t('Question'), - 'body_label' => t('Answer'), - ) - ); -} - -/** - * Defines the form where new questions and answers are written. - * - * @param &$node - * The node being added or edited. - * @param &$param - * The hook can set this variable to an associative array of attributes to add - * to the enclosing
tag. - * @return - * The form elements in the $form array. - */ -function faq_form(&$node, &$param) { - $type = node_get_types('type', $node); - - // Short question. - $form['title'] = array( - '#type' => 'textfield', - '#title' => check_plain($type->title_label), - '#default_value' => $node->title, - '#required' => TRUE, - '#weight' => -2, - '#description' => t('Question to be answered. This will appear in all question listings, such as the FAQ blocks.'), - '#maxlength' => 255, - ); - - // Detailed question. - if (variable_get('faq_question_long_form', 1) || variable_get('faq_question_length', 'short') == 'long') { - $form['detailed_question'] = array( - '#type' => 'textarea', - '#title' => t('Question details (optional)'), - '#default_value' => $node->detailed_question, - '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'detailed_question') : -1, - '#rows' => 3, - '#description' => t('Longer question text. This will be displayed in all layouts where the answer appears, in addition to the shorter question text.'), - ); - } - - // Answer. - if (!empty($type->body_label)) { - $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); - $form['body_field']['body']['#description'] = t('This is that answer to the question. It will be filtered according to the input format.'); - } - - return $form; -} - - -/** - * Inserts the faq node question text into the 'faq_questions' table. - * - * @param $node - * The node object. - */ -function faq_insert($node) { - $ret = db_query("INSERT INTO {faq_questions} (nid, vid, question, detailed_question) VALUES(%d, %d, '%s', '%s')", $node->nid, $node->vid, $node->title, $node->detailed_question); -} - -/** - * Updates the faq node question text in the 'faq_questions' table. - * - * @param $node - * The node object. - */ -function faq_update($node) { - if ($node->revision) { - faq_insert($node); - } - else { - db_query("UPDATE {faq_questions} SET question = '%s', detailed_question = '%s' WHERE nid = %d AND vid = %d", $node->title, $node->detailed_question, $node->nid, $node->vid); - } -} - -/** - * Deletes an FAQ node from the database. - * - * @param &$node - * Which node to delete. - */ -function faq_delete(&$node) { - db_query("DELETE FROM {faq_weights} WHERE nid = '%d'", $node->nid); - db_query("DELETE FROM {faq_questions} WHERE nid = '%d'", $node->nid); -} - -/** - * Implements hook_load(). - * - * Initialises $node->question using the value in the 'faq_questions' table. - * - * @param $node - * The node object. - */ -function faq_load($node) { - $result = db_fetch_object(db_query('SELECT question, detailed_question FROM {faq_questions} WHERE nid = %d AND vid = %d', $node->nid, $node->vid)); - if ($result && !drupal_match_path($_GET['q'], 'node/'. $node->nid .'/edit')) { - $question_length = variable_get('faq_question_length', 'short'); - if ($question_length == 'long' && !empty($result->detailed_question)) { - $result->title = $result->detailed_question; - } - else { - $result->title = $result->question; - } - } - return $result; -} - -/** - * Implements hook_nodeapi(). - */ -function faq_nodeapi(&$node, $op, $teaser, $page) { - switch ($op) { - case 'delete revision': - db_query('DELETE FROM {faq_questions} WHERE nid = %d AND vid = %d', $node->nid, $node->vid); - break; - } -} - - -/** - * Implements hook_view(). - * - * @param $node - * Which node to show. - * @param $teaser - * Boolean variable, if set to TRUE, it will show only a short part of the - * content. - * @param $page - * Boolean variable, if set to TRUE, it will setup the breadcrumbs. - * @return - * The node object. - */ -function faq_view($node, $teaser = FALSE, $page = FALSE) { - drupal_add_css(drupal_get_path('module', 'faq') .'/faq.css'); - $node = node_prepare($node, $teaser); - $node->detailed_question = check_markup($node->detailed_question, $node->format, FALSE); - $content = $node->content['body']['#value']; - - if (!empty($node->detailed_question) && variable_get('faq_question_length', 'short') == 'both' && (variable_get('faq_display', 'questions_top') == 'hide_answer' || drupal_match_path($_GET['q'], 'node/' . $node->nid))) { - $node->content['body']['#value'] = '
'. $node->detailed_question .'
'. $content; - } - - return $node; -} - -/** - * Implements hook_views_api(). - */ -function faq_views_api() { - return array( - 'api' => 2, - 'path' => drupal_get_path('module', 'faq') . '/views', - ); -} - -/** - * Implements hook_content_extra_fields(). - */ -function faq_content_extra_fields($type_name) { - $extras = array(); - - if ($type_name == 'faq') { - $extras['detailed_question'] = array( - 'label' => t('Detailed question'), - 'description' => t('FAQ detailed question field'), - 'weight' => 10, - ); - } - - return $extras; -} - -/** - * Function to display the faq page. - * - * @param $tid - * Default is 0, determines if the questions and answers on the page - * will be shown according to a category or non-categorized. - * @param $faq_display - * Optional parameter to override default question layout setting. - * @param $category_display - * Optional parameter to override default category layout setting. - * @return - * The output variable which contains an HTML formatted page with FAQ - * questions and answers. - */ -function faq_page($tid = 0, $faq_display = '', $category_display = '') { - if (module_exists('pathauto')) { - module_load_include('inc', 'pathauto'); - } - - // Things to provide translations for. - $default_values = array(t('Frequently Asked Questions'), t('Back to Top'), t('Q:'), t('A:')); - - $output = $output_answers = ''; - drupal_add_css(drupal_get_path('module', 'faq') .'/faq.css'); - if (arg(0) == 'faq') { - drupal_set_title(check_plain(variable_get('faq_title', 'Frequently Asked Questions'))); - } - if (!module_exists("taxonomy")) { - $tid = 0; - } - - // Configure the breadcrumb trail. - if (!empty($tid) && $current_term = taxonomy_get_term($tid)) { - if (!drupal_lookup_path('alias', arg(0) .'/'. arg(1)) && module_exists('pathauto')) { - $placeholders = pathauto_get_placeholders('taxonomy', taxonomy_get_term($tid)); - if ($alias = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) .'/'. arg(1), arg(1))) { - drupal_goto($alias); - } - } - if (drupal_match_path($_GET['q'], 'faq/*')) { - faq_set_breadcrumb($current_term); - } - } - - - if (empty($faq_display)) { - $faq_display = variable_get('faq_display', 'questions_top'); - } - $use_categories = variable_get('faq_use_categories', FALSE); - if (!empty($category_display)) { - $use_categories = TRUE; - } - else { - $category_display = variable_get('faq_category_display', 'categories_inline'); - } - if (!module_exists("taxonomy")) { - $use_categories = FALSE; - } - - $faq_path = drupal_get_path('module', 'faq') .'/includes'; - - if (($use_categories && $category_display == 'hide_qa') || $faq_display == 'hide_answer') { - 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'); - } - - // Non-categorized questions and answers. - if (!$use_categories || ($category_display == 'none' && empty($tid))) { - if (!empty($tid)) { - drupal_not_found(); - return; - } - $default_sorting = variable_get('faq_default_sorting', 'DESC'); - $default_weight = 0; - if ($default_sorting != 'DESC') { - $default_weight = 1000000; - $result = db_query(db_rewrite_sql("SELECT n.nid, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY effective_weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight); - } - else { - $result = db_query(db_rewrite_sql("SELECT n.nid, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY effective_weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight); - } - $data = array(); - while ($row = db_fetch_object($result)) { - $node = node_load($row->nid); - if (node_access('view', $node)) { - $data[] = $node; - } - } - - switch ($faq_display) { - case 'questions_top': - include_once($faq_path .'/faq.questions_top.inc'); - $output = theme('faq_questions_top', $data); - break; - - case 'hide_answer': - include_once($faq_path .'/faq.hide_answer.inc'); - $output = theme('faq_hide_answer', $data); - break; - - case 'questions_inline': - include_once($faq_path .'/faq.questions_inline.inc'); - $output = theme('faq_questions_inline', $data); - break; - - case 'new_page': - include_once($faq_path .'/faq.new_page.inc'); - $output = theme('faq_new_page', $data); - break; - - } // End of switch. - } - - - // Categorize questions. - else { - $hide_child_terms = variable_get('faq_hide_child_terms', FALSE); - - - // If we're viewing a specific category/term. - if (!empty($tid)) { - if ($term = taxonomy_get_term($tid)) { - $title = variable_get('faq_title', 'Frequently Asked Questions'); - if (arg(0) == 'faq' && is_numeric(arg(1))) { - drupal_set_title(check_plain($title . ($title ? ' - ' : '') . faq_tt("taxonomy:term:$term->tid:name", $term->name))); - } - _display_faq_by_category($faq_display, $category_display, $term, 0, $output, $output_answers); - return theme('faq_page', $output, $output_answers); - } - else { - drupal_not_found(); - return; - } - } - - - $list_style = variable_get('faq_category_listing', 'ul'); - $vocabularies = taxonomy_get_vocabularies('faq'); - $vocab_omit = variable_get('faq_omit_vocabulary', array()); - $items = array(); - $vocab_items = array(); - foreach ($vocabularies as $vid => $vobj) { - if (isset($vocab_omit[$vid]) && $vocab_omit[$vid] != 0) { - continue; - } - - if ($category_display == "new_page") { - $vocab_items = _get_indented_faq_terms($vid, 0); - $items = array_merge($items, $vocab_items); - } - - // Not a new page. - else { - if ($hide_child_terms && $category_display == 'hide_qa') { - $tree = taxonomy_get_tree($vid, 0, -1, 1); - } - else { - $tree = taxonomy_get_tree($vid); - } - foreach ($tree as $term) { - - switch ($category_display) { - - case 'hide_qa': - case 'categories_inline': - if (taxonomy_term_count_nodes($term->tid, 'faq')) { - _display_faq_by_category($faq_display, $category_display, $term, 1, $output, $output_answers); - } - break; - - - } // End of switch (category_display). - } // End of foreach term. - } // End of foreach vocab. - } // End of if $category_display != new_page. - - if ($category_display == "new_page") { - $output = theme('item_list', $items, NULL, $list_style); - } - } - - $faq_description = variable_get('faq_description', ''); - $format = variable_get('faq_description_format', 0); - if ($format) { - $faq_description = check_markup($faq_description, $format, FALSE); - } - return theme('faq_page', $output, $output_answers, $faq_description); -} - -/** - * Display FAQ questions and answers filtered by category. - * - * @param $faq_display - * Define the way the FAQ is being shown; can have the values: - * 'questions top',hide answers','questions inline','new page'. - * @param $category_display - * The layout of categories which should be used. - * @param $term - * The category / term to display FAQs for. - * @param $display_header - * Set if the header will be shown or not. - * @param &$output - * Reference which holds the content of the page, HTML formatted. - * @param &$output_answer - * Reference which holds the answers from the FAQ, when showing questions - * on top. - */ -function _display_faq_by_category($faq_display, $category_display, $term, $display_header, &$output, &$output_answers) { - - $default_sorting = variable_get('faq_default_sorting', 'DESC'); - $default_weight = 0; - if ($default_sorting != 'DESC') { - $default_weight = 1000000; - $result = db_query(db_rewrite_sql("SELECT n.nid, 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 w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY effective_weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $term->tid); - } - else { - $result = db_query(db_rewrite_sql("SELECT n.nid, 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 w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY effective_weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $term->tid); - } - $data = array(); - while ($row = db_fetch_object($result)) { - $node = node_load($row->nid); - if (node_access('view', $node)) { - $data[] = $node; - } - } - - - // Handle indenting of categories. - $depth = 0; - if (!isset($term->depth)) $term->depth = 0; - while ($depth < $term->depth) { - $display_header = 1; - $indent = '
'; - $output .= $indent; - $depth++; - } - - // Set up the class name for hiding the q/a for a category if required. - $faq_class = "faq-qa"; - if ($category_display == "hide_qa") { - $faq_class = "faq-qa-hide"; - } - - $faq_path = drupal_get_path('module', 'faq') .'/includes'; - - switch ($faq_display) { - - case 'questions_top': - include_once($faq_path .'/faq.questions_top.inc'); - // @todo fix workaround: have to share result. - $output .= theme('faq_category_questions_top', $data, $display_header, $category_display, $term, $faq_class, $term); - $output_answers .= theme('faq_category_questions_top_answers', $data, $display_header, $category_display, $term, $faq_class, $term); - break; - - - case 'hide_answer': - include_once($faq_path .'/faq.hide_answer.inc'); - $output .= theme('faq_category_hide_answer', $data, $display_header, $category_display, $term, $faq_class, $term); - break; - - - case 'questions_inline': - include_once($faq_path .'/faq.questions_inline.inc'); - $output .= theme('faq_category_questions_inline', $data, $display_header, $category_display, $term, $faq_class, $term); - break; - - - case 'new_page': - include_once($faq_path .'/faq.new_page.inc'); - $output .= theme('faq_category_new_page', $data, $display_header, $category_display, $term, $faq_class, $term); - break; - - } // End of switch (faq_display). - - - // Handle indenting of categories. - while ($depth > 0) { - $output .= '
'; - $depth--; - } - -} - -/** - * Implements hook_theme(). - */ -function faq_theme() { - $path = drupal_get_path('module', 'faq') .'/includes'; - return array( - 'faq_draggable_question_order_table' => array( - 'arguments' => array('form' => NULL), - ), - 'faq_questions_top' => array( - 'path' => $path, - 'file' => 'faq.questions_top.inc', - 'template' => 'faq-questions-top', - 'arguments' => array('data' => NULL), - ), - 'faq_category_questions_top' => array( - 'path' => $path, - 'file' => 'faq.questions_top.inc', - 'template' => 'faq-category-questions-top', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), - ), - 'faq_category_questions_top_answers' => array( - 'path' => $path, - 'file' => 'faq.questions_top.inc', - 'template' => 'faq-category-questions-top-answers', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), - ), - 'faq_hide_answer' => array( - 'path' => $path, - 'file' => 'faq.hide_answer.inc', - 'template' => 'faq-hide-answer', - 'arguments' => array('data' => NULL), - ), - 'faq_category_hide_answer' => array( - 'path' => $path, - 'file' => 'faq.hide_answer.inc', - 'template' => 'faq-category-hide-answer', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), - ), - 'faq_questions_inline' => array( - 'path' => $path, - 'file' => 'faq.questions_inline.inc', - 'template' => 'faq-questions-inline', - 'arguments' => array('data' => NULL), - ), - 'faq_category_questions_inline' => array( - 'path' => $path, - 'file' => 'faq.questions_inline.inc', - 'template' => 'faq-category-questions-inline', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), - ), - 'faq_new_page' => array( - 'path' => $path, - 'file' => 'faq.new_page.inc', - 'template' => 'faq-new-page', - 'arguments' => array('data' => NULL), - ), - 'faq_category_new_page' => array( - 'path' => $path, - 'file' => 'faq.new_page.inc', - 'template' => 'faq-category-new-page', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), - ), - 'faq_page' => array( - 'arguments' => array('content' => '', 'answers' => '', 'description' => NULL), - ), - ); -} - -/** - * Implements hook_block(). - * - * Create the code of the FAQ page providing three block types: FAQ Categories, - * Recent FAQs and Random FAQs. - */ -function faq_block($op = 'list', $delta = 0, $edit = array()) { - static $vocabularies, $terms; - - switch ($op) { - - case 'list': - $blocks[0]['info'] = t('FAQ Categories'); - $blocks[1]['info'] = t('Recent FAQs'); - $blocks[2]['info'] = t('Random FAQs'); - return $blocks; - - case 'view': - $block = array(); - switch ($delta) { - case 0: - // FAQ Categories. - if (module_exists('taxonomy')) { - if (!isset($terms)) { - $terms = array(); - $vocabularies = taxonomy_get_vocabularies('faq'); - $vocab_omit = array_flip(variable_get('faq_omit_vocabulary', array())); - $vocabularies = array_diff_key($vocabularies, $vocab_omit); - foreach ($vocabularies as $vocab) { - foreach (taxonomy_get_tree($vocab->vid) as $term) { - if (taxonomy_term_count_nodes($term->tid, 'faq')) { - $terms[$term->name] = $term->tid; - } - } - } - } - if (count($terms) > 0) { - $block['subject'] = t('FAQ Categories'); - $items = array(); - foreach ($terms as $name => $tid) { - $items[] = l(faq_tt("taxonomy:term:$tid:name", $name), 'faq/'. $tid); - } - $list_style = variable_get('faq_category_listing', 'ul'); - $block['content'] = theme('item_list', $items, NULL, $list_style); - } - } - break; - - - case 1: - // Recent FAQs. - $block['subject'] = t('Recent FAQs'); - $block['content'] = faq_highlights_block(variable_get('faq_block_recent_faq_count', 5)); - break; - - case 2: - // Random FAQs. - $block['subject'] = t('Random FAQs'); - $block['content'] = faq_random_highlights_block(variable_get('faq_block_random_faq_count', 5)); - break; - - } // End switch($delta). - - return $block; - - - case 'configure': - switch ($delta) { - case 0: - return; - - case 1: - // Recent FAQs. - $form['faq_block_recent_faq_count'] = array( - '#type' => 'textfield', - '#title' => t('Number of FAQs to show'), - '#description' => t("This controls the number of FAQs that appear in the 'Recent FAQs' block"), - '#default_value' => variable_get('faq_block_recent_faq_count', 5), - ); - break; - - case 2: - // Random FAQs. - $form['faq_block_random_faq_count'] = array( - '#type' => 'textfield', - '#title' => t('Number of FAQs to show'), - '#description' => t("This controls the number of FAQs that appear in the 'Random FAQs' block"), - '#default_value' => variable_get('faq_block_random_faq_count', 5), - ); - break; - } // End switch($delta). - - return $form; - - case 'save': - switch ($delta) { - case 0: - break; - - case 1: - variable_set('faq_block_recent_faq_count', $edit['faq_block_recent_faq_count']); - break; - - case 2: - variable_set('faq_block_random_faq_count', $edit['faq_block_random_faq_count']); - break; - } // End switch($delta). - return; - - } // End switch($op). - -} - -/** - * Create the HTML output for the Recent FAQs block. - * - * @param $num - * The default value is 5; determines the number of FAQ entries to be shown. - * @return - * The HTML-formatted code displaying the Recent FAQs. - */ -function faq_highlights_block($num = 5) { - $disable_node_links = variable_get('faq_disable_node_links', FALSE); - - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY n.created DESC", "n", "nid"), 0, $num); - - $items = array(); - while ($row = db_fetch_object($result)) { - $node = node_load(array('nid' => $row->nid)); - $node = node_prepare($node); - if (node_access('view', $node)) { - if ($disable_node_links) { - $items[] = l($node->question, 'faq', array('fragment' => 'n'. $node->nid)); - } - else { - $items[] = l($node->question, 'node/'. $node->nid); - } - } - } - $list_style = variable_get('faq_question_listing', 'ul'); - $output = theme('item_list', $items, NULL, $list_style); - $output .= ''; - - return $output; -} - -/** - * Create the HTML output for the Random FAQs block. - * - * @param $num - * The default value is 5; determines the number of FAQ entries to be shown. - * @return - * The HTML-formatted code displaying the Random FAQs. - */ -function faq_random_highlights_block($num = 5) { - $disable_node_links = variable_get('faq_disable_node_links', FALSE); - - $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY RAND()", "n", "nid"), 0, $num); - - $items = array(); - while ($row = db_fetch_object($result)) { - $node = node_load(array('nid' => $row->nid)); - $node = node_prepare($node); - if (node_access('view', $node)) { - if ($disable_node_links) { - $items[] = l($node->question, 'faq', array('fragment' => 'n'. $node->nid)); - } - else { - $items[] = l($node->question, 'node/'. $node->nid); - } - } - } - $list_style = variable_get('faq_question_listing', 'ul'); - $output = theme('item_list', $items, NULL, $list_style); - $output .= ''; - - return $output; -} - -/** - * Return a HTML formatted list of terms indented according to the term depth. - * - * @param $vid - * Vocabulary id. - * @param $tid - * Term id. - * @return - * Return a HTML formatted list of terms indented according to the term depth. - */ -function _get_indented_faq_terms($vid, $tid) { - if (module_exists('pathauto')) { - module_load_include('inc', 'pathauto'); - } - - $display_faq_count = variable_get('faq_count', FALSE); - $hide_child_terms = variable_get('faq_hide_child_terms', FALSE); - - $items = array(); - $tree = taxonomy_get_tree($vid, $tid, -1, 1); - - foreach ($tree as $term) { - - $tree_count = taxonomy_term_count_nodes($term->tid, 'faq'); - - if ($tree_count) { - // Get taxonomy image. - $term_image = ''; - if (module_exists('taxonomy_image')) { - $term_image = taxonomy_image_display($term->tid, array('class' => 'faq-tax-image')); - } - - // Get term description. - $desc = ''; - if (!empty($term->description)) { - $desc = '
'; - $desc .= check_markup(faq_tt("taxonomy:term:$term->tid:description", $term->description)) ."
"; - } - - // See if this term has any nodes itself, should it be a link? - $result = db_query(db_rewrite_sql("SELECT COUNT(n.nid) AS c FROM {term_node} tn INNER JOIN {node} n ON (n.nid = tn.nid AND n.vid = tn.vid) WHERE n.status = 1 AND n.type = 'faq' AND tn.tid = '%d' ", "n", "nid"), $term->tid); - $term_node_count = db_fetch_object($result); - - if ($term_node_count->c > 0) { - $path = "faq/$term->tid"; - - if (!drupal_lookup_path('alias', arg(0) .'/'. $term->tid) && module_exists('pathauto')) { - $placeholders = pathauto_get_placeholders('taxonomy', $term); - $path = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) .'/'. $term->tid, $term->tid); - } - - if ($display_faq_count) { - $count = $term_node_count->c; - if ($hide_child_terms) { - $count = $tree_count; - } - $cur_item = $term_image . l(faq_tt("taxonomy:term:$term->tid:name", $term->name), $path) ." ($count) ". $desc; - } - else { - $cur_item = $term_image . l(faq_tt("taxonomy:term:$term->tid:name", $term->name), $path) . $desc; - } - } - else { - $cur_item = $term_image . check_plain(faq_tt("taxonomy:term:$term->tid:name", $term->name)) . $desc; - } - if (!empty($term_image)) { - $cur_item .= '
'; - } - - $term_items = array(); - if (!$hide_child_terms) { - $term_items = _get_indented_faq_terms($vid, $term->tid); - } - $items[] = array("data" => $cur_item, "children" => $term_items); - - } - } - - return $items; -} - -/** - * Get a list of terms associated with the FAQ nodes. - * - * @return - * Return the HTML-formatted content. - */ -function faq_get_terms() { - $items = array(); - $vocabularies = taxonomy_get_vocabularies('faq'); - $vocab_omit = array_flip(variable_get('faq_omit_vocabulary', array())); - $vocabularies = array_diff_key($vocabularies, $vocab_omit); - foreach ($vocabularies as $vid => $vobj) { - $vocab_items = _get_indented_faq_terms($vid, 0); - $items = array_merge($items, $vocab_items); - } - return theme('item_list', $items); -} - -/** - * Format the output for the faq_site_map() function. - * - * @return - * Return a list of FAQ categories if categorization is enabled, otherwise - * return a list of faq nodes. - */ -function faq_get_faq_list() { - // Return list of vocab terms if categories are configured. - $use_categories = variable_get('faq_use_categories', FALSE); - if ($use_categories) { - return faq_get_terms(); - } - - // Otherwise return list of weighted FAQ nodes. - $items = array(); - $default_sorting = variable_get('faq_default_sorting', 'DESC'); - $default_weight = 0; - if ($default_sorting != 'DESC') { - $default_weight = 1000000; - $result = db_query(db_rewrite_sql("SELECT n.nid, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY effective_weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight); - } - else { - $result = db_query(db_rewrite_sql("SELECT n.nid, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY effective_weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight); - } - while ($row = db_fetch_object($result)) { - $node = node_load($row->nid); - if (node_access('view', $node)) { - $items[] = l($node->question, "node/$node->nid"); - } - } - - return theme('item_list', $items); -} - -/** - * Implements hook_site_map(). - * - * Not needed by the latest site_map module as it implements a _site_map_faq() - * function itself. Leaving this code here for now in case things change again. - * - * Create a sitemap, by showing all the FAQ entries list - categorized or not - - * using faq_get_faq_list() function. - * @return - * Return a list of FAQ categories if categorization is enabled, otherwise - * return a list of faq nodes. - */ -/* -function faq_site_map() { - $title = variable_get('faq_title', 'Frequently Asked Questions'); - $output = faq_get_faq_list(); - return theme('box', $title, $output); -} - */ - -/** - * Implements hook_link_alter(). - * - * Change the term links on a node to point at the appropriate faq page. - */ -function faq_link_alter(&$links, $node) { - static $vocabularies; - - if ($node->type != 'faq' || !variable_get('faq_use_categories', FALSE) || !module_exists("taxonomy") || !variable_get('faq_enable_term_links', 1)) { - return; - } - if (!isset($vocabularies)) { - $vocabularies = taxonomy_get_vocabularies('faq'); - $vocab_omit = array_flip(variable_get('faq_omit_vocabulary', array())); - $vocabularies = array_diff_key($vocabularies, $vocab_omit); - } - foreach ($links as $module => $link) { - if (strpos($module, 'taxonomy_term') !== FALSE) { - // Link back to the faq and not the taxonomy term page. We'll only - // do this if the taxonomy term in question belongs to faq vocab. - $tid = str_replace('taxonomy/term/', '', $link['href']); - $term = taxonomy_get_term($tid); - if (!is_object($term)) continue; - foreach ($vocabularies as $vid => $vobj) { - if ($term->vid == $vid && taxonomy_term_count_nodes($term->tid, 'faq')) { - $links[$module]['href'] = str_replace('taxonomy/term', 'faq', $link['href']); - break; - } - } - } - } -} - -if (!function_exists('array_diff_key')) { - function array_diff_key() { - $arrs = func_get_args(); - $result = array_shift($arrs); - foreach ($arrs as $array) { - foreach ($result as $key => $v) { - if (array_key_exists($key, $array)) { - unset($result[$key]); - } - } - } - return $result; - } -} - -/** - * Implements hook_term_path(). - */ -function faq_term_path($term) { - return 'faq/'. $term->tid; -} - -/** - * Helper function to setup the faq question. - * - * @param &$data - * Array reference to store display data in. - * @param $node - * The node object. - * @param $path - * The path/url which the question should link to if links are disabled. - * @param $anchor - * Link anchor to use in question links. - */ -function faq_view_question(&$data, $node, $path = NULL, $anchor = NULL) { - $disable_node_links = variable_get('faq_disable_node_links', FALSE); - $question = ''; - - // Don't link to faq node, instead provide no link, or link to current page. - if ($disable_node_links) { - if (empty($path) && empty($anchor)) { - $question = check_plain($node->title); - } - elseif (empty($path)) { - // Can't seem to use l() function with empty string as screen-readers - // don't like it, so create anchor name manually. - $question = '' . check_plain($node->title); - } - else { - $options = array(); - if ($anchor) { - $options['attributes'] = array('id' => $anchor); - } - $question = l($node->title, $path, $options); - } - } - - // Link to faq node. - else { - if (empty($anchor)) { - $question = l($node->title, "node/$node->nid"); - } - else { - $question = l($node->title, "node/$node->nid", array("attributes" => array("id" => "$anchor"))); - } - } - - if (variable_get('faq_display', 'questions_top') != 'hide_answer' && !empty($node->detailed_question) && variable_get('faq_question_length', 'short') == 'both') { - $node->detailed_question = check_markup($node->detailed_question, $node->format, FALSE); - $question .= '
'. $node->detailed_question .'
'; - } - $data['question'] = $question; -} - -/** - * Helper function to setup the faq answer. - * - * @param &$data - * Array reference to store display data in. - * @param $node - * The node object. - * @param $back_to_top - * An array containing the "back to top" link. - * @param $teaser - * Whether or not to use teasers. - * @param $links - * Whether or not to show node links. - */ -function faq_view_answer(&$data, $node, $back_to_top, $teaser, $links) { - - // Build the faq node content and invoke other modules' links, etc, functions. - $node = (object)$node; - $node = node_build_content($node, $teaser, 0); - if ($links) { - $node->links = module_invoke_all('link', 'node', $node, $teaser); - foreach (module_implements('link_alter') as $module) { - $function = $module .'_link_alter'; - $function($node->links, $node); - } - } - - // Add "edit answer" link if they have the correct permissions. - if (node_access('update', $node)) { - $node->links['faq_edit_link'] = array( - 'title' => t('Edit answer'), - 'href' => "node/$node->nid/edit", - 'query' => drupal_get_destination(), - 'attributes' => array('title' => t('Edit answer')), - ); - } - - // Add "back to top" link. - if (!empty($back_to_top)) { - $node->links['faq_back_to_top'] = $back_to_top; - } - - $content = drupal_render($node->content); - node_invoke_nodeapi($node, 'alter', $teaser, 0); - - // Unset unused $node text so that a bad theme can not open a security hole. - // $node->body = NULL; - // $node->teaser = NULL; - - $data['body'] = $content; - if ($links) { - $data['links'] = theme('links', $node->links); - } -} - -/** - * Helper function to setup the "back to top" link. - * - * @param $path - * The path/url where the "back to top" link should bring the user too. This - * could be the 'faq' page or one of the categorized faq pages, e.g 'faq/123' - * where 123 is the tid. - * @return - * An array containing the "back to top" link. - */ -function faq_init_back_to_top($path) { - $back_to_top = array(); - $back_to_top_text = trim(variable_get('faq_back_to_top', 'Back to Top')); - if (!empty($back_to_top_text)) { - $back_to_top = array( - 'title' => check_plain($back_to_top_text), - 'href' => $path, - 'attributes' => array('title' => t('Go back to the top of the page.')), - 'fragment' => 'top', - 'html' => TRUE, - ); - } - - return $back_to_top; -} - -/** - * Helper function for retrieving the sub-categories faqs. - * - * @param $term - * The category / term to display FAQs for. - * @param $theme_function - * Theme function to use to format the Q/A layout for sub-categories. - * @param $default_weight - * Is 0 for $default_sorting = DESC; is 1000000 for $default_sorting = ASC. - * @param $default_sorting - * If 'DESC', nodes are sorted by creation date descending; if 'ASC', nodes - * are sorted by creation date ascending. - * @param $category_display - * The layout of categories which should be used. - * @param $class - * CSS class which the HTML div will be using. A special class name is - * required in order to hide and questions / answers. - * @param $parent_term - * The original, top-level, term we're displaying FAQs for. - */ -function faq_get_child_categories_faqs($term, $theme_function, $default_weight, $default_sorting, $category_display, $class, $parent_term = NULL) { - $output = array(); - - $list = taxonomy_get_children($term->tid); - - if (!is_array($list)) { - return ''; - } - foreach ($list as $tid => $child_term) { - $child_term->depth = $term->depth + 1; - - if (taxonomy_term_count_nodes($child_term->tid, 'faq')) { - if ($default_sorting == 'DESC') { - $result = db_query(db_rewrite_sql("SELECT n.nid, 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 w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY effective_weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $child_term->tid); - } - else { - $result = db_query(db_rewrite_sql("SELECT n.nid, 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 w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY effective_weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $child_term->tid); - } - - $data = array(); - while ($row = db_fetch_object($result)) { - $node = node_load($row->nid); - if (node_access('view', $node)) { - $data[] = $node; - } - } - $output[] = theme($theme_function, $data, 1, $category_display, $child_term, $class, $parent_term); - } - } - - return $output; -} - -/** - * Helper function to setup the list of sub-categories for the header. - * - * @param $term - * The term to setup the list of child terms for. - * @return - * An array of sub-categories. - */ -function faq_view_child_category_headers($term) { - - $child_categories = array(); - $list = taxonomy_get_children($term->tid); - - foreach ($list as $tid => $child_term) { - $term_node_count = taxonomy_term_count_nodes($child_term->tid, 'faq'); - if ($term_node_count) { - - // Get taxonomy image. - $term_image = ''; - if (module_exists('taxonomy_image')) { - $term_image = taxonomy_image_display($child_term->tid, array('class' => 'faq-tax-image')); - } - - $term_vars['link'] = l(faq_tt("taxonomy:term:$child_term->tid:name", $child_term->name), "faq/$child_term->tid"); - $term_vars['description'] = check_markup(faq_tt("taxonomy:term:$child_term->tid:description", $child_term->description)); - $term_vars['count'] = $term_node_count; - $term_vars['term_image'] = $term_image; - $child_categories[] = $term_vars; - } - } - - return $child_categories; -} - -/** - * Implements hook_pathauto(). - */ -function faq_pathauto($op) { - switch ($op) { - case 'settings': - $settings = array(); - $settings['module'] = 'faq'; - $settings['token_type'] = 'taxonomy'; - $settings['groupheader'] = t('FAQ category path settings'); - $settings['patterndescr'] = t('Default path pattern (applies to all FAQ categories with blank patterns below)'); - $settings['patterndefault'] = t('faq/[catpath-raw]'); - - $patterns = token_get_list('taxonomy'); - foreach ($patterns as $type => $pattern_set) { - if ($type != 'global') { - foreach ($pattern_set as $pattern => $description) { - $settings['placeholders']['['. $pattern .']'] = $description; - } - } - } - return (object) $settings; - default: - break; - } -} - -/** - * Function to set up the FAQ breadcrumbs for a given taxonomy term. - * - * @param $term - * The taxonomy term object. - */ -function faq_set_breadcrumb($term = NULL) { - $breadcrumb = array(); - if (variable_get('faq_custom_breadcrumbs', TRUE)) { - if (module_exists("taxonomy") && $term) { - $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq/'. $term->tid); - while ($parents = taxonomy_get_parents($term->tid)) { - $term = array_shift($parents); - $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq/'. $term->tid); - } - } - $breadcrumb[] = l(variable_get('faq_title', 'Frequently Asked Questions'), 'faq'); - $breadcrumb[] = l(t('Home'), NULL, array('attributes' => array('title' => variable_get('site_name', '')))); - $breadcrumb = array_reverse($breadcrumb); - return drupal_set_breadcrumb($breadcrumb); - } - // This is also used to set the breadcrumbs in the faq_preprocess_page() - // so we need to return a valid trail. - return drupal_get_breadcrumb(); -} - -/** - * Implements template_preprocess_page(). - * - * Override the breadcrumbs for faq nodes. - */ -function faq_preprocess_page(&$variables) { - if (!empty($variables['node']) && isset($variables['node']->type) && $variables['node']->type == 'faq' && module_exists('taxonomy')) { - if (!empty($variables['node']->taxonomy)) { - foreach ($variables['node']->taxonomy as $term) { - continue; - } - } - else { - $term = NULL; - } - $variables['breadcrumb'] = theme('breadcrumb', faq_set_breadcrumb($term)); - } -} - -/** - * Helper function for when i18ntaxonomy module is not installed. - */ -function faq_tt($string_id, $default, $language = NULL) { - return function_exists('tt') ? tt($string_id, $default, $language) : $default; -} - -/** - * Implements hook_filter(). - */ -function faq_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) { - switch ($op) { - case 'list': - return array( - 0 => t('Embed FAQ page'), - ); - - case 'no cache': - switch ($delta) { - case 0: - return TRUE; - } - - case 'description': - switch ($delta) { - case 0: - return t('Embed FAQ page using [faq] type tags. Disables filter caching so not recommended for all input formats.'); - } - - case "process": - switch ($delta) { - case 0: - $text = preg_replace_callback('/\[faq:?([^\]]*)\]/', '_faq_faq_page_filter_replacer', $text); - // Remove comments, as they're not supported by all input formats. - $text = preg_replace('//', '', $text); - return $text; - } - return $text; - - default: - return $text; - } -} - -/** - * Implements hook_filter_tips(). - */ -function faq_filter_tips($delta, $format, $long = FALSE) { - switch ($delta) { - case 0: - return t('[faq] or [faq:123,questions_inline,categories_inline] - insert FAQ content based on the optional category, question style and category style.'); - } -} - -/** - * Helper function for faq input filter. - */ -function _faq_faq_page_filter_replacer($matches) { - $tid = 0; - $faq_display = ''; - $category_display = ''; - if (drupal_strlen($matches[1])) { - list ($tid, $faq_display, $category_display) = explode(',', $matches[1] .',,'); - $tid = (int) trim($tid); - $faq_display = trim($faq_display); - $category_display = trim($category_display); - // These two checks ensure that a typo in the faq_display or - // category_display string still results in the FAQ showing. - if ($faq_display && !in_array($faq_display, array('questions_top', 'hide_answer', 'questions_inline', 'new_page'))) { - $faq_display = ''; - } - if ($category_display && !in_array($category_display, array('hide_qa', 'new_page', 'categories_inline'))) { - $category_display = ''; - } - } - - return faq_page($tid, $faq_display, $category_display); -} - -/** - * Theme function for faq page wrapper divs. - */ -function theme_faq_page($content = '', $answers = '', $description = NULL) { - $output = '
'; - if (!empty($description)) { - $output .= '
'. $description ."
\n"; - } - if (variable_get('faq_show_expand_all', FALSE)) { - $output .= '
'; - $output .= '[' . t('expand all') . ']'; - $output .= '[' . t('collapse all') . ']'; - $output .= "
\n"; - } - - $output .= $content; - $output .= $answers ."
\n"; - return $output; -} - -/** - * Theme function for question ordering drag and drop table. - */ -function theme_faq_draggable_question_order_table($form) { - drupal_add_tabledrag('question-sort', 'order', 'sibling', 'sort'); - $header = array('', t('Question'), '', t('Sort')); - foreach (element_children($form) as $key) { - // Add class to group weight fields for drag and drop. - $form[$key]['sort']['#attributes']['class'] = 'sort'; - - $row = array(''); - $row[] = drupal_render($form[$key]['title']); - $row[] = drupal_render($form[$key]['nid']); - $row[] = drupal_render($form[$key]['sort']); - $rows[] = array('data' => $row, 'class' => 'draggable'); - } - $output = theme('table', $header, $rows, array('id' => 'question-sort')); - $output .= drupal_render($form); - return $output; -} - diff --git a/modules/faq/includes/faq-category-hide-answer.tpl.php b/modules/faq/includes/faq-category-hide-answer.tpl.php deleted file mode 100644 index 3b8879b..0000000 --- a/modules/faq/includes/faq-category-hide-answer.tpl.php +++ /dev/null @@ -1,136 +0,0 @@ - 0) { - $hdr = 'h6'; -} -else { - $hdr = 'h5'; -} - -?>
- -
- - < class="faq-header"> - - - - () - - > - - - - - - -
- - -
- -
- - - -
- < class="faq-category-list"> - $subcat): ?> -
  • - - - () - - -
    - -
    -
  • - - > -
    - - -
    - - - - $subcat_html): ?> -
    - - - - -
    - - $node): ?> -
    -
    - -
    - -
    - - - - -
    -
    - - -
    - -
    - -
    diff --git a/modules/faq/includes/faq-category-new-page.tpl.php b/modules/faq/includes/faq-category-new-page.tpl.php deleted file mode 100644 index 208ad56..0000000 --- a/modules/faq/includes/faq-category-new-page.tpl.php +++ /dev/null @@ -1,126 +0,0 @@ - 0) { - $hdr = 'h6'; -} -else { - $hdr = 'h5'; -} - -?>
    - -
    - - < class="faq-header"> - - - - () - - > - - - - - - -
    - - -
    - -
    - - - -
    - < class="faq-category-list"> - $subcat): ?> -
  • - - - () - - -
    - -
    -
  • - - > -
    - - -
    - - - - $subcat_html): ?> -
    - - - - - -
    - < class="faq-category-list"> - $question_link): ?> -
  • - -
  • - - > -
    - - - -
    - -
    diff --git a/modules/faq/includes/faq-category-questions-inline.tpl.php b/modules/faq/includes/faq-category-questions-inline.tpl.php deleted file mode 100644 index c09d1ff..0000000 --- a/modules/faq/includes/faq-category-questions-inline.tpl.php +++ /dev/null @@ -1,145 +0,0 @@ - 0) { - $hdr = 'h6'; -} -else { - $hdr = 'h5'; -} - -?> - -
    - -
    - - < class="faq-header"> - - - - () - - > - - - - - - -
    - - -
    - -
    - - - -
    - < class="faq-category-list"> - $subcat): ?> -
  • - - - () - - -
    - -
    -
  • - - > -
    - - -
    - - - - $subcat_html): ?> -
    - - - - -
    - - $node): ?> -
    - - - - -
    - -
    - - - - - - - -
    - - -
    - -
    - -
    diff --git a/modules/faq/includes/faq-category-questions-top-answers.tpl.php b/modules/faq/includes/faq-category-questions-top-answers.tpl.php deleted file mode 100644 index ebe1684..0000000 --- a/modules/faq/includes/faq-category-questions-top-answers.tpl.php +++ /dev/null @@ -1,135 +0,0 @@ - 0) { - $hdr = 'h6'; -} -else { - $hdr = 'h5'; -} - -$depth = 0; - -?> - - -
    - - - -
    - - - < class="faq-header"> - - - > -
    -
    -
    - - - - - - - $subcat_html): ?> - - - - - -
    -
    - - - - - $node): ?> - -
    - - - - -
    - -
    - - - - - - - -
    - - - - - - -
    -
    -
    - - - 0): ?> -
    - - - 0) { - $hdr = 'h6'; -} -else { - $hdr = 'h5'; -} - -?> - -
    - - -
    - - < class="faq-header"> - - - - () - - > - - - - -
    - - -
    - -
    - - - - -
    - < class="faq-category-list"> - $subcat): ?> -
  • - - - () - - -
    - -
    -
  • - - > -
    - - -
    - - - - $subcat_html): ?> -
    - - - - - -
    - < class="faq-ul-questions-top"> - $question_link): ?> -
  • - -
  • - - > -
    - - - -
    -
    - - - - - < class="faq-header"> - - - > -
    - - - -
    -
    - - - $node): ?> - -
    - -
    - -
    - - - - - -
    - - - -
    -
    - - -
    -
    -
    - - - -
    -
    - -
    - -
    - - - - -
    -
    - - -
    diff --git a/modules/faq/includes/faq-new-page.tpl.php b/modules/faq/includes/faq-new-page.tpl.php deleted file mode 100644 index be08d16..0000000 --- a/modules/faq/includes/faq-new-page.tpl.php +++ /dev/null @@ -1,20 +0,0 @@ - - - -
    - - - -
    -
    - - - - -
    - -
    - - - - - - - -
    - - -
    diff --git a/modules/faq/includes/faq-questions-top.tpl.php b/modules/faq/includes/faq-questions-top.tpl.php deleted file mode 100644 index 6d247e6..0000000 --- a/modules/faq/includes/faq-questions-top.tpl.php +++ /dev/null @@ -1,56 +0,0 @@ - - - -
    - - - -
    - - - - -
    - -
    - - - - - -
    - - -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; -} - diff --git a/modules/faq/includes/faq.new_page.inc b/modules/faq/includes/faq.new_page.inc deleted file mode 100644 index 06d5ef1..0000000 --- a/modules/faq/includes/faq.new_page.inc +++ /dev/null @@ -1,134 +0,0 @@ -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; -} - diff --git a/modules/faq/includes/faq.questions_inline.inc b/modules/faq/includes/faq.questions_inline.inc deleted file mode 100644 index 390e3ae..0000000 --- a/modules/faq/includes/faq.questions_inline.inc +++ /dev/null @@ -1,168 +0,0 @@ -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; -} - diff --git a/modules/faq/includes/faq.questions_top.inc b/modules/faq/includes/faq.questions_top.inc deleted file mode 100644 index e944795..0000000 --- a/modules/faq/includes/faq.questions_top.inc +++ /dev/null @@ -1,282 +0,0 @@ -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; - } -} - diff --git a/modules/faq/views/faq.views.inc b/modules/faq/views/faq.views.inc deleted file mode 100644 index a0107f8..0000000 --- a/modules/faq/views/faq.views.inc +++ /dev/null @@ -1,132 +0,0 @@ - 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; -} -