diff --git a/README.md b/README.md index 26a1e04..c43d8a3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Advanced-Sidebox 2.0.7 +## Advanced-Sidebox 2.1

Advanced Sidebox Logo diff --git a/Upload/admin/jscripts/asb.js b/Upload/admin/jscripts/asb/asb.js similarity index 88% rename from Upload/admin/jscripts/asb.js rename to Upload/admin/jscripts/asb/asb.js index a2eddd8..e83fdcb 100644 --- a/Upload/admin/jscripts/asb.js +++ b/Upload/admin/jscripts/asb/asb.js @@ -6,7 +6,7 @@ * this file contains JavaScript for the ACP functions */ -ASB = { +(function() { /** * init() * @@ -14,8 +14,7 @@ ASB = { * * @return: n/a */ - init: function() - { + function init() { if ($('help_link')) { $('help_link').observe('click', function(event) { Event.stop(event); @@ -30,5 +29,6 @@ ASB = { }); } } -}; -Event.observe(window, 'load', ASB.init); + + Event.observe(window, 'load', init); +})(); diff --git a/Upload/admin/jscripts/asb/asb.min.js b/Upload/admin/jscripts/asb/asb.min.js new file mode 100644 index 0000000..a668d68 --- /dev/null +++ b/Upload/admin/jscripts/asb/asb.min.js @@ -0,0 +1,3 @@ +(function(){function init(){if($('help_link')){$('help_link').observe('click',function(event){Event.stop(event);MyBB.popupWindow(this.href,'asbHelp',840,520);});} +if($('help_link_icon')){$('help_link_icon').observe('click',function(event){Event.stop(event);MyBB.popupWindow(this.up('a').href,'asbHelp',840,520);});}} +Event.observe(window,'load',init);})(); \ No newline at end of file diff --git a/Upload/admin/jscripts/asb_modal.js b/Upload/admin/jscripts/asb/asb_modal.js similarity index 73% rename from Upload/admin/jscripts/asb_modal.js rename to Upload/admin/jscripts/asb/asb_modal.js index 03fae45..5e3c22a 100644 --- a/Upload/admin/jscripts/asb_modal.js +++ b/Upload/admin/jscripts/asb/asb_modal.js @@ -7,8 +7,7 @@ * https://prototype.lighthouseapp.com/projects/8886/tickets/1384 */ -MyModal = Class.create(MyModal, -{ +var ASB = (function(a) { /** * submit() * @@ -17,16 +16,16 @@ MyModal = Class.create(MyModal, * of the Prototype JS library when serializing multiple * select elements * - * @param - event - (Event) the submit event object + * @param - e - (Event) the submit event object * @return: n/a */ - submit: function(event) - { - Event.stop(event); + function submit(e) { + var form, select, selects, option, options, newElement, s, o; + + Event.stop(e); this.showOverlayLoader(); // get all the select elements on this form - var form, select, selects, option, options, newElement, s, o; form = $(this.options.formId); selects = $$('#' + this.options.formId + ' select'); @@ -63,4 +62,28 @@ MyModal = Class.create(MyModal, onComplete: this.onComplete.bind(this), }); } -}); + + /** + * displayModal() + * + * intercept module errors if necessary + * + * @param - $super - (Function) the parent function + * @param - data - (String) the HTML + * @return: n/a + */ + function displayModal($super, data) { + if(data == 'asb') { + window.location = "./index.php?module=config-asb"; + return; + } + $super(data); + } + + a.Modal = Class.create(MyModal, { + submit: submit, + displayModal: displayModal, + }); + + return a; +})(ASB || {}); diff --git a/Upload/admin/jscripts/asb/asb_modal.min.js b/Upload/admin/jscripts/asb/asb_modal.min.js new file mode 100644 index 0000000..790f1a0 --- /dev/null +++ b/Upload/admin/jscripts/asb/asb_modal.min.js @@ -0,0 +1,8 @@ +var ASB=(function(a){function submit(e){var form,select,selects,option,options,newElement,s,o;Event.stop(e);this.showOverlayLoader();form=$(this.options.formId);selects=$$('#'+this.options.formId+' select');for(s=0;sasb'){window.location="./index.php?module=config-asb";return;} +$super(data);} +a.Modal=Class.create(MyModal,{submit:submit,displayModal:displayModal,});return a;})(ASB||{}); \ No newline at end of file diff --git a/Upload/admin/jscripts/asb_scripts.js b/Upload/admin/jscripts/asb/asb_scripts.js similarity index 81% rename from Upload/admin/jscripts/asb_scripts.js rename to Upload/admin/jscripts/asb/asb_scripts.js index cf56c85..9644bbd 100644 --- a/Upload/admin/jscripts/asb_scripts.js +++ b/Upload/admin/jscripts/asb/asb_scripts.js @@ -6,8 +6,8 @@ * this file contains JavaScript for the ACP script edit functions */ -ASBScript = { - current: '', +var ASB = (function(a) { + var current = ''; /** * init() @@ -18,8 +18,7 @@ ASBScript = { * * @return: n/a */ - init: function() - { + function init() { // only show replace all options when selected new Peeker($$(".replace_all"), $("replace_content"), /1/, true); @@ -51,13 +50,13 @@ ASBScript = { // watch the 'detected' selectors and send the chosen // item to the appropriate text box - ASBScript.observeInputs(); + observeInputs(); // watch the file name input and if it has changed on blur // attempt to detect hooks, template and URL attributes (page, action) // and display them as selectable lists - $('filename').observe('blur', ASBScript.update); - }, + $('filename').observe('blur', update); + } /** * update() @@ -67,15 +66,14 @@ ASBScript = { * @param - event - (Event) the blur event object * @return: n/a */ - update: function(event) - { + function update(event) { // if nothing has changed, get out - if (this.value == ASBScript.current || this.value == '') { + if (this.value == current || this.value == '') { return; } // otherwise, update the current script - ASBScript.current = this.value; + current = this.value; // hide the 'detected' selectors $('hook_list').hide(); @@ -90,16 +88,15 @@ ASBScript = { // attempt to get the info new Ajax.Request('index.php', { - parameters: - { + parameters: { module: 'config-asb', action: 'xmlhttp', mode: 'analyze_script', filename: this.value }, - onSuccess: ASBScript.showResults + onSuccess: showResults }); - }, + } /** * showResults() @@ -109,8 +106,7 @@ ASBScript = { * @param - response - (Response) the XMLHTTP response object * @return: n/a */ - showResults: function(response) - { + function showResults(response) { // hide all the spinners var spinners = $$('div.ajax_spinners'); for (x = 0; x < spinners.length; ++x) { @@ -126,24 +122,24 @@ ASBScript = { var info = response.responseText.evalJSON(); // if there is info, show it - if (info['hooks']) { - $('hook_list').innerHTML = info['hooks']; + if (info.hooks) { + $('hook_list').update(info.hooks); $('hook_list').show(); } - if (info['templates']) { - $('template_list').innerHTML = info['templates']; + if (info.templates) { + $('template_list').update(info.templates); $('template_list').show(); } - if (info['actions']) { - $('action_list').innerHTML = info['actions']; + if (info.actions) { + $('action_list').update(info.actions); $('action_list').show(); } // re-do our observation of the selectors now that they have been rebuilt - ASBScript.observeInputs(); - }, + observeInputs(); + } /** * observeInputs() @@ -153,8 +149,7 @@ ASBScript = { * @param - response - (Response) the XMLHTTP response object * @return: n/a */ - observeInputs: function () - { + function observeInputs() { if ($('hook_selector')) { $('hook_selector').observe('change', function(event) { $('hook').value = this.value; @@ -173,5 +168,24 @@ ASBScript = { }); } } -}; -Event.observe(window, 'load', ASBScript.init); + + /** + * setCurrent() + * + * public setter + * + * @param - value - (String) the current file name + * @return: n/a + */ + function setCurrent(value) { + current = value || ''; + } + + Event.observe(window, 'load', init); + + a.scripts = { + setCurrent: setCurrent, + }; + + return a; +})(ASB || {}); diff --git a/Upload/admin/jscripts/asb/asb_scripts.min.js b/Upload/admin/jscripts/asb/asb_scripts.min.js new file mode 100644 index 0000000..b717557 --- /dev/null +++ b/Upload/admin/jscripts/asb/asb_scripts.min.js @@ -0,0 +1,17 @@ +var ASB=(function(a){var current='';function init(){new Peeker($$(".replace_all"),$("replace_content"),/1/,true);new Peeker($$(".replace_all"),$("header_search"),/0/,true);new Peeker($$(".replace_all"),$("footer_search"),/0/,true);new Peeker($$(".eval"),$("template_row"),/0/,true);new Peeker($$(".eval"),$("header_search"),/0/,true);new Peeker($$(".eval"),$("footer_search"),/0/,true);new Peeker($$(".eval"),$("replace_all"),/0/,true);new Peeker($$(".eval"),$("replace_content"),/0/,true);if($('replace_all_yes').checked){$("header_search").hide();$("footer_search").hide();}else{$("replace_content").hide();} +if($('eval_yes').checked){$("header_search").hide();$("footer_search").hide();$("template_row").hide();$("replace_all").hide();$("replace_content").hide();} +observeInputs();$('filename').observe('blur',update);} +function update(event){if(this.value==current||this.value==''){return;} +current=this.value;$('hook_list').hide();$('template_list').hide();$('action_list').hide();var spinners=$$('div.ajax_spinners');for(x=0;x{1} value"; - -$l['asb_template'] = "Template"; -$l['asb_template_desc'] = "name of the template to edit"; -$l['asb_hook'] = "Hook"; -$l['asb_hook_desc'] = "plugin hook to use"; - -$l['asb_header_search_text'] = "Header Search Text"; -$l['asb_header_search_text_desc'] = "ASB will place the side box tables just after the contents of this setting are found"; -$l['asb_footer_search_text'] = "Footer Search Text"; -$l['asb_footer_search_text_desc'] = "ASB will place the side box tables just before the contents of this setting are found"; - -$l['asb_replace_template'] = "Replacing entire template?"; -$l['asb_replace_template_desc'] = "set to yes in order to replace the entire template with custom content"; -$l['asb_replacement_content'] = "Replacement Content"; -$l['asb_replacement_content_desc'] = "content to replace into this page"; -$l['asb_replacement_template'] = "Replacement Template Name"; -$l['asb_replacement_template_desc'] = "optionally enter a valid template name here and it will be used (leave blank to use custom content above)"; -$l['asb_output_to_vars'] = "Output Sideboxes To Variables Rather Than Editing Templates"; -$l['asb_output_to_vars_desc'] = "use this option if the script does not use templates to output the side box columns as {1}"; - -$l['asb_creating'] = "Creating"; -$l['asb_editing'] = "Editing"; -$l['asb_new_sidebox_action'] = "{1} A New {2} Sidebox"; -$l['asb_detecting'] = "detecting"; +$l['asb_add'] = 'Add'; +$l['asb_cancel'] = 'Cancel'; +$l['asb_save'] = 'Save'; +$l['asb_status'] = 'Status'; +$l['asb_visibility'] = 'Visibility'; +$l['asb_hooks'] = 'Hooks'; +$l['asb_templates'] = 'Templates'; +$l['asb_actions'] = 'Actions'; +$l['asb_detected'] = 'Detected'; +$l['asb_update'] = 'Update'; +$l['asb_none'] = 'none'; + +$l['asb_inactive'] = 'Inactive'; +$l['asb_inactive_desc'] = 'this script is currently deactivated, click to activate'; +$l['asb_active'] = 'Active'; +$l['asb_active_desc'] = 'this script is currently activated, click to deactivate'; + +$l['asb_filter_label'] = 'Showing only side boxes viewable on {1}'; + +$l['asb_title'] = 'Title'; +$l['asb_title_desc'] = 'the display name'; +$l['asb_filename'] = 'Filename'; +$l['asb_filename_desc'] = 'the file name of the script'; +$l['asb_action'] = 'Action'; +$l['asb_page'] = 'Page'; +$l['asb_scriptvar_generic_desc'] = 'the URL {1} value'; + +$l['asb_template'] = 'Template'; +$l['asb_template_desc'] = 'name of the template to edit'; +$l['asb_hook'] = 'Hook'; +$l['asb_hook_desc'] = 'plugin hook to use'; + +$l['asb_header_search_text'] = 'Header Search Text'; +$l['asb_header_search_text_desc'] = 'ASB will place the side box tables just after the contents of this setting are found'; +$l['asb_footer_search_text'] = 'Footer Search Text'; +$l['asb_footer_search_text_desc'] = 'ASB will place the side box tables just before the contents of this setting are found'; + +$l['asb_replace_template'] = 'Replacing entire template?'; +$l['asb_replace_template_desc'] = 'set to yes in order to replace the entire template with custom content'; +$l['asb_replacement_content'] = 'Replacement Content'; +$l['asb_replacement_content_desc'] = 'content to replace into this page'; +$l['asb_replacement_template'] = 'Replacement Template Name'; +$l['asb_replacement_template_desc'] = 'optionally enter a valid template name here and it will be used (leave blank to use custom content above)'; +$l['asb_output_to_vars'] = 'Output Sideboxes To Variables Rather Than Editing Templates'; +$l['asb_output_to_vars_desc'] = 'use this option if the script does not use templates to output the side box columns as {1}'; + +$l['asb_creating'] = 'Creating'; +$l['asb_editing'] = 'Editing'; +$l['asb_new_sidebox_action'] = '{1} A New {2} Sidebox'; +$l['asb_detecting'] = 'detecting'; // positioning $l['asb_position_left_boxes'] = 'Left Boxes'; $l['asb_position_right_boxes'] = 'Right Boxes'; $l['asb_position_desc'] = 'choose left or right'; -$l['asb_position'] = "Position"; -$l['asb_position_left'] = "Left"; -$l['asb_position_right'] = "Right"; +$l['asb_position'] = 'Position'; +$l['asb_position_left'] = 'Left'; +$l['asb_position_right'] = 'Right'; // controls $l['asb_edit'] = 'Edit'; @@ -134,7 +143,7 @@ $l['asb_save_fail'] = 'The box could not be saved'; $l['asb_delete_box_success'] = 'The box was deleted successfully'; $l['asb_delete_box_failure'] = 'There was an error while attempting to remove the seleced sidebox'; -$l['asb_no_description'] = "no description"; +$l['asb_no_description'] = 'no description'; $l['asb_edit_fail_bad_module'] = 'The chosen module was invalid and cannot be used.'; // menus @@ -146,17 +155,18 @@ // add/edit $l['asb_edit_box'] = 'Edit Side Box'; $l['asb_type_desc'] = 'select one of several pre-sets'; -$l['asb_add_new_sidebox'] = "Add a new side box of this type"; +$l['asb_add_new_sidebox'] = 'Add a new side box of this type'; -$l['asb_modal_tab_general'] = "General"; -$l['asb_modal_tab_permissions'] = "Permissions"; -$l['asb_modal_tab_pages'] = "Pages"; -$l['asb_modal_tab_settings'] = "Settings"; -$l['asb_modal_tab_settings_desc'] = "Custom Module Settings"; +$l['asb_modal_tab_general'] = 'General'; +$l['asb_modal_tab_permissions'] = 'Permissions'; +$l['asb_modal_tab_pages'] = 'Pages'; +$l['asb_modal_tab_themes'] = 'Themes'; +$l['asb_modal_tab_settings'] = 'Settings'; +$l['asb_modal_tab_settings_desc'] = 'Custom Module Settings'; -$l['asb_sample_content_line1'] = "Place your custom content here."; -$l['asb_sample_content_line2'] = "For example:"; -$l['asb_sample_content_line3'] = "my custom content"; +$l['asb_sample_content_line1'] = 'Place your custom content here.'; +$l['asb_sample_content_line2'] = 'For example:'; +$l['asb_sample_content_line3'] = 'my custom content'; // groups $l['asb_which_groups'] = 'Which Groups?'; @@ -169,8 +179,11 @@ $l['asb_both_scripts'] = 'Both Scripts'; $l['asb_which_scripts'] = 'Which Scripts?'; -$l['asb_no_script_filter'] = "Do not filter by script"; -$l['asb_script_filter_title'] = "Show only the boxes for {1}"; +$l['asb_no_script_filter'] = 'Do not filter by script'; +$l['asb_script_filter_title'] = 'Show only the boxes for {1}'; + +// themes +$l['asb_which_themes'] = 'Which Themes?'; $l['asb_index'] = 'Index'; $l['asb_forumdisplay'] = 'Forum'; @@ -191,8 +204,12 @@ $l['asb_abbr_showteam'] = 'Team'; $l['asb_abbr_stats'] = 'Stats'; -$l['asb_all_scripts_deactivated'] = "This Side Box Is Deactivated"; -$l['asb_globally_visible'] = "Globally Visible"; +$l['asb_invalid_sidebox'] = 'invalid side box'; +$l['asb_no_active_scripts'] = 'no active scripts'; +$l['asb_visibile_for_all_themes'] = 'Visible For All Themes'; + +$l['asb_all_scripts_deactivated'] = 'This Side Box Is Deactivated'; +$l['asb_globally_visible'] = 'Globally Visible'; // custom titles $l['asb_current_title'] = 'current title: '; @@ -202,6 +219,10 @@ $l['asb_default_title'] = 'currently using default title'; $l['asb_default_title_info'] = '(leave blank to keep default title)'; +// title link +$l['asb_title_link'] = 'Title Link'; +$l['asb_title_link_desc'] = 'URL for title link (leave blank for no link)'; + // misc. options $l['asb_display_order'] = 'Display Order'; @@ -210,7 +231,7 @@ */ // general use and box types -$l['asb_box'] = "Box"; +$l['asb_box'] = 'Box'; $l['asb_custom'] = 'Custom'; // page @@ -228,13 +249,14 @@ // module info $l['asb_no_modules_detected'] = 'no modules detected'; -$l['asb_module_info_good_count'] = "There {1} {2} {3} detected"; +$l['asb_module_info_good_count'] = 'There {1} {2} {3} detected'; $l['asb_are'] = 'are'; $l['asb_is'] = 'is'; $l['asb_module_plural'] = 'modules'; $l['asb_module_singular'] = 'module'; -$l['asb_module_awaiting_install'] = ", {1} {2} awaiting installation."; +$l['asb_module_awaiting_install'] = ', {1} {2} awaiting installation.'; $l['asb_module_all_good'] = ' and properly installed.'; +$l['asb_module_out_of_date'] = 'This addon is out-of-date and will require an update before it can be used.'; // user messages $l['asb_install_addon_success'] = 'The module was installed successfully'; @@ -300,25 +322,25 @@ $l['asb_manage_scripts'] = 'Manage Scripts'; $l['asb_manage_scripts_desc'] = 'change how side boxes appear for each page'; -$l['asb_edit_script'] = "Add New Script"; -$l['asb_edit_script_desc'] = "add new script definitions or edit existing info"; - -$l['asb_add_new_script'] = "Add a new script definition"; -$l['asb_no_scripts'] = "no script info to show"; -$l['asb_script_info'] = "Script Info"; - -$l['asb_script_save_success'] = "The script definition was saved successfully"; -$l['asb_script_save_fail'] = "The script definition could not be saved successfully"; -$l['asb_script_import_success'] = "The script definition was imported successfully"; -$l['asb_script_import_fail'] = "The script definition could not be imported successfully"; -$l['asb_script_delete_success'] = "The script definition was deleted successfully"; -$l['asb_script_delete_fail'] = "The script definition could not be deleted successfully"; -$l['asb_script_export_success'] = "The script definition was exported successfully"; -$l['asb_script_export_fail'] = "The script definition could not be exported successfully"; -$l['asb_script_activate_success'] = "The script definition was activated successfully"; -$l['asb_script_activate_fail'] = "The script definition could not be activated successfully"; -$l['asb_script_deactivate_success'] = "The script definition was deactivated successfully"; -$l['asb_script_deactivate_fail'] = "The script definition could not be deactivated successfully"; +$l['asb_edit_script'] = 'Add New Script'; +$l['asb_edit_script_desc'] = 'add new script definitions or edit existing info'; + +$l['asb_add_new_script'] = 'Add a new script definition'; +$l['asb_no_scripts'] = 'no script info to show'; +$l['asb_script_info'] = 'Script Info'; + +$l['asb_script_save_success'] = 'The script definition was saved successfully'; +$l['asb_script_save_fail'] = 'The script definition could not be saved successfully'; +$l['asb_script_import_success'] = 'The script definition was imported successfully'; +$l['asb_script_import_fail'] = 'The script definition could not be imported successfully'; +$l['asb_script_delete_success'] = 'The script definition was deleted successfully'; +$l['asb_script_delete_fail'] = 'The script definition could not be deleted successfully'; +$l['asb_script_export_success'] = 'The script definition was exported successfully'; +$l['asb_script_export_fail'] = 'The script definition could not be exported successfully'; +$l['asb_script_activate_success'] = 'The script definition was activated successfully'; +$l['asb_script_activate_fail'] = 'The script definition could not be activated successfully'; +$l['asb_script_deactivate_success'] = 'The script definition was deactivated successfully'; +$l['asb_script_deactivate_fail'] = 'The script definition could not be deactivated successfully'; // ajax $l['asb_ajax_deleting_sidebox'] = 'Deleting . . .'; diff --git a/Upload/inc/languages/english/asb.lang.php b/Upload/inc/languages/english/asb.lang.php index 1eaff84..75d0887 100644 --- a/Upload/inc/languages/english/asb.lang.php +++ b/Upload/inc/languages/english/asb.lang.php @@ -7,13 +7,13 @@ * contains language used on the forum side */ -$l['asb'] = "Advanced Sidebox"; +$l['asb'] = 'Advanced Sidebox'; // UCP -$l['asb_show_sidebox'] = "Show side boxes."; +$l['asb_show_sidebox'] = 'Show side boxes.'; // visibility toggle icons -$l['asb_toggle_show'] = "show side boxes"; -$l['asb_toggle_hide'] = "hide side boxes"; +$l['asb_toggle_show'] = 'show side boxes'; +$l['asb_toggle_hide'] = 'hide side boxes'; ?> diff --git a/Upload/inc/languages/english/asb_addon.lang.php b/Upload/inc/languages/english/asb_addon.lang.php index c413185..d75775f 100644 --- a/Upload/inc/languages/english/asb_addon.lang.php +++ b/Upload/inc/languages/english/asb_addon.lang.php @@ -7,7 +7,7 @@ * contains language used on both forum and ACP side by add-on modules */ -$l['asb_addon'] = 'Add-on'; +$l['asb_addon'] = 'Addon'; // default settings $l['asb_xmlhttp_on_title'] = 'AJAX Update?'; @@ -25,18 +25,8 @@ $l['asb_thread_hide_list_title'] = 'Thread Hide List'; $l['asb_thread_hide_list_desc'] = '(optional) add a thread id or a comma-separated list of tids to be excluded/hidden [If Forum Show List or Forum Hide List are in use, this settings will override and amend]'; -// examples -$l['asb_example1_title'] = '[Example 1] Simplest Box'; -$l['asb_example1_desc'] = 'As simple as it gets. This box illustrates the easiest way to create an add-on module'; - -$l['asb_example2_title'] = '[Example 2] Using Templates'; -$l['asb_example2_desc'] = 'A simple box to illustrate using templates to produce content'; - -$l['asb_example3_title'] = '[Example 3] Using Settings'; -$l['asb_example3_desc'] = 'A simple box to illustrate using settings to control content'; -$l['asb_example3_setting_anouncement_text'] = 'Announcement Text'; -$l['asb_example3_setting_anouncement_text_desc'] = 'this text will be styled and displayed'; -$l['asb_example3_info'] = 'Custom text can be used by entering a value for the Announcement Text.'; +$l['asb_important_threads_only_title'] = 'Important Threads Only?'; +$l['asb_important_threads_only_desc'] = "YES to only use 'stickied' threads, NO (default) to use any threads/posts"; // welcome $l['asb_welcome'] = 'Welcome'; @@ -128,6 +118,9 @@ $l['asb_avatar_width_title'] = 'Avatar Width'; $l['asb_avatar_width_desc'] = 'width in pixels IF showing avatars'; +$l['asb_new_threads_only_title'] = 'New Threads Only?'; +$l['asb_new_threads_only_desc'] = 'enter nothing or 0 to show all threads with new posts (default), or enter the amount of days to show only threads created within that time'; + // recent posts $l['asb_recent_posts'] = 'Recent Posts'; $l['asb_recent_posts_desc'] = 'Lists the latest posts'; @@ -193,4 +186,58 @@ $l['asb_staff_online_no_staff_online'] = 'There are no staff members currently online.'; +// slideshow +$l['asb_slideshow'] = 'Slideshow'; +$l['asb_slideshow_desc'] = 'Display images in series with configurable options'; + +$l['asb_slideshow_folder_title'] = 'Image Path'; +$l['asb_slideshow_folder_description'] = 'this is the folder that contains the images to display from the forum root. (Example: images OR images/english NOT http://myforum.com/images)'; + +$l['asb_slideshow_rate_title'] = 'Rate'; +$l['asb_slideshow_rate_description'] = 'time in seconds to pause on each image'; + +$l['asb_slideshow_shuffle_title'] = 'Shuffle?'; +$l['asb_slideshow_shuffle_description'] = 'YES (default) to randomize image order, NO to use default order'; + +$l['asb_slideshow_fade_rate_title'] = 'Transistion Time'; +$l['asb_slideshow_fade_rate_description'] = 'time in seconds to fade from one image to the next'; + +$l['asb_slideshow_footer_text_title'] = 'Footer Link Text'; +$l['asb_slideshow_footer_text_description'] = 'text for footer link, leave blank for no footer'; + +$l['asb_slideshow_footer_url_title'] = 'Footer Link URL'; +$l['asb_slideshow_footer_url_description'] = 'URL for footer link, above setting must have a value before it will be effective'; + +// top poster +$l['asb_top_poster_title'] = 'Top Poster'; +$l['asb_top_poster_desc'] = 'Highlight the user of your forum with the most posts within a given time period'; + +$l['asb_top_poster_no_one'] = 'no one'; +$l['asb_top_poster_no_posts'] = 'no posts'; +$l['asb_top_poster_no_avatar'] = 'no avatar'; +$l['asb_top_poster_posts'] = 'posts!'; +$l['asb_top_poster_congrats'] = 'Congratulations to {1}, our current top poster for the last {2} with {3} posts!'; + +$l['asb_top_poster_time_frame_title'] = 'Time Frame'; +$l['asb_top_poster_time_frame_desc'] = 'time to compare for top poster stats'; + +$l['asb_top_poster_avatar_size_title'] = 'Avatar Size'; +$l['asb_top_poster_avatar_size_desc'] = 'size in pixels for top poster avatar (leave blank to fill side box minus some padding)'; + +$l['asb_top_poster_one_day_title'] = 'One Day'; +$l['asb_top_poster_one_week_title'] = 'One Week'; +$l['asb_top_poster_two_weeks_title'] = 'Two Weeks'; +$l['asb_top_poster_one_month_title'] = 'One Month'; +$l['asb_top_poster_three_months_title'] = 'Three Months'; +$l['asb_top_poster_six_months_title'] = 'Six Months'; +$l['asb_top_poster_one_year_title'] = 'One Year'; + +$l['asb_top_poster_one_day'] = 'day'; +$l['asb_top_poster_one_week'] = 'week'; +$l['asb_top_poster_two_weeks'] = 'two weeks'; +$l['asb_top_poster_one_month'] = 'month'; +$l['asb_top_poster_three_months'] = 'three months'; +$l['asb_top_poster_six_months'] = 'six months'; +$l['asb_top_poster_one_year'] = 'year'; + ?> diff --git a/Upload/inc/plugins/asb.php b/Upload/inc/plugins/asb.php index 8f7c59a..0eb3ed0 100644 --- a/Upload/inc/plugins/asb.php +++ b/Upload/inc/plugins/asb.php @@ -8,26 +8,26 @@ */ // disallow direct access to this file for security reasons -if(!defined("IN_MYBB")) +if(!defined('IN_MYBB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } // for modules -define("IN_ASB", true); -define("ASB_MODULES_DIR", MYBB_ROOT. "inc/plugins/asb/modules"); +define('IN_ASB', true); +define('ASB_MODULES_DIR', MYBB_ROOT . 'inc/plugins/asb/modules'); // some basic functions used everywhere require_once MYBB_ROOT . 'inc/plugins/asb/functions.php'; // load the install/admin routines only if in ACP. -if(defined("IN_ADMINCP")) +if(defined('IN_ADMINCP')) { - require_once MYBB_ROOT . "inc/plugins/asb/acp.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/acp.php'; } else { - require_once MYBB_ROOT . "inc/plugins/asb/forum.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/forum.php'; } ?> diff --git a/Upload/inc/plugins/asb/acp.php b/Upload/inc/plugins/asb/acp.php index a048836..356e360 100644 --- a/Upload/inc/plugins/asb/acp.php +++ b/Upload/inc/plugins/asb/acp.php @@ -9,13 +9,13 @@ */ // disallow direct access to this file for security reasons -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } define('ASB_URL', 'index.php?module=config-asb'); require_once MYBB_ROOT . 'inc/plugins/asb/functions_acp.php'; -require_once MYBB_ROOT . "inc/plugins/asb/install.php"; +require_once MYBB_ROOT . 'inc/plugins/asb/install.php'; /* * asb_admin() @@ -36,12 +36,17 @@ function asb_admin() } // now load up, this is our time - global $mybb, $lang, $html, $scripts, $all_scripts; + global $mybb, $lang, $html, $scripts, $all_scripts, $min; if(!$lang->asb) { $lang->load('asb'); } + if($mybb->settings['asb_minify_js']) + { + $min = '.min'; + } + // a few general functions and classes for the ACP side require_once MYBB_ROOT . 'inc/plugins/asb/classes/acp.php'; @@ -86,7 +91,7 @@ function asb_admin() */ function asb_admin_manage_sideboxes() { - global $mybb, $db, $page, $lang, $html, $scripts, $all_scripts; + global $mybb, $db, $page, $lang, $html, $scripts, $all_scripts, $min; $addons = asb_get_all_modules(); @@ -96,6 +101,11 @@ function asb_admin_manage_sideboxes() // display them foreach($addons as $module) { + if(!$module->is_valid()) + { + continue; + } + $id = $box_type = $module->get('base_name'); $title = $module->get('title'); $title_url = $html->url(array("action" => 'edit_box', "addon" => $box_type)); @@ -180,11 +190,12 @@ function asb_admin_manage_sideboxes() + - - - + + + EOF; @@ -249,7 +260,7 @@ function asb_admin_manage_sideboxes() */ function asb_admin_edit_box() { - global $page, $lang, $mybb, $db, $html, $scripts, $all_scripts; + global $page, $lang, $mybb, $db, $html, $scripts, $all_scripts, $min; $sidebox = new Sidebox($mybb->input['id']); $id = (int) $sidebox->get('id'); @@ -283,8 +294,12 @@ function asb_admin_edit_box() } else { - flash_message($lang->asb_edit_fail_bad_module); - admin_redirect($html->url()); + flash_message($lang->asb_edit_fail_bad_module, 'error'); + if($mybb->input['ajax'] != 1) + { + admin_redirect($html->url()); + } + die('asb'); } } else @@ -312,20 +327,25 @@ function asb_admin_edit_box() $sidebox->set('display_order', $display_order); $script_list = $mybb->input['script_select_box']; - $group_list = $mybb->input['group_select_box']; + if($script_list[0] == 'all_scripts' || (count($script_list) >= count($all_scripts))) + { + $script_list = array(); + } + $sidebox->set('scripts', $script_list); + $group_list = $mybb->input['group_select_box']; if($group_list[0] == 'all') { $group_list = array(); } - if($script_list[0] == 'all_scripts' || (count($script_list) >= count($all_scripts))) + $sidebox->set('groups', $group_list); + + $theme_list = $mybb->input['theme_select_box']; + if($theme_list[0] == 'all_themes') { - $script_list = array(); + $theme_list = array(); } - - // store them - $sidebox->set('scripts', $script_list); - $sidebox->set('groups', $group_list); + $sidebox->set('themes', $theme_list); // box type $sidebox->set('box_type', $module); @@ -347,10 +367,10 @@ function asb_admin_edit_box() if(isset($mybb->input[$setting['name']])) { // store it - $setting['value'] = $mybb->input[$setting['name']]; - $settings[$setting['name']] = $setting; + $settings[$setting['name']] = $mybb->input[$setting['name']]; } } + $settings = $parent->do_settings_save($settings); $sidebox->set('settings', $settings); } } @@ -381,6 +401,8 @@ function asb_admin_edit_box() } } + $sidebox->set('title_link', trim($mybb->input['title_link'])); + // save the side box $new_id = $sidebox->save(); asb_cache_has_changed(); @@ -389,7 +411,7 @@ function asb_admin_edit_box() if($mybb->input['ajax'] != 1) { // if in the standard form handle it with a redirect - flash_message($lang->asb_save_success, "success"); + flash_message($lang->asb_save_success, 'success'); admin_redirect('index.php?module=config-asb'); } @@ -413,13 +435,13 @@ function asb_admin_edit_box() * create the new

representation of the side box * (title only it will be filled in later by the updater) */ - $build_script = "Sidebox.createDiv({$id}, '{$box_title}', '{$column_id}'); "; + $build_script = "ASB.sidebox.createDiv({$id}, '{$box_title}', '{$column_id}'); "; } // update the side box after we're done via AJAX $script = << -{$build_script}Sidebox.updateDiv({$id}); +{$build_script}ASB.sidebox.updateDiv({$id}); EOF; @@ -430,7 +452,9 @@ function asb_admin_edit_box() if($id == 0) { - // if it doesn't then this is a new box, check the page view filter to try to predict which script the user will want + $page_title = $lang->asb_add_a_sidebox; + + // this is a new box, check the page view filter to try to predict which script the user will want if($mybb->input['page']) { // start them out with the script they are viewing for Which Scripts @@ -483,7 +507,7 @@ function asb_admin_edit_box()
EOF; - $form = new Form("", "post", "modal_form"); + $form = new Form('', 'post', 'modal_form'); } else { @@ -494,17 +518,19 @@ function asb_admin_edit_box() // add a little CSS $page->extra_header .= << - + + EOF; $page->output_header("{$lang->asb} - {$page_title}"); - $form = new Form($html->url(array("action" => 'edit_box', "id" => $id, "addon" => $module)), "post", "modal_form"); + $form = new Form($html->url(array("action" => 'edit_box', "id" => $id, "addon" => $module)), 'post', 'modal_form'); } $tabs = array( "general" => $lang->asb_modal_tab_general, "permissions" => $lang->asb_modal_tab_permissions, "pages" => $lang->asb_modal_tab_pages, + "themes" => $lang->asb_modal_tab_themes, "settings" => $lang->asb_modal_tab_settings ); @@ -512,7 +538,7 @@ function asb_admin_edit_box() $do_settings = true; if(!$sidebox->has_settings && !$parent->has_settings) { - unset($tabs["settings"]); + unset($tabs['settings']); $do_settings = false; } reset($tabs); @@ -528,12 +554,12 @@ function asb_admin_edit_box() if($custom_title == 1) { // alter the descrption - $current_title = '
' . $lang->asb_current_title . '

' . $sidebox->get('title') . '
' . $lang->asb_current_title_info; + $current_title = '' . $lang->asb_current_title . '

' . $sidebox->get('title') . '
' . $lang->asb_current_title_info; } else { // default description - $current_title = '
' . $lang->asb_default_title_info; + $current_title = $lang->asb_default_title_info; } // current editing text @@ -553,6 +579,9 @@ function asb_admin_edit_box() // box title $form_container->output_row($lang->asb_custom_title, $current_title, $form->generate_text_box('box_title') . $form->generate_hidden_field('current_title', $sidebox->get('title')), 'box_title', array("id" => 'box_title')); + // title link + $form_container->output_row($lang->asb_title_link, $lang->asb_title_link_desc, $form->generate_text_box('title_link', $sidebox->get('title_link')), 'title_link', array("id" => 'title_link')); + // position $form_container->output_row($lang->asb_position, '', $form->generate_radio_button('box_position', 0, $lang->asb_position_left, array("checked" => ($sidebox->get('position') == 0))) . '  ' . $form->generate_radio_button('box_position', 1, $lang->asb_position_right, array("checked" => ($sidebox->get('position') != 0)))); @@ -562,11 +591,14 @@ function asb_admin_edit_box() else { // box title - $form_container->output_row('', '', $form->generate_text_box('box_title') . '
' . $current_title . $form->generate_hidden_field('current_title', $sidebox->get('title')) . $form->generate_hidden_field('display_order', $sidebox->get('display_order')) . $form->generate_hidden_field('pos', $position), 'box_title', array("id" => 'box_title')); + $form_container->output_row($lang->asb_title, $current_title, $form->generate_text_box('box_title'), 'box_title', array("id" => 'box_title')); + + // title link + $form_container->output_row($lang->asb_title_link, $lang->asb_title_link_desc, $form->generate_text_box('title_link', $sidebox->get('title_link')) . $form->generate_hidden_field('current_title', $sidebox->get('title')) . $form->generate_hidden_field('display_order', $sidebox->get('display_order')) . $form->generate_hidden_field('pos', $position), 'title_link', array("id" => 'title_link')); } $form_container->end(); - echo "\n
\n
\n"; + echo "\n
\n
\n"; $form_container = new FormContainer($lang->asb_which_groups); // prepare options for which groups @@ -576,7 +608,7 @@ function asb_admin_edit_box() $options[0] = $lang->asb_guests; // look for all groups except Super Admins - $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'gid')); + $query = $db->simple_select('usergroups', 'gid, title', "gid != '1'", array('order_by' => 'gid')); while($usergroup = $db->fetch_array($query)) { // store them their titles by groud id @@ -596,12 +628,12 @@ function asb_admin_edit_box() $form_container->end(); - echo "\n
\n
\n"; + echo "\n
\n
\n"; $form_container = new FormContainer($lang->asb_which_scripts); // prepare for which scripts $choices = array(); - $choices["all_scripts"] = $lang->asb_all; + $choices['all_scripts'] = $lang->asb_all; // are there active scripts? if(is_array($all_scripts)) @@ -633,6 +665,22 @@ function asb_admin_edit_box() $form_container->output_row('', $script_warning, $form->generate_select_box('script_select_box[]', $choices, $selected_scripts, array("id" => 'script_select_box', "multiple" => true))); $form_container->end(); + echo "\n
\n
\n"; + $form_container = new FormContainer($lang->asb_which_themes); + + // do we have themes stored? + $themes = $sidebox->get('themes'); + if(empty($themes)) + { + $themes = 'all_themes'; + } + + $choices = array("all_themes" => 'All Themes') + asb_get_all_themes(); + + // which scripts + $form_container->output_row('', '', $form->generate_select_box('theme_select_box[]', $choices, $themes, array("id" => 'theme_select_box', "multiple" => true))); + $form_container->end(); + if($do_settings) { echo "
\n
\n"; @@ -643,24 +691,29 @@ function asb_admin_edit_box() $form_container = new FormContainer($lang->asb_modal_tab_settings_desc); + $settings = $parent->get('settings'); + if($id) { $sidebox_settings = $sidebox->get('settings'); - } - elseif($is_module) - { - $sidebox_settings = $parent->get('settings'); + foreach($settings as $name => $value) + { + if(isset($sidebox_settings[$name])) + { + $settings[$name]['value'] = $sidebox_settings[$name]; + } + } } - if(is_array($sidebox_settings)) + foreach((array) $settings as $setting) { - foreach($sidebox_settings as $setting) - { - // allow the handler to build module settings - asb_build_setting($form, $form_container, $setting); - } + // allow the handler to build module settings + asb_build_setting($form, $form_container, $setting); } + $form_container->end(); + + $parent->do_settings_load(); echo "
\n"; } @@ -698,7 +751,7 @@ function asb_admin_edit_box() */ function asb_admin_custom_boxes() { - global $lang, $mybb, $db, $page, $html; + global $lang, $mybb, $db, $page, $html, $min; if($mybb->input['mode'] == 'export') { @@ -724,7 +777,7 @@ function asb_admin_custom_boxes() // info good? if((int) $mybb->input['id'] == 0) { - flash_message($lang->asb_add_custom_box_delete_failure, "error"); + flash_message($lang->asb_add_custom_box_delete_failure, 'error'); admin_redirect($html->url(array("action" => 'custom_boxes'))); } @@ -734,18 +787,18 @@ function asb_admin_custom_boxes() // success? if(!$this_custom->remove()) { - flash_message($lang->asb_add_custom_box_delete_failure, "error"); + flash_message($lang->asb_add_custom_box_delete_failure, 'error'); admin_redirect($html->url(array("action" => 'custom_boxes'))); } // :) - flash_message($lang->asb_add_custom_box_delete_success, "success"); + flash_message($lang->asb_add_custom_box_delete_success, 'success'); asb_cache_has_changed(); admin_redirect($html->url(array("action" => 'custom_boxes'))); } // POSTing? - if($mybb->request_method == "post") + if($mybb->request_method == 'post') { if($mybb->input['mode'] == 'import') { @@ -828,7 +881,7 @@ function asb_admin_custom_boxes() { if(!$mybb->input['box_name'] || !$mybb->input['box_content']) { - flash_message($lang->asb_custom_box_save_failure_no_content, "error"); + flash_message($lang->asb_custom_box_save_failure_no_content, 'error'); admin_redirect($html->url(array("action" => 'custom_boxes'))); } $this_custom = new Custom_type((int) $mybb->input['id']); @@ -842,11 +895,11 @@ function asb_admin_custom_boxes() // success? if(!$this_custom->save()) { - flash_message($lang->asb_custom_box_save_failure, "error"); + flash_message($lang->asb_custom_box_save_failure, 'error'); admin_redirect($html->url(array("action" => 'custom_boxes', "id" => $this_custom->get('id')))); } - flash_message($lang->asb_custom_box_save_success, "success"); + flash_message($lang->asb_custom_box_save_success, 'success'); asb_cache_has_changed(); admin_redirect($html->url(array("action" => 'custom_boxes', "id" => $this_custom->get('id')))); } @@ -869,7 +922,7 @@ function asb_admin_custom_boxes() - ' + EOF; } @@ -878,7 +931,7 @@ function asb_admin_custom_boxes() $action = $lang->asb_add_custom; if($this_box->get('id')) { - $specify_box = "&id=" . $this_box->get('id'); + $specify_box = '&id=' . $this_box->get('id'); $currently_editing = $lang->asb_editing . ': ' . $this_box->get('title') . ''; $action = $lang->asb_edit . ' ' . $this_box->get('title'); } @@ -903,15 +956,15 @@ function asb_admin_custom_boxes() $page->extra_header .= << - + EOF; $page->add_breadcrumb_item($lang->asb_custom_boxes, $html->url(array("action" => 'custom_boxes'))); $page->add_breadcrumb_item($lang->asb_add_custom); - $page->output_header("{$lang->asb_name} - {$action}"); + $page->output_header("{$lang->asb} - {$action}"); asb_output_tabs('asb_add_custom'); - $form = new Form($html->url(array("action" => 'custom_boxes')) . $specify_box, "post", "edit_box"); + $form = new Form($html->url(array("action" => 'custom_boxes')) . $specify_box, 'post', 'edit_box'); $form_container = new FormContainer($currently_editing); $form_container->output_cell($lang->asb_name); @@ -966,11 +1019,11 @@ function asb_admin_custom_boxes() $page->extra_header .= << - + EOF; $page->add_breadcrumb_item($lang->asb_custom_boxes); - $page->output_header("{$lang->asb_name} - {$lang->asb_custom_boxes}"); + $page->output_header("{$lang->asb} - {$lang->asb_custom_boxes}"); asb_output_tabs('asb_custom'); $new_box_url = $html->url(array("action" => 'custom_boxes', "mode" => 'edit')); @@ -1058,7 +1111,7 @@ function asb_admin_custom_boxes() */ function asb_admin_manage_scripts() { - global $mybb, $db, $page, $lang, $html; + global $mybb, $db, $page, $lang, $html, $min; require_once MYBB_ROOT . 'inc/plugins/asb/classes/script_info.php'; @@ -1199,6 +1252,7 @@ function asb_admin_manage_scripts() $filename = $data['filename']; $action = "{$lang->asb_edit} {$data['title']}"; } + $lang->asb_edit_script = $action; $queryadmin = $db->simple_select('adminoptions', '*', "uid='{$mybb->user['uid']}'"); $admin_options = $db->fetch_array($queryadmin); @@ -1218,30 +1272,30 @@ function asb_admin_manage_scripts() $page->extra_header .= << - + - + EOF; $page->add_breadcrumb_item($lang->asb_manage_scripts, $html->url(array("action" => 'manage_scripts'))); $page->add_breadcrumb_item($lang->asb_edit_script); - $page->output_header("{$lang->asb} - {$lang->asb_manage_scripts} - {$action}"); + $page->output_header("{$lang->asb} - {$lang->asb_manage_scripts} - {$lang->asb_edit_script}"); asb_output_tabs('asb_edit_script'); $spinner = <<
EOF; $form = new Form($html->url(array("action" => 'manage_scripts', "mode" => 'edit')), 'post', 'edit_script'); - $form_container = new FormContainer("{$button_text} {$data['title']}"); + $form_container = new FormContainer($lang->asb_edit_script); $form_container->output_row("{$lang->asb_title}:", $lang->asb_title_desc, $form->generate_text_box('title', $data['title'])); @@ -1310,12 +1364,12 @@ function asb_admin_manage_scripts() { $page->extra_header .= << - + EOF; $page->add_breadcrumb_item($lang->asb_manage_scripts); - $page->output_header("{$lang->asb_name} - {$lang->asb_manage_scripts}"); + $page->output_header("{$lang->asb} - {$lang->asb_manage_scripts}"); asb_output_tabs('asb_scripts'); $new_script_url = $html->url(array("action" => 'manage_scripts', "mode" => 'edit')); @@ -1400,11 +1454,11 @@ function asb_admin_manage_scripts() */ function asb_admin_manage_modules() { - global $lang, $mybb, $db, $page, $html; + global $lang, $mybb, $db, $page, $html, $min; $page->extra_header .= << - + EOF; @@ -1415,9 +1469,10 @@ function asb_admin_manage_modules() asb_output_tabs('asb_modules'); $table = new Table; - $table->construct_header($lang->asb_name); - $table->construct_header($lang->asb_description); - $table->construct_header($lang->asb_controls); + $table->construct_header($lang->asb_name, array("width" => '22%')); + $table->construct_header($lang->asb_description, array("width" => '55%')); + $table->construct_header($lang->asb_modules_author, array("width" => '15%')); + $table->construct_header($lang->asb_controls, array("width" => '8%')); $addons = asb_get_all_modules(); @@ -1426,13 +1481,35 @@ function asb_admin_manage_modules() { foreach($addons as $this_module) { - $data = $this_module->get(array('title', 'description', 'base_name')); + $data = $this_module->get(array('title', 'description', 'base_name', 'author', 'author_site', 'module_site', 'version', 'compatibility')); + + $out_of_date = ''; + if(!$data['compatibility'] || version_compare('2.1', $data['compatibility'], '<')) + { + $out_of_date = <<{$lang->asb_module_out_of_date} +EOF; + } // title - $table->construct_cell("{$data['title']}"); + $table->construct_cell($html->link($data['module_site'], $data['title'], array("style" => 'font-weight: bold;')) . " ({$data['version']})"); // description - $table->construct_cell($data['description']); + $table->construct_cell($data['description'] . $out_of_date); + + if($data['author'] == 'Wildcard') + { + $data['author'] = 'default'; + } + + $author = $data['author']; + if($data['author_site']) + { + $author = $html->link($data['author_site'], $data['author'], array("style" => 'font-weight: bold;')); + } + + // author + $table->construct_cell($author); // options pop-up $popup = new PopupMenu('module_' . $data['base_name'], $lang->asb_options); @@ -1563,7 +1640,7 @@ function asb_admin_xmlhttp() Event.stop(event); // create the modal edit box dialogue - new MyModal({ + new ASB.Modal({ type: 'ajax', url: this.readAttribute('href') + '&ajax=1' }); @@ -1596,18 +1673,18 @@ function asb_admin_delete_box() if((int) $mybb->input['id'] == 0) { - flash_message($lang->asb_delete_box_failure, "error"); + flash_message($lang->asb_delete_box_failure, 'error'); admin_redirect($html->url()); } $sidebox = new Sidebox($mybb->input['id']); if(!$sidebox->remove()) { - flash_message($lang->asb_delete_box_failure, "error"); + flash_message($lang->asb_delete_box_failure, 'error'); } else { - flash_message($lang->asb_delete_box_success, "success"); + flash_message($lang->asb_delete_box_success, 'success'); asb_cache_has_changed(); } admin_redirect($html->url()); @@ -1627,18 +1704,18 @@ function asb_admin_delete_addon() // info goof? if(!isset($mybb->input['addon']) || strlen(trim($mybb->input['addon'])) == 0) { - flash_message($lang->asb_delete_addon_failure, "error"); + flash_message($lang->asb_delete_addon_failure, 'error'); admin_redirect($html->url(array("action" => 'manage_modules'))); } $this_module = new Addon_type($mybb->input['addon']); if(!$this_module->remove()) { - flash_message($lang->asb_delete_addon_failure, "error"); + flash_message($lang->asb_delete_addon_failure, 'error'); } else { - flash_message($lang->asb_delete_addon_success, "success"); + flash_message($lang->asb_delete_addon_success, 'success'); asb_cache_has_changed(); } admin_redirect($html->url(array("action" => 'manage_modules'))); @@ -1657,7 +1734,7 @@ function asb_admin_update_theme_select() $gid = asb_get_settingsgroup(); if((int) $gid == 0) { - flash_message($lang->asb_theme_exclude_select_update_fail, "error"); + flash_message($lang->asb_theme_exclude_select_update_fail, 'error'); admin_redirect('index.php?module=config-settings'); } @@ -1673,7 +1750,7 @@ function asb_admin_update_theme_select() // is the setting created? if($db->num_rows($query) == 0) { - flash_message($lang->asb_theme_exclude_select_update_fail, "error"); + flash_message($lang->asb_theme_exclude_select_update_fail, 'error'); admin_redirect('index.php?module=config-settings'); } @@ -1684,11 +1761,11 @@ function asb_admin_update_theme_select() // success? if(!$status) { - flash_message($lang->asb_theme_exclude_select_update_fail, "error"); + flash_message($lang->asb_theme_exclude_select_update_fail, 'error'); } else { - flash_message($lang->asb_theme_exclude_select_update_success, "success"); + flash_message($lang->asb_theme_exclude_select_update_success, 'success'); } admin_redirect(asb_build_settings_url($gid)); } @@ -1700,7 +1777,7 @@ function asb_admin_update_theme_select() * * @return: n/a */ -$plugins->add_hook("admin_config_settings_change", "asb_admin_config_settings_change"); +$plugins->add_hook('admin_config_settings_change', 'asb_admin_config_settings_change'); function asb_admin_config_settings_change() { global $mybb; @@ -1748,15 +1825,13 @@ function asb_admin_config_menu(&$sub_menu) $lang->load('asb'); } - $asb_menuitem = array( - 'id' => 'asb', - 'title' => $lang->asb, - 'link' => ASB_URL - ); - end($sub_menu); $key = (key($sub_menu)) + 10; - $sub_menu[$key] = $asb_menuitem; + $sub_menu[$key] = array( + 'id' => 'asb', + 'title' => $lang->asb, + 'link' => ASB_URL + ); } /* diff --git a/Upload/inc/plugins/asb/classes/acp.php b/Upload/inc/plugins/asb/classes/acp.php index 3ed2d58..d17136c 100644 --- a/Upload/inc/plugins/asb/classes/acp.php +++ b/Upload/inc/plugins/asb/classes/acp.php @@ -10,31 +10,31 @@ // check dependencies if(!class_exists('MalleableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/malleable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/malleable.php'; } if(!class_exists('StorableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/storable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/storable.php'; } if(!class_exists('PortableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/portable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/portable.php'; } if(!class_exists('Sidebox')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/sidebox.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/sidebox.php'; } if(!class_exists('Custom_type')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/custom.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/custom.php'; } if(!class_exists('Addon_type')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/module.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/module.php'; } if(!class_exists('HTMLGenerator')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/html_generator.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/html_generator.php'; } ?> diff --git a/Upload/inc/plugins/asb/classes/forum.php b/Upload/inc/plugins/asb/classes/forum.php index 262f074..5dfc0cc 100644 --- a/Upload/inc/plugins/asb/classes/forum.php +++ b/Upload/inc/plugins/asb/classes/forum.php @@ -9,27 +9,27 @@ if(!class_exists('MalleableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/malleable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/malleable.php'; } if(!class_exists('StorableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/storable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/storable.php'; } if(!class_exists('PortableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/portable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/portable.php'; } if(!class_exists('Sidebox')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/sidebox.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/sidebox.php'; } if(!class_exists('Custom_type')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/custom.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/custom.php'; } if(!class_exists('Addon_type')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/module.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/module.php'; } ?> diff --git a/Upload/inc/plugins/asb/classes/installer.php b/Upload/inc/plugins/asb/classes/installer.php index 40e978f..d011aa7 100644 --- a/Upload/inc/plugins/asb/classes/installer.php +++ b/Upload/inc/plugins/asb/classes/installer.php @@ -212,17 +212,17 @@ public function remove_tables() * @param - $column_list - (array) an associative array of tables and columns * @return: n/a */ - public function add_columns() + public function add_columns($columns = '') { - if(!is_array($this->columns) || empty($this->columns)) + if(!is_array($columns) || empty($columns)) { - return false; + $columns = $this->columns; } - foreach($this->columns as $table => $columns) + foreach($columns as $table => $all_columns) { $sep = $added_columns = ''; - foreach($columns as $title => $definition) + foreach($all_columns as $title => $definition) { if(!$this->field_exists($table, $title)) { @@ -501,7 +501,7 @@ private function build_table_list() $query = $this->db->write_query(" SHOW TABLES - FROM {$config['database']['database']} + FROM `{$config['database']['database']}` "); $table_list = array(); diff --git a/Upload/inc/plugins/asb/classes/module.php b/Upload/inc/plugins/asb/classes/module.php index 35fa4bd..db05178 100644 --- a/Upload/inc/plugins/asb/classes/module.php +++ b/Upload/inc/plugins/asb/classes/module.php @@ -9,7 +9,7 @@ if(!class_exists('MalleableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/malleable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/malleable.php'; } /* @@ -120,16 +120,19 @@ public function run($function_name, $args = '') class Addon_type extends ExternalModule { protected $author = 'Wildcard'; - protected $author_site = 'http://wildcardsearch.github.com/Advanced-Sidebox'; + protected $author_site = ''; + protected $module_site = 'https://github.com/WildcardSearch/Advanced-Sidebox'; protected $settings = array(); public $has_settings = false; + protected $scripts = array(); + public $has_scripts = false; protected $templates = array(); public $xmlhttp = false; protected $is_installed = false; protected $is_upgraded = false; protected $old_version = 0; - protected $version = 0; - protected $discarded_settings = array(); + protected $version = '0'; + protected $compatibility = '0'; protected $discarded_templates = array(); protected $wrap_content = false; protected $prefix = 'asb'; @@ -145,25 +148,32 @@ class Addon_type extends ExternalModule public function load($module) { // input is necessary - if(parent::load($module)) + if(!parent::load($module)) { - $this->has_settings = !empty($this->settings); - $this->old_version = $this->get_cache_version(); + return false; + } - // if this module needs to be upgraded . . . - if(version_compare($this->old_version, $this->version, '<') && !defined('IN_ASB_UNINSTALL')) - { - // get-r-done - $this->upgrade(); - } - else - { - // otherwise mark upgrade status - $this->is_upgraded = $this->is_installed = true; - } - return true; + if(!$this->compatibility || version_compare('2.1', $this->compatibility, '<')) + { + return false; } - return false; + + $this->has_settings = !empty($this->settings); + $this->has_scripts = !empty($this->scripts); + $this->old_version = $this->get_cache_version(); + + // if this module needs to be upgraded . . . + if(version_compare($this->old_version, $this->version, '<') && !defined('IN_ASB_UNINSTALL')) + { + // get-r-done + $this->upgrade(); + } + else + { + // otherwise mark upgrade status + $this->is_upgraded = $this->is_installed = true; + } + return true; } /* @@ -199,7 +209,7 @@ public function install($cleanup = true) // if it exists, update if($db->num_rows($query) > 0) { - $db->update_query("templates", $template, "title='{$template['title']}' AND sid IN('-2', '-1')"); + $db->update_query('templates', $template, "title='{$template['title']}' AND sid IN('-2', '-1')"); } else { @@ -210,7 +220,7 @@ public function install($cleanup = true) if(!empty($insert_array)) { - $db->insert_query_multiple("templates", $insert_array); + $db->insert_query_multiple('templates', $insert_array); } } @@ -227,14 +237,6 @@ public function install($cleanup = true) */ public function uninstall($cleanup = true) { - global $db; - - // installed? - if(!$this->is_installed) - { - return; - } - $this->unset_cache_version(); // unless specifically asked not to, delete any boxes that use this module @@ -259,6 +261,7 @@ public function uninstall($cleanup = true) if($delete_list) { + global $db; $db->delete_query('templates', "title IN({$delete_list})"); } } @@ -288,7 +291,7 @@ protected function upgrade() $delete_list = $sep = ''; foreach($this->discarded_templates as $template) { - $delete_list .= "{$sep}'{$template['title']}'"; + $delete_list .= "{$sep}'{$template}'"; $sep = ','; } @@ -395,20 +398,13 @@ protected function update_children() } } - // update all the settings + // update any settings which are missing foreach($this->settings as $name => $setting) { if(!isset($sidebox_settings[$name])) { // new setting-- default value - $sidebox_settings[$name] = $this->settings[$name]; - } - else - { - // existing setting-- preserve value - $value = $sidebox_settings[$name]['value']; - $sidebox_settings[$name] = $setting; - $sidebox_settings[$name]['value'] = $value; + $sidebox_settings[$name] = $this->settings[$name]['value']; } } @@ -485,9 +481,9 @@ protected function unset_cache_version() * @return: (mixed) the return value of the called module function or * (bool) false on error */ - public function build_template($settings, $template_var, $width) + public function build_template($settings, $template_var, $width, $script) { - foreach(array('settings', 'template_var', 'width') as $key) + foreach(array('settings', 'template_var', 'width', 'script') as $key) { $args[$key] = $$key; } @@ -495,7 +491,7 @@ public function build_template($settings, $template_var, $width) } /* - * function do_xmlhttp() + * do_xmlhttp() * * @param - $dateline (int) UNIX timestamp representing the last time * the side box was updated @@ -513,6 +509,34 @@ public function do_xmlhttp($dateline, $settings, $width) } return $this->run('xmlhttp', $args); } + + /* + * do_settings_load() + * + * @return: (mixed) the return value of the called module function or + * (bool) false on error + */ + public function do_settings_load() + { + return $this->run('settings_load', $settings); + } + + /* + * do_settings_save() + * + * @param - $settings (array) the individual side box settings + * @return: (mixed) the return value of the called module function or + * (bool) false on error + */ + public function do_settings_save($settings) + { + $retval = $this->run('settings_save', $settings); + if($retval) + { + return $retval; + } + return $settings; + } } ?> diff --git a/Upload/inc/plugins/asb/classes/script_info.php b/Upload/inc/plugins/asb/classes/script_info.php index 2cd67db..73347a4 100644 --- a/Upload/inc/plugins/asb/classes/script_info.php +++ b/Upload/inc/plugins/asb/classes/script_info.php @@ -10,15 +10,15 @@ // check dependencies if(!class_exists('MalleableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/malleable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/malleable.php'; } if(!class_exists('StorableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/storable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/storable.php'; } if(!class_exists('PortableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/portable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/portable.php'; } class ScriptInfo extends PortableObject diff --git a/Upload/inc/plugins/asb/classes/sidebox.php b/Upload/inc/plugins/asb/classes/sidebox.php index 9319031..8d002ce 100644 --- a/Upload/inc/plugins/asb/classes/sidebox.php +++ b/Upload/inc/plugins/asb/classes/sidebox.php @@ -10,6 +10,7 @@ class Sidebox extends StorableObject { protected $title; + protected $title_link; protected $box_type; protected $position = 0; protected $display_order; @@ -18,6 +19,7 @@ class Sidebox extends StorableObject protected $scripts = array(); protected $groups = array(); + protected $themes = array(); protected $settings = array(); public $has_settings = false; @@ -53,29 +55,16 @@ public function load($data) { if($data && parent::load($data)) { - // are there settings? - if($this->settings) + foreach(array('settings', 'groups', 'scripts', 'themes') as $property) { - // if so decode them - $this->settings = json_decode($this->settings, true); - - // if they seem legit - $this->has_settings = (is_array($this->settings) && !empty($this->settings)); - } - - // are there settings? - if($this->groups) - { - // if so decode them - $this->groups = json_decode($this->groups, true); + if($this->$property) + { + // if so decode them + $this->$property = json_decode($this->$property, true); + } } - // are there settings? - if($this->scripts) - { - // if so decode them - $this->scripts = json_decode($this->scripts, true); - } + $this->has_settings = (is_array($this->settings) && !empty($this->settings)); return true; } return false; diff --git a/Upload/inc/plugins/asb/classes/storable.php b/Upload/inc/plugins/asb/classes/storable.php index 2ee431e..a403645 100644 --- a/Upload/inc/plugins/asb/classes/storable.php +++ b/Upload/inc/plugins/asb/classes/storable.php @@ -126,24 +126,24 @@ public function save() switch(gettype($this->$property)) { - case "boolean": + case 'boolean': $this->data[$property] = (bool) $value; break; - case "integer": + case 'integer': $this->data[$property] = (int) $value; break; - case "NULL": + case 'NULL': $this->data[$property] = NULL; break; - case "double": + case 'double': $this->data[$property] = (float) $value; break; - case "string": + case 'string': $this->data[$property] = $db->escape_string($value); break; - case "array": - case "object": - case "resource": + case 'array': + case 'object': + case 'resource': $this->data[$property] = $db->escape_string(json_encode($value)); break; default: diff --git a/Upload/inc/plugins/asb/classes/template_handler.php b/Upload/inc/plugins/asb/classes/template_handler.php index 410a39b..89eb077 100644 --- a/Upload/inc/plugins/asb/classes/template_handler.php +++ b/Upload/inc/plugins/asb/classes/template_handler.php @@ -7,76 +7,32 @@ * this file contains class definitions for the template handling and editing system */ -class TemplateHandler +class ASBTemplateHandler { - // the template to edit (if any) - protected $template_name = ''; - - // any extra JS needed - protected $extra_scripts = ''; - - // true to eval() columns in lieu of editing templates - protected $eval = false; - - // used when in eval() mode to produce content for custom scripts - protected $template_vars; - - // used to complete replace the edited script - protected $replace_all = false; - - // the contents to replace if replace_all is true - protected $replacement = ''; - - // the search keys - protected $find_top = ''; - protected $find_bottom = ''; - - // the columns - protected $insert_top = ''; - protected $insert_bottom = ''; - - // the side boxes - protected $left_content; - protected $right_content; - - // dimensions - protected $width_left; - protected $width_right; - - /* - * __construct() - * - * called upon creation to store content in an appropriate format IF it exists - * - * @param - $left_insert - (string) the left column of side box content for this page - * @param - $right_insert - (string) ^ right tho :p - * @param - $width_left - (int) is the width (specified in ACP for each script) for left columns - * @param - $width_right - (int) is blah blah blah but right instead - * @param - $extra_scripts - (string) - any extra JS needed by modules used on this script - * @param - $template_vars - (array) - a non-indexed array of template variables - * to globalize (used when outputting to custom pages) - * @return: n/a - */ - public function __construct($left_insert, $right_insert, $width_left, $width_right, $extra_scripts = '', $template_vars = array()) + static public function edit($boxes, $width, $script) { - global $mybb, $lang, $templates; + global $mybb, $lang, $templates, $headerinclude; - if(!$lang->asb) + if($mybb->settings['asb_minify_js']) { - $lang->load('asb'); + $min = '.min'; } - // store width upon construct (mostly here for custom implementations like portal) - $this->width_left = $width_left; - $this->width_right = $width_right; - $this->extra_scripts = $extra_scripts; - $this->template_vars = $template_vars; - + $left_insert = $boxes[0]; + $right_insert = $boxes[1]; + $width_left = $width[0]; + $width_right = $width[1]; $toggles = $show = array(); + $filename = THIS_SCRIPT; // if admin wants to show the toggle icons . . . if($mybb->settings['asb_show_toggle_icons']) { + // we will need this js + $headerinclude .= << +EOF; + $toggle_info['left'] = array( "close" => array( "img" => 'inc/plugins/asb/images/left_arrow.png', @@ -140,8 +96,8 @@ public function __construct($left_insert, $right_insert, $width_left, $width_rig $toggle_name = "toggle_{$key}"; $$toggle_name = $toggles[$key]; - // finally set $this->POSITION_content for ::make_edits() - $this->$prop_name = <<{$toggle_left} {$content} @@ -149,70 +105,14 @@ public function __construct($left_insert, $right_insert, $width_left, $width_rig EOF; } } - } - - /* - * make_edits() - * - * handles the rudimentary tasks of editing a template for side boxes - * - * @return: n/a - */ - public function make_edits() - { - global $templates, $mybb, $headerinclude; - - // load the cache and attempt to store this script's info - $asb = asb_get_cache(); - $this_script = asb_get_this_script($asb); + eval("\$insert_top = \"" . $templates->get('asb_begin') . "\";"); + eval("\$insert_bottom = \"" . $templates->get('asb_end') . "\";"); - // do we have a valid script? - if(is_array($this_script) && !empty($this_script)) - { - foreach($this_script as $key => $val) - { - if(property_exists($this, $key) && isset($val) && $val) - { - $this->$key = $val; - } - } - } - else - { - // if not get out - return; - } - - // if there is no info, go with the default values - $this->find_top = trim($this->find_top); - if(!$this->find_top) - { - $this->find_top = '{$header}'; - } - $this->find_bottom = trim($this->find_bottom); - if(!$this->find_bottom) - { - $this->find_bottom = '{$footer}'; - } - $filename = THIS_SCRIPT; - - $left_content = $this->left_content; - eval("\$this->insert_top = \"" . $templates->get('asb_begin') . "\";"); - - $right_content = $this->right_content; - eval("\$this->insert_bottom = \"" . $templates->get('asb_end') . "\";"); - - if($mybb->settings['asb_show_toggle_icons']) - { - // we will need this js - $headerinclude .= ''; - } - - if(is_array($this->extra_scripts) && !empty($this->extra_scripts)) + if(is_array($script['extra_scripts']) && !empty($script['extra_scripts'])) { $sep = ''; $dateline = TIME_NOW; - foreach($this->extra_scripts as $addon => $info) + foreach($script['extra_scripts'] as $addon => $info) { // build the JS objects to pass to the custom object builder $extra_scripts .= << + EOF; } + if(is_array($script['js'])) { + foreach($script['js'] as $script_name) { + if(file_exists(MYBB_ROOT . "jscripts/asb/{$script_name}{$min}.js")) + { + $script_name .= $min; + } + $headerinclude .= << +EOF; + } + } + // replace everything on the page? - if($this->replace_all == true) + if($script['replace_all'] == true) { // if there is content - if($this->replacement) + if($script['replacement']) { // replace the existing page entirely - $templates->cache[$this->template_name] = str_replace(array('{$asb_left}', '{$asb_right}'), array($this->insert_top, $this->insert_bottom), $this->replacement); + $templates->cache[$script['template_name']] = str_replace(array('{$asb_left}', '{$asb_right}'), array($insert_top, $insert_bottom), $script['replacement']); } } // outputting to variables? (custom script/Page Manager) - elseif($this->eval) + elseif($script['eval']) { // globalize our columns global $asb_left, $asb_right; // globalize all the add-on template variables - if(is_array($this->template_vars) && !empty($this->template_vars)) + if(is_array($script['template_vars']) && !empty($script['template_vars'])) { - foreach($this->template_vars as $var) + foreach($script['template_vars'] as $var) { global $$var; } } // now eval() their content for the custom script - eval("\$asb_left = \"" . str_replace("\\'", "'", addslashes($this->insert_top)) . "\";"); - eval("\$asb_right = \"" . str_replace("\\'", "'", addslashes($this->insert_bottom)) . "\";"); + eval("\$asb_left = \"" . str_replace("\\'", "'", addslashes($insert_top)) . "\";"); + eval("\$asb_right = \"" . str_replace("\\'", "'", addslashes($insert_bottom)) . "\";"); } // otherwise we are editing the template in the cache else { // if there are columns stored - if($this->insert_top || $this->insert_bottom) + if($insert_top || $insert_bottom) { // make the edits - $find_top_pos = strpos($templates->cache[$this->template_name], $this->find_top); + $find_top_pos = strpos($templates->cache[$script['template_name']], $script['find_top']); if($find_top_pos !== false) { - $find_bottom_pos = strpos($templates->cache[$this->template_name], $this->find_bottom); + $find_bottom_pos = strpos($templates->cache[$script['template_name']], $script['find_bottom']); if($find_bottom_pos !== false) { @@ -283,12 +198,12 @@ public function make_edits() * FIRST instance of the search text (find_top and find_bottom) rather * than replacing multiple found instances */ - $templates->cache[$this->template_name] = - substr($templates->cache[$this->template_name], 0, $find_top_pos + strlen($this->find_top)) . - $this->insert_top . - substr($templates->cache[$this->template_name], $find_top_pos + strlen($this->find_top), $find_bottom_pos - ($find_top_pos + strlen($this->find_top))) . - $this->insert_bottom . - substr($templates->cache[$this->template_name], $find_bottom_pos); + $templates->cache[$script['template_name']] = + substr($templates->cache[$script['template_name']], 0, $find_top_pos + strlen($script['find_top'])) . + $insert_top . + substr($templates->cache[$script['template_name']], $find_top_pos + strlen($script['find_top']), $find_bottom_pos - ($find_top_pos + strlen($script['find_top']))) . + $insert_bottom . + substr($templates->cache[$script['template_name']], $find_bottom_pos); } } } diff --git a/Upload/inc/plugins/asb/classes/xmlhttp.php b/Upload/inc/plugins/asb/classes/xmlhttp.php index 98e510f..e161973 100644 --- a/Upload/inc/plugins/asb/classes/xmlhttp.php +++ b/Upload/inc/plugins/asb/classes/xmlhttp.php @@ -9,23 +9,23 @@ if(!class_exists('MalleableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/malleable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/malleable.php'; } if(!class_exists('StorableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/storable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/storable.php'; } if(!class_exists('PortableObject')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/portable.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/portable.php'; } if(!class_exists('Sidebox')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/sidebox.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/sidebox.php'; } if(!class_exists('Addon_type')) { - require_once MYBB_ROOT . "inc/plugins/asb/classes/module.php"; + require_once MYBB_ROOT . 'inc/plugins/asb/classes/module.php'; } ?> diff --git a/Upload/inc/plugins/asb/forum.php b/Upload/inc/plugins/asb/forum.php index 113c2ee..147ff97 100644 --- a/Upload/inc/plugins/asb/forum.php +++ b/Upload/inc/plugins/asb/forum.php @@ -20,7 +20,7 @@ */ function asb_start() { - global $mybb; + global $mybb, $theme; // side box, add-on and custom box classes require_once MYBB_ROOT . 'inc/plugins/asb/classes/forum.php'; @@ -88,6 +88,13 @@ function asb_start() continue; } + // is this theme available for this side box? + $good_themes = $sidebox->get('themes'); + if($good_themes && !in_array($theme['tid'], $good_themes)) + { + continue; + } + $result = false; // get the template variable @@ -100,17 +107,9 @@ function asb_start() // add-on module, so we can proceed if($module->is_valid()) { - // if this side box doesn't have any settings, but the add-on module it was derived from does . . . - $settings = $sidebox->get('settings'); - if($sidebox->has_settings == false && $module->has_settings) - { - // . . . this side box hasn't been upgraded to the new on-board settings system. Use the settings (and values) from the add-on module as default settings - $settings = $module->get('settings'); - } - // build the template. pass settings, template variable // name and column width - $result = $module->build_template($settings, $template_var, $width[$pos]); + $result = $module->build_template($sidebox->get('settings'), $template_var, $width[$pos], get_current_location()); } // if it doesn't verify as an add-on, try it as a custom box elseif(isset($asb['custom'][$module_name]) && is_array($asb['custom'][$module_name])) @@ -124,6 +123,10 @@ function asb_start() $result = $custom->build_template($template_var); } } + else + { + continue; + } /* * all box types return true or false based upon whether they have @@ -141,13 +144,9 @@ function asb_start() } } - // load the template handler class definitions + // load the template handler class definition and make the edits require_once MYBB_ROOT . 'inc/plugins/asb/classes/template_handler.php'; - - $template_handler = new TemplateHandler($boxes[0], $boxes[1], $width[0], $width[1], $this_script['extra_scripts'], $this_script['template_vars']); - - // edit the templates (or eval() if any scripts require it) - $template_handler->make_edits(); + ASBTemplateHandler::edit($boxes, $width, $this_script); } /* @@ -166,12 +165,12 @@ function asb_initialize() case 'usercp.php': if($mybb->settings['asb_allow_user_disable']) { - $plugins->add_hook("usercp_options_end", "asb_usercp_options_end"); - $plugins->add_hook("usercp_do_options_end", "asb_usercp_options_end"); + $plugins->add_hook('usercp_options_end', 'asb_usercp_options_end'); + $plugins->add_hook('usercp_do_options_end', 'asb_usercp_options_end'); } break; case 'xmlhttp.php': - $plugins->add_hook("xmlhttp", "asb_xmlhttp"); + $plugins->add_hook('xmlhttp', 'asb_xmlhttp'); break; } @@ -217,9 +216,9 @@ function asb_usercp_options_end() } // if the form is being submitted save the users choice. - if($mybb->request_method == "post") + if($mybb->request_method == 'post') { - $db->update_query("users", array("show_sidebox" => (int) $mybb->input['showsidebox']), "uid='{$user['uid']}'"); + $db->update_query('users', array("show_sidebox" => (int) $mybb->input['showsidebox']), "uid='{$user['uid']}'"); } // don't be silly and waste a query :p (thanks Destroy666) @@ -277,7 +276,7 @@ function asb_xmlhttp() if($module->is_valid() && $sidebox->is_valid()) { // then call the module's AJAX method and echo its return value - echo($module->do_xmlhttp($mybb->input['dateline'], $sidebox->get('settings'), $mybb->input['width'])); + echo($module->do_xmlhttp($mybb->input['dateline'], $sidebox->get('settings'), $mybb->input['width'], $mybb->input['script'])); } exit; } diff --git a/Upload/inc/plugins/asb/functions.php b/Upload/inc/plugins/asb/functions.php index ad42ae5..2cf9028 100644 --- a/Upload/inc/plugins/asb/functions.php +++ b/Upload/inc/plugins/asb/functions.php @@ -19,16 +19,16 @@ function asb_do_checks() global $mybb, $theme; // if the EXCLUDE list isn't empty and this theme is listed . . . - $exclude_list = unserialize($mybb->settings['asb_exclude_theme']); - if(is_array($exclude_list) && in_array($theme['tid'], $exclude_list)) + $exclude_list = asb_get_excluded_themes(); + if($exclude_list && in_array($theme['tid'], $exclude_list)) { // no side boxes for you return false; } /* - * if the current user is not a guest and has disabled the side - * box display in UCP then do not display the side boxes + * if the current user is not a guest, admin has allowed disabling side box + * display and the user has chosen to do so then do not display */ if($mybb->settings['asb_allow_user_disable'] && $mybb->user['uid'] != 0 && $mybb->user['show_sidebox'] == 0) { @@ -37,6 +37,37 @@ function asb_do_checks() return true; } +/* + * asb_get_excluded_themes() + * + * get the tids of any excluded themes + * + * @return: (array) the list of excluded themes (bool) false on fail + */ +function asb_get_excluded_themes($sql = false) +{ + global $mybb; + + $retval = unserialize($mybb->settings['asb_exclude_theme']); + if(!is_array($retval) || empty($retval)) + { + $retval = false; + } + + if($sql) + { + if($retval) + { + $retval = ' AND pid NOT IN(' . implode(',', $retval) . ')'; + } + else + { + $retval = ''; + } + } + return $retval; +} + /* * asb_get_cache() * @@ -49,7 +80,7 @@ function asb_get_cache() global $cache; static $asb; - // if we've already retrieved it (we will do it thrice per script) + // if we've already retrieved it (we will do it twice per script) // then just return the static copy, otherwise retrieve it if(!isset($asb) || empty($asb)) { @@ -162,12 +193,19 @@ function asb_build_cache(&$asb) $settings = $sidebox->get('settings'); // again, default here is off if anything goes wrong - if($settings['xmlhttp_on']['value']) + if($settings['xmlhttp_on']) { // if all is good add the script building info $asb['scripts'][$filename]['extra_scripts'][$module]['position'] = $pos; $asb['scripts'][$filename]['extra_scripts'][$module]['id'] = $id; - $asb['scripts'][$filename]['extra_scripts'][$module]['rate'] = $settings['xmlhttp_on']['value']; + $asb['scripts'][$filename]['extra_scripts'][$module]['rate'] = $settings['xmlhttp_on']; + } + } + + if($addons[$module]->has_scripts) + { + foreach($addons[$module]->get('scripts') as $script) { + $asb['scripts'][$filename]['js'][$script] = $script; } } } @@ -275,6 +313,7 @@ function asb_get_this_script($asb, $get_all = false) // merge any globally visible (script-wise) side boxes with this script $return_array['template_vars'] = array_merge((array) $asb['scripts']['global']['template_vars'], (array) $return_array['template_vars']); $return_array['extra_scripts'] = (array) $asb['scripts']['global']['extra_scripts'] + (array) $return_array['extra_scripts']; + $return_array['js'] = (array) $asb['scripts']['global']['js'] + (array) $return_array['js']; // the template handler does not need side boxes and templates if(!$get_all) @@ -410,7 +449,7 @@ function asb_build_sidebox_content($this_box) } // build our info - foreach(array('id', 'box_type', 'wrap_content', 'title') as $key) + foreach(array('id', 'box_type', 'wrap_content', 'title', 'title_link') as $key) { if(isset($data[$key])) { @@ -431,24 +470,30 @@ function asb_build_sidebox_content($this_box) $sidebox['expdisplay_id'] = "{$box_type}_{$id}_e"; $sidebox['name'] = "{$id}_{$box_type}_" . TIME_NOW; $sidebox['class'] = $sidebox['id'] = "{$box_type}_main_{$id}"; - $sidebox['title'] = $title; $sidebox['content'] = $content; + $sidebox['title'] = $title; + if($title_link) + { + $sidebox['title'] = <<{$title} +EOF; + } if($mybb->settings['asb_show_expanders']) { // check if this side box is either expanded or collapsed and hide it as necessary. $expdisplay = ''; $collapsed_name = "{$box_type}_{$id}_c"; - if(isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == "display: show;") + if(isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == 'display: show;') { - $expcolimage = "collapse_collapsed.gif"; - $expdisplay = "display: none;"; - $expaltext = "[+]"; + $expcolimage = 'collapse_collapsed.gif'; + $expdisplay = 'display: none;'; + $expaltext = '[+]'; } else { - $expcolimage = "collapse.gif"; - $expaltext = "[-]"; + $expcolimage = 'collapse.gif'; + $expaltext = '[-]'; } eval("\$expander = \"" . $templates->get('asb_expander') . "\";"); } @@ -597,4 +642,36 @@ function asb_get_all_scripts() return $return_array; } +/* + * asb_get_all_themes() + * + * rebuilds the theme exclude list ACP setting + * + * @return: (string) the + EOF; } - else + + // Create an option for each theme and insert code to unserialize each option and 'remember' settings + foreach($all_themes as $tid => $name) { - $theme_select = <<{$name} +EOF; + } + + // put it all together + return << - + EOF; - } - return $theme_select; } /* versioning */ diff --git a/Upload/inc/plugins/asb/help/index.php b/Upload/inc/plugins/asb/help/index.php index 1dfdf75..6c87098 100644 --- a/Upload/inc/plugins/asb/help/index.php +++ b/Upload/inc/plugins/asb/help/index.php @@ -10,7 +10,7 @@ global $page_title, $links_array; // CSS - $header_include = << EOF; @@ -18,7 +18,7 @@ $links_array = array( "main" => 'Main Page', "install" => 'Install & Upgrade', - "manage_sideboxes" => 'Sideboxes', + "manage_sideboxes" => 'Sideboxes', "edit_box" => 'Add and Edit Sideboxes', "custom" => 'Custom Boxes', "edit_custom" => 'Edit Custom Boxes', diff --git a/Upload/inc/plugins/asb/install.php b/Upload/inc/plugins/asb/install.php index c71687a..3e42d5e 100644 --- a/Upload/inc/plugins/asb/install.php +++ b/Upload/inc/plugins/asb/install.php @@ -8,9 +8,9 @@ */ // disallow direct access to this file for security reasons -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -29,7 +29,7 @@ function asb_info() $lang->load('asb'); } - $extra_links = "
"; + $extra_links = '
'; $settings_link = asb_build_settings_link(); if($settings_link) { @@ -97,12 +97,12 @@ function asb_info() return array( "name" => $name, "description" => $asb_description, - "website" => "https://github.com/WildcardSearch/Advanced-Sidebox", + "website" => 'https://github.com/WildcardSearch/Advanced-Sidebox', "author" => $author, - "authorsite" => "http://www.rantcentralforums.com", - "version" => "2.0.7", - "compatibility" => "16*", - "guid" => "870e9163e2ae9b606a789d9f7d4d2462", + "authorsite" => 'http://www.rantcentralforums.com', + "version" => '2.1', + "compatibility" => '16*', + "guid" => '870e9163e2ae9b606a789d9f7d4d2462', ); } @@ -196,6 +196,52 @@ function asb_activate() { @unlink(MYBB_ROOT . 'inc/languages/english/admin/asb_addon.lang.php'); } + + /* + * upgrade existing side boxes settings and removed old js files + */ + if(version_compare($old_version, '2.1', '<')) + { + require_once MYBB_ROOT . 'inc/plugins/asb/classes/forum.php'; + $sideboxes = asb_get_all_sideboxes(); + foreach($sideboxes as $sidebox) + { + $settings = array(); + foreach((array) $sidebox->get('settings') as $name => $setting) + { + $settings[$name] = $setting['value']; + } + $sidebox->set('settings', $settings); + $sidebox->save(); + } + + for($x = 1; $x < 4; $x++) + { + $module_name = 'example'; + if($x != 1) + { + $module_name .= $x; + } + + $module = new Addon_type($module_name); + $module->remove(); + } + + asb_cache_has_changed(); + + $removed_files = array( + 'jscripts/asb.js', + 'jscripts/asb_xmlhttp.js', + 'admin/jscripts/asb.js', + 'admin/jscripts/asb_modal.js', + 'admin/jscripts/asb_scripts.js', + 'admin/jscripts/asb_sideboxes.js' + ); + foreach($removed_files as $file) + { + @unlink(MYBB_ROOT . $file); + } + } } asb_set_cache_version(); @@ -287,7 +333,7 @@ function asb_get_settingsgroup() global $db; // otherwise we will have to query the db - $query = $db->simple_select("settinggroups", "gid", "name='asb_settings'"); + $query = $db->simple_select('settinggroups', 'gid', "name='asb_settings'"); $gid = (int) $db->fetch_field($query, 'gid'); } return $gid; @@ -305,7 +351,7 @@ function asb_build_settings_url($gid) { if($gid) { - return "index.php?module=config-settings&action=change&gid=" . $gid; + return 'index.php?module=config-settings&action=change&gid=' . $gid; } } diff --git a/Upload/inc/plugins/asb/install_data.php b/Upload/inc/plugins/asb/install_data.php index 3c5633e..f926f37 100644 --- a/Upload/inc/plugins/asb/install_data.php +++ b/Upload/inc/plugins/asb/install_data.php @@ -13,9 +13,11 @@ "display_order" => 'INT(10) NOT NULL', "box_type" => 'VARCHAR(25) NOT NULL', "title" => 'VARCHAR(32) NOT NULL', + "title_link" => 'VARCHAR(128) NOT NULL', "position" => 'INT(2)', "scripts" => 'TEXT', "groups" => 'TEXT', + "themes" => 'TEXT', "settings" => 'TEXT', "wrap_content" => 'INT(1)', "dateline" => 'INT(10)' @@ -60,57 +62,66 @@ $settings = array( "asb_settings" => array( "group" => array( - "name" => "asb_settings", - "title" => "Advanced Sidebox", + "name" => 'asb_settings', + "title" => 'Advanced Sidebox', "description" => $lang->asb_settingsgroup_description, - "disporder" => "101", + "disporder" => '101', "isdefault" => 0 ), "settings" => array( "asb_show_empty_boxes" => array( - "sid" => "NULL", - "name" => "asb_show_empty_boxes", - "title" => $lang->asb_show_empty_boxes . ":", + "sid" => 'NULL', + "name" => 'asb_show_empty_boxes', + "title" => $lang->asb_show_empty_boxes . ':', "description" => $db->escape_string($lang->asb_show_empty_boxes_desc), - "optionscode" => "yesno", + "optionscode" => 'yesno', "value" => '1', "disporder" => '10' ), "asb_show_toggle_icons" => array( - "sid" => "NULL", - "name" => "asb_show_toggle_icons", + "sid" => 'NULL', + "name" => 'asb_show_toggle_icons', "title" => $lang->asb_show_toggle_icons, "description" => '', - "optionscode" => "yesno", + "optionscode" => 'yesno', "value" => '0', "disporder" => '20' ), "asb_show_expanders" => array( - "sid" => "NULL", - "name" => "asb_show_expanders", + "sid" => 'NULL', + "name" => 'asb_show_expanders', "title" => $lang->asb_show_expanders, "description" => '', - "optionscode" => "yesno", + "optionscode" => 'yesno', "value" => '1', "disporder" => '30' ), "asb_allow_user_disable" => array( - "sid" => "NULL", - "name" => "asb_allow_user_disable", + "sid" => 'NULL', + "name" => 'asb_allow_user_disable', "title" => $lang->asb_allow_user_disable, "description" => '', - "optionscode" => "yesno", + "optionscode" => 'yesno', "value" => '1', "disporder" => '40' ), + "asb_minify_js" => array( + "sid" => 'NULL', + "name" => 'asb_minify_js', + "title" => $lang->asb_minify_js_title, + "description" => $lang->asb_minify_js_desc, + "optionscode" => 'yesno', + "value" => '1', + "disporder" => '50' + ), "asb_exclude_theme" => array( - "sid" => "NULL", - "name" => "asb_exclude_theme", - "title" => $lang->asb_theme_exclude_list . ":", + "sid" => 'NULL', + "name" => 'asb_exclude_theme', + "title" => $lang->asb_theme_exclude_list . ':', "description" => $db->escape_string($lang->asb_theme_exclude_list_description . $update_themes_link), "optionscode" => $db->escape_string(asb_build_theme_exclude_select()), "value" => '', - "disporder" => '50' + "disporder" => '60' ) ) ) diff --git a/Upload/inc/plugins/asb/modules/example.php b/Upload/inc/plugins/asb/modules/example.php deleted file mode 100644 index c2e2265..0000000 --- a/Upload/inc/plugins/asb/modules/example.php +++ /dev/null @@ -1,70 +0,0 @@ -
Please make sure IN_MYBB is defined."); -} - -/* - * asb_example_info() - * - * provide info to ASB about the addon - * - * @return: (array) the module info - */ -function asb_example_info() -{ - global $lang; - - if(!$lang->asb_addon) - { - $lang->load('asb_addon'); - } - - return array ( - "title" => $lang->asb_example1_title, - "description" => $lang->asb_example1_desc, - "wrap_content" => true, - "version" => "1" - ); -} - -/* - * asb_example_build_template() - * - * handles display of children of this addon at page load - * - * @param - $args - (array) the specific information from the child box - * @return: (bool) true on success, false on fail/no content - */ -function asb_example_build_template($args) -{ - extract($args); - - /* - * using variable variables (thanks Euan T.) we declare the template variable as global here and eval() its contents. - */ - global $$template_var; //<-- this is necessary - - /* - * note the structure, this content should appropriate (and validate) as the contents of an HTML element in structure and content. - */ - $$template_var = << - Same from either side. - -EOF; - - // return true if your box has something to show, or false if it doesn't. - return true; -} - -?> diff --git a/Upload/inc/plugins/asb/modules/example2.php b/Upload/inc/plugins/asb/modules/example2.php deleted file mode 100644 index df3115b..0000000 --- a/Upload/inc/plugins/asb/modules/example2.php +++ /dev/null @@ -1,80 +0,0 @@ -
Please make sure IN_MYBB is defined."); -} - -/* - * asb_example2_info() - * - * provide info to ASB about the addon - * - * @return: (array) the module info - */ -function asb_example2_info() -{ - global $lang; - - if(!$lang->asb_addon) - { - $lang->load('asb_addon'); - } - - return array( - "title" => $lang->asb_example2_title, - "description" => $lang->asb_example2_desc, - "wrap_content" => true, - "version" => "1.1", - "templates" => array( - array( - "title" => "asb_example", - "template" => << - Image sized to side box column: - - - - logo - - -EOF - ) - ) - ); -} - -/* - * asb_example2_build_template() - * - * handles display of children of this addon at page load - * - * @param - $args - (array) the specific information from the child box - * @return: (bool) true on success, false on fail/no content - */ -function asb_example2_build_template($args) -{ - extract($args); - - global $$template_var, $templates; - - // you can use the side box width to size HTML elements: - $inner_width = (int) ($width * .79); - $margin = (int) (($width - $inner_width) / 2); - - // then eval() the template variable with the template above and you are done - eval("\$" . $template_var . " = \"" . $templates->get("asb_example") . "\";"); - - // return true if your box has something to show, or false if it doesn't. - return true; -} - -?> diff --git a/Upload/inc/plugins/asb/modules/example3.php b/Upload/inc/plugins/asb/modules/example3.php deleted file mode 100644 index 8f9ba31..0000000 --- a/Upload/inc/plugins/asb/modules/example3.php +++ /dev/null @@ -1,85 +0,0 @@ -
Please make sure IN_MYBB is defined."); -} - -/* - * asb_example3_info() - * - * provide info to ASB about the addon - * - * @return: (array) the module info - */ -function asb_example3_info() -{ - global $lang; - - if(!$lang->asb_addon) - { - $lang->load('asb_addon'); - } - - return array( - "title" => $lang->asb_example3_title, - "description" => $lang->asb_example3_desc, - "wrap_content" => true, - "version" => "1", - "settings" => array( - "example3_setting" => array( - "sid" => "NULL", - "name" => "example3_setting", - "title" => $lang->asb_example3_setting_anouncement_text, - "description" => $lang->asb_example3_setting_anouncement_text_desc, - "optionscode" => "text", - "value" => '' - ) - ) - ); -} - -/* - * asb_example3_build_template() - * - * handles display of children of this addon at page load - * - * @param - $args - (array) the specific information from the child box - * @return: (bool) true on success, false on fail/no content - */ -function asb_example3_build_template($args) -{ - extract($args); - - global $$template_var, $lang; - - if(!$lang->asb_addon) - { - $lang->load('asb_addon'); - } - - if(!$settings['example3_setting']['value']) - { - $settings['example3_setting']['value'] = $lang->asb_example3_info; - } - - $$template_var = << - {$settings['example3_setting']['value']} - - -EOF; - - // return true if your box has something to show, or false if it doesn't. - return true; -} - -?> diff --git a/Upload/inc/plugins/asb/modules/latest_threads.php b/Upload/inc/plugins/asb/modules/latest_threads.php index 32a8ab2..df84113 100644 --- a/Upload/inc/plugins/asb/modules/latest_threads.php +++ b/Upload/inc/plugins/asb/modules/latest_threads.php @@ -8,9 +8,9 @@ */ // Include a check for Advanced Sidebox -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -32,78 +32,95 @@ function asb_latest_threads_info() return array( "title" => $lang->asb_latest_threads, "description" => $lang->asb_latest_threads_desc, - "version" => "1.1", + "version" => '1.1.1', + "compatibility" => '2.1', "wrap_content" => true, "xmlhttp" => true, "settings" => array( "max_threads" => array( - "sid" => "NULL", - "name" => "max_threads", + "sid" => 'NULL', + "name" => 'max_threads', "title" => $lang->asb_max_threads_title, "description" => $lang->asb_max_threads_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '20' ), "forum_show_list" => array( - "sid" => "NULL", - "name" => "forum_show_list", + "sid" => 'NULL', + "name" => 'forum_show_list', "title" => $lang->asb_forum_show_list_title, "description" => $lang->asb_forum_show_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "forum_hide_list" => array( - "sid" => "NULL", - "name" => "forum_hide_list", + "sid" => 'NULL', + "name" => 'forum_hide_list', "title" => $lang->asb_forum_hide_list_title, "description" => $lang->asb_forum_hide_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "thread_show_list" => array( - "sid" => "NULL", - "name" => "thread_show_list", + "sid" => 'NULL', + "name" => 'thread_show_list', "title" => $lang->asb_thread_show_list_title, "description" => $lang->asb_thread_show_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "thread_hide_list" => array( - "sid" => "NULL", - "name" => "thread_hide_list", + "sid" => 'NULL', + "name" => 'thread_hide_list', "title" => $lang->asb_thread_hide_list_title, "description" => $lang->asb_thread_hide_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "last_poster_avatar" => array( - "sid" => "NULL", - "name" => "last_poster_avatar", + "sid" => 'NULL', + "name" => 'last_poster_avatar', "title" => $lang->asb_last_poster_avatar_title, "description" => $lang->asb_last_poster_avatar_desc, - "optionscode" => "yesno", + "optionscode" => 'yesno', "value" => '0' ), "avatar_width" => array( - "sid" => "NULL", - "name" => "avatar_width", + "sid" => 'NULL', + "name" => 'avatar_width', "title" => $lang->asb_avatar_width_title, "description" => $lang->asb_avatar_width_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '30' ), + "new_threads_only" => array( + "sid" => 'NULL', + "name" => 'new_threads_only', + "title" => $lang->asb_new_threads_only_title, + "description" => $lang->asb_new_threads_only_desc, + "optionscode" => 'text', + "value" => '0' + ), + "important_threads_only" => array( + "sid" => 'NULL', + "name" => 'important_threads_only', + "title" => $lang->asb_important_threads_only_title, + "description" => $lang->asb_important_threads_only_desc, + "optionscode" => 'yesno', + "value" => '0' + ), "xmlhttp_on" => array( - "sid" => "NULL", - "name" => "xmlhttp_on", + "sid" => 'NULL', + "name" => 'xmlhttp_on', "title" => $lang->asb_xmlhttp_on_title, "description" => $lang->asb_xmlhttp_on_description, - "optionscode" => "text", + "optionscode" => 'text', "value" => '0' ) ), "templates" => array( array( - "title" => "asb_latest_threads_thread", + "title" => 'asb_latest_threads_thread', "template" => << @@ -229,8 +246,7 @@ function latest_threads_get_threadlist($settings, $width) $query = $db->query(" SELECT fid - FROM " . - TABLE_PREFIX . "forums + FROM {$db->table_prefix}forums WHERE active != 0 ORDER BY @@ -243,10 +259,8 @@ function latest_threads_get_threadlist($settings, $width) $query = $db->query(" SELECT f.fid, fr.dateline AS lastread - FROM " . - TABLE_PREFIX . "forums f - LEFT JOIN " . - TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}') + FROM {$db->table_prefix}forums f + LEFT JOIN {$db->table_prefix}forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}') WHERE f.active != 0 ORDER BY @@ -267,7 +281,7 @@ function latest_threads_get_threadlist($settings, $width) } // Build a post parser - require_once MYBB_ROOT."inc/class_parser.php"; + require_once MYBB_ROOT . 'inc/class_parser.php'; $parser = new postParser; // get forums user cannot view @@ -277,14 +291,34 @@ function latest_threads_get_threadlist($settings, $width) $unviewwhere = " AND t.fid NOT IN ({$unviewable})"; } + // get inactive forums + $inactive = get_inactive_forums(); + if($inactive) + { + $inactivewhere = " AND t.fid NOT IN ({$inactive})"; + } + + // new threads only? + if((int) $settings['new_threads_only'] > 0) + { + // use admin's time limit + $thread_time_limit = TIME_NOW - 60 * 60 * 24 * (int) $settings['new_threads_only']; + $new_threads = " AND t.dateline > {$thread_time_limit}"; + } + + if($settings['important_threads_only']) + { + $important_threads = ' AND NOT t.sticky=0'; + } + // build the exclude conditions - $show['fids'] = asb_build_id_list($settings['forum_show_list']['value'], 't.fid'); - $show['tids'] = asb_build_id_list($settings['thread_show_list']['value'], 't.tid'); - $hide['fids'] = asb_build_id_list($settings['forum_hide_list']['value'], 't.fid'); - $hide['tids'] = asb_build_id_list($settings['thread_hide_list']['value'], 't.tid'); + $show['fids'] = asb_build_id_list($settings['forum_show_list'], 't.fid'); + $show['tids'] = asb_build_id_list($settings['thread_show_list'], 't.tid'); + $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 't.fid'); + $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 't.tid'); $where['show'] = asb_build_SQL_where($show, ' OR '); $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT '); - $query_where = $unviewwhere . asb_build_SQL_where($where, ' AND ', ' AND '); + $query_where = $new_threads . $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND '); $altbg = alt_trow(); $maxtitlelen = 48; @@ -295,16 +329,14 @@ function latest_threads_get_threadlist($settings, $width) SELECT t.*, u.username, u.avatar, u.usergroup, u.displaygroup - FROM " . - TABLE_PREFIX . "threads t - LEFT JOIN " . - TABLE_PREFIX . "users u ON (u.uid=t.lastposteruid) + FROM {$db->table_prefix}threads t + LEFT JOIN {$db->table_prefix}users u ON (u.uid=t.lastposteruid) WHERE t.visible='1' AND t.closed NOT LIKE 'moved|%'{$query_where} ORDER BY t.lastpost DESC LIMIT - 0, " . (int) $settings['max_threads']['value'] + 0, " . (int) $settings['max_threads'] ); if($db->num_rows($query) == 0) @@ -322,10 +354,10 @@ function latest_threads_get_threadlist($settings, $width) $thread_ids = implode(",", array_keys($thread_cache)); - // Fetch the read threads. + // fetch the read threads. if($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0) { - $query = $db->simple_select("threadsread", "tid,dateline", "uid='".$mybb->user['uid']."' AND tid IN(" . $thread_ids . ")"); + $query = $db->simple_select('threadsread', 'tid,dateline', "uid='{$mybb->user['uid']}' AND tid IN({$thread_ids})"); while($readthread = $db->fetch_array($query)) { $thread_cache[$readthread['tid']]['lastread'] = $readthread['dateline']; @@ -352,14 +384,14 @@ function latest_threads_get_threadlist($settings, $width) } else { - if($settings['last_poster_avatar']['value']) + if($settings['last_poster_avatar']) { if(strlen(trim($thread['avatar'])) == 0) { $thread['avatar'] = "{$theme['imgdir']}/default_avatar.gif"; } - $avatar_width = (int) min($width / 2, max($width / 8, $settings['avatar_width']['value'])); + $avatar_width = (int) min($width / 2, max($width / 8, $settings['avatar_width'])); $last_poster_name = << @@ -417,7 +449,7 @@ function latest_threads_get_threadlist($settings, $width) } else { - $last_read = my_get_array_cookie("threadread", $thread['tid']); + $last_read = my_get_array_cookie('threadread', $thread['tid']); } if($forum_read > $last_read) @@ -427,7 +459,7 @@ function latest_threads_get_threadlist($settings, $width) if($thread['lastpost'] > $last_read && $last_read) { - $thread['newpostlink'] = get_thread_link($thread['tid'], 0, "newpost"); + $thread['newpostlink'] = get_thread_link($thread['tid'], 0, 'newpost'); eval("\$gotounread = \"" . $templates->get("asb_latest_threads_gotounread") . "\";"); $unreadpost = 1; } diff --git a/Upload/inc/plugins/asb/modules/private_messages.php b/Upload/inc/plugins/asb/modules/private_messages.php index 024de6d..fa6b3b1 100644 --- a/Upload/inc/plugins/asb/modules/private_messages.php +++ b/Upload/inc/plugins/asb/modules/private_messages.php @@ -8,9 +8,9 @@ */ // Include a check for Advanced Sidebox -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -34,20 +34,21 @@ function asb_private_messages_info() "description" => $lang->asb_private_messages_desc, "wrap_content" => true, "xmlhttp" => true, - "version" => "1.1.1", + "version" => '1.1.1', + "compatibility" => '2.1', "settings" => array( "xmlhttp_on" => array( - "sid" => "NULL", - "name" => "xmlhttp_on", - "title" => $lang->asb_xmlhttp_on_title, - "description" => $lang->asb_xmlhttp_on_description, - "optionscode" => "text", - "value" => '0' + "sid" => 'NULL', + "name" => 'xmlhttp_on', + "title" => $lang->asb_xmlhttp_on_title, + "description" => $lang->asb_xmlhttp_on_description, + "optionscode" => 'text', + "value" => '0' ) ), "templates" => array( array( - "title" => "asb_pms", + "title" => 'asb_pms', "template" => << diff --git a/Upload/inc/plugins/asb/modules/rand_quote.php b/Upload/inc/plugins/asb/modules/rand_quote.php index 95b4d8c..4c39b51 100644 --- a/Upload/inc/plugins/asb/modules/rand_quote.php +++ b/Upload/inc/plugins/asb/modules/rand_quote.php @@ -8,9 +8,9 @@ */ // Include a check for Advanced Sidebox -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -34,70 +34,79 @@ function asb_rand_quote_info() "description" => $lang->asb_random_quotes_desc, "wrap_content" => true, "xmlhttp" => true, - "version" => "1.5.1", + "version" => '1.5.1', + "compatibility" => '2.1', "settings" => array( "forum_show_list" => array( - "sid" => "NULL", - "name" => "forum_show_list", + "sid" => 'NULL', + "name" => 'forum_show_list', "title" => $lang->asb_forum_show_list_title, "description" => $lang->asb_forum_show_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "forum_hide_list" => array( - "sid" => "NULL", - "name" => "forum_hide_list", + "sid" => 'NULL', + "name" => 'forum_hide_list', "title" => $lang->asb_forum_hide_list_title, "description" => $lang->asb_forum_hide_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "thread_show_list" => array( - "sid" => "NULL", - "name" => "thread_show_list", + "sid" => 'NULL', + "name" => 'thread_show_list', "title" => $lang->asb_thread_show_list_title, "description" => $lang->asb_thread_show_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "thread_hide_list" => array( - "sid" => "NULL", - "name" => "thread_hide_list", + "sid" => 'NULL', + "name" => 'thread_hide_list', "title" => $lang->asb_thread_hide_list_title, "description" => $lang->asb_thread_hide_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "min_length" => array( - "sid" => "NULL", - "name" => "min_length", + "sid" => 'NULL', + "name" => 'min_length', "title" => $lang->asb_random_quotes_min_quote_length_title, "description" => $lang->asb_random_quotes_min_quote_length_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '20' ), "max_length" => array( - "sid" => "NULL", - "name" => "max_length", + "sid" => 'NULL', + "name" => 'max_length', "title" => $lang->asb_random_quotes_max_quote_length_title, "description" => $lang->asb_random_quotes_max_quote_length, - "optionscode" => "text", + "optionscode" => 'text', "value" => '160' ), "default_text" => array( - "sid" => "NULL", - "name" => "default_text", + "sid" => 'NULL', + "name" => 'default_text', "title" => $lang->asb_random_quotes_default_text_title, "description" => $lang->asb_random_quotes_default_text_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), + "important_threads_only" => array( + "sid" => 'NULL', + "name" => 'important_threads_only', + "title" => $lang->asb_important_threads_only_title, + "description" => $lang->asb_important_threads_only_desc, + "optionscode" => 'yesno', + "value" => '0' + ), "xmlhttp_on" => array( - "sid" => "NULL", - "name" => "xmlhttp_on", + "sid" => 'NULL', + "name" => 'xmlhttp_on', "title" => $lang->asb_xmlhttp_on_title, "description" => $lang->asb_xmlhttp_on_description, - "optionscode" => "text", + "optionscode" => 'text', "value" => '0' ) ), @@ -106,7 +115,7 @@ function asb_rand_quote_info() ), "templates" => array( array( - "title" => "asb_rand_quote_sidebox", + "title" => 'asb_rand_quote_sidebox', "template" => << @@ -226,23 +235,35 @@ function asb_rand_quote_get_quote($settings, $width) $unviewwhere = " AND p.fid NOT IN ({$unviewable})"; } + // get inactive forums + $inactive = get_inactive_forums(); + if($inactive) + { + $inactivewhere = " AND p.fid NOT IN ({$inactive})"; + } + + if($settings['important_threads_only']) + { + $important_threads = ' AND NOT t.sticky=0'; + } + // build the exclude conditions - $show['fids'] = asb_build_id_list($settings['forum_show_list']['value'], 'p.fid'); - $show['tids'] = asb_build_id_list($settings['thread_show_list']['value'], 'p.tid'); - $hide['fids'] = asb_build_id_list($settings['forum_hide_list']['value'], 'p.fid'); - $hide['tids'] = asb_build_id_list($settings['thread_hide_list']['value'], 'p.tid'); + $show['fids'] = asb_build_id_list($settings['forum_show_list'], 'p.fid'); + $show['tids'] = asb_build_id_list($settings['thread_show_list'], 'p.tid'); + $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 'p.fid'); + $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 'p.tid'); $where['show'] = asb_build_SQL_where($show, ' OR '); $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT '); - $query_where = $unviewwhere . asb_build_SQL_where($where, ' AND ', ' AND '); + $query_where = $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND '); $post_query = $db->query(" SELECT p.pid, p.message, p.fid, p.tid, p.subject, p.uid, - u.username, u.usergroup, u.displaygroup, u.avatar - FROM " . - TABLE_PREFIX . "posts p - LEFT JOIN " . - TABLE_PREFIX . "users u ON (u.uid=p.uid) + u.username, u.usergroup, u.displaygroup, u.avatar, + t.sticky + FROM {$db->table_prefix}posts p + LEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid) + LEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid) WHERE p.visible='1'{$query_where} ORDER BY @@ -259,7 +280,7 @@ function asb_rand_quote_get_quote($settings, $width) $rand_post = $db->fetch_array($post_query); // build a post parser - require_once MYBB_ROOT."inc/class_parser.php"; + require_once MYBB_ROOT . 'inc/class_parser.php'; $parser = new postParser; // we just need the text and smilies (we'll parse them after we check length) @@ -277,11 +298,11 @@ function asb_rand_quote_get_quote($settings, $width) $title_font_size = (int) ($font_size * .65); $message_font_size = (int) $font_size; - if(strlen($new_message) < $settings['min_length']['value']) + if(strlen($new_message) < $settings['min_length']) { - if($settings['default_text']['value']) + if($settings['default_text']) { - $new_message = $settings['default_text']['value']; + $new_message = $settings['default_text']; } else { @@ -290,9 +311,9 @@ function asb_rand_quote_get_quote($settings, $width) } } - if($settings['max_length']['value'] && strlen($new_message) > $settings['max_length']['value']) + if($settings['max_length'] && strlen($new_message) > $settings['max_length']) { - $new_message = substr($new_message, 0, $settings['max_length']['value']) . ' . . .'; + $new_message = substr($new_message, 0, $settings['max_length']) . ' . . .'; } // set up the user name link so that it displays correctly for the display group of the user @@ -308,7 +329,7 @@ function asb_rand_quote_get_quote($settings, $width) // if the user has an avatar then display it, otherwise force the default avatar. $avatar_filename = "{$theme['imgdir']}/default_avatar.gif"; - if($rand_post['avatar'] != "") + if($rand_post['avatar'] != '') { $avatar_filename = $rand_post['avatar']; } @@ -319,7 +340,7 @@ function asb_rand_quote_get_quote($settings, $width) if(my_strlen($rand_post['subject']) > 40) { - $rand_post['subject'] = my_substr($rand_post['subject'], 0, 40) . " . . ."; + $rand_post['subject'] = my_substr($rand_post['subject'], 0, 40) . ' . . .'; } if(substr(strtolower($rand_post['subject']), 0, 3) == 're:') diff --git a/Upload/inc/plugins/asb/modules/recent_posts.php b/Upload/inc/plugins/asb/modules/recent_posts.php index 5e2a78b..e7e1e2f 100644 --- a/Upload/inc/plugins/asb/modules/recent_posts.php +++ b/Upload/inc/plugins/asb/modules/recent_posts.php @@ -8,9 +8,9 @@ */ // Include a check for Advanced Sidebox -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -32,74 +32,83 @@ function asb_recent_posts_info() return array( "title" => $lang->asb_recent_posts, "description" => $lang->asb_recent_posts_desc, - "version" => "1.3.1", + "version" => '1.3.2', + "compatibility" => '2.1', "wrap_content" => true, "xmlhttp" => true, "settings" => array( "max_posts" => array( - "sid" => "NULL", - "name" => "max_posts", + "sid" => 'NULL', + "name" => 'max_posts', "title" => $lang->asb_recent_posts_max_title, "description" => $lang->asb_recent_posts_max_description, - "optionscode" => "text", + "optionscode" => 'text', "value" => '5' ), "max_length" => array( - "sid" => "NULL", - "name" => "max_length", + "sid" => 'NULL', + "name" => 'max_length', "title" => $lang->asb_recent_posts_max_length_title, "description" => $lang->asb_recent_posts_max_length_description, - "optionscode" => "text", + "optionscode" => 'text', "value" => '20' ), "forum_show_list" => array( - "sid" => "NULL", - "name" => "forum_show_list", + "sid" => 'NULL', + "name" => 'forum_show_list', "title" => $lang->asb_forum_show_list_title, "description" => $lang->asb_forum_show_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "forum_hide_list" => array( - "sid" => "NULL", - "name" => "forum_hide_list", + "sid" => 'NULL', + "name" => 'forum_hide_list', "title" => $lang->asb_forum_hide_list_title, "description" => $lang->asb_forum_hide_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "thread_show_list" => array( - "sid" => "NULL", - "name" => "thread_show_list", + "sid" => 'NULL', + "name" => 'thread_show_list', "title" => $lang->asb_thread_show_list_title, "description" => $lang->asb_thread_show_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), "thread_hide_list" => array( - "sid" => "NULL", - "name" => "thread_hide_list", + "sid" => 'NULL', + "name" => 'thread_hide_list', "title" => $lang->asb_thread_hide_list_title, "description" => $lang->asb_thread_hide_list_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '' ), + "important_threads_only" => array( + "sid" => 'NULL', + "name" => 'important_threads_only', + "title" => $lang->asb_important_threads_only_title, + "description" => $lang->asb_important_threads_only_desc, + "optionscode" => 'yesno', + "value" => '0' + ), "xmlhttp_on" => array( - "sid" => "NULL", - "name" => "xmlhttp_on", + "sid" => 'NULL', + "name" => 'xmlhttp_on', "title" => $lang->asb_xmlhttp_on_title, "description" => $lang->asb_xmlhttp_on_description, - "optionscode" => "text", + "optionscode" => 'text', "value" => '0' ) ), "templates" => array( array( - "title" => "asb_recent_posts_post", + "title" => 'asb_recent_posts_post', "template" => << - {\$post[\'subject\']} + {\$post[\'subject\']} @@ -201,17 +210,29 @@ function recent_posts_get_postlist($settings) $unviewable = get_unviewable_forums(true); if($unviewable) { - $unviewwhere = " AND p.fid NOT IN ($unviewable)"; + $unviewwhere = " AND p.fid NOT IN ({$unviewable})"; + } + + // get inactive forums + $inactive = get_inactive_forums(); + if($inactive) + { + $inactivewhere = " AND p.fid NOT IN ({$inactive})"; + } + + if($settings['important_threads_only']) + { + $important_threads = ' AND NOT t.sticky=0'; } // build the exclude conditions - $show['fids'] = asb_build_id_list($settings['forum_show_list']['value'], 'p.fid'); - $show['tids'] = asb_build_id_list($settings['thread_show_list']['value'], 'p.tid'); - $hide['fids'] = asb_build_id_list($settings['forum_hide_list']['value'], 'p.fid'); - $hide['tids'] = asb_build_id_list($settings['thread_hide_list']['value'], 'p.tid'); + $show['fids'] = asb_build_id_list($settings['forum_show_list'], 'p.fid'); + $show['tids'] = asb_build_id_list($settings['thread_show_list'], 'p.tid'); + $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 'p.fid'); + $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 'p.tid'); $where['show'] = asb_build_SQL_where($show, ' OR '); $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT '); - $query_where = $unviewwhere . asb_build_SQL_where($where, ' AND ', ' AND '); + $query_where = $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND '); $altbg = alt_trow(); $maxtitlelen = 48; @@ -219,19 +240,18 @@ function recent_posts_get_postlist($settings) // Query for the latest forum discussions $query = $db->query(" - SELECT - p.tid, p.pid, p.message, p.fid, p.dateline, p.subject, - u.username, u.uid, u.displaygroup, u.usergroup - FROM - " . TABLE_PREFIX . "posts p - LEFT JOIN - " . TABLE_PREFIX . "users u ON (u.uid=p.uid) + SELECT p.tid, p.pid, p.message, p.fid, p.dateline, p.subject, + u.username, u.uid, u.displaygroup, u.usergroup, + t.sticky + FROM {$db->table_prefix}posts p + LEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid) + LEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid) WHERE p.visible='1'{$query_where} ORDER BY p.dateline DESC LIMIT - 0, " . (int) $settings['max_posts']['value'] + 0, " . (int) $settings['max_posts'] ); if($db->num_rows($query) == 0) @@ -241,7 +261,7 @@ function recent_posts_get_postlist($settings) } // Build a post parser - require_once MYBB_ROOT."inc/class_parser.php"; + require_once MYBB_ROOT . 'inc/class_parser.php'; $parser = new postParser; $post_cache = array(); @@ -275,7 +295,7 @@ function recent_posts_get_postlist($settings) if(my_strlen($post['subject']) > $maxtitlelen) { - $post['subject'] = my_substr($post['subject'], 0, $maxtitlelen) . "..."; + $post['subject'] = my_substr($post['subject'], 0, $maxtitlelen) . '...'; } if(substr(strtolower($post['subject']), 0, 3) == 're:') @@ -286,58 +306,13 @@ function recent_posts_get_postlist($settings) $post['subject'] = htmlspecialchars_uni($parser->parse_badwords($post['subject'])); $post['link'] = get_thread_link($post['tid']) . "&pid={$post['pid']}#pid{$post['pid']}"; - $gotounread = ''; - $last_read = 0; - - if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid']) - { - $forum_read = $readforums[$post['fid']]; - - $read_cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24; - if($forum_read == 0 || $forum_read < $read_cutoff) - { - $forum_read = $read_cutoff; - } - } - else - { - $forum_read = $forumsread[$post['fid']]; - } - - if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $post['dateline'] > $forum_read) - { - if($post['lastread']) - { - $last_read = $post['lastread']; - } - else - { - $last_read = $read_cutoff; - } - } - else - { - $last_read = my_get_array_cookie("threadread", $post['tid']); - } - - if($forum_read > $last_read) - { - $last_read = $forum_read; - } - - if($post['dateline'] > $last_read && $last_read) - { - $post['subject'] = "{$post['subject']}"; - $unreadpost = 1; - } - // we just need the text and smilies (we'll parse them after we check length) $pattern = "|[[\/\!]*?[^\[\]]*?]|si"; $post_excerpt = strip_tags(str_replace('
', '', asb_strip_url(preg_replace($pattern, '$1', $post['message'])))); - if(strlen($post_excerpt) > $settings['max_length']['value']) + if(strlen($post_excerpt) > $settings['max_length']) { - $post_excerpt = substr($post_excerpt, 0, $settings['max_length']['value']) . ' . . .'; + $post_excerpt = substr($post_excerpt, 0, $settings['max_length']) . ' . . .'; } eval("\$postlist .= \"" . $templates->get("asb_recent_posts_post") . "\";"); diff --git a/Upload/inc/plugins/asb/modules/search_box.php b/Upload/inc/plugins/asb/modules/search_box.php index b2638cf..84a5bb5 100644 --- a/Upload/inc/plugins/asb/modules/search_box.php +++ b/Upload/inc/plugins/asb/modules/search_box.php @@ -8,9 +8,9 @@ */ // Include a check for Advanced Sidebox -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -34,9 +34,10 @@ function asb_search_box_info() "description" => $lang->asb_search_desc, "wrap_content" => true, "version" => "1.2.1", + "compatibility" => '2.1', "templates" => array( array( - "title" => "asb_search", + "title" => 'asb_search', "template" => << @@ -91,7 +92,7 @@ function asb_search_box_build_template($args) $lang->load('asb_addon'); } - eval("\$" . $template_var . " = \"" . $templates->get("asb_search") . "\";"); + eval("\$" . $template_var . " = \"" . $templates->get('asb_search') . "\";"); return true; } diff --git a/Upload/inc/plugins/asb/modules/slideshow.php b/Upload/inc/plugins/asb/modules/slideshow.php new file mode 100644 index 0000000..5329f26 --- /dev/null +++ b/Upload/inc/plugins/asb/modules/slideshow.php @@ -0,0 +1,174 @@ +
Please make sure IN_MYBB is defined.'); +} + +/* + * asb_slideshow_info() + * + * provide info to ASB about the addon + * + * @return: (array) the module info + */ +function asb_slideshow_info() +{ + global $lang; + + if(!$lang->asb_addon) + { + $lang->load('asb_addon'); + } + + return array( + "title" => $lang->asb_slideshow, + "description" => $lang->asb_slideshow_desc, + "wrap_content" => true, + "version" => '1', + "compatibility" => '2.1', + "scripts" => array( + 'Slideshow', + ), + "settings" => array( + "folder" => array( + "sid" => 'NULL', + "name" => 'folder', + "title" => $lang->asb_slideshow_folder_title, + "description" => $lang->asb_slideshow_folder_description, + "optionscode" => 'text', + "value" => 'images' + ), + "rate" => array( + "sid" => 'NULL', + "name" => 'rate', + "title" => $lang->asb_slideshow_rate_title, + "description" => $lang->asb_slideshow_rate_description, + "optionscode" => 'text', + "value" => '10' + ), + "shuffle" => array( + "sid" => 'NULL', + "name" => 'shuffle', + "title" => $lang->asb_slideshow_shuffle_title, + "description" => $lang->asb_slideshow_shuffle_description, + "optionscode" => 'yesno', + "value" => '1' + ), + "fade_rate" => array( + "sid" => 'NULL', + "name" => 'fade_rate', + "title" => $lang->asb_slideshow_fade_rate_title, + "description" => $lang->asb_slideshow_fade_rate_description, + "optionscode" => 'text', + "value" => '1' + ), + "footer_text" => array( + "sid" => 'NULL', + "name" => 'footer_text', + "title" => $lang->asb_slideshow_footer_text_title, + "description" => $lang->asb_slideshow_footer_text_description, + "optionscode" => 'text', + "value" => '' + ), + "footer_url" => array( + "sid" => 'NULL', + "name" => 'footer_url', + "title" => $lang->asb_slideshow_footer_url_title, + "description" => $lang->asb_slideshow_footer_url_description, + "optionscode" => 'text', + "value" => '' + ), + ), + ); +} + +/* + * asb_slideshow_build_template() + * + * handles display of children of this addon at page load + * + * @param - $args - (array) the specific information from the child box + * @return: (bool) true on success, false on fail/no content + */ +function asb_slideshow_build_template($args) +{ + extract($args); + + global $$template_var, $mybb; + + $shuffle = $settings['shuffle'] ? 'true' : 'false'; + $folder = $settings['folder']; + $rate = (int) $settings['rate'] ? (int) $settings['rate'] : 10; + $fade_rate = (float) $settings['fade_rate'] ? (float) $settings['fade_rate'] : 1; + + if(!is_dir(MYBB_ROOT . $folder)) + { + return false; + } + + $sep = ''; + foreach(new DirectoryIterator(MYBB_ROOT . $folder) as $file) + { + if($file->isDir() || $file->isDot()) + { + continue; + } + + $extension = pathinfo($file->getFilename(), PATHINFO_EXTENSION); + if(!in_array($extension, array('gif', 'png', 'jpg', 'jpeg'))) + { + continue; + } + + $filenames .= "{$sep}'{$file->getFilename()}'"; + $sep = ','; + } + + if ($settings['footer_text'] && $settings['footer_url']) { + $footer = << + + + + +EOF; + } + + $width = $width * .9; + $folder = $mybb->settings['bburl'] . '/' . $folder; + $$template_var = << + +
+ + + {$footer} +EOF; + + return true; +} + +?> diff --git a/Upload/inc/plugins/asb/modules/staff_online_box.php b/Upload/inc/plugins/asb/modules/staff_online_box.php index f7c3b37..3d93f15 100644 --- a/Upload/inc/plugins/asb/modules/staff_online_box.php +++ b/Upload/inc/plugins/asb/modules/staff_online_box.php @@ -8,9 +8,9 @@ */ // this file may not be executed from outside of script -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("You need MyBB and Advanced Sidebox installed and properly initialized to use this script."); + die('You need MyBB and Advanced Sidebox installed and properly initialized to use this script.'); } /* @@ -32,24 +32,25 @@ function asb_staff_online_box_info() return array( "title" => $lang->asb_staff_online, "description" => $lang->asb_staff_online_desc, - "version" => "1.4.4", + "version" => '1.4.4', + "compatibility" => '2.1', "wrap_content" => true, "xmlhttp" => true, "settings" => array( "max_staff" => array( - "sid" => "NULL", - "name" => "max_staff", + "sid" => 'NULL', + "name" => 'max_staff', "title" => $lang->asb_staff_online_max_staff_title, "description" => $lang->asb_staff_online_max_staff_desc, - "optionscode" => "text", + "optionscode" => 'text', "value" => '5' ), "xmlhttp_on" => array( - "sid" => "NULL", - "name" => "xmlhttp_on", + "sid" => 'NULL', + "name" => 'xmlhttp_on', "title" => $lang->asb_xmlhttp_on_title, "description" => $lang->asb_xmlhttp_on_description, - "optionscode" => "text", + "optionscode" => 'text', "value" => '0' ) ), @@ -58,7 +59,7 @@ function asb_staff_online_box_info() ), "templates" => array( array( - "title" => "asb_staff_online_bit", + "title" => 'asb_staff_online_bit', "template" => << @@ -161,7 +162,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) } // get our setting value - $max_rows = (int) $settings['max_staff']['value']; + $max_rows = (int) $settings['max_staff']; // if max_rows is set to 0 then show nothing if(!$max_rows) @@ -174,7 +175,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) $users = array(); // get all the groups admin has specified should be shown on showteam.php - $query = $db->simple_select("usergroups", "gid, title, usertitle, image", "showforumteam=1", array('order_by' => 'disporder')); + $query = $db->simple_select('usergroups', 'gid, title, usertitle, image', 'showforumteam=1', array('order_by' => 'disporder')); while($usergroup = $db->fetch_array($query)) { // store them in our array @@ -182,7 +183,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) } // get all the users of those specific groups - $groups_in = implode(",", array_keys($usergroups)); + $groups_in = implode(',', array_keys($usergroups)); // if there were no groups . . . if(!$groups_in) @@ -199,10 +200,8 @@ function asb_staff_online_box_get_online_staff($settings, $width) SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup, u.avatar - FROM - " . TABLE_PREFIX . "sessions s - LEFT JOIN - " . TABLE_PREFIX . "users u ON (s.uid=u.uid) + FROM {$db->table_prefix}sessions s + LEFT JOIN {$db->table_prefix}users u ON (s.uid=u.uid) WHERE (displaygroup IN ($groups_in) OR (displaygroup='0' AND usergroup IN ($groups_in))) AND s.time > '{$timesearch}' ORDER BY @@ -264,7 +263,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) // if the user has an avatar then display it, otherwise force the default avatar. $staff_avatar_filename = "{$theme['imgdir']}/default_avatar.gif"; - if($user['avatar'] != "") + if($user['avatar'] != '') { $staff_avatar_filename = $user['avatar']; } diff --git a/Upload/inc/plugins/asb/modules/statistics.php b/Upload/inc/plugins/asb/modules/statistics.php index 909d665..98ff1f7 100644 --- a/Upload/inc/plugins/asb/modules/statistics.php +++ b/Upload/inc/plugins/asb/modules/statistics.php @@ -8,9 +8,9 @@ */ // Include a check for Advanced Sidebox -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -33,20 +33,21 @@ function asb_statistics_info() "title" => $lang->asb_stats, "description" => $lang->asb_stats_desc, "wrap_content" => true, - "version" => "1.2", + "version" => '1.2', + "compatibility" => '2.1', "settings" => array( "format_username" => array( - "sid" => "NULL", - "name" => "format_username", + "sid" => 'NULL', + "name" => 'format_username', "title" => $lang->asb_stats_format_usernames_title, "description" => $lang->asb_stats_format_usernames_desc, - "optionscode" => "yesno", + "optionscode" => 'yesno', "value" => '0' ), ), "templates" => array( array( - "title" => "asb_statistics", + "title" => 'asb_statistics', "template" => << @@ -90,10 +91,10 @@ function asb_statistics_build_template($args) $statistics['numposts'] = my_number_format($statistics['numposts']); $statistics['numusers'] = my_number_format($statistics['numusers']); - $newestmember = "" . $lang->asb_stats_no_one . ""; + $newestmember = "{$lang->asb_stats_no_one}"; if($statistics['lastusername']) { - if($settings['format_username']['value']) + if($settings['format_username']) { $last_user = get_user($statistics['lastuid']); $last_username = format_name($last_user['username'], $last_user['usergroup'], $last_user['displaygroup']); @@ -105,7 +106,7 @@ function asb_statistics_build_template($args) $newestmember = build_profile_link($last_username, $statistics['lastuid']); } - eval("\$" . $template_var . " = \"" . $templates->get("asb_statistics") . "\";"); + eval("\$" . $template_var . " = \"" . $templates->get('asb_statistics') . "\";"); return true; } diff --git a/Upload/inc/plugins/asb/modules/top_poster.php b/Upload/inc/plugins/asb/modules/top_poster.php new file mode 100644 index 0000000..cc46553 --- /dev/null +++ b/Upload/inc/plugins/asb/modules/top_poster.php @@ -0,0 +1,183 @@ +
Please make sure IN_MYBB is defined.'); +} + +/* + * asb_top_poster_info() + * + * provide info to ASB about the addon + * + * @return: (array) the module info + */ +function asb_top_poster_info() +{ + global $lang; + + if(!$lang->asb_addon) + { + $lang->load('asb_addon'); + } + + return array ( + "title" => $lang->asb_top_poster_title, + "description" => $lang->asb_top_poster_desc, + "wrap_content" => true, + "version" => '1.1.3', + "compatibility" => '2.1', + "settings" => array( + "time_frame" => array( + "sid" => 'NULL', + "name" => 'time_frame', + "title" => $lang->asb_top_poster_time_frame_title, + "description" => $lang->asb_top_poster_time_frame_desc, + "optionscode" => "select +1={$lang->asb_top_poster_one_day_title} +7={$lang->asb_top_poster_one_week_title} +14={$lang->asb_top_poster_two_weeks_title} +30={$lang->asb_top_poster_one_month_title} +90={$lang->asb_top_poster_three_months_title} +180={$lang->asb_top_poster_six_months_title} +365={$lang->asb_top_poster_one_year_title}", + "value" => '1' + ), + "avatar_size" => array( + "name" => 'avatar_size', + "title" => $lang->asb_top_poster_avatar_size_title, + "description" => $lang->asb_top_poster_avatar_size_desc, + "optionscode" => 'text', + "value" => '' + ), + ), + "templates" => array( + array( + "title" => 'asb_top_poster', + "template" => << + {\$lang->asb_top_poster_no_avatar}

{\$top_poster_text} + +EOF + ) + ), + ); +} + +/* + * asb_top_poster_build_template() + * + * handles display of children of this addon at page load + * + * @param - $args - (array) the specific information from the child box + * @return: (bool) true on success, false on fail/no content + */ +function asb_top_poster_build_template($args) +{ + extract($args); + global $$template_var, $db, $templates, $lang, $theme; + + if(!$lang->asb_addon) + { + $lang->load('asb_addon'); + } + + if(!$settings['time_frame']) + { + $settings['time_frame'] = 1; + } + $timesearch = TIME_NOW - (86400 * $settings['time_frame']); + + $group_by = 'p.uid'; + if($db->type == 'pgsql') + { + $group_by = $db->build_fields_string('users', 'u.'); + } + + $query = $db->query(<<table_prefix}posts p +LEFT JOIN {$db->table_prefix}users u ON (p.uid=u.uid) +WHERE p.dateline > {$timesearch} +GROUP BY {$group_by} ORDER BY poststoday DESC +LIMIT 1 +EOF +); + + // some defaults + $top_poster = $lang->asb_top_poster_no_one; + $top_poster_posts = $lang->asb_top_poster_no_posts; + $top_poster_text = $lang->asb_top_poster_no_posts; + $ret_val = false; + + // adjust language for time frame + switch ($settings['time_frame']) { + case 7: + $top_poster_timeframe = $lang->asb_top_poster_one_week; + break; + case 14: + $top_poster_timeframe = $lang->asb_top_poster_two_weeks; + break; + case 30: + $top_poster_timeframe = $lang->asb_top_poster_one_month; + break; + case 90: + $top_poster_timeframe = $lang->asb_top_poster_three_months; + break; + case 180: + $top_poster_timeframe = $lang->asb_top_poster_six_months; + break; + case 365: + $top_poster_timeframe = $lang->asb_top_poster_one_year; + break; + default: + $top_poster_timeframe = $lang->asb_top_poster_one_day; + } + + // default to default :p + $top_poster_avatar = "{$theme['imgdir']}/default_avatar.gif"; + $avatar_width = (int) $width * .83; + if((int) $settings['avatar_size']) + { + $avatar_width = (int) $settings['avatar_size']; + } + + $user = $db->fetch_array($query); + + // if we have a user . . . + if($user['poststoday']) + { + // default to guest + $top_poster = $lang->guest; + if($user['uid']) + { + $username = format_name($user['username'], $user['usergroup'], $user['displaygroup']); + $top_poster = build_profile_link($username, $user['uid']); + } + + $top_poster_posts = $user['poststoday']; + + if($user['avatar'] != '') + { + $top_poster_avatar = $user['avatar']; + } + + $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats, $top_poster, $top_poster_timeframe, $top_poster_posts); + $ret_val = true; + } + + eval("\$\$template_var = \"" . $templates->get('asb_top_poster') . "\";"); + + // return true if your box has something to show, or false if it doesn't. + return $ret_val; +} + +?> diff --git a/Upload/inc/plugins/asb/modules/welcome_box.php b/Upload/inc/plugins/asb/modules/welcome_box.php index 5f026fc..4377b33 100644 --- a/Upload/inc/plugins/asb/modules/welcome_box.php +++ b/Upload/inc/plugins/asb/modules/welcome_box.php @@ -33,10 +33,11 @@ function asb_welcome_box_info() "title" => $lang->asb_welcome, "description" => $lang->asb_welcome_desc, "wrap_content" => true, - "version" => "1.3.2", + "version" => '1.3.2', + "compatibility" => '2.1', "templates" => array( array( - "title" => "asb_welcome", + "title" => 'asb_welcome', "template" => << @@ -46,7 +47,7 @@ function asb_welcome_box_info() EOF ), array( - "title" => "asb_welcome_membertext", + "title" => 'asb_welcome_membertext', "template" => <<{\$lang->asb_welcome_member_welcome_lastvisit}: {\$lastvisit}
{\$lang->since_then}
@@ -58,7 +59,7 @@ function asb_welcome_box_info() EOF ), array( - "title" => "asb_welcome_guesttext", + "title" => 'asb_welcome_guesttext', "template" => <<{\$lang->asb_welcome_guest_welcome_registration}

@@ -98,12 +99,12 @@ function asb_welcome_box_build_template($args) { // Get number of new posts, threads, announcements $query = $db->simple_select("posts", "COUNT(pid) AS newposts", "visible=1 AND dateline>'" . $mybb->user['lastvisit'] . "' $unviewwhere"); - $newposts = $db->fetch_field($query, "newposts"); + $newposts = $db->fetch_field($query, 'newposts'); if($newposts) { // If there aren't any new posts, there is no point in wasting two more queries - $query = $db->simple_select("threads", "COUNT(tid) AS newthreads", "visible=1 AND dateline>'" . $mybb->user['lastvisit'] . "' $unviewwhere"); - $newthreads = $db->fetch_field($query, "newthreads"); + $query = $db->simple_select('threads', 'COUNT(tid) AS newthreads', "visible=1 AND dateline>'{$mybb->user['lastvisit']}' {$unviewwhere}"); + $newthreads = $db->fetch_field($query, 'newthreads'); $announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']); if(is_array($announcementsfids)) @@ -114,8 +115,8 @@ function asb_welcome_box_build_template($args) } $announcementsfids = implode(',', $fid_array); - $query = $db->simple_select("threads", "COUNT(tid) AS newann", "visible=1 AND dateline>'" . $mybb->user['lastvisit'] . "' AND fid IN (" . $announcementsfids . ") $unviewwhere"); - $newann = $db->fetch_field($query, "newann"); + $query = $db->simple_select('threads', 'COUNT(tid) AS newann', "visible=1 AND dateline>'{$mybb->user['lastvisit']}' AND fid IN ({$announcementsfids}) {$unviewwhere}"); + $newann = $db->fetch_field($query, 'newann'); } if(!$newthreads) @@ -165,7 +166,7 @@ function asb_welcome_box_build_template($args) // if the user has an avatar then display it, otherwise force the default avatar. $avatar_filename = "{$theme['imgdir']}/default_avatar.gif"; - if($mybb->user['avatar'] != "") + if($mybb->user['avatar'] != '') { $avatar_filename = $mybb->user['avatar']; } @@ -194,11 +195,11 @@ function asb_welcome_box_build_template($args) $username = $lang->username; break; } - eval("\$welcometext = \"" . $templates->get("asb_welcome_guesttext") . "\";"); + eval("\$welcometext = \"" . $templates->get('asb_welcome_guesttext') . "\";"); } $lang->welcome = $lang->sprintf($lang->welcome, $mybb->user['username']); - eval("\$" . $template_var . " = \"" . $templates->get("asb_welcome") . "\";"); + eval("\$" . $template_var . " = \"" . $templates->get('asb_welcome') . "\";"); return true; } diff --git a/Upload/inc/plugins/asb/modules/whosonline.php b/Upload/inc/plugins/asb/modules/whosonline.php index 27ec726..bcb20a2 100644 --- a/Upload/inc/plugins/asb/modules/whosonline.php +++ b/Upload/inc/plugins/asb/modules/whosonline.php @@ -8,9 +8,9 @@ */ // Include a check for Advanced Sidebox -if(!defined("IN_MYBB") || !defined("IN_ASB")) +if(!defined('IN_MYBB') || !defined('IN_ASB')) { - die("Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined."); + die('Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.'); } /* @@ -32,7 +32,8 @@ function asb_whosonline_info() return array( "title" => $lang->asb_wol, "description" => $lang->asb_wol_desc, - "version" => "1.4.4", + "version" => '1.4.4', + "compatibility" => '2.1', "wrap_content" => true, "xmlhttp" => true, "settings" => array( @@ -194,8 +195,12 @@ function asb_whosonline_get_online_members($settings, $width) $all_users = array(); // width - $rowlength = (int) $settings['asb_avatar_per_row']['value']; - $max_rows = (int) $settings['asb_avatar_max_rows']['value']; + $rowlength = (int) $settings['asb_avatar_per_row']; + if ($rowlength == 0) { + return false; + } + + $max_rows = (int) $settings['asb_avatar_max_rows']; $row = 1; $avatar_count = 0; $enough_already = false; @@ -211,22 +216,22 @@ function asb_whosonline_get_online_members($settings, $width) $onlinemembers = ''; $query = $db->write_query(" SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup, u.avatar, u.avatardimensions - FROM " . TABLE_PREFIX . "sessions s - LEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid) - WHERE s.time > '$timesearch' + FROM {$db->table_prefix}sessions s + LEFT JOIN {$db->table_prefix}users u ON (s.uid=u.uid) + WHERE s.time > '{$timesearch}' ORDER BY u.username ASC, s.time DESC "); while($user = $db->fetch_array($query)) { // create a key to test if this user is a search bot. - $botkey = my_strtolower(str_replace("bot=", '', $user['sid'])); + $botkey = my_strtolower(str_replace('bot=', '', $user['sid'])); - if($user['uid'] == "0") + if($user['uid'] == '0') { ++$guestcount; } - elseif(my_strpos($user['sid'], "bot=") !== false && $session->bots[$botkey]) + elseif(my_strpos($user['sid'], 'bot=') !== false && $session->bots[$botkey]) { // The user is a search bot. $onlinemembers .= format_name($session->bots[$botkey], $session->botgroup); @@ -256,10 +261,10 @@ function asb_whosonline_get_online_members($settings, $width) { $user['profilelink'] = get_profile_link($user['uid']); - if($settings['show_avatars']['value']) + if($settings['show_avatars']) { // If the user has an avatar then display it . . . - if($user['avatar'] != "") + if($user['avatar'] != '') { $avatar_filename = $user['avatar']; } @@ -271,11 +276,11 @@ function asb_whosonline_get_online_members($settings, $width) $avatar_height_style = " min-height: {$avatar_height}px; max-height: {$avatar_height}px;"; $avatar_width_style = " min-width: {$avatar_width}px; max-width: {$avatar_width}px;"; - if($settings['asb_avatar_maintain_aspect']['value']) + if($settings['asb_avatar_maintain_aspect']) { // Check the avatar's dimensions, then constrain it by its largest dimension $avatar_dimensions = explode('|', $user['avatardimensions']); - + if($avatar_dimensions[0] > $avatar_dimensions[1]) { $avatar_height_style = ''; @@ -308,12 +313,12 @@ function asb_whosonline_get_online_members($settings, $width) // . . . otherwise, add it to the list else { - eval("\$onlinemembers .= \"" . $templates->get("asb_whosonline_memberbit_avatar", 1, 0) . "\";"); + eval("\$onlinemembers .= \"" . $templates->get('asb_whosonline_memberbit_avatar', 1, 0) . "\";"); // If we reach the end of the row, insert a
if(($membercount - (($row - 1) * $rowlength)) == $rowlength) { - $onlinemembers .= ""; + $onlinemembers .= ''; ++$row; } ++$avatar_count; @@ -322,7 +327,7 @@ function asb_whosonline_get_online_members($settings, $width) else { $user['username'] = format_name(trim($user['username']), $user['usergroup'], $user['displaygroup']); - eval("\$onlinemembers .= \"" . $templates->get("asb_whosonline_memberbit_name", 1, 0) . "\";"); + eval("\$onlinemembers .= \"" . $templates->get('asb_whosonline_memberbit_name', 1, 0) . "\";"); $sep = $lang->comma . ' '; } } @@ -333,7 +338,7 @@ function asb_whosonline_get_online_members($settings, $width) } } - if(!$settings['show_avatars']['value']) + if(!$settings['show_avatars']) { $onlinemembers = '' . $onlinemembers . ''; } @@ -352,7 +357,7 @@ function asb_whosonline_get_online_members($settings, $width) } // Most users online - $mostonline = $cache->read("mostonline"); + $mostonline = $cache->read('mostonline'); if($onlinecount > $mostonline['numusers']) { $time = TIME_NOW; @@ -376,7 +381,7 @@ function asb_whosonline_get_online_members($settings, $width) if($membercount) { - eval("\$onlinemembers = \"" . $templates->get("asb_whosonline") . "\";"); + eval("\$onlinemembers = \"" . $templates->get('asb_whosonline') . "\";"); return $onlinemembers; } else diff --git a/Upload/jscripts/asb/Slideshow.js b/Upload/jscripts/asb/Slideshow.js new file mode 100644 index 0000000..d28d7fe --- /dev/null +++ b/Upload/jscripts/asb/Slideshow.js @@ -0,0 +1,520 @@ +/* + * Plugin Name: Advanced Sidebox for MyBB 1.6.x + * Copyright 2014 WildcardSearch + * http://www.rantcentralforums.com + * + * this file contains a module for the Slideshow box addon as well as + * some helpers (Timers/Effects) + */ + +var ASB = (function(a) { + + /** + * Effect + * + * an object containing element effects processing functions + */ + var Effect = (function() { + + /** + * Timer + * + * an object containing timeframe handling for effects + */ + var Timer = (function() { + + /** + * Timer() + * + * the timer object's constructor + * + * @param - effect - (Object) the original effect + * @param - options - (Object) effects options + * @return void + */ + function Timer(effect, options) { + this.options = options; + + // make sure we have work to do + if (this.options.from == this.options.to) { + return; + } + + // calculate timing + this.totalFrames = this.options.duration * this.options.fps; + this.interval = (1 / this.options.fps) * 1000; + this.increment = (this.options.to - this.options.from) / (this.totalFrames - 1); + + // the original effect object + this.effect = effect; + + // a little more setup + this.running = true; + this.currentFrame = 0; + this.value = this.options.from; + + // begin the timing + this.run(); + Event.observe(window, 'unload', this.stop.bindAsEventListener(this)); + } + + /* + * run() + * + * sets timer to go another round + * + * @return void + */ + function run() { + this.timeOutId = window.setTimeout(this.update.bind(this), this.interval); + } + + /** + * stop() + * + * end the timer + * + * @return - void + */ + function stop() { + window.clearTimeout(this.timeOutId); + } + + /* + * update() + * + * increment the internal value, run the effect hook and either + * continue or end the cycle + * + * @return - void + */ + function update() { + this.currentFrame++; + this.value += this.increment; + this.effect.runHook('update', [this.value]); + + if (this.currentFrame < this.totalFrames) { + this.run(); + } else { + this.running = false; + this.value = this.options.to; + this.effect.runHook('update', [this.value]); + this.effect.runHook('finish'); + } + } + + Timer.prototype = { + run: run, + stop: stop, + update: update, + }; + + return Timer; + })(), + + /** + * Base + * + * an object containing basic effect functionality and a bridge to the timer + */ + Base = (function() { + var baseOptions = { + to: 0, + duration: 1, + fps: 66, + }; + + /** + * initialize() + * + * format options, attach to element, run effect hooks and the timer + * + * @param - element - (String) the id of the element to affect + * @param - options - (Object) settings for the effect + * @return - void + */ + function initialize(element, options) { + if (!element || !$(element)) { + return; + } + + this.element = $(element); + this.options = Object.extend(Object.extend({}, baseOptions), options || {}); + + this.runHook('setup'); + this.timer = new Timer(this, this.options); + } + + /** + * runHook() + * + * @param - hook - (String) the effect function to call + * @param - args - (Array) the arguments to pass to the function + * @return - void + */ + function runHook(hook, args) { + if (typeof this[hook] === 'function') { + this[hook].apply(this, args || []); + } + } + + /** + * isRunning() + * + * a shortcut to determining if the Timer object is currently engaged + * + * @return - (Boolean) true if running, false if not + */ + function isRunning() { + return this.timer.running; + } + + /** + * forceRender() + * + * borrowed from the scriptaculous library, this helps to force the + * browser to render the element at each interval + * + * @return - void + */ + function forceRender() { + try { + var n = document.createTextNode(' '); + this.element.appendChild(n); + this.element.removeChild(n); + } catch(e) {} + } + + // this object will be used to create any effects + return { + baseOptions: baseOptions, + init: initialize, + runHook: runHook, + isRunning: isRunning, + forceRender: forceRender, + }; + })(), + + /** + * Fade + * + * an effect that changes opacity from one value to another over + * a range of time + */ + Fade = (function(b) { + /** + * Fade() + * + * the constructor-- simply calls Base.init() + * + * @param - element - (String) the id of the element to affect + * @param - options - (Object) settings for the effect + * @return - void + */ + function Fade(element, options) { + this.init(element, options); + } + + /** + * setup() + * + * called just after options have been checked and just before + * the timer is initiated + * + * @return - void + */ + function setup() { + if (this.options.from == undefined) { + this.options.from = this.element.getOpacity(); + } + this.element.setOpacity(this.options.from).show(); + } + + /** + * update() + * + * called each time the timer interval runs out + * + * @param - value - (mixed) the current value at this frame + * @return - void + */ + function update(value) { + this.element.setOpacity(value); + } + + /** + * finish() + * + * called when the effect is complete + * + * @return - void + */ + function finish() { + if (this.options.to == 0) { + this.element.hide().setOpacity(this.options.from); + } + this.forceRender(); + } + + Fade.prototype = Object.extend({ + setup: setup, + update: update, + finish: finish, + }, b); + + return Fade; + })(Base); + + return { + Timer: Timer, + Base: Base, + Fade: Fade, + }; + })(); + + /** + * Slideshow() + * + * constructor for slideshow objects-- commandeers an element and cycles + * through a defined set of images using configurable options + * + * @param - container - (String) the id of the containing
+ * @param - options - (Object) settings for the object + * @return - void + */ + function Slideshow(container, options) { + if (!$(container)) { + return; + } + + this.options = { + rate: 10, + shuffle: false, + fadeRate: 1, + size: 100, + }; + Object.extend(this.options, options || {}); + + // set up the container + this.container = $(container); + this.container.setStyle({ + width: this.options.size + 'px', + height: this.options.size + 'px', + marginLeft: 'auto', + marginRight: 'auto', + position: 'relative', + }); + + // no images, no have slideshow + if (!this.options.images || this.options.images.length == 0) { + return; + } + + this.current = 0; + if (this.options.shuffle) { + this.options.images.sort(function() { + return 0.5 - Math.random(); + }); + } + + // create the main image holder, set it up and insert it into the container + this.mainImage = new Element('img', { + src: this.getCurrentImage(), + }).setStyle({ + display: 'none', + position: 'absolute', + width: this.options.size + 'px', + left: '0px', + top: '0px', + }); + this.container.insert(this.mainImage); + + // clone the main image, store it as a buffer and insert it into the container + this.bufferImage = this.mainImage.clone(); + this.container.insert(this.bufferImage); + + this.cloneWidth = this.cloneHeight = 0; + + /** + * get things going and begin cycling when the page loads + * and end when the user leaves + */ + this.showCurrent(); + Event.observe(window, 'load', this.run.bindAsEventListener(this)); + Event.observe(window, 'unload', this.stop.bindAsEventListener(this)); + } + + /** + * run() + * + * ready the slideshow to go another round + * + * @return - void + */ + function run() { + this.timeOutId = window.setTimeout(this.showNext.bind(this), this.options.rate * 1000); + } + + /** + * stop() + * + * end the slideshow + * + * @return - void + */ + function stop() { + window.clearTimeout(this.timeOutId); + } + + /** + * getCurrentImage() + * + * build the image file name + * + * @return - (String) + */ + function getCurrentImage() { + return this.options.folder ? + this.options.folder + '/' + this.options.images[this.current] : + this.options.images[this.current]; + } + + /** + * nextImage() + * + * do the buffer swap and cycle to the next image + * + * @return - void + */ + function nextImage() { + this.bufferImage.src = this.mainImage.src; + this.resizeImage(this.bufferImage).show(); + this.mainImage.hide(); + + this.current++; + if (this.options.images.length <= this.current) { + this.current = 0; + } + } + + /** + * showCurrent() + * + * load the current image and perform the transition + * + * @return - void + */ + function showCurrent() { + this.mainImage.src = this.getCurrentImage(); + + /* + * clone the main image and display it off-screen in order to + * get the correct size + */ + this.clone = new Element('img', { + src: this.mainImage.src, + }).setStyle({ + position: 'absolute', + top: '-9999px', + display: 'block', + }); + $$('body')[0].insert(this.clone); + this.clone.observe('load', this.resize.bindAsEventListener(this)); + + // fade in the new image + new Effect.Fade(this.mainImage, { + from: 0, + to: 1, + duration: this.options.fadeRate, + }); + + // if we have already initialized, fade out the old image + if (this.running) { + new Effect.Fade(this.bufferImage, { + from: 1, + to: 0, + duration: this.options.fadeRate, + }); + } + this.running = true; + } + + /** + * resize() + * + * when the clone loads, get its dimensions and use them to resize the + * main image + * + * @return - void + */ + function resize(e) { + var height = this.clone.getHeight(), + width = this.clone.getWidth(), + ratio; + + // maintain the ratio + if (height > width) { + ratio = height / width; + this.cloneWidth = parseInt(this.options.size / ratio); + this.cloneHeight = this.options.size; + } else { + ratio = width / height; + this.cloneWidth = this.options.size; + this.cloneHeight = parseInt(this.options.size / ratio); + } + + this.clone.remove(); + this.resizeImage(this.mainImage); + } + + /** + * resizeImage() + * + * apply the stored dimensions to a given element + * + * @param - el - (Object) the DOM Element Object + * @return - (Object) the DOM Element Object + */ + function resizeImage(el) { + el.setStyle({ + height: this.cloneHeight + 'px', + width: this.cloneWidth + 'px', + left: parseInt((this.options.size / 2) - (this.cloneWidth / 2)) + 'px', + top: parseInt((this.options.size / 2) - (this.cloneHeight / 2)) + 'px', + }); + return el; + } + + /** + * showNext() + * + * called cyclically to advance to the next image and restart the timer + * + * @param - el - (Object) the DOM Element Object + * @return - (Object) the DOM Element Object + */ + function showNext() { + if (this.container.offsetWidth > 0) { + this.nextImage(); + this.showCurrent(); + } + this.run(); + } + + Slideshow.prototype = { + run: run, + stop: stop, + showCurrent: showCurrent, + getCurrentImage: getCurrentImage, + nextImage: nextImage, + showNext: showNext, + resize: resize, + resizeImage: resizeImage, + }; + + a.modules = Object.extend({ + Slideshow: Slideshow, + }, a.modules || {}); + + return a; +})(ASB || {}); diff --git a/Upload/jscripts/asb/Slideshow.min.js b/Upload/jscripts/asb/Slideshow.min.js new file mode 100644 index 0000000..f0aa224 --- /dev/null +++ b/Upload/jscripts/asb/Slideshow.min.js @@ -0,0 +1,32 @@ +var ASB=(function(a){var Effect=(function(){var Timer=(function(){function Timer(effect,options){this.options=options;if(this.options.from==this.options.to){return;} +this.totalFrames=this.options.duration*this.options.fps;this.interval=(1/this.options.fps)*1000;this.increment=(this.options.to-this.options.from)/(this.totalFrames-1);this.effect=effect;this.running=true;this.currentFrame=0;this.value=this.options.from;this.run();Event.observe(window,'unload',this.stop.bindAsEventListener(this));} +function run(){this.timeOutId=window.setTimeout(this.update.bind(this),this.interval);} +function stop(){window.clearTimeout(this.timeOutId);} +function update(){this.currentFrame++;this.value+=this.increment;this.effect.runHook('update',[this.value]);if(this.currentFramewidth){ratio=height/width;this.cloneWidth=parseInt(this.options.size/ratio);this.cloneHeight=this.options.size;}else{ratio=width/height;this.cloneWidth=this.options.size;this.cloneHeight=parseInt(this.options.size/ratio);} +this.clone.remove();this.resizeImage(this.mainImage);} +function resizeImage(el){el.setStyle({height:this.cloneHeight+'px',width:this.cloneWidth+'px',left:parseInt((this.options.size/2)-(this.cloneWidth/2))+'px',top:parseInt((this.options.size/2)-(this.cloneHeight/2))+'px',});return el;} +function showNext(){if(this.container.offsetWidth>0){this.nextImage();this.showCurrent();} +this.run();} +Slideshow.prototype={run:run,stop:stop,showCurrent:showCurrent,getCurrentImage:getCurrentImage,nextImage:nextImage,showNext:showNext,resize:resize,resizeImage:resizeImage,};a.modules=Object.extend({Slideshow:Slideshow,},a.modules||{});return a;})(ASB||{}); \ No newline at end of file diff --git a/Upload/jscripts/asb.js b/Upload/jscripts/asb/asb.js similarity index 85% rename from Upload/jscripts/asb.js rename to Upload/jscripts/asb/asb.js index 51b3e01..63a9524 100644 --- a/Upload/jscripts/asb.js +++ b/Upload/jscripts/asb/asb.js @@ -6,7 +6,7 @@ * this file contains handlers for the side box toggle icon scripts */ -ASBColumns = { +(function() { /** * init() * @@ -14,18 +14,17 @@ ASBColumns = { * * @return: n/a */ - init: function() - { + function init() { if ($('asb_hide_column_left')) { // left show/hide icon click - $('asb_hide_column_left').observe('click', ASBColumns.toggle); + $('asb_hide_column_left').observe('click', toggle); } if ($('asb_hide_column_right')) { // left show/hide icon click - $('asb_hide_column_right').observe('click', ASBColumns.toggle); + $('asb_hide_column_right').observe('click', toggle); } - }, + } /** * toggle() @@ -36,8 +35,7 @@ ASBColumns = { * @param - event - (Event) the click event object * @return: n/a */ - toggle: function(event) - { + function toggle(event) { // the link does nothing if JS is deactivated and until the page has fully loaded Event.stop(event); @@ -68,5 +66,5 @@ ASBColumns = { Cookie.unset(cookieName); } } -}; -Event.observe(window, 'load', ASBColumns.init); + Event.observe(window, 'load', init); +})(); diff --git a/Upload/jscripts/asb/asb.min.js b/Upload/jscripts/asb/asb.min.js new file mode 100644 index 0000000..fe247ec --- /dev/null +++ b/Upload/jscripts/asb/asb.min.js @@ -0,0 +1,5 @@ +(function(){function init(){if($('asb_hide_column_left')){$('asb_hide_column_left').observe('click',toggle);} +if($('asb_hide_column_right')){$('asb_hide_column_right').observe('click',toggle);}} +function toggle(event){Event.stop(event);var position='left';if(this.id=='asb_hide_column_right'){position='right';} +var cookieName='asb_hide_'+position,column=$('asb_'+position+'_column_id'),closeIcon=$('asb_'+position+'_close'),openIcon=$('asb_'+position+'_open');var hide=Cookie.get(cookieName);if(hide==0||hide==undefined){column.style.display='none';closeIcon.style.display='none';openIcon.style.display='inline';Cookie.set(cookieName,1);}else{column.style.display='';closeIcon.style.display='inline';openIcon.style.display='none';Cookie.unset(cookieName);}} +Event.observe(window,'load',init);})(); \ No newline at end of file diff --git a/Upload/jscripts/asb_xmlhttp.js b/Upload/jscripts/asb/asb_xmlhttp.js similarity index 75% rename from Upload/jscripts/asb_xmlhttp.js rename to Upload/jscripts/asb/asb_xmlhttp.js index 4f2f261..d1909cd 100644 --- a/Upload/jscripts/asb_xmlhttp.js +++ b/Upload/jscripts/asb/asb_xmlhttp.js @@ -9,10 +9,7 @@ */ // thanks to http://www.fluther.com/users/adrianscott/ -Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, -{ - phpTimeDiff: 0, - +var ASB = (function(a) { /** * initialize() * @@ -24,8 +21,7 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, * @param - options - (object) various options for the updater * @return: n/a */ - initialize: function($super, container, url, options) - { + function initialize($super, container, url, options) { // set up our parent object $super(options); @@ -42,7 +38,7 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, // initiate the timer this.start(); - }, + } /** * start() @@ -51,11 +47,10 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, * * @return: n/a */ - start: function() - { + function start() { this.options.onComplete = this.updateComplete.bind(this); this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, + } /** * stop() @@ -64,12 +59,11 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, * * @return: n/a */ - stop: function() - { + function stop() { this.updater.options.onComplete = undefined; clearTimeout(this.timer); (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, + } /** * updateComplete() @@ -79,8 +73,7 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, * @param - response - (Response) the XMLHTTP response object * @return: n/a */ - updateComplete: function(response) - { + function updateComplete(response) { // good response? if (response.responseText && response.responseText != 'nochange') { // might add this option later @@ -99,7 +92,7 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, // key up to do it again this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, + } /** * onTimerEvent() @@ -108,8 +101,7 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, * * @return: n/a */ - onTimerEvent: function() - { + function onTimerEvent() { // don't update collapsed side boxes (thanks again, Destroy666) if (this.container.offsetWidth <= 0 && this.container.offsetHeight <= 0) { // just reset the timer and get out @@ -120,31 +112,40 @@ Ajax.SideboxPeriodicalUpdater = Class.create(Ajax.Base, // and finally, this is what we are doing every {rate} seconds this.updater = new Ajax.Request(this.url, this.options); } -}); -/* - * asbBuildUpdaters() - * - * prepare the Updater objects - * - * @param - updaters - (array) an array filled with objects filled with side box details - * @param - widths - (object) widths for both positions - * @return: n/a - */ -function asbBuildUpdaters(updaters, widths) -{ - // no objects in the array - if (updaters.length == 0) { - // get out - return; - } + SideboxUpdater = Class.create(Ajax.Base, { + initialize: initialize, + start: start, + stop: stop, + updateComplete: updateComplete, + onTimerEvent: onTimerEvent, + }); - var this_id = '', width = 0; - for (var i = 0; i < updaters.length; i++) { - // build the element ID - this_id = updaters[i].addon + '_main_' + updaters[i].id; + /* + * buildUpdaters() + * + * prepare the Updater objects + * + * @param - updaters - (array) an array filled with objects filled with side box details + * @param - widths - (object) widths for both positions + * @return: n/a + */ + function buildUpdaters(updaters, widths, script) { + // no objects in the array + if (updaters.length == 0) { + // get out + return; + } + + var this_id = '', width = 0; + for (var i = 0; i < updaters.length; i++) { + // build the element ID + this_id = updaters[i].addon + '_main_' + updaters[i].id; + + if (!$(this_id)) { + continue; + } - if ($(this_id)) { // get the correct width width = widths.left; if (updaters[i].position) { @@ -152,19 +153,24 @@ function asbBuildUpdaters(updaters, widths) } // this object will only update when a valid response is received - new Ajax.SideboxPeriodicalUpdater(this_id, 'xmlhttp.php', - { - parameters: - { + new SideboxUpdater(this_id, 'xmlhttp.php', { + parameters: { action: 'asb', id: updaters[i].id, addon: updaters[i].addon, dateline: updaters[i].dateline, - width: width + width: width, + script: script, }, method: 'get', frequency: updaters[i].rate }); } } -} + + a.ajax = { + buildUpdaters: buildUpdaters, + }; + + return a; +})(ASB || {}); diff --git a/Upload/jscripts/asb/asb_xmlhttp.min.js b/Upload/jscripts/asb/asb_xmlhttp.min.js new file mode 100644 index 0000000..56a770c --- /dev/null +++ b/Upload/jscripts/asb/asb_xmlhttp.min.js @@ -0,0 +1,12 @@ +var ASB=(function(a){function initialize($super,container,url,options){$super(options);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||30);this.decay=this.options.decay=(this.options.decay||1);this.updater={};this.container=$(container).down('tbody');this.url=url;this.phpTimeDiff=Math.floor(this.options.parameters.dateline-(new Date().getTime()/1000));this.start();} +function start(){this.options.onComplete=this.updateComplete.bind(this);this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency);} +function stop(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);} +function updateComplete(response){if(response.responseText&&response.responseText!='nochange'){this.decay=this.options.decay;this.container.update(response.responseText);}else{this.decay=this.decay*this.options.decay;} +this.options.parameters.dateline=Math.floor(new Date().getTime()/1000+this.phpTimeDiff);this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency);} +function onTimerEvent(){if(this.container.offsetWidth<=0&&this.container.offsetHeight<=0){this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency);return;} +this.updater=new Ajax.Request(this.url,this.options);} +SideboxUpdater=Class.create(Ajax.Base,{initialize:initialize,start:start,stop:stop,updateComplete:updateComplete,onTimerEvent:onTimerEvent,});function buildUpdaters(updaters,widths,script){if(updaters.length==0){return;} +var this_id='',width=0;for(var i=0;i