Last active
February 28, 2025 15:40
-
-
Save pupi1985/125dc479ed69953627193782c862a0ed to your computer and use it in GitHub Desktop.
Dynamic category change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Question2Answer by Gideon Greenspan and contributors | |
| http://www.question2answer.org/ | |
| Description: Miscellaneous language phrases | |
| This program is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU General Public License | |
| as published by the Free Software Foundation; either version 2 | |
| of the License, or (at your option) any later version. | |
| This program is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| GNU General Public License for more details. | |
| More about this license: http://www.question2answer.org/license.php | |
| */ | |
| return array( | |
| 'block_ip_button' => 'Block IP address', | |
| 'browse_categories' => 'Browse categories', | |
| 'browse_category_x' => 'Browse category ^', | |
| 'captcha_approve_fix' => 'This verification will stop appearing once your account is approved.', | |
| 'captcha_confirm_fix' => 'To avoid this verification in future, please ^5confirm your email address^6.', | |
| 'captcha_error' => 'Please complete the anti-spam verification', | |
| 'captcha_label' => 'Anti-spam verification:', | |
| 'captcha_login_fix' => 'To avoid this verification in future, please ^1log in^2 or ^3register^4.', | |
| 'feed_a_edited_prefix' => 'Answer edited: ', | |
| 'feed_a_prefix' => 'Answered: ', | |
| 'feed_a_reshown_prefix' => 'Answer reshown: ', | |
| 'feed_a_selected_prefix' => 'Answer selected: ', | |
| 'feed_c_edited_prefix' => 'Comment edited: ', | |
| 'feed_c_moved_prefix' => 'Comment moved: ', | |
| 'feed_c_prefix' => 'Commented: ', | |
| 'feed_c_reshown_prefix' => 'Comment reshown: ', | |
| 'feed_closed_prefix' => 'Closed: ', | |
| 'feed_edited_prefix' => 'Edited: ', | |
| 'feed_hidden_prefix' => 'Hidden: ', | |
| 'feed_not_found' => 'Feed not found', | |
| 'feed_recategorized_prefix' => 'Recategorized: ', | |
| 'feed_reopened_prefix' => 'Reopened: ', | |
| 'feed_reshown_prefix' => 'Reshown: ', | |
| 'feed_retagged_prefix' => 'Retagged: ', | |
| 'feedback_email' => 'Your email: (optional)', | |
| 'feedback_empty' => 'Please use this field to send some comments or suggestions', | |
| 'feedback_message' => 'Your comments or suggestions for ^:', | |
| 'feedback_name' => 'Your name: (optional)', | |
| 'feedback_sent' => 'Your message below was sent - thank you.', | |
| 'feedback_title' => 'Send feedback', | |
| 'form_security_again' => 'Please click again to confirm', | |
| 'form_security_reload' => 'Please reload the page then try again', | |
| 'hide_all_ip_button' => 'Hide all posts from this IP', | |
| 'host_name' => 'Host name:', | |
| 'inbox' => 'Inbox', | |
| 'matches_blocked_ips' => 'Matches blocked IP addresses:', | |
| 'message_empty' => 'Please enter your message to send to this user', | |
| 'message_explanation' => 'This will be sent as a notification from ^. Your email address will not be revealed unless you include it in the message.', | |
| 'message_for_x' => 'Your message for ^:', | |
| 'message_limit' => 'You cannot send more private messages this hour', | |
| 'message_must_login' => 'Please ^1log in^2 or ^3register^4 to send private messages.', | |
| 'message_recent_history' => 'Recent correspondence with ^', | |
| 'message_sent' => 'Your private message below was sent', | |
| 'more_favorite_qs' => 'More favorite questions...', | |
| 'more_favorite_tags' => 'More favorite tags...', | |
| 'more_favorite_users' => 'More favorite users...', | |
| 'my_favorites_title' => 'My favorites', | |
| 'nav_all_my_updates' => 'All my updates', | |
| 'nav_my_content' => 'My content', | |
| 'nav_my_details' => 'My account', | |
| 'nav_my_favorites' => 'My favorites', | |
| 'nav_user_activity' => 'Recent activity', | |
| 'nav_user_as' => 'All answers', | |
| 'nav_user_pms' => 'Private messages', | |
| 'nav_user_qs' => 'All questions', | |
| 'nav_user_wall' => 'Wall', | |
| 'next_step' => 'Next step', | |
| 'no_activity_from_x' => 'No activity from ^', | |
| 'no_favorite_categories' => 'No favorite categories', | |
| 'no_favorite_qs' => 'No favorite questions', | |
| 'no_favorite_tags' => 'No favorite tags', | |
| 'no_favorite_users' => 'No favorite users', | |
| 'no_recent_updates' => 'No recent updates', | |
| 'no_updates_content' => 'No recent updates for my content', | |
| 'no_updates_favorites' => 'No updates for my favorites', | |
| 'outbox' => 'Sent items', | |
| 'pm_inbox_title' => 'Private messages received', | |
| 'pm_outbox_title' => 'Private messages sent', | |
| 'private_message_title' => 'Send a private message', | |
| 'recent_activity_from_x' => 'Recent activity from ^', | |
| 'recent_updates_content' => 'Recent updates for my content', | |
| 'recent_updates_favorites' => 'Recent updates for my favorites', | |
| 'recent_updates_title' => 'Recent updates for me', | |
| 'site_in_maintenance' => 'This site is currently down for maintenance - please come back soon.', | |
| 'suggest_favorites_add' => 'To add a question or other item to your favorites, click the ^ at the top of its page.', | |
| 'suggest_update_favorites' => 'For more updates, add items to ^1your favorites^2.', | |
| 'unblock_ip_button' => 'Unblock IP address', | |
| 'your_a_commented' => 'your answer commented', | |
| 'your_a_edited' => 'your answer edited', | |
| 'your_a_hidden' => 'your answer hidden', | |
| 'your_a_questioned' => 'asked on your answer', | |
| 'your_a_reshown' => 'your answer reshown', | |
| 'your_a_selected' => 'your answer selected', | |
| 'your_c_edited' => 'your comment edited', | |
| 'your_c_followed' => 'your comment followed', | |
| 'your_c_hidden' => 'your comment hidden', | |
| 'your_c_moved' => 'your comment moved', | |
| 'your_c_reshown' => 'your comment reshown', | |
| 'your_q_answered' => 'your question answered', | |
| 'your_q_closed' => 'your question closed', | |
| 'your_q_commented' => 'your question commented', | |
| 'your_q_edited' => 'your question edited', | |
| 'your_q_hidden' => 'your question hidden', | |
| 'your_q_recategorized' => 'your question recategorized', | |
| 'your_q_reopened' => 'your question reopened', | |
| 'your_q_reshown' => 'your question reshown', | |
| 'your_q_retagged' => 'your question retagged', | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Question2Answer by Gideon Greenspan and contributors | |
| http://www.question2answer.org/ | |
| Description: Controller for page listing categories | |
| This program is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU General Public License | |
| as published by the Free Software Foundation; either version 2 | |
| of the License, or (at your option) any later version. | |
| This program is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| GNU General Public License for more details. | |
| More about this license: http://www.question2answer.org/license.php | |
| */ | |
| if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser | |
| header('Location: ../../'); | |
| exit; | |
| } | |
| require_once QA_INCLUDE_DIR . 'db/selects.php'; | |
| require_once QA_INCLUDE_DIR . 'app/format.php'; | |
| $categoryslugs = qa_request_parts(1); | |
| $hasSlugs = !empty($categoryslugs); | |
| // Get information about appropriate categories and redirect to questions page if category has no sub-categories | |
| $userid = qa_get_logged_in_userid(); | |
| list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending( | |
| qa_db_category_nav_selectspec($categoryslugs, false, false, true), | |
| $hasSlugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, | |
| isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null | |
| ); | |
| if ($hasSlugs && !isset($categoryid)) { | |
| return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; | |
| } | |
| // Function for recursive display of categories | |
| function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap) | |
| { | |
| foreach ($navigation as $key => $navlink) { | |
| $category = $categories[$navlink['categoryid']]; | |
| if (!$category['childcount']) { | |
| unset($navigation[$key]['url']); | |
| } elseif ($navlink['selected']) { | |
| $navigation[$key]['state'] = 'open'; | |
| $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid'])); | |
| } else | |
| $navigation[$key]['state'] = 'closed'; | |
| if (@$favoritemap[$navlink['categoryid']]) { | |
| $navigation[$key]['favorited'] = true; | |
| } | |
| $navigation[$key]['note'] = | |
| ' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1) | |
| ? qa_lang_html_sub('main/1_question', '1', '1') | |
| : qa_lang_html_sub('main/x_questions', number_format($category['qcount'])) | |
| ).'</a>'; | |
| if (strlen($category['content'])) | |
| $navigation[$key]['note'] .= qa_html(' - ' . $category['content']); | |
| if (isset($navlink['subnav'])) | |
| qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap); | |
| } | |
| } | |
| // Prepare content for theme | |
| $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, $categoryid))); | |
| $qa_content['title'] = $hasSlugs ? qa_lang_html_sub('misc/browse_category_x', $categories[$categoryid]['title']) : qa_lang_html('misc/browse_categories'); | |
| if (count($categories)) { | |
| $navigation = qa_category_navigation($categories, $categoryid, 'categories/', false); | |
| unset($navigation['all']); | |
| $favoritemap = array(); | |
| if (isset($favoritecats)) { | |
| foreach ($favoritecats as $category) { | |
| $favoritemap[$category['categoryid']] = true; | |
| } | |
| } | |
| qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap); | |
| $qa_content['nav_list'] = array( | |
| 'nav' => $navigation, | |
| 'type' => 'browse-cat', | |
| ); | |
| } else { | |
| $qa_content['title'] = qa_lang_html('main/no_categories_found'); | |
| $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags()); | |
| } | |
| return $qa_content; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment